File tree 4 files changed +223
-178
lines changed
vendor/assets/javascripts
4 files changed +223
-178
lines changed Original file line number Diff line number Diff line change 1
1
# Place all the behaviors and hooks related to the matching controller here.
2
2
# All this logic will automatically be available in application.js.
3
3
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4
- # = require showdown
4
+ # = require marked
5
+ # = require highlight/highlight
6
+ # = require highlight/language
5
7
# = require blur
6
8
# = require jquery.filedrop
7
9
# = require jquery.textselection
31
33
if event .keyCode == 13
32
34
search (null )
33
35
36
+ enablePreviewEditing ()
37
+
34
38
35
39
window .initializeProtip = ->
36
40
if inEditMode = $ (" .x-tip-content.preview" ).length > 0
@@ -344,3 +348,16 @@ toggleCommentEditMode = (comment)->
344
348
comment .children (' p' ).first ().toggleClass (' hidden' )
345
349
comment .find (' .edit-comment' ).toggleClass (' hidden' )
346
350
comment .siblings (' ul.edit-del' ).toggleClass (' hidden' )
351
+
352
+ marked .setOptions highlight : (code ) ->
353
+ hljs .highlightAuto (code).value
354
+
355
+ enablePreviewEditing = ->
356
+ if $ (' .preview-body' ).length > 0
357
+ updatePreview = ->
358
+ markdown = marked $ (' #protip_body' ).val (), gfm : true
359
+ $ (' .preview-body' ).html markdown
360
+
361
+ $ (' #protip_body' ).on ' keyup' , updatePreview
362
+
363
+ updatePreview ()
You can’t perform that action at this time.
0 commit comments