UNPKG

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.26 kB
/*! * 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,a){"object"==typeof exports&&"undefined"!=typeof module?a(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],a):a(("undefined"!=typeof globalThis?globalThis:e||self).FroalaEditor)}(this,function(e){"use strict";Object.assign(e.DEFAULTS,{paragraphStyles:{"fr-text-gray":"Gray","fr-text-bordered":"Bordered","fr-text-spaced":"Spaced","fr-text-uppercase":"Uppercase"},paragraphMultipleStyles:!0}),e.PLUGINS.paragraphStyle=function(o){var i=o.$;return{_init:function(){},apply:function(e,a,t){void 0===a&&(a=o.opts.paragraphStyles);for(var r="",l=((t=void 0===t?o.opts.paragraphMultipleStyles:t)||((r=Object.keys(a)).splice(r.indexOf(e),1),r=r.join(" ")),o.selection.save(),o.html.wrap(!0,!0,!0,!0),o.selection.restore(),o.helpers.selectionBlocks([".fr-code-snippet"])),s=(o.selection.save(),i(l[0]).hasClass(e)),n=0;n<l.length;n++)i(l[n]).removeClass(r).toggleClass(e,!s),i(l[n]).hasClass("fr-temp-div")&&i(l[n]).removeClass("fr-temp-div"),""===i(l[n]).attr("class")&&i(l[n]).removeAttr("class");1===l.length&&"fr-text-bordered"===e&&null===l[0].nextSibling&&(t=i("<br>"),l[0].after(t[0])),o.html.unwrap(),o.selection.restore()},refreshOnShow:function(e,a){var t,r=o.selection.blocks();r.length&&(t=i(r[0]),a.find(".fr-command").each(function(){var e=i(this).data("param1"),e=t.hasClass(e);i(this).toggleClass("fr-active",e).attr("aria-selected",e)}))}}},e.RegisterCommand("paragraphStyle",{type:"dropdown",html:function(){var e,a='<ul class="fr-dropdown-list" role="presentation">',t=this.opts.paragraphStyles;for(e in t)t.hasOwnProperty(e)&&(a+='<li role="presentation"><a class="fr-command '.concat(e,'" tabIndex="-1" role="option" data-cmd="paragraphStyle" data-param1="').concat(e,'" title="').concat(this.language.translate(t[e]),'">').concat(this.language.translate(t[e]),"</a></li>"));return a+="</ul>"},title:"Paragraph Style",callback:function(e,a){this.paragraphStyle.apply(a)},refreshOnShow:function(e,a){this.paragraphStyle.refreshOnShow(e,a)},plugin:"paragraphStyle"}),e.DefineIcon("paragraphStyle",{NAME:"magic",SVG_KEY:"paragraphStyle"})});