/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/froala-editor-paragraph-format-extended-plugin@0.2.0/dist/paragraph_format_extended.cjs.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_froalaEditor=_interopRequireDefault(require("froala-editor"));function getFormatId(t){var e="";return t.tag&&(e+=t.tag.toLowerCase()),t.id&&(e+="#".concat(t.id)),t.class&&(e+=(t.class instanceof Array?t.class:String(t.class).split(/\s+/)).filter((function(t){return t})).sort().map((function(t){return".".concat(t)})).join("")),e}function getIdFormat(t){var e=/([^.#]*)(#[^.]+|.{0})(\.[\s\S]+|.{0})/.exec(t);return e?{tag:e[1].toLowerCase()||null,id:e[2].slice(1)||null,class:e[3].split(".").filter((function(t){return t})).join(" ")||null}:{}}_froalaEditor.default.DEFAULTS=(0,_objectSpread2.default)({},_froalaEditor.default.DEFAULTS,{paragraphFormatExtended:[{title:"Normal"},{tag:"h1",title:"Heading 1"},{tag:"h2",title:"Heading 2"},{tag:"h3",title:"Heading 3"},{tag:"h4",title:"Heading 4"},{tag:"h4",class:"fr-text-bordered",title:"Header 4 bordered"},{tag:"pre",title:"Code"}],paragraphFormatExtendedSelection:!1}),_froalaEditor.default.PLUGINS.paragraphFormatExtended=function(t){var e=t.$;function a(e){var a,r=t.html.defaultTag();e instanceof HTMLElement?(a={tag:e.tagName.toLowerCase(),id:e.getAttribute("id"),class:e.getAttribute("class")},-1!==["li","td","th"].indexOf(a.tag)&&(a.tag=r)):a={tag:r};var n=[a];return a.tag===r&&n.push((0,_objectSpread2.default)({},a,{tag:null})),n.map(getFormatId)}function r(a,r,n){if(!(r&&r.toLowerCase()!==t.html.defaultTag()||n))return a;var o;if(a.find("ul, ol").length>0){o=e("<".concat(r,">")),a.prepend(o);for(var i=t.node.contents(a[0])[0];i&&-1===["ul","ol"].indexOf(i.tagName.toLowerCase());){var l=i.nextSibling;o.append(i),i=l}}else o=e("<".concat(r,">")).html(a.html()),a.html(o);return o}function n(e,a,r){return a.toLowerCase()!==t.html.defaultTag()||r?i(e,a):(e.replaceWith(e.html()),null)}function o(e,a,r){return a.toLowerCase()!==t.html.defaultTag()||r?i(e,a):(t.node.isEmpty(e[0],!0)||e.append("<br/>"),e.replaceWith(e.html()),null)}function i(a,r){r||(r='div class="fr-temp-div"'.concat(t.node.isEmpty(a[0],!0)?' data-empty="true"':""));var n=e("<".concat(r," ").concat(t.node.attributes(a[0]),">")).html(a.html()).removeAttr("data-empty");return a.replaceWith(n),n}return{apply:function(a){var l=getIdFormat(a),d=l.tag||t.html.defaultTag(),c=l.class||l.id;t.selection.save(),t.html.wrap(!0,!0,!0,!0,!0),t.selection.restore();var s=t.selection.blocks(),p=Array.prototype.slice.call(s);t.selection.save(),t.$el.find("pre").attr("skip",!0),s.forEach((function(a){if(!t.node.isList(a)&&!p.some((function(t){return t!==a&&a.contains(t)}))){var s=("LI"===a.tagName?r:"LI"===a.parentNode.tagName?n:-1!==["TD","TH"].indexOf(a.parentNode.tagName)?o:i)(e(a),d,c);s&&s.each((function(t,e){for(var a=0,r=["id","class"];a<r.length;a++){var n=r[a];l[n]?e.setAttribute(n,l[n]):e.removeAttribute(n)}p.push(e)}))}})),t.$el.find('pre:not([skip="true"]) + pre:not([skip="true"])').each((function(t,a){var r=e(a);r.prev().append("<br>".concat(r.html())),r.remove()})),t.$el.find("pre").removeAttr("skip"),t.html.unwrap(),t.selection.restore()},refreshButton:function(e){if(t.opts.paragraphFormatExtendedSelection){for(var r=a(t.selection.blocks()[0]),n=t.opts.paragraphFormatExtended,o="—",i=0;i<n.length;++i)if(-1!==r.indexOf(getFormatId(n[i]))){o=t.language.translate(n[i].title);break}e.find("> span").text(o)}},refreshDropdown:function(e){var r=a(t.selection.blocks()[0]).map((function(t){return'.fr-command[data-param1="'.concat(t,'"]')})).join(", ");e.find(r).addClass("fr-active").attr("aria-selected",!0)}}},_froalaEditor.default.DefineIcon("paragraphFormatExtended",{NAME:"paragraph",SVG_KEY:"paragraphFormat"}),_froalaEditor.default.RegisterCommand("paragraphFormatExtended",{type:"dropdown",title:"Paragraph Format",plugin:"paragraphFormatExtended",displaySelection:function(t){return t.opts.paragraphFormatExtendedSelection},defaultSelection:function(t){return t.language.translate(t.opts.paragraphDefaultSelection)},displaySelectionWidth:100,html:function(){var t=this,e=this.opts.paragraphFormatExtended.map((function(e){var a=t.language.translate(e.title),r=e.tag||t.html.defaultTag(),n=getFormatId(e);return'<li role="presentation">'+"<".concat(r).concat(e.class?' class="'.concat(e.class,'"'):"").concat(e.id?' id="'.concat(e.id,'"'):"",' style="padding: 0 !important; margin: 0 !important;" role="presentation">')+'<a class="fr-command" tabIndex="-1" role="option" data-cmd="paragraphFormatExtended" data-param1="'.concat(n,'" title="').concat(a,'">')+a+"</a>"+"</".concat(r,">")+"</li>"})).join("\n");return'<ul class="fr-dropdown-list" role="presentation">'.concat(e,"</ul>")},callback:function(t,e){this.paragraphFormatExtended.apply(e)},refresh:function(t){this.paragraphFormatExtended.refreshButton(t)},refreshOnShow:function(t,e){this.paragraphFormatExtended.refreshDropdown(e)}});
//# sourceMappingURL=/sm/fc417d7ee805772f41dae6e1b1b567c0cba028e6a4507ad7917e1322417cb6de.map