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