plugin.min.js 27 KB

123456789
  1. /**
  2. * Copyright (c) Tiny Technologies, Inc. All rights reserved.
  3. * Licensed under the LGPL or a commercial license.
  4. * For LGPL see License.txt in the project root for license information.
  5. * For commercial licenses see https://www.tiny.cloud/
  6. *
  7. * Version: 5.4.2 (2020-08-17)
  8. */
  9. !function(u){"use strict";var e,n,t,r,o,i,a,c=tinymce.util.Tools.resolve("tinymce.PluginManager"),s=function(){},y=function(e){return function(){return e}},f=function(n){return function(e){return!n(e)}},d=y(!1),l=y(!0),m=function(){return p},p=(e=function(e){return e.isNone()},{fold:function(e,n){return e()},is:d,isSome:d,isNone:l,getOr:t=function(e){return e},getOrThunk:n=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:y(null),getOrUndefined:y(undefined),or:t,orThunk:n,map:m,each:s,bind:m,exists:d,forall:l,filter:m,equals:e,equals_:e,toArray:function(){return[]},toString:y("none()")}),g=function(t){var e=y(t),n=function(){return o},r=function(e){return e(t)},o={fold:function(e,n){return n(t)},is:function(e){return t===e},isSome:l,isNone:d,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return g(e(t))},each:function(e){e(t)},bind:r,exists:r,forall:r,filter:function(e){return e(t)?o:p},toArray:function(){return[t]},toString:function(){return"some("+t+")"},equals:function(e){return e.is(t)},equals_:function(e,n){return e.fold(d,function(e){return n(t,e)})}};return o},v={some:g,none:m,from:function(e){return null===e||e===undefined?p:g(e)}},h=function(r){return function(e){return t=typeof(n=e),(null===n?"null":"object"==t&&(Array.prototype.isPrototypeOf(n)||n.constructor&&"Array"===n.constructor.name)?"array":"object"==t&&(String.prototype.isPrototypeOf(n)||n.constructor&&"String"===n.constructor.name)?"string":t)===r;var n,t}},S=function(n){return function(e){return typeof e===n}},b=h("string"),C=h("array"),N=S("boolean"),O=S("function"),L=S("number"),w=Array.prototype.slice,T=Array.prototype.push,D=function(e,n){for(var t=e.length,r=new Array(t),o=0;o<t;o++){var i=e[o];r[o]=n(i,o)}return r},k=function(e,n){for(var t=0,r=e.length;t<r;t++){n(e[t],t)}},x=function(e,n){for(var t=[],r=0,o=e.length;r<o;r++){var i=e[r];n(i,r)&&t.push(i)}return t},A=function(e,n,t){return k(e,function(e){t=n(t,e)}),t},E=function(e,n,t){for(var r=0,o=e.length;r<o;r++){var i=e[r];if(n(i,r))return v.some(i);if(t(i,r))break}return v.none()},P=function(e,n){return E(e,n,d)},B=function(e,n){return function(e){for(var n=[],t=0,r=e.length;t<r;++t){if(!C(e[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+e);T.apply(n,e[t])}return n}(D(e,n))},R=function(e){var n=w.call(e,0);return n.reverse(),n},I=function(e){return 0===e.length?v.none():v.some(e[0])},M=function(e){return 0===e.length?v.none():v.some(e[e.length-1])},U=function(){return(U=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},_=function(e,n){var t=function(e,n){for(var t=0;t<e.length;t++){var r=e[t];if(r.test(n))return r}return undefined}(e,n);if(!t)return{major:0,minor:0};var r=function(e){return Number(n.replace(t,"$"+e))};return $(r(1),r(2))},F=function(){return $(0,0)},$=function(e,n){return{major:e,minor:n}},H={nu:$,detect:function(e,n){var t=String(n).toLowerCase();return 0===e.length?F():_(e,t)},unknown:F},j="Edge",q="Chrome",K="Opera",V="Firefox",W="Safari",Q=function(e){var n=e.current,t=e.version,r=function(e){return function(){return n===e}};return{current:n,version:t,isEdge:r(j),isChrome:r(q),isIE:r("IE"),isOpera:r(K),isFirefox:r(V),isSafari:r(W)}},X={unknown:function(){return Q({current:undefined,version:H.unknown()})},nu:Q,edge:y(j),chrome:y(q),ie:y("IE"),opera:y(K),firefox:y(V),safari:y(W)},z="Windows",Y="Android",G="Solaris",J="FreeBSD",Z="ChromeOS",ee=function(e){var n=e.current,t=e.version,r=function(e){return function(){return n===e}};return{current:n,version:t,isWindows:r(z),isiOS:r("iOS"),isAndroid:r(Y),isOSX:r("OSX"),isLinux:r("Linux"),isSolaris:r(G),isFreeBSD:r(J),isChromeOS:r(Z)}},ne={unknown:function(){return ee({current:undefined,version:H.unknown()})},nu:ee,windows:y(z),ios:y("iOS"),android:y(Y),linux:y("Linux"),osx:y("OSX"),solaris:y(G),freebsd:y(J),chromeos:y(Z)},te=function(e,n){var t=String(n).toLowerCase();return P(e,function(e){return e.search(t)})},re=function(e,t){return te(e,t).map(function(e){var n=H.detect(e.versionRegexes,t);return{current:e.name,version:n}})},oe=function(e,t){return te(e,t).map(function(e){var n=H.detect(e.versionRegexes,t);return{current:e.name,version:n}})},ie=function(e,n){return-1!==e.indexOf(n)},ae=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ue=function(n){return function(e){return ie(e,n)}},se=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return ie(e,"edge/")&&ie(e,"chrome")&&ie(e,"safari")&&ie(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ae],search:function(e){return ie(e,"chrome")&&!ie(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return ie(e,"msie")||ie(e,"trident")}},{name:"Opera",versionRegexes:[ae,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ue("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ue("firefox")},{name:"Safari",versionRegexes:[ae,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(ie(e,"safari")||ie(e,"mobile/"))&&ie(e,"applewebkit")}}],ce=[{name:"Windows",search:ue("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return ie(e,"iphone")||ie(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ue("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:ue("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ue("linux"),versionRegexes:[]},{name:"Solaris",search:ue("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ue("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:ue("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],fe={browsers:y(se),oses:y(ce)},de=function(e,n){var t,r,o,i,a,u,s,c,f,d,l,m,p=fe.browsers(),g=fe.oses(),v=re(p,e).fold(X.unknown,X.nu),h=oe(g,e).fold(ne.unknown,ne.nu);return{browser:v,os:h,deviceType:(r=v,o=e,i=n,a=(t=h).isiOS()&&!0===/ipad/i.test(o),u=t.isiOS()&&!a,s=t.isiOS()||t.isAndroid(),c=s||i("(pointer:coarse)"),f=a||!u&&s&&i("(min-device-width:768px)"),d=u||s&&!f,l=r.isSafari()&&t.isiOS()&&!1===/safari/i.test(o),m=!d&&!f&&!l,{isiPad:y(a),isiPhone:y(u),isTablet:y(f),isPhone:y(d),isTouch:y(c),isAndroid:t.isAndroid,isiOS:t.isiOS,isWebView:y(l),isDesktop:y(m)})}},le=function(e){return u.window.matchMedia(e).matches},me=(i=!(r=function(){return de(u.navigator.userAgent,le)}),function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return i||(i=!0,o=r.apply(null,e)),o}),pe=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:y(e)}},ge={fromHtml:function(e,n){var t=(n||u.document).createElement("div");if(t.innerHTML=e,!t.hasChildNodes()||1<t.childNodes.length)throw u.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return pe(t.childNodes[0])},fromTag:function(e,n){var t=(n||u.document).createElement(e);return pe(t)},fromText:function(e,n){var t=(n||u.document).createTextNode(e);return pe(t)},fromDom:pe,fromPoint:function(e,n,t){var r=e.dom();return v.from(r.elementFromPoint(n,t)).map(pe)}},ve=function(e,n){return e.dom()===n.dom()},he=function(e,n){return t=e.dom(),r=n.dom(),o=t,i=r,a=u.Node.DOCUMENT_POSITION_CONTAINED_BY,0!=(o.compareDocumentPosition(i)&a);var t,r,o,i,a},ye=function(e,n){return me().browser.isIE()?he(e,n):(t=n,r=e.dom(),o=t.dom(),r!==o&&r.contains(o));var t,r,o},Se=function(e,n){var t=e.dom();if(1!==t.nodeType)return!1;var r=t;if(r.matches!==undefined)return r.matches(n);if(r.msMatchesSelector!==undefined)return r.msMatchesSelector(n);if(r.webkitMatchesSelector!==undefined)return r.webkitMatchesSelector(n);if(r.mozMatchesSelector!==undefined)return r.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},be=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),Ce=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),Ne=tinymce.util.Tools.resolve("tinymce.util.VK"),Oe=function(e,n,t){return e.isSome()&&n.isSome()?v.some(t(e.getOrDie(),n.getOrDie())):v.none()},Le=("undefined"!=typeof u.window?u.window:Function("return this;")(),function(e){return e.dom().nodeName.toLowerCase()}),we=(a=1,function(e){return e.dom().nodeType===a}),Te=function(e){return v.from(e.dom().parentNode).map(ge.fromDom)},De=function(e){return D(e.dom().childNodes,ge.fromDom)},ke=function(e,n){var t=e.dom().childNodes;return v.from(t[n]).map(ge.fromDom)},xe=function(e){return ke(e,0)},Ae=function(e){return ke(e,e.dom().childNodes.length-1)},Ee=function(n,t){Te(n).each(function(e){e.dom().insertBefore(t.dom(),n.dom())})},Pe=function(e,n){e.dom().appendChild(n.dom())},Be=function(n,e){k(e,function(e){Pe(n,e)})},Re=function(e){var n=e.dom();null!==n.parentNode&&n.parentNode.removeChild(n)},Ie=function(e,n,t){return e.fire("ListMutation",{action:n,element:t})},Me=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),Ue=tinymce.util.Tools.resolve("tinymce.util.Tools"),_e=function(n){return function(e){return e&&e.nodeName.toLowerCase()===n}},Fe=function(n){return function(e){return e&&n.test(e.nodeName)}},$e=function(e){return e&&3===e.nodeType},He=Fe(/^(OL|UL|DL)$/),je=Fe(/^(OL|UL)$/),qe=_e("ol"),Ke=Fe(/^(LI|DT|DD)$/),Ve=Fe(/^(DT|DD)$/),We=Fe(/^(TH|TD)$/),Qe=_e("br"),Xe=function(e,n){return n&&!!e.schema.getTextBlockElements()[n.nodeName]},ze=function(e,n){return e&&e.nodeName in n},Ye=function(e,n,t){var r=e.isEmpty(n);return!(t&&0<e.select("span[data-mce-type=bookmark]",n).length)&&r},Ge=function(e,n){return e.isChildOf(n,e.getRoot())},Je=function(e,n){var t=n||e.selection.getStart(!0);return e.dom.getParent(t,"OL,UL,DL",nn(e,t))},Ze=function(e){var n,t,r,o=Je(e),i=e.selection.getSelectedBlocks();return r=i,(t=o)&&1===r.length&&r[0]===t?(n=o,Ue.grep(n.querySelectorAll("ol,ul,dl"),function(e){return He(e)})):Ue.grep(i,function(e){return He(e)&&o!==e})},en=function(e){var t,n,r,o=e.selection.getSelectedBlocks();return Ue.grep((t=e,n=o,r=Ue.map(n,function(e){var n=t.dom.getParent(e,"li,dd,dt",nn(t,e));return n||e}),Me.unique(r)),function(e){return Ke(e)})},nn=function(e,n){var t=e.dom.getParents(n,"TD,TH");return 0<t.length?t[0]:e.getBody()},tn=function(e,n){var t=e.dom.getParents(n,"ol,ul",nn(e,n));return M(t)},rn=function(e){var n,t,r,o=(t=tn(n=e,n.selection.getStart()),r=x(n.selection.getSelectedBlocks(),je),t.toArray().concat(r));return on(e,o)},on=function(n,e){var t=D(e,function(e){return tn(n,e).getOr(e)});return Me.unique(t)},an=function(e,n){var t,r,o,i,a=e.dom,u=e.schema.getBlockElements(),s=a.createFragment(),c=!1===(t=e.getParam("forced_root_block","p"))?"":!0===t?"p":t;if(c&&((o=a.create(c)).tagName===c.toUpperCase()&&a.setAttribs(o,e.getParam("forced_root_block_attrs",{})),ze(n.firstChild,u)||s.appendChild(o)),n)for(;r=n.firstChild;){var f=r.nodeName;i||"SPAN"===f&&"bookmark"===r.getAttribute("data-mce-type")||(i=!0),ze(r,u)?(s.appendChild(r),o=null):c?(o||(o=a.create(c),s.appendChild(o)),o.appendChild(r)):s.appendChild(r)}return c?i||o.appendChild(a.create("br",{"data-mce-bogus":"1"})):s.appendChild(a.create("br")),s},un=Object.keys,sn=function(e,n){for(var t=un(e),r=0,o=t.length;r<o;r++){var i=t[r];n(e[i],i)}},cn=function(e,n){var t,r,o,i,a={};return t=n,i=a,r=function(e,n){i[n]=e},o=s,sn(e,function(e,n){(t(e,n)?r:o)(e,n)}),a},fn=function(e,n){var t=e.dom();sn(n,function(e,n){!function(e,n,t){if(!(b(t)||N(t)||L(t)))throw u.console.error("Invalid call to Attr.set. Key ",n,":: Value ",t,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(n,t+"")}(t,n,e)})},dn=function(e){return A(e.dom().attributes,function(e,n){return e[n.name]=n.value,e},{})},ln=(O(u.Element.prototype.attachShadow)&&O(u.Node.prototype.getRootNode),function(e,n,t){if(!b(t))throw u.console.error("Invalid call to CSS.set. Property ",n,":: Value ",t,":: Element ",e),new Error("CSS value must be a string: "+t);var r;(r=e).style!==undefined&&O(r.style.getPropertyValue)&&e.style.setProperty(n,t)}),mn=function(e){return n=e,t=!0,ge.fromDom(n.dom().cloneNode(t));var n,t},pn=function(e,n){var t,r,o,i,a=(t=e,r=n,o=ge.fromTag(r),i=dn(t),fn(o,i),o);Ee(e,a);var u=De(e);return Be(a,u),Re(e),a},gn=function(e,n){Pe(e.item,n.list)},vn=function(f,e,d){var n=e.slice(0,d.depth);return M(n).each(function(e){var n,t,r,o,i,a,u,s,c=(n=f,t=d.itemAttributes,r=d.content,o=ge.fromTag("li",n),fn(o,t),Be(o,r),o);a=c,Pe((i=e).list,a),i.item=a,s=d,Le((u=e).list)!==s.listType&&(u.list=pn(u.list,s.listType)),fn(u.list,s.listAttributes)}),n},hn=function(e,n,t){var r,o=function(e,n,t){for(var r,o,i,a=[],u=0;u<t;u++)a.push((r=e,o=n.listType,i={list:ge.fromTag(o,r),item:ge.fromTag("li",r)},Pe(i.list,i.item),i));return a}(e,t,t.depth-n.length);return function(e){for(var n=1;n<e.length;n++)gn(e[n-1],e[n])}(o),function(e,n){for(var t=0;t<e.length-1;t++)r=e[t].item,o="list-style-type",i="none",a=r.dom(),ln(a,o,i);var r,o,i,a;M(e).each(function(e){fn(e.list,n.listAttributes),fn(e.item,n.itemAttributes),Be(e.item,n.content)})}(o,t),r=o,Oe(M(n),I(r),gn),n.concat(o)},yn=function(e){return Se(e,"OL,UL")},Sn=function(e){return xe(e).map(yn).getOr(!1)},bn=function(e){return 0<e.depth},Cn=function(e){return e.isSelected},Nn=function(e){var n=De(e),t=Ae(e).map(yn).getOr(!1)?n.slice(0,-1):n;return D(t,mn)},On=function(u){return k(u,function(r,e){var n,t,o,i,a;o=(n=u)[t=e].depth,i=function(e){return e.depth===o&&!e.dirty},a=function(e){return e.depth<o},E(R(n.slice(0,t)),i,a).orThunk(function(){return E(n.slice(t+1),i,a)}).fold(function(){var e;r.dirty&&((e=r).listAttributes=cn(e.listAttributes,function(e,n){return"start"!==n}))},function(e){return t=e,(n=r).listType=t.listType,void(n.listAttributes=U({},t.listAttributes));var n,t})}),u},Ln=function(i,a,u,s){return xe(s).filter(yn).fold(function(){a.each(function(e){ve(e.start,s)&&u.set(!0)});var n,t,r,e=(n=s,t=i,r=u.get(),Te(n).filter(we).map(function(e){return{depth:t,dirty:!1,isSelected:r,content:Nn(n),itemAttributes:dn(n),listAttributes:dn(e),listType:Le(e)}}));a.each(function(e){ve(e.end,s)&&u.set(!1)});var o=Ae(s).filter(yn).map(function(e){return wn(i,a,u,e)}).getOr([]);return e.toArray().concat(o)},function(e){return wn(i,a,u,e)})},wn=function(n,t,r,e){return B(De(e),function(e){return(yn(e)?wn:Ln)(n+1,t,r,e)})},Tn=function(e,n){var t,r=(t=!1,{get:function(){return t},set:function(e){t=e}});return D(e,function(e){return{sourceList:e,entries:wn(0,n,r,e)}})},Dn=function(i,e){var n=On(e);return D(n,function(e){var n,t,r,o=(n=e.content,r=(t||u.document).createDocumentFragment(),k(n,function(e){r.appendChild(e.dom())}),ge.fromDom(r));return ge.fromDom(an(i,o.dom()))})},kn=function(e,n){var t,r,o=On(n);return t=e.contentDocument,r=A(o,function(e,n){return(n.depth>e.length?hn:vn)(t,e,n)},[]),I(r).map(function(e){return e.list}).toArray()},xn=function(u,e,s){var n,t=Tn(e,(n=D(en(u),ge.fromDom),Oe(P(n,f(Sn)),P(R(n),f(Sn)),function(e,n){return{start:e,end:n}})));k(t,function(e){var n,t;n=e.entries,t=s,k(x(n,Cn),function(e){return function(e,n){switch(e){case"Indent":n.depth++;break;case"Outdent":n.depth--;break;case"Flatten":n.depth=0}n.dirty=!0}(t,e)});var r,o,i,a=(r=u,o=e.entries,B(function(e,n){if(0===e.length)return[];for(var t=n(e[0]),r=[],o=[],i=0,a=e.length;i<a;i++){var u=e[i],s=n(u);s!==t&&(r.push(o),o=[]),t=s,o.push(u)}return 0!==o.length&&r.push(o),r}(o,bn),function(e){return(I(e).map(bn).getOr(!1)?kn:Dn)(r,e)}));k(a,function(e){Ie(u,"Indent"===s?"IndentList":"OutdentList",e.dom())}),i=e.sourceList,k(a,function(e){Ee(i,e)}),Re(e.sourceList)})},An=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),En=An.DOM,Pn=function(n,t){Se(t,"dd")?pn(t,"dt"):Se(t,"dt")&&Te(t).each(function(e){return function(e,n,t){var r=En.select('span[data-mce-type="bookmark"]',n),o=an(e,t),i=En.createRng();i.setStartAfter(t),i.setEndAfter(n);for(var a,u=i.extractContents(),s=u.firstChild;s;s=s.firstChild)if("LI"===s.nodeName&&e.dom.isEmpty(s)){En.remove(s);break}e.dom.isEmpty(u)||En.insertAfter(u,n),En.insertAfter(o,n),Ye(e.dom,t.parentNode)&&(a=t.parentNode,Ue.each(r,function(e){a.parentNode.insertBefore(e,t.parentNode)}),En.remove(a)),En.remove(t),Ye(e.dom,n)&&En.remove(n)}(n,e.dom(),t.dom())})},Bn=function(e){Se(e,"dt")&&pn(e,"dd")},Rn=function(e,n){if($e(e))return{container:e,offset:n};var t=be.getNode(e,n);return $e(t)?{container:t,offset:n>=e.childNodes.length?t.data.length:0}:t.previousSibling&&$e(t.previousSibling)?{container:t.previousSibling,offset:t.previousSibling.data.length}:t.nextSibling&&$e(t.nextSibling)?{container:t.nextSibling,offset:0}:{container:e,offset:n}},In=function(e){var n=e.cloneRange(),t=Rn(e.startContainer,e.startOffset);n.setStart(t.container,t.offset);var r=Rn(e.endContainer,e.endOffset);return n.setEnd(r.container,r.offset),n},Mn=function(e,n){var t,r=D(rn(e),ge.fromDom),o=D(x(en(e),Ve),ge.fromDom),i=!1;if(r.length||o.length){var a=e.selection.getBookmark();xn(e,r,n),t=e,k(o,"Indent"===n?Bn:function(e){return Pn(t,e)}),e.selection.moveToBookmark(a),e.selection.setRng(In(e.selection.getRng())),e.nodeChanged(),i=!0}return i},Un=function(e){return Mn(e,"Indent")},_n=function(e){return Mn(e,"Outdent")},Fn=function(e){return Mn(e,"Flatten")},$n=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),Hn=An.DOM,jn=function(o){var i={},e=function(e){var n,t,r;t=o[e?"startContainer":"endContainer"],r=o[e?"startOffset":"endOffset"],1===t.nodeType&&(n=Hn.create("span",{"data-mce-type":"bookmark"}),t.hasChildNodes()?(r=Math.min(r,t.childNodes.length-1),e?t.insertBefore(n,t.childNodes[r]):Hn.insertAfter(n,t.childNodes[r])):t.appendChild(n),t=n,r=0),i[e?"startContainer":"endContainer"]=t,i[e?"startOffset":"endOffset"]=r};return e(!0),o.collapsed||e(),i},qn=function(o){function e(e){var n,t,r;n=r=o[e?"startContainer":"endContainer"],t=o[e?"startOffset":"endOffset"],n&&(1===n.nodeType&&(t=function(e){for(var n=e.parentNode.firstChild,t=0;n;){if(n===e)return t;1===n.nodeType&&"bookmark"===n.getAttribute("data-mce-type")||t++,n=n.nextSibling}return-1}(n),n=n.parentNode,Hn.remove(r),!n.hasChildNodes()&&Hn.isBlock(n)&&n.appendChild(Hn.create("br"))),o[e?"startContainer":"endContainer"]=n,o[e?"startOffset":"endOffset"]=t)}e(!0),e();var n=Hn.createRng();return n.setStart(o.startContainer,o.startOffset),o.endContainer&&n.setEnd(o.endContainer,o.endOffset),In(n)},Kn=function(e){switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},Vn=function(e){return/\btox\-/.test(e.className)},Wn=function(e,t,r){var n=function(e){var n=E(e.parents,He,We).filter(function(e){return e.nodeName===t&&!Vn(e)}).isSome();r(n)},o=e.dom.getParents(e.selection.getNode());return n({parents:o}),e.on("NodeChange",n),function(){return e.off("NodeChange",n)}},Qn=function(t,e){Ue.each(e,function(e,n){t.setAttribute(n,e)})},Xn=function(e,n,t){var r,o,i,a,u,s,c;r=e,o=n,a=(i=t)["list-style-type"]?i["list-style-type"]:null,r.setStyle(o,"list-style-type",a),u=e,Qn(s=n,(c=t)["list-attributes"]),Ue.each(u.select("li",s),function(e){Qn(e,c["list-item-attributes"])})},zn=function(e,n,t,r){var o=n[t?"startContainer":"endContainer"],i=n[t?"startOffset":"endOffset"];for(1===o.nodeType&&(o=o.childNodes[Math.min(i,o.childNodes.length-1)]||o),!t&&Qe(o.nextSibling)&&(o=o.nextSibling);o.parentNode!==r;){if(Xe(e,o))return o;if(/^(TD|TH)$/.test(o.parentNode.nodeName))return o;o=o.parentNode}return o},Yn=function(f,d,l){void 0===l&&(l={});var e=f.selection.getRng(),m="LI",n=nn(f,f.selection.getStart(!0)),p=f.dom;if("false"!==p.getContentEditable(f.selection.getNode())){"DL"===(d=d.toUpperCase())&&(m="DT");var t=jn(e);Ue.each(function(t,e,r){for(var o,i=[],a=t.dom,n=zn(t,e,!0,r),u=zn(t,e,!1,r),s=[],c=n;c&&(s.push(c),c!==u);c=c.nextSibling);return Ue.each(s,function(e){if(Xe(t,e))return i.push(e),void(o=null);if(a.isBlock(e)||Qe(e))return Qe(e)&&a.remove(e),void(o=null);var n=e.nextSibling;$n.isBookmarkNode(e)&&(Xe(t,n)||!n&&e.parentNode===r)?o=null:(o||(o=a.create("p"),e.parentNode.insertBefore(o,e),i.push(o)),o.appendChild(e))}),i}(f,e,n),function(e){var n,t,r,o,i,a,u,s,c=e.previousSibling;c&&He(c)&&c.nodeName===d&&(t=c,r=l,o=p.getStyle(t,"list-style-type"),i=r?r["list-style-type"]:"",o===(i=null===i?"":i))?(n=c,e=p.rename(e,m),c.appendChild(e)):(n=p.create(d),e.parentNode.insertBefore(n,e),n.appendChild(e),e=p.rename(e,m)),a=p,u=e,s=["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],Ue.each(s,function(e){var n;return a.setStyle(u,((n={})[e]="",n))}),Xn(p,n,l),Jn(f.dom,n)}),f.selection.setRng(qn(t))}},Gn=function(e,n,t){return s=t,(u=n)&&s&&He(u)&&u.nodeName===s.nodeName&&(i=n,a=t,(o=e).getStyle(i,"list-style-type",!0)===o.getStyle(a,"list-style-type",!0))&&(r=t,n.className===r.className);var r,o,i,a,u,s},Jn=function(e,n){var t,r;if(t=n.nextSibling,Gn(e,n,t)){for(;r=t.firstChild;)n.appendChild(r);e.remove(t)}if(t=n.previousSibling,Gn(e,n,t)){for(;r=t.lastChild;)n.insertBefore(r,n.firstChild);e.remove(t)}},Zn=function(n,e,t,r,o){if(e.nodeName!==r||et(o)){var i=jn(n.selection.getRng(!0));Ue.each([e].concat(t),function(e){!function(e,n,t,r){if(n.nodeName!==t){var o=e.dom.rename(n,t);Xn(e.dom,o,r),Ie(e,Kn(t),o)}else Xn(e.dom,n,r),Ie(e,Kn(t),n)}(n,e,r,o)}),n.selection.setRng(qn(i))}else Fn(n)},et=function(e){return"list-style-type"in e},nt=function(e,n,t){var r=Je(e),o=Ze(e);t=t||{},r&&0<o.length?Zn(e,r,o,n,t):function(e,n,t,r){if(n!==e.getBody())if(n)if(n.nodeName!==t||et(r)||Vn(n)){var o=jn(e.selection.getRng(!0));Xn(e.dom,n,r);var i=e.dom.rename(n,t);Jn(e.dom,i),e.selection.setRng(qn(o)),Ie(e,Kn(t),i)}else Fn(e);else Yn(e,t,r),Ie(e,Kn(t),n)}(e,r,n,t)},tt=An.DOM,rt=function(i,e){Ue.each(Ue.grep(i.select("ol,ul",e)),function(e){var n,t,r,o;n=i,"LI"===(o=(t=e).parentNode).nodeName&&o.firstChild===t&&((r=o.previousSibling)&&"LI"===r.nodeName?(r.appendChild(t),Ye(n,o)&&tt.remove(o)):tt.setStyle(o,"listStyleType","none")),He(o)&&(r=o.previousSibling)&&"LI"===r.nodeName&&r.appendChild(t)})},ot=function(e,n,t,r){var o=n.startContainer,i=n.startOffset;if($e(o)&&(t?i<o.data.length:0<i))return o;var a=e.schema.getNonEmptyElements();1===o.nodeType&&(o=be.getNode(o,i));var u,s,c=new Ce(o,r);for(t&&(u=e.dom,Qe(s=o)&&u.isBlock(s.nextSibling)&&!Qe(s.previousSibling)&&c.next());o=c[t?"next":"prev2"]();){if("LI"===o.nodeName&&!o.hasChildNodes())return o;if(a[o.nodeName])return o;if($e(o)&&0<o.data.length)return o}},it=function(e,n){var t=n.childNodes;return 1===t.length&&!He(t[0])&&e.isBlock(t[0])},at=function(e,n,t){var r,o,i,a=it(e,t)?t.firstChild:t;if(it(o=e,i=n)&&o.remove(i.firstChild,!0),!Ye(e,n,!0))for(;r=n.firstChild;)a.appendChild(r)},ut=function(n,e,t){var r,o=e.parentNode;if(Ge(n,e)&&Ge(n,t)){He(t.lastChild)&&(r=t.lastChild),o===t.lastChild&&Qe(o.previousSibling)&&n.remove(o.previousSibling);var i=t.lastChild;i&&Qe(i)&&e.hasChildNodes()&&n.remove(i),Ye(n,t,!0)&&n.$(t).empty(),at(n,e,t),r&&t.appendChild(r);var a=ye(ge.fromDom(t),ge.fromDom(e))?n.getParents(e,He,t):[];n.remove(e),k(a,function(e){Ye(n,e)&&e!==n.getRoot()&&n.remove(e)})}},st=function(e,n,t,r){var o,i,a,u=e.dom;if(u.isEmpty(r))i=t,a=r,(o=e).dom.$(a).empty(),ut(o.dom,i,a),o.selection.setCursorLocation(a);else{var s=jn(n);ut(u,t,r),e.selection.setRng(qn(s))}},ct=function(n,t){var e=n.dom,r=n.selection,o=r.getStart(),i=nn(n,o),a=e.getParent(r.getStart(),"LI",i);if(a){var u=a.parentNode;if(u===n.getBody()&&Ye(e,u))return!0;var s=In(r.getRng()),c=e.getParent(ot(n,s,t,i),"LI",i);if(c&&c!==a)return n.undoManager.transact(function(){var e;t?st(n,s,c,a):(e=a).parentNode.firstChild===e?_n(n):function(e,n,t,r){var o=jn(n);ut(e.dom,t,r);var i=qn(o);e.selection.setRng(i)}(n,s,a,c)}),!0;if(!c&&!t&&0===s.startOffset&&0===s.endOffset)return n.undoManager.transact(function(){Fn(n)}),!0}return!1},ft=function(o,i){var a=o.dom,e=o.selection.getStart(),u=nn(o,e),s=a.getParent(e,a.isBlock,u);if(s&&a.isEmpty(s)){var n=In(o.selection.getRng()),c=a.getParent(ot(o,n,i,u),"LI",u);if(c)return o.undoManager.transact(function(){var e,n,t,r;n=s,t=u,r=(e=a).getParent(n.parentNode,e.isBlock,t),e.remove(n),r&&e.isEmpty(r)&&e.remove(r),Jn(a,c.parentNode),o.selection.select(c,!0),o.selection.collapse(i)}),!0}return!1},dt=function(e,n){return e.selection.isCollapsed()?ct(i=e,a=n)||ft(i,a):(r=(t=e).selection.getStart(),o=nn(t,r),!!(t.dom.getParent(r,"LI,DT,DD",o)||0<en(t).length)&&(t.undoManager.transact(function(){t.execCommand("Delete"),rt(t.dom,t.getBody())}),!0));var t,r,o,i,a},lt=function(t){var r=t.dom,e=Je(t);qe(e)&&t.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:r.getAttrib(e,"start")||"1"},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:function(e){var n=e.getData();t.undoManager.transact(function(){r.setAttrib(Je(t),"start","1"===n.start?"":n.start)}),e.close()}})},mt=function(n,t){return function(){var e=n.dom.getParent(n.selection.getStart(),"UL,OL,DL");return e&&e.nodeName===t}},pt=function(e){var n,t;e.getParam("lists_indent_on_tab",!0)&&(n=e).on("keydown",function(e){e.keyCode!==Ne.TAB||Ne.metaKeyPressed(e)||n.undoManager.transact(function(){(e.shiftKey?_n:Un)(n)&&e.preventDefault()})}),(t=e).on("keydown",function(e){e.keyCode===Ne.BACKSPACE?dt(t,!1)&&e.preventDefault():e.keyCode===Ne.DELETE&&dt(t,!0)&&e.preventDefault()})};!function gt(){c.add("lists",function(e){var t,n,r,o,i,a,u,s;return!1==!(!/(^|[ ,])rtc([, ]|$)/.test(e.getParam("plugins","","string"))||!c.get("rtc"))&&(pt(e),(t=e).on("BeforeExecCommand",function(e){var n=e.command.toLowerCase();"indent"===n?Un(t):"outdent"===n&&_n(t)}),t.addCommand("InsertUnorderedList",function(e,n){nt(t,"UL",n)}),t.addCommand("InsertOrderedList",function(e,n){nt(t,"OL",n)}),t.addCommand("InsertDefinitionList",function(e,n){nt(t,"DL",n)}),t.addCommand("RemoveList",function(){Fn(t)}),t.addCommand("mceListProps",function(){lt(t)}),t.addQueryStateHandler("InsertUnorderedList",mt(t,"UL")),t.addQueryStateHandler("InsertOrderedList",mt(t,"OL")),t.addQueryStateHandler("InsertDefinitionList",mt(t,"DL"))),i=function(e){return function(){return n.execCommand(e)}},r="advlist",o=(n=e).getParam("plugins","","string"),-1===Ue.inArray(o.split(/[ ,]/),r)&&(n.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:i("InsertOrderedList"),onSetup:function(e){return Wn(n,"OL",e.setActive)}}),n.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:i("InsertUnorderedList"),onSetup:function(e){return Wn(n,"UL",e.setActive)}})),u={text:"List properties...",icon:"ordered-list",onAction:function(){return lt(a)},onSetup:function(n){return Wn(a,"OL",function(e){return n.setDisabled(!e)})}},(a=e).ui.registry.addMenuItem("listprops",u),a.ui.registry.addContextMenu("lists",{update:function(e){var n=Je(a,e);return qe(n)?["listprops"]:[]}}),s=e,{backspaceDelete:function(e){dt(s,e)}}})}()}(window);