diff --git a/go.mod b/go.mod
index 54d642676..87a1a0d6e 100644
--- a/go.mod
+++ b/go.mod
@@ -40,7 +40,7 @@ require (
github.com/admpub/copier v0.1.1
github.com/admpub/go-ps v0.0.1
github.com/admpub/regexp2 v1.1.8
- github.com/coscms/webcore v0.3.13
+ github.com/coscms/webcore v0.3.14
github.com/nging-plugins/caddymanager v1.6.2
github.com/nging-plugins/collector v1.6.1
github.com/nging-plugins/dbmanager v1.6.6
@@ -252,7 +252,7 @@ require (
github.com/coscms/forms v1.12.2 // indirect
github.com/coscms/go-imgparse v0.0.1 // indirect
github.com/coscms/oauth2s v0.4.1 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fcjr/aia-transport-go v1.2.2 // indirect
@@ -263,7 +263,7 @@ require (
github.com/garyburd/redigo v1.6.4 // indirect
github.com/geoffgarside/ber v1.1.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
- github.com/go-acme/lego/v4 v4.18.0 // indirect
+ github.com/go-acme/lego/v4 v4.19.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
@@ -316,11 +316,11 @@ require (
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/pkg/errors v0.9.1 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
- github.com/prometheus/common v0.59.1 // indirect
+ github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
@@ -336,7 +336,7 @@ require (
github.com/syndtr/goleveldb v1.0.0
github.com/tidwall/btree v1.7.0 // indirect
github.com/tidwall/buntdb v1.3.2 // indirect
- github.com/tidwall/gjson v1.17.3 // indirect
+ github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/grect v0.1.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
diff --git a/go.sum b/go.sum
index e489fa54e..6e2ffbea2 100644
--- a/go.sum
+++ b/go.sum
@@ -1095,8 +1095,8 @@ github.com/coscms/oauth2s v0.4.1 h1:wt8IpmGmI/mwecKwjbdDWsGhecFJtJ2todeTdWWEg+0=
github.com/coscms/oauth2s v0.4.1/go.mod h1:O2SoVCCNeStzWkHTQ9/udvGiWI5/tKGR7x7H9rwkN0Q=
github.com/coscms/webauthn v0.3.1 h1:ycolyzptBj7d+boEvxw1JAGkgJcR8r6kVSA4wDrahNk=
github.com/coscms/webauthn v0.3.1/go.mod h1:nyMNZvFm9cArfyu6RQjrGvI+CCsl9mcC01jT4MsmByQ=
-github.com/coscms/webcore v0.3.13 h1:3I+cypHM5iERChR1fL5JgmUSyH56N2mhvQ6YqKpvjdw=
-github.com/coscms/webcore v0.3.13/go.mod h1:DEQ6jfUb9tQtfiV480YAwjoAiu10DiQe9weeLB9Rq5o=
+github.com/coscms/webcore v0.3.14 h1:wtTK7glkAxlr61ghy3BJftnkRb03UjaoWejcKZKExzc=
+github.com/coscms/webcore v0.3.14/go.mod h1:bY40kwT+vOHaAUr+43SLFSBGzlABjCHIApRlJXcSgp8=
github.com/cpu/goacmedns v0.1.1/go.mod h1:MuaouqEhPAHxsbqjgnck5zeghuwBP1dLnPoobeGqugQ=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@@ -1108,8 +1108,9 @@ github.com/creack/pty v1.1.23 h1:4M6+isWdcStXEf15G/RbrMPOQj1dZ7HPZCGwE4kOeP0=
github.com/creack/pty v1.1.23/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
+github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE=
github.com/deepmap/oapi-codegen v1.3.11/go.mod h1:suMvK7+rKlx3+tpa8ByptmvoXbAV70wERKTOGH3hLp0=
@@ -1233,8 +1234,8 @@ github.com/go-acme/lego/v4 v4.4.0/go.mod h1:l3+tFUFZb590dWcqhWZegynUthtaHJbG2fev
github.com/go-acme/lego/v4 v4.5.3/go.mod h1:mL1DY809LzjvRuaxINNxsI26f5oStVhBGTpJMiinkZM=
github.com/go-acme/lego/v4 v4.10.0/go.mod h1:EMbf0Jmqwv94nJ5WL9qWnSXIBZnvsS9gNypansHGc6U=
github.com/go-acme/lego/v4 v4.14.2/go.mod h1:kBXxbeTg0x9AgaOYjPSwIeJy3Y33zTz+tMD16O4MO6c=
-github.com/go-acme/lego/v4 v4.18.0 h1:2hH8KcdRBSb+p5o9VZIm61GAOXYALgILUCSs1Q+OYsk=
-github.com/go-acme/lego/v4 v4.18.0/go.mod h1:Blkg3izvXpl3zxk7WKngIuwR2I/hvYVP3vRnvgBp7m8=
+github.com/go-acme/lego/v4 v4.19.0 h1:c7YabBOwoa2URsPiCNGQsdzQnbd8Y23B4/66gxh4H7c=
+github.com/go-acme/lego/v4 v4.19.0/go.mod h1:wtDe3dDkmV4/oI2nydpNXSJpvV10J9RCyZ6MbYxNtlQ=
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs=
github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s=
@@ -2058,8 +2059,9 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR
github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo=
github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk=
github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
+github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
@@ -2097,8 +2099,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
-github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0=
-github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
+github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
+github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@@ -2312,8 +2314,8 @@ github.com/tidwall/buntdb v1.3.2/go.mod h1:lZZrZUWzlyDJKlLQ6DKAy53LnG7m5kHyrEHvv
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
-github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
-github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
+github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/grect v0.1.4 h1:dA3oIgNgWdSspFzn1kS4S/RDpZFLrIxAZOdJKjYapOg=
github.com/tidwall/grect v0.1.4/go.mod h1:9FBsaYRaR0Tcy4UwefBX/UDcDcDy9V5jUcxHzv2jd5Q=
github.com/tidwall/lotsa v1.0.2 h1:dNVBH5MErdaQ/xd9s769R31/n2dXavsQ0Yf4TMEHHw8=
diff --git a/public/assets/backend/js/editor/editor.js b/public/assets/backend/js/editor/editor.js
index 724594c83..cd35c8654 100644
--- a/public/assets/backend/js/editor/editor.js
+++ b/public/assets/backend/js/editor/editor.js
@@ -277,7 +277,7 @@ App.editor.markdown = function (editorElement, uploadUrl, options) {
dialogLockScreen: false,
onload: function () {
var editor=this;
- editormd.loadPlugin(path+"plugins/drop-or-paste-upload/drop-or-paste-upload", function(){
+ editormd.loadPlugin(path+"plugins/drop-or-paste-upload/drop-or-paste-upload.min", function(){
editor.dropOrPasteUpload();
});
}
diff --git a/public/assets/backend/js/editor/editor.min.js b/public/assets/backend/js/editor/editor.min.js
index 173fd897e..cc33ac570 100644
--- a/public/assets/backend/js/editor/editor.min.js
+++ b/public/assets/backend/js/editor/editor.min.js
@@ -1 +1 @@
-App.loader.libs.editormdPreview=["#editor/markdown/lib/marked.min.js","#editor/markdown/lib/prettify.min.js","#editor/markdown/lib/raphael.min.js","#editor/markdown/lib/underscore.min.js","#editor/markdown/css/editormd.preview.min.css","#editor/markdown/editormd.min.js"];App.loader.libs.codemirror=["#editor/markdown/lib/codemirror/codemirror.min.css","#editor/markdown/lib/codemirror/addon/fold/foldgutter.css","#editor/markdown/lib/codemirror/addon/hint/show-hint.css","#editor/markdown/lib/codemirror/theme/ambiance.css","#editor/markdown/lib/codemirror/codemirror.min.js","#editor/markdown/lib/codemirror/modes.min.js","#editor/markdown/lib/codemirror/addons.min.js","#editor/markdown/lib/codemirror/addon/hint/show-hint.js"];App.loader.libs.editormd=["#editor/markdown/css/editormd.min.css","#editor/markdown/css/editormd.preview.min.css","#editor/markdown/editormd.min.js"];App.loader.libs.flowChart=["#editor/markdown/lib/flowchart.min.js"];App.loader.libs.flowChartJQuery=["#editor/markdown/lib/jquery.flowchart.min.js"];App.loader.libs.sequenceDiagram=["#editor/markdown/lib/sequence-diagram.min.js"];App.loader.libs.tinymce=["#editor/tinymce/custom.css","#editor/tinymce/tinymce.min.js","#editor/tinymce/jquery.tinymce.min.js","#editor/tinymce/langs/"+App.langTag("_")+".js"];App.loader.libs.dialog=["#dialog/bootstrap-dialog.min.css","#dialog/bootstrap-dialog.min.js"];App.loader.libs.markdownit=["#markdown/it/markdown-it.min.js","#markdown/it/plugins/emoji/markdown-it-emoji.min.js"];App.loader.libs.codehighlight=["#markdown/it/plugins/highlight/loader/prettify.js","#markdown/it/plugins/highlight/loader/run_prettify.js?skin=sons-of-obsidian"];App.loader.libs.powerFloat=["#float/powerFloat.min.css","#float/powerFloat.min.js"];App.loader.libs.uploadPreviewer=["#jquery.uploadPreviewer/css/jquery.uploadPreviewer.min.css","#jquery.uploadPreviewer/jquery.uploadPreviewer.min.js"];App.loader.libs.fileUpload=["#jquery.upload/js/vendor/jquery.ui.widget.min.js","#jquery.upload/js/jquery.iframe-transport.min.js","#jquery.upload/js/jquery.fileupload.min.js","#jquery.upload/js/jquery.fileupload-process.min.js"];App.loader.libs.jcrop=["#jquery.crop/css/jquery.Jcrop.min.css","#jquery.crop/js/jquery.Jcrop.min.js"];App.loader.libs.cropImage=["#jquery.crop/css/jquery.Jcrop.min.css","#jquery.crop/js/jquery.Jcrop.min.js","#behavior/page/crop-image.min.js"];App.loader.libs.select2=["#jquery.select2/select2.css","#jquery.select2/select2.min.js"];App.loader.libs.select2ex=["#behaviour/page/select2.min.js"];App.loader.libs.selectPage=["#selectpage/selectpage.css","#selectpage/selectpage.min.js"];App.loader.libs.cascadeSelect=["#behaviour/page/cascade-select.min.js"];App.loader.libs.forms=["#behaviour/page/forms.min.js"];App.loader.libs.jqueryui=["#jquery.ui/jquery-ui.custom.min.js","#jquery.ui/jquery-ui.touch-punch.min.js"];App.loader.libs.dropzone=["#jquery.ui/css/dropzone.min.css","#dropzone/dropzone.min.js"];App.loader.libs.loadingOverlay=["#loadingoverlay/loadingoverlay.min.js"];App.loader.libs.dateRangePicker=["#daterangepicker/daterangepicker.min.css","#daterangepicker/moment.min.js","#daterangepicker/jquery.daterangepicker.min.js","#behaviour/page/datetime.min.js"];App.loader.libs.magnificPopup=["#magnific-popup/magnific-popup.min.css","#magnific-popup/jquery.magnific-popup.min.js"];App.loader.libs.inputmask=["#inputmask/inputmask.min.js","#inputmask/jquery.inputmask.min.js"];App.loader.libs.clipboard=["#clipboard/clipboard.min.js","#clipboard/utils.js"];App.editor={browsingFileURL:App.loader.siteURL+(typeof window.IS_BACKEND!=="undefined"&&window.IS_BACKEND?BACKEND_URL:FRONTEND_URL+"/user/file")+"/finder"};App.editor.loadingOverlay=function(e){App.loader.defined(typeof $.fn.LoadingOverlay,"loadingOverlay");return $.LoadingOverlay(e||{})};App.editor.dialog=function(e){App.loader.defined(typeof BootstrapDialog,"dialog");return BootstrapDialog.show(e||{})};App.editor.contypeAttachers={};App.editor.contypeAttachers.markdown=function(e){App.editor.markdownToHTML(e)};App.editor.contypeAttachers.html=function(e){var t=$(e).find("pre[class^=language-]");if(t.length>0)App.editor.codeHighlight(t)};App.editor.attachContype=function(e){var t=e?$(e):$(document);t.find("[data-contype]:not([contype-attached])").each(function(){$(this).attr("contype-attached","1");var e=$(this).data("contype");if(typeof App.editor.contypeAttachers[e]!="undefined"){App.editor.contypeAttachers[e](this)}})};App.editor.markdownReset=function(){var e=ASSETS_URL+"/js/editor/markdown/";editormd.emoji.path=e+"images/emojis/";editormd.katexURL.css=e+"lib/katex/katex.min";editormd.katexURL.js=e+"lib/katex/katex.min"};App.editor.markdownToHTML=function(i,o,e){if(typeof i=="string"){i=document.querySelector(i);if(!i)return}if($(i).data("markdownRendered"))return;$(i).data("markdownRendered",true);var t=function(e,t){var i={markdown:o,htmlDecode:"style,script,iframe|on*",toc:true,tocm:true,emoji:true,taskList:true,tex:true,flowChart:true,sequenceDiagram:true};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){i.theme="dark"}var r=$.extend({},i,e||{});var a=function(){return t(r)};App.loader.defined(typeof marked,"editormdPreview",function(){if(r.flowChart){return App.loader.defined(typeof flowchart,"flowChart",function(){return App.loader.defined(typeof $.fn.flowChart,"flowChartJQuery",function(){if(r.sequenceDiagram)return App.loader.defined(typeof $.fn.sequenceDiagram,"sequenceDiagram",function(){a()});a()})})}if(needSequenceDiagram){return App.loader.defined(typeof $.fn.sequenceDiagram,"sequenceDiagram",function(){a()})}a()},function(){App.editor.markdownReset()});return r};var r="markdown-render-processing-"+App.utils.unixtime();var a='
';if(o==null||typeof o=="boolean"){var n=$(i),d=$(i).hasClass("markdown-code");if(!o&&!d){n=$(i).find(".markdown-code");if(n.length<1)return}if(d){n.prepend(a)}else{n.first().before(a)}t(e,function(t){n.each(function(){if($(this).children("textarea").length>0){t.markdown=$(this).children("textarea").text()}else{t.markdown=$(this).text()}var e=editormd.markdownToHTML(this,t);$(this).data("markdown-viewer",e)});$("#"+r).remove()});return}$(i).before(a);t(e,function(e){var t=editormd.markdownToHTML(i,e);$(i).data("markdown-viewer",t);$("#"+r).remove()})};App.editor.markdowns=function(e,t,i){$(e).each(function(){App.editor.markdown(this,t,i)})};App.editor.markdown=function(e,t,i){var r=false;if(!t)t=$(e).attr("action");App.loader.defined(typeof editormd,"editormd",null,function(){App.editor.markdownReset()});if(t){if(t.substr(0,1)=="!"){t=t.substr(1);r=true}if(t.indexOf("?")>=0){t+="&"}else{t+="?"}if(!r)t+="format=json&";t+="filetype=image&client=markdown"}var a=function(t){App.editor.finderDialog(App.editor.browsingFileURL+"?from=parent&size=12&filetype=image&multiple=0",function(e){if(e.length<=0){return App.message({type:"error",text:App.t("没有选择任何选项!")})}t.dialog.find("[data-url]").val(e[0])},1e5)};var o=$(e).parent(),n=o.attr("id");if(n===undefined){n="webx-md-"+App.utils.unixtime();o.attr("id",n)}var d=ASSETS_URL+"/js/editor/markdown/";var p={width:"100%",height:o.height(),path:d+"lib/",markdown:$(e).val(),placeholder:$(e).attr("placeholder")||"",codeFold:true,saveHTMLToTextarea:true,searchReplace:true,watch:true,htmlDecode:"style,script,iframe|on*",emoji:true,taskList:true,tocm:true,tex:true,flowChart:true,sequenceDiagram:true,imageUpload:true,imageFormats:["jpg","jpeg","gif","png","bmp"],imageUploadURL:t,imageBrowseFn:a,crossDomainUpload:true,uploadCallbackURL:d+"plugins/image-dialog/upload_callback.htm",dialogLockScreen:false,onload:function(){var e=this;editormd.loadPlugin(d+"plugins/drop-or-paste-upload/drop-or-paste-upload",function(){e.dropOrPasteUpload()})}};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){p.theme="dark"}var l=$.extend({},p,i||{});if(r){l.toolbarIcons=function(){return["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","browsing-image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"]};l.toolbarIconsClass={"browsing-image":"fa-image"};l.toolbarIconTexts={"browsing-image":App.t("选择图片")};l.toolbarHandlers={"browsing-image":function(n,e,t,i){App.editor.finderDialog(App.editor.browsingFileURL+"?from=parent&size=12&filetype=image&multiple=1",function(e,t){if(e.length<=0){return App.message({type:"error",text:App.t("没有选择任何选项!")})}var i=[];for(var r=0;r0){e=$(this).children("textarea").text()}else{e=$(this).text()}$(this).html(r.render($.trim(e)));$(this).find("pre > code").each(function(){$(this).parent("pre").addClass("prettyprint linenums")});if(typeof prettyPrint!=="undefined")prettyPrint()})};App.editor.markdownItInstance=function(){App.loader.defined(typeof window.markdownit,"markdownit");var e=window.markdownit();if(typeof window.markdownitEmoji!="undefined")e.use(window.markdownitEmoji);return e};App.editor.tinymces=function(e,t,i,r){$(e).each(function(){App.editor.tinymce(this,t,i,r)})};App.editor.finderDialog=function(t,r,i){if(!i)i=2e3;App.loader.defined(typeof BootstrapDialog,"dialog");var e=BootstrapDialog.show({title:App.t("选择文件"),message:function(i){var e="finderDialogCallback"+App.utils.unixtime();window[e]=function(e,t){r(e,t);if(e&&e.length>0)i.close()};return $('')},onshown:function(e){e.$modal.css("zIndex",i);e.$modalBody.css("padding",0)}});return e};App.editor.tinymceOnceFix=false;App.editor.tinymce=function(e,o,t,i){if(!App.editor.tinymceOnceFix){App.editor.tinymceOnceFix=true;$(document).on("focusin",function(e){if($(e.target).closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length){e.stopImmediatePropagation()}})}App.loader.defined(typeof $.fn.tinymce,"tinymce");if(!o)o=$(e).attr("action");var r=App.editor.browsingFileURL;if(o&&o.substr(0,1)=="!"){r=o.substr(1);o=$(e).data("upload-url")}if(o){if(o.indexOf("?")>=0){o+="&"}else{o+="?"}o+="format=json&client=tinymce&filetype="}if(r){r=r.replace(/[\?&]multiple=1/,"");if(r.indexOf("?")>=0){r+="&"}else{r+="?"}r+="from=parent&client=tinymce&filetype="}var a="undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | customDateButton";var n="undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | insertfile image media template link anchor codesample | ltr rtl | customDateButton";var d=function(i,e,t){switch(t.filetype){case"file":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{text:t[0].name})});break;case"image":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{alt:t[0].name})});break;case"media":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{})});break;default:alert("Unsupported file type")}};var p=function(e,t,i){var r=new XMLHttpRequest,a=new FormData;r.withCredentials=false;r.open("POST",o);r.onload=function(){if(r.status!=200){i("HTTP Error: "+r.status);return}var e=JSON.parse(r.responseText);if(!e||typeof e.Code=="undefined"){i("Invalid JSON: "+r.responseText);return}if(e.Code!=1){i(e.Info);return}t(e.Data.Url)};a.append("filedata",e.blob(),e.filename());r.send(a)};var l="link table";var s="bold italic | quicklink h2 h3 blockquote quicktable";var c="print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern noneditable charmap quickbars emoticons";if(o){l+=" image imagetools";s+=" quickimage"}var f={height:i?200:500,menubar:true,language:App.langTag("_"),plugins:[c],toolbar:i?a:n,toolbar_sticky:true,autosave_ask_before_unload:false,autosave_interval:"30s",autosave_prefix:"{path}{query}-{id}-",autosave_restore_when_empty:true,autosave_retention:"2m",image_advtab:true,templates:[{title:"New Table",description:"creates a new table",content:'\t\t\t
\t\t\t\t\t\t\t\t\t\t\t\t | \t\t\t\t\t | \t\t\t\t
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t | \t\t\t\t\t | \t\t\t\t
\t\t\t\t\t\t
\t\t\t
'}],image_caption:true,relative_urls:false,image_title:true,quickbars_selection_toolbar:s,noneditable_noneditable_class:"mceNonEditable",toolbar_drawer:"sliding",contextmenu:l,setup:function(r){var t=function(e){return'"};r.ui.registry.addButton("customDateButton",{icon:"insert-time",tooltip:"Insert Current Date",disabled:true,onAction:function(e){r.insertContent(t(new Date))},onSetup:function(t){var i=function(e){t.setDisabled(e.element.nodeName.toLowerCase()==="time")};r.on("NodeChange",i);return function(e){r.off("NodeChange",i)}}})}};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){f.skin="oxide-dark";f.content_css="dark"}if(r)f.file_picker_callback=d;if(o)f.images_upload_handler=p;var u=App.utils.elemToId(e).replace(/^#/,"");$(e).tinymce($.extend({},f,t||{}));$(e).data("editor-name","tinymce");var m=tinymce.get(u);$(e).data("editor-object",m)};App.editor.switcher=function(e,r,a){if($(e).length<1)return;var t,i=String($(e).get(0).tagName).toLowerCase();switch(i){case"select":t="change";break;default:t="click"}$(e).on(t,function(){var e=$(this).val();var t=$(r);var i=$(this).data("editor-name")||a;t.data("editor-type",e);return App.editor.switch(i,t)});$(r).data("placeholder",$(r).attr("placeholder"));switch(i){case"input":$(e).filter(":checked").first().trigger(t);break;default:$(e).trigger(t)}};App.editor.switch=function(e,r,t,i){var a=r.attr("action")||r.data("upload-url")||"!"+App.editor.browsingFileURL+"?size=12&multiple=1",o=r.data("editor-type"),n=r.data("editor-name"),d=r.data("editor-object"),p=r.data("current-editor-type");if(p==o)return;var l=r.data("class"),s=r.data("style");if(l===undefined){l=r.attr("class");if(!l)l="";r.data("class",l)}if(s===undefined){s=r.attr("style");if(!s)s="";r.data("style",s)}var c=r.data("content-elem"),f=c;if(c)f=App.loader.parseTmpl(c,{type:o});var u=r.get(0);var m=function(){r.attr("class",l).attr("style",s)};var g=function(){switch(n){case"ueditor":d&&d.destroy();break;case"tinymce":default:d&&typeof d.remove=="function"&&d.remove()}};var h=function(e){var t=r.data(e+"-options")||{};switch(e){case"ueditor":App.editor.ueditor(u,a,t);break;case"tinymce":default:App.editor.tinymce(u,a,t);var i=window.setInterval(function(){if(r.next(".tox-tinymce").length>0){r.next(".tox-tinymce").show();window.clearInterval(i)}},100);break}};var w=function(){var e=r.data("markdown-options")||{};App.editor.markdown(u,a,e)};var y=function(){if(f&&$(f).length>0){var e=App.loader.parseTmpl(c,{type:p});if(e&&$(e).length>0){$(e).text(r.val());var t=$('textarea[name="'+r.parent().attr("id")+'-html-code"]');if(t.length>0&&t.val()!=""){$(f).text(t.val());$(f).val(t.val())}}r.val($(f).val());r.text($(f).val())}r.parent().removeAttr("class").css("height","auto");r.siblings().remove();m()};switch(o){case"markdown":if(i){var v=App.loader.parseTmpl(c,{type:p});if(v&&$(v).length>0){if(r.val()!=$(v).val()&&!confirm("确定要切换吗?切换编辑器将会丢失您当前所做的修改。")){if(t!=null)t();return false}}}if(f&&$(f).length>0){r.text($(f).val());r.val($(f).val())}g();w();r.data("current-editor-type",o);break;case"text":g();y();r.show().focus();r.data("current-editor-type",o);break;default:y();h(e);r.data("current-editor-type","html")}return true};if(typeof App.utils=="undefined")App.utils={};App.utils.elemToId=function(e){if(typeof e!="object"){if(String(e).substring(0,1)!="#"){e="#"+e}return e}var t=$(e).attr("id");if(t)return"#"+t;t="generated-id-"+App.utils.unixtime();$(e).attr("id",t);return"#"+t};App.utils.unixtime=function(){return(new Date).getTime()};App.editor.selectPages=function(){App.loader.defined(typeof $.fn.selectPage,"selectPage");for(var e=0;e=0){t+="&"}else{t+="?"}t+="from=parent&client=fileInput&filetype=image";var o=this;App.editor.finderDialog(t,function(e){var t=e[0];var i=$(o).data("input");if(!i){i=$(o).parent(".input-group-btn").siblings("input")[0]}if(i)$(i).val(t);var r=$(o).data("preview-btn");if(!r){r=$(o).parent(".input-group-btn").siblings(".preview-btn")[0]}if(r){if(!$(r).data("attached-float")){App.float(App.utils.elemToId(r)+" a img");$(r).data("attached-float",true)}$(r).removeClass("hidden").children("a").attr("href",t).children("img").attr("src",t)}var a=$(o).data("preview-img");if(a){$(a).attr("src",t)}if(n)n(t)})})});$(e+'input[data-toggle="uploadPreviewer"]').each(function(){$(this).css("width","70px");var e=$(this).data("preview-container");var t=$(this).data("upload-url");var i=$(this).data("preview-btn");var r=$(this).uploadPreviewer($.extend({buttonText:' '+App.t("上传"),previewTableContainer:e,url:t,previewTableShow:false},a||{}));$(this).data("uploadPreviewer",r);if(i&&!$(i).data("attached-float")){App.float(App.utils.elemToId(i)+" a img");$(i).data("attached-float",true)}$(this).on("file-preview:changed",function(o){$(o.target).data("uploadPreviewer").submit(function(e){if(e.Code!=1){if(d)d(e);return App.message({text:e.Info,type:"error"})}var t=e.Data.files[0];var i=$(o.target).data("input");if(!i){i=$(o.target).parents(".input-group-btn").prev("input")[0]}$(i).val(t);var r=$(o.target).data("preview-btn");if(!r){r=$(o.target).parents(".input-group-btn").siblings(".preview-btn")[0]}if(r){if(!$(r).data("attached-float")){App.float(App.utils.elemToId(r)+" a img");$(r).data("attached-float",true)}$(r).removeClass("hidden").children("a").attr("href",t).children("img").attr("src",t)}var a=$(o.target).data("preview-img");if(a){$(a).attr("src",t)}if(n)n(t);App.message({text:App.t("上传成功"),type:"success"})},function(){if(d)d()})})})};App.editor.codemirror=function(l,s,c){if($(l).length<1)return null;var e=function(){if($(l).data("codemirror"))return;var e={lineNumbers:true,lineWrapping:true,lineWrapping:true,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],autoCloseTags:true,autoCloseBrackets:true,showTrailingSpace:true,indentWithTabs:true,matchBrackets:true,styleActiveLine:true,styleSelectedText:true,highlightSelectionMatches:true,smartIndent:true,mode:"text/x-csrc",width:null,height:null,hintOptions:{completeSingle:false}};var t=$.extend(e,s||{});var i=$(l)[0].tagName.toUpperCase()=="TEXTAREA"?CodeMirror.fromTextArea($(l)[0],t):CodeMirror($(l)[0],t);var r=t.mode,a={"text/x-csrc":"clike","text/css":"css","text/x-mysql":"sql","text/x-mssql":"sql","text/x-markdown":"markdown","text/x-yaml":"yaml","text/x-toml":"toml","text/javascript":"javascript","application/javascript":"javascript","text/json":"javascript","text/html":"html","message/http":"http",null:"null"};if(c&&typeof c=="object"){a=$.extend(a,c);c=null}if(!c){if(t.mode in a){c=a[t.mode]}else{if(typeof CodeMirror.modeInfo!=="undefined"){for(var o=0;o=0?"&":"?";e.url+=p+"client=dropzone"}var l=$(r).dropzone($.extend({paramName:"file",maxFilesize:.5,acceptedFiles:"image/*",dictDefaultMessage:'\t\t \t\t'+App.t("点击此处或拖动文件到这里开始上传")+'
\t\t\t\t
',dictResponseError:App.t("上传文件出错!"),dictCancelUpload:App.t("取消"),dictRemoveFile:App.t("删除")},e||{}));var s=l[0].dropzone;s.on("success",function(e,t,i){if(t.error){if(typeof t.error.message!="undefined")t.error=t.error.message;if(o)o.call(this,e,t.error);return App.message({text:t.error,type:"error"})}if(a)a.apply(this,arguments);else $(r).trigger("dropzone.success",arguments)}).on("removedfile",function(e){if(t)t.apply(this,arguments);else $(r).trigger("dropzone.removedfile",arguments)}).on("error",function(e,t,i){if(o)o.apply(this,arguments);else $(r).trigger("dropzone.error",arguments)});if(i){s.on("processing",function(e){s.options.url=e.uploadURL})}$(r).data("dropzone",s);return s};App.editor.dateRangePicker=function(e,t){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.daterangepicker(e,t)};App.editor.dateRangePickerx=function(e,t,i,r){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.daterangepickerx(e,t,i,r)};App.editor.datePicker=function(e,t){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.datepicker(e,t)};App.editor.popup=function(e,t){if(e==null)e=".image-zoom";var i={type:"image",mainClass:"mfp-with-zoom",zoom:{enabled:true,duration:300,easing:"ease-in-out",opener:function(e){var t=$(e);return t}}};App.loader.defined(typeof $.fn.magnificPopup,"magnificPopup",function(){$(e).magnificPopup($.extend(i,t||{}))})};App.editor.inputmask=function(e,t){App.loader.defined(typeof $.fn.inputmask,"inputmask",function(){$(e).inputmask(t)})};App.editor.clipboard=function(e,t){App.loader.defined(typeof ClipboardJS,"clipboard",function(){attachCopy(e,t)})};
\ No newline at end of file
+App.loader.libs.editormdPreview=["#editor/markdown/lib/marked.min.js","#editor/markdown/lib/prettify.min.js","#editor/markdown/lib/raphael.min.js","#editor/markdown/lib/underscore.min.js","#editor/markdown/css/editormd.preview.min.css","#editor/markdown/editormd.min.js"];App.loader.libs.codemirror=["#editor/markdown/lib/codemirror/codemirror.min.css","#editor/markdown/lib/codemirror/addon/fold/foldgutter.css","#editor/markdown/lib/codemirror/addon/hint/show-hint.css","#editor/markdown/lib/codemirror/theme/ambiance.css","#editor/markdown/lib/codemirror/codemirror.min.js","#editor/markdown/lib/codemirror/modes.min.js","#editor/markdown/lib/codemirror/addons.min.js","#editor/markdown/lib/codemirror/addon/hint/show-hint.js"];App.loader.libs.editormd=["#editor/markdown/css/editormd.min.css","#editor/markdown/css/editormd.preview.min.css","#editor/markdown/editormd.min.js"];App.loader.libs.flowChart=["#editor/markdown/lib/flowchart.min.js"];App.loader.libs.flowChartJQuery=["#editor/markdown/lib/jquery.flowchart.min.js"];App.loader.libs.sequenceDiagram=["#editor/markdown/lib/sequence-diagram.min.js"];App.loader.libs.tinymce=["#editor/tinymce/custom.css","#editor/tinymce/tinymce.min.js","#editor/tinymce/jquery.tinymce.min.js","#editor/tinymce/langs/"+App.langTag("_")+".js"];App.loader.libs.dialog=["#dialog/bootstrap-dialog.min.css","#dialog/bootstrap-dialog.min.js"];App.loader.libs.markdownit=["#markdown/it/markdown-it.min.js","#markdown/it/plugins/emoji/markdown-it-emoji.min.js"];App.loader.libs.codehighlight=["#markdown/it/plugins/highlight/loader/prettify.js","#markdown/it/plugins/highlight/loader/run_prettify.js?skin=sons-of-obsidian"];App.loader.libs.powerFloat=["#float/powerFloat.min.css","#float/powerFloat.min.js"];App.loader.libs.uploadPreviewer=["#jquery.uploadPreviewer/css/jquery.uploadPreviewer.min.css","#jquery.uploadPreviewer/jquery.uploadPreviewer.min.js"];App.loader.libs.fileUpload=["#jquery.upload/js/vendor/jquery.ui.widget.min.js","#jquery.upload/js/jquery.iframe-transport.min.js","#jquery.upload/js/jquery.fileupload.min.js","#jquery.upload/js/jquery.fileupload-process.min.js"];App.loader.libs.jcrop=["#jquery.crop/css/jquery.Jcrop.min.css","#jquery.crop/js/jquery.Jcrop.min.js"];App.loader.libs.cropImage=["#jquery.crop/css/jquery.Jcrop.min.css","#jquery.crop/js/jquery.Jcrop.min.js","#behavior/page/crop-image.min.js"];App.loader.libs.select2=["#jquery.select2/select2.css","#jquery.select2/select2.min.js"];App.loader.libs.select2ex=["#behaviour/page/select2.min.js"];App.loader.libs.selectPage=["#selectpage/selectpage.css","#selectpage/selectpage.min.js"];App.loader.libs.cascadeSelect=["#behaviour/page/cascade-select.min.js"];App.loader.libs.forms=["#behaviour/page/forms.min.js"];App.loader.libs.jqueryui=["#jquery.ui/jquery-ui.custom.min.js","#jquery.ui/jquery-ui.touch-punch.min.js"];App.loader.libs.dropzone=["#jquery.ui/css/dropzone.min.css","#dropzone/dropzone.min.js"];App.loader.libs.loadingOverlay=["#loadingoverlay/loadingoverlay.min.js"];App.loader.libs.dateRangePicker=["#daterangepicker/daterangepicker.min.css","#daterangepicker/moment.min.js","#daterangepicker/jquery.daterangepicker.min.js","#behaviour/page/datetime.min.js"];App.loader.libs.magnificPopup=["#magnific-popup/magnific-popup.min.css","#magnific-popup/jquery.magnific-popup.min.js"];App.loader.libs.inputmask=["#inputmask/inputmask.min.js","#inputmask/jquery.inputmask.min.js"];App.loader.libs.clipboard=["#clipboard/clipboard.min.js","#clipboard/utils.js"];App.editor={browsingFileURL:App.loader.siteURL+(typeof window.IS_BACKEND!=="undefined"&&window.IS_BACKEND?BACKEND_URL:FRONTEND_URL+"/user/file")+"/finder"};App.editor.loadingOverlay=function(e){App.loader.defined(typeof $.fn.LoadingOverlay,"loadingOverlay");return $.LoadingOverlay(e||{})};App.editor.dialog=function(e){App.loader.defined(typeof BootstrapDialog,"dialog");return BootstrapDialog.show(e||{})};App.editor.contypeAttachers={};App.editor.contypeAttachers.markdown=function(e){App.editor.markdownToHTML(e)};App.editor.contypeAttachers.html=function(e){var t=$(e).find("pre[class^=language-]");if(t.length>0)App.editor.codeHighlight(t)};App.editor.attachContype=function(e){var t=e?$(e):$(document);t.find("[data-contype]:not([contype-attached])").each(function(){$(this).attr("contype-attached","1");var e=$(this).data("contype");if(typeof App.editor.contypeAttachers[e]!="undefined"){App.editor.contypeAttachers[e](this)}})};App.editor.markdownReset=function(){var e=ASSETS_URL+"/js/editor/markdown/";editormd.emoji.path=e+"images/emojis/";editormd.katexURL.css=e+"lib/katex/katex.min";editormd.katexURL.js=e+"lib/katex/katex.min"};App.editor.markdownToHTML=function(i,o,e){if(typeof i=="string"){i=document.querySelector(i);if(!i)return}if($(i).data("markdownRendered"))return;$(i).data("markdownRendered",true);var t=function(e,t){var i={markdown:o,htmlDecode:"style,script,iframe|on*",toc:true,tocm:true,emoji:true,taskList:true,tex:true,flowChart:true,sequenceDiagram:true};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){i.theme="dark"}var r=$.extend({},i,e||{});var a=function(){return t(r)};App.loader.defined(typeof marked,"editormdPreview",function(){if(r.flowChart){return App.loader.defined(typeof flowchart,"flowChart",function(){return App.loader.defined(typeof $.fn.flowChart,"flowChartJQuery",function(){if(r.sequenceDiagram)return App.loader.defined(typeof $.fn.sequenceDiagram,"sequenceDiagram",function(){a()});a()})})}if(needSequenceDiagram){return App.loader.defined(typeof $.fn.sequenceDiagram,"sequenceDiagram",function(){a()})}a()},function(){App.editor.markdownReset()});return r};var r="markdown-render-processing-"+App.utils.unixtime();var a='
';if(o==null||typeof o=="boolean"){var n=$(i),d=$(i).hasClass("markdown-code");if(!o&&!d){n=$(i).find(".markdown-code");if(n.length<1)return}if(d){n.prepend(a)}else{n.first().before(a)}t(e,function(t){n.each(function(){if($(this).children("textarea").length>0){t.markdown=$(this).children("textarea").text()}else{t.markdown=$(this).text()}var e=editormd.markdownToHTML(this,t);$(this).data("markdown-viewer",e)});$("#"+r).remove()});return}$(i).before(a);t(e,function(e){var t=editormd.markdownToHTML(i,e);$(i).data("markdown-viewer",t);$("#"+r).remove()})};App.editor.markdowns=function(e,t,i){$(e).each(function(){App.editor.markdown(this,t,i)})};App.editor.markdown=function(e,t,i){var r=false;if(!t)t=$(e).attr("action");App.loader.defined(typeof editormd,"editormd",null,function(){App.editor.markdownReset()});if(t){if(t.substr(0,1)=="!"){t=t.substr(1);r=true}if(t.indexOf("?")>=0){t+="&"}else{t+="?"}if(!r)t+="format=json&";t+="filetype=image&client=markdown"}var a=function(t){App.editor.finderDialog(App.editor.browsingFileURL+"?from=parent&size=12&filetype=image&multiple=0",function(e){if(e.length<=0){return App.message({type:"error",text:App.t("没有选择任何选项!")})}t.dialog.find("[data-url]").val(e[0])},1e5)};var o=$(e).parent(),n=o.attr("id");if(n===undefined){n="webx-md-"+App.utils.unixtime();o.attr("id",n)}var d=ASSETS_URL+"/js/editor/markdown/";var p={width:"100%",height:o.height(),path:d+"lib/",markdown:$(e).val(),placeholder:$(e).attr("placeholder")||"",codeFold:true,saveHTMLToTextarea:true,searchReplace:true,watch:true,htmlDecode:"style,script,iframe|on*",emoji:true,taskList:true,tocm:true,tex:true,flowChart:true,sequenceDiagram:true,imageUpload:true,imageFormats:["jpg","jpeg","gif","png","bmp"],imageUploadURL:t,imageBrowseFn:a,crossDomainUpload:true,uploadCallbackURL:d+"plugins/image-dialog/upload_callback.htm",dialogLockScreen:false,onload:function(){var e=this;editormd.loadPlugin(d+"plugins/drop-or-paste-upload/drop-or-paste-upload.min",function(){e.dropOrPasteUpload()})}};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){p.theme="dark"}var l=$.extend({},p,i||{});if(r){l.toolbarIcons=function(){return["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","browsing-image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"]};l.toolbarIconsClass={"browsing-image":"fa-image"};l.toolbarIconTexts={"browsing-image":App.t("选择图片")};l.toolbarHandlers={"browsing-image":function(n,e,t,i){App.editor.finderDialog(App.editor.browsingFileURL+"?from=parent&size=12&filetype=image&multiple=1",function(e,t){if(e.length<=0){return App.message({type:"error",text:App.t("没有选择任何选项!")})}var i=[];for(var r=0;r0){e=$(this).children("textarea").text()}else{e=$(this).text()}$(this).html(r.render($.trim(e)));$(this).find("pre > code").each(function(){$(this).parent("pre").addClass("prettyprint linenums")});if(typeof prettyPrint!=="undefined")prettyPrint()})};App.editor.markdownItInstance=function(){App.loader.defined(typeof window.markdownit,"markdownit");var e=window.markdownit();if(typeof window.markdownitEmoji!="undefined")e.use(window.markdownitEmoji);return e};App.editor.tinymces=function(e,t,i,r){$(e).each(function(){App.editor.tinymce(this,t,i,r)})};App.editor.finderDialog=function(t,r,i){if(!i)i=2e3;App.loader.defined(typeof BootstrapDialog,"dialog");var e=BootstrapDialog.show({title:App.t("选择文件"),message:function(i){var e="finderDialogCallback"+App.utils.unixtime();window[e]=function(e,t){r(e,t);if(e&&e.length>0)i.close()};return $('')},onshown:function(e){e.$modal.css("zIndex",i);e.$modalBody.css("padding",0)}});return e};App.editor.tinymceOnceFix=false;App.editor.tinymce=function(e,o,t,i){if(!App.editor.tinymceOnceFix){App.editor.tinymceOnceFix=true;$(document).on("focusin",function(e){if($(e.target).closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length){e.stopImmediatePropagation()}})}App.loader.defined(typeof $.fn.tinymce,"tinymce");if(!o)o=$(e).attr("action");var r=App.editor.browsingFileURL;if(o&&o.substr(0,1)=="!"){r=o.substr(1);o=$(e).data("upload-url")}if(o){if(o.indexOf("?")>=0){o+="&"}else{o+="?"}o+="format=json&client=tinymce&filetype="}if(r){r=r.replace(/[\?&]multiple=1/,"");if(r.indexOf("?")>=0){r+="&"}else{r+="?"}r+="from=parent&client=tinymce&filetype="}var a="undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | customDateButton";var n="undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | insertfile image media template link anchor codesample | ltr rtl | customDateButton";var d=function(i,e,t){switch(t.filetype){case"file":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{text:t[0].name})});break;case"image":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{alt:t[0].name})});break;case"media":App.editor.finderDialog(r+t.filetype,function(e,t){if(e&&e.length>0)i(e[0],{})});break;default:alert("Unsupported file type")}};var p=function(e,t,i){var r=new XMLHttpRequest,a=new FormData;r.withCredentials=false;r.open("POST",o);r.onload=function(){if(r.status!=200){i("HTTP Error: "+r.status);return}var e=JSON.parse(r.responseText);if(!e||typeof e.Code=="undefined"){i("Invalid JSON: "+r.responseText);return}if(e.Code!=1){i(e.Info);return}t(e.Data.Url)};a.append("filedata",e.blob(),e.filename());r.send(a)};var l="link table";var s="bold italic | quicklink h2 h3 blockquote quicktable";var c="print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern noneditable charmap quickbars emoticons";if(o){l+=" image imagetools";s+=" quickimage"}var f={height:i?200:500,menubar:true,language:App.langTag("_"),plugins:[c],toolbar:i?a:n,toolbar_sticky:true,autosave_ask_before_unload:false,autosave_interval:"30s",autosave_prefix:"{path}{query}-{id}-",autosave_restore_when_empty:true,autosave_retention:"2m",image_advtab:true,templates:[{title:"New Table",description:"creates a new table",content:'\t\t\t
\t\t\t\t\t\t\t\t\t\t\t\t | \t\t\t\t\t | \t\t\t\t
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t | \t\t\t\t\t | \t\t\t\t
\t\t\t\t\t\t
\t\t\t
'}],image_caption:true,relative_urls:false,image_title:true,quickbars_selection_toolbar:s,noneditable_noneditable_class:"mceNonEditable",toolbar_drawer:"sliding",contextmenu:l,setup:function(r){var t=function(e){return'"};r.ui.registry.addButton("customDateButton",{icon:"insert-time",tooltip:"Insert Current Date",disabled:true,onAction:function(e){r.insertContent(t(new Date))},onSetup:function(t){var i=function(e){t.setDisabled(e.element.nodeName.toLowerCase()==="time")};r.on("NodeChange",i);return function(e){r.off("NodeChange",i)}}})}};if(typeof window.THEME_COLOR=="string"&&window.THEME_COLOR=="dark"){f.skin="oxide-dark";f.content_css="dark"}if(r)f.file_picker_callback=d;if(o)f.images_upload_handler=p;var u=App.utils.elemToId(e).replace(/^#/,"");$(e).tinymce($.extend({},f,t||{}));$(e).data("editor-name","tinymce");var m=tinymce.get(u);$(e).data("editor-object",m)};App.editor.switcher=function(e,r,a){if($(e).length<1)return;var t,i=String($(e).get(0).tagName).toLowerCase();switch(i){case"select":t="change";break;default:t="click"}$(e).on(t,function(){var e=$(this).val();var t=$(r);var i=$(this).data("editor-name")||a;t.data("editor-type",e);return App.editor.switch(i,t)});$(r).data("placeholder",$(r).attr("placeholder"));switch(i){case"input":$(e).filter(":checked").first().trigger(t);break;default:$(e).trigger(t)}};App.editor.switch=function(e,r,t,i){var a=r.attr("action")||r.data("upload-url")||"!"+App.editor.browsingFileURL+"?size=12&multiple=1",o=r.data("editor-type"),n=r.data("editor-name"),d=r.data("editor-object"),p=r.data("current-editor-type");if(p==o)return;var l=r.data("class"),s=r.data("style");if(l===undefined){l=r.attr("class");if(!l)l="";r.data("class",l)}if(s===undefined){s=r.attr("style");if(!s)s="";r.data("style",s)}var c=r.data("content-elem"),f=c;if(c)f=App.loader.parseTmpl(c,{type:o});var u=r.get(0);var m=function(){r.attr("class",l).attr("style",s)};var g=function(){switch(n){case"ueditor":d&&d.destroy();break;case"tinymce":default:d&&typeof d.remove=="function"&&d.remove()}};var h=function(e){var t=r.data(e+"-options")||{};switch(e){case"ueditor":App.editor.ueditor(u,a,t);break;case"tinymce":default:App.editor.tinymce(u,a,t);var i=window.setInterval(function(){if(r.next(".tox-tinymce").length>0){r.next(".tox-tinymce").show();window.clearInterval(i)}},100);break}};var w=function(){var e=r.data("markdown-options")||{};App.editor.markdown(u,a,e)};var y=function(){if(f&&$(f).length>0){var e=App.loader.parseTmpl(c,{type:p});if(e&&$(e).length>0){$(e).text(r.val());var t=$('textarea[name="'+r.parent().attr("id")+'-html-code"]');if(t.length>0&&t.val()!=""){$(f).text(t.val());$(f).val(t.val())}}r.val($(f).val());r.text($(f).val())}r.parent().removeAttr("class").css("height","auto");r.siblings().remove();m()};switch(o){case"markdown":if(i){var v=App.loader.parseTmpl(c,{type:p});if(v&&$(v).length>0){if(r.val()!=$(v).val()&&!confirm("确定要切换吗?切换编辑器将会丢失您当前所做的修改。")){if(t!=null)t();return false}}}if(f&&$(f).length>0){r.text($(f).val());r.val($(f).val())}g();w();r.data("current-editor-type",o);break;case"text":g();y();r.show().focus();r.data("current-editor-type",o);break;default:y();h(e);r.data("current-editor-type","html")}return true};if(typeof App.utils=="undefined")App.utils={};App.utils.elemToId=function(e){if(typeof e!="object"){if(String(e).substring(0,1)!="#"){e="#"+e}return e}var t=$(e).attr("id");if(t)return"#"+t;t="generated-id-"+App.utils.unixtime();$(e).attr("id",t);return"#"+t};App.utils.unixtime=function(){return(new Date).getTime()};App.editor.selectPages=function(){App.loader.defined(typeof $.fn.selectPage,"selectPage");for(var e=0;e=0){t+="&"}else{t+="?"}t+="from=parent&client=fileInput&filetype=image";var o=this;App.editor.finderDialog(t,function(e){var t=e[0];var i=$(o).data("input");if(!i){i=$(o).parent(".input-group-btn").siblings("input")[0]}if(i)$(i).val(t);var r=$(o).data("preview-btn");if(!r){r=$(o).parent(".input-group-btn").siblings(".preview-btn")[0]}if(r){if(!$(r).data("attached-float")){App.float(App.utils.elemToId(r)+" a img");$(r).data("attached-float",true)}$(r).removeClass("hidden").children("a").attr("href",t).children("img").attr("src",t)}var a=$(o).data("preview-img");if(a){$(a).attr("src",t)}if(n)n(t)})})});$(e+'input[data-toggle="uploadPreviewer"]').each(function(){$(this).css("width","70px");var e=$(this).data("preview-container");var t=$(this).data("upload-url");var i=$(this).data("preview-btn");var r=$(this).uploadPreviewer($.extend({buttonText:' '+App.t("上传"),previewTableContainer:e,url:t,previewTableShow:false},a||{}));$(this).data("uploadPreviewer",r);if(i&&!$(i).data("attached-float")){App.float(App.utils.elemToId(i)+" a img");$(i).data("attached-float",true)}$(this).on("file-preview:changed",function(o){$(o.target).data("uploadPreviewer").submit(function(e){if(e.Code!=1){if(d)d(e);return App.message({text:e.Info,type:"error"})}var t=e.Data.files[0];var i=$(o.target).data("input");if(!i){i=$(o.target).parents(".input-group-btn").prev("input")[0]}$(i).val(t);var r=$(o.target).data("preview-btn");if(!r){r=$(o.target).parents(".input-group-btn").siblings(".preview-btn")[0]}if(r){if(!$(r).data("attached-float")){App.float(App.utils.elemToId(r)+" a img");$(r).data("attached-float",true)}$(r).removeClass("hidden").children("a").attr("href",t).children("img").attr("src",t)}var a=$(o.target).data("preview-img");if(a){$(a).attr("src",t)}if(n)n(t);App.message({text:App.t("上传成功"),type:"success"})},function(){if(d)d()})})})};App.editor.codemirror=function(l,s,c){if($(l).length<1)return null;var e=function(){if($(l).data("codemirror"))return;var e={lineNumbers:true,lineWrapping:true,lineWrapping:true,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],autoCloseTags:true,autoCloseBrackets:true,showTrailingSpace:true,indentWithTabs:true,matchBrackets:true,styleActiveLine:true,styleSelectedText:true,highlightSelectionMatches:true,smartIndent:true,mode:"text/x-csrc",width:null,height:null,hintOptions:{completeSingle:false}};var t=$.extend(e,s||{});var i=$(l)[0].tagName.toUpperCase()=="TEXTAREA"?CodeMirror.fromTextArea($(l)[0],t):CodeMirror($(l)[0],t);var r=t.mode,a={"text/x-csrc":"clike","text/css":"css","text/x-mysql":"sql","text/x-mssql":"sql","text/x-markdown":"markdown","text/x-yaml":"yaml","text/x-toml":"toml","text/javascript":"javascript","application/javascript":"javascript","text/json":"javascript","text/html":"html","message/http":"http",null:"null"};if(c&&typeof c=="object"){a=$.extend(a,c);c=null}if(!c){if(t.mode in a){c=a[t.mode]}else{if(typeof CodeMirror.modeInfo!=="undefined"){for(var o=0;o=0?"&":"?";e.url+=p+"client=dropzone"}var l=$(r).dropzone($.extend({paramName:"file",maxFilesize:.5,acceptedFiles:"image/*",dictDefaultMessage:'\t\t \t\t'+App.t("点击此处或拖动文件到这里开始上传")+'
\t\t\t\t
',dictResponseError:App.t("上传文件出错!"),dictCancelUpload:App.t("取消"),dictRemoveFile:App.t("删除")},e||{}));var s=l[0].dropzone;s.on("success",function(e,t,i){if(t.error){if(typeof t.error.message!="undefined")t.error=t.error.message;if(o)o.call(this,e,t.error);return App.message({text:t.error,type:"error"})}if(a)a.apply(this,arguments);else $(r).trigger("dropzone.success",arguments)}).on("removedfile",function(e){if(t)t.apply(this,arguments);else $(r).trigger("dropzone.removedfile",arguments)}).on("error",function(e,t,i){if(o)o.apply(this,arguments);else $(r).trigger("dropzone.error",arguments)});if(i){s.on("processing",function(e){s.options.url=e.uploadURL})}$(r).data("dropzone",s);return s};App.editor.dateRangePicker=function(e,t){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.daterangepicker(e,t)};App.editor.dateRangePickerx=function(e,t,i,r){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.daterangepickerx(e,t,i,r)};App.editor.datePicker=function(e,t){App.loader.defined(typeof App.daterangepicker,"dateRangePicker");return App.datepicker(e,t)};App.editor.popup=function(e,t){if(e==null)e=".image-zoom";var i={type:"image",mainClass:"mfp-with-zoom",zoom:{enabled:true,duration:300,easing:"ease-in-out",opener:function(e){var t=$(e);return t}}};App.loader.defined(typeof $.fn.magnificPopup,"magnificPopup",function(){$(e).magnificPopup($.extend(i,t||{}))})};App.editor.inputmask=function(e,t){App.loader.defined(typeof $.fn.inputmask,"inputmask",function(){$(e).inputmask(t)})};App.editor.clipboard=function(e,t){App.loader.defined(typeof ClipboardJS,"clipboard",function(){attachCopy(e,t)})};
\ No newline at end of file
diff --git a/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.js b/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.js
index b0bf4f811..85b52fa3d 100644
--- a/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.js
+++ b/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.js
@@ -1,3 +1,131 @@
+/*
+ * HTMLParser - This implementation of parser assumes we are parsing HTML in browser
+ * and user DOM methods available in browser for parsing HTML.
+ *
+ * @author Himanshu Gilani
+ *
+ */
+
+/*
+ Universal JavaScript Module, supports AMD (RequireJS), Node.js, and the browser.
+ https://gist.github.com/kirel/1268753
+*/
+(function (name, definition) {
+ if (typeof define === 'function') { // AMD
+ define(definition);
+ } else if (typeof module !== 'undefined' && module.exports) { // Node.js
+ module.exports = definition();
+ } else { // Browser
+ var theModule = definition(), global = this, old = global[name];
+ theModule.noConflict = function () {
+ global[name] = old;
+ return theModule;
+ };
+ global[name] = theModule;
+ }
+ })('markdownDOMParser', function() {
+
+ var HTMLParser = function (html, handler, opts) {
+ opts = opts || {};
+
+ var e = document.createElement('div');
+ e.innerHTML = html;
+ var node = e;
+ var nodesToIgnore = opts['nodesToIgnore'] || [];
+ var parseHiddenNodes = opts['parseHiddenNodes'] || 'false';
+
+ var c = node.childNodes;
+ for (var i = 0; i < c.length; i++) {
+ try {
+ var ignore = false;
+ for (var k=0; k< nodesToIgnore.length; k++) {
+ if (c[i].nodeName.toLowerCase() == nodesToIgnore[k]) {
+ ignore= true;
+ break;
+ }
+ }
+
+ //NOTE hidden node testing is expensive in FF.
+ if (ignore || (!parseHiddenNodes && isHiddenNode(c[i])) ){
+ continue;
+ }
+
+ if (c[i].nodeName.toLowerCase() != "#text" && c[i].nodeName.toLowerCase() != "#comment") {
+ var attrs = [];
+
+ if (c[i].hasAttributes()) {
+ var attributes = c[i].attributes;
+ for ( var a = 0; a < attributes.length; a++) {
+ var attribute = attributes.item(a);
+
+ attrs.push({
+ name : attribute.nodeName,
+ value : attribute.nodeValue,
+ });
+ }
+ }
+
+ if (handler.start) {
+ if (c[i].hasChildNodes()) {
+ handler.start(c[i].nodeName, attrs, false);
+
+ //if (c[i].nodeName.toLowerCase() == "pre" || c[i].nodeName.toLowerCase() == "code") {
+ // handler.chars(c[i].innerHTML);
+ //} else
+ if (c[i].nodeName.toLowerCase() == "iframe" || c[i].nodeName.toLowerCase() == "frame") {
+ if (c[i].contentDocument && c[i].contentDocument.documentElement) {
+ return HTMLParser(c[i].contentDocument.documentElement, handler, opts);
+ }
+ } else {
+ HTMLParser(c[i].innerHTML, handler, opts);
+ }
+
+ if (handler.end) {
+ handler.end(c[i].nodeName);
+ }
+ } else {
+ handler.start(c[i].nodeName, attrs, true);
+ }
+ }
+ } else if (c[i].nodeName.toLowerCase() == "#text") {
+ if (handler.chars) {
+ handler.chars(c[i].nodeValue);
+ }
+ } else if (c[i].nodeName.toLowerCase() == "#comment") {
+ if (handler.comment) {
+ handler.comment(c[i].nodeValue);
+ }
+ }
+
+ } catch (e) {
+ //properly log error
+ console.error(e);
+ console.log("error while parsing node: " + c[i].nodeName.toLowerCase());
+ }
+ }
+ };
+
+ function isHiddenNode(node) {
+ if (node.nodeName.toLowerCase() == "title"){
+ return false;
+ }
+
+ if (window.getComputedStyle) {
+ try {
+ var style = window.getComputedStyle(node, null);
+ if (style.getPropertyValue && style.getPropertyValue('display') == 'none') {
+ return true;
+ }
+ } catch (e) {
+ // consume and ignore. node styles are not accessible
+ }
+ return false;
+ }
+ }
+
+ return HTMLParser;
+ });
+
/*!
* editormd附件拖拽和图片粘贴上传插件
*
@@ -16,9 +144,531 @@
(function () {
+ function trim(value) {
+ if(value===undefined||value==null) return '';
+ return value.replace(/^\s+|\s+$/g,"");
+ }
+
+ function endsWith(value, suffix) {
+ return value.match(suffix+"$") == suffix;
+ }
+
+ function startsWith(value, str) {
+ return value.indexOf(str) == 0;
+ }
+
+ function html2markdown(html, opts) {
+ opts = opts || {};
+
+ var nodeList = [];
+ var listTagStack = [];
+ var linkAttrStack = [];
+ var blockquoteStack = [];
+ var preStack = [];
+ var codeStack = [];
+ var links = [];
+ var inlineStyle = opts['inlineStyle'] || false;
+ var parser = opts['parser'];
+ var markdownTags = {
+ "hr": "- - -\n\n",
+ "br": " \n",
+ "title": "# ",
+ "h1": "# ",
+ "h2": "## ",
+ "h3": "### ",
+ "h4": "#### ",
+ "h5": "##### ",
+ "h6": "###### ",
+ "b": "**",
+ "strong": "**",
+ "i": "_",
+ "em": "_",
+ "dfn": "_",
+ "var": "_",
+ "cite": "_",
+ "span": " ",
+ "ul": "* ",
+ "ol": "1. ",
+ "dl": "- ",
+ "blockquote": "> "
+ };
+
+ if (!parser && typeof markdownDOMParser !== 'undefined') {
+ parser = markdownDOMParser;
+ }
+
+ function getListMarkdownTag() {
+ var listItem = "";
+ if (listTagStack) {
+ for (var i = 0; i < listTagStack.length - 1; i++) {
+ listItem += " ";
+ }
+ }
+ listItem += peek(listTagStack);
+ return listItem;
+ }
+
+ function convertAttrs(attrs) {
+ var attributes = {};
+ for (var k in attrs) {
+ var attr = attrs[k];
+ attributes[attr.name] = attr;
+ }
+ return attributes;
+ }
+
+ function peek(list) {
+ if (list && list.length > 0) {
+ return list.slice(-1)[0];
+ }
+ return "";
+ }
+
+ function peekTillNotEmpty(list) {
+ if (!list) {
+ return "";
+ }
+
+ for (var i = list.length - 1; i >= 0; i--){
+ if (list[i] != "") {
+ return list[i];
+ }
+ }
+ return "";
+ }
+
+ function removeIfEmptyTag(start) {
+ var cleaned = false;
+ if (start == peekTillNotEmpty(nodeList)) {
+ while (peek(nodeList) != start) {
+ nodeList.pop();
+ }
+ nodeList.pop();
+ cleaned = true;
+ }
+ return cleaned;
+ }
+
+ function sliceText(start) {
+ var text = [];
+ while (nodeList.length > 0 && peek(nodeList) != start) {
+ var t = nodeList.pop();
+ text.unshift(t);
+ }
+ return text.join("");
+ }
+
+ function block(isEndBlock) {
+ var lastItem = nodeList.pop();
+ if (!lastItem) {
+ return;
+ }
+
+ if (!isEndBlock) {
+ var block;
+ if (/\s*\n\n\s*$/.test(lastItem)) {
+ lastItem = lastItem.replace(/\s*\n\n\s*$/, "\n\n");
+ block = "";
+ } else if (/\s*\n\s*$/.test(lastItem)) {
+ lastItem = lastItem.replace(/\s*\n\s*$/, "\n");
+ block = "\n";
+ } else if (/\s+$/.test(lastItem)) {
+ block = "\n\n";
+ } else {
+ block = "\n\n";
+ }
+
+ nodeList.push(lastItem);
+ nodeList.push(block);
+ } else {
+ nodeList.push(lastItem);
+ if (!endsWith(lastItem, "\n")) {
+ nodeList.push("\n\n");
+ }
+ }
+ }
+
+ function listBlock() {
+ if (nodeList.length > 0) {
+ var li = peek(nodeList);
+
+ if (!endsWith(li, "\n")) {
+ nodeList.push("\n");
+ }
+ } else {
+ nodeList.push("\n");
+ }
+ }
+
+ parser(html, {
+ start: function(tag, attrs, unary) {
+ tag = tag.toLowerCase();
+
+ if (unary && (tag != "br" && tag != "hr" && tag != "img")) {
+ return;
+ }
+
+ switch (tag) {
+ case "br":
+ nodeList.push(markdownTags[tag]);
+ break;
+ case "hr":
+ block();
+ nodeList.push(markdownTags[tag]);
+ break;
+ case "title":
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ block();
+ nodeList.push(markdownTags[tag]);
+ break;
+ case "b":
+ case "strong":
+ case "i":
+ case "em":
+ case "dfn":
+ case "var":
+ case "cite":
+ nodeList.push(markdownTags[tag]);
+ break;
+ case "code":
+ case "span":
+ if (preStack.length > 0) {
+ break;
+ } else if (!/\s+$/.test(peek(nodeList))) {
+ nodeList.push(markdownTags[tag]);
+ }
+ break;
+ case "p":
+ case "div":
+ case "table":
+ case "tbody":
+ case "tr":
+ case "td":
+ block();
+ break;
+ case "ul":
+ case "ol":
+ case "dl":
+ listTagStack.push(markdownTags[tag]);
+ // lists are block elements
+ if (listTagStack.length > 1) {
+ listBlock();
+ } else {
+ block();
+ }
+ break;
+ case "li":
+ case "dt":
+ var li = getListMarkdownTag();
+ nodeList.push(li);
+ break;
+ case "a":
+ var attribs = convertAttrs(attrs);
+ linkAttrStack.push(attribs);
+ nodeList.push("[");
+ break;
+ case "img":
+ var attribs = convertAttrs(attrs);
+ var alt, title, url;
+
+ attribs["src"] ? url = attribs["src"].value : url = "";
+ if (!url) {
+ break;
+ }
+
+ attribs['alt'] ? alt = trim(attribs['alt'].value) : alt = "";
+ attribs['title'] ? title = trim(attribs['title'].value) : title = "";
+
+ // if parent of image tag is nested in anchor tag use inline style
+ if (!inlineStyle && !startsWith(peekTillNotEmpty(nodeList), "[")) {
+ var l = links.indexOf(url);
+ if (l == -1) {
+ links.push(url);
+ l=links.length-1;
+ }
+
+ block();
+ nodeList.push("![");
+ if (alt!= "") {
+ nodeList.push(alt);
+ } else if (title != null) {
+ nodeList.push(title);
+ }
+
+ nodeList.push("][" + l + "]");
+ block();
+ } else {
+ //if image is not a link image then treat images as block elements
+ if (!startsWith(peekTillNotEmpty(nodeList), "[")) {
+ block();
+ }
+
+ nodeList.push("![" + alt + "](" + url + (title ? " \"" + title + "\"" : "") + ")");
+
+ if (!startsWith(peekTillNotEmpty(nodeList), "[")) {
+ block(true);
+ }
+ }
+ break;
+ case "blockquote":
+ //listBlock();
+ block();
+ blockquoteStack.push(markdownTags[tag]);
+ break;
+ case "pre":
+ block();
+ preStack.push(true);
+ nodeList.push(" ");
+ break;
+ case "table":
+ nodeList.push("");
+ break;
+ case "thead":
+ nodeList.push("");
+ break;
+ case "tbody":
+ nodeList.push("");
+ break;
+ case "tr":
+ nodeList.push("");
+ break;
+ case "td":
+ nodeList.push("");
+ break;
+ }
+ },
+ chars: function(text) {
+ if (preStack.length > 0) {
+ text = text.replace(/\n/g,"\n ");
+ } else if (trim(text) != "") {
+ text = text.replace(/\s+/g, " ");
+
+ var prevText = peekTillNotEmpty(nodeList);
+ if (/\s+$/.test(prevText)) {
+ text = text.replace(/^\s+/g, "");
+ }
+ } else {
+ nodeList.push("");
+ return;
+ }
+
+ //if(blockquoteStack.length > 0 && peekTillNotEmpty(nodeList).endsWith("\n")) {
+ if (blockquoteStack.length > 0) {
+ nodeList.push(blockquoteStack.join(""));
+ }
+
+ nodeList.push(text);
+ },
+ end: function(tag) {
+ tag = tag.toLowerCase();
+
+ switch (tag) {
+ case "title":
+ case "h1":
+ case "h2":
+ case "h3":
+ case "h4":
+ case "h5":
+ case "h6":
+ if(!removeIfEmptyTag(markdownTags[tag])) {
+ block(true);
+ }
+ break;
+ case "p":
+ case "div":
+ case "table":
+ case "tbody":
+ case "tr":
+ case "td":
+ while(nodeList.length > 0 && trim(peek(nodeList)) == "") {
+ nodeList.pop();
+ }
+ block(true);
+ break;
+ case "b":
+ case "strong":
+ case "i":
+ case "em":
+ case "dfn":
+ case "var":
+ case "cite":
+ if (!removeIfEmptyTag(markdownTags[tag])) {
+ nodeList.push(trim(sliceText(markdownTags[tag])));
+ nodeList.push(markdownTags[tag]);
+ }
+ break;
+ case "a":
+ var text = sliceText("[");
+ text = text.replace(/\s+/g, " ");
+ text = trim(text);
+
+ if (text == "") {
+ nodeList.pop();
+ break;
+ }
+
+ var attrs = linkAttrStack.pop();
+ var url;
+ attrs["href"] && attrs["href"].value != "" ? url = attrs["href"].value : url = "";
+
+ if (url == "") {
+ nodeList.pop();
+ nodeList.push(text);
+ break;
+ }
+
+ nodeList.push(text);
+
+ if (!inlineStyle && !startsWith(peek(nodeList), "!")){
+ var l = links.indexOf(url);
+ if (l == -1) {
+ links.push(url);
+ l=links.length-1;
+ }
+ nodeList.push("][" + l + "]");
+ } else {
+ if(startsWith(peek(nodeList), "!")){
+ var text = nodeList.pop();
+ text = nodeList.pop() + text;
+ block();
+ nodeList.push(text);
+ }
+
+ var title = attrs["title"];
+ nodeList.push("](" + url + (title ? " \"" + trim(title.value).replace(/\s+/g, " ") + "\"" : "") + ")");
+
+ if(startsWith(peek(nodeList), "!")){
+ block(true);
+ }
+ }
+ break;
+ case "ul":
+ case "ol":
+ case "dl":
+ listBlock();
+ listTagStack.pop();
+ break;
+ case "li":
+ case "dt":
+ var li = getListMarkdownTag();
+ if (!removeIfEmptyTag(li)) {
+ var text = trim(sliceText(li));
+
+ if (startsWith(text, "[![")) {
+ nodeList.pop();
+ block();
+ nodeList.push(text);
+ block(true);
+ } else {
+ nodeList.push(text);
+ listBlock();
+ }
+ }
+ break;
+ case "blockquote":
+ blockquoteStack.pop();
+ break;
+ case "pre":
+ //uncomment following experimental code to discard line numbers when syntax highlighters are used
+ //notes this code thorough testing before production user
+ /*
+ var p=[];
+ var flag = true;
+ var count = 0, whiteSpace = 0, line = 0;
+ console.log(">> " + peek(nodeList));
+ while(peek(nodeList).startsWith(" ") || flag == true)
+ {
+ //console.log('inside');
+ var text = nodeList.pop();
+ p.push(text);
+
+ if(flag == true && !text.startsWith(" ")) {
+ continue;
+ } else {
+ flag = false;
+ }
+
+ //var result = parseInt(text.trim());
+ if(!isNaN(text.trim())) {
+ count++;
+ } else if(text.trim() == ""){
+ whiteSpace++;
+ } else {
+ line++;
+ }
+ flag = false;
+ }
+
+ console.log(line);
+ if(line != 0)
+ {
+ while(p.length != 0) {
+ nodeList.push(p.pop());
+ }
+ }
+ */
+ block(true);
+ preStack.pop();
+ break;
+ case "code":
+ case "span":
+ if (preStack.length > 0) {
+ break;
+ } else if (trim(peek(nodeList)) == "") {
+ nodeList.pop();
+ nodeList.push(markdownTags[tag]);
+ } else {
+ var text = nodeList.pop();
+ nodeList.push(trim(text));
+ nodeList.push(markdownTags[tag]);
+ }
+ break;
+ case "table":
+ nodeList.push(" |
");
+ break;
+ case "thead":
+ nodeList.push("");
+ break;
+ case "tbody":
+ nodeList.push("");
+ break;
+ case "tr":
+ nodeList.push("");
+ break;
+ case "td":
+ nodeList.push("");
+ break;
+ case "br":
+ case "hr":
+ case "img":
+ break;
+ }
+
+ }
+ }, {"nodesToIgnore": ["script", "noscript", "object", "iframe", "frame", "head", "style", "label"]});
+
+ if (!inlineStyle) {
+ for (var i = 0; i < links.length; i++) {
+ if (i == 0) {
+ var lastItem = nodeList.pop();
+ nodeList.push(lastItem.replace(/\s+$/g, ""));
+ nodeList.push("\n\n[" + i + "]: " + links[i]);
+ } else {
+ nodeList.push("\n[" + i + "]: " + links[i]);
+ }
+ }
+ }
+
+ return nodeList.join("");
+
+ }
var factory = function (exports) {
var $ = jQuery; // if using module loader(Require.js/Sea.js).
- var pluginName = "drop-or-paste-upload"; // 定义插件名称
// ajax上传图片 可自行处理
function _ajax(url, data, callback) {
$.ajax({
@@ -39,18 +689,23 @@
function _isImage(file) {
return file.type.indexOf('image/') === 0;
}
- function upload(file) {
+ function upload(file, callback) {
// File { name: "mrvx5eugoqb.jpg", lastModified: 1533178146229, webkitRelativePath: "", size: 261784, type: "image/jpeg" }
var _this = this, isImage = _isImage(file),
forms = new FormData(), fileName = new Date().getTime() + "." + file.name.split(".").pop();
forms.append(_this.classPrefix + "image-file", file, fileName);
_ajax(_this.settings.imageUploadURL, forms, function (ret) {
if (ret.success == 1) {
- var url = ret.url;
+ var url = ret.url, content = '';
if (isImage) {
- _this.cm.replaceSelection("![](" + url + ")");
+ content = "![](" + url + ")";
} else {
- _this.cm.replaceSelection("[下载附件](" + url + ")");
+ content = "[下载附件](" + url + ")";
+ }
+ if(callback){
+ callback(content)
+ }else{
+ _this.cm.replaceSelection(content);
}
} else {
alert(ret.message);
@@ -66,29 +721,49 @@
var _this = this;
var settings = _this.settings;
var id = _this.id;
+ var makeHTMLCallback = function(content){
+ content = html2markdown(content);
+ _this.cm.replaceSelection(content);
+ };
if (!settings.imageUpload || !settings.imageUploadURL) {
console.log('你还未开启图片上传或者没有配置上传地址');
return false;
}
-
+ if(typeof(settings.parsePastedHTML)=='undefined'){
+ settings.parsePasteHTML = _this.markdownTextarea.data('parse-pasted-html');
+ if(settings.parsePasteHTML==undefined) settings.parsePasteHTML = true;
+ }
+ var parseHTML=settings.parsePasteHTML?true:false;
//监听粘贴板事件
- var $textarea = $('#' + id);
+ var $textarea = $('#' + id);//
$textarea.off('paste').on('paste', function (e) {
- var items = (e.clipboardData || e.originalEvent.clipboardData || window.clipboardData).items;
+ var clipboardData = (e.clipboardData || e.originalEvent.clipboardData || window.clipboardData);
+ var items = clipboardData.items;
if (items && items.length) {
- var file = null;
+ var did = false, stopEvent = function(){
+ if (did) return;
+ did = true
+ e.preventDefault()
+ e.stopPropagation()
+ };
for (var i = 0; i < items.length; i++) {
- if (_isImage(items[i])) {
- file = items[i].getAsFile();
- break;
+ switch(items[i].kind){
+ case 'file':
+ if (_isImage(items[i])) {
+ stopEvent()
+ upload.call(_this, items[i].getAsFile());
+ }
+ break;
+ case 'string':
+ if(parseHTML && items[i].type=='text/html'){
+ stopEvent()
+ items[i].getAsString(makeHTMLCallback);
+ }
+ break;
}
}
- if (!file) return;
- e.preventDefault()
- e.stopPropagation()
- upload.call(_this, file);
}
});
$textarea.off("dragover").off("dragenter").on("dragover dragenter", function (e) {
@@ -99,7 +774,13 @@
e.preventDefault()
e.stopPropagation()
var files = this.files || e.originalEvent.dataTransfer.files;
- upload.call(_this, files[0]);
+ if(files && files.length){
+ for (var i = 0; i < files.length; i++) {
+ if (_isImage(files[i])) {
+ upload.call(_this, files[i]);
+ }
+ }
+ }
});
};
};
diff --git a/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.min.js b/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.min.js
new file mode 100644
index 000000000..13aa6496c
--- /dev/null
+++ b/public/assets/backend/js/editor/markdown/plugins/drop-or-paste-upload/drop-or-paste-upload.min.js
@@ -0,0 +1 @@
+(function(e,a){if(typeof define==="function"){define(a)}else if(typeof module!=="undefined"&&module.exports){module.exports=a()}else{var r=a(),t=this,s=t[e];r.noConflict=function(){t[e]=s;return r};t[e]=r}})("markdownDOMParser",function(){var v=function(e,a,r){r=r||{};var t=document.createElement("div");t.innerHTML=e;var s=t;var n=r["nodesToIgnore"]||[];var o=r["parseHiddenNodes"]||"false";var i=s.childNodes;for(var f=0;f
"};if(!t&&typeof markdownDOMParser!=="undefined"){t=markdownDOMParser}function b(){var e="";if(u){for(var a=0;a0){return e.slice(-1)[0]}return""}function w(e){if(!e){return""}for(var a=e.length-1;a>=0;a--){if(e[a]!=""){return e[a]}}return""}function i(e){var a=false;if(e==w(c)){while(k(c)!=e){c.pop()}c.pop();a=true}return a}function f(e){var a=[];while(c.length>0&&k(c)!=e){var r=c.pop();a.unshift(r)}return a.join("")}function y(e){var a=c.pop();if(!a){return}if(!e){var r;if(/\s*\n\n\s*$/.test(a)){a=a.replace(/\s*\n\n\s*$/,"\n\n");r=""}else if(/\s*\n\s*$/.test(a)){a=a.replace(/\s*\n\s*$/,"\n");r="\n"}else if(/\s+$/.test(a)){r="\n\n"}else{r="\n\n"}c.push(a);c.push(r)}else{c.push(a);if(!o(a,"\n")){c.push("\n\n")}}}function L(){if(c.length>0){var e=k(c);if(!o(e,"\n")){c.push("\n")}}else{c.push("\n")}}t(e,{start:function(e,a,r){e=e.toLowerCase();if(r&&(e!="br"&&e!="hr"&&e!="img")){return}switch(e){case"br":c.push(m[e]);break;case"hr":y();c.push(m[e]);break;case"title":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":y();c.push(m[e]);break;case"b":case"strong":case"i":case"em":case"dfn":case"var":case"cite":c.push(m[e]);break;case"code":case"span":if(d.length>0){break}else if(!/\s+$/.test(k(c))){c.push(m[e])}break;case"p":case"div":case"table":case"tbody":case"tr":case"td":y();break;case"ul":case"ol":case"dl":u.push(m[e]);if(u.length>1){L()}else{y()}break;case"li":case"dt":var t=b();c.push(t);break;case"a":var s=g(a);l.push(s);c.push("[");break;case"img":var s=g(a);var n,o,i;s["src"]?i=s["src"].value:i="";if(!i){break}s["alt"]?n=D(s["alt"].value):n="";s["title"]?o=D(s["title"].value):o="";if(!v&&!N(w(c),"[")){var f=h.indexOf(i);if(f==-1){h.push(i);f=h.length-1}y();c.push("![");if(n!=""){c.push(n)}else if(o!=null){c.push(o)}c.push("]["+f+"]");y()}else{if(!N(w(c),"[")){y()}c.push("!["+n+"]("+i+(o?' "'+o+'"':"")+")");if(!N(w(c),"[")){y(true)}}break;case"blockquote":y();p.push(m[e]);break;case"pre":y();d.push(true);c.push(" ");break;case"table":c.push("");break;case"thead":c.push("");break;case"tbody":c.push("");break;case"tr":c.push("");break;case"td":c.push("");break}},chars:function(e){if(d.length>0){e=e.replace(/\n/g,"\n ")}else if(D(e)!=""){e=e.replace(/\s+/g," ");var a=w(c);if(/\s+$/.test(a)){e=e.replace(/^\s+/g,"")}}else{c.push("");return}if(p.length>0){c.push(p.join(""))}c.push(e)},end:function(e){e=e.toLowerCase();switch(e){case"title":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":if(!i(m[e])){y(true)}break;case"p":case"div":case"table":case"tbody":case"tr":case"td":while(c.length>0&&D(k(c))==""){c.pop()}y(true);break;case"b":case"strong":case"i":case"em":case"dfn":case"var":case"cite":if(!i(m[e])){c.push(D(f(m[e])));c.push(m[e])}break;case"a":var a=f("[");a=a.replace(/\s+/g," ");a=D(a);if(a==""){c.pop();break}var r=l.pop();var t;r["href"]&&r["href"].value!=""?t=r["href"].value:t="";if(t==""){c.pop();c.push(a);break}c.push(a);if(!v&&!N(k(c),"!")){var s=h.indexOf(t);if(s==-1){h.push(t);s=h.length-1}c.push("]["+s+"]")}else{if(N(k(c),"!")){var a=c.pop();a=c.pop()+a;y();c.push(a)}var n=r["title"];c.push("]("+t+(n?' "'+D(n.value).replace(/\s+/g," ")+'"':"")+")");if(N(k(c),"!")){y(true)}}break;case"ul":case"ol":case"dl":L();u.pop();break;case"li":case"dt":var o=b();if(!i(o)){var a=D(f(o));if(N(a,"[![")){c.pop();y();c.push(a);y(true)}else{c.push(a);L()}}break;case"blockquote":p.pop();break;case"pre":y(true);d.pop();break;case"code":case"span":if(d.length>0){break}else if(D(k(c))==""){c.pop();c.push(m[e])}else{var a=c.pop();c.push(D(a));c.push(m[e])}break;case"table":c.push(" |
");break;case"thead":c.push("");break;case"tbody":c.push("");break;case"tr":c.push("");break;case"td":c.push("");break;case"br":case"hr":case"img":break}}},{nodesToIgnore:["script","noscript","object","iframe","frame","head","style","label"]});if(!v){for(var s=0;s
-
-->
\ No newline at end of file