mirror of https://github.com/mindoc-org/mindoc.git
4 lines
38 KiB
JavaScript
4 lines
38 KiB
JavaScript
|
/*! Editor.md v1.5.0 | addons.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-09 */
|
||
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineOption("showTrailingSpace",!1,function(t,i,o){o==e.Init&&(o=!1),o&&!i?t.removeOverlay("trailingspace"):!o&&i&&t.addOverlay({token:function(e){for(var t=e.string.length,i=t;i&&/\s/.test(e.string.charAt(i-1));--i);return i>e.pos?(e.pos=i,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(e){function t(e,t,i){var o,r=e.getWrapperElement();return o=r.appendChild(document.createElement("div")),i?o.className="CodeMirror-dialog CodeMirror-dialog-bottom":o.className="CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?o.innerHTML=t:o.appendChild(t),o}function i(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",function(o,r,n){function a(e){if("string"==typeof e)h.value=e;else{if(c)return;c=!0,l.parentNode.removeChild(l),d.focus(),n.onClose&&n.onClose(l)}}n||(n={}),i(this,null);var s,l=t(this,o,n.bottom),c=!1,d=this,h=l.getElementsByTagName("input")[0];return h?(n.value&&(h.value=n.value,h.select()),n.onInput&&e.on(h,"input",function(e){n.onInput(e,h.value,a)}),n.onKeyUp&&e.on(h,"keyup",function(e){n.onKeyUp(e,h.value,a)}),e.on(h,"keydown",function(t){n&&n.onKeyDown&&n.onKeyDown(t,h.value,a)||((27==t.keyCode||n.closeOnEnter!==!1&&13==t.keyCode)&&(h.blur(),e.e_stop(t),a()),13==t.keyCode&&r(h.value,t))}),n.closeOnBlur!==!1&&e.on(h,"blur",a),h.focus()):(s=l.getElementsByTagName("button")[0])&&(e.on(s,"click",function(){a(),d.focus()}),n.closeOnBlur!==!1&&e.on(s,"blur",a),s.focus()),a}),e.defineExtension("openConfirm",function(o,r,n){function a(){c||(c=!0,s.parentNode.removeChild(s),d.focus())}i(this,null);var s=t(this,o,n&&n.bottom),l=s.getElementsByTagName("button"),c=!1,d=this,h=1;l[0].focus();for(var u=0;u<l.length;++u){var f=l[u];!function(t){e.on(f,"click",function(i){e.e_preventDefault(i),a(),t&&t(d)})}(r[u]),e.on(f,"blur",function(){--h,setTimeout(function(){0>=h&&a()},200)}),e.on(f,"focus",function(){++h})}}),e.defineExtension("openNotification",function(o,r){function n(){l||(l=!0,clearTimeout(a),s.parentNode.removeChild(s))}i(this,n);var a,s=t(this,o,r&&r.bottom),l=!1,c=r&&"undefined"!=typeof r.duration?r.duration:5e3;return e.on(s,"click",function(t){e.e_preventDefault(t),n()}),c&&(a=setTimeout(n,c)),n})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,r,n){if(this.atOccurrence=!1,this.doc=e,null==n&&"string"==typeof t&&(n=!1),r=r?e.clipPos(r):o(0,0),this.pos={from:r,to:r},"string"!=typeof t)t.global||(t=new RegExp(t.source,t.ignoreCase?"ig":"g")),this.matches=function(i,r){if(i){t.lastIndex=0;for(var n,a,s=e.getLine(r.line).slice(0,r.ch),l=0;;){t.lastIndex=l;var c=t.exec(s);if(!c)break;if(n=c,a=n.index,l=n.index+(n[0].length||1),l==s.length)break}var d=n&&n[0].length||0;d||(0==a&&0==s.length?n=void 0:a!=e.getLine(r.line).length&&d++)}else{t.lastIndex=r.ch;var s=e.getLine(r.line),n=t.exec(s),d=n&&n[0].length||0,a=n&&n.index;a+d==s.length||d||(d=1)}return n&&d?{from:o(r.line,a),to:o(r.line,a+d),match:n}:void 0};else{var a=t;n&&(t=t.toLowerCase());var s=n?function(e){return e.toLowerCase()}:function(e){return e},l=t.split("\n");if(1==l.length)t.length?this.matches=function(r,n){if(r){var l=e.getLine(n.line).slice(0,n.ch),c=s(l),d=c.lastIndexOf(t);if(d>-1)return d=i(l,c,d),{from:o(n.line,d),to:o(n.line,d+a.length)}}else{var l=e.getLine(n.line).slice(n.ch),c=s(l),d=c.indexOf(t);if(d>-1)return d=i(l,c,d)+n.ch,{from:o(n.line,d),to:o(n.line,d+a.length)}}}:this.matches=function(){};else{var c=a.split("\n");this.matches=function(t,i){var r=l.length-1;if(t){if
|
||
|
|
||
|
}(function(e){"use strict";function t(e){for(var t=0;t<e.state.activeLines.length;t++)e.removeLineClass(e.state.activeLines[t],"wrap",n),e.removeLineClass(e.state.activeLines[t],"background",a)}function i(e,t){if(e.length!=t.length)return!1;for(var i=0;i<e.length;i++)if(e[i]!=t[i])return!1;return!0}function o(e,o){for(var r=[],s=0;s<o.length;s++){var l=o[s];if(l.empty()){var c=e.getLineHandleVisualStart(l.head.line);r[r.length-1]!=c&&r.push(c)}}i(e.state.activeLines,r)||e.operation(function(){t(e);for(var i=0;i<r.length;i++)e.addLineClass(r[i],"wrap",n),e.addLineClass(r[i],"background",a);e.state.activeLines=r})}function r(e,t){o(e,t.ranges)}var n="CodeMirror-activeline",a="CodeMirror-activeline-background";e.defineOption("styleActiveLine",!1,function(i,n,a){var s=a&&a!=e.Init;n&&!s?(i.state.activeLines=[],o(i,i.listSelections()),i.on("beforeSelectionChange",r)):!n&&s&&(i.off("beforeSelectionChange",r),t(i),delete i.state.activeLines)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){var i=e.getRange(c(t.line,t.ch-1),c(t.line,t.ch+1));return 2==i.length?i:null}function i(t,i,o){var r=t.getLine(i.line),n=t.getTokenAt(i);if(/\bstring2?\b/.test(n.type))return!1;var a=new e.StringStream(r.slice(0,i.ch)+o+r.slice(i.ch),4);for(a.pos=a.start=n.start;;){var s=t.getMode().token(a,n.state);if(a.pos>=i.ch+1)return/\bstring2?\b/.test(s);a.start=a.pos}}function o(o,r){for(var n={name:"autoCloseBrackets",Backspace:function(i){if(i.getOption("disableInput"))return e.Pass;for(var r=i.listSelections(),n=0;n<r.length;n++){if(!r[n].empty())return e.Pass;var a=t(i,r[n].head);if(!a||o.indexOf(a)%2!=0)return e.Pass}for(var n=r.length-1;n>=0;n--){var s=r[n].head;i.replaceRange("",c(s.line,s.ch-1),c(s.line,s.ch+1))}}},a="",s=0;s<o.length;s+=2)(function(t,o){a+=o,n["'"+t+"'"]=function(n){if(n.getOption("disableInput"))return e.Pass;for(var s,d,h=n.listSelections(),u=0;u<h.length;u++){var f,g=h[u],p=g.head,d=n.getRange(p,c(p.line,p.ch+1));if(g.empty())if(t==o&&d==o)f=n.getRange(p,c(p.line,p.ch+3))==t+t+t?"skipThree":"skip";else if(t==o&&p.ch>1&&r.indexOf(t)>=0&&n.getRange(c(p.line,p.ch-2),p)==t+t&&(p.ch<=2||n.getRange(c(p.line,p.ch-3),c(p.line,p.ch-2))!=t))f="addFour";else if('"'==t||"'"==t){if(e.isWordChar(d)||!i(n,p,t))return e.Pass;f="both"}else{if(!(n.getLine(p.line).length==p.ch||a.indexOf(d)>=0||l.test(d)))return e.Pass;f="both"}else f="surround";if(s){if(s!=f)return e.Pass}else s=f}n.operation(function(){if("skip"==s)n.execCommand("goCharRight");else if("skipThree"==s)for(var e=0;3>e;e++)n.execCommand("goCharRight");else if("surround"==s){for(var i=n.getSelections(),e=0;e<i.length;e++)i[e]=t+i[e]+o;n.replaceSelections(i,"around")}else"both"==s?(n.replaceSelection(t+o,null),n.execCommand("goCharLeft")):"addFour"==s&&(n.replaceSelection(t+t+t+t,"before"),n.execCommand("goCharRight"))})},t!=o&&(n["'"+o+"'"]=function(t){for(var i=t.listSelections(),r=0;r<i.length;r++){var n=i[r];if(!n.empty()||t.getRange(n.head,c(n.head.line,n.head.ch+1))!=o)return e.Pass}t.execCommand("goCharRight")})})(o.charAt(s),o.charAt(s+1));return n}function r(i){return function(o){if(o.getOption("disableInput"))return e.Pass;for(var r=o.listSelections(),n=0;n<r.length;n++){if(!r[n].empty())return e.Pass;var a=t(o,r[n].head);if(!a||i.indexOf(a)%2!=0)return e.Pass}o.operation(function(){o.replaceSelection("\n\n",null),o.execCommand("goCharLeft"),r=o.listSelections();for(var e=0;e<r.length;e++){var t=r[e].head.line;o.indentLine(t,null,!0),o.indentLine(t+1,null,!0)}})}}var n="()[]{}''\"\"",a="'\"",s="[]{}",l=/\s/,c=e.Pos;e.defineOption("autoCloseBrackets",!1,function(t,i,l){if(l!=e.Init&&l&&t.removeKeyMap("autoCloseBrackets"),i){var c=n,d=a,h=s;"string"==typeof i?c=i:"object"==typeof i&&(null!=i.pairs&&(c=i.pairs),null!=i.triples&&(d=i.triples),null!=i.explode&&(h=i.explode));var u=o(c,d);h&&(u.Enter=r(h)),t.addKeyMap(u)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/
|