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.18 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,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(e){"use strict";e.PLUGINS.quote=function(a){var r=a.$;function c(){for(var e=a.selection.blocks(),t=0;t<e.length;t++)e[t]=function(e){for(;e.parentNode&&e.parentNode!=a.el;)e=e.parentNode;return e}(e[t]);a.selection.save();var o=r(document.createElement("blockquote"));for(o.insertBefore(e[0]),t=0;t<e.length;t++)o.append(e[t]);a.opts.trackChangesEnabled&&a.track_changes.addQuote(o),a.html.unwrap(),a.selection.restore()}return{apply:function(e){if(a.selection.save(),a.html.wrap(!0,!0,!0,!0),a.selection.restore(),"increase"==e)c();else if("decrease"==e){for(var t=a.opts.trackChangesEnabled,o=a.selection.blocks(),n=0;n<o.length;n++)"BLOCKQUOTE"!=o[n].tagName&&(o[n]=t&&r(o[n]).parentsUntil(a.$el,"[data-track-id^=pending]").get(0)||r(o[n]).parentsUntil(a.$el,"BLOCKQUOTE").get(0));for(a.selection.save(),n=0;n<o.length;n++)o[n]&&(t?a.track_changes.removeQuote(r(o[n]),n):r(o[n]).replaceWith(o[n].innerHTML));a.html.unwrap(),a.selection.restore()}}}},e.RegisterShortcut(e.KEYCODE.SINGLE_QUOTE,"quote","increase","'"),e.RegisterShortcut(e.KEYCODE.SINGLE_QUOTE,"quote","decrease","'",!0),e.RegisterCommand("quote",{title:"Quote",type:"dropdown",html:function(){var e,t,o='<ul class="fr-dropdown-list" role="presentation">',n={increase:"Increase",decrease:"Decrease"};for(e in n)n.hasOwnProperty(e)&&(t=this.shortcuts.get("quote.".concat(e)),o+='<li role="presentation"><a class="fr-command fr-active '.concat(e,'" tabIndex="-1" role="option" data-cmd="quote" data-param1="').concat(e,'" title="').concat(n[e],'">').concat(this.language.translate(n[e])).concat(t?'<span class="fr-shortcut">'.concat(t,"</span>"):"","</a></li>"));return o+="</ul>"},callback:function(e,t){this.quote.apply(t)},plugin:"quote"}),e.DefineIcon("quote",{NAME:"quote-left",SVG_KEY:"blockquote"})});