UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

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