UNPKG

@progress/kendo-ui

Version:

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

1 lines 6.72 kB
module.exports=function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}({0:function(t,e,i){t.exports=i(954)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},954:function(t,e,i){var n,a,r;!function(o,define){a=[i(955)],n=o,r="function"==typeof n?n.apply(e,a):n,!(void 0!==r&&(t.exports=r))}(function(){!function(t){var e,i=window.kendo,n=i.Class,a=t.extend,r=i.ui.editor,o=i.ui.Editor.fn.options.formats,s=r.Dom,l=r.ToolTemplate,f=r.FormatTool,m=r.EditorUtils,u=m.registerTool,g=m.registerFormat,d=r.RangeUtils,h=n.extend({init:function(t){this.format=t},contains:function(t,e){var i,n,a;for(i=0,n=e.length;i<n;i++)if(a=e[i],!a||!s.isAncestorOrSelf(t,a))return!1;return!0},findSuitable:function(e){var i,n,a,r,o=this.format,l=[];for(i=0,n=e.length;i<n;i++){for(r=o.length-1;r>=0&&!(a=s.ofType(e[i],o[r].tags)?e[i]:s.closestEditableOfType(e[i],o[r].tags));r--);if(!a||"true"===a.contentEditable)return[];t.inArray(a,l)<0&&l.push(a)}for(this._resolveListsItems(l),i=0,n=l.length;i<n;i++)if(this.contains(l[i],l))return[l[i]];return l},_resolveListsItems:function(t){var e,i,n;for(e=0;e<t.length;e++)i=t[e],n=s.is(i,"li")?i:s.wrapper(i),n=n&&s.list(n)?n.children[0]:n,s.is(n,"li")&&(i=t[e]=n)},findFormat:function(t){var e,i,n,a,o,l,f=this.format,m=s.editableParent(t),u=this.options&&this.options.immutables,g=r.Immutables;for(e=0,i=f.length;e<i;e++){if(n=t,a=f[e].tags,o=f[e].attr,u&&a&&"immutable"==a[0]&&(l=g.immutableParent(n),l&&s.attrEquals(l,o)))return n;for(;n&&s.isAncestorOf(m,n);){if(s.ofType(n,a)&&s.attrEquals(n,o))return n;n=n.parentNode}}return null},getFormat:function(t){var e,i,n=this,a=function(t){return n.findFormat(s.isDataNode(t)?t.parentNode:t)},r=a(t[0]);if(!r)return"";for(e=1,i=t.length;e<i;e++)if(r!=a(t[e]))return"";return r.nodeName.toLowerCase()},isFormatted:function(t){for(var e=0,i=t.length;e<i;e++)if(!this.findFormat(t[e]))return!1;return!0}}),c=n.extend({init:function(t,e){this.format=t,this.values=e,this.finder=new h(t)},wrap:function(t,e,i){var n,a,r,o,l,f=1==i.length?s.blockParentOrBody(i[0]):s.commonAncestor.apply(null,i);for(s.isInline(f)&&(f=s.blockParentOrBody(f)),n=s.significantChildNodes(f),a=s.findNodeIndex(n[0]),r=s.create(f.ownerDocument,t,e),o=0;o<n.length;o++)l=n[o],s.isBlock(l)?(s.attr(l,e),r.childNodes.length&&(s.insertBefore(r,l),r=r.cloneNode(!1)),a=s.findNodeIndex(l)+1):r.appendChild(l);r.firstChild&&s.insertAt(f,r,a)},apply:function(e){function i(t){return a({},t&&t.attr,h)}var n,r,o,l,f,u,g,d,h=this.values;if(this._handleImmutables(e,!0),r=s.filter("img",e),o=m.formatByName("img",this.format),l=i(o),t.each(r,function(){s.attr(this,l)}),r.length!=e.length)if(f=s.filter("img",e,!0),u=this.finder.findSuitable(f),u.length)for(g=0,d=u.length;g<d;g++)n=m.formatByName(s.name(u[g]),this.format),s.attr(u[g],i(n));else n=this.format[0],this.wrap(n.tags[0],i(n),f)},_handleImmutables:function(t,e){var i,n,a,o,l;if(this.immutables()&&(i=m.formatByName("immutable",this.format)))for(n=r.Immutables,a=t.length-1,o=a;o>=0;o--)l=n.immutableParent(t[o]),l&&(l!==t[o+1]&&(e?s.attr(l,i.attr):s.unstyle(l,i.attr.style)),t.splice(o,1))},immutables:function(){return this.editor&&this.editor.options.immutables},remove:function(t){var e,i,n,a,r;for(this._handleImmutables(t,!1),e=0,i=t.length;e<i;e++)n=this.finder.findFormat(t[e]),n&&(r=s.name(n),a=m.formatByName(r,this.format),a.attr.style&&s.unstyle(n,a.attr.style),a.attr.className&&s.removeClass(n,a.attr.className))},toggle:function(t){var e=this,i=s.filterBy(d.nodes(t),s.htmlIndentSpace,!0);e.finder.isFormatted(i)?e.remove(i):e.apply(i)}}),y=n.extend({init:function(t,e){var i=this;i.format=t,i.values=e,i.finder=new h(t)},apply:function(t){var e,i,n,a,o,l,f,m,u,g,d=this.format,h=s.blockParents(t),y=d[0].tags[0];if(h.length)for(e=0,i=h.length;e<i;e++)m=h[e],u=this.immutables()&&r.Immutables.immutableParent(m),u||(f=s.name(m),"li"==f?(n=m.parentNode,a=new r.ListFormatter(n.nodeName.toLowerCase(),y),o=this.editor.createRange(),o.selectNode(h[e]),a.toggle(o)):y&&("td"==f||m.attributes.contentEditable)?new c(d,this.values).apply(m.childNodes):(l=s.changeTag(m,y),s.attr(l,d[0].attr)));else g=new c(d,this.values),g.editor=this.editor,g.apply(t)},toggle:function(t){var e=d.textNodes(t);e.length||(t.selectNodeContents(t.commonAncestorContainer),e=d.textNodes(t),e.length||(e=s.significantChildNodes(t.commonAncestorContainer))),this.apply(e)},immutables:function(){return this.editor&&this.editor.options.immutables}}),p=f.extend({init:function(t){f.fn.init.call(this,a(t,{finder:new h(t.format),formatter:function(){return new c(t.format)}}))}});a(r,{BlockFormatFinder:h,BlockFormatter:c,GreedyBlockFormatter:y,BlockFormatTool:p}),e=["ul","ol","li"],g("justifyLeft",[{tags:s.nonListBlockElements,attr:{style:{textAlign:"left"}}},{tags:["img"],attr:{style:{"float":"left",display:"",marginLeft:"",marginRight:""}}},{tags:["immutable"],attr:{style:{"float":"left",display:"",marginLeft:"",marginRight:""}}},{tags:e,attr:{style:{textAlign:"left",listStylePosition:""}}}]),u("justifyLeft",new p({format:o.justifyLeft,template:new l({template:m.buttonTemplate,title:"Justify Left"})})),g("justifyCenter",[{tags:s.nonListBlockElements,attr:{style:{textAlign:"center"}}},{tags:["img"],attr:{style:{display:"block",marginLeft:"auto",marginRight:"auto","float":""}}},{tags:["immutable"],attr:{style:{display:"block",marginLeft:"auto",marginRight:"auto","float":""}}},{tags:e,attr:{style:{textAlign:"center",listStylePosition:"inside"}}}]),u("justifyCenter",new p({format:o.justifyCenter,template:new l({template:m.buttonTemplate,title:"Justify Center"})})),g("justifyRight",[{tags:s.nonListBlockElements,attr:{style:{textAlign:"right"}}},{tags:["img"],attr:{style:{"float":"right",display:"",marginLeft:"",marginRight:""}}},{tags:["immutable"],attr:{style:{"float":"right",display:"",marginLeft:"",marginRight:""}}},{tags:e,attr:{style:{textAlign:"right",listStylePosition:"inside"}}}]),u("justifyRight",new p({format:o.justifyRight,template:new l({template:m.buttonTemplate,title:"Justify Right"})})),g("justifyFull",[{tags:s.nonListBlockElements,attr:{style:{textAlign:"justify"}}},{tags:["img"],attr:{style:{display:"block",marginLeft:"auto",marginRight:"auto","float":""}}},{tags:["immutable"],attr:{style:{display:"block",marginLeft:"auto",marginRight:"auto","float":""}}},{tags:e,attr:{style:{textAlign:"justify",listStylePosition:""}}}]),u("justifyFull",new p({format:o.justifyFull,template:new l({template:m.buttonTemplate,title:"Justify Full"})}))}(window.kendo.jQuery)},i(3))},955:function(t,e){t.exports=require("./format")}});