froala-editor
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.
7 lines (6 loc) • 2.67 kB
JavaScript
/*!
* froala_editor v5.0.1 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2026 Froala Labs
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(("undefined"!=typeof globalThis?globalThis:e||self).FroalaEditor)}(this,function(i){"use strict";Object.assign(i.DEFAULTS,{lineHeights:{Default:"",Single:"1",1.15:"1.15",1.5:"1.5",Double:"2"}}),i.PLUGINS.lineHeight=function(a){var l=a.$;return{_init:function(){},apply:function(e){a.selection.save(),a.html.wrap(!0,!0,!0,!0),a.selection.restore();var t=a.helpers.selectionBlocks([".fr-code-snippet"]);t.length&&l(t[0]).parent().is("td")&&a.format.applyStyle("line-height",e.toString()),a.selection.save();for(var n=0;n<t.length;n++)l(t[n]).css("line-height",e),a.opts.enter!==i.ENTER_BR||t.length&&l(t[0]).parent().is("td")||(l(t[n]).hasClass("fr-temp-div")&&l(t[n]).removeClass("fr-temp-div"),""===l(t[n]).attr("class")&&l(t[n]).removeAttr("class")),""===l(t[n]).attr("style")&&l(t[n]).removeAttr("style");a.html.unwrap(),a.selection.restore()},refreshOnShow:function(e,t){var i,n=a.selection.blocks();n.length&&(i=l(n[0]),t.find(".fr-command").each(function(){var e,t=l(this).data("param1"),n=i.attr("style"),a=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"!==i.text()||(a=!0),n&&-1!==n.indexOf("line-height")||""!==t||(a=!0),l(this).toggleClass("fr-active",a).attr("aria-selected",a)}))}}},i.RegisterCommand("lineHeight",{type:"dropdown",html:function(){var e='<ul class="fr-dropdown-list" role="presentation">',t=this.opts.lineHeights;if(t instanceof Array)for(var n=0;n<t.length;n++)e+='<li role="presentation"><a class="fr-command '.concat(t[n].label,'" tabIndex="-1" role="option" data-cmd="lineHeight" data-param1="').concat(t[n].value,'" title="').concat(this.language.translate(t[n].label),'">').concat(this.language.translate(t[n].label),"</a></li>");else if(t instanceof Object)for(var a in t)t.hasOwnProperty(a)&&(e+='<li role="presentation"><a class="fr-command '.concat(a,'" tabIndex="-1" role="option" data-cmd="lineHeight" data-param1="').concat(t[a],'" title="').concat(this.language.translate(a),'">').concat(this.language.translate(a),"</a></li>"));return e+="</ul>"},title:"Line Height",callback:function(e,t){this.lineHeight.apply(t)},refreshOnShow:function(e,t){this.lineHeight.refreshOnShow(e,t)},plugin:"lineHeight"}),i.DefineIcon("lineHeight",{NAME:"arrows-v",FA5NAME:"arrows-alt-v",SVG_KEY:"lineHeight"})});