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