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