Skip to content

Commit

Permalink
Still thinking how to do this shit
Browse files Browse the repository at this point in the history
  • Loading branch information
alagu committed May 5, 2013
1 parent adb6b65 commit 497afd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
16 changes: 10 additions & 6 deletions lib/pagoda/public/js/showdown-live.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# Add onclick listener.
class ShowdownLive
constructor: (@selector)->
@selector = $(@selector)
# Hide the textarea
width = $(@selector).width()
height = $(@selector).height()
$(@selector).css('display', 'none')
width = @selector.width()
height = @selector.height()
@selector.css('display', 'none')

# Insert a live node
@livenode = $('<div contenteditable="true" class="showdown-live"></div>')
Expand All @@ -28,17 +29,20 @@ class ShowdownLive

# Put HTML inside livenode
converter = new Showdown.converter();
html = converter.makeHtml($(@selector).val());
html = converter.makeHtml(@selector.val());
@livenode.html(html)

@log "Initing #{@selector} as ShowdownLive"
@log "Initing ##{@selector.attr('id')} as ShowdownLive"

keyhandle: (e) =>
shdlv_html = @livenode.html()
shdlv_html = shdlv_html.replace(/<p>/g,"\n")
shdlv_html = shdlv_html.replace(/<\/p>/g,"\n")
shdlv_html = shdlv_html.replace(/<br>/g,"\n")
$(@selector).val(shdlv_html)

lines = @selector.val().split("\n")
@log lines


log: (message)->
console.log message
Expand Down
16 changes: 9 additions & 7 deletions lib/pagoda/public/js/showdown-live.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 497afd6

Please sign in to comment.