From 796ed9817077c33e240e18ce98936c75af2ee9b6 Mon Sep 17 00:00:00 2001
From: Agus Makmun
Date: Sat, 30 Mar 2024 16:28:40 +0700
Subject: [PATCH] fix: editor unable to load in django admin inline
---
martor/__init__.py | 4 +-
martor/static/martor/css/martor-admin.min.css | 4 +-
.../martor/css/martor.bootstrap.min.css | 4 +-
.../static/martor/css/martor.semantic.min.css | 4 +-
martor/static/martor/js/martor.bootstrap.js | 40 ++++++++++---------
.../static/martor/js/martor.bootstrap.min.js | 7 ++--
martor/static/martor/js/martor.semantic.js | 30 +++++++-------
.../static/martor/js/martor.semantic.min.js | 7 ++--
8 files changed, 53 insertions(+), 47 deletions(-)
diff --git a/martor/__init__.py b/martor/__init__.py
index 59f5bdc5..8c98f7d7 100644
--- a/martor/__init__.py
+++ b/martor/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-__VERSION__ = "1.6.41"
-__RELEASE_DATE__ = "29-Mar-2024"
+__VERSION__ = "1.6.42"
+__RELEASE_DATE__ = "30-Mar-2024"
__AUTHOR__ = "Agus Makmun (Summon Agus)"
__AUTHOR_EMAIL__ = "summon.agus@gmail.com"
diff --git a/martor/static/martor/css/martor-admin.min.css b/martor/static/martor/css/martor-admin.min.css
index b71aa6ce..d008e663 100644
--- a/martor/static/martor/css/martor-admin.min.css
+++ b/martor/static/martor/css/martor-admin.min.css
@@ -1,7 +1,7 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
diff --git a/martor/static/martor/css/martor.bootstrap.min.css b/martor/static/martor/css/martor.bootstrap.min.css
index 14913838..b430b79e 100644
--- a/martor/static/martor/css/martor.bootstrap.min.css
+++ b/martor/static/martor/css/martor.bootstrap.min.css
@@ -1,7 +1,7 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
diff --git a/martor/static/martor/css/martor.semantic.min.css b/martor/static/martor/css/martor.semantic.min.css
index d20d4045..f30e4aab 100644
--- a/martor/static/martor/css/martor.semantic.min.css
+++ b/martor/static/martor/css/martor.semantic.min.css
@@ -1,7 +1,7 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
**/
diff --git a/martor/static/martor/js/martor.bootstrap.js b/martor/static/martor/js/martor.bootstrap.js
index 10dccade..78cd5f7a 100644
--- a/martor/static/martor/js/martor.bootstrap.js
+++ b/martor/static/martor/js/martor.bootstrap.js
@@ -1,9 +1,10 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
+ * JS Minifier : https://jscompress.com
**/
(function ($) {
@@ -147,14 +148,14 @@
var currentTab = $('.tab-pane#nav-preview-' + field_name);
var editorTabButton = $('.nav-link#nav-editor-tab-' + field_name);
var previewTabButton = $('.nav-link#nav-preview-tab-' + field_name);
- var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar')
+ var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar');
editorTabButton.click(function () {
// show the `.martor-toolbar` for this current editor if under preview.
- $(this).closest('.tab-martor-menu').find('.martor-toolbar').show();
+ toolbarButtons.show();
});
previewTabButton.click(function () {
- $(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
+ toolbarButtons.hide();
});
var refreshPreview = function () {
@@ -207,7 +208,7 @@
if (editorConfig.living !== 'true') {
previewTabButton.click(function () {
// hide the `.martor-toolbar` for this current editor if under preview.
- $(this).closest('.tab-martor-menu').find('.martor-toolbar').hide();
+ toolbarButtons.hide();
refreshPreview();
});
} else {
@@ -858,9 +859,7 @@
});
// Set initial value if has the content before.
- if (textareaId.val() != '') {
- editor.setValue(textareaId.val(), -1);
- }
+ editor.setValue(textareaId.val(), -1);
});// end each `mainMartor`
};
@@ -870,15 +869,18 @@
if ('django' in window && 'jQuery' in window.django)
django.jQuery(document).on('formset:added', function (event) {
- var row = $(event.target);
- row.find('.main-martor').each(function () {
- var id = row.attr('id');
- id = id.substr(id.lastIndexOf('-') + 1);
- // Notice here we are using our jQuery instead of Django's.
- // This is because plugins are only loaded for ours.
- var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
- $(this).replaceWith(fixed);
- fixed.martor();
- });
+ // add delay for formset to load
+ setTimeout(function(){
+ var row = $(event.target);
+ row.find('.main-martor').each(function () {
+ var id = row.attr('id');
+ id = id.substr(id.lastIndexOf('-') + 1);
+ // Notice here we are using our jQuery instead of Django's.
+ // This is because plugins are only loaded for ours.
+ var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
+ $(this).replaceWith(fixed);
+ fixed.martor();
+ });
+ }, 1000);
});
})(jQuery);
diff --git a/martor/static/martor/js/martor.bootstrap.min.js b/martor/static/martor/js/martor.bootstrap.min.js
index 841d9011..dfb902b8 100644
--- a/martor/static/martor/js/martor.bootstrap.min.js
+++ b/martor/static/martor/js/martor.bootstrap.min.js
@@ -1,8 +1,9 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
+ * JS Minifier : https://jscompress.com
**/
-!function(e){e||(e=django.jQuery),e.fn.martor=function(){e(".martor").trigger("martor.init");var n=function(e){var n=null,o=0;if(document.cookie&&""!==document.cookie)for(var t=document.cookie.split(";");oNothing to preview
")},error:function(e){console.log("error",e)}})};let p;if(window.onload=function(){v()},"true"!==l.living?g.click((function(){e(this).closest(".tab-martor-menu").find(".martor-toolbar").hide(),v()})):c.on("change",(function(){p&&clearTimeout(p),p=setTimeout(v,s.data("save-timeout"))})),"true"==l.spellcheck)try{enable_spellcheck(r)}catch(e){console.log("Spellcheck lib doesn't installed.")}var w=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," **** "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"**"+a+"**"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}},k=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," __ "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"_"+a+"_"),n.end.column+=2,e.focus(),e.selection.setSelectionRange(n)}},h=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n----------\n\n"),e.focus(),e.selection.moveTo(o.row+4,o.column+10)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n----------\n\n"+a),e.focus(),e.selection.moveTo(n.end.row+4,n.end.column+10)}},C=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n# "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n# "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},y=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n## "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n## "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+3)}},T=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n### "),e.focus(),e.selection.moveTo(o.row+2,o.column+4)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n### "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+4)}},S=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n```\n\n```\n"),e.focus(),e.selection.moveTo(o.row+3,o.column)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n```\n"+a+"\n```\n"),e.focus(),e.selection.moveTo(n.end.row+3,n.end.column+3)}},b=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," `` "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"`"+a+"`"),n.end.column+=2,e.focus(),e.selection.setSelectionRange(n)}},R=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n> \n"),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n> "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},x=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n* "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n* "+a),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},O=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n1. "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n1. "+a),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+3)}},j=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," [](https://) "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"["+a+"](https://) "),e.focus(),e.selection.moveTo(n.end.row,n.end.column+11)}},P=function(e,n){var o=e.getSelectionRange();if(void 0===n)if(e.selection.isEmpty()){var t=e.getCursorPosition();e.session.insert(t," ![](https://) "),e.focus(),e.selection.moveTo(t.row,t.column+3)}else{var a=e.getSelectionRange(),i=e.session.getTextRange(a);e.session.replace(a,"!["+i+"](https://) "),e.focus(),e.selection.moveTo(o.end.row,o.end.column+12)}else{t=e.getCursorPosition();e.session.insert(t,"!["+n.name+"]("+n.link+") "),e.focus(),e.selection.moveTo(t.row,t.column+n.name.length+2)}},E=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," @[]"),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"@["+a+"]"),e.focus(),e.selection.moveTo(n.end.row,n.end.column+3)}},K=function(e,n){var o=e.getCursorPosition();e.session.insert(o," "+n+" "),e.focus(),e.selection.moveTo(o.row,o.column+n.length+2)};c.commands.addCommand({name:"markdownToBold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(e){w(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToItalic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(e){k(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnderscores",bindKey:{win:"Ctrl-Shift-U",mac:"Command-Shift-U"},exec:function(e){!function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," ++++ "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"++"+a+"++"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}}(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToStrikethrough",bindKey:{win:"Ctrl-Shift-S",mac:"Command-Shift-S"},exec:function(e){!function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," ~~~~ "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"~~"+a+"~~"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}}(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToHorizontal",bindKey:{win:"Ctrl-H",mac:"Command-H"},exec:function(e){h(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH1",bindKey:{win:"Ctrl-Alt-1",mac:"Command-Option-1"},exec:function(e){C(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH2",bindKey:{win:"Ctrl-Alt-2",mac:"Command-Option-3"},exec:function(e){y(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH3",bindKey:{win:"Ctrl-Alt-3",mac:"Command-Option-3"},exec:function(e){T(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToPre",bindKey:{win:"Ctrl-Alt-P",mac:"Command-Option-P"},exec:function(e){S(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToCode",bindKey:{win:"Ctrl-Alt-C",mac:"Command-Option-C"},exec:function(e){b(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToBlockQuote",bindKey:{win:"Ctrl-Q",mac:"Command-Shift-K"},exec:function(e){R(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnorderedList",bindKey:{win:"Ctrl-U",mac:"Command-U"},exec:function(e){x(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToOrderedList",bindKey:{win:"Ctrl-Shift+O",mac:"Command-Option-O"},exec:function(e){O(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToLink",bindKey:{win:"Ctrl-L",mac:"Command-L"},exec:function(e){j(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToImageLink",bindKey:{win:"Ctrl-Shift-I",mac:"Command-Option-I"},exec:function(e){P(e)},readOnly:!0}),"true"===l.mention&&c.commands.addCommand({name:"markdownToMention",bindKey:{win:"Ctrl-M",mac:"Command-M"},exec:function(e){E(e)},readOnly:!0}),e(".markdown-bold[data-field-name="+i+"]").click((function(){w(c)})),e(".markdown-italic[data-field-name="+i+"]").click((function(){k(c)})),e(".markdown-horizontal[data-field-name="+i+"]").click((function(){h(c)})),e(".markdown-h1[data-field-name="+i+"]").click((function(){C(c)})),e(".markdown-h2[data-field-name="+i+"]").click((function(){y(c)})),e(".markdown-h3[data-field-name="+i+"]").click((function(){T(c)})),e(".markdown-pre[data-field-name="+i+"]").click((function(){S(c)})),e(".markdown-code[data-field-name="+i+"]").click((function(){b(c)})),e(".markdown-blockquote[data-field-name="+i+"]").click((function(){R(c)})),e(".markdown-unordered-list[data-field-name="+i+"]").click((function(){x(c)})),e(".markdown-ordered-list[data-field-name="+i+"]").click((function(){O(c)})),e(".markdown-link[data-field-name="+i+"]").click((function(){j(c)})),e(".markdown-image-link[data-field-name="+i+"]").click((function(){P(c)}));var A=e(".markdown-direct-mention[data-field-name="+i+"]"),M=e(".markdown-image-upload[data-field-name="+i+"]");"true"==l.mention?A.click((function(){E(c)})):(A.remove(),e(".markdown-reference tbody tr")[1].remove()),"true"==l.imgur?M.on("change",(function(o){o.preventDefault(),function(o){var t=e("#"+r).closest("form").get(0),a=o.container.id.replace("martor-",""),i=new FormData(t);i.append("csrfmiddlewaretoken",n("csrftoken")),e.ajax({url:s.data("upload-url"),type:"POST",data:i,async:!0,cache:!1,contentType:!1,enctype:"multipart/form-data",processData:!1,beforeSend:function(){console.log("Uploading..."),e(".upload-progress[data-field-name="+a+"]").show()},success:function(n){e(".upload-progress[data-field-name="+a+"]").hide(),200==n.status?(console.log(n),P(o,imageData={name:n.name,link:n.link})):alert(n.error)},error:function(n){console.log("error",n),e(".upload-progress[data-field-name="+a+"]").hide()}})}(c)})):M.remove(),e(".markdown-help[data-field-name="+i+"]").click((function(){e(".modal-help-guide[data-field-name="+i+"]").modal("show")}));var U=e(".martor-field-"+i),_=e(".markdown-toggle-maximize[data-field-name="+i+"]"),I=function(){e(document.body).removeClass("overflow"),e(this).attr({title:"Full Screen"}),e(this).find("svg.bi-arrows-angle-expand").show(),e(this).find("svg.bi-arrows-angle-contract").hide(),e(".main-martor-fullscreen").find(".martor-preview").removeAttr("style"),a.removeClass("main-martor-fullscreen"),U.removeAttr("style"),c.resize()};_.on("click",(function(){!function(n){n.attr({title:"Minimize"}),n.find("svg.bi-arrows-angle-expand").hide(),n.find("svg.bi-arrows-angle-contract").show(),a.addClass("main-martor-fullscreen");var o=document.body.clientHeight-90;U.attr({style:"height:"+o+"px"}),e(".main-martor-fullscreen").find(".martor-preview").attr({style:"overflow-y: auto;height:"+o+"px"}),c.resize(),n.one("click",I),e(document.body).addClass("overflow")}(e(this))})),e(document).keyup((function(e){27==e.keyCode&&a.hasClass("main-martor-fullscreen")&&_.trigger("click")})),e(".markdown-emoji[data-field-name="+i+"]").click((function(){var n=e(".modal-emoji[data-field-name="+i+"]").modal("show"),o="undefined"!=typeof emojis?emojis:[],t=n.find(".emoji-content-body"),a=n.find(".emoji-loader-init");t.html(""),a.show(),n.show();for(var r=0;r '+o[r]+"
"),e('a[data-emoji-target="'+o[r]+'"]').click((function(){K(c,e(this).data("emoji-target")),n.modal("hide")}))}a.hide(),t.show(),n.modal("handleUpdate")})),""!=s.val()&&c.setValue(s.val(),-1)}))},e((function(){e(".main-martor").martor()})),"django"in window&&"jQuery"in window.django&&django.jQuery(document).on("formset:added",(function(n,o){o.find(".main-martor").each((function(){var n=o.attr("id");n=n.substr(n.lastIndexOf("-")+1);var t=e(this.outerHTML.replace(/__prefix__/g,n));e(this).replaceWith(t),t.martor()}))}))}(jQuery);
+!function(A){(A=A||django.jQuery).fn.martor=function(){A(".martor").trigger("martor.init");function K(e){var n=null,o=0;if(document.cookie&&""!==document.cookie)for(var t=document.cookie.split(";");oNothing to preview")},error:function(e){console.log("error",e)}})}let g;if(window.onload=function(){u()},"true"!==a.living?n.click(function(){d.hide(),u()}):r.on("change",function(){g&&clearTimeout(g),g=setTimeout(u,c.data("save-timeout"))}),"true"==a.spellcheck)try{enable_spellcheck(t)}catch(e){console.log("Spellcheck lib doesn't installed.")}function f(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," **** "),e.focus(),e.selection.moveTo(o.row,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"**"+o+"**"),t.end.column+=4,e.focus(),e.selection.setSelectionRange(t))}function p(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," __ "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"_"+o+"_"),t.end.column+=2,e.focus(),e.selection.setSelectionRange(t))}function w(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n----------\n\n"),e.focus(),e.selection.moveTo(o.row+4,o.column+10)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n----------\n\n"+o),e.focus(),e.selection.moveTo(t.end.row+4,t.end.column+10))}function v(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n# "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n# "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function k(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n## "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n## "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+3))}function h(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n### "),e.focus(),e.selection.moveTo(o.row+2,o.column+4)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n### "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+4))}function C(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n```\n\n```\n"),e.focus(),e.selection.moveTo(o.row+3,o.column)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n```\n"+o+"\n```\n"),e.focus(),e.selection.moveTo(t.end.row+3,t.end.column+3))}function y(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," `` "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"`"+o+"`"),t.end.column+=2,e.focus(),e.selection.setSelectionRange(t))}function T(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n> \n"),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n> "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function S(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n* "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n* "+o),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function R(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n1. "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n1. "+o),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+3))}function b(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," [](https://) "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"["+o+"](https://) "),e.focus(),e.selection.moveTo(t.end.row,t.end.column+11))}function x(e,n){var o,t,a,i=e.getSelectionRange();void 0===n?e.selection.isEmpty()?(a=e.getCursorPosition(),e.session.insert(a," ![](https://) "),e.focus(),e.selection.moveTo(a.row,a.column+3)):(o=e.getSelectionRange(),t=e.session.getTextRange(o),e.session.replace(o,"!["+t+"](https://) "),e.focus(),e.selection.moveTo(i.end.row,i.end.column+12)):(a=e.getCursorPosition(),e.session.insert(a,"!["+n.name+"]("+n.link+") "),e.focus(),e.selection.moveTo(a.row,a.column+n.name.length+2))}function O(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," @[]"),e.focus(),e.selection.moveTo(o.row,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"@["+o+"]"),e.focus(),e.selection.moveTo(t.end.row,t.end.column+3))}r.commands.addCommand({name:"markdownToBold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(e){f(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToItalic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(e){p(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToUnderscores",bindKey:{win:"Ctrl-Shift-U",mac:"Command-Shift-U"},exec:function(e){var n,o,t;t=(n=e).getSelectionRange(),n.selection.isEmpty()?(o=n.getCursorPosition(),n.session.insert(o," ++++ "),n.focus(),n.selection.moveTo(o.row,o.column+3)):(e=n.getSelectionRange(),o=n.session.getTextRange(e),n.session.replace(e,"++"+o+"++"),t.end.column+=4,n.focus(),n.selection.setSelectionRange(t))},readOnly:!0}),r.commands.addCommand({name:"markdownToStrikethrough",bindKey:{win:"Ctrl-Shift-S",mac:"Command-Shift-S"},exec:function(e){var n,o,t;t=(n=e).getSelectionRange(),n.selection.isEmpty()?(o=n.getCursorPosition(),n.session.insert(o," ~~~~ "),n.focus(),n.selection.moveTo(o.row,o.column+3)):(e=n.getSelectionRange(),o=n.session.getTextRange(e),n.session.replace(e,"~~"+o+"~~"),t.end.column+=4,n.focus(),n.selection.setSelectionRange(t))},readOnly:!0}),r.commands.addCommand({name:"markdownToHorizontal",bindKey:{win:"Ctrl-H",mac:"Command-H"},exec:function(e){w(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToH1",bindKey:{win:"Ctrl-Alt-1",mac:"Command-Option-1"},exec:function(e){v(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToH2",bindKey:{win:"Ctrl-Alt-2",mac:"Command-Option-3"},exec:function(e){k(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToH3",bindKey:{win:"Ctrl-Alt-3",mac:"Command-Option-3"},exec:function(e){h(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToPre",bindKey:{win:"Ctrl-Alt-P",mac:"Command-Option-P"},exec:function(e){C(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToCode",bindKey:{win:"Ctrl-Alt-C",mac:"Command-Option-C"},exec:function(e){y(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToBlockQuote",bindKey:{win:"Ctrl-Q",mac:"Command-Shift-K"},exec:function(e){T(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToUnorderedList",bindKey:{win:"Ctrl-U",mac:"Command-U"},exec:function(e){S(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToOrderedList",bindKey:{win:"Ctrl-Shift+O",mac:"Command-Option-O"},exec:function(e){R(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToLink",bindKey:{win:"Ctrl-L",mac:"Command-L"},exec:function(e){b(e)},readOnly:!0}),r.commands.addCommand({name:"markdownToImageLink",bindKey:{win:"Ctrl-Shift-I",mac:"Command-Option-I"},exec:function(e){x(e)},readOnly:!0}),"true"===a.mention&&r.commands.addCommand({name:"markdownToMention",bindKey:{win:"Ctrl-M",mac:"Command-M"},exec:function(e){O(e)},readOnly:!0}),A(".markdown-bold[data-field-name="+s+"]").click(function(){f(r)}),A(".markdown-italic[data-field-name="+s+"]").click(function(){p(r)}),A(".markdown-horizontal[data-field-name="+s+"]").click(function(){w(r)}),A(".markdown-h1[data-field-name="+s+"]").click(function(){v(r)}),A(".markdown-h2[data-field-name="+s+"]").click(function(){k(r)}),A(".markdown-h3[data-field-name="+s+"]").click(function(){h(r)}),A(".markdown-pre[data-field-name="+s+"]").click(function(){C(r)}),A(".markdown-code[data-field-name="+s+"]").click(function(){y(r)}),A(".markdown-blockquote[data-field-name="+s+"]").click(function(){T(r)}),A(".markdown-unordered-list[data-field-name="+s+"]").click(function(){S(r)}),A(".markdown-ordered-list[data-field-name="+s+"]").click(function(){R(r)}),A(".markdown-link[data-field-name="+s+"]").click(function(){b(r)}),A(".markdown-image-link[data-field-name="+s+"]").click(function(){x(r)});i=A(".markdown-direct-mention[data-field-name="+s+"]"),n=A(".markdown-image-upload[data-field-name="+s+"]");"true"==a.mention?i.click(function(){O(r)}):(i.remove(),A(".markdown-reference tbody tr")[1].remove()),"true"==a.imgur?n.on("change",function(e){var n,o;e.preventDefault(),n=r,e=A("#"+t).closest("form").get(0),o=n.container.id.replace("martor-",""),(e=new FormData(e)).append("csrfmiddlewaretoken",K("csrftoken")),A.ajax({url:c.data("upload-url"),type:"POST",data:e,async:!0,cache:!1,contentType:!1,enctype:"multipart/form-data",processData:!1,beforeSend:function(){console.log("Uploading..."),A(".upload-progress[data-field-name="+o+"]").show()},success:function(e){A(".upload-progress[data-field-name="+o+"]").hide(),200==e.status?(console.log(e),x(n,imageData={name:e.name,link:e.link})):alert(e.error)},error:function(e){console.log("error",e),A(".upload-progress[data-field-name="+o+"]").hide()}})}):n.remove(),A(".markdown-help[data-field-name="+s+"]").click(function(){A(".modal-help-guide[data-field-name="+s+"]").modal("show")});function j(){A(document.body).removeClass("overflow"),A(this).attr({title:"Full Screen"}),A(this).find("svg.bi-arrows-angle-expand").show(),A(this).find("svg.bi-arrows-angle-contract").hide(),A(".main-martor-fullscreen").find(".martor-preview").removeAttr("style"),o.removeClass("main-martor-fullscreen"),P.removeAttr("style"),r.resize()}var P=A(".martor-field-"+s),E=A(".markdown-toggle-maximize[data-field-name="+s+"]");E.on("click",function(){!function(e){e.attr({title:"Minimize"}),e.find("svg.bi-arrows-angle-expand").hide(),e.find("svg.bi-arrows-angle-contract").show(),o.addClass("main-martor-fullscreen");var n=document.body.clientHeight-90;P.attr({style:"height:"+n+"px"}),A(".main-martor-fullscreen").find(".martor-preview").attr({style:"overflow-y: auto;height:"+n+"px"}),r.resize(),e.one("click",j),A(document.body).addClass("overflow")}(A(this))}),A(document).keyup(function(e){27==e.keyCode&&o.hasClass("main-martor-fullscreen")&&E.trigger("click")}),A(".markdown-emoji[data-field-name="+s+"]").click(function(){var t=A(".modal-emoji[data-field-name="+s+"]").modal("show"),e="undefined"!=typeof emojis?emojis:[],n=t.find(".emoji-content-body"),o=t.find(".emoji-loader-init");n.html(""),o.show(),t.show();for(var a=0;a '+e[a]+"
"),A('a[data-emoji-target="'+e[a]+'"]').click(function(){var e,n,o;e=r,n=A(this).data("emoji-target"),o=e.getCursorPosition(),e.session.insert(o," "+n+" "),e.focus(),e.selection.moveTo(o.row,o.column+n.length+2),t.modal("hide")})}o.hide(),n.show(),t.modal("handleUpdate")}),r.setValue(c.val(),-1)})},A(function(){A(".main-martor").martor()}),"django"in window&&"jQuery"in window.django&&django.jQuery(document).on("formset:added",function(e){setTimeout(function(){var n=A(e.target);n.find(".main-martor").each(function(){var e=(e=n.attr("id")).substr(e.lastIndexOf("-")+1),e=A(this.outerHTML.replace(/__prefix__/g,e));A(this).replaceWith(e),e.martor()})},1e3)})}(jQuery);
diff --git a/martor/static/martor/js/martor.semantic.js b/martor/static/martor/js/martor.semantic.js
index d02a5b7e..4fd67740 100644
--- a/martor/static/martor/js/martor.semantic.js
+++ b/martor/static/martor/js/martor.semantic.js
@@ -1,9 +1,10 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
+ * JS Minifier : https://jscompress.com
**/
(function ($) {
@@ -855,9 +856,7 @@
});
// Set initial value if has the content before.
- if (textareaId.val() != '') {
- editor.setValue(textareaId.val(), -1);
- }
+ editor.setValue(textareaId.val(), -1);
});// end each `mainMartor`
};
@@ -867,14 +866,17 @@
if ('django' in window && 'jQuery' in window.django)
django.jQuery(document).on('formset:added', function (event, $row) {
- $row.find('.main-martor').each(function () {
- var id = $row.attr('id');
- id = id.substr(id.lastIndexOf('-') + 1);
- // Notice here we are using our jQuery instead of Django's.
- // This is because plugins are only loaded for ours.
- var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
- $(this).replaceWith(fixed);
- fixed.martor();
- });
+ // add delay for formset to load
+ setTimeout(function(){
+ $row.find('.main-martor').each(function () {
+ var id = $row.attr('id');
+ id = id.substr(id.lastIndexOf('-') + 1);
+ // Notice here we are using our jQuery instead of Django's.
+ // This is because plugins are only loaded for ours.
+ var fixed = $(this.outerHTML.replace(/__prefix__/g, id));
+ $(this).replaceWith(fixed);
+ fixed.martor();
+ });
+ }, 1000);
});
})(jQuery);
diff --git a/martor/static/martor/js/martor.semantic.min.js b/martor/static/martor/js/martor.semantic.min.js
index fc15f423..2f91c50b 100644
--- a/martor/static/martor/js/martor.semantic.min.js
+++ b/martor/static/martor/js/martor.semantic.min.js
@@ -1,8 +1,9 @@
/**
- * Name : Martor v1.6.41
+ * Name : Martor v1.6.42
* Created by : Agus Makmun (Summon Agus)
- * Release date : 29-Mar-2024
+ * Release date : 30-Mar-2024
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
* Repository : https://github.com/agusmakmun/django-markdown-editor
+ * JS Minifier : https://jscompress.com
**/
-!function(e){e||(e=django.jQuery),e.fn.martor=function(){e(".martor").trigger("martor.init");var n=function(e){var n=null,o=0;if(document.cookie&&""!==document.cookie)for(var t=document.cookie.split(";");oNothing to preview")},error:function(e){console.log("error",e)}})};let v;if(window.onload=function(){g()},"true"!==l.living?f.click((function(){e(this).closest(".tab-martor-menu").find(".martor-toolbar").hide(),g()})):c.on("change",(function(){v&&clearTimeout(v),v=setTimeout(g,s.data("save-timeout"))})),e(".item[data-tab=editor-tab-"+i+"]").click((function(){e(this).closest(".tab-martor-menu").find(".martor-toolbar").show()})),"true"==l.spellcheck)try{enable_spellcheck(r)}catch(e){console.log("Spellcheck lib doesn't installed.")}var p=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," **** "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"**"+a+"**"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}},w=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," __ "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"_"+a+"_"),n.end.column+=2,e.focus(),e.selection.setSelectionRange(n)}},k=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n----------\n\n"),e.focus(),e.selection.moveTo(o.row+4,o.column+10)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n----------\n\n"+a),e.focus(),e.selection.moveTo(n.end.row+4,n.end.column+10)}},C=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n# "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n# "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},h=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n## "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n## "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+3)}},y=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n### "),e.focus(),e.selection.moveTo(o.row+2,o.column+4)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n### "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+4)}},T=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n```\n\n```\n"),e.focus(),e.selection.moveTo(o.row+3,o.column)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n```\n"+a+"\n```\n"),e.focus(),e.selection.moveTo(n.end.row+3,n.end.column+3)}},S=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," `` "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"`"+a+"`"),n.end.column+=2,e.focus(),e.selection.setSelectionRange(n)}},b=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n> \n"),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n> "+a+"\n"),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},R=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n* "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n* "+a),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+2)}},x=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o,"\n\n1. "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"\n\n1. "+a),e.focus(),e.selection.moveTo(n.end.row+2,n.end.column+3)}},O=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," [](https://) "),e.focus(),e.selection.moveTo(o.row,o.column+2)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"["+a+"](https://) "),e.focus(),e.selection.moveTo(n.end.row,n.end.column+10)}},j=function(e,n){var o=e.getSelectionRange();if(void 0===n)if(e.selection.isEmpty()){var t=e.getCursorPosition();e.session.insert(t," ![](https://) "),e.focus(),e.selection.moveTo(t.row,t.column+3)}else{var a=e.getSelectionRange(),i=e.session.getTextRange(a);e.session.replace(a,"!["+i+"](https://) "),e.focus(),e.selection.moveTo(o.end.row,o.end.column+11)}else{t=e.getCursorPosition();e.session.insert(t,"!["+n.name+"]("+n.link+") "),e.focus(),e.selection.moveTo(t.row,t.column+n.name.length+2)}},P=function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," @[]"),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"@["+a+"]"),e.focus(),e.selection.moveTo(n.end.row,n.end.column+3)}},E=function(e,n){var o=e.getCursorPosition();e.session.insert(o," "+n+" "),e.focus(),e.selection.moveTo(o.row,o.column+n.length+2)};c.commands.addCommand({name:"markdownToBold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(e){p(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToItalic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(e){w(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnderscores",bindKey:{win:"Ctrl-Shift-U",mac:"Command-Shift-U"},exec:function(e){!function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," ++++ "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"++"+a+"++"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}}(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToStrikethrough",bindKey:{win:"Ctrl-Shift-S",mac:"Command-Shift-S"},exec:function(e){!function(e){var n=e.getSelectionRange();if(e.selection.isEmpty()){var o=e.getCursorPosition();e.session.insert(o," ~~~~ "),e.focus(),e.selection.moveTo(o.row,o.column+3)}else{var t=e.getSelectionRange(),a=e.session.getTextRange(t);e.session.replace(t,"~~"+a+"~~"),n.end.column+=4,e.focus(),e.selection.setSelectionRange(n)}}(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToHorizontal",bindKey:{win:"Ctrl-H",mac:"Command-H"},exec:function(e){k(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH1",bindKey:{win:"Ctrl-Alt-1",mac:"Command-Option-1"},exec:function(e){C(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH2",bindKey:{win:"Ctrl-Alt-2",mac:"Command-Option-3"},exec:function(e){h(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH3",bindKey:{win:"Ctrl-Alt-3",mac:"Command-Option-3"},exec:function(e){y(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToPre",bindKey:{win:"Ctrl-Alt-P",mac:"Command-Option-P"},exec:function(e){T(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToCode",bindKey:{win:"Ctrl-Alt-C",mac:"Command-Option-C"},exec:function(e){S(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToBlockQuote",bindKey:{win:"Ctrl-Q",mac:"Command-Shift-K"},exec:function(e){b(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnorderedList",bindKey:{win:"Ctrl-U",mac:"Command-U"},exec:function(e){R(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToOrderedList",bindKey:{win:"Ctrl-Shift+O",mac:"Command-Option-O"},exec:function(e){x(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToLink",bindKey:{win:"Ctrl-L",mac:"Command-L"},exec:function(e){O(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToImageLink",bindKey:{win:"Ctrl-Shift-I",mac:"Command-Option-I"},exec:function(e){j(e)},readOnly:!0}),"true"===l.mention&&c.commands.addCommand({name:"markdownToMention",bindKey:{win:"Ctrl-M",mac:"Command-M"},exec:function(e){P(e)},readOnly:!0}),e(".markdown-bold[data-field-name="+i+"]").click((function(){p(c)})),e(".markdown-italic[data-field-name="+i+"]").click((function(){w(c)})),e(".markdown-horizontal[data-field-name="+i+"]").click((function(){k(c)})),e(".markdown-h1[data-field-name="+i+"]").click((function(){C(c)})),e(".markdown-h2[data-field-name="+i+"]").click((function(){h(c)})),e(".markdown-h3[data-field-name="+i+"]").click((function(){y(c)})),e(".markdown-pre[data-field-name="+i+"]").click((function(){T(c)})),e(".markdown-code[data-field-name="+i+"]").click((function(){S(c)})),e(".markdown-blockquote[data-field-name="+i+"]").click((function(){b(c)})),e(".markdown-unordered-list[data-field-name="+i+"]").click((function(){R(c)})),e(".markdown-ordered-list[data-field-name="+i+"]").click((function(){x(c)})),e(".markdown-link[data-field-name="+i+"]").click((function(){O(c)})),e(".markdown-image-link[data-field-name="+i+"]").click((function(){j(c)}));var K=e(".markdown-direct-mention[data-field-name="+i+"]"),z=e(".markdown-image-upload[data-field-name="+i+"]");"true"===l.mention?K.click((function(){P(c)})):(K.remove(),e(".markdown-reference tbody tr")[1].remove()),"true"===l.imgur?z.on("change",(function(o){o.preventDefault(),function(o){var t=e("#"+r).closest("form").get(0),a=o.container.id.replace("martor-",""),i=new FormData(t);i.append("csrfmiddlewaretoken",n("csrftoken")),e.ajax({url:s.data("upload-url"),type:"POST",data:i,async:!0,cache:!1,contentType:!1,enctype:"multipart/form-data",processData:!1,beforeSend:function(){console.log("Uploading..."),e(".upload-progress[data-field-name="+a+"]").show()},success:function(n){e(".upload-progress[data-field-name="+a+"]").hide(),200==n.status?(console.log(n),j(o,imageData={name:n.name,link:n.link})):alert(n.error)},error:function(n){console.log("error",n),e(".upload-progress[data-field-name="+a+"]").hide()}})}(c)})):z.remove(),e(".markdown-help[data-field-name="+i+"]").click((function(){e(".modal-help-guide[data-field-name="+i+"]").modal("show")})),a.find(".ui.martor-toolbar .ui.dropdown").dropdown(),a.find(".ui.tab-martor-menu .item").tab();var A=e(".martor-field-"+i),M=e(".markdown-toggle-maximize[data-field-name="+i+"]"),_=function(){e(document.body).removeClass("overflow"),e(this).attr({title:"Full Screen"}),e(this).find(".minimize.icon").removeClass("minimize").addClass("maximize"),e(".main-martor-fullscreen").find(".martor-preview").removeAttr("style"),a.removeClass("main-martor-fullscreen"),A.removeAttr("style"),c.resize()};M.on("click",(function(){!function(n){n.attr({title:"Minimize"}),n.find(".maximize.icon").removeClass("maximize").addClass("minimize"),a.addClass("main-martor-fullscreen");var o=document.body.clientHeight-90;A.attr({style:"height:"+o+"px"}),e(".main-martor-fullscreen").find(".martor-preview").attr({style:"overflow-y: auto;height:"+o+"px"}),c.resize(),n.one("click",_),e(document.body).addClass("overflow")}(e(this))})),e(document).keyup((function(n){27==n.keyCode&&a.hasClass("main-martor-fullscreen")&&e(".minimize.icon").trigger("click")})),e(".markdown-emoji[data-field-name="+i+"]").click((function(){var n=e(".modal-emoji[data-field-name="+i+"]"),o="undefined"!=typeof emojis?emojis:[],t=n.find(".emoji-content-body"),a=n.find(".emoji-loader-init");t.html(""),a.show(),n.modal({onVisible:function(){for(var i=0;i '+o[i]+"
"),e('a[data-emoji-target="'+o[i]+'"]').click((function(){E(c,e(this).data("emoji-target")),n.modal("hide",100)}))}a.hide(),n.modal("refresh")}}).modal("show")})),""!=s.val()&&c.setValue(s.val(),-1)}))},e((function(){e(".main-martor").martor()})),"django"in window&&"jQuery"in window.django&&django.jQuery(document).on("formset:added",(function(n,o){o.find(".main-martor").each((function(){var n=o.attr("id");n=n.substr(n.lastIndexOf("-")+1);var t=e(this.outerHTML.replace(/__prefix__/g,n));e(this).replaceWith(t),t.martor()}))}))}(jQuery);
+!function(E){(E=E||django.jQuery).fn.martor=function(){E(".martor").trigger("martor.init");function P(e){var n=null,o=0;if(document.cookie&&""!==document.cookie)for(var t=document.cookie.split(";");oNothing to preview")},error:function(e){console.log("error",e)}})}var d=E(".tab.segment[data-tab=preview-tab-"+s+"]"),a=E(".item[data-tab=preview-tab-"+s+"]");let u;if(window.onload=function(){l()},"true"!==i.living?a.click(function(){E(this).closest(".tab-martor-menu").find(".martor-toolbar").hide(),l()}):c.on("change",function(){u&&clearTimeout(u),u=setTimeout(l,r.data("save-timeout"))}),E(".item[data-tab=editor-tab-"+s+"]").click(function(){E(this).closest(".tab-martor-menu").find(".martor-toolbar").show()}),"true"==i.spellcheck)try{enable_spellcheck(t)}catch(e){console.log("Spellcheck lib doesn't installed.")}function f(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," **** "),e.focus(),e.selection.moveTo(o.row,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"**"+o+"**"),t.end.column+=4,e.focus(),e.selection.setSelectionRange(t))}function g(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," __ "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"_"+o+"_"),t.end.column+=2,e.focus(),e.selection.setSelectionRange(t))}function p(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n----------\n\n"),e.focus(),e.selection.moveTo(o.row+4,o.column+10)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n----------\n\n"+o),e.focus(),e.selection.moveTo(t.end.row+4,t.end.column+10))}function w(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n# "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n# "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function v(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n## "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n## "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+3))}function k(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n### "),e.focus(),e.selection.moveTo(o.row+2,o.column+4)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n### "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+4))}function C(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n```\n\n```\n"),e.focus(),e.selection.moveTo(o.row+3,o.column)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n```\n"+o+"\n```\n"),e.focus(),e.selection.moveTo(t.end.row+3,t.end.column+3))}function h(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," `` "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"`"+o+"`"),t.end.column+=2,e.focus(),e.selection.setSelectionRange(t))}function y(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n> \n"),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n> "+o+"\n"),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function T(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n* "),e.focus(),e.selection.moveTo(o.row+2,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n* "+o),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+2))}function S(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o,"\n\n1. "),e.focus(),e.selection.moveTo(o.row+2,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"\n\n1. "+o),e.focus(),e.selection.moveTo(t.end.row+2,t.end.column+3))}function b(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," [](https://) "),e.focus(),e.selection.moveTo(o.row,o.column+2)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"["+o+"](https://) "),e.focus(),e.selection.moveTo(t.end.row,t.end.column+10))}function R(e,n){var o,t,i,a=e.getSelectionRange();void 0===n?e.selection.isEmpty()?(i=e.getCursorPosition(),e.session.insert(i," ![](https://) "),e.focus(),e.selection.moveTo(i.row,i.column+3)):(o=e.getSelectionRange(),t=e.session.getTextRange(o),e.session.replace(o,"!["+t+"](https://) "),e.focus(),e.selection.moveTo(a.end.row,a.end.column+11)):(i=e.getCursorPosition(),e.session.insert(i,"!["+n.name+"]("+n.link+") "),e.focus(),e.selection.moveTo(i.row,i.column+n.name.length+2))}function x(e){var n,o,t=e.getSelectionRange();e.selection.isEmpty()?(o=e.getCursorPosition(),e.session.insert(o," @[]"),e.focus(),e.selection.moveTo(o.row,o.column+3)):(n=e.getSelectionRange(),o=e.session.getTextRange(n),e.session.replace(n,"@["+o+"]"),e.focus(),e.selection.moveTo(t.end.row,t.end.column+3))}c.commands.addCommand({name:"markdownToBold",bindKey:{win:"Ctrl-B",mac:"Command-B"},exec:function(e){f(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToItalic",bindKey:{win:"Ctrl-I",mac:"Command-I"},exec:function(e){g(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnderscores",bindKey:{win:"Ctrl-Shift-U",mac:"Command-Shift-U"},exec:function(e){var n,o,t;t=(n=e).getSelectionRange(),n.selection.isEmpty()?(o=n.getCursorPosition(),n.session.insert(o," ++++ "),n.focus(),n.selection.moveTo(o.row,o.column+3)):(e=n.getSelectionRange(),o=n.session.getTextRange(e),n.session.replace(e,"++"+o+"++"),t.end.column+=4,n.focus(),n.selection.setSelectionRange(t))},readOnly:!0}),c.commands.addCommand({name:"markdownToStrikethrough",bindKey:{win:"Ctrl-Shift-S",mac:"Command-Shift-S"},exec:function(e){var n,o,t;t=(n=e).getSelectionRange(),n.selection.isEmpty()?(o=n.getCursorPosition(),n.session.insert(o," ~~~~ "),n.focus(),n.selection.moveTo(o.row,o.column+3)):(e=n.getSelectionRange(),o=n.session.getTextRange(e),n.session.replace(e,"~~"+o+"~~"),t.end.column+=4,n.focus(),n.selection.setSelectionRange(t))},readOnly:!0}),c.commands.addCommand({name:"markdownToHorizontal",bindKey:{win:"Ctrl-H",mac:"Command-H"},exec:function(e){p(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH1",bindKey:{win:"Ctrl-Alt-1",mac:"Command-Option-1"},exec:function(e){w(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH2",bindKey:{win:"Ctrl-Alt-2",mac:"Command-Option-3"},exec:function(e){v(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToH3",bindKey:{win:"Ctrl-Alt-3",mac:"Command-Option-3"},exec:function(e){k(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToPre",bindKey:{win:"Ctrl-Alt-P",mac:"Command-Option-P"},exec:function(e){C(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToCode",bindKey:{win:"Ctrl-Alt-C",mac:"Command-Option-C"},exec:function(e){h(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToBlockQuote",bindKey:{win:"Ctrl-Q",mac:"Command-Shift-K"},exec:function(e){y(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToUnorderedList",bindKey:{win:"Ctrl-U",mac:"Command-U"},exec:function(e){T(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToOrderedList",bindKey:{win:"Ctrl-Shift+O",mac:"Command-Option-O"},exec:function(e){S(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToLink",bindKey:{win:"Ctrl-L",mac:"Command-L"},exec:function(e){b(e)},readOnly:!0}),c.commands.addCommand({name:"markdownToImageLink",bindKey:{win:"Ctrl-Shift-I",mac:"Command-Option-I"},exec:function(e){R(e)},readOnly:!0}),"true"===i.mention&&c.commands.addCommand({name:"markdownToMention",bindKey:{win:"Ctrl-M",mac:"Command-M"},exec:function(e){x(e)},readOnly:!0}),E(".markdown-bold[data-field-name="+s+"]").click(function(){f(c)}),E(".markdown-italic[data-field-name="+s+"]").click(function(){g(c)}),E(".markdown-horizontal[data-field-name="+s+"]").click(function(){p(c)}),E(".markdown-h1[data-field-name="+s+"]").click(function(){w(c)}),E(".markdown-h2[data-field-name="+s+"]").click(function(){v(c)}),E(".markdown-h3[data-field-name="+s+"]").click(function(){k(c)}),E(".markdown-pre[data-field-name="+s+"]").click(function(){C(c)}),E(".markdown-code[data-field-name="+s+"]").click(function(){h(c)}),E(".markdown-blockquote[data-field-name="+s+"]").click(function(){y(c)}),E(".markdown-unordered-list[data-field-name="+s+"]").click(function(){T(c)}),E(".markdown-ordered-list[data-field-name="+s+"]").click(function(){S(c)}),E(".markdown-link[data-field-name="+s+"]").click(function(){b(c)}),E(".markdown-image-link[data-field-name="+s+"]").click(function(){R(c)});n=E(".markdown-direct-mention[data-field-name="+s+"]"),a=E(".markdown-image-upload[data-field-name="+s+"]");"true"===i.mention?n.click(function(){x(c)}):(n.remove(),E(".markdown-reference tbody tr")[1].remove()),"true"===i.imgur?a.on("change",function(e){var n,o;e.preventDefault(),n=c,e=E("#"+t).closest("form").get(0),o=n.container.id.replace("martor-",""),(e=new FormData(e)).append("csrfmiddlewaretoken",P("csrftoken")),E.ajax({url:r.data("upload-url"),type:"POST",data:e,async:!0,cache:!1,contentType:!1,enctype:"multipart/form-data",processData:!1,beforeSend:function(){console.log("Uploading..."),E(".upload-progress[data-field-name="+o+"]").show()},success:function(e){E(".upload-progress[data-field-name="+o+"]").hide(),200==e.status?(console.log(e),R(n,imageData={name:e.name,link:e.link})):alert(e.error)},error:function(e){console.log("error",e),E(".upload-progress[data-field-name="+o+"]").hide()}})}):a.remove(),E(".markdown-help[data-field-name="+s+"]").click(function(){E(".modal-help-guide[data-field-name="+s+"]").modal("show")}),o.find(".ui.martor-toolbar .ui.dropdown").dropdown(),o.find(".ui.tab-martor-menu .item").tab();function O(){E(document.body).removeClass("overflow"),E(this).attr({title:"Full Screen"}),E(this).find(".minimize.icon").removeClass("minimize").addClass("maximize"),E(".main-martor-fullscreen").find(".martor-preview").removeAttr("style"),o.removeClass("main-martor-fullscreen"),j.removeAttr("style"),c.resize()}var j=E(".martor-field-"+s),a=E(".markdown-toggle-maximize[data-field-name="+s+"]");a.on("click",function(){!function(e){e.attr({title:"Minimize"}),e.find(".maximize.icon").removeClass("maximize").addClass("minimize"),o.addClass("main-martor-fullscreen");var n=document.body.clientHeight-90;j.attr({style:"height:"+n+"px"}),E(".main-martor-fullscreen").find(".martor-preview").attr({style:"overflow-y: auto;height:"+n+"px"}),c.resize(),e.one("click",O),E(document.body).addClass("overflow")}(E(this))}),E(document).keyup(function(e){27==e.keyCode&&o.hasClass("main-martor-fullscreen")&&E(".minimize.icon").trigger("click")}),E(".markdown-emoji[data-field-name="+s+"]").click(function(){var t=E(".modal-emoji[data-field-name="+s+"]"),o="undefined"!=typeof emojis?emojis:[],i=t.find(".emoji-content-body"),a=t.find(".emoji-loader-init");i.html(""),a.show(),t.modal({onVisible:function(){for(var e=0;e '+o[e]+"
"),E('a[data-emoji-target="'+o[e]+'"]').click(function(){var e,n,o;e=c,n=E(this).data("emoji-target"),o=e.getCursorPosition(),e.session.insert(o," "+n+" "),e.focus(),e.selection.moveTo(o.row,o.column+n.length+2),t.modal("hide",100)})}a.hide(),t.modal("refresh")}}).modal("show")}),c.setValue(r.val(),-1)})},E(function(){E(".main-martor").martor()}),"django"in window&&"jQuery"in window.django&&django.jQuery(document).on("formset:added",function(e,n){setTimeout(function(){n.find(".main-martor").each(function(){var e=(e=n.attr("id")).substr(e.lastIndexOf("-")+1),e=E(this.outerHTML.replace(/__prefix__/g,e));E(this).replaceWith(e),e.martor()})},1e3)})}(jQuery);