Files
mindoc/static/editor.md/lib/codemirror/addons.min.js

2 lines
46 KiB
Go
Raw Normal View History

2024-03-27 16:26:01 +08:00
/*! Editor.md v1.7.17 | addons.min.js | Open source online markdown editor. | MIT License | By: IBM Skills Network | https://github.com/ibm-skills-network/editor.md | 2024-03-27 */
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){o.defineOption("showTrailingSpace",!1,function(e,t,n){(n=n==o.Init?!1:n)&&!t?e.removeOverlay("trailingspace"):!n&&t&&e.addOverlay({token:function(e){for(var t=e.string.length,n=t;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(u){function d(e,t,n){var e=e.getWrapperElement(),o=e.appendChild(document.createElement("div"));return o.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?o.innerHTML=t:o.appendChild(t),u.addClass(e,"dialog-opened"),o}function h(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}u.defineExtension("openDialog",function(e,t,n){n=n||{},h(this,null);var o=d(this,e,n.bottom),r=!1,i=this;function a(e){"string"==typeof e?l.value=e:r||(r=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),i.focus(),n.onClose&&n.onClose(o))}var l=o.getElementsByTagName("input")[0];return l?(l.focus(),n.value&&(l.value=n.value,!1!==n.selectValueOnOpen)&&l.select(),n.onInput&&u.on(l,"input",function(e){n.onInput(e,l.value,a)}),n.onKeyUp&&u.on(l,"keyup",function(e){n.onKeyUp(e,l.value,a)}),u.on(l,"keydown",function(e){n&&n.onKeyDown&&n.onKeyDown(e,l.value,a)||((27==e.keyCode||!1!==n.closeOnEnter&&13==e.keyCode)&&(l.blur(),u.e_stop(e),a()),13==e.keyCode&&t(l.value,e))}),!1!==n.closeOnBlur&&u.on(o,"focusout",function(e){null!==e.relatedTarget&&a()})):(e=o.getElementsByTagName("button")[0])&&(u.on(e,"click",function(){a(),i.focus()}),!1!==n.closeOnBlur&&u.on(e,"blur",a),e.focus()),a}),u.defineExtension("openConfirm",function(e,t,n){h(this,null);var o=d(this,e,n&&n.bottom),r=o.getElementsByTagName("button"),i=!1,a=this,l=1;function s(){i||(i=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),a.focus())}r[0].focus();for(var c=0;c<r.length;++c){var f=r[c];!function(t){u.on(f,"click",function(e){u.e_preventDefault(e),s(),t&&t(a)})}(t[c]),u.on(f,"blur",function(){--l,setTimeout(function(){l<=0&&s()},200)}),u.on(f,"focus",function(){++l})}}),u.defineExtension("openNotification",function(e,t){h(this,i);var n,o=d(this,e,t&&t.bottom),r=!1,e=t&&void 0!==t.duration?t.duration:5e3;function i(){r||(r=!0,clearTimeout(n),u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o))}return u.on(o,"click",function(e){u.e_preventDefault(e),i()}),e&&(n=setTimeout(i,e)),i})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(r){"use strict";var m,v,y=r.Pos;function p(e,t){for(var n,o=null!=(o=(n=e).flags)?o:(n.ignoreCase?"i":"")+(n.global?"g":"")+(n.multiline?"m":""),r=o,i=0;i<t.length;i++)-1==r.indexOf(t.charAt(i))&&(r+=t.charAt(i));return o==r?e:new RegExp(e.source,r)}function g(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function h(e,t,n){t=p(t,"g");for(var o=n.line,r=n.ch,i=e.lastLine();o<=i;o++,r=0){t.lastIndex=r;var a=e.getLine(o),a=t.exec(a);if(a)return{from:y(o,a.index),to:y(o,a.index+a[0].length),match:a}}}function i(e,t,n){if(!g(t))return h(e,t,n);t=p(t,"gm");for(var o=1,r=n.line,i=e.lastLine();r<=i;){for(var a=0;a<o&&!(i<r);a++)var l=e.getLine(r++),s=null==s?l:s+"\n"+l;o*=2,t.lastIndex=n.ch;var c,f,u,d=t.exec(s);if(d)return u=s.slice(0,d.index).split("\n"),c=d[0].split("\n"),f=n.line+u.length-1,u=u[u.length-1].length,{from:y(f,u),to:y(f+c.length-1,1==c.length?u+c[0].length:c[c.length-1].length),match:d}}}function b(e,t,n){for(var o,r=0;r<=e.length;){t.lastIndex=r;var i=t.exec(e);if(!i)break;var a=i.index+i[0].length;if(a>e.length-n)break;(!o||a>o.index+o[0].lengt