@firestitch/froala
Version:
The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.
3 lines (2 loc) • 2.17 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(e.FroalaEditor)}(this,function(a){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a,Object.assign(a.DEFAULTS,{lineHeights:{Default:"",Single:"1",1.15:"1.15",1.5:"1.5",Double:"2"}}),a.PLUGINS.lineHeight=function(i){var r=i.$;return{_init:function(){},apply:function(e){i.selection.save(),i.html.wrap(!0,!0,!0,!0),i.selection.restore();var t=i.selection.blocks();t.length&&r(t[0]).parent().is("td")&&i.format.applyStyle("line-height",e.toString()),i.selection.save();for(var n=0;n<t.length;n++)r(t[n]).css("line-height",e),i.opts.enter!==a.ENTER_BR||t.length&&r(t[0]).parent().is("td")||(r(t[n]).hasClass("fr-temp-div")&&r(t[n]).removeClass("fr-temp-div"),""===r(t[n]).attr("class")&&r(t[n]).removeAttr("class")),""===r(t[n]).attr("style")&&r(t[n]).removeAttr("style");i.html.unwrap(),i.selection.restore()},refreshOnShow:function(e,t){var a,n=i.selection.blocks();n.length&&(a=r(n[0]),t.find(".fr-command").each(function(){var e,t=r(this).data("param1"),n=a.attr("style"),i=0<=(n||"").indexOf("line-height: "+t+";");!n||(e=(e=(e=n.substring(n.indexOf("line-height"))).substr(0,e.indexOf(";")))&&e.split(":")[1])&&e.length||"Default"!==a.text()||(i=!0),n&&-1!==n.indexOf("line-height")||""!==t||(i=!0),r(this).toggleClass("fr-active",i).attr("aria-selected",i)}))}}},a.RegisterCommand("lineHeight",{type:"dropdown",html:function(){var e,t='<ul class="fr-dropdown-list" role="presentation">',n=this.opts.lineHeights;for(e in n)n.hasOwnProperty(e)&&(t+='<li role="presentation"><a class="fr-command '.concat(e,'" tabIndex="-1" role="option" data-cmd="lineHeight" data-param1="').concat(n[e],'" title="').concat(this.language.translate(e),'">').concat(this.language.translate(e),"</a></li>"));return t+="</ul>"},title:"Line Height",callback:function(e,t){this.lineHeight.apply(t)},refreshOnShow:function(e,t){this.lineHeight.refreshOnShow(e,t)},plugin:"lineHeight"}),a.DefineIcon("lineHeight",{NAME:"arrows-v",FA5NAME:"arrows-alt-v",SVG_KEY:"lineHeight"})});
//# sourceMappingURL=line_height.min.js.map