@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 7.25 kB
JavaScript
module.exports=function(i){var n={};function r(t){if(n[t])return n[t].exports;var e=n[t]={exports:{},id:t,loaded:!1};return i[t].call(e.exports,e,e.exports,r),e.loaded=!0,e.exports}return r.m=i,r.c=n,r.p="",r(0)}({0:function(t,e,i){t.exports=i(1003)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},997:function(t,e){t.exports=require("./formatblock")},1003:function(t,e,i){var n;i(3),i=[i(997)],void 0===(e="function"==typeof(n=function(){var p=window.kendo.jQuery,s=window.kendo,l=s.Class,e=p.extend,u=s.ui.editor,h=u.Dom,o=u.RangeUtils,t=u.EditorUtils,f=u.Command,i=u.ToolTemplate,d=u.FormatTool,c=u.BlockFormatFinder,m=o.textNodes,n=u.EditorUtils.registerTool,a=c.extend({init:function(t){this.tag=t.tag;this.attr=t.attr;this.altAttr=t.altAttr;var e=this.tags=[this.tag=="ul"?"ol":"ul",this.tag];var i=[{tags:e,attr:this.attr}];if(this.altAttr)i.push({tags:e,attr:this.altAttr});c.fn.init.call(this,i)},matchesType:function(t){return h.attrEquals(t,this.attr)||this.altAttr&&h.attrEquals(t,this.altAttr)},isList:function(t){return h.list(t)},isFormatted:function(t){var e=[];var i,n;for(n=0;n<t.length;n++){i=this.findFormat(t[n],this.isList);if(i&&h.name(i)==this.tag&&this.matchesType(i))e.push(i)}if(e.length<1)return false;if(e.length!=t.length)return false;for(n=0;n<e.length;n++){if(e[n].parentNode!=i.parentNode)break;if(e[n]!=i)return false}return true},findSuitable:function(t){var e=this.findFormat(t[0],this.isList);if(e&&h.name(e)==this.tag)return e;return null}}),g=l.extend({init:function(t,e){var i=this;t=p.isPlainObject(t)?t:{tag:t,attr:null};i.tag=t.tag;i.attr=t.attr;i.finder=new a(t);i.unwrapTag=e},isList:function(t){return h.list(t)},immutables:function(){return this.editor&&!!this.editor.options.immutables},wrap:function(t,e){var i=h.create(t.ownerDocument,"li"),n,r,a=this.immutables()?u.Immutables.immutable:p.noop;for(n=0;n<e.length;n++){r=e[n];if(h.is(r,"li")){t.appendChild(r);continue}if(this.isList(r)){while(r.firstChild)t.appendChild(r.firstChild);continue}if(h.is(r,"td")){while(r.firstChild)i.appendChild(r.firstChild);t.appendChild(i);r.appendChild(t);t=t.cloneNode(false);i=i.cloneNode(false);continue}i.appendChild(r);if(h.isBlock(r)){t.appendChild(i);if(!a(r))h.unwrap(r);i=i.cloneNode(false)}}if(i.firstChild)t.appendChild(i)},containsAny:function(t,e){for(var i=0;i<e.length;i++)if(h.isAncestorOrSelf(t,e[i]))return true;return false},suitable:function(t,e){if(t.className=="k-marker"){var i=t.nextSibling;if(i&&h.isBlock(i))return false;i=t.previousSibling;if(i&&h.isBlock(i))return false}return this.containsAny(t,e)||h.isInline(t)||t.nodeType==3},_parentLists:function(t){var e=h.closestEditable(t);return p(t).parentsUntil(e,"ul,ol")},split:function(t){var e=m(t);var i,n,r;if(e.length){i=h.parentOfType(e[0],["li"]);n=h.parentOfType(e[e.length-1],["li"]);t.setStartBefore(i);t.setEndAfter(n);for(var a=0,s=e.length;a<s;a++){var l=this.finder.findFormat(e[a]);if(l){r=this._parentLists(l);if(r.length)o.split(t,r.last()[0],true);else o.split(t,l,true)}}}},merge:function(t,e){var i=e.previousSibling,n;while(i&&(i.className=="k-marker"||i.nodeType==3&&h.isWhitespace(i)))i=i.previousSibling;if(i&&h.name(i)==t&&this.finder.matchesType(i)){while(e.firstChild)i.appendChild(e.firstChild);h.remove(e);e=i}n=e.nextSibling;while(n&&(n.className=="k-marker"||n.nodeType==3&&h.isWhitespace(n)))n=n.nextSibling;if(n&&h.name(n)==t&&this.finder.matchesType(n)){while(e.lastChild)n.insertBefore(e.lastChild,n.firstChild);h.remove(e)}},breakable:function(t){return t!=t.ownerDocument.body&&!/table|tbody|thead|tr|td/.test(h.name(t))&&!t.attributes.contentEditable},findSuitableNode:function(t){var e=this,i=e.finder,n=e.tag,r;r=i.findSuitable(t);if(!r){i=new a({tag:n=="ul"?"ol":"ul"});r=i.findSuitable(t)}if(!r){i=new a({tag:n});r=i.findSuitable(t);r=r&&e.finder.matchesType(r)?null:r}return r},applyOnSection:function(u,e){var t=this.tag;var i=this.attr;var n=h.closestSplittableParent(e);var r=[];var a=this.findSuitableNode(e);var s;if(/table|tbody|thead/.test(h.name(n)))s=p.map(e,function(t){return h.parentOfType(t,["td"])});else{s=h.significantChildNodes(n);if(p.grep(s,h.isBlock).length)s=p.grep(s,function(t){return this.containsAny(t,e)}.bind(this));if(!s.length)s=e}function l(){r.push(this)}for(var o=0;o<s.length;o++){var f=s[o];var d=(!a||!h.isAncestorOrSelf(a,f))&&this.suitable(f,e);if(!d)continue;if(a&&this.isList(f)){p.each(f.children,l);h.remove(f)}else r.push(f)}if(r.length==s.length&&this.breakable(n))r=[n];if(!a){a=h.create(n.ownerDocument,t,i);if(h.isBlock(r[0]))h.mergeAttributes(r[0],a);h.insertBefore(a,r[0])}this.wrap(a,r);while(h.isBom(a.nextSibling))h.remove(a.nextSibling);if(!this.finder.matchesType(a)){a.removeAttribute("type");a.style.listStyleType="";h.mergeAttributes(h.create(n.ownerDocument,t,i),a,true)}if(a&&a.getAttribute("type")==="")a.removeAttribute("type");if(!h.is(a,t))h.changeTag(a,t);this.merge(t,a)},apply:function(t){var e=0,i=[],n,r,a,s,l=t.length,o=this.immutables()?u.Immutables.immutableParent:p.noop;function f(){if(n)i.push({section:n,nodes:r})}for(e=0;e<l;e++){s=o(t[e])||t[e];a=h.closestEditable(s,["td","th","body"]);if(!n||a!=n){f();r=[s];n=a}else r.push(s)}f();for(e=0;e<i.length;e++)this.applyOnSection(i[e].section,i[e].nodes)},unwrap:function(t){var e=t.ownerDocument.createDocumentFragment(),i=this.unwrapTag,n,r,a,s;for(r=t.firstChild;r;r=r.nextSibling){a=h.create(t.ownerDocument,i||"p");while(r.firstChild){s=r.firstChild;if(h.isBlock(s)){if(a.firstChild){e.appendChild(a);a=h.create(t.ownerDocument,i||"p")}e.appendChild(s)}else a.appendChild(s)}if(a.firstChild)e.appendChild(a)}n=this._parentLists(t);if(n[0]){h.insertAfter(e,n.last()[0]);n.last().remove()}else h.insertAfter(e,t);h.remove(t)},remove:function(t){var e;for(var i=0,n=t.length;i<n;i++){e=this.finder.findFormat(t[i]);if(e)this.unwrap(e)}},toggle:function(t){var e=this,i=m(t),n=t.commonAncestorContainer;if(!i.length){t.selectNodeContents(n);i=m(t);if(!i.length){var r=n.ownerDocument.createTextNode("");t.startContainer.appendChild(r);i=[r];t.selectNode(r.parentNode)}}i=h.filterBy(i,h.htmlIndentSpace,true);if(e.finder.isFormatted(i)){e.split(t);e.remove(i)}else e.apply(i)}}),b=f.extend({init:function(t){t.formatter=new g({tag:t.tag,attr:t.attr});f.fn.init.call(this,t)}}),r=d.extend({init:function(t){this.options=t;d.fn.init.call(this,e(t,{finder:new a(t)}))},command:function(t){return new b(e(t,{tag:this.options.tag,attr:this.options.attr}))}});e(u,{ListFormatFinder:a,ListFormatter:g,ListCommand:b,ListTool:r}),n("insertUnorderedList",new r({tag:"ul",attr:{style:{listStyleType:""},type:""},template:new i({template:t.buttonTemplate,title:"Insert unordered list"})})),n("insertOrderedList",new r({tag:"ol",attr:{style:{listStyleType:""},type:""},template:new i({template:t.buttonTemplate,title:"Insert ordered list"})})),n("insertUpperRomanList",new r({tag:"ol",attr:{style:{listStyleType:"upper-roman"}},altAttr:{type:"I"},template:new i({template:t.buttonTemplate,title:"Insert upper roman list"})})),n("insertLowerRomanList",new r({tag:"ol",attr:{style:{listStyleType:"lower-roman"}},altAttr:{type:"i"},template:new i({template:t.buttonTemplate,title:"Insert lower roman list"})}))})?n.apply(e,i):n)||(t.exports=e)}});