@akilli/editor 5.1.8 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.js +2 -2
- package/package.json +4 -4
- package/readme.md +1 -1
package/dist/editor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=class{static get AUDIO(){return"audio"}static get BLOCK(){return"block"}static get BREAK(){return"break"}static get CAPTION(){return"caption"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get CONTAINER(){return"container"}static get FIGURE(){return"figure"}static get FORMAT(){return"format"}static get HEADING(){return"heading"}static get IFRAME(){return"iframe"}static get IMAGE(){return"image"}static get LIST(){return"list"}static get LISTITEM(){return"listitem"}static get PARAGRAPH(){return"paragraph"}static get PREFORMAT(){return"preformat"}static get QUOTE(){return"quote"}static get ROOT(){return"root"}static get RULE(){return"rule"}static get SLOT(){return"slot"}static get SUMMARY(){return"summary"}static get TABLE(){return"table"}static get TABLECELL(){return"tablecell"}static get TABLEROW(){return"tablerow"}static get TABLESECTION(){return"tablesection"}static get VIDEO(){return"video"}};function B(s){return typeof s<"u"}function W(s){return typeof s=="function"}function b(s){return s&&typeof s=="string"}function S(s){return!B(s)||b(s)}function _e(s){return!B(s)||Array.isArray(s)&&s.length>0}function Me(s){return!B(s)||s instanceof HTMLElement}var T=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get tag(){return this.#r}#o;get dialog(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof L)||!b(e)||!S(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i&&this.editor.tags.get(i),this.#o=this.editor.dialogs.get(e)}execute(){this.dialog?this._openDialog():this._insert(this.#s())}_insert(t={}){if(!this.tag)return;this.#i(t);let e=this.editor.dom.getSelectedElementByName(this.tag.name);this.tag.group!==o.FORMAT?this.editor.dom.insert(this.editor.dom.createElement(this.tag.name,{attributes:t})):e&&Object.keys(t).length>0?e.parentElement.replaceChild(this.editor.dom.createElement(this.tag.name,{attributes:t,html:e.textContent}),e):e?e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e):this.editor.dom.format(this.editor.dom.createElement(this.tag.name,{attributes:t}))}_openDialog(){this.dialog?.open(t=>this._insert(t),this.#s())}#s(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return this.#i(t),t}#i(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])}};var z=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}findByTagName(t){return Array.from(this.#t.values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var q=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof p))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var r=class{static get A(){return"a"}static get ABBR(){return"abbr"}static get ALL(){return"*"}static get AUDIO(){return"audio"}static get B(){return"b"}static get BLOCK(){return"app-block"}static get BLOCKQUOTE(){return"blockquote"}static get BR(){return"br"}static get BUTTON(){return"button"}static get CITE(){return"cite"}static get CODE(){return"code"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get DATA(){return"data"}static get DEL(){return"del"}static get DETAILS(){return"details"}static get DFN(){return"dfn"}static get DIALOG(){return"dialog"}static get DIV(){return"div"}static get EDITOR(){return"akilli-editor"}static get EM(){return"em"}static get FIELDSET(){return"fieldset"}static get FIGCAPTION(){return"figcaption"}static get FIGURE(){return"figure"}static get FOCUSBAR(){return"editor-focusbar"}static get FORM(){return"form"}static get FORMATBAR(){return"editor-formatbar"}static get H2(){return"h2"}static get H3(){return"h3"}static get HR(){return"hr"}static get I(){return"i"}static get IFRAME(){return"iframe"}static get IMG(){return"img"}static get INPUT(){return"input"}static get INS(){return"ins"}static get KBD(){return"kbd"}static get LABEL(){return"label"}static get LEGEND(){return"legend"}static get LI(){return"li"}static get MARK(){return"mark"}static get OL(){return"ol"}static get P(){return"p"}static get PRE(){return"pre"}static get Q(){return"q"}static get ROOT(){return"editor-root"}static get S(){return"s"}static get SAMP(){return"samp"}static get SECTION(){return"section"}static get SLOT(){return"slot"}static get SMALL(){return"small"}static get STRONG(){return"strong"}static get SUB(){return"sub"}static get SUMMARY(){return"summary"}static get SUP(){return"sup"}static get TABLE(){return"table"}static get TBODY(){return"tbody"}static get TD(){return"td"}static get TFOOT(){return"tfoot"}static get TH(){return"th"}static get THEAD(){return"thead"}static get TIME(){return"time"}static get TOOLBAR(){return"editor-toolbar"}static get TR(){return"tr"}static get U(){return"u"}static get UL(){return"ul"}static get VAR(){return"var"}static get VIDEO(){return"video"}};var v=class{#t;constructor(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t=t,this.register(this.#r.bind(this))}dispatch(t,e=void 0,i=void 0){if(!b(t)||!Me(e)||!Me(i))throw new TypeError("Invalid argument");this.#t.dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!W(t))throw new TypeError("Invalid argument");new MutationObserver(t).observe(this.#t,e)}#e(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))}#r(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(this.#e("insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>this.#e("insert",n,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&this.#e("delete",i,e.target))})}};var E=class{static get FIRST(){return"first"}static get PREV(){return"prev"}static get NEXT(){return"next"}static get LAST(){return"last"}static values(){return[this.FIRST,this.PREV,this.NEXT,this.LAST]}};var j=class{#t;get editor(){return this.#t}#e;get document(){return this.#e}#r;get window(){return this.#r}#o;get root(){return this.#o}#s={alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""};constructor(t,e){if(!(t instanceof L)||!(e instanceof Document))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=this.document.defaultView,this.#o=this.document.documentElement}registerElement(t,e,i=void 0){B(this.window.customElements.get(t))||this.window.customElements.define(t,e,i?{extends:i}:void 0)}createElement(t,{attributes:e={},html:i=""}={}){let n=this.document.createElement(t);return n.innerHTML=i,Object.entries(e).forEach(([l,c])=>c&&n.setAttribute(l,`${c}`)),n}insert(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))this.insertBefore(t,e);else if(e){let i=this.closest(e,t);i&&this.insertAfter(t,i),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e)}else if(this.editor.tags.allowed(this.editor.root,t))this.insertLastChild(t,this.editor.root);else throw new TypeError("Invalid argument")}insertText(t){let e=this.getSelectedEditable();if(e){let i=this.getRange();i.deleteContents(),i.insertNode(this.createText(t)),i.collapse(),e.normalize()}}format(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getRange(),i=this.getSelectedEditable();if(!e||e.collapsed||!e.toString().trim()||!i||!this.editor.tags.allowed(i,t))return;e.startContainer instanceof Text&&e.startContainer.parentElement!==i&&e.setStartBefore(e.startContainer.parentElement),e.endContainer instanceof Text&&e.endContainer.parentElement!==i&&e.setEndAfter(e.endContainer.parentElement);let n=e.toString(),l=Array.from(e.cloneContents().childNodes).every(c=>c instanceof Text&&!c.textContent.trim()||c instanceof HTMLElement&&c.localName===t.localName);e.deleteContents(),l?e.insertNode(this.createText(n)):(t.textContent=n,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}createTable(t=1,e=1){let i=this.createElement(r.TABLE);return this.insertLastChild(this.createTableHeader(1,e),i),this.insertLastChild(this.createTableBody(t,e),i),this.insertLastChild(this.createTableFooter(1,e),i),i}createTableColumnGroup(t=1){let e=this.createElement(r.COLGROUP);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.COL),e);return e}createTableHeader(t=1,e=1){return this.#i(r.THEAD,t,e)}createTableBody(t=1,e=1){return this.#i(r.TBODY,t,e)}createTableFooter(t=1,e=1){return this.#i(r.TFOOT,t,e)}createTableHeaderRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TH),e);return e}createTableRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TD),e);return e}createTableRowAfter(t){if(!(t instanceof HTMLTableRowElement))throw new TypeError("Invalid argument");this.insertAfter(this.createTableRow(t.cells.length),t)}createTableColumnAfter(t){if(!(t instanceof HTMLTableColElement)||t.localName!==r.COL)throw new TypeError("Invalid argument");let e=t.parentElement,i=e.parentElement,n=Array.from(e.children).indexOf(t);Array.from(i.rows).forEach(l=>this.insertAfter(this.createElement(l.cells[n].localName),l.cells[n])),this.insertAfter(this.createElement(r.COL),t)}sort(t,e){if(!(t instanceof HTMLElement)||!E.values().includes(e))throw new TypeError("Invalid argument");if(t.parentElement.children.length<=1)return;let i=t.parentElement,n=i.parentElement,l=t.previousElementSibling,c=t.nextElementSibling,u=i.firstElementChild,f=i.lastElementChild,g=t===u,O=t===f,M=t.localName===r.COL,K=Array.from(i.children).indexOf(t);e===E.PREV&&!g&&l.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertBefore(I.cells[K],I.cells[K-1])),this.insertBefore(t,l)):e===E.NEXT&&!O&&c.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertAfter(I.cells[K],I.cells[K+1])),this.insertAfter(t,c)):(e===E.FIRST&&!g||e===E.NEXT&&O)&&u.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertFirstChild(I.cells[K],I)),this.insertBefore(t,u)):(e===E.LAST&&!O||e===E.PREV&&g)&&f.hasAttribute("data-sortable")&&(M&&Array.from(n.rows).forEach(I=>this.insertLastChild(I.cells[K],I)),this.insertAfter(t,f))}insertBefore(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforebegin",t)}insertAfter(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterend",t)}insertFirstChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterbegin",t)}insertLastChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforeend",t)}delete(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if([r.COL,r.TR].includes(t.localName)&&t.matches(":only-child"))return;if(t.localName===r.COL){let n=Array.from(t.parentElement.children).indexOf(t),l=t.parentElement.parentElement;Array.from(l.rows).forEach(c=>c.removeChild(c.cells[n]))}let e=t.previousElementSibling,i=t.nextElementSibling;t===this.getActiveElement()&&t.blur(),t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if(this.editor.root.contains(t))return!0;let e=t.closest(this.editor.root.localName);return e&&!e.parentElement}closest(t,e){if(!(t instanceof HTMLElement)||!this.contains(t.parentElement))throw new TypeError("Invalid argument");let i=t,n=t.parentElement;do if(this.arbitrary(n)&&this.editor.tags.allowed(n,e))return i;while((i=n)&&(n=n.parentElement)&&this.contains(n))}wrap(t,e,i={}){let n;if(t instanceof HTMLElement){if(t.parentElement.localName!==e&&(n=this.closest(t,e))){let l=this.createElement(e,i);this.insertAfter(l,n),this.insertLastChild(t,l)}}else throw new TypeError("Invalid argument")}getActiveElement(){let t=this.document.activeElement;return t&&this.contains(t)?t:void 0}getSelectedElement(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement&&e===i&&this.contains(e))return e}getSelectedElementByName(t){let e=this.getSelectedElement();return e?.localName===t?e:void 0}getSelectedAttributesByName(t){let e=this.getSelectedElementByName(t),i={};return e&&Array.from(e.attributes).forEach(n=>i[n.nodeName]=n.nodeValue),i}getSelectedEditable(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement){let n=e.closest("[contenteditable=true]"),l=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===l&&this.contains(n))return n}}getSelection(){return this.window.getSelection()}getRange(){let t=this.getSelection();return t.rangeCount>0?t.getRangeAt(0):void 0}setRange(t){let e=this.getSelection();e.removeAllRanges(),e.addRange(t)}selectContents(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}removeClass(t,...e){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.classList.remove(...e),t.classList.length>0||t.removeAttribute("class")}open({url:t,name:e,call:i,params:n={}}){if(!b(t)||!b(e)||!W(i))throw new TypeError("Invalid argument");let l=this.createElement(r.A,{attributes:{href:t}}),c=new URL(l.href);Object.entries(n).forEach(([f,g])=>c.searchParams.set(f,`${g}`));let u=this.window.open(c.toString(),e,this.#a());this.window.addEventListener("message",f=>{f.origin===c.origin&&f.source===u&&(i(f.data),u.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}#i(t,e,i){let n=this.createElement(t);for(let l=0;l<e;l++)this.insertLastChild(t===r.THEAD?this.createTableHeaderRow(i):this.createTableRow(i),n);return n}#a(){let t=Object.assign({},this.#s,{height:`${this.getHeight()}`,width:`${this.getWidth()}`},this.editor.config.base.browser);return Object.entries(t).filter(([,e])=>!!e).map(([e,i])=>`${e}=${i}`).join(",")}};var A=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}filter(t){throw new Error("Not implemented")}};var V=class{#t=new Set;add(t){if(!(t instanceof A))throw new TypeError("Invalid argument");this.#t.add(t)}filter(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t.forEach(e=>{t.normalize(),e.filter(t)})}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var F=class{name;group;children;attributes;alignable;arbitrary;deletable;editable;empty;focusable;navigable;slotable;sortable;enter;constructor({name:t,group:e,...i}={}){if(!b(t)||!b(e)||!_e(i.children)||!_e(i.attributes)||!S(i.enter))throw new TypeError("Invalid argument");this.name=t,this.group=e,this.children=i.children||[],this.attributes=i.attributes||[],this.arbitrary=i.arbitrary===!0,this.alignable=i.alignable===!0,this.deletable=i.deletable===!0,this.editable=i.editable===!0,this.empty=i.empty===!0,this.focusable=i.focusable===!0,this.navigable=i.navigable===!0,this.slotable=i.slotable===!0,this.sortable=i.sortable===!0,this.enter=i.enter}};var d=class{#t;get editor(){return this.#t}static get name(){throw new Error("Missing name")}static get dependencies(){return[]}static get config(){return{}}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}init(){throw new Error("Not implemented")}_(t){return this.editor.translate(t)}_i18n(t){t[this.editor.config.base.lang]&&(this.editor.i18n=t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new F(t))}_command(t){this.editor.commands.set(new T(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.toolbar)}_formatbar(t,e=void 0,i=void 0){let n=this._(t),l=this._("Alt"),c=this._("Shift"),u=n+(e?` [${l} + ${c} + ${e}]`:"");this.editor.dom.insertLastChild(this.#e(n,u,e,i),this.editor.formatbar)}_focusbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.focusbar)}#e(t,e,i=void 0,n=void 0){if(!b(t)||!b(e)||!S(i))throw new TypeError("Invalid argument");return this.editor.dom.createElement(r.BUTTON,{attributes:{type:"button",title:e,"data-command":n||this.constructor.name,"data-key":i},html:t})}};var $=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof d))throw new TypeError("Invalid argument");this.#t.set(t.constructor.name,t)}init(){this.#t.forEach(t=>t.init())}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var Q=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof F))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}allowed(t,e,i=!1){let n=i?e:this.get(e)?.group;return!!this.get(t)?.children.includes(n)}freeze(){this.#t.forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(this.#t),Object.freeze(this)}};var L=class{#t;get orig(){return this.#t}#e={};get config(){return this.#e}#r;get dom(){return this.#r}#o;get element(){return this.#o}#s;get toolbar(){return this.#s}#i;get toolbarDispatcher(){return this.#i}#a;get formatbar(){return this.#a}#d;get formatbarDispatcher(){return this.#d}#m;get focusbar(){return this.#m}#l;get focusbarDispatcher(){return this.#l}#c;get root(){return this.#c}#h;get rootDispatcher(){return this.#h}#n={};get i18n(){return this.#n}set i18n(t){this.#n={...this.#n,...t||{}}}#u=new Q;get tags(){return this.#u}#f=new V;get filters(){return this.#f}#p=new q;get dialogs(){return this.#p}#g=new z;get commands(){return this.#g}#E=new $;get plugins(){return this.#E}static get defaultConfig(){return{}}constructor(t,e={}){if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=new j(this,this.orig.ownerDocument),this.#o=this.dom.createElement(r.EDITOR),this.#s=this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}}),this.dom.insertLastChild(this.toolbar,this.element),this.#i=new v(this.toolbar),this.#a=this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}}),this.formatbar.hidden=!0,this.dom.insertLastChild(this.formatbar,this.element),this.#d=new v(this.formatbar),this.#m=this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}}),this.focusbar.hidden=!0,this.dom.insertLastChild(this.focusbar,this.element),this.#l=new v(this.focusbar),this.#c=this.dom.createElement(r.ROOT),this.dom.insertLastChild(this.root,this.element),this.#h=new v(this.root)}init(){let t=this.config;this.#e={};let e=this.constructor.defaultConfig.base?.plugins||[],i=e;if(Array.isArray(t.base?.plugins)&&t.base.plugins.length>0){let c=t.base.plugins;t.base?.pluginsDisabled?i=i.filter(u=>!c.includes(u.name)):(i=[],c.forEach(u=>{let f=e.find(g=>g.name===u);f&&i.push(f)}))}let n=new Set,l=c=>{c.dependencies?.forEach(l),n.add(c)};i.map(l),n.forEach(c=>{Object.entries(c.config).forEach(([u,f])=>{this.config[c.name]??={},this.config[c.name][u]=t[c.name]?.[u]||this.constructor.defaultConfig[c.name]?.[u]||f}),this.plugins.set(new c(this))}),this.config.base.lang&&(this.element.lang=this.config.base.lang),this.plugins.init(),this.toolbarDispatcher.dispatch("init"),this.formatbarDispatcher.dispatch("init"),this.focusbarDispatcher.dispatch("init"),this.rootDispatcher.dispatch("init")}freeze(){Object.freeze(this.config),Object.freeze(this.i18n),this.tags.freeze(),this.filters.freeze(),this.dialogs.freeze(),this.commands.freeze(),this.plugins.freeze()}load(){this.orig instanceof HTMLTextAreaElement?(this.orig.form.addEventListener("submit",()=>this.save()),this.setHtml(this.orig.value.replace("/ /g"," "))):this.setHtml(this.orig.innerHTML),this.dom.insertAfter(this.element,this.orig),this.orig.hidden=!0,this.rootDispatcher.dispatch("load")}destroy(){this.element.parentElement.removeChild(this.element),this.orig.hidden=!1,this.rootDispatcher.dispatch("destroy")}getHtml(){let t=this.dom.createElement(this.root.localName,{html:this.root.innerHTML});return this.filters.filter(t),this.rootDispatcher.dispatch("gethtml",t),t.innerHTML}setHtml(t){let e=this.dom.createElement(this.root.localName,{html:t});this.rootDispatcher.dispatch("sethtml",e),this.filters.filter(e),this.root.innerHTML=e.innerHTML}save(){this.orig instanceof HTMLTextAreaElement?this.orig.value=this.getHtml():this.orig.innerHTML=this.getHtml(),this.rootDispatcher.dispatch("save")}translate(t){return this.i18n[t]||t}url(t){let e=this.dom.window.origin||this.dom.window.location.origin,i=this.dom.createElement(r.A,{attributes:{href:t}});return e===i.origin?i.pathname:i.href}static create(t,e={}){let i=new this(t,e);return i.init(),i.freeze(),i.load(),i}};var Y=class{#t;get editor(){return this.#t}#e;get form(){return this.#e}#r;constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t,this.#e=this.editor.dom.createElement(r.FORM,{attributes:{method:"dialog"}}),this.addFieldset().#o().#s()}addFieldset(){let t=this.editor.dom.createElement(r.FIELDSET);return this.#r?this.editor.dom.insertAfter(t,this.#r):this.editor.dom.insertFirstChild(t,this.#e),this.#r=t,this}addLegend(t){if(!b(t))throw new TypeError("Invalid argument");return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LEGEND,{html:t}),this.#r),this}addTextInput(t,e,i={}){return this.addInput(t,e,i,"text")}addNumberInput(t,e,i={}){return this.addInput(t,e,i,"number")}addInput(t,e,i={},n="text"){if(!b(t)||!b(e)||!b(n))throw new TypeError("Invalid argument");Object.assign(i,{id:`editor-${t}`,name:t,type:n});let l=this.editor.dom.createElement(r.DIV);return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LABEL,{attributes:{for:i.id},html:e}),l),this.editor.dom.insertLastChild(this.editor.dom.createElement(r.INPUT,{attributes:i}),l),i.required&&l.setAttribute("data-required",""),this.editor.dom.insertLastChild(l,this.#r),this}#o(){let t=this.#i("Cancel"),e=this.editor.dom.createElement(r.BUTTON,{attributes:{type:"reset"},html:t});return this.editor.dom.insertLastChild(e,this.#e),this}#s(){let t=this.editor.dom.createElement(r.BUTTON,{html:this.#i("Save")});return this.editor.dom.insertLastChild(t,this.#e),this}#i(t){return this.editor.translate(t)}};var p=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get browserUrl(){return this.#r}#o;get formCreator(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof L)||!b(e)||!S(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i}open(t,e={}){this.browserUrl?this.#s(t,e):this.#i(t,e)}_(t){return this.editor.translate(t)}_prepareForm(){throw new Error("Not implemented")}#s(t,e={}){this.editor.dom.open({url:this.browserUrl,name:this.name,call:t,params:e})}#i(t,e={}){let i=this.editor.dom.getRange();this.#a();let n=this.editor.dom.createElement(r.DIALOG);n.addEventListener("click",c=>c.target===n&&n.close()),n.addEventListener("close",()=>{i&&this.editor.dom.setRange(i),n.returnValue&&t(JSON.parse(n.returnValue)),this.#a()}),this.editor.dom.insertLastChild(n,this.editor.element),this.#o=new Y(this.editor),this._prepareForm();let l=this.formCreator.form;l.addEventListener("submit",()=>n.close(JSON.stringify(Object.fromEntries(new FormData(l))))),l.addEventListener("reset",()=>n.close()),new FormData(l).forEach((c,u)=>B(e[u])&&(l.elements[u].value=e[u])),this.editor.dom.insertLastChild(l,n),n.showModal()}#a(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})}};var Z=class extends p{constructor(t){super(t,D.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var x=class{static get NONE(){return"none"}static get LEFT(){return"left"}static get CENTER(){return"center"}static get RIGHT(){return"right"}static values(){return[this.NONE,this.LEFT,this.CENTER,this.RIGHT]}};var X=class extends T{#t;constructor(t,e){if(!x.values().includes(e))throw new TypeError("Invalid argument");super(t,"align-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-alignable")&&(this.editor.dom.removeClass(t,...x.values()),this.#t!==x.NONE&&t.classList.add(this.#t))}};var a=class{static get A(){return"a"}static get ARROWDOWN(){return"ArrowDown"}static get ARROWLEFT(){return"ArrowLeft"}static get ARROWRIGHT(){return"ArrowRight"}static get ARROWUP(){return"ArrowUp"}static get B(){return"b"}static get BACKSPACE(){return"Backspace"}static get C(){return"c"}static get D(){return"d"}static get DEL(){return"Delete"}static get E(){return"e"}static get END(){return"End"}static get ENTER(){return"Enter"}static get F(){return"f"}static get G(){return"g"}static get HOME(){return"Home"}static get I(){return"i"}static get J(){return"j"}static get K(){return"k"}static get L(){return"l"}static get M(){return"m"}static get O(){return"o"}static get Q(){return"q"}static get R(){return"r"}static get S(){return"s"}static get SPACE(){return" "}static get T(){return"t"}static get TAB(){return"Tab"}static get U(){return"u"}static get V(){return"v"}static get W(){return"w"}static get X(){return"x"}static get Y(){return"y"}static get Z(){return"z"}static isEventFor(t,e,{alt:i=!1,ctrl:n=!1,shift:l=!1}={}){return(Array.isArray(e)&&e.includes(t.key)||t.key===e)&&t.altKey===i&&t.ctrlKey===n&&t.shiftKey===l}};var h=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}handleEvent(t){W(this[t.type])&&this[t.type](t)}_(t){return this.editor.translate(t)}};var J=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-alignable")&&t.addEventListener("keydown",this)}keydown(t){let e={[a.ARROWUP]:x.NONE,[a.ARROWLEFT]:x.LEFT,[a.ARROWDOWN]:x.CENTER,[a.ARROWRIGHT]:x.RIGHT};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.dom.removeClass(t.target,...x.values()),e[t.key]!==x.NONE&&t.target.classList.add(e[t.key]))}};var tt=class extends A{filter(t){let e=this.editor.tags.get(t),i=this.editor.tags.allowed(t,r.P),n=e.editable||e.group===o.FORMAT,l=[],c=(u=null)=>{if(i&&l.length>0){let f=this.editor.dom.createElement(r.P,{html:l.join(" ")});u?this.editor.dom.insertBefore(f,u):this.editor.dom.insertLastChild(f,t),l=[]}};Array.from(t.childNodes).forEach(u=>{let f=u.textContent.trim();if(u instanceof HTMLElement){let g=this.#t(u),O=this.editor.tags.get(g);if(O&&this.editor.tags.allowed(t,g))c(g),this.#e(g,O);else if(O&&O.group===o.FORMAT&&i){let M=this.#e(g,O);M&&(l.push(M.outerHTML),t.removeChild(M))}else!n&&f&&i?(l.push(f),t.removeChild(g)):n&&f?t.replaceChild(this.editor.dom.createText(f),g):t.removeChild(g)}else u instanceof Text?(!n&&f&&i&&l.push(f),(!n||!f)&&t.removeChild(u)):u instanceof Node&&t.removeChild(u)}),c()}#t(t){let e=this.editor.config.base.filter[t.localName];if(!e)return t;let i=this.editor.dom.createElement(e,{html:t.innerHTML});return t.parentElement.replaceChild(i,t),i}#e(t,e){if(Array.from(t.attributes).forEach(i=>!e.attributes.includes(i.name)&&t.removeAttribute(i.name)),t.hasChildNodes()&&this.editor.filters.filter(t),t.hasChildNodes()||e.empty)return t;t.parentElement?.removeChild(t)}};var et=class extends T{constructor(t){super(t,"delete")}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var rt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-deletable")&&t.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&a.isEventFor(t,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var it=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.contentEditable==="true"?t.addEventListener("keydown",this):t.parentElement.contentEditable==="true"&&t.addEventListener("dblclick",this)}keydown(t){if(a.isEventFor(t,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(a.isEventFor(t,a.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;if(e){if(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")){let i=this.editor.dom.closest(t.target,e);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(e),i)}else if(!(t.target instanceof HTMLParagraphElement)){let i=this.editor.dom.closest(t.target,r.P);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(r.P),i),t.target.parentElement.removeChild(t.target)}}}else a.isEventFor(t,a.BACKSPACE)&&!t.target.textContent&&t.target.hasAttribute("data-deletable")?(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation()):/^[A-Z]$/.test(t.key)&&a.isEventFor(t,t.key,{alt:!0,shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick({target:t}){this.editor.dom.selectContents(t),this.editor.commands.findByTagName(t.localName)?.execute()}};var ot=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-focusable")&&t.focus()}};var _=class extends h{insertbutton({target:t,detail:{element:e}}){e.getAttribute("data-command")&&e.addEventListener("click",this),e.tabIndex=e===t.firstElementChild?0:-1,e.addEventListener("keydown",this)}click({target:t}){this.editor.commands.execute(t.getAttribute("data-command"))}keydown(t){if(a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.HOME,a.END])){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWLEFT&&!c?e.focus():t.key===a.ARROWRIGHT&&!u?i.focus():t.key===a.HOME||t.key===a.ARROWRIGHT&&u?n.focus():(t.key===a.END||t.key===a.ARROWLEFT&&c)&&l.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");t.hidden=!1;let{x:i,y:n}=e.getBoundingClientRect(),{x:l,y:c}=this.editor.root.getBoundingClientRect(),u=i-l+t.clientWidth-this.editor.root.clientWidth,f=n-c-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,g=t.clientWidth<this.editor.root.clientWidth?i-l:0;g>0&&u>0&&(g=g>u?(g-u)/2:0),t.style.left=`${g}px`,t.style.top=`${f}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var st=class extends _{constructor(t){super(t),this.editor.focusbar.addEventListener("insertbutton",this),this.editor.root.addEventListener("focusin",this),this.editor.root.addEventListener("focusout",this),this.editor.dom.document.addEventListener("selectionchange",this)}insertbutton(t){super.insertbutton(t),t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("mousedown",this)}mousedown(t){t.preventDefault(),t.stopPropagation()}focusin({target:t}){t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}focusout(){this.#e()}selectionchange(){let t=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!t?this.#e():t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}#t(t){this.editor.focusbar.children.length&&(Object.keys(t.dataset).forEach(e=>this.editor.focusbar.dataset[e]=t.dataset[e]),this.editor.focusbar.dataset.tag=t.localName,this._show(this.editor.focusbar,t))}#e(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(t=>delete this.editor.focusbar.dataset[t])}};var at=class extends _{constructor(t){super(t),this.editor.formatbar.addEventListener("insertbutton",this),this.editor.dom.document.addEventListener("selectionchange",this)}selectionchange(){let t=this.editor.dom.getSelectedEditable();t&&!this.editor.dom.getSelection().isCollapsed&&this.editor.tags.allowed(t,o.FORMAT,!0)?this._show(this.editor.formatbar,t):this._hide(this.editor.formatbar)}};var nt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-navigable")&&(t.tabIndex=0,t.addEventListener("keydown",this))}keydown(t){if(t.target===t.currentTarget&&a.isEventFor(t,[a.ARROWUP,a.ARROWDOWN,a.HOME,a.END])&&this.#t(t.target)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWUP&&!c&&e.hasAttribute("data-navigable")?e.focus():t.key===a.ARROWDOWN&&!u&&i.hasAttribute("data-navigable")?i.focus():(t.key===a.HOME||t.key===a.ARROWDOWN&&u)&&n.hasAttribute("data-navigable")?n.focus():(t.key===a.END||t.key===a.ARROWUP&&c)&&l.hasAttribute("data-navigable")&&l.focus(),t.preventDefault(),t.stopPropagation()}}#t(t){if(t.contentEditable!=="true")return!0;let e=this.editor.dom.getSelection(),i=this.editor.dom.getSelectedEditable(),n=this.editor.dom.getSelectedElement();return e.isCollapsed&&e.anchorOffset===0&&[i,t.firstChild].includes(n)}};var dt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t instanceof HTMLSlotElement?t.addEventListener("keydown",this):t.hasAttribute("data-slotable")&&!t.querySelector(":scope > "+r.SLOT)&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.SLOT),t)}keydown(t){a.isEventFor(t,a.BACKSPACE)&&t.target.matches(":only-child")?this.editor.dom.delete(t.target.parentElement):!a.isEventFor(t,a.TAB)&&!a.isEventFor(t,a.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var mt=class extends T{#t;constructor(t,e){if(!E.values().includes(e))throw new TypeError("Invalid argument");super(t,"sort-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-sortable")&&this.editor.dom.sort(t,this.#t)}};var lt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-sortable")&&(t.addEventListener("keydown",this),t.addEventListener("pointerdown",this),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this))}keydown(t){let e={[a.HOME]:E.FIRST,[a.ARROWUP]:E.PREV,[a.ARROWDOWN]:E.NEXT,[a.END]:E.LAST};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{ctrl:!0})&&(this.editor.dom.sort(t.target,e[t.key]),t.preventDefault(),t.stopPropagation())}pointerdown(t){let e=t.target.closest("[data-sortable]");e&&this.editor.dom.contains(e)&&(e.setAttribute("data-sort",""),e.setPointerCapture(t.pointerId))}pointermove(t){let e=t.target.closest("[data-sortable][data-sort]"),i=this.editor.dom.document.elementFromPoint(t.x,t.y);this.#t(),e&&this.editor.dom.contains(e)&&this.#e(e,i)&&i.setAttribute("data-sortover","")}pointerup(t){let e=t.target.closest("[data-sortable][data-sort]");if(e&&this.editor.dom.contains(e)){let i=this.editor.dom.document.elementFromPoint(t.x,t.y),n=i.parentElement;if(this.#t(),e.removeAttribute("data-sort"),e.releasePointerCapture(t.pointerId),this.#e(e,i)){if(e.localName===r.COL&&n===e.parentElement){let l=Array.from(n.children).indexOf(e),c=Array.from(n.children).indexOf(i),u=n.parentElement;Array.from(u.rows).forEach(f=>this.editor.dom.insertBefore(f.cells[l],f.cells[c]))}this.editor.dom.insertBefore(e,i)}}}#t(){this.editor.root.querySelectorAll("[data-sortover]").forEach(t=>t.removeAttribute("data-sortover"))}#e(t,e){return t instanceof HTMLElement&&e instanceof HTMLElement&&this.editor.dom.contains(e)&&![this.editor.root,t].includes(e)&&e.hasAttribute("data-sortable")&&(t.parentElement===e.parentElement||this.editor.dom.arbitrary(t.parentElement)&&this.editor.dom.arbitrary(e.parentElement))&&this.editor.tags.allowed(e.parentElement,t)}};var ct=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){let e=this.editor.tags.get(t);e&&(e.editable&&(t.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.dataset[i]="")}))}};var ht=class extends _{constructor(t){super(t),this.editor.toolbar.addEventListener("insertbutton",this)}};var m=class extends d{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._tag({name:r.ROOT,group:o.ROOT,children:[o.AUDIO,o.BLOCK,o.CONTAINER,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO]}),this._tag({name:r.SLOT,group:o.SLOT,editable:!0,focusable:!0,navigable:!0,sortable:!0}),new ct(this.editor),new ht(this.editor),new at(this.editor),new st(this.editor),new it(this.editor),new rt(this.editor),new nt(this.editor),new lt(this.editor),new J(this.editor),new ot(this.editor),new dt(this.editor),this.editor.filters.add(new tt(this.editor)),this.#t(),this.#e(),this.#r()}#t(){let t={[x.NONE]:"No alignment",[x.LEFT]:"Align left",[x.CENTER]:"Align center",[x.RIGHT]:"Align right"};Object.entries(t).forEach(([e,i])=>{let n=new X(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}#e(){let t={[E.FIRST]:"Sort to the beginning",[E.PREV]:"Sort before previous element",[E.NEXT]:"Sort after next element",[E.LAST]:"Sort to the end"};Object.entries(t).forEach(([e,i])=>{let n=new mt(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}#r(){this.editor.commands.set(new et(this.editor)),this._focusbar("Delete","delete")}};var D=class extends d{static get name(){return"abbreviation"}static get dependencies(){return[m]}init(){this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Z(this.editor)),this._command(r.ABBR),this._formatbar("Abbreviation",a.A)}};var ut=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Audio")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to audio"),required:"required"}).addTextInput("id",this._("ID"))}};var ft=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.AUDIO)).forEach(e=>this.#t(e))}insertaudio({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:H.name}})):t.parentElement.removeChild(t)}};var pt=class extends A{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var gt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertfigure",this)}insertfigure({detail:{element:t}}){t.querySelector(":scope > "+r.FIGCAPTION)||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.FIGCAPTION),t)}};var R=class extends d{static get name(){return"figure"}static get dependencies(){return[m]}init(){this._tag({name:r.FIGURE,group:o.FIGURE,children:[o.AUDIO,o.CAPTION,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.TABLE,o.VIDEO],attributes:["class"],alignable:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag({name:r.FIGCAPTION,group:o.CAPTION,children:[o.FORMAT],editable:!0,navigable:!0,enter:r.P}),new gt(this.editor),this.editor.filters.add(new pt(this.editor))}};var H=class extends d{static get name(){return"audio"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new ft(this.editor),this.editor.dialogs.set(new ut(this.editor,this.constructor.name,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar("Audio")}};var Et=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var bt=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super(),this.attachShadow({mode:"open"})}};var Tt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock({detail:{element:t}}){if(!t.id){t.parentElement.removeChild(t);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.id),i=await fetch(e,{mode:"no-cors"});if(!i.ok)return;let n="";this.editor.config.block.css&&(n=this.editor.config.block.css.split(",").map(c=>`<link rel="stylesheet" href="${c}">`).join(""));let l=await i.text();t.content=n+l}};var Lt=class extends d{static get name(){return"block"}static get dependencies(){return[m]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this.editor.dom.registerElement(r.BLOCK,bt),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new Tt(this.editor),this.editor.dialogs.set(new Et(this.editor,this.constructor.name,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar("Block")}};var At=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.BLOCKQUOTE),t),t.parentElement.removeChild(t))}};var xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:C.name}})}deleteblockquote({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.parentElement.removeChild(t)}};var Rt=class extends A{filter(t){if(t instanceof HTMLPreElement){t.outerHTML=t.outerHTML.replace(/(<br\s*\/?>)/gi,`
|
|
2
|
-
`);return}t.innerHTML=t.innerHTML.replace(/^\s*(<br\s*\/?>\s*)+/gi,"").replace(/\s*(<br\s*\/?>\s*)+$/gi,""),t instanceof HTMLParagraphElement?t.outerHTML=t.outerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"</p><p>"):t.innerHTML=t.innerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"<br>")}};var w=class extends d{static get name(){return"break"}static get dependencies(){return[m]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new Rt(this.editor))}};var C=class extends d{static get name(){return"blockquote"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new xt(this.editor),this._command(r.BLOCKQUOTE),this._toolbar("Blockquote"),this.editor.filters.add(new At(this.editor))}};var wt=class extends d{static get name(){return"bold"}static get dependencies(){return[m]}init(){this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar("bold",a.B)}};var Ot=class extends d{static get name(){return"cite"}static get dependencies(){return[m]}init(){this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar("Citation",a.Z)}};var It=class extends d{static get name(){return"code"}static get dependencies(){return[m]}init(){this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar("Code",a.C)}};var yt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Ct=class extends d{static get name(){return"data"}static get dependencies(){return[m]}init(){this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new yt(this.editor,this.constructor.name)),this._command(r.DATA),this._formatbar("Data",a.J)}};var Nt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var _t=class extends d{static get name(){return"definition"}static get dependencies(){return[m]}init(){this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Nt(this.editor,this.constructor.name)),this._command(r.DFN),this._formatbar("Definition",a.D)}};var Mt=class extends d{static get name(){return"deletion"}static get dependencies(){return[m]}init(){this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar("Text Deletion",a.G)}};var St=class extends A{filter(t){t.querySelectorAll(`${r.SUMMARY}:not(:first-child)`).forEach(e=>e.parentElement.removeChild(e)),t.querySelectorAll(`${r.SUMMARY}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var vt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails({detail:{element:t}}){t.open=!0,t.querySelector(`:scope > ${r.SUMMARY}:first-child`)||this.editor.dom.insertFirstChild(this.editor.dom.createElement(r.SUMMARY),t)}insertsummary({detail:{element:t}}){this.#t(t),t.addEventListener("click",this),t.addEventListener("blur",this),t.addEventListener("keydown",this)}click(t){t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0}blur({target:t}){this.#t(t)}keydown(t){a.isEventFor(t,a.SPACE)?(t.preventDefault(),t.stopPropagation(),this.editor.dom.insertText(" ")):a.isEventFor(t,a.ENTER)&&(t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0)}#t(t){t.textContent.trim()?t.querySelectorAll(r.BR+":not(:last-child)").forEach(e=>e.parentElement.removeChild(e)):t.textContent=this._("Details"),t.lastElementChild instanceof HTMLBRElement||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.BR),t)}};var Bt=class extends d{static get name(){return"details"}static get dependencies(){return[m]}init(){this._tag({name:r.DETAILS,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.SUMMARY,o.TABLE,o.VIDEO],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this._tag({name:r.SUMMARY,group:o.SUMMARY,editable:!0,navigable:!0,enter:r.P}),new vt(this.editor),this._command(r.DETAILS),this._toolbar("Details"),this.editor.filters.add(new St(this.editor))}};var Ft=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var Dt=class extends d{static get name(){return"division"}static get dependencies(){return[m]}init(){this._tag({name:r.DIV,group:o.CONTAINER,children:[o.AUDIO,o.BLOCK,o.FIGURE,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new Ft(this.editor,this.constructor.name)),this._command(r.DIV),this._toolbar("Division")}};var Ht=class extends d{static get name(){return"emphasis"}static get dependencies(){return[m]}init(){this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar("emphasized",a.E)}};var Pt=class extends d{static get name(){return"heading"}static get dependencies(){return[m]}init(){this._tag({name:r.H2,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H2),this._toolbar("Heading")}};var Ut=class extends d{static get name(){return"horizontalrule"}static get dependencies(){return[m]}init(){this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar("Horizontal Rule")}};var ve={"CSS class":"CSS-Klasse",Height:"H\xF6he",ID:"ID","Insert CSS class":"CSS-Klasse eingeben",URL:"URL",Width:"Breite",Abbreviation:"Abk\xFCrzung","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Audio:"Audio","Insert URL to audio":"URL zur Audiodatei eingeben","Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig",Alt:"Alt",Cancel:"Abbrechen",Delete:"L\xF6schen","No alignment":"Keine Ausrichtung",Save:"Speichern",Shift:"Umschalt","Sort after next element":"Hinter das n\xE4chste Element sortieren","Sort before previous element":"Vor das vorherige Element sortieren","Sort to the beginning":"An den Anfang sortieren","Sort to the end":"Ans Ende sortieren",Block:"Block",Blockquote:"Blockzitat",bold:"fett",Citation:"Zitatquelle",Code:"Quelltext",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff","Text Deletion":"Textl\xF6schung",Details:"Details",Division:"Division",emphasized:"betont",Heading:"\xDCberschrift","Horizontal Rule":"Horizontale Linie",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben","Alternative text":"Alternativtext",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist","Text Insertion":"Texteinf\xFCgung",italic:"kursiv","User Input":"Benutzereingabe","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",mark:"markiert","Ordered List":"Geordnete Liste",Paragraph:"Absatz","Preformatted Text":"Vorformatierter Text",Quote:"Zitat","Sample Output":"Beispielausgabe",Section:"Sektion",small:"klein",strikethrough:"durchgestrichen","strongly emphasized":"stark betont",Subheading:"Unter\xFCberschrift",subscript:"tiefgestellt",superscript:"hochgestellt","Add column":"Spalte hinzuf\xFCgen","Add row":"Zeile hinzuf\xFCgen",Columns:"Spalten",Rows:"Zeilen",Table:"Tabelle","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Time:"Zeit",underline:"unterstrichen","Unordered List":"Ungeordnete Liste",Variable:"Variable","Insert URL to video":"URL zur Videodatei eingeben",Video:"Video"};var Gt=class extends d{static get name(){return"i18n"}static get dependencies(){return[m]}init(){this._i18n({de:ve})}};var kt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Iframe")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to embedded page"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Kt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IFRAME)).forEach(e=>this.#t(e))}insertiframe({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.allowFullscreen=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:P.name}})):t.parentElement.removeChild(t)}};var P=class extends d{static get name(){return"iframe"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new Kt(this.editor),this.editor.dialogs.set(new kt(this.editor,this.constructor.name,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar("Iframe")}};var Wt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Image")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to image"),required:"required"}).addTextInput("alt",this._("Alternative text"),{placeholder:this._("Text shown when media element is not available")}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var zt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IMG)).forEach(e=>this.#t(e))}insertimg({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:U.name}})):t.parentElement.removeChild(t)}};var U=class extends d{static get name(){return"image"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new zt(this.editor),this.editor.dialogs.set(new Wt(this.editor,this.constructor.name,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar("Image")}};var qt=class extends d{static get name(){return"insertion"}static get dependencies(){return[m]}init(){this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar("Text Insertion",a.F)}};var jt=class extends d{static get name(){return"italic"}static get dependencies(){return[m]}init(){this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar("italic",a.I)}};var Vt=class extends d{static get name(){return"keyboard"}static get dependencies(){return[m]}init(){this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar("User Input",a.K)}};var $t=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var Qt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.A)).forEach(e=>this.#t(e))}inserta({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("href");e?t.setAttribute("href",this.editor.url(e)):t.parentElement.replaceChild(this.editor.dom.createText(t.textContent),t)}};var Yt=class extends d{static get name(){return"link"}static get dependencies(){return[m]}init(){this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new Qt(this.editor),this.editor.dialogs.set(new $t(this.editor,this.constructor.name)),this._command(r.A),this._formatbar("Link",a.L)}};var Zt=class extends d{static get name(){return"mark"}static get dependencies(){return[m]}init(){this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar("mark",a.M)}};var Xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertli",this),this.editor.root.addEventListener("deleteli",this),this.editor.root.addEventListener("insertol",this),this.editor.root.addEventListener("insertul",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.LI)).forEach(e=>this.#t(e))}insertli({detail:{element:t}}){this.#t(t)}deleteli({detail:{target:t}}){t.children.length===0&&t.parentElement.removeChild(t)}insertol({detail:{element:t}}){this.#e(t)}insertul({detail:{element:t}}){this.#e(t)}#t(t){!(t.parentElement instanceof HTMLOListElement)&&!(t.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(t,r.UL)}#e(t){t.children.length===0&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LI),t)}};var G=class extends d{static get name(){return"list"}static get dependencies(){return[m,w]}init(){this._tag({name:r.LI,group:o.LISTITEM,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.LI}),new Xt(this.editor)}};var Jt=class extends d{static get name(){return"orderedlist"}static get dependencies(){return[m,G]}init(){this._tag({name:r.OL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.OL),this._toolbar("Ordered List")}};var te=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.P)).forEach(e=>e.addEventListener("paste",this))}insertp({detail:{element:t}}){t.addEventListener("paste",this)}paste({target:t}){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(t))}};var ee=class extends d{static get name(){return"paragraph"}static get dependencies(){return[m,w]}init(){this._tag({name:r.P,group:o.PARAGRAPH,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),new te(this.editor),this._command(r.P),this._toolbar("Paragraph")}};var re=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.PRE),t),t.parentElement.removeChild(t))}};var ie=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:N.name}})}deletepre({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.parentElement.removeChild(t)}};var N=class extends d{static get name(){return"preformat"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new ie(this.editor),this._command(r.PRE),this._toolbar("Preformatted Text"),this.editor.filters.add(new re(this.editor))}};var oe=class extends d{static get name(){return"quote"}static get dependencies(){return[m]}init(){this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar("Quote",a.Q)}};var se=class extends d{static get name(){return"sample"}static get dependencies(){return[m]}init(){this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar("Sample Output",a.O)}};var ae=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var ne=class extends d{static get name(){return"section"}static get dependencies(){return[m]}init(){this._tag({name:r.SECTION,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new ae(this.editor,this.constructor.name)),this._command(r.SECTION),this._toolbar("Section")}};var de=class extends d{static get name(){return"small"}static get dependencies(){return[m]}init(){this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar("small",a.W)}};var me=class extends d{static get name(){return"strikethrough"}static get dependencies(){return[m]}init(){this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar("strikethrough",a.R)}};var le=class extends d{static get name(){return"strong"}static get dependencies(){return[m]}init(){this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar("strongly emphasized",a.S)}};var ce=class extends d{static get name(){return"subheading"}static get dependencies(){return[m]}init(){this._tag({name:r.H3,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H3),this._toolbar("Subheading")}};var he=class extends d{static get name(){return"subscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar("subscript",a.X)}};var ue=class extends d{static get name(){return"superscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar("superscript",a.Y)}};var fe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttd({detail:{element:t}}){t.addEventListener("keydown",this)}insertth({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){let e=t.target,i=e.parentElement,n=e.closest(r.TABLE);if(e instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&n instanceof HTMLTableElement&&a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.ARROWUP,a.ARROWDOWN])&&this.#t(e,t.key)){let l=e.cellIndex,c=i.cells.length,u=l===0,f=l===c-1,g=i.rowIndex===0,O=i.rowIndex===n.rows.length-1;t.preventDefault(),t.stopPropagation(),t.key===a.ARROWLEFT&&!u?this.editor.dom.focusEnd(i.cells[l-1]):t.key===a.ARROWLEFT&&g?this.editor.dom.focusEnd(n.rows[n.rows.length-1].cells[c-1]):t.key===a.ARROWLEFT?this.editor.dom.focusEnd(n.rows[i.rowIndex-1].cells[c-1]):t.key===a.ARROWRIGHT&&!f?i.cells[l+1].focus():t.key===a.ARROWRIGHT&&O?n.rows[0].cells[0].focus():t.key===a.ARROWRIGHT?n.rows[i.rowIndex+1].cells[0].focus():t.key===a.ARROWUP&&g?n.rows[n.rows.length-1].cells[l].focus():t.key===a.ARROWUP?n.rows[i.rowIndex-1].cells[l].focus():t.key===a.ARROWDOWN&&O?n.rows[0].cells[l].focus():t.key===a.ARROWDOWN&&n.rows[i.rowIndex+1].cells[l].focus()}}#t(t,e){if([a.ARROWUP,a.ARROWDOWN].includes(e))return!0;let i=this.editor.dom.getSelection(),n=i.anchorNode instanceof HTMLElement?i.anchorNode:t;if(!i.isCollapsed)return!1;if(e===a.ARROWLEFT){let c=t.firstChild;return c instanceof HTMLElement&&(c=c.firstChild),i.anchorOffset===0&&[t,c].includes(n)}let l=t.lastChild;return t.lastChild instanceof HTMLBRElement&&t.lastChild.previousSibling&&(l=t.lastChild.previousSibling),l instanceof HTMLElement&&(l=l.lastChild),i.anchorOffset===n.textContent.length&&[t,l].includes(n)}};var pe=class extends T{constructor(t){super(t,"tablecolumn-add")}execute(){let t=this.editor.dom.getActiveElement();t?.localName===r.COL&&this.editor.dom.createTableColumnAfter(t)}};var ge=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertcol",this)}insertcol({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){a.isEventFor(t,a.ENTER)?this.editor.dom.createTableColumnAfter(t.target):a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var Ee=class extends T{constructor(t){super(t,y.name,r.TABLE)}_insert({rows:t,cols:e}={}){this.editor.dom.insert(this.editor.dom.createTable(parseInt(t,10)||1,parseInt(e,10)||1))}};var be=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Table")).addNumberInput("rows",this._("Rows"),{min:"1",required:"required",value:"1"}).addNumberInput("cols",this._("Columns"),{min:"1",required:"required",value:"1"})}};var Te=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(y.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.TABLE),t),t.parentElement.removeChild(t)):(t instanceof HTMLTableElement&&t.querySelector(`:scope > ${r.THEAD}, :scope > ${r.TFOOT}`)&&!t.querySelector(":scope > "+r.TBODY)||t instanceof HTMLTableSectionElement&&t.rows.length<=0||t instanceof HTMLTableRowElement&&!t.querySelector(`:scope > ${r.TH}:not(:empty), :scope > ${r.TD}:not(:empty)`))&&t.parentElement.removeChild(t)}};var Le=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttable",this)}inserttable({detail:{element:t}}){if(this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:y.name}}),t.tBodies.length>0&&t.tBodies[0].rows[0]){let e=t.tBodies[0],i=e.rows[0].cells.length;t.querySelector(":scope > "+r.COLGROUP)||this.editor.dom.insertFirstChild(this.editor.dom.createTableColumnGroup(i),t),t.tHead||this.editor.dom.insertBefore(this.editor.dom.createTableHeader(1,i),e),t.tFoot||this.editor.dom.insertLastChild(this.editor.dom.createTableFooter(1,i),t)}}};var Ae=class extends T{constructor(t){super(t,"tablerow-add")}execute(){let t=this.editor.dom.getActiveElement();t instanceof HTMLTableRowElement&&this.editor.dom.createTableRowAfter(t)}};var xe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttr",this)}inserttr({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){a.isEventFor(t,a.ENTER)?this.editor.dom.createTableRowAfter(t.target):a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var y=class extends d{static get name(){return"table"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag({name:r.COLGROUP,group:o.COLGROUP,children:[o.COL]}),this._tag({name:r.COL,group:o.COL,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#t(r.THEAD)),this._tag(this.#t(r.TBODY)),this._tag(this.#t(r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL],deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#e(r.TH)),this._tag(this.#e(r.TD)),new Le(this.editor),new ge(this.editor),new xe(this.editor),new fe(this.editor),this.editor.filters.add(new Te(this.editor)),this.editor.dialogs.set(new be(this.editor,this.constructor.name)),this.editor.commands.set(new Ee(this.editor)),this.editor.commands.set(new pe(this.editor)),this.editor.commands.set(new Ae(this.editor)),this._toolbar("Table"),this._focusbar("Add column","tablecolumn-add"),this._focusbar("Add row","tablerow-add")}#t(t){return{name:t,group:o.TABLESECTION,children:[o.TABLEROW]}}#e(t){return{name:t,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}}};var Re=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var we=class extends d{static get name(){return"time"}static get dependencies(){return[m]}init(){this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new Re(this.editor,this.constructor.name)),this._command(r.TIME),this._formatbar("Time",a.T)}};var Oe=class extends d{static get name(){return"underline"}static get dependencies(){return[m]}init(){this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar("underline",a.U)}};var Ie=class extends d{static get name(){return"unorderedlist"}static get dependencies(){return[m,G]}init(){this._tag({name:r.UL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.UL),this._toolbar("Unordered List")}};var ye=class extends d{static get name(){return"variable"}static get dependencies(){return[m]}init(){this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar("Variable",a.V)}};var Ce=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Video")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to video"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Ne=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.VIDEO)).forEach(e=>this.#t(e))}insertvideo({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:k.name}})):t.parentElement.removeChild(t)}};var k=class extends d{static get name(){return"video"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new Ne(this.editor),this.editor.dialogs.set(new Ce(this.editor,this.constructor.name,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar("Video")}};var Se=class extends L{static get defaultConfig(){return{base:{plugins:[Gt,wt,jt,le,Ht,Oe,me,Yt,Zt,de,_t,D,oe,Ot,It,Vt,se,ye,he,ue,we,Ct,qt,Mt,ee,Pt,ce,Ie,Jt,Ut,C,U,k,H,P,y,N,ne,Bt,Dt,Lt]}}}};export{Se as default};
|
|
1
|
+
var o=Object.freeze({AUDIO:"audio",BLOCK:"block",BREAK:"break",CAPTION:"caption",COL:"col",COLGROUP:"colgroup",CONTAINER:"container",FIGURE:"figure",FORMAT:"format",HEADING:"heading",IFRAME:"iframe",IMAGE:"image",LIST:"list",LISTITEM:"listitem",PARAGRAPH:"paragraph",PREFORMAT:"preformat",QUOTE:"quote",ROOT:"root",RULE:"rule",SLOT:"slot",SUMMARY:"summary",TABLE:"table",TABLECELL:"tablecell",TABLEROW:"tablerow",TABLESECTION:"tablesection",VIDEO:"video"});function F(s){return typeof s<"u"}function j(s){return typeof s=="function"}function E(s){return s&&typeof s=="string"}function v(s){return!F(s)||E(s)}function ve(s){return!F(s)||Array.isArray(s)&&s.length>0}function De(s){return!F(s)||s instanceof HTMLElement}var A=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get tag(){return this.#r}#o;get dialog(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof x)||!E(e)||!v(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i&&this.editor.tags.get(i),this.#o=this.editor.dialogs.get(e)}execute(){this.dialog?this._openDialog():this._insert(this.#s())}_insert(t={}){if(!this.tag)return;this.#i(t);let e=this.editor.dom.getSelectedElementByName(this.tag.name);this.tag.group!==o.FORMAT?this.editor.dom.insert(this.editor.dom.createElement(this.tag.name,{attributes:t})):e&&Object.keys(t).length>0?e.parentElement.replaceChild(this.editor.dom.createElement(this.tag.name,{attributes:t,html:e.textContent}),e):e?e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e):this.editor.dom.format(this.editor.dom.createElement(this.tag.name,{attributes:t}))}_openDialog(){this.dialog?.open(t=>this._insert(t),this.#s())}#s(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return this.#i(t),t}#i(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])}};var q=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof A))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}findByTagName(t){return Array.from(this.#t.values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var V=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof p))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var r=Object.freeze({A:"a",ABBR:"abbr",ALL:"*",AUDIO:"audio",B:"b",BLOCK:"app-block",BLOCKQUOTE:"blockquote",BR:"br",BUTTON:"button",CITE:"cite",CODE:"code",COL:"col",COLGROUP:"colgroup",DATA:"data",DEL:"del",DETAILS:"details",DFN:"dfn",DIALOG:"dialog",DIV:"div",EDITOR:"akilli-editor",EM:"em",FIELDSET:"fieldset",FIGCAPTION:"figcaption",FIGURE:"figure",FOCUSBAR:"editor-focusbar",FORM:"form",FORMATBAR:"editor-formatbar",H2:"h2",H3:"h3",HR:"hr",I:"i",IFRAME:"iframe",IMG:"img",INPUT:"input",INS:"ins",KBD:"kbd",LABEL:"label",LEGEND:"legend",LI:"li",MARK:"mark",OL:"ol",P:"p",PRE:"pre",Q:"q",ROOT:"editor-root",S:"s",SAMP:"samp",SECTION:"section",SLOT:"slot",SMALL:"small",STRONG:"strong",SUB:"sub",SUMMARY:"summary",SUP:"sup",TABLE:"table",TBODY:"tbody",TD:"td",TFOOT:"tfoot",TH:"th",THEAD:"thead",TIME:"time",TOOLBAR:"editor-toolbar",TR:"tr",U:"u",UL:"ul",VAR:"var",VIDEO:"video"});var D=class{#t;constructor(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t=t,this.register(this.#r.bind(this))}dispatch(t,e=void 0,i=void 0){if(!E(t)||!De(e)||!De(i))throw new TypeError("Invalid argument");this.#t.dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!j(t))throw new TypeError("Invalid argument");new MutationObserver(t).observe(this.#t,e)}#e(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))}#r(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(this.#e("insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(a=>this.#e("insert",a,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&this.#e("delete",i,e.target))})}};var T=Object.freeze({FIRST:"first",PREV:"prev",NEXT:"next",LAST:"last"});var $=class{#t;get editor(){return this.#t}#e;get document(){return this.#e}#r;get window(){return this.#r}#o;get root(){return this.#o}#s={alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""};constructor(t,e){if(!(t instanceof x)||!(e instanceof Document))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=this.document.defaultView,this.#o=this.document.documentElement}registerElement(t,e,i=void 0){F(this.window.customElements.get(t))||this.window.customElements.define(t,e,i?{extends:i}:void 0)}createElement(t,{attributes:e={},html:i=""}={}){let a=this.document.createElement(t);return a.innerHTML=i,Object.entries(e).forEach(([l,c])=>c&&a.setAttribute(l,`${c}`)),a}insert(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))this.insertBefore(t,e);else if(e){let i=this.closest(e,t);i&&this.insertAfter(t,i),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e)}else if(this.editor.tags.allowed(this.editor.root,t))this.insertLastChild(t,this.editor.root);else throw new TypeError("Invalid argument")}insertText(t){let e=this.getSelectedEditable();if(e){let i=this.getRange();i.deleteContents(),i.insertNode(this.createText(t)),i.collapse(),e.normalize()}}format(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getRange(),i=this.getSelectedEditable();if(!e||e.collapsed||!e.toString().trim()||!i||!this.editor.tags.allowed(i,t))return;e.startContainer instanceof Text&&e.startContainer.parentElement!==i&&e.setStartBefore(e.startContainer.parentElement),e.endContainer instanceof Text&&e.endContainer.parentElement!==i&&e.setEndAfter(e.endContainer.parentElement);let a=e.toString(),l=Array.from(e.cloneContents().childNodes).every(c=>c instanceof Text&&!c.textContent.trim()||c instanceof HTMLElement&&c.localName===t.localName);e.deleteContents(),l?e.insertNode(this.createText(a)):(t.textContent=a,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}createTable(t=1,e=1){let i=this.createElement(r.TABLE);return this.insertLastChild(this.createTableHeader(1,e),i),this.insertLastChild(this.createTableBody(t,e),i),this.insertLastChild(this.createTableFooter(1,e),i),i}createTableColumnGroup(t=1){let e=this.createElement(r.COLGROUP);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.COL),e);return e}createTableHeader(t=1,e=1){return this.#i(r.THEAD,t,e)}createTableBody(t=1,e=1){return this.#i(r.TBODY,t,e)}createTableFooter(t=1,e=1){return this.#i(r.TFOOT,t,e)}createTableHeaderRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TH),e);return e}createTableRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TD),e);return e}createTableRowAfter(t){if(!(t instanceof HTMLTableRowElement))throw new TypeError("Invalid argument");this.insertAfter(this.createTableRow(t.cells.length),t)}createTableColumnAfter(t){if(!(t instanceof HTMLTableColElement)||t.localName!==r.COL)throw new TypeError("Invalid argument");let e=t.parentElement,i=e.parentElement,a=Array.from(e.children).indexOf(t);Array.from(i.rows).forEach(l=>this.insertAfter(this.createElement(l.cells[a].localName),l.cells[a])),this.insertAfter(this.createElement(r.COL),t)}sort(t,e){if(!(t instanceof HTMLElement)||!Object.values(T).includes(e))throw new TypeError("Invalid argument");if(t.parentElement.children.length<=1)return;let i=t.parentElement,a=i.parentElement,l=t.previousElementSibling,c=t.nextElementSibling,f=i.firstElementChild,u=i.lastElementChild,g=t===f,I=t===u,B=t.localName===r.COL,W=Array.from(i.children).indexOf(t);e===T.PREV&&!g&&l.hasAttribute("data-sortable")?(B&&Array.from(a.rows).forEach(C=>this.insertBefore(C.cells[W],C.cells[W-1])),this.insertBefore(t,l)):e===T.NEXT&&!I&&c.hasAttribute("data-sortable")?(B&&Array.from(a.rows).forEach(C=>this.insertAfter(C.cells[W],C.cells[W+1])),this.insertAfter(t,c)):(e===T.FIRST&&!g||e===T.NEXT&&I)&&f.hasAttribute("data-sortable")?(B&&Array.from(a.rows).forEach(C=>this.insertFirstChild(C.cells[W],C)),this.insertBefore(t,f)):(e===T.LAST&&!I||e===T.PREV&&g)&&u.hasAttribute("data-sortable")&&(B&&Array.from(a.rows).forEach(C=>this.insertLastChild(C.cells[W],C)),this.insertAfter(t,u))}insertBefore(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforebegin",t)}insertAfter(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterend",t)}insertFirstChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterbegin",t)}insertLastChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforeend",t)}delete(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if([r.COL,r.TR].includes(t.localName)&&t.matches(":only-child"))return;if(t.localName===r.COL){let a=Array.from(t.parentElement.children).indexOf(t),l=t.parentElement.parentElement;Array.from(l.rows).forEach(c=>c.removeChild(c.cells[a]))}let e=t.previousElementSibling,i=t.nextElementSibling;t===this.getActiveElement()&&t.blur(),t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if(this.editor.root.contains(t))return!0;let e=t.closest(this.editor.root.localName);return e&&!e.parentElement}closest(t,e){if(!(t instanceof HTMLElement)||!this.contains(t.parentElement))throw new TypeError("Invalid argument");let i=t,a=t.parentElement;do if(this.arbitrary(a)&&this.editor.tags.allowed(a,e))return i;while((i=a)&&(a=a.parentElement)&&this.contains(a))}wrap(t,e,i={}){let a;if(t instanceof HTMLElement){if(t.parentElement.localName!==e&&(a=this.closest(t,e))){let l=this.createElement(e,i);this.insertAfter(l,a),this.insertLastChild(t,l)}}else throw new TypeError("Invalid argument")}getActiveElement(){let t=this.document.activeElement;return t&&this.contains(t)?t:void 0}getSelectedElement(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement&&e===i&&this.contains(e))return e}getSelectedElementByName(t){let e=this.getSelectedElement();return e?.localName===t?e:void 0}getSelectedAttributesByName(t){let e=this.getSelectedElementByName(t),i={};return e&&Array.from(e.attributes).forEach(a=>i[a.nodeName]=a.nodeValue),i}getSelectedEditable(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement){let a=e.closest("[contenteditable=true]"),l=i.closest("[contenteditable=true]");if(a instanceof HTMLElement&&a===l&&this.contains(a))return a}}getSelection(){return this.window.getSelection()}getRange(){let t=this.getSelection();return t.rangeCount>0?t.getRangeAt(0):void 0}setRange(t){let e=this.getSelection();e.removeAllRanges(),e.addRange(t)}selectContents(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}removeClass(t,...e){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.classList.remove(...e),t.classList.length>0||t.removeAttribute("class")}open({url:t,name:e,call:i,params:a={}}){if(!E(t)||!E(e)||!j(i))throw new TypeError("Invalid argument");let l=this.createElement(r.A,{attributes:{href:t}}),c=new URL(l.href);Object.entries(a).forEach(([u,g])=>c.searchParams.set(u,`${g}`));let f=this.window.open(c.toString(),e,this.#a());this.window.addEventListener("message",u=>{u.origin===c.origin&&u.source===f&&(i(u.data),f.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}#i(t,e,i){let a=this.createElement(t);for(let l=0;l<e;l++)this.insertLastChild(t===r.THEAD?this.createTableHeaderRow(i):this.createTableRow(i),a);return a}#a(){let t=Object.assign({},this.#s,{height:`${this.getHeight()}`,width:`${this.getWidth()}`},this.editor.config.base.browser);return Object.entries(t).filter(([,e])=>!!e).map(([e,i])=>`${e}=${i}`).join(",")}};var w=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof x))throw new TypeError("Invalid argument");this.#t=t}filter(t){throw new Error("Not implemented")}};var Q=class{#t=new Set;add(t){if(!(t instanceof w))throw new TypeError("Invalid argument");this.#t.add(t)}filter(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t.forEach(e=>{t.normalize(),e.filter(t)})}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var H=class{name;group;children;attributes;alignable;arbitrary;deletable;editable;empty;focusable;navigable;slotable;sortable;enter;constructor({name:t,group:e,...i}={}){if(!E(t)||!E(e)||!ve(i.children)||!ve(i.attributes)||!v(i.enter))throw new TypeError("Invalid argument");this.name=t,this.group=e,this.children=i.children||[],this.attributes=i.attributes||[],this.arbitrary=i.arbitrary===!0,this.alignable=i.alignable===!0,this.deletable=i.deletable===!0,this.editable=i.editable===!0,this.empty=i.empty===!0,this.focusable=i.focusable===!0,this.navigable=i.navigable===!0,this.slotable=i.slotable===!0,this.sortable=i.sortable===!0,this.enter=i.enter}};var n=class{#t;get editor(){return this.#t}static get name(){throw new Error("Missing name")}static get dependencies(){return[]}static get config(){return{}}constructor(t){if(!(t instanceof x))throw new TypeError("Invalid argument");this.#t=t}init(){throw new Error("Not implemented")}_(t){return this.editor.translate(t)}_i18n(t){t[this.editor.config.base.lang]&&(this.editor.i18n=t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new H(t))}_command(t){this.editor.commands.set(new A(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.toolbar)}_formatbar(t,e=void 0,i=void 0){let a=this._(t),l=this._("Alt"),c=this._("Shift"),f=a+(e?` [${l} + ${c} + ${e}]`:"");this.editor.dom.insertLastChild(this.#e(a,f,e,i),this.editor.formatbar)}_focusbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.focusbar)}#e(t,e,i=void 0,a=void 0){if(!E(t)||!E(e)||!v(i))throw new TypeError("Invalid argument");return this.editor.dom.createElement(r.BUTTON,{attributes:{type:"button",title:e,"data-command":a||this.constructor.name,"data-key":i},html:t})}};var Y=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof n))throw new TypeError("Invalid argument");this.#t.set(t.constructor.name,t)}init(){this.#t.forEach(t=>t.init())}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var Z=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof H))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}allowed(t,e,i=!1){let a=i?e:this.get(e)?.group;return!!this.get(t)?.children.includes(a)}freeze(){this.#t.forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(this.#t),Object.freeze(this)}};var x=class{#t;get orig(){return this.#t}#e={};get config(){return this.#e}#r;get dom(){return this.#r}#o;get element(){return this.#o}#s;get toolbar(){return this.#s}#i;get toolbarDispatcher(){return this.#i}#a;get formatbar(){return this.#a}#d;get formatbarDispatcher(){return this.#d}#m;get focusbar(){return this.#m}#l;get focusbarDispatcher(){return this.#l}#c;get root(){return this.#c}#h;get rootDispatcher(){return this.#h}#n={};get i18n(){return this.#n}set i18n(t){this.#n={...this.#n,...t||{}}}#f=new Z;get tags(){return this.#f}#u=new Q;get filters(){return this.#u}#p=new V;get dialogs(){return this.#p}#g=new q;get commands(){return this.#g}#E=new Y;get plugins(){return this.#E}static get defaultConfig(){return{}}constructor(t,e={}){if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=new $(this,this.orig.ownerDocument),this.#o=this.dom.createElement(r.EDITOR),this.#s=this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}}),this.dom.insertLastChild(this.toolbar,this.element),this.#i=new D(this.toolbar),this.#a=this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}}),this.formatbar.hidden=!0,this.dom.insertLastChild(this.formatbar,this.element),this.#d=new D(this.formatbar),this.#m=this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}}),this.focusbar.hidden=!0,this.dom.insertLastChild(this.focusbar,this.element),this.#l=new D(this.focusbar),this.#c=this.dom.createElement(r.ROOT),this.dom.insertLastChild(this.root,this.element),this.#h=new D(this.root)}init(){let t=this.config;this.#e={};let e=this.constructor.defaultConfig.base?.plugins||[],i=e;if(Array.isArray(t.base?.plugins)&&t.base.plugins.length>0){let c=t.base.plugins;t.base?.pluginsDisabled?i=i.filter(f=>!c.includes(f.name)):(i=[],c.forEach(f=>{let u=e.find(g=>g.name===f);u&&i.push(u)}))}let a=new Set,l=c=>{c.dependencies?.forEach(l),a.add(c)};i.map(l),a.forEach(c=>{Object.entries(c.config).forEach(([f,u])=>{this.config[c.name]??={},this.config[c.name][f]=t[c.name]?.[f]||this.constructor.defaultConfig[c.name]?.[f]||u}),this.plugins.set(new c(this))}),this.config.base.lang&&(this.element.lang=this.config.base.lang),this.plugins.init(),this.toolbarDispatcher.dispatch("init"),this.formatbarDispatcher.dispatch("init"),this.focusbarDispatcher.dispatch("init"),this.rootDispatcher.dispatch("init")}freeze(){Object.freeze(this.config),Object.freeze(this.i18n),this.tags.freeze(),this.filters.freeze(),this.dialogs.freeze(),this.commands.freeze(),this.plugins.freeze()}load(){this.orig instanceof HTMLTextAreaElement?(this.orig.form.addEventListener("submit",()=>this.save()),this.setHtml(this.orig.value.replace("/ /g"," "))):this.setHtml(this.orig.innerHTML),this.dom.insertAfter(this.element,this.orig),this.orig.hidden=!0,this.rootDispatcher.dispatch("load")}destroy(){this.element.parentElement.removeChild(this.element),this.orig.hidden=!1,this.rootDispatcher.dispatch("destroy")}getHtml(){let t=this.dom.createElement(this.root.localName,{html:this.root.innerHTML});return this.filters.filter(t),this.rootDispatcher.dispatch("gethtml",t),t.innerHTML}setHtml(t){let e=this.dom.createElement(this.root.localName,{html:t});this.rootDispatcher.dispatch("sethtml",e),this.filters.filter(e),this.root.innerHTML=e.innerHTML}save(){this.orig instanceof HTMLTextAreaElement?this.orig.value=this.getHtml():this.orig.innerHTML=this.getHtml(),this.rootDispatcher.dispatch("save")}translate(t){return this.i18n[t]||t}url(t){let e=this.dom.window.origin||this.dom.window.location.origin,i=this.dom.createElement(r.A,{attributes:{href:t}});return e===i.origin?i.pathname:i.href}static create(t,e={}){let i=new this(t,e);return i.init(),i.freeze(),i.load(),i}};var X=class{#t;get editor(){return this.#t}#e;get form(){return this.#e}#r;constructor(t){if(!(t instanceof x))throw new TypeError("Invalid argument");this.#t=t,this.#e=this.editor.dom.createElement(r.FORM,{attributes:{method:"dialog"}}),this.addFieldset().#o().#s()}addFieldset(){let t=this.editor.dom.createElement(r.FIELDSET);return this.#r?this.editor.dom.insertAfter(t,this.#r):this.editor.dom.insertFirstChild(t,this.#e),this.#r=t,this}addLegend(t){if(!E(t))throw new TypeError("Invalid argument");return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LEGEND,{html:t}),this.#r),this}addTextInput(t,e,i={}){return this.addInput(t,e,i,"text")}addNumberInput(t,e,i={}){return this.addInput(t,e,i,"number")}addInput(t,e,i={},a="text"){if(!E(t)||!E(e)||!E(a))throw new TypeError("Invalid argument");Object.assign(i,{id:`editor-${t}`,name:t,type:a});let l=this.editor.dom.createElement(r.DIV);return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LABEL,{attributes:{for:i.id},html:e}),l),this.editor.dom.insertLastChild(this.editor.dom.createElement(r.INPUT,{attributes:i}),l),i.required&&l.setAttribute("data-required",""),this.editor.dom.insertLastChild(l,this.#r),this}#o(){let t=this.#i("Cancel"),e=this.editor.dom.createElement(r.BUTTON,{attributes:{type:"reset"},html:t});return this.editor.dom.insertLastChild(e,this.#e),this}#s(){let t=this.editor.dom.createElement(r.BUTTON,{html:this.#i("Save")});return this.editor.dom.insertLastChild(t,this.#e),this}#i(t){return this.editor.translate(t)}};var p=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get browserUrl(){return this.#r}#o;get formCreator(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof x)||!E(e)||!v(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i}open(t,e={}){this.browserUrl?this.#s(t,e):this.#i(t,e)}_(t){return this.editor.translate(t)}_prepareForm(){throw new Error("Not implemented")}#s(t,e={}){this.editor.dom.open({url:this.browserUrl,name:this.name,call:t,params:e})}#i(t,e={}){let i=this.editor.dom.getRange();this.#a();let a=this.editor.dom.createElement(r.DIALOG);a.addEventListener("click",c=>c.target===a&&a.close()),a.addEventListener("close",()=>{i&&this.editor.dom.setRange(i),a.returnValue&&t(JSON.parse(a.returnValue)),this.#a()}),this.editor.dom.insertLastChild(a,this.editor.element),this.#o=new X(this.editor),this._prepareForm();let l=this.formCreator.form;l.addEventListener("submit",()=>a.close(JSON.stringify(Object.fromEntries(new FormData(l))))),l.addEventListener("reset",()=>a.close()),new FormData(l).forEach((c,f)=>F(e[f])&&(l.elements[f].value=e[f])),this.editor.dom.insertLastChild(l,a),a.showModal()}#a(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})}};var J=class extends p{constructor(t){super(t,P.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var R=Object.freeze({NONE:"none",LEFT:"left",CENTER:"center",RIGHT:"right"});var tt=class extends A{#t;constructor(t,e){if(!Object.values(R).includes(e))throw new TypeError("Invalid argument");super(t,"align-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-alignable")&&(this.editor.dom.removeClass(t,...Object.values(R)),this.#t!==R.NONE&&t.classList.add(this.#t))}};var h=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof x))throw new TypeError("Invalid argument");this.#t=t}handleEvent(t){j(this[t.type])&&this[t.type](t)}_(t){return this.editor.translate(t)}};var b=Object.freeze({A:"a",ARROWDOWN:"ArrowDown",ARROWLEFT:"ArrowLeft",ARROWRIGHT:"ArrowRight",ARROWUP:"ArrowUp",B:"b",BACKSPACE:"Backspace",C:"c",D:"d",DEL:"Delete",E:"e",END:"End",ENTER:"Enter",F:"f",G:"g",HOME:"Home",I:"i",J:"j",K:"k",L:"l",M:"m",O:"o",Q:"q",R:"r",S:"s",SPACE:" ",T:"t",TAB:"Tab",U:"u",V:"v",W:"w",X:"x",Y:"y",Z:"z"}),d=b,je=Object.freeze([b.ARROWLEFT,b.ARROWRIGHT,b.ARROWUP,b.ARROWDOWN]),qe=Object.freeze([b.HOME,b.ARROWUP,b.ARROWDOWN,b.END]),Ve=Object.freeze([b.HOME,b.ARROWLEFT,b.ARROWRIGHT,b.END]),Be=Object.freeze({[b.ARROWUP]:R.NONE,[b.ARROWLEFT]:R.LEFT,[b.ARROWDOWN]:R.CENTER,[b.ARROWRIGHT]:R.RIGHT}),Fe=Object.freeze({[b.HOME]:T.FIRST,[b.ARROWUP]:T.PREV,[b.ARROWDOWN]:T.NEXT,[b.END]:T.LAST});function L(s,t,{alt:e=!1,ctrl:i=!1,shift:a=!1}={}){return s.key===t&&s.altKey===e&&s.ctrlKey===i&&s.shiftKey===a}function et(s,t,{alt:e=!1,ctrl:i=!1,shift:a=!1}={}){return Array.isArray(t)&&t.includes(s.key)&&s.altKey===e&&s.ctrlKey===i&&s.shiftKey===a}function Pe(s){return et(s,je)}function Ue(s){return et(s,qe)}function Ge(s){return et(s,Ve)}function ke(s){return et(s,Object.keys(Be),{shift:!0})}function Ke(s){return et(s,Object.keys(Fe),{ctrl:!0})}function ze(s){return/^[A-Z]$/.test(s.key)&&L(s,s.key,{alt:!0,shift:!0})}var rt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-alignable")&&t.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&ke(t)&&(t.preventDefault(),t.stopPropagation(),this.editor.dom.removeClass(t.target,...Object.values(R)),Be[t.key]!==R.NONE&&t.target.classList.add(Be[t.key]))}};var it=class extends w{filter(t){let e=this.editor.tags.get(t),i=this.editor.tags.allowed(t,r.P),a=e.editable||e.group===o.FORMAT,l=[],c=(f=null)=>{if(i&&l.length>0){let u=this.editor.dom.createElement(r.P,{html:l.join(" ")});f?this.editor.dom.insertBefore(u,f):this.editor.dom.insertLastChild(u,t),l=[]}};Array.from(t.childNodes).forEach(f=>{let u=f.textContent.trim();if(f instanceof HTMLElement){let g=this.#t(f),I=this.editor.tags.get(g);if(I&&this.editor.tags.allowed(t,g))c(g),this.#e(g,I);else if(I&&I.group===o.FORMAT&&i){let B=this.#e(g,I);B&&(l.push(B.outerHTML),t.removeChild(B))}else!a&&u&&i?(l.push(u),t.removeChild(g)):a&&u?t.replaceChild(this.editor.dom.createText(u),g):t.removeChild(g)}else f instanceof Text?(!a&&u&&i&&l.push(u),(!a||!u)&&t.removeChild(f)):f instanceof Node&&t.removeChild(f)}),c()}#t(t){let e=this.editor.config.base.filter[t.localName];if(!e)return t;let i=this.editor.dom.createElement(e,{html:t.innerHTML});return t.parentElement.replaceChild(i,t),i}#e(t,e){if(Array.from(t.attributes).forEach(i=>!e.attributes.includes(i.name)&&t.removeAttribute(i.name)),t.hasChildNodes()&&this.editor.filters.filter(t),t.hasChildNodes()||e.empty)return t;t.parentElement?.removeChild(t)}};var ot=class extends A{constructor(t){super(t,"delete")}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var st=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-deletable")&&t.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&L(t,d.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var at=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.contentEditable==="true"?t.addEventListener("keydown",this):t.parentElement.contentEditable==="true"&&t.addEventListener("dblclick",this)}keydown(t){if(L(t,d.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(L(t,d.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;if(e){if(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")){let i=this.editor.dom.closest(t.target,e);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(e),i)}else if(!(t.target instanceof HTMLParagraphElement)){let i=this.editor.dom.closest(t.target,r.P);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(r.P),i),t.target.parentElement.removeChild(t.target)}}}else L(t,d.BACKSPACE)&&!t.target.textContent&&t.target.hasAttribute("data-deletable")?(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation()):ze(t)&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick({target:t}){this.editor.dom.selectContents(t),this.editor.commands.findByTagName(t.localName)?.execute()}};var nt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-focusable")&&t.focus()}};var S=class extends h{insertbutton({target:t,detail:{element:e}}){e.getAttribute("data-command")&&e.addEventListener("click",this),e.tabIndex=e===t.firstElementChild?0:-1,e.addEventListener("keydown",this)}click({target:t}){this.editor.commands.execute(t.getAttribute("data-command"))}keydown(t){if(Ge(t)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,a=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===a,f=t.target===l;t.key===d.ARROWLEFT&&!c?e.focus():t.key===d.ARROWRIGHT&&!f?i.focus():t.key===d.HOME||t.key===d.ARROWRIGHT&&f?a.focus():(t.key===d.END||t.key===d.ARROWLEFT&&c)&&l.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");t.hidden=!1;let{x:i,y:a}=e.getBoundingClientRect(),{x:l,y:c}=this.editor.root.getBoundingClientRect(),f=i-l+t.clientWidth-this.editor.root.clientWidth,u=a-c-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,g=t.clientWidth<this.editor.root.clientWidth?i-l:0;g>0&&f>0&&(g=g>f?(g-f)/2:0),t.style.left=`${g}px`,t.style.top=`${u}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var dt=class extends S{constructor(t){super(t),this.editor.focusbar.addEventListener("insertbutton",this),this.editor.root.addEventListener("focusin",this),this.editor.root.addEventListener("focusout",this),this.editor.dom.document.addEventListener("selectionchange",this)}insertbutton(t){super.insertbutton(t),t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("mousedown",this)}mousedown(t){t.preventDefault(),t.stopPropagation()}focusin({target:t}){t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}focusout(){this.#e()}selectionchange(){let t=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!t?this.#e():t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}#t(t){this.editor.focusbar.children.length&&(Object.keys(t.dataset).forEach(e=>this.editor.focusbar.dataset[e]=t.dataset[e]),this.editor.focusbar.dataset.tag=t.localName,this._show(this.editor.focusbar,t))}#e(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(t=>delete this.editor.focusbar.dataset[t])}};var mt=class extends S{constructor(t){super(t),this.editor.formatbar.addEventListener("insertbutton",this),this.editor.dom.document.addEventListener("selectionchange",this)}selectionchange(){let t=this.editor.dom.getSelectedEditable();t&&!this.editor.dom.getSelection().isCollapsed&&this.editor.tags.allowed(t,o.FORMAT,!0)?this._show(this.editor.formatbar,t):this._hide(this.editor.formatbar)}};var lt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-navigable")&&(t.tabIndex=0,t.addEventListener("keydown",this))}keydown(t){if(t.target===t.currentTarget&&Ue(t)&&this.#t(t.target)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,a=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===a,f=t.target===l;t.key===d.ARROWUP&&!c&&e.hasAttribute("data-navigable")?e.focus():t.key===d.ARROWDOWN&&!f&&i.hasAttribute("data-navigable")?i.focus():(t.key===d.HOME||t.key===d.ARROWDOWN&&f)&&a.hasAttribute("data-navigable")?a.focus():(t.key===d.END||t.key===d.ARROWUP&&c)&&l.hasAttribute("data-navigable")&&l.focus(),t.preventDefault(),t.stopPropagation()}}#t(t){if(t.contentEditable!=="true")return!0;let e=this.editor.dom.getSelection(),i=this.editor.dom.getSelectedEditable(),a=this.editor.dom.getSelectedElement();return e.isCollapsed&&e.anchorOffset===0&&[i,t.firstChild].includes(a)}};var ct=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t instanceof HTMLSlotElement?t.addEventListener("keydown",this):t.hasAttribute("data-slotable")&&!t.querySelector(":scope > "+r.SLOT)&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.SLOT),t)}keydown(t){L(t,d.BACKSPACE)&&t.target.matches(":only-child")?this.editor.dom.delete(t.target.parentElement):!L(t,d.TAB)&&!L(t,d.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var ht=class extends A{#t;constructor(t,e){if(!Object.values(T).includes(e))throw new TypeError("Invalid argument");super(t,"sort-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-sortable")&&this.editor.dom.sort(t,this.#t)}};var ft=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-sortable")&&(t.addEventListener("keydown",this),t.addEventListener("pointerdown",this),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this))}keydown(t){t.target===t.currentTarget&&Ke(t)&&(this.editor.dom.sort(t.target,Fe[t.key]),t.preventDefault(),t.stopPropagation())}pointerdown(t){let e=t.target.closest("[data-sortable]");e&&this.editor.dom.contains(e)&&(e.setAttribute("data-sort",""),e.setPointerCapture(t.pointerId))}pointermove(t){let e=t.target.closest("[data-sortable][data-sort]"),i=this.editor.dom.document.elementFromPoint(t.x,t.y);this.#t(),e&&this.editor.dom.contains(e)&&this.#e(e,i)&&i.setAttribute("data-sortover","")}pointerup(t){let e=t.target.closest("[data-sortable][data-sort]");if(e&&this.editor.dom.contains(e)){let i=this.editor.dom.document.elementFromPoint(t.x,t.y),a=i.parentElement;if(this.#t(),e.removeAttribute("data-sort"),e.releasePointerCapture(t.pointerId),this.#e(e,i)){if(e.localName===r.COL&&a===e.parentElement){let l=Array.from(a.children).indexOf(e),c=Array.from(a.children).indexOf(i),f=a.parentElement;Array.from(f.rows).forEach(u=>this.editor.dom.insertBefore(u.cells[l],u.cells[c]))}this.editor.dom.insertBefore(e,i)}}}#t(){this.editor.root.querySelectorAll("[data-sortover]").forEach(t=>t.removeAttribute("data-sortover"))}#e(t,e){return t instanceof HTMLElement&&e instanceof HTMLElement&&this.editor.dom.contains(e)&&![this.editor.root,t].includes(e)&&e.hasAttribute("data-sortable")&&(t.parentElement===e.parentElement||this.editor.dom.arbitrary(t.parentElement)&&this.editor.dom.arbitrary(e.parentElement))&&this.editor.tags.allowed(e.parentElement,t)}};var ut=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){let e=this.editor.tags.get(t);e&&(e.editable&&(t.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.dataset[i]="")}))}};var pt=class extends S{constructor(t){super(t),this.editor.toolbar.addEventListener("insertbutton",this)}};var m=class extends n{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._tag({name:r.ROOT,group:o.ROOT,children:[o.AUDIO,o.BLOCK,o.CONTAINER,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO]}),this._tag({name:r.SLOT,group:o.SLOT,editable:!0,focusable:!0,navigable:!0,sortable:!0}),new ut(this.editor),new pt(this.editor),new mt(this.editor),new dt(this.editor),new at(this.editor),new st(this.editor),new lt(this.editor),new ft(this.editor),new rt(this.editor),new nt(this.editor),new ct(this.editor),this.editor.filters.add(new it(this.editor)),this.#t(),this.#e(),this.#r()}#t(){let t={[R.NONE]:"No alignment",[R.LEFT]:"Align left",[R.CENTER]:"Align center",[R.RIGHT]:"Align right"};Object.entries(t).forEach(([e,i])=>{let a=new tt(this.editor,e);this.editor.commands.set(a),this._focusbar(i,a.name)})}#e(){let t={[T.FIRST]:"Sort to the beginning",[T.PREV]:"Sort before previous element",[T.NEXT]:"Sort after next element",[T.LAST]:"Sort to the end"};Object.entries(t).forEach(([e,i])=>{let a=new ht(this.editor,e);this.editor.commands.set(a),this._focusbar(i,a.name)})}#r(){this.editor.commands.set(new ot(this.editor)),this._focusbar("Delete","delete")}};var P=class extends n{static get name(){return"abbreviation"}static get dependencies(){return[m]}init(){this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new J(this.editor)),this._command(r.ABBR),this._formatbar("Abbreviation",d.A)}};var gt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Audio")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to audio"),required:"required"}).addTextInput("id",this._("ID"))}};var Et=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.AUDIO)).forEach(e=>this.#t(e))}insertaudio({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:U.name}})):t.parentElement.removeChild(t)}};var bt=class extends w{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var Tt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertfigure",this)}insertfigure({detail:{element:t}}){t.querySelector(":scope > "+r.FIGCAPTION)||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.FIGCAPTION),t)}};var O=class extends n{static get name(){return"figure"}static get dependencies(){return[m]}init(){this._tag({name:r.FIGURE,group:o.FIGURE,children:[o.AUDIO,o.CAPTION,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.TABLE,o.VIDEO],attributes:["class"],alignable:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag({name:r.FIGCAPTION,group:o.CAPTION,children:[o.FORMAT],editable:!0,navigable:!0,enter:r.P}),new Tt(this.editor),this.editor.filters.add(new bt(this.editor))}};var U=class extends n{static get name(){return"audio"}static get dependencies(){return[m,O]}static get config(){return{browser:void 0}}init(){this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new Et(this.editor),this.editor.dialogs.set(new gt(this.editor,this.constructor.name,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar("Audio")}};var Lt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var At=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super(),this.attachShadow({mode:"open"})}};var xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock({detail:{element:t}}){if(!t.id){t.parentElement.removeChild(t);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.id),i=await fetch(e,{mode:"no-cors"});if(!i.ok)return;let a="";this.editor.config.block.css&&(a=this.editor.config.block.css.split(",").map(c=>`<link rel="stylesheet" href="${c}">`).join(""));let l=await i.text();t.content=a+l}};var wt=class extends n{static get name(){return"block"}static get dependencies(){return[m]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this.editor.dom.registerElement(r.BLOCK,At),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new xt(this.editor),this.editor.dialogs.set(new Lt(this.editor,this.constructor.name,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar("Block")}};var Rt=class extends w{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(_.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.BLOCKQUOTE),t),t.parentElement.removeChild(t))}};var Ot=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:_.name}})}deleteblockquote({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(_.name)&&t.parentElement.removeChild(t)}};var yt=class extends w{filter(t){if(t instanceof HTMLPreElement){t.outerHTML=t.outerHTML.replace(/(<br\s*\/?>)/gi,`
|
|
2
|
+
`);return}t.innerHTML=t.innerHTML.replace(/^\s*(<br\s*\/?>\s*)+/gi,"").replace(/\s*(<br\s*\/?>\s*)+$/gi,""),t instanceof HTMLParagraphElement?t.outerHTML=t.outerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"</p><p>"):t.innerHTML=t.innerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"<br>")}};var y=class extends n{static get name(){return"break"}static get dependencies(){return[m]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new yt(this.editor))}};var _=class extends n{static get name(){return"blockquote"}static get dependencies(){return[m,y,O]}init(){this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new Ot(this.editor),this._command(r.BLOCKQUOTE),this._toolbar("Blockquote"),this.editor.filters.add(new Rt(this.editor))}};var It=class extends n{static get name(){return"bold"}static get dependencies(){return[m]}init(){this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar("bold",d.B)}};var Ct=class extends n{static get name(){return"cite"}static get dependencies(){return[m]}init(){this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar("Citation",d.Z)}};var Nt=class extends n{static get name(){return"code"}static get dependencies(){return[m]}init(){this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar("Code",d.C)}};var _t=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Mt=class extends n{static get name(){return"data"}static get dependencies(){return[m]}init(){this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new _t(this.editor,this.constructor.name)),this._command(r.DATA),this._formatbar("Data",d.J)}};var St=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var Bt=class extends n{static get name(){return"definition"}static get dependencies(){return[m]}init(){this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new St(this.editor,this.constructor.name)),this._command(r.DFN),this._formatbar("Definition",d.D)}};var vt=class extends n{static get name(){return"deletion"}static get dependencies(){return[m]}init(){this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar("Text Deletion",d.G)}};var Dt=class extends w{filter(t){t.querySelectorAll(`${r.SUMMARY}:not(:first-child)`).forEach(e=>e.parentElement.removeChild(e)),t.querySelectorAll(`${r.SUMMARY}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var Ft=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails({detail:{element:t}}){t.open=!0,t.querySelector(`:scope > ${r.SUMMARY}:first-child`)||this.editor.dom.insertFirstChild(this.editor.dom.createElement(r.SUMMARY),t)}insertsummary({detail:{element:t}}){this.#t(t),t.addEventListener("click",this),t.addEventListener("blur",this),t.addEventListener("keydown",this)}click(t){t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0}blur({target:t}){this.#t(t)}keydown(t){L(t,d.SPACE)?(t.preventDefault(),t.stopPropagation(),this.editor.dom.insertText(" ")):L(t,d.ENTER)&&(t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0)}#t(t){t.textContent.trim()?t.querySelectorAll(r.BR+":not(:last-child)").forEach(e=>e.parentElement.removeChild(e)):t.textContent=this._("Details"),t.lastElementChild instanceof HTMLBRElement||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.BR),t)}};var Ht=class extends n{static get name(){return"details"}static get dependencies(){return[m]}init(){this._tag({name:r.DETAILS,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.SUMMARY,o.TABLE,o.VIDEO],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this._tag({name:r.SUMMARY,group:o.SUMMARY,editable:!0,navigable:!0,enter:r.P}),new Ft(this.editor),this._command(r.DETAILS),this._toolbar("Details"),this.editor.filters.add(new Dt(this.editor))}};var Pt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var Ut=class extends n{static get name(){return"division"}static get dependencies(){return[m]}init(){this._tag({name:r.DIV,group:o.CONTAINER,children:[o.AUDIO,o.BLOCK,o.FIGURE,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new Pt(this.editor,this.constructor.name)),this._command(r.DIV),this._toolbar("Division")}};var Gt=class extends n{static get name(){return"emphasis"}static get dependencies(){return[m]}init(){this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar("emphasized",d.E)}};var kt=class extends n{static get name(){return"heading"}static get dependencies(){return[m]}init(){this._tag({name:r.H2,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H2),this._toolbar("Heading")}};var Kt=class extends n{static get name(){return"horizontalrule"}static get dependencies(){return[m]}init(){this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar("Horizontal Rule")}};var We={"CSS class":"CSS-Klasse",Height:"H\xF6he",ID:"ID","Insert CSS class":"CSS-Klasse eingeben",URL:"URL",Width:"Breite",Abbreviation:"Abk\xFCrzung","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Audio:"Audio","Insert URL to audio":"URL zur Audiodatei eingeben","Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig",Alt:"Alt",Cancel:"Abbrechen",Delete:"L\xF6schen","No alignment":"Keine Ausrichtung",Save:"Speichern",Shift:"Umschalt","Sort after next element":"Hinter das n\xE4chste Element sortieren","Sort before previous element":"Vor das vorherige Element sortieren","Sort to the beginning":"An den Anfang sortieren","Sort to the end":"Ans Ende sortieren",Block:"Block",Blockquote:"Blockzitat",bold:"fett",Citation:"Zitatquelle",Code:"Quelltext",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff","Text Deletion":"Textl\xF6schung",Details:"Details",Division:"Division",emphasized:"betont",Heading:"\xDCberschrift","Horizontal Rule":"Horizontale Linie",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben","Alternative text":"Alternativtext",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist","Text Insertion":"Texteinf\xFCgung",italic:"kursiv","User Input":"Benutzereingabe","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",mark:"markiert","Ordered List":"Geordnete Liste",Paragraph:"Absatz","Preformatted Text":"Vorformatierter Text",Quote:"Zitat","Sample Output":"Beispielausgabe",Section:"Sektion",small:"klein",strikethrough:"durchgestrichen","strongly emphasized":"stark betont",Subheading:"Unter\xFCberschrift",subscript:"tiefgestellt",superscript:"hochgestellt","Add column":"Spalte hinzuf\xFCgen","Add row":"Zeile hinzuf\xFCgen",Columns:"Spalten",Rows:"Zeilen",Table:"Tabelle","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Time:"Zeit",underline:"unterstrichen","Unordered List":"Ungeordnete Liste",Variable:"Variable","Insert URL to video":"URL zur Videodatei eingeben",Video:"Video"};var zt=class extends n{static get name(){return"i18n"}static get dependencies(){return[m]}init(){this._i18n({de:We})}};var Wt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Iframe")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to embedded page"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var jt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IFRAME)).forEach(e=>this.#t(e))}insertiframe({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.allowFullscreen=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:G.name}})):t.parentElement.removeChild(t)}};var G=class extends n{static get name(){return"iframe"}static get dependencies(){return[m,O]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new jt(this.editor),this.editor.dialogs.set(new Wt(this.editor,this.constructor.name,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar("Iframe")}};var qt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Image")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to image"),required:"required"}).addTextInput("alt",this._("Alternative text"),{placeholder:this._("Text shown when media element is not available")}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Vt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IMG)).forEach(e=>this.#t(e))}insertimg({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:k.name}})):t.parentElement.removeChild(t)}};var k=class extends n{static get name(){return"image"}static get dependencies(){return[m,O]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new Vt(this.editor),this.editor.dialogs.set(new qt(this.editor,this.constructor.name,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar("Image")}};var $t=class extends n{static get name(){return"insertion"}static get dependencies(){return[m]}init(){this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar("Text Insertion",d.F)}};var Qt=class extends n{static get name(){return"italic"}static get dependencies(){return[m]}init(){this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar("italic",d.I)}};var Yt=class extends n{static get name(){return"keyboard"}static get dependencies(){return[m]}init(){this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar("User Input",d.K)}};var Zt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var Xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.A)).forEach(e=>this.#t(e))}inserta({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("href");e?t.setAttribute("href",this.editor.url(e)):t.parentElement.replaceChild(this.editor.dom.createText(t.textContent),t)}};var Jt=class extends n{static get name(){return"link"}static get dependencies(){return[m]}init(){this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new Xt(this.editor),this.editor.dialogs.set(new Zt(this.editor,this.constructor.name)),this._command(r.A),this._formatbar("Link",d.L)}};var te=class extends n{static get name(){return"mark"}static get dependencies(){return[m]}init(){this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar("mark",d.M)}};var ee=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertli",this),this.editor.root.addEventListener("deleteli",this),this.editor.root.addEventListener("insertol",this),this.editor.root.addEventListener("insertul",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.LI)).forEach(e=>this.#t(e))}insertli({detail:{element:t}}){this.#t(t)}deleteli({detail:{target:t}}){t.children.length===0&&t.parentElement.removeChild(t)}insertol({detail:{element:t}}){this.#e(t)}insertul({detail:{element:t}}){this.#e(t)}#t(t){!(t.parentElement instanceof HTMLOListElement)&&!(t.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(t,r.UL)}#e(t){t.children.length===0&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LI),t)}};var K=class extends n{static get name(){return"list"}static get dependencies(){return[m,y]}init(){this._tag({name:r.LI,group:o.LISTITEM,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.LI}),new ee(this.editor)}};var re=class extends n{static get name(){return"orderedlist"}static get dependencies(){return[m,K]}init(){this._tag({name:r.OL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.OL),this._toolbar("Ordered List")}};var ie=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.P)).forEach(e=>e.addEventListener("paste",this))}insertp({detail:{element:t}}){t.addEventListener("paste",this)}paste({target:t}){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(t))}};var oe=class extends n{static get name(){return"paragraph"}static get dependencies(){return[m,y]}init(){this._tag({name:r.P,group:o.PARAGRAPH,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),new ie(this.editor),this._command(r.P),this._toolbar("Paragraph")}};var se=class extends w{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(M.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.PRE),t),t.parentElement.removeChild(t))}};var ae=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:M.name}})}deletepre({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(M.name)&&t.parentElement.removeChild(t)}};var M=class extends n{static get name(){return"preformat"}static get dependencies(){return[m,y,O]}init(){this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new ae(this.editor),this._command(r.PRE),this._toolbar("Preformatted Text"),this.editor.filters.add(new se(this.editor))}};var ne=class extends n{static get name(){return"quote"}static get dependencies(){return[m]}init(){this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar("Quote",d.Q)}};var de=class extends n{static get name(){return"sample"}static get dependencies(){return[m]}init(){this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar("Sample Output",d.O)}};var me=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var le=class extends n{static get name(){return"section"}static get dependencies(){return[m]}init(){this._tag({name:r.SECTION,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new me(this.editor,this.constructor.name)),this._command(r.SECTION),this._toolbar("Section")}};var ce=class extends n{static get name(){return"small"}static get dependencies(){return[m]}init(){this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar("small",d.W)}};var he=class extends n{static get name(){return"strikethrough"}static get dependencies(){return[m]}init(){this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar("strikethrough",d.R)}};var fe=class extends n{static get name(){return"strong"}static get dependencies(){return[m]}init(){this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar("strongly emphasized",d.S)}};var ue=class extends n{static get name(){return"subheading"}static get dependencies(){return[m]}init(){this._tag({name:r.H3,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H3),this._toolbar("Subheading")}};var pe=class extends n{static get name(){return"subscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar("subscript",d.X)}};var ge=class extends n{static get name(){return"superscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar("superscript",d.Y)}};var Ee=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttd({detail:{element:t}}){t.addEventListener("keydown",this)}insertth({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){let e=t.target,i=e.parentElement,a=e.closest(r.TABLE);if(e instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&a instanceof HTMLTableElement&&Pe(t)&&this.#t(e,t.key)){let l=e.cellIndex,c=i.cells.length,f=l===0,u=l===c-1,g=i.rowIndex===0,I=i.rowIndex===a.rows.length-1;t.preventDefault(),t.stopPropagation(),t.key===d.ARROWLEFT&&!f?this.editor.dom.focusEnd(i.cells[l-1]):t.key===d.ARROWLEFT&&g?this.editor.dom.focusEnd(a.rows[a.rows.length-1].cells[c-1]):t.key===d.ARROWLEFT?this.editor.dom.focusEnd(a.rows[i.rowIndex-1].cells[c-1]):t.key===d.ARROWRIGHT&&!u?i.cells[l+1].focus():t.key===d.ARROWRIGHT&&I?a.rows[0].cells[0].focus():t.key===d.ARROWRIGHT?a.rows[i.rowIndex+1].cells[0].focus():t.key===d.ARROWUP&&g?a.rows[a.rows.length-1].cells[l].focus():t.key===d.ARROWUP?a.rows[i.rowIndex-1].cells[l].focus():t.key===d.ARROWDOWN&&I?a.rows[0].cells[l].focus():t.key===d.ARROWDOWN&&a.rows[i.rowIndex+1].cells[l].focus()}}#t(t,e){if([d.ARROWUP,d.ARROWDOWN].includes(e))return!0;let i=this.editor.dom.getSelection(),a=i.anchorNode instanceof HTMLElement?i.anchorNode:t;if(!i.isCollapsed)return!1;if(e===d.ARROWLEFT){let c=t.firstChild;return c instanceof HTMLElement&&(c=c.firstChild),i.anchorOffset===0&&[t,c].includes(a)}let l=t.lastChild;return t.lastChild instanceof HTMLBRElement&&t.lastChild.previousSibling&&(l=t.lastChild.previousSibling),l instanceof HTMLElement&&(l=l.lastChild),i.anchorOffset===a.textContent.length&&[t,l].includes(a)}};var be=class extends A{constructor(t){super(t,"tablecolumn-add")}execute(){let t=this.editor.dom.getActiveElement();t?.localName===r.COL&&this.editor.dom.createTableColumnAfter(t)}};var Te=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertcol",this)}insertcol({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){L(t,d.ENTER)?this.editor.dom.createTableColumnAfter(t.target):L(t,d.BACKSPACE)&&this.editor.dom.delete(t.target)}};var Le=class extends A{constructor(t){super(t,N.name,r.TABLE)}_insert({rows:t,cols:e}={}){this.editor.dom.insert(this.editor.dom.createTable(parseInt(t,10)||1,parseInt(e,10)||1))}};var Ae=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Table")).addNumberInput("rows",this._("Rows"),{min:"1",required:"required",value:"1"}).addNumberInput("cols",this._("Columns"),{min:"1",required:"required",value:"1"})}};var xe=class extends w{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.TABLE),t),t.parentElement.removeChild(t)):(t instanceof HTMLTableElement&&t.querySelector(`:scope > ${r.THEAD}, :scope > ${r.TFOOT}`)&&!t.querySelector(":scope > "+r.TBODY)||t instanceof HTMLTableSectionElement&&t.rows.length<=0||t instanceof HTMLTableRowElement&&!t.querySelector(`:scope > ${r.TH}:not(:empty), :scope > ${r.TD}:not(:empty)`))&&t.parentElement.removeChild(t)}};var we=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttable",this)}inserttable({detail:{element:t}}){if(this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:N.name}}),t.tBodies.length>0&&t.tBodies[0].rows[0]){let e=t.tBodies[0],i=e.rows[0].cells.length;t.querySelector(":scope > "+r.COLGROUP)||this.editor.dom.insertFirstChild(this.editor.dom.createTableColumnGroup(i),t),t.tHead||this.editor.dom.insertBefore(this.editor.dom.createTableHeader(1,i),e),t.tFoot||this.editor.dom.insertLastChild(this.editor.dom.createTableFooter(1,i),t)}}};var Re=class extends A{constructor(t){super(t,"tablerow-add")}execute(){let t=this.editor.dom.getActiveElement();t instanceof HTMLTableRowElement&&this.editor.dom.createTableRowAfter(t)}};var Oe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttr",this)}inserttr({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){L(t,d.ENTER)?this.editor.dom.createTableRowAfter(t.target):L(t,d.BACKSPACE)&&this.editor.dom.delete(t.target)}};var N=class extends n{static get name(){return"table"}static get dependencies(){return[m,y,O]}init(){this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag({name:r.COLGROUP,group:o.COLGROUP,children:[o.COL]}),this._tag({name:r.COL,group:o.COL,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#t(r.THEAD)),this._tag(this.#t(r.TBODY)),this._tag(this.#t(r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL],deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#e(r.TH)),this._tag(this.#e(r.TD)),new we(this.editor),new Te(this.editor),new Oe(this.editor),new Ee(this.editor),this.editor.filters.add(new xe(this.editor)),this.editor.dialogs.set(new Ae(this.editor,this.constructor.name)),this.editor.commands.set(new Le(this.editor)),this.editor.commands.set(new be(this.editor)),this.editor.commands.set(new Re(this.editor)),this._toolbar("Table"),this._focusbar("Add column","tablecolumn-add"),this._focusbar("Add row","tablerow-add")}#t(t){return{name:t,group:o.TABLESECTION,children:[o.TABLEROW]}}#e(t){return{name:t,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}}};var ye=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var Ie=class extends n{static get name(){return"time"}static get dependencies(){return[m]}init(){this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new ye(this.editor,this.constructor.name)),this._command(r.TIME),this._formatbar("Time",d.T)}};var Ce=class extends n{static get name(){return"underline"}static get dependencies(){return[m]}init(){this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar("underline",d.U)}};var Ne=class extends n{static get name(){return"unorderedlist"}static get dependencies(){return[m,K]}init(){this._tag({name:r.UL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.UL),this._toolbar("Unordered List")}};var _e=class extends n{static get name(){return"variable"}static get dependencies(){return[m]}init(){this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar("Variable",d.V)}};var Me=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Video")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to video"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Se=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.VIDEO)).forEach(e=>this.#t(e))}insertvideo({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:z.name}})):t.parentElement.removeChild(t)}};var z=class extends n{static get name(){return"video"}static get dependencies(){return[m,O]}static get config(){return{browser:void 0}}init(){this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new Se(this.editor),this.editor.dialogs.set(new Me(this.editor,this.constructor.name,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar("Video")}};var He=class extends x{static get defaultConfig(){return{base:{plugins:[zt,It,Qt,fe,Gt,Ce,he,Jt,te,ce,Bt,P,ne,Ct,Nt,Yt,de,_e,pe,ge,Ie,Mt,$t,vt,oe,kt,ue,Ne,re,Kt,_,k,z,U,G,N,M,le,Ht,Ut,wt]}}}};export{He as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akilli/editor",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "A HTML standards-compliant and dependency-free rich text editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contenteditable",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"release:major": "./release major"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@akilli/editor-src": "^5.1
|
|
45
|
-
"esbuild": "^0.17
|
|
46
|
-
"prettier": "^
|
|
44
|
+
"@akilli/editor-src": "^5.2.1",
|
|
45
|
+
"esbuild": "^0.18.17",
|
|
46
|
+
"prettier": "^3.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|