diff --git a/README.md b/README.md index d76ece3..00a7cf6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This is a jQuery plugin. ## Requirements -* Bootstrap 3 +* Bootstrap 4 * jQuery * Ace editor (http://ace.c9.io) diff --git a/dist/css/bootstrap-markdown-editor.css b/dist/css/bootstrap-markdown-editor.css index db5fd78..4872a6d 100644 --- a/dist/css/bootstrap-markdown-editor.css +++ b/dist/css/bootstrap-markdown-editor.css @@ -1,6 +1,6 @@ /*! * Bootstrap Markdown Editor v2.0.2 (https://github.com/inacho/bootstrap-markdown-editor) - * Copyright 2016 Ignacio de Tomás + * Copyright 2019 Ignacio de Tomás * Licensed under MIT (https://github.com/inacho/bootstrap-markdown-editor/blob/master/LICENSE) */ diff --git a/dist/js/bootstrap-markdown-editor.js b/dist/js/bootstrap-markdown-editor.js index cb6854f..45651f0 100644 --- a/dist/js/bootstrap-markdown-editor.js +++ b/dist/js/bootstrap-markdown-editor.js @@ -1,7 +1,7 @@ /*! * Bootstrap Markdown Editor v2.0.2 (https://github.com/inacho/bootstrap-markdown-editor) - * Copyright 2016 Ignacio de Tomás + * Copyright 2019 Ignacio de Tomás * Licensed under MIT (https://github.com/inacho/bootstrap-markdown-editor/blob/master/LICENSE) */ -!function(a){"use strict";function b(b,c,d,e,f){if(c.length){f.show();var g=new FormData,h=0;for(h=0;h1&&(b="\n");for(var c=0;ce&&(c=d-e,b.css("height",c+"px"))}function d(a,b){a.commands.addCommand({name:"bold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(a){var c=a.session.getTextRange(a.getSelectionRange());""===c?b.insertSnippet(a,"**${1:text}**"):b.insertSnippet(a,"**"+c+"**")},readOnly:!1}),a.commands.addCommand({name:"italic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(a){var c=a.session.getTextRange(a.getSelectionRange());""===c?b.insertSnippet(a,"*${1:text}*"):b.insertSnippet(a,"*"+c+"*")},readOnly:!1}),a.commands.addCommand({name:"link",bindKey:{win:"Ctrl-K",mac:"Command-K"},exec:function(a){var c=a.session.getTextRange(a.getSelectionRange());""===c?b.insertSnippet(a,"[${1:text}](http://$2)"):b.insertSnippet(a,"["+c+"](http://$1)")},readOnly:!1})}function e(a,b){0===a.getCursorPosition().column?(a.navigateLineStart(),a.insert(b+" ")):(a.navigateLineStart(),a.insert(b+" "),a.navigateLineEnd())}function f(b,c){var d="";return d+='
',d+='
',d+='
',d+='
',d+='',d+='',d+='',d+="
",d+='
',d+='',d+='',d+="
",d+='
',d+='',d+='',d+="
",d+='
',d+='',d+='',c.imageUpload===!0&&(d+='
'),d+="
",c.fullscreen===!0&&(d+='
',d+='",d+="
"),c.preview===!0&&(d+='
',d+='",d+='",d+="
"),d+="
",d+="
",d+='
'+a("
").text(b).html()+"
",d+=''}var g={init:function(g){var h,i=a.extend(!0,{},a.fn.markdownEditor.defaults,g),j=this,k=!1,l=!1;j.addClass("md-textarea-hidden"),h=a("
"),j.after(h),h.addClass("md-container").html(f(j.val(),i)),"function"==typeof a().tooltip&&h.find('[data-mdtooltip="tooltip"]').tooltip({container:"body"});var m=h.find(".md-editor"),n=h.find(".md-preview"),o=h.find(".md-loading");h.css({width:i.width}),m.css({height:i.height,fontSize:i.fontSize}),n.css({height:i.height});var p,q=ace.edit(m[0]);return q.setTheme("ace/theme/"+i.theme),q.getSession().setMode("ace/mode/markdown"),q.getSession().setUseWrapMode(!0),q.getSession().setUseSoftTabs(i.softTabs),q.getSession().on("change",function(){j.val(q.getSession().getValue())}),q.setHighlightActiveLine(!1),q.setShowPrintMargin(!1),q.renderer.setShowGutter(!1),ace.config.loadModule("ace/ext/language_tools",function(){p=ace.require("ace/snippets").snippetManager,d(q,p)}),i.imageUpload&&(h.find(".md-input-upload").on("change",function(){var c=a(this).get(0).files;b(i.uploadPath,c,q,p,o)}),h.on("dragenter",function(a){a.stopPropagation(),a.preventDefault()}),h.on("dragover",function(a){a.stopPropagation(),a.preventDefault()}),h.on("drop",function(a){a.preventDefault();var c=a.originalEvent.dataTransfer.files;b(i.uploadPath,c,q,p,o)})),i.fullscreen===!0&&a(window).resize(function(){l===!0&&c(k===!1?m:n)}),h.find(".md-btn").click(function(){var b=a(this).data("btn"),d=q.session.getTextRange(q.getSelectionRange());"h1"===b?e(q,"#"):"h2"===b?e(q,"##"):"h3"===b?e(q,"###"):"ul"===b?e(q,"*"):"ol"===b?e(q,"1."):"bold"===b?q.execCommand("bold"):"italic"===b?q.execCommand("italic"):"link"===b?q.execCommand("link"):"image"===b?""===d?p.insertSnippet(q,"![${1:text}](http://$2)"):p.insertSnippet(q,"!["+d+"](http://$1)"):"edit"===b?(k=!1,n.hide(),m.show(),h.find(".btn-edit").addClass("active"),h.find(".btn-preview").removeClass("active"),l===!0&&c(m)):"preview"===b?(k=!0,n.html('

