Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.DS_Store

/node_modules/*
!/node_modules/.bin
/node_modules/.bin/*
!/node_modules/htmlmd*
!/node_modules/htmltojsx*
npm-debug.log
spec/**/*.*
7 changes: 7 additions & 0 deletions lib/build-text-editor.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TextEditor = null
module.exports = (params) ->
if atom.workspace.buildTextEditor?
atom.workspace.buildTextEditor(params)
else
TextEditor ?= require("atom").TextEditor
new TextEditor(params)
46 changes: 23 additions & 23 deletions lib/panel-view.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{TextEditor} = require 'atom'
buildTextEditor = require './build-text-editor'
{$, ScrollView} = require 'atom-space-pen-views'

module.exports =
class PanelView extends ScrollView
constructor: (@title,@src,@grammar)->
@editor = new TextEditor mini:false
@editor = buildTextEditor mini:false
@attach()
super

Expand Down Expand Up @@ -35,29 +35,29 @@ class PanelView extends ScrollView
@editor

dragStart: (evt,ele)->
view = @view()
editorHeight = view.find('atom-text-editor').height()
top = view.parent().position().top
ht = view.height()
width = view.width()
view.css position :'fixed'
view.css top: evt.pageY
view.css width: width
view.css 'max-height', ''
view.css height: ht
$(document).mousemove (evt,ele)=>
view = @view()
editorHeight = view.find('atom-text-editor').height()
top = view.parent().position().top
ht = view.height()
width = view.width()
view.css position :'fixed'
view.css top: evt.pageY
view.css width: width
view.css 'max-height', ''
view.css height: ht
$(document).mousemove (evt,ele)=>
view = @view()
view.css top: evt.pageY
height = ht + top - evt.pageY
height = height * -1 if height < 0
textEditorHeight = editorHeight + top - evt.pageY
textEditorHeight = textEditorHeight * -1 if textEditorHeight < 0
view.find('atom-text-editor').css height: textEditorHeight
view.css height: height
$(document).mouseup (evt,ele)=>
view = @view().view()
view.css position :'static'
$(document).unbind('mousemove')
height = ht + top - evt.pageY
height = height * -1 if height < 0
textEditorHeight = editorHeight + top - evt.pageY
textEditorHeight = textEditorHeight * -1 if textEditorHeight < 0
view.find('atom-text-editor').css height: textEditorHeight
view.css height: height
$(document).mouseup (evt,ele)=>
view = @view().view()
view.css position :'static'
$(document).unbind('mousemove')

attach: ->
$(document).keyup (e)=>
Expand Down
26 changes: 13 additions & 13 deletions lib/preview-plus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ module.exports =
@previewStatus.live.toggleClass 'on'

toggleHTML: ->
atom.config.set 'preview-plus.htmlp', !atom.config.get 'preview-plus.htmlp'
if editor = atom.workspace.getActiveTextEditor()
key = @getGrammar editor
if atom.config.get('preview-plus.htmlp')
@previewStatus.updateCompileTo('htmlp') if 'htmlp' in @config[key]["enum"]
else
@previewStatus.updateCompileTo atom.config.get "preview-plus.#{key}"
atom.config.set 'preview-plus.htmlp', !atom.config.get 'preview-plus.htmlp'
if editor = atom.workspace.getActiveTextEditor()
key = @getGrammar editor
if atom.config.get('preview-plus.htmlp')
@previewStatus.updateCompileTo('htmlp') if 'htmlp' in @config[key]["enum"]
else
@previewStatus.updateCompileTo atom.config.get "preview-plus.#{key}"

showConfig: ->
# srcdir = atom.project.get('preview-plus.srcdir')
Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports =
@subscriptions = new CompositeDisposable()
idx = null
itemSets = atom.contextMenu.itemSets
contextMenu = _.find itemSets, (item,itemIdx)->
contextMenu = _.find itemSets, (item,itemIdx) ->
idx = itemIdx
item.items[0]?.command is 'preview-plus:preview'

Expand Down Expand Up @@ -179,11 +179,11 @@ module.exports =
@preview editor,fpath,error,true

getContent: (tag,text)->
regex = new RegExp("<pp-#{tag}>([\\s\\S]*?)</pp-#{tag}>")
match = text.match(regex)
if match? and match[1].trim()
data = loophole.allowUnsafeEval ->
eval "(#{match[1]})"
regex = new RegExp("<pp-#{tag}>([\\s\\S]*?)</pp-#{tag}>")
match = text.match(regex)
if match? and match[1].trim()
data = loophole.allowUnsafeEval ->
eval "(#{match[1]})"

preview: (editor,fpath,text,err=false)->
activePane = atom.workspace.paneForItem(editor)
Expand Down