11 lines
27 KiB
JavaScript
11 lines
27 KiB
JavaScript
/**
|
|
* 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.5 (2019-05-09)
|
|
*/
|
|
|
|
!function(u){"use strict";var e,n,t,r,o,i,a,s,c=tinymce.util.Tools.resolve("tinymce.PluginManager"),f=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),d=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),l=tinymce.util.Tools.resolve("tinymce.util.VK"),p=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),m=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),g=function(e){return e&&"BR"===e.nodeName},h=function(e){return e&&3===e.nodeType},y=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},N=function(e){return e&&/^(OL|UL)$/.test(e.nodeName)},S=function(e){return e&&/^(DT|DD)$/.test(e.nodeName)},O=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},C=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},b=g,T=function(e,n){return n&&!!e.schema.getTextBlockElements()[n.nodeName]},L=function(e,n){return e&&e.nodeName in n},D=function(e,n){return!!g(n)&&!(!e.isBlock(n.nextSibling)||g(n.previousSibling))},E=function(e,n,t){var r=e.isEmpty(n);return!(t&&0<e.select("span[data-mce-type=bookmark]",n).length)&&r},w=function(e,n){return e.isChildOf(n,e.getRoot())},k=function(e,n){if(h(e))return{container:e,offset:n};var t=f.getNode(e,n);return h(t)?{container:t,offset:n>=e.childNodes.length?t.data.length:0}:t.previousSibling&&h(t.previousSibling)?{container:t.previousSibling,offset:t.previousSibling.data.length}:t.nextSibling&&h(t.nextSibling)?{container:t.nextSibling,offset:0}:{container:e,offset:n}},A=function(e){var n=e.cloneRange(),t=k(e.startContainer,e.startOffset);n.setStart(t.container,t.offset);var r=k(e.endContainer,e.endOffset);return n.setEnd(r.container,r.offset),n},x=m.DOM,R=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=x.create("span",{"data-mce-type":"bookmark"}),t.hasChildNodes()?(r=Math.min(r,t.childNodes.length-1),e?t.insertBefore(n,t.childNodes[r]):x.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},I=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,x.remove(r),!n.hasChildNodes()&&x.isBlock(n)&&n.appendChild(x.create("br"))),o[e?"startContainer":"endContainer"]=n,o[e?"startOffset":"endOffset"]=t)}e(!0),e();var n=x.createRng();return n.setStart(o.startContainer,o.startOffset),o.endContainer&&n.setEnd(o.endContainer,o.endOffset),A(n)},_=function(e){return function(){return e}},B=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return!t.apply(null,e)}},P=_(!1),M=_(!0),U=P,F=M,j=function(){return H},H=(r={fold:function(e,n){return e()},is:U,isSome:U,isNone:F,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:function(){return null},getOrUndefined:function(){return undefined},or:t,orThunk:n,map:j,ap:j,each:function(){},bind:j,flatten:j,exists:U,forall:F,filter:j,equals:e=function(e){return e.isNone()},equals_:e,toArray:function(){return[]},toString:_("none()")},Object.freeze&&Object.freeze(r),r),$=function(t){var e=function(){return 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:F,isNone:U,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return $(e(t))},ap:function(e){return e.fold(j,function(e){return $(e(t))})},each:function(e){e(t)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(t)?o:H},equals:function(e){return e.is(t)},equals_:function(e,n){return e.fold(U,function(e){return n(t,e)})},toArray:function(){return[t]},toString:function(){return"some("+t+")"}};return o},q={some:$,none:j,from:function(e){return null===e||e===undefined?H:$(e)}},W=function(n){return function(e){return function(e){if(null===e)return"null";var n=typeof e;return"object"===n&&Array.prototype.isPrototypeOf(e)?"array":"object"===n&&String.prototype.isPrototypeOf(e)?"string":n}(e)===n}},z=W("string"),K=W("boolean"),V=W("function"),X=W("number"),Q=(Array.prototype.indexOf,undefined,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,e)}return r}),Y=function(e,n){for(var t=0,r=e.length;t<r;t++)n(e[t],t,e)},G=function(e,n){for(var t=[],r=0,o=e.length;r<o;r++){var i=e[r];n(i,r,e)&&t.push(i)}return t},J=function(e,n){if(0===e.length)return[];for(var t=n(e[0]),r=[],o=[],i=0,u=e.length;i<u;i++){var a=e[i],s=n(a);s!==t&&(r.push(o),o=[]),t=s,o.push(a)}return 0!==o.length&&r.push(o),r},Z=function(e,n,t){return Y(e,function(e){t=n(t,e)}),t},ee=function(e,n){for(var t=0,r=e.length;t<r;t++){var o=e[t];if(n(o,t,e))return q.some(o)}return q.none()},ne=Array.prototype.push,te=function(e){for(var n=[],t=0,r=e.length;t<r;++t){if(!Array.prototype.isPrototypeOf(e[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+e);ne.apply(n,e[t])}return n},re=function(e,n){var t=Q(e,n);return te(t)},oe=Array.prototype.slice,ie=function(e){var n=oe.call(e,0);return n.reverse(),n},ue=function(e){return 0===e.length?q.none():q.some(e[0])},ae=function(e){return 0===e.length?q.none():q.some(e[e.length-1])},se=(V(Array.from)&&Array.from,"undefined"!=typeof u.window?u.window:Function("return this;")()),ce=function(e,n){return function(e,n){for(var t=n!==undefined&&null!==n?n:se,r=0;r<e.length&&t!==undefined&&null!==t;++r)t=t[e[r]];return t}(e.split("."),n)},fe=function(e,n){var t=ce(e,n);if(t===undefined||null===t)throw e+" not available on this browser";return t},de=function(e){var n,t=ce("ownerDocument.defaultView",e);return(n=t,fe("HTMLElement",n)).prototype.isPrototypeOf(e)},le=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),me=function(e){var n=e.selection.getStart(!0);return e.dom.getParent(n,"OL,UL,DL",pe(e,n))},ge=function(e){var t,n,r,o=e.selection.getSelectedBlocks();return v.grep((t=e,n=o,r=v.map(n,function(e){var n=t.dom.getParent(e,"li,dd,dt",pe(t,e));return n||e}),le.unique(r)),function(e){return O(e)})},pe=function(e,n){var t=e.dom.getParents(n,"TD,TH");return 0<t.length?t[0]:e.getBody()},ve=function(e,n){var t=e.dom.getParents(n,"ol,ul",pe(e,n));return ae(t)},he=function(n,e){var t=Q(e,function(e){return ve(n,e).getOr(e)});return le.unique(t)},ye={isList:function(e){var n=me(e);return de(n)},getParentList:me,getSelectedSubLists:function(e){var n,t,r,o=me(e),i=e.selection.getSelectedBlocks();return r=i,(t=o)&&1===r.length&&r[0]===t?(n=o,v.grep(n.querySelectorAll("ol,ul,dl"),function(e){return y(e)})):v.grep(i,function(e){return y(e)&&o!==e})},getSelectedListItems:ge,getClosestListRootElm:pe,getSelectedDlItems:function(e){return G(ge(e),S)},getSelectedListRoots:function(e){var n,t,r,o=(t=ve(n=e,n.selection.getStart()),r=G(n.selection.getSelectedBlocks(),N),t.toArray().concat(r));return he(e,o)}},Ne=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:_(e)}},Se={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 Ne(t.childNodes[0])},fromTag:function(e,n){var t=(n||u.document).createElement(e);return Ne(t)},fromText:function(e,n){var t=(n||u.document).createTextNode(e);return Ne(t)},fromDom:Ne,fromPoint:function(e,n,t){var r=e.dom();return q.from(r.elementFromPoint(n,t)).map(Ne)}},Oe=function(e,n){for(var t=[],r=0;r<e.length;r++){var o=e[r];if(!o.isSome())return q.none();t.push(o.getOrDie())}return q.some(n.apply(null,t))},Ce=Object.keys,be=function(){return fe("Node")},Te=function(e,n,t){return 0!=(e.compareDocumentPosition(n)&t)},Le=function(e,n){return Te(e,n,be().DOCUMENT_POSITION_CONTAINED_BY)},De=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 we(r(1),r(2))},Ee=function(){return we(0,0)},we=function(e,n){return{major:e,minor:n}},ke={nu:we,detect:function(e,n){var t=String(n).toLowerCase();return 0===e.length?Ee():De(e,t)},unknown:Ee},Ae="Firefox",xe=function(e,n){return function(){return n===e}},Re=function(e){var n=e.current;return{current:n,version:e.version,isEdge:xe("Edge",n),isChrome:xe("Chrome",n),isIE:xe("IE",n),isOpera:xe("Opera",n),isFirefox:xe(Ae,n),isSafari:xe("Safari",n)}},Ie={unknown:function(){return Re({current:undefined,version:ke.unknown()})},nu:Re,edge:_("Edge"),chrome:_("Chrome"),ie:_("IE"),opera:_("Opera"),firefox:_(Ae),safari:_("Safari")},_e="Windows",Be="Android",Pe="Solaris",Me="FreeBSD",Ue=function(e,n){return function(){return n===e}},Fe=function(e){var n=e.current;return{current:n,version:e.version,isWindows:Ue(_e,n),isiOS:Ue("iOS",n),isAndroid:Ue(Be,n),isOSX:Ue("OSX",n),isLinux:Ue("Linux",n),isSolaris:Ue(Pe,n),isFreeBSD:Ue(Me,n)}},je={unknown:function(){return Fe({current:undefined,version:ke.unknown()})},nu:Fe,windows:_(_e),ios:_("iOS"),android:_(Be),linux:_("Linux"),osx:_("OSX"),solaris:_(Pe),freebsd:_(Me)},He=function(e,n){var t=String(n).toLowerCase();return ee(e,function(e){return e.search(t)})},$e=function(e,t){return He(e,t).map(function(e){var n=ke.detect(e.versionRegexes,t);return{current:e.name,version:n}})},qe=function(e,t){return He(e,t).map(function(e){var n=ke.detect(e.versionRegexes,t);return{current:e.name,version:n}})},We=function(e,n){return-1!==e.indexOf(n)},ze=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Ke=function(n){return function(e){return We(e,n)}},Ve=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return We(e,"edge/")&&We(e,"chrome")&&We(e,"safari")&&We(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ze],search:function(e){return We(e,"chrome")&&!We(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return We(e,"msie")||We(e,"trident")}},{name:"Opera",versionRegexes:[ze,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Ke("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Ke("firefox")},{name:"Safari",versionRegexes:[ze,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(We(e,"safari")||We(e,"mobile/"))&&We(e,"applewebkit")}}],Xe=[{name:"Windows",search:Ke("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return We(e,"iphone")||We(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Ke("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:Ke("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Ke("linux"),versionRegexes:[]},{name:"Solaris",search:Ke("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Ke("freebsd"),versionRegexes:[]}],Qe={browsers:_(Ve),oses:_(Xe)},Ye=function(e){var n,t,r,o,i,u,a,s,c,f,d,l=Qe.browsers(),m=Qe.oses(),g=$e(l,e).fold(Ie.unknown,Ie.nu),p=qe(m,e).fold(je.unknown,je.nu);return{browser:g,os:p,deviceType:(t=g,r=e,o=(n=p).isiOS()&&!0===/ipad/i.test(r),i=n.isiOS()&&!o,u=n.isAndroid()&&3===n.version.major,a=n.isAndroid()&&4===n.version.major,s=o||u||a&&!0===/mobile/i.test(r),c=n.isiOS()||n.isAndroid(),f=c&&!s,d=t.isSafari()&&n.isiOS()&&!1===/safari/i.test(r),{isiPad:_(o),isiPhone:_(i),isTablet:_(s),isPhone:_(f),isTouch:_(c),isAndroid:n.isAndroid,isiOS:n.isiOS,isWebView:_(d)})}},Ge={detect:(o=function(){var e=u.navigator.userAgent;return Ye(e)},a=!1,function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return a||(a=!0,i=o.apply(null,e)),i})},Je=(u.Node.ATTRIBUTE_NODE,u.Node.CDATA_SECTION_NODE,u.Node.COMMENT_NODE,u.Node.DOCUMENT_NODE,u.Node.DOCUMENT_TYPE_NODE,u.Node.DOCUMENT_FRAGMENT_NODE,u.Node.ELEMENT_NODE),Ze=(u.Node.TEXT_NODE,u.Node.PROCESSING_INSTRUCTION_NODE,u.Node.ENTITY_REFERENCE_NODE,u.Node.ENTITY_NODE,u.Node.NOTATION_NODE,Je),en=function(e,n){return e.dom()===n.dom()},nn=Ge.detect().browser.isIE()?function(e,n){return Le(e.dom(),n.dom())}:function(e,n){var t=e.dom(),r=n.dom();return t!==r&&t.contains(r)},tn=function(e,n){var t=e.dom();if(t.nodeType!==Ze)return!1;if(t.matches!==undefined)return t.matches(n);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(n);if(t.webkitMatchesSelector!==undefined)return t.webkitMatchesSelector(n);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},rn=function(e){var n=e.dom();return q.from(n.parentNode).map(Se.fromDom)},on=function(e){var n=e.dom();return Q(n.childNodes,Se.fromDom)},un=function(e,n){var t=e.dom().childNodes;return q.from(t[n]).map(Se.fromDom)},an=function(e){return un(e,0)},sn=function(e){return un(e,e.dom().childNodes.length-1)},cn=(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n]}("element","offset"),function(n,t){rn(n).each(function(e){e.dom().insertBefore(t.dom(),n.dom())})}),fn=function(e,n){e.dom().appendChild(n.dom())},dn=function(n,e){Y(e,function(e){fn(n,e)})},ln=function(e){var n=e.dom();null!==n.parentNode&&n.parentNode.removeChild(n)},mn=function(e){return e.dom().nodeName.toLowerCase()},gn=function(e,n){var t=e.dom();!function(e,n){for(var t=Ce(e),r=0,o=t.length;r<o;r++){var i=t[r];n(e[i],i,e)}}(n,function(e,n){!function(e,n,t){if(!(z(t)||K(t)||X(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)})},pn=function(e){return Z(e.dom().attributes,function(e,n){return e[n.name]=n.value,e},{})},vn=function(e,n,t){if(!z(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);e.style!==undefined&&e.style.setProperty(n,t)},hn=function(e){return n=e,t=!0,Se.fromDom(n.dom().cloneNode(t));var n,t},yn=function(e,n){var t,r,o,i,u=(t=e,r=n,o=Se.fromTag(r),i=pn(t),gn(o,i),o);cn(e,u);var a=on(e);return dn(u,a),ln(e),u},Nn=function(e,n){fn(e.item,n.list)},Sn=function(f,e,d){var n=e.slice(0,d.depth);return ae(n).each(function(e){var n,t,r,o,i,u,a,s,c=(n=f,t=d.itemAttributes,r=d.content,o=Se.fromTag("li",n),gn(o,t),dn(o,r),o);u=c,fn((i=e).list,u),i.item=u,s=d,mn((a=e).list)!==s.listType&&(a.list=yn(a.list,s.listType)),gn(a.list,s.listAttributes)}),n},On=function(e,n,t){var r,o=function(e,n,t){for(var r,o,i,u=[],a=0;a<t;a++)u.push((r=e,o=n.listType,i={list:Se.fromTag(o,r),item:Se.fromTag("li",r)},fn(i.list,i.item),i));return u}(e,t,t.depth-n.length);return function(e){for(var n=1;n<e.length;n++)Nn(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",u=r.dom(),vn(u,o,i);var r,o,i,u;ae(e).each(function(e){gn(e.list,n.listAttributes),gn(e.item,n.itemAttributes),dn(e.item,n.content)})}(o,t),r=o,Oe([ae(n),ue(r)],Nn),n.concat(o)},Cn=function(e){return tn(e,"OL,UL")},bn=function(e){return an(e).map(Cn).getOr(!1)},Tn=function(e){return 0<e.depth},Ln=function(e){return e.isSelected},Dn=function(e){var n=on(e),t=sn(e).map(Cn).getOr(!1)?n.slice(0,-1):n;return Q(t,hn)},En=Object.prototype.hasOwnProperty,wn=(s=function(e,n){return n},function(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Can't merge zero objects");for(var t={},r=0;r<e.length;r++){var o=e[r];for(var i in o)En.call(o,i)&&(t[i]=s(t[i],o[i]))}return t}),kn=function(n){Y(n,function(r,e){(function(e,n){for(var t=e[n].depth,r=n-1;0<=r;r--){if(e[r].depth===t)return q.some(e[r]);if(e[r].depth<t)break}return q.none()})(n,e).each(function(e){var n,t;t=e,(n=r).listType=t.listType,n.listAttributes=wn({},t.listAttributes)})})},An=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return An(t())}}},xn=function(i,u,a,s){return an(s).filter(Cn).fold(function(){u.each(function(e){en(e.start,s)&&a.set(!0)});var n,t,r,e=(n=s,t=i,r=a.get(),rn(n).map(function(e){return{depth:t,isSelected:r,content:Dn(n),itemAttributes:pn(n),listAttributes:pn(e),listType:mn(e)}}));u.each(function(e){en(e.end,s)&&a.set(!1)});var o=sn(s).filter(Cn).map(function(e){return Rn(i,u,a,e)}).getOr([]);return e.toArray().concat(o)},function(e){return Rn(i,u,a,e)})},Rn=function(n,t,r,e){return re(on(e),function(e){return(Cn(e)?Rn:xn)(n+1,t,r,e)})},In=tinymce.util.Tools.resolve("tinymce.Env"),_n=function(e,n){var t,r,o,i,u=e.dom,a=e.schema.getBlockElements(),s=u.createFragment();if(e.settings.forced_root_block&&(o=e.settings.forced_root_block),o&&((r=u.create(o)).tagName===e.settings.forced_root_block&&u.setAttribs(r,e.settings.forced_root_block_attrs),L(n.firstChild,a)||s.appendChild(r)),n)for(;t=n.firstChild;){var c=t.nodeName;i||"SPAN"===c&&"bookmark"===t.getAttribute("data-mce-type")||(i=!0),L(t,a)?(s.appendChild(t),r=null):o?(r||(r=u.create(o),s.appendChild(r)),r.appendChild(t)):s.appendChild(t)}return e.settings.forced_root_block?i||In.ie&&!(10<In.ie)||r.appendChild(u.create("br",{"data-mce-bogus":"1"})):s.appendChild(u.create("br")),s},Bn=function(e,n,t){return e.fire("ListMutation",{action:n,element:t})},Pn=function(i,e){return Q(e,function(e){var n,t,r,o=(n=e.content,r=(t||u.document).createDocumentFragment(),Y(n,function(e){r.appendChild(e.dom())}),Se.fromDom(r));return Se.fromDom(_n(i,o.dom()))})},Mn=function(e,n){return kn(n),(t=e.contentDocument,r=n,o=Z(r,function(e,n){return n.depth>e.length?On(t,e,n):Sn(t,e,n)},[]),ue(o).map(function(e){return e.list})).toArray();var t,r,o},Un=function(a,e,s){var n,t,r,o,i,u=(n=e,o=a,i=Q(ye.getSelectedListItems(o),Se.fromDom),t=Oe([ee(i,B(bn)),ee(ie(i),B(bn))],function(e,n){return{start:e,end:n}}),r=An(!1),Q(n,function(e){return{sourceList:e,entries:Rn(0,t,r,e)}}));Y(u,function(e){var n,t;n=e.entries,t=s,Y(G(n,Ln),function(e){return function(e,n){switch(e){case"Indent":n.depth++;break;case"Outdent":n.depth--;break;case"Flatten":n.depth=0}}(t,e)});var r,o,i,u=(r=a,o=e.entries,re(J(o,Tn),function(e){return ue(e).map(Tn).getOr(!1)?Mn(r,e):Pn(r,e)}));Y(u,function(e){Bn(a,"Indent"===s?"IndentList":"OutdentList",e.dom())}),i=e.sourceList,Y(u,function(e){cn(i,e)}),ln(e.sourceList)})},Fn=m.DOM,jn=function(e,n,t){var r,o,i,u,a,s;for(i=Fn.select('span[data-mce-type="bookmark"]',n),a=_n(e,t),(r=Fn.createRng()).setStartAfter(t),r.setEndAfter(n),u=(o=r.extractContents()).firstChild;u;u=u.firstChild)if("LI"===u.nodeName&&e.dom.isEmpty(u)){Fn.remove(u);break}e.dom.isEmpty(o)||Fn.insertAfter(o,n),Fn.insertAfter(a,n),E(e.dom,t.parentNode)&&(s=t.parentNode,v.each(i,function(e){s.parentNode.insertBefore(e,t.parentNode)}),Fn.remove(s)),Fn.remove(t),E(e.dom,n)&&Fn.remove(n)},Hn=function(e){tn(e,"DT")&&yn(e,"DD")},$n=function(r,e,n){Y(n,"Indent"===e?Hn:function(e){return n=r,void(tn(t=e,"DD")?yn(t,"DT"):tn(t,"DT")&&rn(t).each(function(e){return jn(n,e.dom(),t.dom())}));var n,t})},qn=function(e,n){var t=Q(ye.getSelectedListRoots(e),Se.fromDom),r=Q(ye.getSelectedDlItems(e),Se.fromDom),o=!1;if(t.length||r.length){var i=e.selection.getBookmark();Un(e,t,n),$n(e,n,r),e.selection.moveToBookmark(i),e.selection.setRng(A(e.selection.getRng())),e.nodeChanged(),o=!0}return o},Wn=function(e){return qn(e,"Indent")},zn=function(e){return qn(e,"Outdent")},Kn=function(e){return qn(e,"Flatten")},Vn=function(e){return/\btox\-/.test(e.className)},Xn=function(e){switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},Qn=function(t,e){v.each(e,function(e,n){t.setAttribute(n,e)})},Yn=function(e,n,t){var r,o,i,u,a,s,c;r=e,o=n,u=(i=t)["list-style-type"]?i["list-style-type"]:null,r.setStyle(o,"list-style-type",u),a=e,Qn(s=n,(c=t)["list-attributes"]),v.each(a.select("li",s),function(e){Qn(e,c["list-item-attributes"])})},Gn=function(e,n,t,r){var o,i;for(o=n[t?"startContainer":"endContainer"],i=n[t?"startOffset":"endOffset"],1===o.nodeType&&(o=o.childNodes[Math.min(i,o.childNodes.length-1)]||o),!t&&b(o.nextSibling)&&(o=o.nextSibling);o.parentNode!==r;){if(T(e,o))return o;if(/^(TD|TH)$/.test(o.parentNode.nodeName))return o;o=o.parentNode}return o},Jn=function(f,d,l){void 0===l&&(l={});var e,n=f.selection.getRng(!0),m="LI",t=ye.getClosestListRootElm(f,f.selection.getStart(!0)),g=f.dom;"false"!==g.getContentEditable(f.selection.getNode())&&("DL"===(d=d.toUpperCase())&&(m="DT"),e=R(n),v.each(function(t,e,r){for(var o,i=[],u=t.dom,n=Gn(t,e,!0,r),a=Gn(t,e,!1,r),s=[],c=n;c&&(s.push(c),c!==a);c=c.nextSibling);return v.each(s,function(e){if(T(t,e))return i.push(e),void(o=null);if(u.isBlock(e)||b(e))return b(e)&&u.remove(e),void(o=null);var n=e.nextSibling;p.isBookmarkNode(e)&&(T(t,n)||!n&&e.parentNode===r)?o=null:(o||(o=u.create("p"),e.parentNode.insertBefore(o,e),i.push(o)),o.appendChild(e))}),i}(f,n,t),function(e){var n,t,r,o,i,u,a,s,c;(t=e.previousSibling)&&y(t)&&t.nodeName===d&&(r=t,o=l,i=g.getStyle(r,"list-style-type"),u=o?o["list-style-type"]:"",i===(u=null===u?"":u))?(n=t,e=g.rename(e,m),t.appendChild(e)):(n=g.create(d),e.parentNode.insertBefore(n,e),n.appendChild(e),e=g.rename(e,m)),a=g,s=e,c=["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],v.each(c,function(e){var n;return a.setStyle(s,((n={})[e]="",n))}),Yn(g,n,l),et(f.dom,n)}),f.selection.setRng(I(e)))},Zn=function(e,n,t){return s=t,(a=n)&&s&&y(a)&&a.nodeName===s.nodeName&&(i=n,u=t,(o=e).getStyle(i,"list-style-type",!0)===o.getStyle(u,"list-style-type",!0))&&(r=t,n.className===r.className);var r,o,i,u,a,s},et=function(e,n){var t,r;if(t=n.nextSibling,Zn(e,n,t)){for(;r=t.firstChild;)n.appendChild(r);e.remove(t)}if(t=n.previousSibling,Zn(e,n,t)){for(;r=t.lastChild;)n.insertBefore(r,n.firstChild);e.remove(t)}},nt=function(n,e,t,r,o){if(e.nodeName!==r||tt(o)){var i=R(n.selection.getRng(!0));v.each([e].concat(t),function(e){!function(e,n,t,r){if(n.nodeName!==t){var o=e.dom.rename(n,t);Yn(e.dom,o,r),Bn(e,Xn(t),o)}else Yn(e.dom,n,r),Bn(e,Xn(t),n)}(n,e,r,o)}),n.selection.setRng(I(i))}else Kn(n)},tt=function(e){return"list-style-type"in e},rt={toggleList:function(e,n,t){var r=ye.getParentList(e),o=ye.getSelectedSubLists(e);t=t||{},r&&0<o.length?nt(e,r,o,n,t):function(e,n,t,r){if(n!==e.getBody())if(n)if(n.nodeName!==t||tt(r)||Vn(n)){var o=R(e.selection.getRng(!0));Yn(e.dom,n,r);var i=e.dom.rename(n,t);et(e.dom,i),e.selection.setRng(I(o)),Bn(e,Xn(t),i)}else Kn(e);else Jn(e,t,r),Bn(e,Xn(t),n)}(e,r,n,t)},mergeWithAdjacentLists:et},ot=m.DOM,it=function(e,n){var t,r=n.parentNode;"LI"===r.nodeName&&r.firstChild===n&&((t=r.previousSibling)&&"LI"===t.nodeName?(t.appendChild(n),E(e,r)&&ot.remove(r)):ot.setStyle(r,"listStyleType","none")),y(r)&&(t=r.previousSibling)&&"LI"===t.nodeName&&t.appendChild(n)},ut=function(n,e){v.each(v.grep(n.select("ol,ul",e)),function(e){it(n,e)})},at=function(e,n,t,r){var o=n.startContainer,i=n.startOffset;if(3===o.nodeType&&(t?i<o.data.length:0<i))return o;var u=e.schema.getNonEmptyElements();1===o.nodeType&&(o=f.getNode(o,i));var a=new d(o,r);for(t&&D(e.dom,o)&&a.next();o=a[t?"next":"prev2"]();){if("LI"===o.nodeName&&!o.hasChildNodes())return o;if(u[o.nodeName])return o;if(3===o.nodeType&&0<o.data.length)return o}},st=function(e,n){var t=n.childNodes;return 1===t.length&&!y(t[0])&&e.isBlock(t[0])},ct=function(e,n,t){var r,o,i,u;if(o=st(e,t)?t.firstChild:t,st(i=e,u=n)&&i.remove(u.firstChild,!0),!E(e,n,!0))for(;r=n.firstChild;)o.appendChild(r)},ft=function(n,e,t){var r,o,i=e.parentNode;if(w(n,e)&&w(n,t)){y(t.lastChild)&&(o=t.lastChild),i===t.lastChild&&b(i.previousSibling)&&n.remove(i.previousSibling),(r=t.lastChild)&&b(r)&&e.hasChildNodes()&&n.remove(r),E(n,t,!0)&&n.$(t).empty(),ct(n,e,t),o&&t.appendChild(o);var u=nn(Se.fromDom(t),Se.fromDom(e))?n.getParents(e,y,t):[];n.remove(e),Y(u,function(e){E(n,e)&&e!==n.getRoot()&&n.remove(e)})}},dt=function(e,n,t,r){var o,i,u,a=e.dom;if(a.isEmpty(r))i=t,u=r,(o=e).dom.$(u).empty(),ft(o.dom,i,u),o.selection.setCursorLocation(u);else{var s=R(n);ft(a,t,r),e.selection.setRng(I(s))}},lt=function(e,n){var t,r,o,i=e.dom,u=e.selection,a=u.getStart(),s=ye.getClosestListRootElm(e,a),c=i.getParent(u.getStart(),"LI",s);if(c){if((t=c.parentNode)===e.getBody()&&E(i,t))return!0;if(r=A(u.getRng(!0)),(o=i.getParent(at(e,r,n,s),"LI",s))&&o!==c)return n?dt(e,r,o,c):function(e,n,t,r){var o=R(n);ft(e.dom,t,r);var i=I(o);e.selection.setRng(i)}(e,r,c,o),!0;if(!o&&!n)return Kn(e),!0}return!1},mt=function(e,n){return lt(e,n)||function(o,i){var u=o.dom,e=o.selection.getStart(),a=ye.getClosestListRootElm(o,e),s=u.getParent(e,u.isBlock,a);if(s&&u.isEmpty(s)){var n=A(o.selection.getRng(!0)),c=u.getParent(at(o,n,i,a),"LI",a);if(c)return o.undoManager.transact(function(){var e,n,t,r;n=s,t=a,r=(e=u).getParent(n.parentNode,e.isBlock,t),e.remove(n),r&&e.isEmpty(r)&&e.remove(r),rt.mergeWithAdjacentLists(u,c.parentNode),o.selection.select(c,!0),o.selection.collapse(i)}),!0}return!1}(e,n)},gt=function(e,n){return e.selection.isCollapsed()?mt(e,n):(r=(t=e).selection.getStart(),o=ye.getClosestListRootElm(t,r),!!(t.dom.getParent(r,"LI,DT,DD",o)||0<ye.getSelectedListItems(t).length)&&(t.undoManager.transact(function(){t.execCommand("Delete"),ut(t.dom,t.getBody())}),!0));var t,r,o},pt=function(n){n.on("keydown",function(e){e.keyCode===l.BACKSPACE?gt(n,!1)&&e.preventDefault():e.keyCode===l.DELETE&>(n,!0)&&e.preventDefault()})},vt=gt,ht=function(n){return{backspaceDelete:function(e){vt(n,e)}}},yt=function(n,t){return function(){var e=n.dom.getParent(n.selection.getStart(),"UL,OL,DL");return e&&e.nodeName===t}},Nt=function(t){t.on("BeforeExecCommand",function(e){var n=e.command.toLowerCase();"indent"===n?Wn(t):"outdent"===n&&zn(t)}),t.addCommand("InsertUnorderedList",function(e,n){rt.toggleList(t,"UL",n)}),t.addCommand("InsertOrderedList",function(e,n){rt.toggleList(t,"OL",n)}),t.addCommand("InsertDefinitionList",function(e,n){rt.toggleList(t,"DL",n)}),t.addCommand("RemoveList",function(){Kn(t)}),t.addQueryStateHandler("InsertUnorderedList",yt(t,"UL")),t.addQueryStateHandler("InsertOrderedList",yt(t,"OL")),t.addQueryStateHandler("InsertDefinitionList",yt(t,"DL"))},St=function(e){return e.getParam("lists_indent_on_tab",!0)},Ot=function(e){var n;St(e)&&(n=e).on("keydown",function(e){e.keyCode!==l.TAB||l.metaKeyPressed(e)||n.undoManager.transact(function(){(e.shiftKey?zn(n):Wn(n))&&e.preventDefault()})}),pt(e)},Ct=function(n,i){return function(o){var e=function(e){var n=function(e,n){for(var t=0;t<e.length;t++)if(n(e[t]))return t;return-1}(e.parents,C),t=-1!==n?e.parents.slice(0,n):e.parents,r=v.grep(t,y);o.setActive(0<r.length&&r[0].nodeName===i&&!Vn(r[0]))};return n.on("NodeChange",e),function(){return n.off("NodeChange",e)}}},bt=function(n){var e,t,r,o=function(e){return function(){return n.execCommand(e)}};t="advlist",r=(e=n).settings.plugins?e.settings.plugins:"",-1===v.inArray(r.split(/[ ,]/),t)&&(n.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:o("InsertOrderedList"),onSetup:Ct(n,"OL")}),n.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:o("InsertUnorderedList"),onSetup:Ct(n,"UL")}))};c.add("lists",function(e){return Ot(e),bt(e),Nt(e),ht(e)}),function Tt(){}}(window);
|