Markdown editor for DraftVersion body
This commit is contained in:
@@ -46,6 +46,8 @@
|
||||
//= require embed_video
|
||||
//= require banners
|
||||
//= require social_share
|
||||
//= require markdown-it
|
||||
//= require markdown_editor
|
||||
//= require custom
|
||||
|
||||
var initialize_modules = function() {
|
||||
@@ -68,6 +70,7 @@ var initialize_modules = function() {
|
||||
App.EmbedVideo.initialize();
|
||||
App.Banners.initialize();
|
||||
App.SocialShare.initialize();
|
||||
App.MarkdownEditor.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
|
||||
20
app/assets/javascripts/markdown_editor.js.coffee
Normal file
20
app/assets/javascripts/markdown_editor.js.coffee
Normal file
@@ -0,0 +1,20 @@
|
||||
App.MarkdownEditor =
|
||||
|
||||
refresh_preview: (element, md) ->
|
||||
textarea_content = element.find('textarea').val()
|
||||
result = md.render(textarea_content)
|
||||
element.find('#markdown-preview').html(result)
|
||||
|
||||
initialize: ->
|
||||
$('.markdown-editor').each ->
|
||||
md = window.markdownit({
|
||||
html: true,
|
||||
breaks: true,
|
||||
typographer: true,
|
||||
})
|
||||
App.MarkdownEditor.refresh_preview($(this), md)
|
||||
$(this).on 'change input paste keyup', ->
|
||||
App.MarkdownEditor.refresh_preview($(this), md)
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user