2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e[f]=d(a[f]);b.apply(null,e)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};h("6",tinymce.util.Tools.resolve),g("1",["6"],function(a){return a("tinymce.PluginManager")}),g("g",["6"],function(a){return a("tinymce.dom.RangeUtils")}),g("h",["6"],function(a){return a("tinymce.dom.TreeWalker")}),g("b",["6"],function(a){return a("tinymce.util.VK")}),g("i",["6"],function(a){return a("tinymce.dom.BookmarkManager")}),g("d",["6"],function(a){return a("tinymce.util.Tools")}),g("j",["6"],function(a){return a("tinymce.dom.DOMUtils")}),g("e",[],function(){var a=function(a){return a&&3===a.nodeType},b=function(a){return a&&/^(OL|UL|DL)$/.test(a.nodeName)},c=function(a){return a&&/^(LI|DT|DD)$/.test(a.nodeName)},d=function(a){return a&&/^(TH|TD)$/.test(a.nodeName)},e=function(a){return a&&"BR"===a.nodeName},f=function(a){return a.parentNode.firstChild===a},g=function(a){return a.parentNode.lastChild===a},h=function(a,b){return b&&!!a.schema.getTextBlockElements()[b.nodeName]},i=function(a,b){return a&&a.nodeName in b},j=function(a,b){return!!e(b)&&!(!a.isBlock(b.nextSibling)||e(b.previousSibling))},k=function(a,b,c){var d=a.isEmpty(b);return!(c&&a.select("span[data-mce-type=bookmark]",b).length>0)&&d},l=function(a,b){return a.isChildOf(b,a.getRoot())};return{isTextNode:a,isListNode:b,isListItemNode:c,isTableCellNode:d,isBr:e,isFirstChild:f,isLastChild:g,isTextBlock:h,isBlock:i,isBogusBr:j,isEmpty:k,isChildOfBody:l}}),g("p",["g","e"],function(a,b){var c=function(c,d){var e=a.getNode(c,d);if(b.isListItemNode(c)&&b.isTextNode(e)){var f=d>=c.childNodes.length?e.data.length:0;return{container:e,offset:f}}return{container:c,offset:d}},d=function(a){var b=a.cloneRange(),d=c(a.startContainer,a.startOffset);b.setStart(d.container,d.offset);var e=c(a.endContainer,a.endOffset);return b.setEnd(e.container,e.offset),b};return{getNormalizedEndPoint:c,normalizeRange:d}}),g("k",["j","e","p"],function(a,b,c){var d=a.DOM,e=function(a){var b={},c=function(c){var e,f,g;f=a[c?"startContainer":"endContainer"],g=a[c?"startOffset":"endOffset"],1===f.nodeType&&(e=d.create("span",{"data-mce-type":"bookmark"}),f.hasChildNodes()?(g=Math.min(g,f.childNodes.length-1),c?f.insertBefore(e,f.childNodes[g]):d.insertAfter(e,f.childNodes[g])):f.appendChild(e),f=e,g=0),b[c?"startContainer":"endContainer"]=f,b[c?"startOffset":"endOffset"]=g};return c(!0),a.collapsed||c(),b},f=function(a){function b(b){var c,e,f,g=function(a){for(var b=a.parentNode.firstChild,c=0;b;){if(b===a)return c;1===b.nodeType&&"bookmark"===b.getAttribute("data-mce-type")||c++,b=b.nextSibling}return-1};c=f=a[b?"startContainer":"endContainer"],e=a[b?"startOffset":"endOffset"],c&&(1===c.nodeType&&(e=g(c),c=c.parentNode,d.remove(f),!c.hasChildNodes()&&d.isBlock(c)&&c.appendChild(d.create("br"))),a[b?"startContainer":"endContainer"]=c,a[b?"startOffset":"endOffset"]=e)}b(!0),b();var e=d.createRng();return e.setStart(a.startContainer,a.startOffset),a.endContainer&&e.setEnd(a.endContainer,a.endOffset),c.normalizeRange(e)};return{createBookmark:e,resolveBookmark:f}}),g("l",["j","d","e"],function(a,b,c){var d=a.DOM,e=function(a,b){var e,f=b.parentNode;"LI"===f.nodeName&&f.firstChild===b&&(e=f.previousSibling,e&&"LI"===e.nodeName?(e.appendChild(b),c.isEmpty(a,f)&&d.remove(f)):d.setStyle(f,"listStyleType","none")),c.isListNode(f)&&(e=f.previousSibling,e&&"LI"===e.nodeName&&e.appendChild(b))},f=function(a,c){b.each(b.grep(a.select("ol,ul",c)),function(b){e(a,b)})};return{normalizeList:e,normalizeLists:f}}),g("m",["6"],function(a){return a("tinymce.dom.DomQuery")}),g("f",["m","d","e"],function(a,b,c){var d=function(a){var b=a.selection.getStart(!0);return a.dom.getParent(b,"OL,UL,DL",j(a,b))},e=function(a,b){return a&&1===b.length&&b[0]===a},f=function(a){return b.grep(a.querySelectorAll("ol,ul,dl"),function(a){return c.isListNode(a)})},g=function(a){var g=d(a),h=a.selection.getSelectedBlocks();return e(g,h)?f(g):b.grep(h,function(a){return c.isListNode(a)&&g!==a})},h=function(c,d){var e=b.map(d,function(a){var b=c.dom.getParent(a,"li,dd,dt",j(c,a));return b?b:a});return a.unique(e)},i=function(a){var d=a.selection.getSelectedBlocks();return b.grep(h(a,d),function(a){return c.isListItemNode(a)})},j=function(a,b){var c=a.dom.getParents(b,"TD,TH"),d=c.length>0?c[0]:a.getBody();return d};return{getParentList:d,getSelectedSubLists:g,getSelectedListItems:i,getClosestListRootElm:j}}),g("q",["6"],function(a){return a("tinymce.Env")}),g("o",["j","q","e"],function(a,b,c){var d=a.DOM,e=function(a,e,f){var g,h,i,j=d.createFragment(),k=a.schema.getBlockElements();if(a.settings.forced_root_block&&(f=f||a.settings.forced_root_block),f&&(h=d.create(f),h.tagName===a.settings.forced_root_block&&d.setAttribs(h,a.settings.forced_root_block_attrs),c.isBlock(e.firstChild,k)||j.appendChild(h)),e)for(;g=e.firstChild;){var l=g.nodeName;i||"SPAN"===l&&"bookmark"===g.getAttribute("data-mce-type")||(i=!0),c.isBlock(g,k)?(j.appendChild(g),h=null):f?(h||(h=d.create(f),j.appendChild(h)),h.appendChild(g)):j.appendChild(g)}return a.settings.forced_root_block?i||b.ie&&!(b.ie>10)||h.appendChild(d.create("br",{"data-mce-bogus":"1"})):j.appendChild(d.create("br")),j};return{createNewTextBlock:e}}),g("n",["j","e","o","d"],function(a,b,c,d){var e=a.DOM,f=function(a,f,g,h){var i,j,k,l,m=function(a){d.each(k,function(b){a.parentNode.insertBefore(b,g.parentNode)}),e.remove(a)};for(k=e.select('span[data-mce-type="bookmark"]',f),h=h||c.createNewTextBlock(a,g),i=e.createRng(),i.setStartAfter(g),i.setEndAfter(f),j=i.extractContents(),l=j.firstChild;l;l=l.firstChild)if("LI"===l.nodeName&&a.dom.isEmpty(l)){e.remove(l);break}a.dom.isEmpty(j)||e.insertAfter(j,f),e.insertAfter(h,f),b.isEmpty(a.dom,g.parentNode)&&m(g.parentNode),e.remove(g),b.isEmpty(a.dom,f)&&e.remove(f)};return{splitList:f}}),g("9",["j","k","e","l","f","n","o"],function(a,b,c,d,e,f,g){var h=a.DOM,i=function(a,b){c.isEmpty(a,b)&&h.remove(b)},j=function(a,b){var e,j=b.parentNode,k=j.parentNode;return j===a.getBody()||("DD"===b.nodeName?(h.rename(b,"DT"),!0):c.isFirstChild(b)&&c.isLastChild(b)?("LI"===k.nodeName?(h.insertAfter(b,k),i(a.dom,k),h.remove(j)):c.isListNode(k)?h.remove(j,!0):(k.insertBefore(g.createNewTextBlock(a,b),j),h.remove(j)),!0):c.isFirstChild(b)?("LI"===k.nodeName?(h.insertAfter(b,k),b.appendChild(j),i(a.dom,k)):c.isListNode(k)?k.insertBefore(b,j):(k.insertBefore(g.createNewTextBlock(a,b),j),h.remove(b)),!0):c.isLastChild(b)?("LI"===k.nodeName?h.insertAfter(b,k):c.isListNode(k)?h.insertAfter(b,j):(h.insertAfter(g.createNewTextBlock(a,b),j),h.remove(b)),!0):("LI"===k.nodeName?(j=k,e=g.createNewTextBlock(a,b,"LI")):e=c.isListNode(k)?g.createNewTextBlock(a,b,"LI"):g.createNewTextBlock(a,b),f.splitList(a,j,b,e),d.normalizeLists(a.dom,j.parentNode),!0))},k=function(a){var c=e.getSelectedListItems(a);if(c.length){var d,f,g=b.createBookmark(a.selection.getRng(!0)),h=e.getClosestListRootElm(a,a.selection.getStart(!0));for(d=c.length;d--;)for(var i=c[d].parentNode;i&&i!==h;){for(f=c.length;f--;)if(c[f]===i){c.splice(d,1);break}i=i.parentNode}for(d=0;d<c.length&&(j(a,c[d])||0!==d);d++);return a.selection.setRng(b.resolveBookmark(g)),a.nodeChanged(),!0}};return{outdent:j,outdentSelection:k}}),g("a",["i","d","9","k","e","l","f","n"],function(a,b,c,d,e,f,g,h){var i=function(a,b,c){var d=c["list-style-type"]?c["list-style-type"]:null;a.setStyle(b,"list-style-type",d)},j=function(a,c){b.each(c,function(b,c){a.setAttribute(c,b)})},k=function(a,c,d){j(c,d["list-attributes"]),b.each(a.select("li",c),function(a){j(a,d["list-item-attributes"])})},l=function(a,b,c){i(a,b,c),k(a,b,c)},m=function(a,b,c,d){var f,g;for(f=b[c?"startContainer":"endContainer"],g=b[c?"startOffset":"endOffset"],1===f.nodeType&&(f=f.childNodes[Math.min(g,f.childNodes.length-1)]||f),!c&&e.isBr(f.nextSibling)&&(f=f.nextSibling);f.parentNode!==d;){if(e.isTextBlock(a,f))return f;if(/^(TD|TH)$/.test(f.parentNode.nodeName))return f;f=f.parentNode}return f},n=function(c,d,f){for(var g,h=[],i=c.dom,j=m(c,d,!0,f),k=m(c,d,!1,f),l=[],n=j;n&&(l.push(n),n!==k);n=n.nextSibling);return b.each(l,function(b){if(e.isTextBlock(c,b))return h.push(b),void(g=null);if(i.isBlock(b)||e.isBr(b))return e.isBr(b)&&i.remove(b),void(g=null);var d=b.nextSibling;return a.isBookmarkNode(b)&&(e.isTextBlock(c,d)||!d&&b.parentNode===f)?void(g=null):(g||(g=i.create("p"),b.parentNode.insertBefore(g,b),h.push(g)),void g.appendChild(b))}),h},o=function(a,b,c){var d=a.getStyle(b,"list-style-type"),e=c?c["list-style-type"]:"";return e=null===e?"":e,d===e},p=function(a,c,f){var h,i=a.selection.getRng(!0),j="LI",k=g.getClosestListRootElm(a,a.selection.getStart(!0)),m=a.dom;f=f?f:{},"false"!==m.getContentEditable(a.selection.getNode())&&(c=c.toUpperCase(),"DL"===c&&(j="DT"),h=d.createBookmark(i),b.each(n(a,i,k),function(b){var d,g;g=b.previousSibling,g&&e.isListNode(g)&&g.nodeName===c&&o(m,g,f)?(d=g,b=m.rename(b,j),g.appendChild(b)):(d=m.create(c),b.parentNode.insertBefore(d,b),d.appendChild(b),b=m.rename(b,j)),l(m,d,f),v(a.dom,d)}),a.selection.setRng(d.resolveBookmark(h)))},q=function(a){var i=d.createBookmark(a.selection.getRng(!0)),j=g.getClosestListRootElm(a,a.selection.getStart(!0)),k=g.getSelectedListItems(a),l=b.grep(k,function(b){return a.dom.isEmpty(b)});k=b.grep(k,function(b){return!a.dom.isEmpty(b)}),b.each(l,function(b){if(e.isEmpty(a.dom,b))return void c.outdent(a,b)}),b.each(k,function(b){var c,d;if(b.parentNode!==a.getBody()){for(c=b;c&&c!==j;c=c.parentNode)e.isListNode(c)&&(d=c);h.splitList(a,d,b),f.normalizeLists(a.dom,d.parentNode)}}),a.selection.setRng(d.resolveBookmark(i))},r=function(a,b){return a&&b&&e.isListNode(a)&&a.nodeName===b.nodeName},s=function(a,b,c){var d=a.getStyle(b,"list-style-type",!0),e=a.getStyle(c,"list-style-type",!0);return d===e},t=function(a,b){return a.className===b.className},u=function(a,b,c){return r(b,c)&&s(a,b,c)&&t(b,c)},v=function(a,b){var c,d;if(c=b.nextSibling,u(a,b,c)){for(;d=c.firstChild;)b.appendChild(d);a.remove(c)}if(c=b.previousSibling,u(a,b,c)){for(;d=c.lastChild;)b.insertBefore(d,b.firstChild);a.remove(c)}},w=function(a,b,c,d){if(b.nodeName!==c){var e=a.rename(b,c);l(a,e,d)}else l(a,b,d)},x=function(a,c,e,f,g){if(c.nodeName!==f||y(g)){var h=d.createBookmark(a.selection.getRng(!0));b.each([c].concat(e),function(b){w(a.dom,b,f,g)}),a.selection.setRng(d.resolveBookmark(h))}else q(a,f)},y=function(a){return"list-style-type"in a},z=function(a,b,c,e){if(b!==a.getBody())if(b)if(b.nodeName!==c||y(e)){var f=d.createBookmark(a.selection.getRng(!0));l(a.dom,b,e),v(a.dom,a.dom.rename(b,c)),a.selection.setRng(d.resolveBookmark(f))}else q(a,c);else p(a,c,e)},A=function(a,b,c){var d=g.getParentList(a),e=g.getSelectedSubLists(a);c=c?c:{},d&&e.length>0?x(a,d,e,b,c):z(a,d,b,c)};return{toggleList:A,removeList:q,mergeWithAdjacentLists:v}}),g("7",["g","h","b","a","k","e","l","p","f"],function(a,b,c,d,e,f,g,h,i){var j=function(c,d,e,g){var h,i,j=d.startContainer,k=d.startOffset;if(3===j.nodeType&&(e?k<j.data.length:k>0))return j;for(h=c.schema.getNonEmptyElements(),1===j.nodeType&&(j=a.getNode(j,k)),i=new b(j,g),e&&f.isBogusBr(c.dom,j)&&i.next();j=i[e?"next":"prev2"]();){if("LI"===j.nodeName&&!j.hasChildNodes())return j;if(h[j.nodeName])return j;if(3===j.nodeType&&j.data.length>0)return j}},k=function(a,b){var c=b.childNodes;return 1===c.length&&!f.isListNode(c[0])&&a.isBlock(c[0])},l=function(a,b){k(a,b)&&a.remove(b.firstChild,!0)},m=function(a,b,c){var d,e;if(e=k(a,c)?c.firstChild:c,l(a,b),!f.isEmpty(a,b,!0))for(;d=b.firstChild;)e.appendChild(d)},n=function(a,b,c){var d,e,g=b.parentNode;f.isChildOfBody(a,b)&&f.isChildOfBody(a,c)&&(f.isListNode(c.lastChild)&&(e=c.lastChild),g===c.lastChild&&f.isBr(g.previousSibling)&&a.remove(g.previousSibling),d=c.lastChild,d&&f.isBr(d)&&b.hasChildNodes()&&a.remove(d),f.isEmpty(a,c,!0)&&a.$(c).empty(),m(a,b,c),e&&c.appendChild(e),a.remove(b),f.isEmpty(a,g)&&g!==a.getRoot()&&a.remove(g))},o=function(a,b,c){a.dom.$(c).empty(),n(a.dom,b,c),a.selection.setCursorLocation(c)},p=function(a,b,c,d){var f=a.dom;if(f.isEmpty(d))o(a,c,d);else{var g=e.createBookmark(b);n(f,c,d),a.selection.setRng(e.resolveBookmark(g))}},q=function(a,b,c,d){var f=e.createBookmark(b);n(a.dom,c,d);var g=e.resolveBookmark(f);a.selection.setRng(g)},r=function(a,b){var c,e,g,k=a.dom,l=a.selection,m=l.getStart(),n=i.getClosestListRootElm(a,m),o=k.getParent(l.getStart(),"LI",n);if(o){if(c=o.parentNode,c===a.getBody()&&f.isEmpty(k,c))return!0;if(e=h.normalizeRange(l.getRng(!0)),g=k.getParent(j(a,e,b,n),"LI",n),g&&g!==o)return b?p(a,e,g,o):q(a,e,o,g),!0;if(!g&&!b&&d.removeList(a,c.nodeName))return!0}return!1},s=function(a,b,c){var d=a.getParent(b.parentNode,a.isBlock,c);a.remove(b),d&&a.isEmpty(d)&&a.remove(d)},t=function(a,b){var c=a.dom,e=a.selection.getStart(),f=i.getClosestListRootElm(a,e),g=c.getParent(e,c.isBlock,f);if(g&&c.isEmpty(g)){var k=h.normalizeRange(a.selection.getRng(!0)),l=c.getParent(j(a,k,b,f),"LI",f);if(l)return a.undoManager.transact(function(){s(c,g,f),d.mergeWithAdjacentLists(c,l.parentNode),a.selection.select(l,!0),a.selection.collapse(b)}),!0}return!1},u=function(a,b){return r(a,b)||t(a,b)},v=function(a){var b=a.selection.getStart(),c=i.getClosestListRootElm(a,b),d=a.dom.getParent(b,"LI,DT,DD",c);return!!(d||i.getSelectedListItems(a).length>0)&&(a.undoManager.transact(function(){a.execCommand("Delete"),g.normalizeLists(a.dom,a.getBody())}),!0)},w=function(a,b){return a.selection.isCollapsed()?u(a,b):v(a)},x=function(a){a.on("keydown",function(b){b.keyCode===c.BACKSPACE?w(a,!1)&&b.preventDefault():b.keyCode===c.DELETE&&w(a,!0)&&b.preventDefault()})};return{setup:x,backspaceDelete:w}}),g("2",["7"],function(a){var b=function(b){return{backspaceDelete:function(c){a.backspaceDelete(b,c)}}};return{get:b}}),g("8",["j","k","e","f"],function(a,b,c,d){var e=a.DOM,f=function(a,b){var d;if(c.isListNode(a)){for(;d=a.firstChild;)b.appendChild(d);e.remove(a)}},g=function(a){var b,d,g;return"DT"===a.nodeName?(e.rename(a,"DD"),!0):(b=a.previousSibling,b&&c.isListNode(b)?(b.appendChild(a),!0):b&&"LI"===b.nodeName&&c.isListNode(b.lastChild)?(b.lastChild.appendChild(a),f(a.lastChild,b.lastChild),!0):(b=a.nextSibling,b&&c.isListNode(b)?(b.insertBefore(a,b.firstChild),!0):(b=a.previousSibling,!(!b||"LI"!==b.nodeName)&&(d=e.create(a.parentNode.nodeName),g=e.getStyle(a.parentNode,"listStyleType"),g&&e.setStyle(d,"listStyleType",g),b.appendChild(d),d.appendChild(a),f(a.lastChild,d),!0))))},h=function(a){var c=d.getSelectedListItems(a);if(c.length){for(var e=b.createBookmark(a.selection.getRng(!0)),f=0;f<c.length&&(g(c[f])||0!==f);f++);return a.selection.setRng(b.resolveBookmark(e)),a.nodeChanged(),!0}};return{indentSelection:h}}),g("3",["8","9","a"],function(a,b,c){var d=function(a,b){return function(){var c=a.dom.getParent(a.selection.getStart(),"UL,OL,DL");return c&&c.nodeName===b}},e=function(e){e.on("BeforeExecCommand",function(c){var d,f=c.command.toLowerCase();if("indent"===f?a.indentSelection(e)&&(d=!0):"outdent"===f&&b.outdentSelection(e)&&(d=!0),d)return e.fire("ExecCommand",{command:c.command}),c.preventDefault(),!0}),e.addCommand("InsertUnorderedList",function(a,b){c.toggleList(e,"UL",b)}),e.addCommand("InsertOrderedList",function(a,b){c.toggleList(e,"OL",b)}),e.addCommand("InsertDefinitionList",function(a,b){c.toggleList(e,"DL",b)}),e.addQueryStateHandler("InsertUnorderedList",d(e,"UL")),e.addQueryStateHandler("InsertOrderedList",d(e,"OL")),e.addQueryStateHandler("InsertDefinitionList",d(e,"DL"))};return{register:e}}),g("c",[],function(){var a=function(a){return a.getParam("lists_indent_on_tab",!0)};return{shouldIndentOnTab:a}}),g("4",["b","8","9","c","7"],function(a,b,c,d,e){var f=function(d){d.on("keydown",function(e){e.keyCode!==a.TAB||a.metaKeyPressed(e)||d.dom.getParent(d.selection.getStart(),"LI,DT,DD")&&(e.preventDefault(),e.shiftKey?c.outdentSelection(d):b.indentSelection(d))})},g=function(a){d.shouldIndentOnTab(a)&&f(a),e.setup(a)};return{setup:g}}),g("5",["d","e","f"],function(a,b,c){var d=function(a,b){for(var c=0;c<a.length;c++){var d=a[c];if(b(d))return c}return-1},e=function(c,e){return function(f){var g=f.control;c.on("NodeChange",function(c){var f=d(c.parents,b.isTableCellNode),h=f!==-1?c.parents.slice(0,f):c.parents,i=a.grep(h,b.isListNode);g.active(i.length>0&&i[0].nodeName===e)})}},f=function(a){return function(d){var e=d.control;a.on("nodechange",function(){var d=c.getSelectedListItems(a),f=d.length>0&&b.isFirstChild(d[0]);e.disabled(f)})}},g=function(b){var c=function(b,c){var d=b.settings.plugins?b.settings.plugins:"";return a.inArray(d.split(/[ ,]/),c)!==-1};c(b,"advlist")||(b.addButton("numlist",{active:!1,title:"Numbered list",cmd:"InsertOrderedList",onPostRender:e(b,"OL")}),b.addButton("bullist",{active:!1,title:"Bullet list",cmd:"InsertUnorderedList",onPostRender:e(b,"UL")})),b.addButton("indent",{icon:"indent",title:"Increase indent",cmd:"Indent",onPostRender:f(b)})};return{register:g}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return a.add("lists",function(a){return d.setup(a),e.register(a),c.register(a),b.get(a)}),function(){}}),d("0")()}();
|