@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 4.73 kB
JavaScript
module.exports=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){e.exports=n(981)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},971:function(e,t){e.exports=require("../command")},981:function(e,t,n){var i,r,o;!function(l,define){r=[n(971)],i=l,o="function"==typeof i?i.apply(t,r):i,!(void 0!==o&&(e.exports=o))}(function(){!function(e){var t=window.kendo,n=t.ui.editor,i=n.Tool,r=n.Command,o=n.ToolTemplate,l=n.EditorUtils,a=n.Dom,s=n.RangeUtils,c=l.registerTool,p=r.extend({init:function(e){r.fn.init.call(this,e)},exec:function(){var e=this.lockRange(!0);this.inlineStyles=[],this.blockStyles=[],this.collectStyles(e),this.editor.inlineStyles=this.inlineStyles,this.editor.blockStyles=this.blockStyles,this.releaseRange(e)},collectStyles:function(e){var t,n=s.nodes(e);for(t=1===n.length?n[0].parentNode:e.startContainer;t&&!a.is(t,"body")&&"editor"!==t.getAttribute("data-role");)a.isBlock(t)?(this.populateStyles(t,"blockStyles"),t=a.is(t,"li")?t.parentNode:null):(this.populateStyles(t,"inlineStyles"),t=t.parentNode)},populateStyles:function(e,t){var n,i,r,o,l,a=e.style,s=e.attributes,c={tags:[e.tagName],attr:{style:{}}};for(l=0;a&&l<a.length;l++)i=a[l],n=a[i],c.attr.style[i]=n;for(l=0;s&&l<s.length;l++)r=s[l].nodeName,o=s[l].nodeValue,"style"!==r&&("class"===r?c.attr.className=o:c.attr[r]=o);this[t].push(c)}}),h=r.extend({init:function(e){r.fn.init.call(this,e)},exec:function(){var e,t=this.lockRange(!0),n=s.getMarkers(t),i=this.editor,r=i.inlineStyles,o=i.blockStyles;(r&&0!==r.length||o&&0!==o.length)&&(3===n.length&&(this.marker.removeCaret(t),this.marker.caret=null),this.removeEmptyElementsFromRange(t),e=s.nodes(t),this.cleanInlineParents(e),a.normalize(t.commonAncestorContainer),2===n.length?(t.setStartAfter(n[0]),t.setEndBefore(n[1])):(t.setStartBefore(e[0]),t.setEndAfter(e[0])),e=s.nodes(t),e&&o&&o.length&&this.applyBlockStyles(e,o),e&&r&&r.length&&this.applyInlineStyles(e,r),this.releaseRange(t))},removeEmptyElementsFromRange:function(e){var t,n=function(e){return a.isInline(e)&&!e.firstChild&&!a.isMarker(e)},i=s.getAll(e,n);if(i&&i.length>0)for(t=0;t<i.length;t++)i[t].parentNode.removeChild(i[t])},cleanInlineParents:function(e){var t,n,i,r,o,l,s;for(t=0;t<e.length;t++)if(n=e[t],i=n.parentNode,!this.immutableParent(n))for(;i&&a.isInline(i);){for(r=i.childNodes,o=0;o<r.length;o++)l=r[o],a.isMarker(l)||l===n||(s=i.cloneNode(!0),s.innerHTML="",a.wrap(l,s));a.unwrap(i),i=n.parentNode}},applyBlockStyles:function(e,t){var n,i,r,o,l,s,c,p,h,m,f,d,u,g,y,b=t[0].tags[0],S=t[0].attr,N=this.editor.document;for(n=0,i=e.length;n<i;n++)if(r=e[n],!a.isWhitespace(r)&&!this.immutableParent(r))if(l=a.blockParentOrBody(r),"BODY"!==l.tagName&&l.tagName!==b){if("LI"!==l.tagName&&"TD"!==l.tagName&&"TH"!==l.tagName){for(c=[],p=[],h=r.previousSibling,m=r.nextSibling;h;)a.isMarker(h)||c.push(h),h=h.previousSibling;if(c.length)for(f=l.cloneNode(!0),f.innerHTML="",a.insertBefore(f,c[0]),g=0;g<c.length;g++)u=c[g],a.insertAt(f,u,0);for(;m;)a.isMarker(m)||p.push(m),m=m.nextSibling;if(p.length)for(d=l.cloneNode(!0),d.innerHTML="",a.insertBefore(d,p[0]),g=0;g<p.length;g++)u=p[g],d.appendChild(u);a.unwrap(l)}o=a.create(N,b,S),a.wrap(r,o)}else l.tagName===b&&a.attr(l,S);if(l&&2===t.length&&"LI"!==l.tagName&&"LI"===b){for(y=[];a.is(o,"li");)y.push(o),o=a.prev(o);for(s=a.create(N,t[1].tags[0],t[1].attr),a.insertBefore(s,y[y.length-1]),s.appendChild(y[0]),n=1,i=y.length;n<i;n++)a.insertBefore(y[n],s.firstChild)}else l&&2===t.length&&"LI"!==l.tagName&&(s=a.create(N,t[1].tags[0],t[1].attr),a.wrap(o,s))},applyInlineStyles:function(e,t){var n,i,r,o,l,s,c=this.editor.document;for(o=0;o<t.length;o++)n=t[o],i=a.create(c,n.tags[0],n.attr),r&&i.appendChild(r),r=i;if(r)for(o=0;o<e.length;o++)if(s=e[o],!a.isWhitespace(s)&&!this.immutableParent(s)){for(l=r.cloneNode(!0),a.insertBefore(l,s);l.children&&l.children.length;)l=l.children[0];l.appendChild(s)}},immutables:function(){return this.editor&&this.editor.options.immutables},immutableParent:function(e){return this.immutables()&&n.Immutables.immutableParent(e)}}),m=i.extend({init:function(e){i.fn.init.call(this,e)},command:function(e){return new p(e)}}),f=i.extend({init:function(e){i.fn.init.call(this,e)},command:function(e){return new h(e)}});e.extend(n,{CopyFormatCommand:p,ApplyFormatCommand:h,CopyFormatTool:m,ApplyFormatTool:f}),c("copyFormat",new m({template:new o({template:l.buttonTemplate,title:"Copy format"})})),c("applyFormat",new f({template:new o({template:l.buttonTemplate,title:"Apply format"})}))}(window.kendo.jQuery)},n(3))}});