@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 4.42 kB
JavaScript
module.exports=function(t){function e(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return t[a].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}({0:function(t,e,n){t.exports=n(956)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},956:function(t,e,n){var a,i,o;!function(r,define){i=[n(957)],a=r,o="function"==typeof a?a.apply(e,i):a,!(void 0!==o&&(t.exports=o))}(function(){!function(t){function e(t){var e,i,o=s.closestEditableOfType(t,["li"]);o&&(e=new a.ListFormatter(s.name(o.parentNode)),i=n.ui.editor.W3CRange.fromNode(t),i.selectNode(o),e.toggle(i))}var n=window.kendo,a=n.ui.editor,i=a.Tool,o=a.ToolTemplate,r=a.DelayedExecutionTool,l=a.Command,s=a.Dom,u=a.EditorUtils,d=a.RangeUtils,c=u.registerTool,m=r.extend({init:function(t){var e=this;i.fn.init.call(e,n.deepExtend({},e.options,t)),e.type="kendoSelectBox",e.finder={getFormat:function(){return""}}},options:{items:[{text:"Paragraph",value:"p"},{text:"Quotation",value:"blockquote"},{text:"Heading 1",value:"h1"},{text:"Heading 2",value:"h2"},{text:"Heading 3",value:"h3"},{text:"Heading 4",value:"h4"},{text:"Heading 5",value:"h5"},{text:"Heading 6",value:"h6"}],width:110},toFormattingItem:function(t){var e,n=t.value;return n?t.tag||t.className?t:(e=n.indexOf("."),0===e?t.className=n.substring(1):e==-1?t.tag=n:(t.tag=n.substring(0,e),t.className=n.substring(e+1)),t):t},command:function(e){var n=this,i=e.value;return i=this.toFormattingItem(i),new a.FormatCommand({range:e.range,formatter:function(){var e,o=(i.tag||i.context||"span").split(","),r=[{tags:o,attr:{className:i.className||""}}];return e=t.inArray(o[0],s.inlineElements)>=0?new a.GreedyInlineFormatter(r):new a.GreedyBlockFormatter(r),e.editor=n.editor,e}})},initialize:function(t,e){var a=e.editor,o=this.options,r=o.name,l=this;l.editor=a,t.width(o.width),t.kendoSelectBox({dataTextField:"text",dataValueField:"value",dataSource:o.items||a.options[r],title:a.options.messages[r],autoSize:!0,change:function(){var t=this.dataItem();t&&i.exec(a,r,t.toJSON())},dataBound:function(){var t,e=this.dataSource.data();for(t=0;t<e.length;t++)e[t]=l.toFormattingItem(e[t])},highlightFirst:!1,template:n.template('<span unselectable="on" style="display:block;#=(data.style||"")#">#:data.text#</span>')}),t.addClass("k-decorated").closest(".k-widget").removeClass("k-"+r).find("*").addBack().attr("unselectable","on")},getFormattingValue:function(e,n){var a,i,o,r,l,s,u;for(a=0;a<e.length;a++)if(i=e[a],o=i.tag||i.context||"",r=i.className?"."+i.className:"",l=o+r,s=t(n[0]).closest(l)[0]){if(1==n.length)return i.value;for(u=1;u<n.length&&t(n[u]).closest(l)[0];u++)if(u==n.length-1)return i.value}return""},update:function(e,n){var a,i,o,l,u,d=t(e).data(this.type);if(d&&(a=d.dataSource,i=a.data(),u=s.commonAncestor.apply(null,n),u==s.closestEditable(u)||this._ancestor!=u)){for(this._ancestor=u,o=0;o<i.length;o++)l=i[o].context,i[o].visible=!l||!!t(u).closest(l).length;a.filter([{field:"visible",operator:"eq",value:!0}]),r.fn.update.call(this,e,n),d.value(this.getFormattingValue(a.view(),n)),d.wrapper.toggleClass("k-state-disabled",!a.view().length)}},destroy:function(){this._ancestor=null}}),g=l.extend({exec:function(){var t,e,n,a=this.lockRange(!0);for(this.tagsToClean=this.options.remove||"strong,em,span,sup,sub,del,b,i,u,font".split(","),d.wrapSelectedElements(a),t=d.mapAll(a,function(t){return t}),e=t.length-1;e>=0;e--)n=t[e],this.immutableParent(n)||this.clean(n);this.releaseRange(a)},clean:function(n){var i,o,r,l,u;if(n&&!s.isMarker(n)){if(i=s.name(n),"ul"==i||"ol"==i)for(o=new a.ListFormatter(i),r=n.previousSibling,l=n.nextSibling,o.unwrap(n);r&&r!=l;r=r.nextSibling)this.clean(r);else if("blockquote"==i)s.changeTag(n,"p");else if(1!=n.nodeType||s.insignificant(n))e(n);else{for(u=n.childNodes.length-1;u>=0;u--)this.clean(n.childNodes[u]);n.removeAttribute("style"),n.removeAttribute("class")}t.inArray(i,this.tagsToClean)>-1&&s.unwrap(n)}},immutableParent:function(t){return this.immutables()&&a.Immutables.immutableParent(t)}});t.extend(a,{FormattingTool:m,CleanFormatCommand:g}),c("formatting",new m({template:new o({template:u.dropDownListTemplate,title:"Format"})})),c("cleanFormatting",new i({command:g,template:new o({template:u.buttonTemplate,title:"Clean formatting"})}))}(window.kendo.jQuery)},n(3))},957:function(t,e){t.exports=require("./inlineformat")}});