public/plugins/textpattern/plugin.min.js in card-mod-tinymce_editor-0.15.5 vs public/plugins/textpattern/plugin.min.js in card-mod-tinymce_editor-0.15.6
- old
+ new
@@ -2,8 +2,8 @@
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
- * Version: 5.0.11 (2019-07-04)
+ * Version: 5.10.7 (2022-12-06)
*/
-!function(f){"use strict";var t,n,e,r,o,a=function(t){var n=t,e=function(){return n};return{get:e,set:function(t){n=t},clone:function(){return a(e())}}},i=tinymce.util.Tools.resolve("tinymce.PluginManager"),u=function(){},c=function(t){return function(){return t}},s=function(t){return t},l=c(!1),d=c(!0),m=l,g=d,p=function(){return h},h=(r={fold:function(t,n){return t()},is:m,isSome:m,isNone:g,getOr:e=function(t){return t},getOrThunk:n=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:e,orThunk:n,map:p,ap:p,each:function(){},bind:p,flatten:p,exists:m,forall:g,filter:p,equals:t=function(t){return t.isNone()},equals_:t,toArray:function(){return[]},toString:c("none()")},Object.freeze&&Object.freeze(r),r),v=function(e){var t=function(){return e},n=function(){return o},r=function(t){return t(e)},o={fold:function(t,n){return n(e)},is:function(t){return e===t},isSome:g,isNone:m,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:n,orThunk:n,map:function(t){return v(t(e))},ap:function(t){return t.fold(p,function(t){return v(t(e))})},each:function(t){t(e)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(e)?o:h},equals:function(t){return t.is(e)},equals_:function(t,n){return t.fold(m,function(t){return n(e,t)})},toArray:function(){return[e]},toString:function(){return"some("+e+")"}};return o},y={some:v,none:p,from:function(t){return null===t||t===undefined?h:v(t)}},k=function(n){return function(t){return function(t){if(null===t)return"null";var n=typeof t;return"object"===n&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"===n&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":n}(t)===n}},b=k("string"),O=k("object"),w=k("array"),E=k("function"),C=Array.prototype.slice,x=(o=Array.prototype.indexOf)===undefined?function(t,n){return S(t,n)}:function(t,n){return o.call(t,n)},T=function(t,n){for(var e=t.length,r=new Array(e),o=0;o<e;o++){var a=t[o];r[o]=n(a,o,t)}return r},N=function(t,n){for(var e=0,r=t.length;e<r;e++){n(t[e],e,t)}},R=function(t,n){for(var e=[],r=0,o=t.length;r<o;r++){var a=t[r];n(a,r,t)&&e.push(a)}return e},P=function(t,n,e){return function(t,n){for(var e=t.length-1;0<=e;e--)n(t[e],e,t)}(t,function(t){e=n(e,t)}),e},S=function(t,n){for(var e=0,r=t.length;e<r;++e)if(t[e]===n)return e;return-1},M=function(t,n){for(var e=0,r=t.length;e<r;++e){if(!0!==n(t[e],e,t))return!1}return!0},A=(E(Array.from)&&Array.from,Object.keys),D=Object.hasOwnProperty,j=function(t,n){return D.call(t,n)},B=function(i){if(!w(i))throw new Error("cases must be an array");if(0===i.length)throw new Error("there must be at least one case");var u=[],e={};return N(i,function(t,r){var n=A(t);if(1!==n.length)throw new Error("one and only one name per case");var o=n[0],a=t[o];if(e[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!w(a))throw new Error("case arguments must be an array");u.push(o),e[o]=function(){var t=arguments.length;if(t!==a.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+a.length+" ("+a+"), got "+t);for(var e=new Array(t),n=0;n<e.length;n++)e[n]=arguments[n];return{fold:function(){if(arguments.length!==i.length)throw new Error("Wrong number of arguments to fold. Expected "+i.length+", got "+arguments.length);return arguments[r].apply(null,e)},match:function(t){var n=A(t);if(u.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+u.join(",")+"\nActual: "+n.join(","));if(!M(u,function(t){return-1<x(n,t)}))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+u.join(", "));return t[o].apply(null,e)},log:function(t){f.console.log(t,{constructors:u,constructor:o,params:e})}}}}),e},I=(B([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),function(t){var n=[],e=[];return N(t,function(t){t.fold(function(t){n.push(t)},function(t){e.push(t)})}),{errors:n,values:e}}),_=function(e){return{is:function(t){return e===t},isValue:d,isError:l,getOr:c(e),getOrThunk:c(e),getOrDie:c(e),or:function(t){return _(e)},orThunk:function(t){return _(e)},fold:function(t,n){return n(e)},map:function(t){return _(t(e))},mapError:function(t){return _(e)},each:function(t){t(e)},bind:function(t){return t(e)},exists:function(t){return t(e)},forall:function(t){return t(e)},toOption:function(){return y.some(e)}}},L=function(e){return{is:l,isValue:l,isError:d,getOr:s,getOrThunk:function(t){return t()},getOrDie:function(){return t=String(e),function(){throw new Error(t)}();var t},or:function(t){return t},orThunk:function(t){return t()},fold:function(t,n){return t(e)},map:function(t){return L(e)},mapError:function(t){return L(t(e))},each:u,bind:function(t){return L(e)},exists:l,forall:d,toOption:y.none}},U={value:_,error:L,fromOption:function(t,n){return t.fold(function(){return L(n)},_)}},q=function(t){return"inline-command"===t.type||"inline-format"===t.type},V=function(t){return"block-command"===t.type||"block-format"===t.type},W=function(t){return n=t,e=function(t,n){return t.start.length===n.start.length?0:t.start.length>n.start.length?-1:1},(r=C.call(n,0)).sort(e),r;var n,e,r},X=function(o){var a=function(t){return U.error({message:t,pattern:o})},t=function(t,n,e){if(o.format===undefined)return o.cmd!==undefined?b(o.cmd)?U.value(e(o.cmd,o.value)):a(t+" pattern has non-string `cmd` parameter"):a(t+" pattern is missing both `format` and `cmd` parameters");var r=void 0;if(w(o.format)){if(!M(o.format,b))return a(t+" pattern has non-string items in the `format` array");r=o.format}else{if(!b(o.format))return a(t+" pattern has non-string `format` parameter");r=[o.format]}return U.value(n(r))};if(!O(o))return a("Raw pattern is not an object");if(!b(o.start))return a("Raw pattern is missing `start` parameter");if(o.end===undefined)return o.replacement!==undefined?b(o.replacement)?0===o.start.length?a("Replacement pattern has empty `start` parameter"):U.value({type:"inline-command",start:"",end:o.start,cmd:"mceInsertContent",value:o.replacement}):a("Replacement pattern has non-string `replacement` parameter"):0===o.start.length?a("Block pattern has empty `start` parameter"):t("Block",function(t){return{type:"block-format",start:o.start,format:t[0]}},function(t,n){return{type:"block-command",start:o.start,cmd:t,value:n}});if(!b(o.end))return a("Inline pattern has non-string `end` parameter");if(0===o.start.length&&0===o.end.length)return a("Inline pattern has empty `start` and `end` parameters");var e=o.start,r=o.end;return 0===r.length&&(r=e,e=""),t("Inline",function(t){return{type:"inline-format",start:e,end:r,format:t}},function(t,n){return{type:"inline-command",start:e,end:r,cmd:t,value:n}})},z=function(t){return"block-command"===t.type?{start:t.start,cmd:t.cmd,value:t.value}:"block-format"===t.type?{start:t.start,format:t.format}:"inline-command"===t.type?"mceInsertContent"===t.cmd&&""===t.start?{start:t.end,replacement:t.value}:{start:t.start,end:t.end,cmd:t.cmd,value:t.value}:"inline-format"===t.type?{start:t.start,end:t.end,format:1===t.format.length?t.format[0]:t.format}:void 0},F=function(t){return{inlinePatterns:R(t,q),blockPatterns:W(R(t,V))}},J=function(r){return{setPatterns:function(t){var n=I(T(t,X));if(0<n.errors.length){var e=n.errors[0];throw new Error(e.message+":\n"+JSON.stringify(e.pattern,null,2))}r.set(F(n.values))},getPatterns:function(){return T(r.get().inlinePatterns,z).concat(T(r.get().blockPatterns,z))}}},K="undefined"!=typeof f.window?f.window:Function("return this;")(),G=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=K.console;e&&(e.error?e.error.apply(e,t):e.log.apply(e,t))},H=[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],Q=function(t){var n,e,r=(n=t,e="textpattern_patterns",j(n,e)?y.from(n[e]):y.none()).getOr(H);if(!w(r))return G("The setting textpattern_patterns should be an array"),{inlinePatterns:[],blockPatterns:[]};var o=I(T(r,X));return N(o.errors,function(t){return G(t.message,t.pattern)}),F(o.values)},Y=tinymce.util.Tools.resolve("tinymce.util.Delay"),Z=tinymce.util.Tools.resolve("tinymce.util.VK"),$=tinymce.util.Tools.resolve("tinymce.util.Tools"),tt=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),nt=function(t){return t.nodeType===f.Node.TEXT_NODE},et=function(t,n,e){if(n&&t.isEmpty(n)&&!e(n)){var r=n.parentNode;t.remove(n),et(t,r,e)}},rt=function(t,n,e,r){void 0===r&&(r=!0);var o=n.startContainer.parentNode,a=n.endContainer.parentNode;n.deleteContents(),r&&!e(n.startContainer)&&(nt(n.startContainer)&&0===n.startContainer.data.length&&t.remove(n.startContainer),nt(n.endContainer)&&0===n.endContainer.data.length&&t.remove(n.endContainer),et(t,o,e),o!==a&&et(t,a,e))},ot=function(t,n){var e,r=n.get(t);return w(r)&&(e=r,0===e.length?y.none():y.some(e[0])).exists(function(t){return j(t,"block")})},at=function(t){return 0===t.start.length},it=function(t,n){return function(t,n){for(var e=0,r=t.length;e<r;e++){var o=t[e];if(n(o,e,t))return y.some(o)}return y.none()}(t,function(t){return 0===n.indexOf(t.start)&&(!j(t,"end")||!t.end||n.lastIndexOf(t.end)===n.length-t.end.length)})},ut=function(t,n){return{element:t,offset:n}},ft=function(t,n){var e=new tt(t,n),r=function(t){for(var n=e[t]();n&&n.nodeType!==f.Node.TEXT_NODE;)n=e[t]();return n&&n.nodeType===f.Node.TEXT_NODE?y.some(n):y.none()};return{next:function(){return r("next")},prev:function(){return r("prev")},prev2:function(){return r("prev2")}}},ct=function(t,n,e){return nt(t)&&0<=n?y.some(ut(t,n)):ft(t,e).prev().map(function(t){return ut(t,t.data.length)})},st=function(t,e,r){if(!nt(t))return y.none();var n=t.textContent;return 0<=e&&e<=n.length?y.some(ut(t,e)):ft(t,r).prev().bind(function(t){var n=t.textContent;return st(t,e+n.length,r)})},lt=function(t,n,e){if(!nt(t))return y.none();var r=t.textContent;return n<=r.length?y.some(ut(t,n)):ft(t,e).next().bind(function(t){return lt(t,n-r.length,e)})},dt=B([{aborted:[]},{edge:["element"]},{success:["info"]}]),mt=B([{abort:[]},{kontinue:[]},{finish:["info"]}]),gt=function(n,e,t,r,o,a){var i=function(){return a.fold(dt.aborted,dt.edge)},u=function(){var t=o();return t?gt(n,t,y.none(),r,o,y.some(e)):i()};if(n.isBlock(e))return i();if(nt(e)){var f=e.textContent;return r(mt,e,f,t).fold(dt.aborted,function(){return u()},dt.success)}return u()},pt=function(t,n,e){if(nt(n)&&(e<0||e>n.data.length))return[];for(var r=[e],o=n;o!==t&&o.parentNode;){for(var a=o.parentNode,i=0;i<a.childNodes.length;i++)if(a.childNodes[i]===o){r.push(i);break}o=a}return o===t?r.reverse():[]},ht=function(t,n,e,r,o){return{start:pt(t,n,e),end:pt(t,r,o)}},vt=function(t,n){var e,r,o,a=n.slice(),i=a.pop();return(e=a,r=function(t,n){return t.bind(function(t){return y.from(t.childNodes[n])})},o=y.some(t),N(e,function(t){o=r(o,t)}),o).bind(function(t){return nt(t)&&0<=i&&t.data.length,y.some({node:t,offset:i})})},yt=function(n,e){return vt(n,e.start).bind(function(t){var o=t.node,a=t.offset;return vt(n,e.end).map(function(t){var n=t.node,e=t.offset,r=f.document.createRange();return r.setStart(o,a),r.setEnd(n,e),r})})},kt=function(r,o,t){ft(o,o).next().each(function(e){lt(e,t.start.length,o).each(function(t){var n=r.createRng();n.setStart(e,0),n.setEnd(t.element,t.offset),rt(r,n,function(t){return t===o})})})},bt=function(t,n){var e=t.dom,r=t.selection.getRng(),o=e.getParent(r.startContainer,e.isBlock);if(!e.is(o,"p")||o.nodeType!==f.Node.ELEMENT_NODE)return[];var a=o.textContent;return it(n,a).map(function(t){return $.trim(a).length===t.start.length?[]:[{pattern:t,range:ht(e.getRoot(),o,0,o,0)}]}).getOr([])},Ot=function(u,t){if(0!==t.length){var n=u.selection.getBookmark();N(t,function(t){return e=t,r=(n=u).dom,o=e.pattern,a=yt(r.getRoot(),e.range).getOrDie("Unable to resolve path range"),i=r.getParent(a.startContainer,r.isBlock),"block-format"===o.type?ot(o.format,n.formatter)&&n.undoManager.transact(function(){kt(n.dom,i,o),n.formatter.apply(o.format)}):"block-command"===o.type&&n.undoManager.transact(function(){kt(n.dom,i,o),n.execCommand(o.cmd,!1,o.value)}),!0;var n,e,r,o,a,i}),u.selection.moveToBookmark(n)}},wt=function(){return(wt=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},Et=0,Ct=function(t,n){return t.create("span",{"data-mce-type":"bookmark",id:n})},xt=function(t,n){var e=t.createRng();return e.setStartAfter(n.start),e.setEndBefore(n.end),e},Tt=function(t,n,e){var r=yt(t.getRoot(),e).getOrDie("Unable to resolve path range"),o=r.startContainer,a=r.endContainer,i=0===r.endOffset?a:a.splitText(r.endOffset),u=0===r.startOffset?o:o.splitText(r.startOffset);return{prefix:n,end:i.parentNode.insertBefore(Ct(t,n+"-end"),i),start:u.parentNode.insertBefore(Ct(t,n+"-start"),u)}},Nt=function(t,n,e){et(t,t.get(n.prefix+"-end"),e),et(t,t.get(n.prefix+"-start"),e)},Rt=function(i,u,t,n,l,d){if(void 0===d&&(d=!1),0!==u.start.length||d)return ct(t,n,l).bind(function(n){var t,e,r,o,a,f,c,s;return(t=i,e=n.element,r=n.offset,f=i,c=l,s=u.start,o=function(e,r,t,n){if(r===c)return e.abort();var o=t.substring(0,n.getOr(t.length)),a=o.lastIndexOf(s.charAt(s.length-1)),i=o.lastIndexOf(s);if(-1===i)return-1!==a?st(r,a+1-s.length,c).fold(function(){return e.kontinue()},function(t){var n=f.createRng();return n.setStart(t.element,t.offset),n.setEnd(r,a+1),n.toString()===s?e.finish(n):e.kontinue()}):e.kontinue();var u=f.createRng();return u.setStart(r,i),u.setEnd(r,i+s.length),e.finish(u)},a=new tt(e,l),gt(t,e,y.some(r),o,a.prev,y.none())).fold(y.none,y.none,y.some).bind(function(t){if(d){if(t.endContainer===n.element&&t.endOffset===n.offset)return y.none();if(0===n.offset&&t.endContainer.textContent.length===t.endOffset)return y.none()}return y.some(t)})});var e=i.createRng();return e.setStart(t,n),e.setEnd(t,n),y.some(e)},Pt=function(a,i,u){var f=a.dom,c=f.getRoot(),s=u.pattern,l=u.position.element,d=u.position.offset;return st(l,d-u.pattern.end.length,i).bind(function(t){var r=ht(c,t.element,t.offset,l,d);if(at(s))return y.some({matches:[{pattern:s,startRng:r,endRng:r}],position:t});var n=St(a,u.remainingPatterns,t.element,t.offset,i),o=n.getOr({matches:[],position:t}),e=o.position;return Rt(f,s,e.element,e.offset,i,n.isNone()).map(function(t){var n,e=ht(c,(n=t).startContainer,n.startOffset,n.endContainer,n.endOffset);return{matches:o.matches.concat([{pattern:s,startRng:e,endRng:r}]),position:ut(t.startContainer,t.startOffset)}})})},St=function(d,m,g,p,h){var v=d.dom;return ct(g,p,v.getRoot()).bind(function(t){var n=v.createRng();n.setStart(h,0),n.setEnd(g,p);for(var e,r,o,a,i,u=n.toString(),f=0;f<m.length;f++){var c=m[f];if(e=u,r=c.end,i=a=o=void 0,a=r,i=(o=e).length-r.length,""===a||!(o.length<a.length||o.substr(i,i+a.length)!==a)){var s=m.slice();s.splice(f,1);var l=Pt(d,h,{pattern:c,remainingPatterns:s,position:t});if(l.isSome())return l}}return y.none()})},Mt=function(n,t,e){n.selection.setRng(e),"inline-format"===t.type?N(t.format,function(t){n.formatter.apply(t)}):n.execCommand(t.cmd,!1,t.value)},At=function(o,t){var n,e,a=(n="mce_textpattern",e=(new Date).getTime(),n+"_"+Math.floor(1e9*Math.random())+ ++Et+String(e)),i=P(t,function(t,n){var e=Tt(o,a+"_end"+t.length,n.endRng);return t.concat([wt({},n,{endMarker:e})])},[]);return P(i,function(t,n){var e=i.length-t.length-1,r=at(n.pattern)?n.endMarker:Tt(o,a+"_start"+e,n.startRng);return t.concat([wt({},n,{startMarker:r})])},[])},Dt=function(t,n,e){var r=t.selection.getRng();if(!1===r.collapsed)return[];var o=t.dom.getParent(r.startContainer,t.dom.isBlock),a=r.startOffset-(e?1:0);return St(t,n,r.startContainer,a,o).fold(function(){return[]},function(t){return t.matches})},jt=function(f,t){if(0!==t.length){var c=f.dom,n=f.selection.getBookmark(),e=At(c,t);N(e,function(t){var n,e,r,o,a,i=c.getParent(t.startMarker.start,c.isBlock),u=function(t){return t===i};at(t.pattern)?(n=f,e=t.pattern,r=t.endMarker,o=u,a=xt(n.dom,r),rt(n.dom,a,o),Mt(n,e,a)):function(t,n,e,r,o){var a=t.dom,i=xt(a,r),u=xt(a,e);rt(a,u,o),rt(a,i,o);var f={prefix:e.prefix,start:e.end,end:r.start},c=xt(a,f);Mt(t,n,c)}(f,t.pattern,t.startMarker,t.endMarker,u),Nt(c,t.endMarker,u),Nt(c,t.startMarker,u)}),f.selection.moveToBookmark(n)}},Bt=function(t,n,e){for(var r=0;r<t.length;r++)if(e(t[r],n))return!0},It=function(e,t){if(!e.selection.isCollapsed())return!1;var r=Dt(e,t.inlinePatterns,!1),o=bt(e,t.blockPatterns);return(0<o.length||0<r.length)&&(e.undoManager.add(),e.undoManager.extra(function(){e.execCommand("mceInsertNewLine")},function(){e.insertContent("\ufeff"),jt(e,r),Ot(e,o);var t=e.selection.getRng(),n=ct(t.startContainer,t.startOffset,e.dom.getRoot());e.execCommand("mceInsertNewLine"),n.each(function(t){"\ufeff"===t.element.data.charAt(t.offset-1)&&(t.element.deleteData(t.offset-1,1),et(e.dom,t.element.parentNode,function(t){return t===e.dom.getRoot()}))})}),!0)},_t=function(t,n){var e=Dt(t,n.inlinePatterns,!0);0<e.length&&t.undoManager.transact(function(){jt(t,e)})},Lt=function(t,n){return Bt(t,n,function(t,n){return t.charCodeAt(0)===n.charCode})},Ut=function(t,n){return Bt(t,n,function(t,n){return t===n.keyCode&&!1===Z.modifierPressed(n)})},qt=function(n,e){var r=[",",".",";",":","!","?"],o=[32];n.on("keydown",function(t){13!==t.keyCode||Z.modifierPressed(t)||It(n,e.get())&&t.preventDefault()},!0),n.on("keyup",function(t){Ut(o,t)&&_t(n,e.get())}),n.on("keypress",function(t){Lt(r,t)&&Y.setEditorTimeout(n,function(){_t(n,e.get())})})};!function Vt(){i.add("textpattern",function(t){var n=a(Q(t.settings));return qt(t,n),J(n)})}()}(window);
+!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),u=function(){return(u=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};function a(t,n,r){if(r||2===arguments.length)for(var e,o=0,a=n.length;o<a;o++)!e&&o in n||((e=e||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}function n(e){return function(t){return r=typeof(n=t),(null===n?"null":"object"==r&&(Array.prototype.isPrototypeOf(n)||n.constructor&&"Array"===n.constructor.name)?"array":"object"==r&&(String.prototype.isPrototypeOf(n)||n.constructor&&"String"===n.constructor.name)?"string":r)===e;var n,r}}function e(){}function i(t){return function(){return t}}function o(t){return t}function r(){return m}var f=n("string"),c=n("object"),s=n("array"),l=i(!1),d=i(!0),m={fold:function(t,n){return t()},isSome:l,isNone:d,getOr:o,getOrThunk:g,getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:i(null),getOrUndefined:i(void 0),or:o,orThunk:g,map:r,each:e,bind:r,exists:l,forall:d,filter:function(){return m},toArray:function(){return[]},toString:i("none()")};function g(t){return t()}function p(t,n){return-1<E.call(t,n)}function h(t,n){for(var r=t.length,e=new Array(r),o=0;o<r;o++){var a=t[o];e[o]=n(a,o)}return e}function v(t,n){for(var r=0,e=t.length;r<e;r++)n(t[r],r)}function y(t,n){for(var r=[],e=0,o=t.length;e<o;e++){var a=t[e];n(a,e)&&r.push(a)}return r}function b(t,e,o){return function(t){for(var n,r=t.length-1;0<=r;r--)n=t[r],o=e(o,n,r)}(t),o}function k(t,n){for(var r=0,e=t.length;r<e;++r)if(!0!==n(t[r],r))return;return 1}var O=function(r){function t(){return o}function n(t){return t(r)}var e=i(r),o={fold:function(t,n){return n(r)},isSome:d,isNone:l,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(t){return O(t(r))},each:function(t){t(r)},bind:n,exists:n,forall:n,filter:function(t){return t(r)?o:m},toArray:function(){return[r]},toString:function(){return"some("+r+")"}};return o},w={some:O,none:r,from:function(t){return null==t?m:O(t)}},C=Array.prototype.slice,E=Array.prototype.indexOf,x=Object.keys,R=Object.hasOwnProperty;function T(t){var n=[],r=[];return v(t,function(t){t.fold(function(t){n.push(t)},function(t){r.push(t)})}),{errors:n,values:r}}function P(t){return"inline-command"===t.type||"inline-format"===t.type}function N(t){return"block-command"===t.type||"block-format"===t.type}function S(o){function a(t){return ut.error({message:t,pattern:o})}function t(t,n,r){if(void 0===o.format)return void 0!==o.cmd?f(o.cmd)?ut.value(r(o.cmd,o.value)):a(t+" pattern has non-string `cmd` parameter"):a(t+" pattern is missing both `format` and `cmd` parameters");var e=void 0;if(s(o.format)){if(!k(o.format,f))return a(t+" pattern has non-string items in the `format` array");e=o.format}else{if(!f(o.format))return a(t+" pattern has non-string `format` parameter");e=[o.format]}return ut.value(n(e))}if(!c(o))return a("Raw pattern is not an object");if(!f(o.start))return a("Raw pattern is missing `start` parameter");if(void 0===o.end)return void 0!==o.replacement?f(o.replacement)?0===o.start.length?a("Replacement pattern has empty `start` parameter"):ut.value({type:"inline-command",start:"",end:o.start,cmd:"mceInsertContent",value:o.replacement}):a("Replacement pattern has non-string `replacement` parameter"):0===o.start.length?a("Block pattern has empty `start` parameter"):t("Block",function(t){return{type:"block-format",start:o.start,format:t[0]}},function(t,n){return{type:"block-command",start:o.start,cmd:t,value:n}});if(!f(o.end))return a("Inline pattern has non-string `end` parameter");if(0===o.start.length&&0===o.end.length)return a("Inline pattern has empty `start` and `end` parameters");var r=o.start,e=o.end;return 0===e.length&&(e=r,r=""),t("Inline",function(t){return{type:"inline-format",start:r,end:e,format:t}},function(t,n){return{type:"inline-command",start:r,end:e,cmd:t,value:n}})}function M(t){return"block-command"===t.type?{start:t.start,cmd:t.cmd,value:t.value}:"block-format"===t.type?{start:t.start,format:t.format}:"inline-command"===t.type?"mceInsertContent"===t.cmd&&""===t.start?{start:t.end,replacement:t.value}:{start:t.start,end:t.end,cmd:t.cmd,value:t.value}:"inline-format"===t.type?{start:t.start,end:t.end,format:1===t.format.length?t.format[0]:t.format}:void 0}function A(t){return{inlinePatterns:y(t,P),blockPatterns:(n=y(t,N),r=function(t,n){return t.start.length===n.start.length?0:t.start.length>n.start.length?-1:1},(e=C.call(n,0)).sort(r),e)};var n,r,e}function B(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=ft.console;r&&(r.error||r.log).apply(r,t)}function D(t){var n=t.getParam("forced_root_block","p");return!1===n?"":!0===n?"p":n}function I(t,n){return{container:t,offset:n}}function j(t){return t.nodeType===Node.TEXT_NODE}function _(t,n,r,e){void 0===e&&(e=!0);var o=n.startContainer.parentNode,a=n.endContainer.parentNode;n.deleteContents(),e&&!r(n.startContainer)&&(j(n.startContainer)&&0===n.startContainer.data.length&&t.remove(n.startContainer),j(n.endContainer)&&0===n.endContainer.data.length&&t.remove(n.endContainer),pt(t,o,r),o!==a&&pt(t,a,r))}function U(t,n){var r,e=n.get(t);return s(e)&&(0<(r=e).length?w.some(r[0]):w.none()).exists(function(t){return R.call(t,"block")})}function L(t){return 0===t.start.length}function V(t,n){var r=w.from(t.dom.getParent(n.startContainer,t.dom.isBlock));return""===D(t)?r.orThunk(function(){return w.some(t.getBody())}):r}function W(n){return function(t){return n===t?-1:0}}function q(t,n,r){if(j(t)&&0<=n)return w.some(I(t,n));var e=gt(ht);return w.from(e.backwards(t,n,W(t),r)).map(function(t){return I(t.container,t.container.data.length)})}function F(t,n,r){if(j(n)&&(r<0||r>n.data.length))return[];for(var e=[r],o=n;o!==t&&o.parentNode;){for(var a=o.parentNode,i=0;i<a.childNodes.length;i++)if(a.childNodes[i]===o){e.push(i);break}o=a}return o===t?e.reverse():[]}function G(t,n,r,e,o){return{start:F(t,n,r),end:F(t,e,o)}}function H(t,n){var r=n.slice(),e=r.pop(),o=r,a=function(t,n){return t.bind(function(t){return w.from(t.childNodes[n])})},i=w.some(t);return v(o,function(t,n){i=a(i,t)}),i.bind(function(t){return j(t)&&(e<0||e>t.data.length)?w.none():w.some({node:t,offset:e})})}function J(n,r){return H(n,r.start).bind(function(t){var o=t.node,a=t.offset;return H(n,r.end).map(function(t){var n=t.node,r=t.offset,e=document.createRange();return e.setStart(o,a),e.setEnd(n,r),e})})}function K(e,o,n){!function(t,n){if(j(t)&&t.length<=0)return w.some(I(t,0));var r=gt(ht);return w.from(r.forwards(t,0,W(t),n)).map(function(t){return I(t.container,0)})}(o,o).each(function(t){var r=t.container;yt(r,n.start.length,o).each(function(t){var n=e.createRng();n.setStart(r,0),n.setEnd(t.container,t.offset),_(e,n,function(t){return t===o})})})}function X(e,a){var i=e.dom,t=e.selection.getRng();return V(e,t).filter(function(t){var n=D(e),r=""===n&&i.is(t,"body")||i.is(t,n);return null!==t&&r}).bind(function(n){var r,e=n.textContent,t=a,o=(r=e).replace("\xa0"," ");return function(t,n,r){for(var e=0,o=t.length;e<o;e++){var a=t[e];if(n(a,e))return w.some(a);if(r(a,e))break}return w.none()}(t,function(t){return 0===r.indexOf(t.start)||0===o.indexOf(t.start)},l).map(function(t){return dt.trim(e).length===t.start.length?[]:[{pattern:t,range:G(i.getRoot(),n,0,n,0)}]})}).getOr([])}function z(t,n){return t.create("span",{"data-mce-type":"bookmark",id:n})}function Q(t,n){var r=t.createRng();return r.setStartAfter(n.start),r.setEndBefore(n.end),r}function Y(t,n,r){var e=J(t.getRoot(),r).getOrDie("Unable to resolve path range"),o=e.startContainer,a=e.endContainer,i=0===e.endOffset?a:a.splitText(e.endOffset),u=0===e.startOffset?o:o.splitText(e.startOffset);return{prefix:n,end:i.parentNode.insertBefore(z(t,n+"-end"),i),start:u.parentNode.insertBefore(z(t,n+"-start"),u)}}function Z(t,n,r){pt(t,t.get(n.prefix+"-end"),r),pt(t,t.get(n.prefix+"-start"),r)}function $(n,t,r){n.selection.setRng(r),"inline-format"===t.type?v(t.format,function(t){n.formatter.apply(t)}):n.execCommand(t.cmd,!1,t.value)}function tt(r,e,o){var a=r.selection.getRng();return!1===a.collapsed?[]:V(r,a).bind(function(t){var n=a.startOffset-(o?1:0);return Ot(r,e,a.startContainer,n,t)}).fold(function(){return[]},function(t){return t.matches})}function nt(p,t){var h,n,o,r,e,a,i;0!==t.length&&(h=p.dom,n=p.selection.getBookmark(),o=h,r=t,e=(new Date).getTime(),a="mce_textpattern_"+Math.floor(1e9*Math.random())+ ++bt+String(e),i=b(r,function(t,n){var r=Y(o,a+"_end"+t.length,n.endRng);return t.concat([u(u({},n),{endMarker:r})])},[]),v(b(i,function(t,n){var r=i.length-t.length-1,e=L(n.pattern)?n.endMarker:Y(o,a+"_start"+r,n.startRng);return t.concat([u(u({},n),{startMarker:e})])},[]),function(t){function n(t){return t===g}var r,e,o,a,i,u,f,c,s,l,d,m,g=h.getParent(t.startMarker.start,h.isBlock);L(t.pattern)?(e=t.pattern,o=t.endMarker,a=n,i=Q((r=p).dom,o),_(r.dom,i,a),$(r,e,i)):(u=p,f=t.pattern,c=t.startMarker,s=t.endMarker,l=n,d=u.dom,m=Q(d,s),_(d,Q(d,c),l),_(d,m,l),$(u,f,Q(d,{prefix:c.prefix,start:c.end,end:s.start}))),Z(h,t.endMarker,n),Z(h,t.startMarker,n)}),p.selection.moveToBookmark(n))}function rt(t,n){var r=tt(t,n.inlinePatterns,!0);0<r.length&&t.undoManager.transact(function(){nt(t,r)})}function et(t,n,r){for(var e=0;e<t.length;e++)if(r(t[e],n))return 1}function ot(n,r){var e=[",",".",";",":","!","?"],o=[32];n.on("keydown",function(t){13!==t.keyCode||lt.modifierPressed(t)||!function(o,t){if(o.selection.isCollapsed()){var a=tt(o,t.inlinePatterns,!1),u=X(o,t.blockPatterns);return(0<u.length||0<a.length)&&(o.undoManager.add(),o.undoManager.extra(function(){o.execCommand("mceInsertNewLine")},function(){var i,t,n;o.insertContent("\ufeff"),nt(o,a),i=o,0!==(t=u).length&&(n=i.selection.getBookmark(),v(t,function(t){return e=(n=i).dom,o=(r=t).pattern,a=J(e.getRoot(),r.range).getOrDie("Unable to resolve path range"),V(n,a).each(function(t){"block-format"===o.type?U(o.format,n.formatter)&&n.undoManager.transact(function(){K(n.dom,t,o),n.formatter.apply(o.format)}):"block-command"===o.type&&n.undoManager.transact(function(){K(n.dom,t,o),n.execCommand(o.cmd,!1,o.value)})}),1;var n,r,e,o,a}),i.selection.moveToBookmark(n));var r=o.selection.getRng(),e=q(r.startContainer,r.startOffset,o.dom.getRoot());o.execCommand("mceInsertNewLine"),e.each(function(t){var n=t.container;"\ufeff"===n.data.charAt(t.offset-1)&&(n.deleteData(t.offset-1,1),pt(o.dom,n.parentNode,function(t){return t===o.dom.getRoot()}))})}),1)}}(n,r.get())||t.preventDefault()},!0),n.on("keyup",function(t){et(o,t,function(t,n){return t===n.keyCode&&!1===lt.modifierPressed(n)})&&rt(n,r.get())}),n.on("keypress",function(t){et(e,t,function(t,n){return t.charCodeAt(0)===n.charCode})&&st.setEditorTimeout(n,function(){rt(n,r.get())})})}!function(i){if(!s(i))throw new Error("cases must be an array");if(0===i.length)throw new Error("there must be at least one case");var u=[],r={};v(i,function(t,e){var n=x(t);if(1!==n.length)throw new Error("one and only one name per case");var o=n[0],a=t[o];if(void 0!==r[o])throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!s(a))throw new Error("case arguments must be an array");u.push(o),r[o]=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=r.length;if(n!==a.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+a.length+" ("+a+"), got "+n);return{fold:function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(t.length!==i.length)throw new Error("Wrong number of arguments to fold. Expected "+i.length+", got "+t.length);return t[e].apply(null,r)},match:function(t){var n=x(t);if(u.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+u.join(",")+"\nActual: "+n.join(","));if(!k(u,function(t){return p(n,t)}))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+u.join(", "));return t[o].apply(null,r)},log:function(t){console.log(t,{constructors:u,constructor:o,params:r})}}}})}([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);var at=function(r){return{isValue:d,isError:l,getOr:i(r),getOrThunk:i(r),getOrDie:i(r),or:function(t){return at(r)},orThunk:function(t){return at(r)},fold:function(t,n){return n(r)},map:function(t){return at(t(r))},mapError:function(t){return at(r)},each:function(t){t(r)},bind:function(t){return t(r)},exists:function(t){return t(r)},forall:function(t){return t(r)},toOptional:function(){return w.some(r)}}},it=function(r){return{isValue:l,isError:d,getOr:o,getOrThunk:function(t){return t()},getOrDie:function(){return t=String(r),function(){throw new Error(t)}();var t},or:o,orThunk:function(t){return t()},fold:function(t,n){return t(r)},map:function(t){return it(r)},mapError:function(t){return it(t(r))},each:e,bind:function(t){return it(r)},exists:l,forall:d,toOptional:w.none}},ut={value:at,error:it,fromOption:function(t,n){return t.fold(function(){return it(n)},at)}},ft="undefined"!=typeof window?window:Function("return this;")(),ct=[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],st=tinymce.util.Tools.resolve("tinymce.util.Delay"),lt=tinymce.util.Tools.resolve("tinymce.util.VK"),dt=tinymce.util.Tools.resolve("tinymce.util.Tools"),mt=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),gt=tinymce.util.Tools.resolve("tinymce.dom.TextSeeker"),pt=function(t,n,r){var e;n&&t.isEmpty(n)&&!r(n)&&(e=n.parentNode,t.remove(n),pt(t,e,r))},ht=mt.DOM,vt=function(t,r,e){if(!j(t))return w.none();var n=t.textContent;if(0<=r&&r<=n.length)return w.some(I(t,r));var o=gt(ht);return w.from(o.backwards(t,r,W(t),e)).bind(function(t){var n=t.container.data;return vt(t.container,r+n.length,e)})},yt=function(t,n,r){if(!j(t))return w.none();var e=t.textContent;if(n<=e.length)return w.some(I(t,n));var o=gt(ht);return w.from(o.forwards(t,n,W(t),r)).bind(function(t){return yt(t.container,n-e.length,r)})},bt=0,kt=function(e,o,a,t){var i,n,r,u,f,c,s,l=o.start;return n=t.container,r=t.offset,i=l,u=function(t,n){var r=t.data.substring(0,n),e=r.lastIndexOf(i.charAt(i.length-1)),o=r.lastIndexOf(i);return-1!==o?o+i.length:-1!==e?e+1:-1},f=a,s=gt(e,(c=e,function(t){return c.isBlock(t)||p(["BR","IMG","HR","INPUT"],t.nodeName)||"false"===c.getContentEditable(t)})),w.from(s.backwards(n,r,u,f)).bind(function(r){if(r.offset>=l.length){var t=e.createRng();return t.setStart(r.container,r.offset-l.length),t.setEnd(r.container,r.offset),w.some(t)}var n=r.offset-l.length;return vt(r.container,n,a).map(function(t){var n=e.createRng();return n.setStart(t.container,t.offset),n.setEnd(r.container,r.offset),n}).filter(function(t){return t.toString()===l}).orThunk(function(){return kt(e,o,a,I(r.container,0))})})},Ot=function(l,d,m,g,p){var h=l.dom;return q(m,g,h.getRoot()).bind(function(t){var n=h.createRng();n.setStart(p,0),n.setEnd(m,g);for(var r,e=n.toString(),o=0;o<d.length;o++){var a,i,u=d[o],f=u.end;i=r=void 0;if(a=(r=e).length-f.length,""===(i=f)||r.length>=i.length&&r.substr(a,a+i.length)===i){var c=d.slice();c.splice(o,1);var s=function(a,i,u){var f=a.dom,c=f.getRoot(),s=u.pattern,l=u.position.container,d=u.position.offset;return vt(l,d-u.pattern.end.length,i).bind(function(t){var r=G(c,t.container,t.offset,l,d);if(L(s))return w.some({matches:[{pattern:s,startRng:r,endRng:r}],position:t});var n=Ot(a,u.remainingPatterns,t.container,t.offset,i),e=n.getOr({matches:[],position:t}),o=e.position;return function(t,r,n,e,o,a){if(void 0===a&&(a=!1),0!==r.start.length||a)return q(n,e,o).bind(function(n){return kt(t,r,o,n).bind(function(t){if(a){if(t.endContainer===n.container&&t.endOffset===n.offset)return w.none();if(0===n.offset&&t.endContainer.textContent.length===t.endOffset)return w.none()}return w.some(t)})});var i=t.createRng();return i.setStart(n,e),i.setEnd(n,e),w.some(i)}(f,s,o.container,o.offset,i,n.isNone()).map(function(t){var n=G(c,t.startContainer,t.startOffset,t.endContainer,t.endOffset);return{matches:e.matches.concat([{pattern:s,startRng:n,endRng:r}]),position:I(t.startContainer,t.startOffset)}})})}(l,p,{pattern:u,remainingPatterns:c,position:t});if(s.isSome())return s}}return w.none()})};t.add("textpattern",function(r){var t,n,e,o=(t=function(){var t=r.getParam("textpattern_patterns",ct,"array");if(!s(t))return B("The setting textpattern_patterns should be an array"),{inlinePatterns:[],blockPatterns:[]};var n=T(h(t,S));return v(n.errors,function(t){return B(t.message,t.pattern),0}),A(n.values)}(),n=t,{get:function(){return n},set:function(t){n=t}});return ot(r,o),e=o,{setPatterns:function(t){var n=T(h(t,S));if(0<n.errors.length){var r=n.errors[0];throw new Error(r.message+":\n"+JSON.stringify(r.pattern,null,2))}e.set(A(n.values))},getPatterns:function(){return a(a([],h(e.get().inlinePatterns,M),!0),h(e.get().blockPatterns,M),!0)}}})}();
\ No newline at end of file