'+i.label.loading+"...

"),i.onPreview(q.getSession().getValue(),function(a){n.html(a)}),m.hide(),n.show(),h.find(".btn-preview").addClass("active"),h.find(".btn-edit").removeClass("active"),l===!0&&c(n)):"fullscreen"===b&&(l===!0?(l=!1,a("body, html").removeClass("md-body-fullscreen"),h.removeClass("md-fullscreen"),m.css("height",i.height),n.css("height",i.height)):(l=!0,a("body, html").addClass("md-body-fullscreen"),h.addClass("md-fullscreen"),c(k===!1?m:n)),q.resize()),q.focus()}),this},content:function(){var a=ace.edit(this.find(".md-editor")[0]);return a.getSession().getValue()},setContent:function(a){var b=ace.edit(this.find(".md-editor")[0]);b.setValue(a,1)}};a.fn.markdownEditor=function(b){return g[b]?g[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?void a.error("Method "+b+" does not exist on jQuery.markdownEditor"):g.init.apply(this,arguments)},a.fn.markdownEditor.defaults={width:"100%",height:"400px",fontSize:"14px",theme:"tomorrow",softTabs:!0,fullscreen:!0,imageUpload:!1,uploadPath:"",preview:!1,onPreview:function(a,b){b(a)},label:{btnHeader1:"Header 1",btnHeader2:"Header 2",btnHeader3:"Header 3",btnBold:"Bold",btnItalic:"Italic",btnList:"Unordered list",btnOrderedList:"Ordered list",btnLink:"Link",btnImage:"Insert image",btnUpload:"Upload image",btnEdit:"Edit",btnPreview:"Preview",btnFullscreen:"Fullscreen",loading:"Loading"}}}(jQuery); \ No newline at end of file +!function(u){"use strict";function f(t,e,a,i,n){if(e.length){n.show();var o=new FormData,s=0;for(s=0;s"),s.after(n),n.addClass("md-container").html((e=s.val(),i="",i+='
',i+='
',i+='
',i+='
',i+='',i+='',i+='',i+="
",i+='
',i+='',i+='',i+="
",i+='
',i+='',i+='',i+="
",i+='
',i+='',i+='',!0===a.imageUpload&&(i+='
'),i+="
",!0===a.fullscreen&&(i+='
',i+='",i+="
"),!0===a.preview&&(i+='
',i+='",i+='",i+="
"),i+="
",i+="
",i+='
'+u("
").text(e).html()+"
",i+='')),"function"==typeof u().tooltip&&n.find('[data-mdtooltip="tooltip"]').tooltip({container:"body"});var r=n.find(".md-editor"),b=n.find(".md-preview"),c=n.find(".md-loading");n.css({width:o.width}),r.css({height:o.height,fontSize:o.fontSize}),b.css({height:o.height});var p,m=ace.edit(r[0]);return m.setTheme("ace/theme/"+o.theme),m.getSession().setMode("ace/mode/markdown"),m.getSession().setUseWrapMode(!0),m.getSession().setUseSoftTabs(o.softTabs),m.getSession().on("change",function(){s.val(m.getSession().getValue())}),m.setHighlightActiveLine(!1),m.setShowPrintMargin(!1),m.renderer.setShowGutter(!1),ace.config.loadModule("ace/ext/language_tools",function(){var t,n;p=ace.require("ace/snippets").snippetManager,n=p,(t=m).commands.addCommand({name:"bold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(t){var e=t.session.getTextRange(t.getSelectionRange());""===e?n.insertSnippet(t,"**${1:text}**"):n.insertSnippet(t,"**"+e+"**")},readOnly:!1}),t.commands.addCommand({name:"italic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(t){var e=t.session.getTextRange(t.getSelectionRange());""===e?n.insertSnippet(t,"*${1:text}*"):n.insertSnippet(t,"*"+e+"*")},readOnly:!1}),t.commands.addCommand({name:"link",bindKey:{win:"Ctrl-K",mac:"Command-K"},exec:function(t){var e=t.session.getTextRange(t.getSelectionRange());""===e?n.insertSnippet(t,"[${1:text}](http://$2)"):n.insertSnippet(t,"["+e+"](http://$1)")},readOnly:!1})}),o.imageUpload&&(n.find(".md-input-upload").on("change",function(){var t=u(this).get(0).files;f(o.uploadPath,t,m,p,c)}),n.on("dragenter",function(t){t.stopPropagation(),t.preventDefault()}),n.on("dragover",function(t){t.stopPropagation(),t.preventDefault()}),n.on("drop",function(t){t.preventDefault();var e=t.originalEvent.dataTransfer.files;f(o.uploadPath,e,m,p,c)})),!0===o.fullscreen&&u(window).resize(function(){!0===l&&g(!1===d?r:b)}),n.find(".md-btn").click(function(){var t=u(this).data("btn"),e=m.session.getTextRange(m.getSelectionRange());"h1"===t?v(m,"#"):"h2"===t?v(m,"##"):"h3"===t?v(m,"###"):"ul"===t?v(m,"*"):"ol"===t?v(m,"1."):"bold"===t?m.execCommand("bold"):"italic"===t?m.execCommand("italic"):"link"===t?m.execCommand("link"):"image"===t?""===e?p.insertSnippet(m,"![${1:text}](http://$2)"):p.insertSnippet(m,"!["+e+"](http://$1)"):"edit"===t?(d=!1,b.hide(),r.show(),n.find(".btn-edit").addClass("active"),n.find(".btn-preview").removeClass("active"),!0===l&&g(r)):"preview"===t?(d=!0,b.html('

'+o.label.loading+"...

"),o.onPreview(m.getSession().getValue(),function(t){b.html(t)}),r.hide(),b.show(),n.find(".btn-preview").addClass("active"),n.find(".btn-edit").removeClass("active"),!0===l&&g(b)):"fullscreen"===t&&(!0===l?(l=!1,u("body, html").removeClass("md-body-fullscreen"),n.removeClass("md-fullscreen"),r.css("height",o.height),b.css("height",o.height)):(l=!0,u("body, html").addClass("md-body-fullscreen"),n.addClass("md-fullscreen"),g(!1===d?r:b)),m.resize()),m.focus()}),this},content:function(){return ace.edit(this.find(".md-editor")[0]).getSession().getValue()},setContent:function(t){ace.edit(this.find(".md-editor")[0]).setValue(t,1)}};u.fn.markdownEditor=function(t){return e[t]?e[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void u.error("Method "+t+" does not exist on jQuery.markdownEditor"):e.init.apply(this,arguments)},u.fn.markdownEditor.defaults={width:"100%",height:"400px",fontSize:"14px",theme:"tomorrow",softTabs:!0,fullscreen:!0,imageUpload:!1,uploadPath:"",preview:!1,onPreview:function(t,e){e(t)},label:{btnHeader1:"Header 1",btnHeader2:"Header 2",btnHeader3:"Header 3",btnBold:"Bold",btnItalic:"Italic",btnList:"Unordered list",btnOrderedList:"Ordered list",btnLink:"Link",btnImage:"Insert image",btnUpload:"Upload image",btnEdit:"Edit",btnPreview:"Preview",btnFullscreen:"Fullscreen",loading:"Loading"}}}(jQuery); \ No newline at end of file diff --git a/src/bootstrap-markdown-editor.js b/src/bootstrap-markdown-editor.js index 16ae146..d48d5f2 100644 --- a/src/bootstrap-markdown-editor.js +++ b/src/bootstrap-markdown-editor.js @@ -118,40 +118,40 @@ html += '
'; html += '
'; - html += '
'; - html += ''; - html += ''; - html += ''; + html += '
'; + html += ''; + html += ''; + html += ''; html += '
'; // .btn-group - html += '
'; - html += ''; - html += ''; + html += '
'; + html += ''; + html += ''; html += '
'; // .btn-group - html += '
'; - html += ''; - html += ''; + html += '
'; + html += ''; + html += ''; html += '
'; // .btn-group - html += '
'; - html += ''; - html += ''; + html += '
'; + html += ''; + html += ''; if (options.imageUpload === true) { - html += '
'; + html += '
'; } html += '
'; // .btn-group if (options.fullscreen === true) { - html += '
'; - html += ''; + html += '
'; + html += ''; html += '
'; // .btn-group } if (options.preview === true) { - html += '
'; - html += ''; - html += ''; + html += '
'; + html += ''; + html += ''; html += '
'; // .btn-group }