BookStack/public/libs/tinymce/plugins/lists/plugin.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),n=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),o=tinymce.util.Tools.resolve("tinymce.util.VK"),r=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),i=tinymce.util.Tools.resolve("tinymce.util.Tools"),a=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=function(e){return e&&"BR"===e.nodeName},d=function(e){return e&&3===e.nodeType},l=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},c=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},f=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},u=s,m=function(e){return e.parentNode.firstChild===e},g=function(e){return e.parentNode.lastChild===e},p=function(e,t){return t&&!!e.schema.getTextBlockElements()[t.nodeName]},v=function(e,t){return e&&e.nodeName in t},h=function(e,t){return!!s(t)&&!(!e.isBlock(t.nextSibling)||s(t.previousSibling))},C=function(e,t,n){var o=e.isEmpty(t);return!(n&&e.select("span[data-mce-type=bookmark]",t).length>0)&&o},y=function(e,t){return e.isChildOf(t,e.getRoot())},N=function(e,n){var o=t.getNode(e,n);return c(e)&&d(o)?{container:o,offset:n>=e.childNodes.length?o.data.length:0}:{container:e,offset:n}},L=function(e){var t=e.cloneRange(),n=N(e.startContainer,e.startOffset);t.setStart(n.container,n.offset);var o=N(e.endContainer,e.endOffset);return t.setEnd(o.container,o.offset),t},S=a.DOM,b=function(e){var t={},n=function(n){var o,r,i;r=e[n?"startContainer":"endContainer"],i=e[n?"startOffset":"endOffset"],1===r.nodeType&&(o=S.create("span",{"data-mce-type":"bookmark"}),r.hasChildNodes()?(i=Math.min(i,r.childNodes.length-1),n?r.insertBefore(o,r.childNodes[i]):S.insertAfter(o,r.childNodes[i])):r.appendChild(o),r=o,i=0),t[n?"startContainer":"endContainer"]=r,t[n?"startOffset":"endOffset"]=i};return n(!0),e.collapsed||n(),t},D=function(e){function t(t){var n,o,r;n=r=e[t?"startContainer":"endContainer"],o=e[t?"startOffset":"endOffset"],n&&(1===n.nodeType&&(o=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}(n),n=n.parentNode,S.remove(r),!n.hasChildNodes()&&S.isBlock(n)&&n.appendChild(S.create("br"))),e[t?"startContainer":"endContainer"]=n,e[t?"startOffset":"endOffset"]=o)}t(!0),t();var n=S.createRng();return n.setStart(e.startContainer,e.startOffset),e.endContainer&&n.setEnd(e.endContainer,e.endOffset),L(n)},k=a.DOM,T=function(e,t){var n,o=t.parentNode;"LI"===o.nodeName&&o.firstChild===t&&((n=o.previousSibling)&&"LI"===n.nodeName?(n.appendChild(t),C(e,o)&&k.remove(o)):k.setStyle(o,"listStyleType","none")),l(o)&&(n=o.previousSibling)&&"LI"===n.nodeName&&n.appendChild(t)},I=function(e,t){i.each(i.grep(e.select("ol,ul",t)),function(t){T(e,t)})},B=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),R=function(e){var t=e.selection.getStart(!0);return e.dom.getParent(t,"OL,UL,DL",O(e,t))},O=function(e,t){var n=e.dom.getParents(t,"TD,TH");return n.length>0?n[0]:e.getBody()},E={getParentList:R,getSelectedSubLists:function(e){var t,n,o,r=R(e),a=e.selection.getSelectedBlocks();return o=a,(n=r)&&1===o.length&&o[0]===n?(t=r,i.grep(t.querySelectorAll("ol,ul,dl"),function(e){return l(e)})):i.grep(a,function(e){return l(e)&&r!==e})},getSelectedListItems:function(e){var t,n,o,r=e.selection.getSelectedBlocks();return i.grep((t=e,n=r,o=i.map(n,function(e){var n=t.dom.getParent(e,"li,dd,dt",O(t,e));return n||e}),B.unique(o)),function(e){return c(e)})},getClosestListRootElm:O},A=tinymce.util.Tools.resolve("tinymce.Env"),P=a.DOM,x=function(e,t,n){var o,r,i,a=P.createFragment(),s=e.schema.getBlockElements();if(e.settings.forced_root_block&&(n=n||e.settings.forced_root_block),n&&((r=P.create(n)).tagName===e.settings.forced_root_block&&P.setAttribs(r,e.settings.forced_root_block_attrs),v(t.firstChild,s)||a.appendChild(r)),t)for(;o=t.firstChild;){var d=o.nodeName;i||"SPAN"===d&&"bookmark"===o.getAttribute("data-mce-type")||(i=!0),v(o,s)?(a.appendChild(o),r=null):n?(r||(r=P.create(n),a.appendChild(r)),r.appendC