@akilli/editor 4.8.0 → 4.8.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/README.md +1 -1
- package/dist/editor.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/editor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var So=Object.defineProperty;var Co=(s,t,e)=>t in s?So(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var S=(s,t,e)=>(Co(s,typeof t!="symbol"?t+"":t,e),e),fi=(s,t,e)=>{if(!t.has(s))throw TypeError("Cannot "+e)};var l=(s,t,e)=>(fi(s,t,"read from private field"),e?e.call(s):t.get(s)),d=(s,t,e)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,e)},b=(s,t,e,i)=>(fi(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e);var f=(s,t,e)=>(fi(s,t,"access private method"),e);var C=Object.freeze({CENTER:"center",LEFT:"left",NONE:"none",RIGHT:"right"}),u=Object.freeze({INVALID_ARGUMENT:"Invalid argument",MISSING_NAME:"Missing name",NOT_IMPLEMENTED:"Not implemented"}),a=Object.freeze({A:"a",B:"b",BACKSPACE:"Backspace",C:"c",D:"d",DEL:"Delete",DOWN:"ArrowDown",E:"e",END:"End",ENTER:"Enter",ESC:"Escape",F:"f",G:"g",HOME:"Home",I:"i",J:"j",K:"k",L:"l",LEFT:"ArrowLeft",M:"m",O:"o",Q:"q",R:"r",RIGHT:"ArrowRight",S:"s",SPACE:" ",T:"t",TAB:"Tab",U:"u",UP:"ArrowUp",V:"v",W:"w",X:"x",Y:"y",Z:"z"}),x=Object.freeze({AFTERBEGIN:"afterbegin",AFTEREND:"afterend",BEFOREBEGIN:"beforebegin",BEFOREEND:"beforeend"}),R=Object.freeze({FIRST:"first",LAST:"last",NEXT:"next",PREV:"prev"}),o=Object.freeze({AUDIO:"audio",BLOCK:"block",BREAK:"break",CAPTION:"caption",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"}),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",DATA:"data",DEL:"del",DETAILS:"details",DFN:"dfn",DIALOG:"editor-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"}),Te=Object.freeze({FUNCTION:"function",STRING:"string",UNDEFINED:"undefined"});function I(s,t,{alt:e=!1,ctrl:i=!1,shift:n=!1}={}){return(Array.isArray(t)&&t.includes(s.key)||s.key===t)&&s.altKey===e&&s.ctrlKey===i&&s.shiftKey===n}function Mt(s){return typeof s===Te.UNDEFINED}function V(s){return typeof s===Te.FUNCTION}function N(s){return s&&typeof s===Te.STRING}function K(s){return Mt(s)||N(s)}function pi(s){return Mt(s)||Array.isArray(s)&&s.length>0}function ui(s){return Mt(s)||s instanceof HTMLElement}var Dt,Ot,St,Ct,yt,xi,Bt,Ii,B=class{constructor(t,e,i=void 0){d(this,yt);d(this,Bt);d(this,Dt,void 0);d(this,Ot,void 0);d(this,St,void 0);d(this,Ct,void 0);if(!(t instanceof D)||!N(e)||!K(i))throw new Error(u.INVALID_ARGUMENT);b(this,Dt,t),b(this,Ot,e),b(this,St,i&&this.editor.tags.get(i)),b(this,Ct,this.editor.dialogs.get(e))}get editor(){return l(this,Dt)}get name(){return l(this,Ot)}get tag(){return l(this,St)}get dialog(){return l(this,Ct)}execute(){this.dialog?this.openDialog():this.insert(f(this,yt,xi).call(this))}insert(t={}){if(!this.tag)return;f(this,Bt,Ii).call(this,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),f(this,yt,xi).call(this))}};Dt=new WeakMap,Ot=new WeakMap,St=new WeakMap,Ct=new WeakMap,yt=new WeakSet,xi=function(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return f(this,Bt,Ii).call(this,t),t},Bt=new WeakSet,Ii=function(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])};var j,Ae=class{constructor(t=[]){d(this,j,new Map);t.forEach(e=>this.set(e))}get(t){return l(this,j).get(t)}set(t){if(!(t instanceof B))throw new Error(u.INVALID_ARGUMENT);l(this,j).set(t.name,t)}find(t){return Array.from(l(this,j).values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){l(this,j).forEach(t=>Object.freeze(t)),Object.freeze(l(this,j)),Object.freeze(this)}};j=new WeakMap;var J,Le=class{constructor(t=[]){d(this,J,new Map);t.forEach(e=>this.set(e))}get(t){return l(this,J).get(t)}set(t){if(!(t instanceof L))throw new Error(u.INVALID_ARGUMENT);l(this,J).set(t.name,t)}freeze(){l(this,J).forEach(t=>Object.freeze(t)),Object.freeze(l(this,J)),Object.freeze(this)}};J=new WeakMap;var at,nt,gi,xe,yo,tt=class{constructor(t){d(this,nt);d(this,xe);d(this,at,void 0);if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);b(this,at,t),this.register(f(this,xe,yo).bind(this))}dispatch(t,e=void 0,i=void 0){if(!N(t)||!ui(e)||!ui(i))throw new Error(u.INVALID_ARGUMENT);l(this,at).dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!V(t))throw new Error(u.INVALID_ARGUMENT);new MutationObserver(t).observe(l(this,at),e)}};at=new WeakMap,nt=new WeakSet,gi=function(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))},xe=new WeakSet,yo=function(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(f(this,nt,gi).call(this,"insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>f(this,nt,gi).call(this,"insert",n,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&f(this,nt,gi).call(this,"delete",i,e.target))})};var Ft,Gt,Pt,Ut,Ie,Ne,Bo,dt=class{constructor(t,e){d(this,Ne);d(this,Ft,void 0);d(this,Gt,void 0);d(this,Pt,void 0);d(this,Ut,void 0);d(this,Ie,{alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""});if(!(t instanceof D)||!(e instanceof Document))throw new Error(u.INVALID_ARGUMENT);b(this,Ft,t),b(this,Gt,e),b(this,Pt,this.document.defaultView),b(this,Ut,this.document.documentElement)}get editor(){return l(this,Ft)}get document(){return l(this,Gt)}get window(){return l(this,Pt)}get root(){return l(this,Ut)}registerElement(t,e,i=void 0){Mt(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(([c,p])=>p&&n.setAttribute(c,`${p}`)),n}insert(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))e.insertAdjacentElement(x.BEFOREBEGIN,t);else if(e)this.closest(e,t)?.insertAdjacentElement(x.AFTEREND,t),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e);else if(this.editor.tags.allowed(this.editor.root,t))this.editor.root.appendChild(t);else throw new Error(u.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 Error(u.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(),c=Array.from(e.cloneContents().childNodes).every(p=>p instanceof Text&&!p.textContent.trim()||p instanceof HTMLElement&&p.localName===t.localName);e.deleteContents(),c?e.insertNode(this.createText(n)):(t.textContent=n,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new Error(u.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 Error(u.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 c=this.createElement(e,i);n.insertAdjacentElement(x.AFTEREND,c),c.appendChild(t)}}else throw new Error(u.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]"),c=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===c&&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 Error(u.INVALID_ARGUMENT);let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}delete(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);let e=t.previousElementSibling,i=t.nextElementSibling;t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}sort(t,e){if(!(t instanceof HTMLElement)||!Object.values(R).includes(e))throw new Error(u.INVALID_ARGUMENT);let i=t.parentElement,n=t.previousElementSibling,c=t.nextElementSibling,p=i.firstElementChild,E=i.lastElementChild,T=t===p,A=t===E;e===R.PREV&&!T&&n.hasAttribute("data-sortable")?(n.insertAdjacentHTML(x.BEFOREBEGIN,t.outerHTML),i.removeChild(t)):e===R.NEXT&&!A&&c.hasAttribute("data-sortable")?(c.insertAdjacentHTML(x.AFTEREND,t.outerHTML),i.removeChild(t)):(e===R.FIRST&&!T||e===R.NEXT&&A)&&p.hasAttribute("data-sortable")?(p.insertAdjacentHTML(x.BEFOREBEGIN,t.outerHTML),i.removeChild(t)):(e===R.LAST&&!A||e===R.PREV&&T)&&E.hasAttribute("data-sortable")&&(E.insertAdjacentHTML(x.AFTEREND,t.outerHTML),i.removeChild(t))}open({url:t,name:e,call:i,params:n={}}){if(!N(t)||!N(e)||!V(i))throw new Error(u.INVALID_ARGUMENT);let c=this.createElement(r.A,{attributes:{href:t}}),p=new URL(c.href);Object.entries(n).forEach(([T,A])=>p.searchParams.set(T,`${A}`));let E=this.window.open(p.toString(),e,f(this,Ne,Bo).call(this));this.window.addEventListener("message",T=>{T.origin===p.origin&&T.source===E&&(i(T.data),E.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}};Ft=new WeakMap,Gt=new WeakMap,Pt=new WeakMap,Ut=new WeakMap,Ie=new WeakMap,Ne=new WeakSet,Bo=function(){let t=Object.assign({},l(this,Ie),{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 Ht,M=class{constructor(t){d(this,Ht,void 0);if(!(t instanceof D))throw new Error(u.INVALID_ARGUMENT);b(this,Ht,t)}get editor(){return l(this,Ht)}filter(t){throw new Error(u.NOT_IMPLEMENTED)}};Ht=new WeakMap;var et,_e=class{constructor(){d(this,et,new Set)}add(t){if(!(t instanceof M))throw new Error(u.INVALID_ARGUMENT);l(this,et).add(t)}filter(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);l(this,et).forEach(e=>{t.normalize(),e.filter(t)})}freeze(){l(this,et).forEach(t=>Object.freeze(t)),Object.freeze(l(this,et)),Object.freeze(this)}};et=new WeakMap;var lt=class{constructor({name:t,group:e,...i}={}){S(this,"name");S(this,"group");S(this,"children");S(this,"attributes");S(this,"alignable");S(this,"arbitrary");S(this,"deletable");S(this,"editable");S(this,"empty");S(this,"focusable");S(this,"navigable");S(this,"slotable");S(this,"sortable");S(this,"enter");if(!N(t)||!N(e)||!pi(i.children)||!pi(i.attributes)||!K(i.enter))throw new Error(u.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 kt,mt,Ei,m=class{constructor(t){d(this,mt);d(this,kt,void 0);if(!(t instanceof D))throw new Error(u.INVALID_ARGUMENT);b(this,kt,t)}get editor(){return l(this,kt)}static get name(){throw new Error(u.MISSING_NAME)}static get dependencies(){return[]}static get config(){return{}}init(){throw new Error(u.NOT_IMPLEMENTED)}_(t){return this.editor.translator.translate(this.constructor.name,t)}_base(t){return this.editor.translator.translate("base",t)}_i18n(t){t[this.editor.config.base.lang]&&this.editor.translator.set(this.constructor.name,t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new lt(t))}_command(t){this.editor.commands.set(new B(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){this.editor.toolbar.appendChild(f(this,mt,Ei).call(this,t,t,void 0,e))}_formatbar(t,e=void 0,i=void 0){let n=this._base("Alt"),c=this._base("Shift"),p=t+(e?` [${n} + ${c} + ${e}]`:"");this.editor.formatbar.appendChild(f(this,mt,Ei).call(this,t,p,e,i))}_focusbar(t,e=void 0){this.editor.focusbar.appendChild(f(this,mt,Ei).call(this,t,t,void 0,e))}};kt=new WeakMap,mt=new WeakSet,Ei=function(t,e,i=void 0,n=void 0){if(!N(t)||!N(e)||!K(i))throw new Error(u.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 z,we=class{constructor(t=[]){d(this,z,new Map);t.forEach(e=>this.set(e))}get(t){return l(this,z).get(t)}set(t){if(!(t instanceof m))throw new Error(u.INVALID_ARGUMENT);l(this,z).set(t.constructor.name,t)}init(){l(this,z).forEach(t=>t.init())}freeze(){l(this,z).forEach(t=>Object.freeze(t)),Object.freeze(l(this,z)),Object.freeze(this)}};z=new WeakMap;var rt,Re=class{constructor(t=[]){d(this,rt,new Map);t.forEach(e=>this.set(e))}get(t){return l(this,rt).get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof lt))throw new Error(u.INVALID_ARGUMENT);l(this,rt).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(){l(this,rt).forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(l(this,rt)),Object.freeze(this)}};rt=new WeakMap;var it,Me=class{constructor(){d(this,it,new Map)}get(t){return l(this,it).get(t)}set(t,e){if(!N(t)||!(e instanceof Object))throw new Error(u.INVALID_ARGUMENT);l(this,it).set(t,e)}translate(t,e){return this.get(t)?.[e]||e}freeze(){l(this,it).forEach(t=>Object.freeze(t)),Object.freeze(l(this,it)),Object.freeze(this)}};it=new WeakMap;var vt,ht,Vt,Kt,jt,zt,qt,Wt,$t,Qt,Yt,Zt,De,Oe,Se,Ce,ye,Be,D=class{constructor(t,e={}){d(this,vt,void 0);d(this,ht,{});d(this,Vt,void 0);d(this,Kt,void 0);d(this,jt,void 0);d(this,zt,void 0);d(this,qt,void 0);d(this,Wt,void 0);d(this,$t,void 0);d(this,Qt,void 0);d(this,Yt,void 0);d(this,Zt,void 0);d(this,De,new Me);d(this,Oe,new Re);d(this,Se,new _e);d(this,Ce,new Le);d(this,ye,new Ae);d(this,Be,new we);if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new Error(u.INVALID_ARGUMENT);b(this,vt,t),b(this,ht,e),b(this,Vt,new dt(this,this.orig.ownerDocument)),b(this,Kt,this.dom.createElement(r.EDITOR)),b(this,jt,this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}})),this.element.appendChild(this.toolbar),b(this,zt,new tt(this.toolbar)),b(this,qt,this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}})),this.formatbar.hidden=!0,this.element.appendChild(this.formatbar),b(this,Wt,new tt(this.formatbar)),b(this,$t,this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}})),this.focusbar.hidden=!0,this.element.appendChild(this.focusbar),b(this,Qt,new tt(this.focusbar)),b(this,Yt,this.dom.createElement(r.ROOT)),this.element.appendChild(this.root),b(this,Zt,new tt(this.root))}get orig(){return l(this,vt)}get config(){return l(this,ht)}get dom(){return l(this,Vt)}get element(){return l(this,Kt)}get toolbar(){return l(this,jt)}get toolbarDispatcher(){return l(this,zt)}get formatbar(){return l(this,qt)}get formatbarDispatcher(){return l(this,Wt)}get focusbar(){return l(this,$t)}get focusbarDispatcher(){return l(this,Qt)}get root(){return l(this,Yt)}get rootDispatcher(){return l(this,Zt)}get translator(){return l(this,De)}get tags(){return l(this,Oe)}get filters(){return l(this,Se)}get dialogs(){return l(this,Ce)}get commands(){return l(this,ye)}get plugins(){return l(this,Be)}static get defaultConfig(){return{}}init(){let t=this.config;b(this,ht,{});let e=this.constructor.defaultConfig.base?.plugins||[],i=e;if(Array.isArray(t.base?.plugins)&&t.base.plugins.length>0){let p=t.base.plugins;t.base?.pluginsDisabled?i=i.filter(E=>!p.includes(E.name)):(i=[],p.forEach(E=>{let T=e.find(A=>A.name===E);T&&i.push(T)}))}let n=new Set,c=p=>{p.dependencies?.forEach(c),n.add(p)};i.map(c),n.forEach(p=>{Object.entries(p.config).forEach(([E,T])=>{var A,y;(A=this.config)[y=p.name]??(A[y]={}),this.config[p.name][E]=t[p.name]?.[E]||this.constructor.defaultConfig[p.name]?.[E]||T}),this.plugins.set(new p(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),this.translator.freeze(),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.orig.insertAdjacentElement(x.AFTEREND,this.element),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")}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}};vt=new WeakMap,ht=new WeakMap,Vt=new WeakMap,Kt=new WeakMap,jt=new WeakMap,zt=new WeakMap,qt=new WeakMap,Wt=new WeakMap,$t=new WeakMap,Qt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,De=new WeakMap,Oe=new WeakMap,Se=new WeakMap,Ce=new WeakMap,ye=new WeakMap,Be=new WeakMap;var G,q,W,Ge,Fo,Pe,Go,Fe=class{constructor(t,e,i,n){d(this,Ge);d(this,Pe);d(this,G,void 0);d(this,q,void 0);d(this,W,void 0);var c,p;if(!(t instanceof dt)||!N(e)||!N(i)||!V(n))throw new Error(u.INVALID_ARGUMENT);b(this,G,t),b(this,q,l(this,G).createElement(r.FORM,{attributes:{method:"dialog"}})),f(p=f(c=this.addFieldset(),Ge,Fo).call(c,i,n),Pe,Go).call(p,e)}get form(){return l(this,q)}addFieldset(){let t=l(this,G).createElement(r.FIELDSET);return l(this,W)?l(this,W).insertAdjacentElement(x.AFTEREND,t):l(this,q).insertAdjacentElement(x.AFTERBEGIN,t),b(this,W,t),this}addLegend(t){if(!N(t))throw new Error(u.INVALID_ARGUMENT);return l(this,W).appendChild(l(this,G).createElement(r.LEGEND,{html:t})),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(!N(t)||!N(e)||!N(n))throw new Error(u.INVALID_ARGUMENT);Object.assign(i,{id:`editor-${t}`,name:t,type:n});let c=l(this,G).createElement(r.DIV);return c.appendChild(l(this,G).createElement(r.LABEL,{attributes:{for:i.id},html:e})),c.appendChild(l(this,G).createElement(r.INPUT,{attributes:i})),i.required&&c.setAttribute("data-required",""),l(this,W).appendChild(c),this}};G=new WeakMap,q=new WeakMap,W=new WeakMap,Ge=new WeakSet,Fo=function(t,e){let i=l(this,G).createElement(r.BUTTON,{attributes:{type:"button"},html:t});return i.addEventListener("click",e),l(this,q).appendChild(i),this},Pe=new WeakSet,Go=function(t){return l(this,q).appendChild(l(this,G).createElement(r.BUTTON,{html:t})),this};var Xt,Jt,te,ee,Ue,Po,He,Uo,re,Ni,L=class{constructor(t,e,i=void 0){d(this,Ue);d(this,He);d(this,re);d(this,Xt,void 0);d(this,Jt,void 0);d(this,te,void 0);d(this,ee,void 0);if(!(t instanceof D)||!N(e)||!K(i))throw new Error(u.INVALID_ARGUMENT);b(this,Xt,t),b(this,Jt,e),b(this,te,i)}get editor(){return l(this,Xt)}get name(){return l(this,Jt)}get url(){return l(this,te)}get formCreator(){return l(this,ee)}open(t,e={}){this.url?f(this,Ue,Po).call(this,t,e):f(this,He,Uo).call(this,t,e)}_(t){return this.editor.translator.translate(this.name,t)}_prepareForm(){throw new Error(u.NOT_IMPLEMENTED)}};Xt=new WeakMap,Jt=new WeakMap,te=new WeakMap,ee=new WeakMap,Ue=new WeakSet,Po=function(t,e={}){this.editor.dom.open({url:this.url,name:this.name,call:t,params:e})},He=new WeakSet,Uo=function(t,e={}){let i=this.editor.dom.getRange(),n=()=>{i&&this.editor.dom.setRange(i),f(this,re,Ni).call(this)};f(this,re,Ni).call(this),b(this,ee,new Fe(this.editor.dom,this._("Save"),this._("Cancel"),n)),this._prepareForm();let c=this.formCreator.form;c.addEventListener("submit",E=>{E.preventDefault(),E.stopPropagation(),n();let T={};Array.from(c.elements).forEach(A=>T[A.name]=A.value),t(T)}),Object.entries(e).forEach(([E,T])=>c.elements[E]&&(c.elements[E].value=T));let p=this.editor.dom.createElement(r.DIALOG);p.addEventListener("close",n),p.appendChild(c),p.show(),this.editor.element.appendChild(p)},re=new WeakSet,Ni=function(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})};var ke=class extends L{constructor(t){super(t,ct.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var ie,g=class{constructor(t){d(this,ie,void 0);if(!(t instanceof D))throw new Error(u.INVALID_ARGUMENT);b(this,ie,t)}get editor(){return l(this,ie)}handleEvent(t){V(this[t.type])&&this[t.type](t)}};ie=new WeakMap;var ve=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-alignable")&&t.detail.element.addEventListener("keydown",this)}keydown(t){let e={[a.UP]:C.NONE,[a.LEFT]:C.LEFT,[a.DOWN]:C.CENTER,[a.RIGHT]:C.RIGHT};t.target===t.currentTarget&&I(t,Object.keys(e),{shift:!0})&&(t.preventDefault(),t.stopPropagation(),t.target.classList.remove(...Object.values(e)),e[t.key]!==C.NONE&&t.target.classList.add(e[t.key]))}};var Ke,Ho,oe,_i,Ve=class extends M{constructor(){super(...arguments);d(this,Ke);d(this,oe)}filter(t){let e=this.editor.tags.get(t),i=this.editor.tags.allowed(t,r.P),n=e.editable||e.group===o.FORMAT,c=[],p=(E=null)=>{i&&c.length>0&&(t.insertBefore(this.editor.dom.createElement(r.P,{html:c.join(" ")}),E),c=[])};Array.from(t.childNodes).forEach(E=>{let T=E.textContent.trim();if(E instanceof HTMLElement){let A=f(this,Ke,Ho).call(this,E),y=this.editor.tags.get(A);if(y&&this.editor.tags.allowed(t,A))p(A),f(this,oe,_i).call(this,A,y);else if(y&&y.group===o.FORMAT&&i){let w=f(this,oe,_i).call(this,A,y);w&&(c.push(w.outerHTML),t.removeChild(w))}else!n&&T&&i?(c.push(T),t.removeChild(A)):n&&T?t.replaceChild(this.editor.dom.createText(T),A):t.removeChild(A)}else E instanceof Text?(!n&&T&&i&&c.push(T),(!n||!T)&&t.removeChild(E)):E instanceof Node&&t.removeChild(E)}),p()}};Ke=new WeakSet,Ho=function(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},oe=new WeakSet,_i=function(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 je=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-deletable")&&t.detail.element.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&I(t,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var ze=class extends HTMLElement{get open(){return this.hasAttribute("open")}set open(t){t===!0?this.setAttribute("open",""):this.removeAttribute("open")}constructor(){super();this.addEventListener("keydown",t=>t.key===a.ESC&&this.close()),this.addEventListener("click",t=>t.target===this&&this.close())}connectedCallback(){this.setAttribute("role","dialog"),this.tabIndex=-1,this.focus()}show(){this.open=!0,this.dispatchEvent(new CustomEvent("show",{detail:{element:this,target:this}}))}close(){this.open=!1,this.dispatchEvent(new CustomEvent("close",{detail:{element:this,target:this}}))}};var qe=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.contentEditable==="true"?t.detail.element.addEventListener("keydown",this):t.detail.element.parentElement.contentEditable==="true"&&t.detail.element.addEventListener("dblclick",this)}keydown(t){if(I(t,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(I(t,a.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;e&&(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")?this.editor.dom.closest(t.target,e)?.insertAdjacentElement(x.AFTEREND,this.editor.dom.createElement(e)):t.target instanceof HTMLParagraphElement||(this.editor.dom.closest(t.target,r.P)?.insertAdjacentElement(x.AFTEREND,this.editor.dom.createElement(r.P)),t.target.parentElement.removeChild(t.target)))}else I(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)&&I(t,t.key,{alt:!0,shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick(t){this.editor.dom.selectContents(t.target),this.editor.commands.find(t.target.localName)?.execute()}};var We=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-focusable")&&t.detail.element.focus()}};var $=class extends g{insertbutton(t){t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("click",this)}click(t){this.editor.commands.execute(t.target.getAttribute("data-command"))}keydown(t){if(I(t,[a.LEFT,a.RIGHT,a.HOME,a.END])){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,c=t.target.parentElement.lastElementChild,p=t.target===n,E=t.target===c;t.key===a.LEFT&&!p?e.focus():t.key===a.RIGHT&&!E?i.focus():t.key===a.HOME||t.key===a.RIGHT&&E?n.focus():(t.key===a.END||t.key===a.LEFT&&p)&&c.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);t.hidden=!1;let{x:i,y:n}=e.getBoundingClientRect(),{x:c,y:p}=this.editor.root.getBoundingClientRect(),E=i-c+t.clientWidth-this.editor.root.clientWidth,T=n-p-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,A=t.clientWidth<this.editor.root.clientWidth?i-c:0;A>0&&E>0&&(A=A>E?(A-E)/2:0),t.style.left=`${A}px`,t.style.top=`${T}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var se,wi,ae,Ri,$e=class extends ${constructor(t){super(t);d(this,se);d(this,ae);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(t){t.target instanceof HTMLElement&&t.target.hasAttribute("data-focusable")&&f(this,se,wi).call(this,t.target)}focusout(){f(this,ae,Ri).call(this)}selectionchange(){let t=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!t?f(this,ae,Ri).call(this):t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&f(this,se,wi).call(this,t)}};se=new WeakSet,wi=function(t){!this.editor.focusbar.children.length||(this._show(this.editor.focusbar,t),Object.keys(t.dataset).forEach(e=>this.editor.focusbar.dataset[e]=t.dataset[e]),this.editor.focusbar.dataset.tag=t.localName)},ae=new WeakSet,Ri=function(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(t=>delete this.editor.focusbar.dataset[t])};var Qe=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 Ze,ko,Ye=class extends g{constructor(t){super(t);d(this,Ze);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-navigable")&&(t.detail.element.tabIndex=0,t.detail.element.addEventListener("keydown",this))}keydown(t){if(t.target===t.currentTarget&&I(t,[a.UP,a.DOWN,a.HOME,a.END])&&f(this,Ze,ko).call(this,t.target)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,c=t.target.parentElement.lastElementChild,p=t.target===n,E=t.target===c;t.key===a.UP&&!p&&e.hasAttribute("data-navigable")?e.focus():t.key===a.DOWN&&!E&&i.hasAttribute("data-navigable")?i.focus():(t.key===a.HOME||t.key===a.DOWN&&E)&&n.hasAttribute("data-navigable")?n.focus():(t.key===a.END||t.key===a.UP&&p)&&c.hasAttribute("data-navigable")&&c.focus(),t.preventDefault(),t.stopPropagation()}}};Ze=new WeakSet,ko=function(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 Xe=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element instanceof HTMLSlotElement?t.detail.element.addEventListener("keydown",this):t.detail.element.hasAttribute("data-slotable")&&!t.detail.element.querySelector(":scope > "+r.SLOT)&&t.detail.element.appendChild(this.editor.dom.createElement(r.SLOT))}keydown(t){!I(t,a.TAB)&&!I(t,a.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var ne,Mi,de,Di,Je=class extends g{constructor(t){super(t);d(this,ne);d(this,de);this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-sortable")&&(t.detail.element.addEventListener("keydown",this),t.detail.element.addEventListener("pointerdown",this),t.detail.element.addEventListener("pointermove",this),t.detail.element.addEventListener("pointerup",this))}keydown(t){let e={[a.HOME]:R.FIRST,[a.UP]:R.PREV,[a.DOWN]:R.NEXT,[a.END]:R.LAST};t.target===t.currentTarget&&I(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);f(this,ne,Mi).call(this),e&&this.editor.dom.contains(e)&&f(this,de,Di).call(this,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);f(this,ne,Mi).call(this),e.removeAttribute("data-sort"),e.releasePointerCapture(t.pointerId),f(this,de,Di).call(this,e,i)&&i.insertAdjacentElement(x.BEFOREBEGIN,e)}}};ne=new WeakSet,Mi=function(){this.editor.root.querySelectorAll("[data-sortover]").forEach(t=>t.removeAttribute("data-sortover"))},de=new WeakSet,Di=function(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 tr=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insert",this)}insert(t){let e=this.editor.tags.get(t.detail.element);e&&(e.editable&&(t.detail.element.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.detail.element.dataset[i]="")}))}};var er=class extends ${constructor(t){super(t);this.editor.toolbar.addEventListener("insertbutton",this)}insertbutton(t){super.insertbutton(t),t.detail.element.tabIndex=t.detail.element===this.editor.toolbar.firstElementChild?0:-1,t.detail.element.addEventListener("keydown",this)}};var Oi={de:{Alt:"Alt",Shift:"Umschalt"}};var h=class extends m{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._i18n(Oi),this.editor.dom.registerElement(r.DIALOG,ze),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 tr(this.editor),new er(this.editor),new Qe(this.editor),new $e(this.editor),new qe(this.editor),new je(this.editor),new Ye(this.editor),new Je(this.editor),new ve(this.editor),new We(this.editor),new Xe(this.editor),this.editor.filters.add(new Ve(this.editor))}};var Si={de:{Abbreviation:"Abk\xFCrzung",Cancel:"Abbrechen","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var ct=class extends m{static get name(){return"abbreviation"}static get dependencies(){return[h]}init(){this._i18n(Si),this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new ke(this.editor)),this._command(r.ABBR),this._formatbar(this._("Abbreviation"),a.A)}};var ft,rr=class extends B{constructor(t,e){let i=Object.entries(C).find(([,n])=>n===e)?.[0].toLowerCase();if(!i)throw new Error(u.INVALID_ARGUMENT);super(t,pt.name+"-"+i);d(this,ft,void 0);b(this,ft,e)}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-alignable")&&(t.classList.remove(...Object.values(C)),l(this,ft)!==C.NONE&&t.classList.add(l(this,ft)))}};ft=new WeakMap;var Ci={de:{"Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig","No alignment":"Keine Ausrichtung"}};var pt=class extends m{static get name(){return"align"}static get dependencies(){return[h]}init(){this._i18n(Ci);let t={[C.NONE]:this._("No alignment"),[C.LEFT]:this._("Align left"),[C.CENTER]:this._("Align center"),[C.RIGHT]:this._("Align right")};Object.entries(t).forEach(([e,i])=>{let n=new rr(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var ir=class extends L{constructor(t,e=void 0){super(t,Q.name,e)}_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 le,yi,or=class extends g{constructor(t){super(t);d(this,le);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.AUDIO)).forEach(e=>f(this,le,yi).call(this,e))}insertaudio(t){f(this,le,yi).call(this,t.detail.element)}};le=new WeakSet,yi=function(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:Q.name}})):t.parentElement.removeChild(t)};var sr=class extends M{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var ar=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insertfigure",this)}insertfigure(t){t.detail.element.querySelector(":scope > "+r.FIGCAPTION)||t.detail.element.appendChild(this.editor.dom.createElement(r.FIGCAPTION))}};var O=class extends m{static get name(){return"figure"}static get dependencies(){return[h]}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 ar(this.editor),this.editor.filters.add(new sr(this.editor))}};var Bi={de:{Audio:"Audio",Cancel:"Abbrechen",ID:"ID","Insert URL to audio":"URL zur Audiodatei eingeben",Save:"Speichern",URL:"URL"}};var Q=class extends m{static get name(){return"audio"}static get dependencies(){return[h,O]}static get config(){return{browser:void 0}}init(){this._i18n(Bi),this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new or(this.editor),this.editor.dialogs.set(new ir(this.editor,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar(this._("Audio"))}};var nr=class extends L{constructor(t,e=void 0){super(t,ut.name,e)}_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var dr=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super();this.attachShadow({mode:"open"})}};var lr=class extends g{constructor(t){super(t);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock(t){if(!t.detail.element.id){t.detail.element.parentElement.removeChild(t.detail.element);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.detail.element.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(p=>`<link rel="stylesheet" href="${p}">`).join(""));let c=await i.text();t.detail.element.content=n+c}};var mr={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben",Save:"Speichern",URL:"URL",Width:"Breite"}};var ut=class extends m{static get name(){return"block"}static get dependencies(){return[h]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this._i18n(mr),this.editor.dom.registerElement(r.BLOCK,dr),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new lr(this.editor),this.editor.dialogs.set(new nr(this.editor,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar(this._("Block"))}};var hr=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(k.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.BLOCKQUOTE)),t.parentElement.removeChild(t))}};var cr=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote(t){this.editor.dom.wrap(t.detail.element,r.FIGURE,{attributes:{class:k.name}})}deleteblockquote(t){t.detail.target.localName===r.FIGURE&&t.detail.target.classList.contains(k.name)&&t.detail.target.parentElement.removeChild(t.detail.target)}};var fr=class extends M{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 P=class extends m{static get name(){return"break"}static get dependencies(){return[h]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new fr(this.editor))}};var Fi={de:{Blockquote:"Blockzitat"}};var k=class extends m{static get name(){return"blockquote"}static get dependencies(){return[h,P,O]}init(){this._i18n(Fi),this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new cr(this.editor),this._command(r.BLOCKQUOTE),this._toolbar(this._("Blockquote")),this.editor.filters.add(new hr(this.editor))}};var Gi={de:{bold:"fett"}};var pr=class extends m{static get name(){return"bold"}static get dependencies(){return[h]}init(){this._i18n(Gi),this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar(this._("bold"),a.B)}};var Pi={de:{Citation:"Zitatquelle"}};var ur=class extends m{static get name(){return"cite"}static get dependencies(){return[h]}init(){this._i18n(Pi),this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar(this._("Citation"),a.Z)}};var Ui={de:{Code:"Quelltext"}};var gr=class extends m{static get name(){return"code"}static get dependencies(){return[h]}init(){this._i18n(Ui),this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar(this._("Code"),a.C)}};var Er=class extends L{constructor(t){super(t,gt.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Hi={de:{Cancel:"Abbrechen",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var gt=class extends m{static get name(){return"data"}static get dependencies(){return[h]}init(){this._i18n(Hi),this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new Er(this.editor)),this._command(r.DATA),this._formatbar(this._("Data"),a.J)}};var br=class extends L{constructor(t){super(t,Et.name)}_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var ki={de:{Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff"}};var Et=class extends m{static get name(){return"definition"}static get dependencies(){return[h]}init(){this._i18n(ki),this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new br(this.editor)),this._command(r.DFN),this._formatbar(this._("Definition"),a.D)}};var Tr=class extends B{constructor(t){super(t,bt.name)}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var vi={de:{Delete:"L\xF6schen"}};var bt=class extends m{static get name(){return"delete"}static get dependencies(){return[h]}init(){this._i18n(vi),this.editor.commands.set(new Tr(this.editor)),this._focusbar(this._("Delete"),this.constructor.name)}};var Vi={de:{"Text Deletion":"Textl\xF6schung"}};var Ar=class extends m{static get name(){return"deletion"}static get dependencies(){return[h]}init(){this._i18n(Vi),this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar(this._("Text Deletion"),a.G)}};var Lr=class extends M{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 me,Ki,xr=class extends g{constructor(t){super(t);d(this,me);this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails(t){t.detail.element.open=!0,t.detail.element.querySelector(`:scope > ${r.SUMMARY}:first-child`)||t.detail.element.insertAdjacentElement(x.AFTERBEGIN,this.editor.dom.createElement(r.SUMMARY))}insertsummary(t){f(this,me,Ki).call(this,t.detail.element),t.detail.element.addEventListener("click",this),t.detail.element.addEventListener("blur",this),t.detail.element.addEventListener("keydown",this)}click(t){t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0}blur(t){f(this,me,Ki).call(this,t.target)}keydown(t){I(t,a.SPACE)?(t.preventDefault(),t.stopPropagation(),this.editor.dom.insertText(" ")):I(t,a.ENTER)&&(t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0)}};me=new WeakSet,Ki=function(t){t.textContent.trim()?t.querySelectorAll(r.BR+":not(:last-child)").forEach(e=>e.parentElement.removeChild(e)):t.textContent=this.editor.translator.translate(Tt.name,"Details"),t.lastElementChild instanceof HTMLBRElement||t.appendChild(this.editor.dom.createElement(r.BR))};var ji={de:{Details:"Details"}};var Tt=class extends m{static get name(){return"details"}static get dependencies(){return[h]}init(){this._i18n(ji),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 xr(this.editor),this._command(r.DETAILS),this._toolbar(this._("Details")),this.editor.filters.add(new Lr(this.editor))}};var Ir=class extends L{constructor(t){super(t,At.name)}_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var zi={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse",Division:"Division","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern"}};var At=class extends m{static get name(){return"division"}static get dependencies(){return[h]}init(){this._i18n(zi),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 Ir(this.editor)),this._command(r.DIV),this._toolbar(this._("Division"))}};var qi={de:{emphasized:"betont"}};var Nr=class extends m{static get name(){return"emphasis"}static get dependencies(){return[h]}init(){this._i18n(qi),this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar(this._("emphasized"),a.E)}};var Wi={de:{Heading:"\xDCberschrift"}};var _r=class extends m{static get name(){return"heading"}static get dependencies(){return[h]}init(){this._i18n(Wi),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(this._("Heading"))}};var $i={de:{"Horizontal Rule":"Horizontale Linie"}};var wr=class extends m{static get name(){return"horizontalrule"}static get dependencies(){return[h]}init(){this._i18n($i),this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar(this._("Horizontal Rule"))}};var Rr=class extends L{constructor(t,e=void 0){super(t,Y.name,e)}_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 he,Qi,Mr=class extends g{constructor(t){super(t);d(this,he);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.IFRAME)).forEach(e=>f(this,he,Qi).call(this,e))}insertiframe(t){f(this,he,Qi).call(this,t.detail.element)}};he=new WeakSet,Qi=function(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:Y.name}})):t.parentElement.removeChild(t)};var Y=class extends m{static get name(){return"iframe"}static get dependencies(){return[h,O]}static get config(){return{browser:void 0}}init(){this._i18n(mr),this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new Mr(this.editor),this.editor.dialogs.set(new Rr(this.editor,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar(this._("Iframe"))}};var Dr=class extends L{constructor(t,e=void 0){super(t,Z.name,e)}_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 ce,Yi,Or=class extends g{constructor(t){super(t);d(this,ce);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.IMG)).forEach(e=>f(this,ce,Yi).call(this,e))}insertimg(t){f(this,ce,Yi).call(this,t.detail.element)}};ce=new WeakSet,Yi=function(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:Z.name}})):t.parentElement.removeChild(t)};var Zi={de:{"Alternative text":"Alternativtext",Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben",Save:"Speichern","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist",URL:"URL",Width:"Breite"}};var Z=class extends m{static get name(){return"image"}static get dependencies(){return[h,O]}static get config(){return{browser:void 0}}init(){this._i18n(Zi),this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new Or(this.editor),this.editor.dialogs.set(new Dr(this.editor,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar(this._("Image"))}};var Xi={de:{"Text Insertion":"Texteinf\xFCgung"}};var Sr=class extends m{static get name(){return"insertion"}static get dependencies(){return[h]}init(){this._i18n(Xi),this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar(this._("Text Insertion"),a.F)}};var Ji={de:{italic:"kursiv"}};var Cr=class extends m{static get name(){return"italic"}static get dependencies(){return[h]}init(){this._i18n(Ji),this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar(this._("italic"),a.I)}};var to={de:{"User Input":"Benutzereingabe"}};var yr=class extends m{static get name(){return"keyboard"}static get dependencies(){return[h]}init(){this._i18n(to),this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar(this._("User Input"),a.K)}};var Br=class extends L{constructor(t){super(t,Lt.name)}_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var fe,eo,Fr=class extends g{constructor(t){super(t);d(this,fe);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.A)).forEach(e=>f(this,fe,eo).call(this,e))}inserta(t){f(this,fe,eo).call(this,t.detail.element)}};fe=new WeakSet,eo=function(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 ro={de:{Cancel:"Abbrechen","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",Save:"Speichern",URL:"URL"}};var Lt=class extends m{static get name(){return"link"}static get dependencies(){return[h]}init(){this._i18n(ro),this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new Fr(this.editor),this.editor.dialogs.set(new Br(this.editor)),this._command(r.A),this._formatbar(this._("Link"),a.L)}};var io={de:{mark:"markiert"}};var Gr=class extends m{static get name(){return"mark"}static get dependencies(){return[h]}init(){this._i18n(io),this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar(this._("mark"),a.M)}};var pe,oo,Pr=class extends g{constructor(t){super(t);d(this,pe);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(t){Array.from(t.detail.element.getElementsByTagName(r.LI)).forEach(e=>f(this,pe,oo).call(this,e))}insertli(t){f(this,pe,oo).call(this,t.detail.element)}deleteli(t){t.detail.target.children.length===0&&t.detail.target.parentElement.removeChild(t.detail.target)}insertol(t){t.detail.element.children.length===0&&t.detail.element.appendChild(this.editor.dom.createElement(r.LI))}insertul(t){this.insertol(t)}};pe=new WeakSet,oo=function(t){!(t.parentElement instanceof HTMLOListElement)&&!(t.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(t,r.UL)};var xt=class extends m{static get name(){return"list"}static get dependencies(){return[h,P]}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 Pr(this.editor)}};var so={de:{"Ordered List":"Geordnete Liste"}};var Ur=class extends m{static get name(){return"orderedlist"}static get dependencies(){return[h,xt]}init(){this._i18n(so),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(this._("Ordered List"))}};var ue,ao,Hr=class extends g{constructor(t){super(t);d(this,ue);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.P)).forEach(e=>f(this,ue,ao).call(this,e))}insertp(t){f(this,ue,ao).call(this,t.detail.element)}paste(t){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(t.target))}};ue=new WeakSet,ao=function(t){t.addEventListener("paste",this)};var no={de:{Paragraph:"Absatz"}};var kr=class extends m{static get name(){return"paragraph"}static get dependencies(){return[h,P]}init(){this._i18n(no),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 Hr(this.editor),this._command(r.P),this._toolbar(this._("Paragraph"))}};var vr=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(v.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.PRE)),t.parentElement.removeChild(t))}};var Vr=class extends g{constructor(t){super(t);this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre(t){this.editor.dom.wrap(t.detail.element,r.FIGURE,{attributes:{class:v.name}})}deletepre(t){t.detail.target.localName===r.FIGURE&&t.detail.target.classList.contains(v.name)&&t.detail.target.parentElement.removeChild(t.detail.target)}};var lo={de:{"Preformatted Text":"Vorformatierter Text"}};var v=class extends m{static get name(){return"preformat"}static get dependencies(){return[h,P,O]}init(){this._i18n(lo),this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new Vr(this.editor),this._command(r.PRE),this._toolbar(this._("Preformatted Text")),this.editor.filters.add(new vr(this.editor))}};var mo={de:{Quote:"Zitat"}};var Kr=class extends m{static get name(){return"quote"}static get dependencies(){return[h]}init(){this._i18n(mo),this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar(this._("Quote"),a.Q)}};var ho={de:{"Sample Output":"Beispielausgabe"}};var jr=class extends m{static get name(){return"sample"}static get dependencies(){return[h]}init(){this._i18n(ho),this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar(this._("Sample Output"),a.O)}};var zr=class extends L{constructor(t){super(t,It.name)}_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var co={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern",Section:"Sektion"}};var It=class extends m{static get name(){return"section"}static get dependencies(){return[h]}init(){this._i18n(co),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 zr(this.editor)),this._command(r.SECTION),this._toolbar(this._("Section"))}};var fo={de:{small:"klein"}};var qr=class extends m{static get name(){return"small"}static get dependencies(){return[h]}init(){this._i18n(fo),this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar(this._("small"),a.W)}};var ge,Wr=class extends B{constructor(t,e){let i=Object.entries(R).find(([,n])=>n===e)?.[0].toLowerCase();if(!i)throw new Error(u.INVALID_ARGUMENT);super(t,Nt.name+"-"+i);d(this,ge,void 0);b(this,ge,e)}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-sortable")&&this.editor.dom.sort(t,l(this,ge))}};ge=new WeakMap;var po={de:{"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"}};var Nt=class extends m{static get name(){return"sort"}static get dependencies(){return[h]}init(){this._i18n(po);let t={[R.FIRST]:this._("Sort to the beginning"),[R.PREV]:this._("Sort before previous element"),[R.NEXT]:this._("Sort after next element"),[R.LAST]:this._("Sort to the end")};Object.entries(t).forEach(([e,i])=>{let n=new Wr(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var uo={de:{strikethrough:"durchgestrichen"}};var $r=class extends m{static get name(){return"strikethrough"}static get dependencies(){return[h]}init(){this._i18n(uo),this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar(this._("strikethrough"),a.R)}};var go={de:{"strongly emphasized":"stark betont"}};var Qr=class extends m{static get name(){return"strong"}static get dependencies(){return[h]}init(){this._i18n(go),this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar(this._("strongly emphasized"),a.S)}};var Eo={de:{Subheading:"Unter\xFCberschrift"}};var Yr=class extends m{static get name(){return"subheading"}static get dependencies(){return[h]}init(){this._i18n(Eo),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(this._("Subheading"))}};var bo={de:{subscript:"tiefgestellt"}};var Zr=class extends m{static get name(){return"subscript"}static get dependencies(){return[h]}init(){this._i18n(bo),this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar(this._("subscript"),a.X)}};var To={de:{superscript:"hochgestellt"}};var Xr=class extends m{static get name(){return"superscript"}static get dependencies(){return[h]}init(){this._i18n(To),this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar(this._("superscript"),a.Y)}};var Jr=class extends B{constructor(t){super(t,F.name,r.TABLE)}insert({rows:t,cols:e}={}){let i=this.editor.dom.createElement(r.FIGURE,{attributes:{class:F.name}}),n=this.editor.dom.createElement(r.TABLE),c=this.editor.dom.createElement(r.TBODY),p=parseInt(t,10)||1,E=parseInt(e,10)||1;for(let T=0;T<p;T++){let A=this.editor.dom.createElement(r.TR);c.appendChild(A);for(let y=0;y<E;++y)A.appendChild(this.editor.dom.createElement(r.TD))}n.appendChild(c),i.appendChild(n),this.editor.dom.insert(i)}};var ti=class extends L{constructor(t){super(t,F.name)}_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 ei=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(F.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.TABLE)),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 ot,ii,_t,bi,oi,vo,ri=class extends g{constructor(t){super(t);d(this,ot);d(this,_t);d(this,oi);this.editor.root.addEventListener("inserttable",this),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttable(t){this.editor.dom.wrap(t.detail.element,r.FIGURE,{attributes:{class:F.name}}),t.detail.element.tBodies.length>0&&t.detail.element.tBodies[0].rows[0]&&(!t.detail.element.tHead||!t.detail.element.tFoot)&&(t.detail.element.tHead||f(this,ot,ii).call(this,t.detail.element.createTHead(),t.detail.element.tBodies[0].rows[0].cells.length),t.detail.element.tFoot||f(this,ot,ii).call(this,t.detail.element.createTFoot(),t.detail.element.tBodies[0].rows[0].cells.length))}inserttd(t){t.detail.element.addEventListener("keydown",this)}insertth(t){t.detail.element.addEventListener("keydown",this)}keydown(t){let e=t.target,i=e.parentElement,n=i.parentElement,c=n instanceof HTMLTableElement?n:n.parentElement,p=[a.LEFT,a.RIGHT,a.UP,a.DOWN],E=I(t,p),T=I(t,p,{ctrl:!0}),A=I(t,p,{alt:!0}),y=I(t,p,{alt:!0,shift:!0});if(e instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&(n instanceof HTMLTableElement||n instanceof HTMLTableSectionElement)&&c instanceof HTMLTableElement&&(E&&f(this,oi,vo).call(this,e,t.key)||T||A||y)){let w=e.cellIndex,H=i.cells.length,st=n.rows.length,U=n instanceof HTMLTableElement?i.rowIndex:i.sectionRowIndex,hi=w===0,ci=w===H-1,Do=U===0,Oo=U===st-1,Ai=i.rowIndex===0,Li=i.rowIndex===c.rows.length-1;t.preventDefault(),t.stopPropagation(),E?t.key===a.LEFT&&!hi?this.editor.dom.focusEnd(i.cells[w-1]):t.key===a.LEFT&&Ai?this.editor.dom.focusEnd(c.rows[c.rows.length-1].cells[H-1]):t.key===a.LEFT?this.editor.dom.focusEnd(c.rows[i.rowIndex-1].cells[H-1]):t.key===a.RIGHT&&!ci?i.cells[w+1].focus():t.key===a.RIGHT&&Li?c.rows[0].cells[0].focus():t.key===a.RIGHT?c.rows[i.rowIndex+1].cells[0].focus():t.key===a.UP&&Ai?c.rows[c.rows.length-1].cells[w].focus():t.key===a.UP?c.rows[i.rowIndex-1].cells[w].focus():t.key===a.DOWN&&Li?c.rows[0].cells[w].focus():t.key===a.DOWN&&c.rows[i.rowIndex+1].cells[w].focus():T?(t.key===a.LEFT&&H>1&&hi?Array.from(c.rows).forEach(_=>_.appendChild(_.cells[w])):t.key===a.LEFT&&H>1?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w],_.cells[w-1])):t.key===a.RIGHT&&H>1&&ci?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w],_.cells[0])):t.key===a.RIGHT&&H>1?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w+1],_.cells[w])):t.key===a.UP&&st>1&&Do?n.appendChild(i):t.key===a.UP&&st>1?n.insertBefore(i,n.rows[U-1]):t.key===a.DOWN&&st>1&&Oo?n.insertBefore(i,n.rows[0]):t.key===a.DOWN&&st>1&&n.insertBefore(n.rows[U+1],i),e.focus()):A?t.key===a.LEFT?Array.from(c.rows).forEach(_=>f(this,_t,bi).call(this,_,_.cells[w])):t.key===a.RIGHT?Array.from(c.rows).forEach(_=>f(this,_t,bi).call(this,_,_.cells[w+1])):t.key===a.UP?f(this,ot,ii).call(this,n,H,U):t.key===a.DOWN&&f(this,ot,ii).call(this,n,H,U+1):y&&(t.key===a.LEFT&&!hi?Array.from(c.rows).forEach(_=>_.deleteCell(w-1)):t.key===a.RIGHT&&!ci?Array.from(c.rows).forEach(_=>_.deleteCell(w+1)):t.key===a.UP&&U>0?n.deleteRow(U-1):t.key===a.DOWN&&U<st-1&&n.deleteRow(U+1))}}};ot=new WeakSet,ii=function(t,e,i=0){let n=t.insertRow(i);for(let c=0;c<e;c++)f(this,_t,bi).call(this,n)},_t=new WeakSet,bi=function(t,e=null){let i=t.parentElement.localName===r.THEAD?r.TH:r.TD;t.insertBefore(this.editor.dom.createElement(i),e)},oi=new WeakSet,vo=function(t,e){if([a.UP,a.DOWN].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.LEFT){let p=t.firstChild;return p instanceof HTMLElement&&(p=p.firstChild),i.anchorOffset===0&&[t,p].includes(n)}let c=t.lastChild;return t.lastChild instanceof HTMLBRElement&&t.lastChild.previousSibling&&(c=t.lastChild.previousSibling),c instanceof HTMLElement&&(c=c.lastChild),i.anchorOffset===n.textContent.length&&[t,c].includes(n)};var Ao={de:{Cancel:"Abbrechen",Columns:"Spalten","Delete next column":"N\xE4chste Spalte l\xF6schen","Delete next row":"N\xE4chste Zeile l\xF6schen","Delete previous column":"Vorherige Spalte l\xF6schen","Delete previous row":"Vorherige Zeile l\xF6schen",Rows:"Zeilen",Save:"Speichern","Sort after next column":"Hinter die n\xE4chste Spalte sortieren","Sort after next row":"Hinter die n\xE4chste Zeile sortieren","Sort before previous column":"Vor die vorherige Spalte sortieren","Sort before previous row":"Vor die vorherige Zeile sortieren","Sort column to the beginning":"Spalte an den Anfang sortieren","Sort row to the beginning":"Zeile an den Anfang sortieren","Sort column to the end":"Spalte ans Ende sortieren","Sort row to the end":"Zeile ans Ende sortieren",Table:"Tabelle"}};var wt,Ti,Ee,Lo,F=class extends m{constructor(){super(...arguments);d(this,wt);d(this,Ee)}static get name(){return"table"}static get dependencies(){return[h,P,O]}init(){this._i18n(Ao),this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag(f(this,wt,Ti).call(this,r.THEAD)),this._tag(f(this,wt,Ti).call(this,r.TBODY)),this._tag(f(this,wt,Ti).call(this,r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL]}),this._tag(f(this,Ee,Lo).call(this,r.TH)),this._tag(f(this,Ee,Lo).call(this,r.TD)),new ri(this.editor),this.editor.filters.add(new ei(this.editor)),this.editor.dialogs.set(new ti(this.editor)),this.editor.commands.set(new Jr(this.editor)),this._toolbar(this._("Table"))}};wt=new WeakSet,Ti=function(t){return{name:t,group:o.TABLESECTION,children:[o.TABLEROW]}},Ee=new WeakSet,Lo=function(t){return{name:t,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}};var si=class extends L{constructor(t){super(t,Rt.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var xo={de:{Cancel:"Abbrechen","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Save:"Speichern",Time:"Zeit"}};var Rt=class extends m{static get name(){return"time"}static get dependencies(){return[h]}init(){this._i18n(xo),this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new si(this.editor)),this._command(r.TIME),this._formatbar(this._("Time"),a.T)}};var Io={de:{underline:"unterstrichen"}};var ai=class extends m{static get name(){return"underline"}static get dependencies(){return[h]}init(){this._i18n(Io),this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar(this._("underline"),a.U)}};var No={de:{"Unordered List":"Ungeordnete Liste"}};var ni=class extends m{static get name(){return"unorderedlist"}static get dependencies(){return[h,xt]}init(){this._i18n(No),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(this._("Unordered List"))}};var _o={de:{Variable:"Variable"}};var di=class extends m{static get name(){return"variable"}static get dependencies(){return[h]}init(){this._i18n(_o),this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar(this._("Variable"),a.V)}};var li=class extends L{constructor(t,e=void 0){super(t,X.name,e)}_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 be,wo,mi=class extends g{constructor(t){super(t);d(this,be);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.VIDEO)).forEach(e=>f(this,be,wo).call(this,e))}insertvideo(t){f(this,be,wo).call(this,t.detail.element)}};be=new WeakSet,wo=function(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:X.name}})):t.parentElement.removeChild(t)};var Ro={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID","Insert URL to video":"URL zur Videodatei eingeben",Save:"Speichern",URL:"URL",Video:"Video",Width:"Breite"}};var X=class extends m{static get name(){return"video"}static get dependencies(){return[h,O]}static get config(){return{browser:void 0}}init(){this._i18n(Ro),this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new mi(this.editor),this.editor.dialogs.set(new li(this.editor,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar(this._("Video"))}};var Mo=class extends D{static get defaultConfig(){return{base:{plugins:[pr,Cr,Qr,Nr,ai,$r,Lt,Gr,qr,Et,ct,Kr,ur,gr,yr,jr,di,Zr,Xr,Rt,gt,Sr,Ar,kr,_r,Yr,ni,Ur,wr,k,Z,X,Q,Y,F,v,It,Tt,At,ut,pt,Nt,bt]}}}};export{Mo as default};
|
|
1
|
+
var vo=Object.defineProperty;var Ko=(s,t,e)=>t in s?vo(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var S=(s,t,e)=>(Ko(s,typeof t!="symbol"?t+"":t,e),e),bi=(s,t,e)=>{if(!t.has(s))throw TypeError("Cannot "+e)};var m=(s,t,e)=>(bi(s,t,"read from private field"),e?e.call(s):t.get(s)),d=(s,t,e)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,e)},b=(s,t,e,i)=>(bi(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e);var p=(s,t,e)=>(bi(s,t,"access private method"),e);var C=Object.freeze({CENTER:"center",LEFT:"left",NONE:"none",RIGHT:"right"}),u=Object.freeze({INVALID_ARGUMENT:"Invalid argument",MISSING_NAME:"Missing name",NOT_IMPLEMENTED:"Not implemented"}),a=Object.freeze({A:"a",B:"b",BACKSPACE:"Backspace",C:"c",D:"d",DEL:"Delete",DOWN:"ArrowDown",E:"e",END:"End",ENTER:"Enter",ESC:"Escape",F:"f",G:"g",HOME:"Home",I:"i",J:"j",K:"k",L:"l",LEFT:"ArrowLeft",M:"m",O:"o",Q:"q",R:"r",RIGHT:"ArrowRight",S:"s",SPACE:" ",T:"t",TAB:"Tab",U:"u",UP:"ArrowUp",V:"v",W:"w",X:"x",Y:"y",Z:"z"}),x=Object.freeze({AFTERBEGIN:"afterbegin",AFTEREND:"afterend",BEFOREBEGIN:"beforebegin",BEFOREEND:"beforeend"}),R=Object.freeze({FIRST:"first",LAST:"last",NEXT:"next",PREV:"prev"}),o=Object.freeze({AUDIO:"audio",BLOCK:"block",BREAK:"break",CAPTION:"caption",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"}),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",DATA:"data",DEL:"del",DETAILS:"details",DFN:"dfn",DIALOG:"editor-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"}),$r=Object.freeze({FUNCTION:"function",STRING:"string",UNDEFINED:"undefined"});function I(s,t,{alt:e=!1,ctrl:i=!1,shift:n=!1}={}){return(Array.isArray(t)&&t.includes(s.key)||s.key===t)&&s.altKey===e&&s.ctrlKey===i&&s.shiftKey===n}function Ot(s){return typeof s===$r.UNDEFINED}function $(s){return typeof s===$r.FUNCTION}function N(s){return s&&typeof s===$r.STRING}function Q(s){return Ot(s)||N(s)}function Ti(s){return Ot(s)||Array.isArray(s)&&s.length>0}function Ai(s){return Ot(s)||s instanceof HTMLElement}var yt,Dt,St,Ct,Bt,Li,Ft,xi,B=class{constructor(t,e,i=void 0){d(this,Bt);d(this,Ft);d(this,yt,void 0);d(this,Dt,void 0);d(this,St,void 0);d(this,Ct,void 0);if(!(t instanceof y)||!N(e)||!Q(i))throw new Error(u.INVALID_ARGUMENT);b(this,yt,t),b(this,Dt,e),b(this,St,i&&this.editor.tags.get(i)),b(this,Ct,this.editor.dialogs.get(e))}get editor(){return m(this,yt)}get name(){return m(this,Dt)}get tag(){return m(this,St)}get dialog(){return m(this,Ct)}execute(){this.dialog?this.openDialog():this.insert(p(this,Bt,Li).call(this))}insert(t={}){if(!this.tag)return;p(this,Ft,xi).call(this,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),p(this,Bt,Li).call(this))}};yt=new WeakMap,Dt=new WeakMap,St=new WeakMap,Ct=new WeakMap,Bt=new WeakSet,Li=function(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return p(this,Ft,xi).call(this,t),t},Ft=new WeakSet,xi=function(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])};var Y,Gt=class{constructor(t=[]){d(this,Y,new Map);t.forEach(e=>this.set(e))}get(t){return m(this,Y).get(t)}set(t){if(!(t instanceof B))throw new Error(u.INVALID_ARGUMENT);m(this,Y).set(t.name,t)}find(t){return Array.from(m(this,Y).values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){m(this,Y).forEach(t=>Object.freeze(t)),Object.freeze(m(this,Y)),Object.freeze(this)}};Y=new WeakMap;var et,Ut=class{constructor(t=[]){d(this,et,new Map);t.forEach(e=>this.set(e))}get(t){return m(this,et).get(t)}set(t){if(!(t instanceof L))throw new Error(u.INVALID_ARGUMENT);m(this,et).set(t.name,t)}freeze(){m(this,et).forEach(t=>Object.freeze(t)),Object.freeze(m(this,et)),Object.freeze(this)}};et=new WeakMap;var xt,It,Qr,Yr,vi,Z=class{constructor(t){d(this,It);d(this,Yr);d(this,xt,void 0);if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);b(this,xt,t),this.register(p(this,Yr,vi).bind(this))}dispatch(t,e=void 0,i=void 0){if(!N(t)||!Ai(e)||!Ai(i))throw new Error(u.INVALID_ARGUMENT);m(this,xt).dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!$(t))throw new Error(u.INVALID_ARGUMENT);new MutationObserver(t).observe(m(this,xt),e)}};xt=new WeakMap,It=new WeakSet,Qr=function(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))},Yr=new WeakSet,vi=function(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(p(this,It,Qr).call(this,"insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>p(this,It,Qr).call(this,"insert",n,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&p(this,It,Qr).call(this,"delete",i,e.target))})};var Pt,Ht,kt,vt,Zr,Xr,Ki,rt=class{constructor(t,e){d(this,Xr);d(this,Pt,void 0);d(this,Ht,void 0);d(this,kt,void 0);d(this,vt,void 0);d(this,Zr,{alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""});if(!(t instanceof y)||!(e instanceof Document))throw new Error(u.INVALID_ARGUMENT);b(this,Pt,t),b(this,Ht,e),b(this,kt,this.document.defaultView),b(this,vt,this.document.documentElement)}get editor(){return m(this,Pt)}get document(){return m(this,Ht)}get window(){return m(this,kt)}get root(){return m(this,vt)}registerElement(t,e,i=void 0){Ot(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(([f,c])=>c&&n.setAttribute(f,`${c}`)),n}insert(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))e.insertAdjacentElement(x.BEFOREBEGIN,t);else if(e)this.closest(e,t)?.insertAdjacentElement(x.AFTEREND,t),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e);else if(this.editor.tags.allowed(this.editor.root,t))this.editor.root.appendChild(t);else throw new Error(u.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 Error(u.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(),f=Array.from(e.cloneContents().childNodes).every(c=>c instanceof Text&&!c.textContent.trim()||c instanceof HTMLElement&&c.localName===t.localName);e.deleteContents(),f?e.insertNode(this.createText(n)):(t.textContent=n,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new Error(u.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 Error(u.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 f=this.createElement(e,i);n.insertAdjacentElement(x.AFTEREND,f),f.appendChild(t)}}else throw new Error(u.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]"),f=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===f&&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 Error(u.INVALID_ARGUMENT);let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}delete(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);let e=t.previousElementSibling,i=t.nextElementSibling;t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}sort(t,e){if(!(t instanceof HTMLElement)||!Object.values(R).includes(e))throw new Error(u.INVALID_ARGUMENT);let i=t.parentElement,n=t.previousElementSibling,f=t.nextElementSibling,c=i.firstElementChild,E=i.lastElementChild,T=t===c,A=t===E;e===R.PREV&&!T&&n.hasAttribute("data-sortable")?(n.insertAdjacentHTML(x.BEFOREBEGIN,t.outerHTML),i.removeChild(t)):e===R.NEXT&&!A&&f.hasAttribute("data-sortable")?(f.insertAdjacentHTML(x.AFTEREND,t.outerHTML),i.removeChild(t)):(e===R.FIRST&&!T||e===R.NEXT&&A)&&c.hasAttribute("data-sortable")?(c.insertAdjacentHTML(x.BEFOREBEGIN,t.outerHTML),i.removeChild(t)):(e===R.LAST&&!A||e===R.PREV&&T)&&E.hasAttribute("data-sortable")&&(E.insertAdjacentHTML(x.AFTEREND,t.outerHTML),i.removeChild(t))}open({url:t,name:e,call:i,params:n={}}){if(!N(t)||!N(e)||!$(i))throw new Error(u.INVALID_ARGUMENT);let f=this.createElement(r.A,{attributes:{href:t}}),c=new URL(f.href);Object.entries(n).forEach(([T,A])=>c.searchParams.set(T,`${A}`));let E=this.window.open(c.toString(),e,p(this,Xr,Ki).call(this));this.window.addEventListener("message",T=>{T.origin===c.origin&&T.source===E&&(i(T.data),E.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}};Pt=new WeakMap,Ht=new WeakMap,kt=new WeakMap,vt=new WeakMap,Zr=new WeakMap,Xr=new WeakSet,Ki=function(){let t=Object.assign({},m(this,Zr),{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 Kt,M=class{constructor(t){d(this,Kt,void 0);if(!(t instanceof y))throw new Error(u.INVALID_ARGUMENT);b(this,Kt,t)}get editor(){return m(this,Kt)}filter(t){throw new Error(u.NOT_IMPLEMENTED)}};Kt=new WeakMap;var it,Vt=class{constructor(){d(this,it,new Set)}add(t){if(!(t instanceof M))throw new Error(u.INVALID_ARGUMENT);m(this,it).add(t)}filter(t){if(!(t instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);m(this,it).forEach(e=>{t.normalize(),e.filter(t)})}freeze(){m(this,it).forEach(t=>Object.freeze(t)),Object.freeze(m(this,it)),Object.freeze(this)}};it=new WeakMap;var ot=class{constructor({name:t,group:e,...i}={}){S(this,"name");S(this,"group");S(this,"children");S(this,"attributes");S(this,"alignable");S(this,"arbitrary");S(this,"deletable");S(this,"editable");S(this,"empty");S(this,"focusable");S(this,"navigable");S(this,"slotable");S(this,"sortable");S(this,"enter");if(!N(t)||!N(e)||!Ti(i.children)||!Ti(i.attributes)||!Q(i.enter))throw new Error(u.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 jt,Nt,Jr,l=class{constructor(t){d(this,Nt);d(this,jt,void 0);if(!(t instanceof y))throw new Error(u.INVALID_ARGUMENT);b(this,jt,t)}get editor(){return m(this,jt)}static get name(){throw new Error(u.MISSING_NAME)}static get dependencies(){return[]}static get config(){return{}}init(){throw new Error(u.NOT_IMPLEMENTED)}_(t){return this.editor.translator.translate(this.constructor.name,t)}_base(t){return this.editor.translator.translate("base",t)}_i18n(t){t[this.editor.config.base.lang]&&this.editor.translator.set(this.constructor.name,t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new ot(t))}_command(t){this.editor.commands.set(new B(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){this.editor.toolbar.appendChild(p(this,Nt,Jr).call(this,t,t,void 0,e))}_formatbar(t,e=void 0,i=void 0){let n=this._base("Alt"),f=this._base("Shift"),c=t+(e?` [${n} + ${f} + ${e}]`:"");this.editor.formatbar.appendChild(p(this,Nt,Jr).call(this,t,c,e,i))}_focusbar(t,e=void 0){this.editor.focusbar.appendChild(p(this,Nt,Jr).call(this,t,t,void 0,e))}};jt=new WeakMap,Nt=new WeakSet,Jr=function(t,e,i=void 0,n=void 0){if(!N(t)||!N(e)||!Q(i))throw new Error(u.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 X,zt=class{constructor(t=[]){d(this,X,new Map);t.forEach(e=>this.set(e))}get(t){return m(this,X).get(t)}set(t){if(!(t instanceof l))throw new Error(u.INVALID_ARGUMENT);m(this,X).set(t.constructor.name,t)}init(){m(this,X).forEach(t=>t.init())}freeze(){m(this,X).forEach(t=>Object.freeze(t)),Object.freeze(m(this,X)),Object.freeze(this)}};X=new WeakMap;var st,qt=class{constructor(t=[]){d(this,st,new Map);t.forEach(e=>this.set(e))}get(t){return m(this,st).get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof ot))throw new Error(u.INVALID_ARGUMENT);m(this,st).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(){m(this,st).forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(m(this,st)),Object.freeze(this)}};st=new WeakMap;var at,Wt=class{constructor(){d(this,at,new Map)}get(t){return m(this,at).get(t)}set(t,e){if(!N(t)||!(e instanceof Object))throw new Error(u.INVALID_ARGUMENT);m(this,at).set(t,e)}translate(t,e){return this.get(t)?.[e]||e}freeze(){m(this,at).forEach(t=>Object.freeze(t)),Object.freeze(m(this,at)),Object.freeze(this)}};at=new WeakMap;var $t,_t,Qt,Yt,Zt,Xt,Jt,te,ee,re,ie,oe,ti,ei,ri,ii,oi,si,y=class{constructor(t,e={}){d(this,$t,void 0);d(this,_t,{});d(this,Qt,void 0);d(this,Yt,void 0);d(this,Zt,void 0);d(this,Xt,void 0);d(this,Jt,void 0);d(this,te,void 0);d(this,ee,void 0);d(this,re,void 0);d(this,ie,void 0);d(this,oe,void 0);d(this,ti,new Wt);d(this,ei,new qt);d(this,ri,new Vt);d(this,ii,new Ut);d(this,oi,new Gt);d(this,si,new zt);if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new Error(u.INVALID_ARGUMENT);b(this,$t,t),b(this,_t,e),b(this,Qt,new rt(this,this.orig.ownerDocument)),b(this,Yt,this.dom.createElement(r.EDITOR)),b(this,Zt,this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}})),this.element.appendChild(this.toolbar),b(this,Xt,new Z(this.toolbar)),b(this,Jt,this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}})),this.formatbar.hidden=!0,this.element.appendChild(this.formatbar),b(this,te,new Z(this.formatbar)),b(this,ee,this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}})),this.focusbar.hidden=!0,this.element.appendChild(this.focusbar),b(this,re,new Z(this.focusbar)),b(this,ie,this.dom.createElement(r.ROOT)),this.element.appendChild(this.root),b(this,oe,new Z(this.root))}get orig(){return m(this,$t)}get config(){return m(this,_t)}get dom(){return m(this,Qt)}get element(){return m(this,Yt)}get toolbar(){return m(this,Zt)}get toolbarDispatcher(){return m(this,Xt)}get formatbar(){return m(this,Jt)}get formatbarDispatcher(){return m(this,te)}get focusbar(){return m(this,ee)}get focusbarDispatcher(){return m(this,re)}get root(){return m(this,ie)}get rootDispatcher(){return m(this,oe)}get translator(){return m(this,ti)}get tags(){return m(this,ei)}get filters(){return m(this,ri)}get dialogs(){return m(this,ii)}get commands(){return m(this,oi)}get plugins(){return m(this,si)}static get defaultConfig(){return{}}init(){let t=this.config;b(this,_t,{});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(E=>!c.includes(E.name)):(i=[],c.forEach(E=>{let T=e.find(A=>A.name===E);T&&i.push(T)}))}let n=new Set,f=c=>{c.dependencies?.forEach(f),n.add(c)};i.map(f),n.forEach(c=>{Object.entries(c.config).forEach(([E,T])=>{var A,O;(A=this.config)[O=c.name]??(A[O]={}),this.config[c.name][E]=t[c.name]?.[E]||this.constructor.defaultConfig[c.name]?.[E]||T}),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),this.translator.freeze(),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.orig.insertAdjacentElement(x.AFTEREND,this.element),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")}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}};$t=new WeakMap,_t=new WeakMap,Qt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,Jt=new WeakMap,te=new WeakMap,ee=new WeakMap,re=new WeakMap,ie=new WeakMap,oe=new WeakMap,ti=new WeakMap,ei=new WeakMap,ri=new WeakMap,ii=new WeakMap,oi=new WeakMap,si=new WeakMap;var U,J,tt,ai,Vi,ni,ji,se=class{constructor(t,e,i,n){d(this,ai);d(this,ni);d(this,U,void 0);d(this,J,void 0);d(this,tt,void 0);var f,c;if(!(t instanceof rt)||!N(e)||!N(i)||!$(n))throw new Error(u.INVALID_ARGUMENT);b(this,U,t),b(this,J,m(this,U).createElement(r.FORM,{attributes:{method:"dialog"}})),p(c=p(f=this.addFieldset(),ai,Vi).call(f,i,n),ni,ji).call(c,e)}get form(){return m(this,J)}addFieldset(){let t=m(this,U).createElement(r.FIELDSET);return m(this,tt)?m(this,tt).insertAdjacentElement(x.AFTEREND,t):m(this,J).insertAdjacentElement(x.AFTERBEGIN,t),b(this,tt,t),this}addLegend(t){if(!N(t))throw new Error(u.INVALID_ARGUMENT);return m(this,tt).appendChild(m(this,U).createElement(r.LEGEND,{html:t})),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(!N(t)||!N(e)||!N(n))throw new Error(u.INVALID_ARGUMENT);Object.assign(i,{id:`editor-${t}`,name:t,type:n});let f=m(this,U).createElement(r.DIV);return f.appendChild(m(this,U).createElement(r.LABEL,{attributes:{for:i.id},html:e})),f.appendChild(m(this,U).createElement(r.INPUT,{attributes:i})),i.required&&f.setAttribute("data-required",""),m(this,tt).appendChild(f),this}};U=new WeakMap,J=new WeakMap,tt=new WeakMap,ai=new WeakSet,Vi=function(t,e){let i=m(this,U).createElement(r.BUTTON,{attributes:{type:"button"},html:t});return i.addEventListener("click",e),m(this,J).appendChild(i),this},ni=new WeakSet,ji=function(t){return m(this,J).appendChild(m(this,U).createElement(r.BUTTON,{html:t})),this};var ae,ne,de,le,di,zi,li,qi,me,Ii,L=class{constructor(t,e,i=void 0){d(this,di);d(this,li);d(this,me);d(this,ae,void 0);d(this,ne,void 0);d(this,de,void 0);d(this,le,void 0);if(!(t instanceof y)||!N(e)||!Q(i))throw new Error(u.INVALID_ARGUMENT);b(this,ae,t),b(this,ne,e),b(this,de,i)}get editor(){return m(this,ae)}get name(){return m(this,ne)}get url(){return m(this,de)}get formCreator(){return m(this,le)}open(t,e={}){this.url?p(this,di,zi).call(this,t,e):p(this,li,qi).call(this,t,e)}_(t){return this.editor.translator.translate(this.name,t)}_prepareForm(){throw new Error(u.NOT_IMPLEMENTED)}};ae=new WeakMap,ne=new WeakMap,de=new WeakMap,le=new WeakMap,di=new WeakSet,zi=function(t,e={}){this.editor.dom.open({url:this.url,name:this.name,call:t,params:e})},li=new WeakSet,qi=function(t,e={}){let i=this.editor.dom.getRange(),n=()=>{i&&this.editor.dom.setRange(i),p(this,me,Ii).call(this)};p(this,me,Ii).call(this),b(this,le,new se(this.editor.dom,this._("Save"),this._("Cancel"),n)),this._prepareForm();let f=this.formCreator.form;f.addEventListener("submit",E=>{E.preventDefault(),E.stopPropagation(),n();let T={};Array.from(f.elements).forEach(A=>T[A.name]=A.value),t(T)}),Object.entries(e).forEach(([E,T])=>f.elements[E]&&(f.elements[E].value=T));let c=this.editor.dom.createElement(r.DIALOG);c.addEventListener("close",n),c.appendChild(f),c.show(),this.editor.element.appendChild(c)},me=new WeakSet,Ii=function(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})};var he=class extends L{constructor(t){super(t,nt.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var ce,g=class{constructor(t){d(this,ce,void 0);if(!(t instanceof y))throw new Error(u.INVALID_ARGUMENT);b(this,ce,t)}get editor(){return m(this,ce)}handleEvent(t){$(this[t.type])&&this[t.type](t)}};ce=new WeakMap;var fe=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-alignable")&&t.detail.element.addEventListener("keydown",this)}keydown(t){let e={[a.UP]:C.NONE,[a.LEFT]:C.LEFT,[a.DOWN]:C.CENTER,[a.RIGHT]:C.RIGHT};t.target===t.currentTarget&&I(t,Object.keys(e),{shift:!0})&&(t.preventDefault(),t.stopPropagation(),t.target.classList.remove(...Object.values(e)),e[t.key]!==C.NONE&&t.target.classList.add(e[t.key]))}};var mi,Wi,ue,Ni,pe=class extends M{constructor(){super(...arguments);d(this,mi);d(this,ue)}filter(e){let i=this.editor.tags.get(e),n=this.editor.tags.allowed(e,r.P),f=i.editable||i.group===o.FORMAT,c=[],E=(T=null)=>{n&&c.length>0&&(e.insertBefore(this.editor.dom.createElement(r.P,{html:c.join(" ")}),T),c=[])};Array.from(e.childNodes).forEach(T=>{let A=T.textContent.trim();if(T instanceof HTMLElement){let O=p(this,mi,Wi).call(this,T),W=this.editor.tags.get(O);if(W&&this.editor.tags.allowed(e,O))E(O),p(this,ue,Ni).call(this,O,W);else if(W&&W.group===o.FORMAT&&n){let w=p(this,ue,Ni).call(this,O,W);w&&(c.push(w.outerHTML),e.removeChild(w))}else!f&&A&&n?(c.push(A),e.removeChild(O)):f&&A?e.replaceChild(this.editor.dom.createText(A),O):e.removeChild(O)}else T instanceof Text?(!f&&A&&n&&c.push(A),(!f||!A)&&e.removeChild(T)):T instanceof Node&&e.removeChild(T)}),E()}};mi=new WeakSet,Wi=function(e){let i=this.editor.config.base.filter[e.localName];if(!i)return e;let n=this.editor.dom.createElement(i,{html:e.innerHTML});return e.parentElement.replaceChild(n,e),n},ue=new WeakSet,Ni=function(e,i){if(Array.from(e.attributes).forEach(n=>!i.attributes.includes(n.name)&&e.removeAttribute(n.name)),e.hasChildNodes()&&this.editor.filters.filter(e),e.hasChildNodes()||i.empty)return e;e.parentElement?.removeChild(e)};var ge=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-deletable")&&t.detail.element.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&I(t,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var Ee=class extends HTMLElement{get open(){return this.hasAttribute("open")}set open(t){t===!0?this.setAttribute("open",""):this.removeAttribute("open")}constructor(){super(),this.addEventListener("keydown",t=>t.key===a.ESC&&this.close()),this.addEventListener("click",t=>t.target===this&&this.close())}connectedCallback(){this.setAttribute("role","dialog"),this.tabIndex=-1,this.focus()}show(){this.open=!0,this.dispatchEvent(new CustomEvent("show",{detail:{element:this,target:this}}))}close(){this.open=!1,this.dispatchEvent(new CustomEvent("close",{detail:{element:this,target:this}}))}};var be=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.contentEditable==="true"?t.detail.element.addEventListener("keydown",this):t.detail.element.parentElement.contentEditable==="true"&&t.detail.element.addEventListener("dblclick",this)}keydown(t){if(I(t,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(I(t,a.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;e&&(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")?this.editor.dom.closest(t.target,e)?.insertAdjacentElement(x.AFTEREND,this.editor.dom.createElement(e)):t.target instanceof HTMLParagraphElement||(this.editor.dom.closest(t.target,r.P)?.insertAdjacentElement(x.AFTEREND,this.editor.dom.createElement(r.P)),t.target.parentElement.removeChild(t.target)))}else I(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)&&I(t,t.key,{alt:!0,shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick(t){this.editor.dom.selectContents(t.target),this.editor.commands.find(t.target.localName)?.execute()}};var Te=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element.hasAttribute("data-focusable")&&t.detail.element.focus()}};var K=class extends g{insertbutton(t){t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("click",this)}click(t){this.editor.commands.execute(t.target.getAttribute("data-command"))}keydown(t){if(I(t,[a.LEFT,a.RIGHT,a.HOME,a.END])){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,f=t.target.parentElement.lastElementChild,c=t.target===n,E=t.target===f;t.key===a.LEFT&&!c?e.focus():t.key===a.RIGHT&&!E?i.focus():t.key===a.HOME||t.key===a.RIGHT&&E?n.focus():(t.key===a.END||t.key===a.LEFT&&c)&&f.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new Error(u.INVALID_ARGUMENT);t.hidden=!1;let{x:i,y:n}=e.getBoundingClientRect(),{x:f,y:c}=this.editor.root.getBoundingClientRect(),E=i-f+t.clientWidth-this.editor.root.clientWidth,T=n-c-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,A=t.clientWidth<this.editor.root.clientWidth?i-f:0;A>0&&E>0&&(A=A>E?(A-E)/2:0),t.style.left=`${A}px`,t.style.top=`${T}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var Le,_i,xe,wi,Ae=class extends K{constructor(e){super(e);d(this,Le);d(this,xe);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(e){super.insertbutton(e),e.detail.element.getAttribute("data-command")&&e.detail.element.addEventListener("mousedown",this)}mousedown(e){e.preventDefault(),e.stopPropagation()}focusin(e){e.target instanceof HTMLElement&&e.target.hasAttribute("data-focusable")&&p(this,Le,_i).call(this,e.target)}focusout(){p(this,xe,wi).call(this)}selectionchange(){let e=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!e?p(this,xe,wi).call(this):e instanceof HTMLElement&&e.hasAttribute("data-focusable")&&p(this,Le,_i).call(this,e)}};Le=new WeakSet,_i=function(e){!this.editor.focusbar.children.length||(Object.keys(e.dataset).forEach(i=>this.editor.focusbar.dataset[i]=e.dataset[i]),this.editor.focusbar.dataset.tag=e.localName,this._show(this.editor.focusbar,e))},xe=new WeakSet,wi=function(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(e=>delete this.editor.focusbar.dataset[e])};var Ie=class extends K{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 hi,$i,Ne=class extends g{constructor(e){super(e);d(this,hi);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-navigable")&&(e.detail.element.tabIndex=0,e.detail.element.addEventListener("keydown",this))}keydown(e){if(e.target===e.currentTarget&&I(e,[a.UP,a.DOWN,a.HOME,a.END])&&p(this,hi,$i).call(this,e.target)){let i=e.target.previousElementSibling,n=e.target.nextElementSibling,f=e.target.parentElement.firstElementChild,c=e.target.parentElement.lastElementChild,E=e.target===f,T=e.target===c;e.key===a.UP&&!E&&i.hasAttribute("data-navigable")?i.focus():e.key===a.DOWN&&!T&&n.hasAttribute("data-navigable")?n.focus():(e.key===a.HOME||e.key===a.DOWN&&T)&&f.hasAttribute("data-navigable")?f.focus():(e.key===a.END||e.key===a.UP&&E)&&c.hasAttribute("data-navigable")&&c.focus(),e.preventDefault(),e.stopPropagation()}}};hi=new WeakSet,$i=function(e){if(e.contentEditable!=="true")return!0;let i=this.editor.dom.getSelection(),n=this.editor.dom.getSelectedEditable(),f=this.editor.dom.getSelectedElement();return i.isCollapsed&&i.anchorOffset===0&&[n,e.firstChild].includes(f)};var _e=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){t.detail.element instanceof HTMLSlotElement?t.detail.element.addEventListener("keydown",this):t.detail.element.hasAttribute("data-slotable")&&!t.detail.element.querySelector(":scope > "+r.SLOT)&&t.detail.element.appendChild(this.editor.dom.createElement(r.SLOT))}keydown(t){!I(t,a.TAB)&&!I(t,a.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var Re,Ri,Me,Mi,we=class extends g{constructor(e){super(e);d(this,Re);d(this,Me);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-sortable")&&(e.detail.element.addEventListener("keydown",this),e.detail.element.addEventListener("pointerdown",this),e.detail.element.addEventListener("pointermove",this),e.detail.element.addEventListener("pointerup",this))}keydown(e){let i={[a.HOME]:R.FIRST,[a.UP]:R.PREV,[a.DOWN]:R.NEXT,[a.END]:R.LAST};e.target===e.currentTarget&&I(e,Object.keys(i),{ctrl:!0})&&(this.editor.dom.sort(e.target,i[e.key]),e.preventDefault(),e.stopPropagation())}pointerdown(e){let i=e.target.closest("[data-sortable]");i&&this.editor.dom.contains(i)&&(i.setAttribute("data-sort",""),i.setPointerCapture(e.pointerId))}pointermove(e){let i=e.target.closest("[data-sortable][data-sort]"),n=this.editor.dom.document.elementFromPoint(e.x,e.y);p(this,Re,Ri).call(this),i&&this.editor.dom.contains(i)&&p(this,Me,Mi).call(this,i,n)&&n.setAttribute("data-sortover","")}pointerup(e){let i=e.target.closest("[data-sortable][data-sort]");if(i&&this.editor.dom.contains(i)){let n=this.editor.dom.document.elementFromPoint(e.x,e.y);p(this,Re,Ri).call(this),i.removeAttribute("data-sort"),i.releasePointerCapture(e.pointerId),p(this,Me,Mi).call(this,i,n)&&n.insertAdjacentElement(x.BEFOREBEGIN,i)}}};Re=new WeakSet,Ri=function(){this.editor.root.querySelectorAll("[data-sortover]").forEach(e=>e.removeAttribute("data-sortover"))},Me=new WeakSet,Mi=function(e,i){return e instanceof HTMLElement&&i instanceof HTMLElement&&this.editor.dom.contains(i)&&![this.editor.root,e].includes(i)&&i.hasAttribute("data-sortable")&&(e.parentElement===i.parentElement||this.editor.dom.arbitrary(e.parentElement)&&this.editor.dom.arbitrary(i.parentElement))&&this.editor.tags.allowed(i.parentElement,e)};var Oe=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert(t){let e=this.editor.tags.get(t.detail.element);e&&(e.editable&&(t.detail.element.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.detail.element.dataset[i]="")}))}};var ye=class extends K{constructor(t){super(t),this.editor.toolbar.addEventListener("insertbutton",this)}insertbutton(t){super.insertbutton(t),t.detail.element.tabIndex=t.detail.element===this.editor.toolbar.firstElementChild?0:-1,t.detail.element.addEventListener("keydown",this)}};var Qi={de:{Alt:"Alt",Shift:"Umschalt"}};var h=class extends l{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._i18n(Qi),this.editor.dom.registerElement(r.DIALOG,Ee),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 Oe(this.editor),new ye(this.editor),new Ie(this.editor),new Ae(this.editor),new be(this.editor),new ge(this.editor),new Ne(this.editor),new we(this.editor),new fe(this.editor),new Te(this.editor),new _e(this.editor),this.editor.filters.add(new pe(this.editor))}};var Yi={de:{Abbreviation:"Abk\xFCrzung",Cancel:"Abbrechen","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var nt=class extends l{static get name(){return"abbreviation"}static get dependencies(){return[h]}init(){this._i18n(Yi),this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new he(this.editor)),this._command(r.ABBR),this._formatbar(this._("Abbreviation"),a.A)}};var wt,De=class extends B{constructor(e,i){let n=Object.entries(C).find(([,f])=>f===i)?.[0].toLowerCase();if(!n)throw new Error(u.INVALID_ARGUMENT);super(e,dt.name+"-"+n);d(this,wt,void 0);b(this,wt,i)}execute(){let e=this.editor.dom.getActiveElement();e?.hasAttribute("data-alignable")&&(e.classList.remove(...Object.values(C)),m(this,wt)!==C.NONE&&e.classList.add(m(this,wt)))}};wt=new WeakMap;var Zi={de:{"Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig","No alignment":"Keine Ausrichtung"}};var dt=class extends l{static get name(){return"align"}static get dependencies(){return[h]}init(){this._i18n(Zi);let t={[C.NONE]:this._("No alignment"),[C.LEFT]:this._("Align left"),[C.CENTER]:this._("Align center"),[C.RIGHT]:this._("Align right")};Object.entries(t).forEach(([e,i])=>{let n=new De(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var Se=class extends L{constructor(t,e=void 0){super(t,V.name,e)}_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 Be,Oi,Ce=class extends g{constructor(e){super(e);d(this,Be);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.AUDIO)).forEach(i=>p(this,Be,Oi).call(this,i))}insertaudio(e){p(this,Be,Oi).call(this,e.detail.element)}};Be=new WeakSet,Oi=function(e){let i=e.getAttribute("src");i?(e.setAttribute("src",this.editor.url(i)),e.controls=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:V.name}})):e.parentElement.removeChild(e)};var Fe=class extends M{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var Ge=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insertfigure",this)}insertfigure(t){t.detail.element.querySelector(":scope > "+r.FIGCAPTION)||t.detail.element.appendChild(this.editor.dom.createElement(r.FIGCAPTION))}};var D=class extends l{static get name(){return"figure"}static get dependencies(){return[h]}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 Ge(this.editor),this.editor.filters.add(new Fe(this.editor))}};var Xi={de:{Audio:"Audio",Cancel:"Abbrechen",ID:"ID","Insert URL to audio":"URL zur Audiodatei eingeben",Save:"Speichern",URL:"URL"}};var V=class extends l{static get name(){return"audio"}static get dependencies(){return[h,D]}static get config(){return{browser:void 0}}init(){this._i18n(Xi),this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new Ce(this.editor),this.editor.dialogs.set(new Se(this.editor,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar(this._("Audio"))}};var Ue=class extends L{constructor(t,e=void 0){super(t,lt.name,e)}_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var Pe=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super(),this.attachShadow({mode:"open"})}};var He=class extends g{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml(t){Array.from(t.detail.element.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock(t){if(!t.detail.element.id){t.detail.element.parentElement.removeChild(t.detail.element);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.detail.element.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 f=await i.text();t.detail.element.content=n+f}};var ci={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben",Save:"Speichern",URL:"URL",Width:"Breite"}};var lt=class extends l{static get name(){return"block"}static get dependencies(){return[h]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this._i18n(ci),this.editor.dom.registerElement(r.BLOCK,Pe),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new He(this.editor),this.editor.dialogs.set(new Ue(this.editor,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar(this._("Block"))}};var ke=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(H.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.BLOCKQUOTE)),t.parentElement.removeChild(t))}};var ve=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote(t){this.editor.dom.wrap(t.detail.element,r.FIGURE,{attributes:{class:H.name}})}deleteblockquote(t){t.detail.target.localName===r.FIGURE&&t.detail.target.classList.contains(H.name)&&t.detail.target.parentElement.removeChild(t.detail.target)}};var Ke=class extends M{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 G=class extends l{static get name(){return"break"}static get dependencies(){return[h]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new Ke(this.editor))}};var Ji={de:{Blockquote:"Blockzitat"}};var H=class extends l{static get name(){return"blockquote"}static get dependencies(){return[h,G,D]}init(){this._i18n(Ji),this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new ve(this.editor),this._command(r.BLOCKQUOTE),this._toolbar(this._("Blockquote")),this.editor.filters.add(new ke(this.editor))}};var to={de:{bold:"fett"}};var Ve=class extends l{static get name(){return"bold"}static get dependencies(){return[h]}init(){this._i18n(to),this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar(this._("bold"),a.B)}};var eo={de:{Citation:"Zitatquelle"}};var je=class extends l{static get name(){return"cite"}static get dependencies(){return[h]}init(){this._i18n(eo),this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar(this._("Citation"),a.Z)}};var ro={de:{Code:"Quelltext"}};var ze=class extends l{static get name(){return"code"}static get dependencies(){return[h]}init(){this._i18n(ro),this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar(this._("Code"),a.C)}};var qe=class extends L{constructor(t){super(t,mt.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var io={de:{Cancel:"Abbrechen",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var mt=class extends l{static get name(){return"data"}static get dependencies(){return[h]}init(){this._i18n(io),this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new qe(this.editor)),this._command(r.DATA),this._formatbar(this._("Data"),a.J)}};var We=class extends L{constructor(t){super(t,ht.name)}_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var oo={de:{Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff"}};var ht=class extends l{static get name(){return"definition"}static get dependencies(){return[h]}init(){this._i18n(oo),this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new We(this.editor)),this._command(r.DFN),this._formatbar(this._("Definition"),a.D)}};var $e=class extends B{constructor(t){super(t,ct.name)}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var so={de:{Delete:"L\xF6schen"}};var ct=class extends l{static get name(){return"delete"}static get dependencies(){return[h]}init(){this._i18n(so),this.editor.commands.set(new $e(this.editor)),this._focusbar(this._("Delete"),this.constructor.name)}};var ao={de:{"Text Deletion":"Textl\xF6schung"}};var Qe=class extends l{static get name(){return"deletion"}static get dependencies(){return[h]}init(){this._i18n(ao),this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar(this._("Text Deletion"),a.G)}};var Ye=class extends M{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 Xe,yi,Ze=class extends g{constructor(e){super(e);d(this,Xe);this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails(e){e.detail.element.open=!0,e.detail.element.querySelector(`:scope > ${r.SUMMARY}:first-child`)||e.detail.element.insertAdjacentElement(x.AFTERBEGIN,this.editor.dom.createElement(r.SUMMARY))}insertsummary(e){p(this,Xe,yi).call(this,e.detail.element),e.detail.element.addEventListener("click",this),e.detail.element.addEventListener("blur",this),e.detail.element.addEventListener("keydown",this)}click(e){e.preventDefault(),e.stopPropagation(),e.target.parentElement.open=!0}blur(e){p(this,Xe,yi).call(this,e.target)}keydown(e){I(e,a.SPACE)?(e.preventDefault(),e.stopPropagation(),this.editor.dom.insertText(" ")):I(e,a.ENTER)&&(e.preventDefault(),e.stopPropagation(),e.target.parentElement.open=!0)}};Xe=new WeakSet,yi=function(e){e.textContent.trim()?e.querySelectorAll(r.BR+":not(:last-child)").forEach(i=>i.parentElement.removeChild(i)):e.textContent=this.editor.translator.translate(ft.name,"Details"),e.lastElementChild instanceof HTMLBRElement||e.appendChild(this.editor.dom.createElement(r.BR))};var no={de:{Details:"Details"}};var ft=class extends l{static get name(){return"details"}static get dependencies(){return[h]}init(){this._i18n(no),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 Ze(this.editor),this._command(r.DETAILS),this._toolbar(this._("Details")),this.editor.filters.add(new Ye(this.editor))}};var Je=class extends L{constructor(t){super(t,pt.name)}_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var lo={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse",Division:"Division","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern"}};var pt=class extends l{static get name(){return"division"}static get dependencies(){return[h]}init(){this._i18n(lo),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 Je(this.editor)),this._command(r.DIV),this._toolbar(this._("Division"))}};var mo={de:{emphasized:"betont"}};var tr=class extends l{static get name(){return"emphasis"}static get dependencies(){return[h]}init(){this._i18n(mo),this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar(this._("emphasized"),a.E)}};var ho={de:{Heading:"\xDCberschrift"}};var er=class extends l{static get name(){return"heading"}static get dependencies(){return[h]}init(){this._i18n(ho),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(this._("Heading"))}};var co={de:{"Horizontal Rule":"Horizontale Linie"}};var rr=class extends l{static get name(){return"horizontalrule"}static get dependencies(){return[h]}init(){this._i18n(co),this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar(this._("Horizontal Rule"))}};var ir=class extends L{constructor(t,e=void 0){super(t,j.name,e)}_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 sr,Di,or=class extends g{constructor(e){super(e);d(this,sr);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.IFRAME)).forEach(i=>p(this,sr,Di).call(this,i))}insertiframe(e){p(this,sr,Di).call(this,e.detail.element)}};sr=new WeakSet,Di=function(e){let i=e.getAttribute("src");i?(e.setAttribute("src",this.editor.url(i)),e.allowFullscreen=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:j.name}})):e.parentElement.removeChild(e)};var j=class extends l{static get name(){return"iframe"}static get dependencies(){return[h,D]}static get config(){return{browser:void 0}}init(){this._i18n(ci),this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new or(this.editor),this.editor.dialogs.set(new ir(this.editor,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar(this._("Iframe"))}};var ar=class extends L{constructor(t,e=void 0){super(t,z.name,e)}_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 dr,Si,nr=class extends g{constructor(e){super(e);d(this,dr);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.IMG)).forEach(i=>p(this,dr,Si).call(this,i))}insertimg(e){p(this,dr,Si).call(this,e.detail.element)}};dr=new WeakSet,Si=function(e){let i=e.getAttribute("src");i?(e.setAttribute("src",this.editor.url(i)),this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:z.name}})):e.parentElement.removeChild(e)};var fo={de:{"Alternative text":"Alternativtext",Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben",Save:"Speichern","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist",URL:"URL",Width:"Breite"}};var z=class extends l{static get name(){return"image"}static get dependencies(){return[h,D]}static get config(){return{browser:void 0}}init(){this._i18n(fo),this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new nr(this.editor),this.editor.dialogs.set(new ar(this.editor,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar(this._("Image"))}};var po={de:{"Text Insertion":"Texteinf\xFCgung"}};var lr=class extends l{static get name(){return"insertion"}static get dependencies(){return[h]}init(){this._i18n(po),this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar(this._("Text Insertion"),a.F)}};var uo={de:{italic:"kursiv"}};var mr=class extends l{static get name(){return"italic"}static get dependencies(){return[h]}init(){this._i18n(uo),this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar(this._("italic"),a.I)}};var go={de:{"User Input":"Benutzereingabe"}};var hr=class extends l{static get name(){return"keyboard"}static get dependencies(){return[h]}init(){this._i18n(go),this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar(this._("User Input"),a.K)}};var cr=class extends L{constructor(t){super(t,ut.name)}_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var pr,Ci,fr=class extends g{constructor(e){super(e);d(this,pr);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.A)).forEach(i=>p(this,pr,Ci).call(this,i))}inserta(e){p(this,pr,Ci).call(this,e.detail.element)}};pr=new WeakSet,Ci=function(e){let i=e.getAttribute("href");i?e.setAttribute("href",this.editor.url(i)):e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e)};var Eo={de:{Cancel:"Abbrechen","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",Save:"Speichern",URL:"URL"}};var ut=class extends l{static get name(){return"link"}static get dependencies(){return[h]}init(){this._i18n(Eo),this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new fr(this.editor),this.editor.dialogs.set(new cr(this.editor)),this._command(r.A),this._formatbar(this._("Link"),a.L)}};var bo={de:{mark:"markiert"}};var ur=class extends l{static get name(){return"mark"}static get dependencies(){return[h]}init(){this._i18n(bo),this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar(this._("mark"),a.M)}};var Er,Bi,gr=class extends g{constructor(e){super(e);d(this,Er);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(e){Array.from(e.detail.element.getElementsByTagName(r.LI)).forEach(i=>p(this,Er,Bi).call(this,i))}insertli(e){p(this,Er,Bi).call(this,e.detail.element)}deleteli(e){e.detail.target.children.length===0&&e.detail.target.parentElement.removeChild(e.detail.target)}insertol(e){e.detail.element.children.length===0&&e.detail.element.appendChild(this.editor.dom.createElement(r.LI))}insertul(e){this.insertol(e)}};Er=new WeakSet,Bi=function(e){!(e.parentElement instanceof HTMLOListElement)&&!(e.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(e,r.UL)};var gt=class extends l{static get name(){return"list"}static get dependencies(){return[h,G]}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 gr(this.editor)}};var To={de:{"Ordered List":"Geordnete Liste"}};var br=class extends l{static get name(){return"orderedlist"}static get dependencies(){return[h,gt]}init(){this._i18n(To),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(this._("Ordered List"))}};var Ar,Fi,Tr=class extends g{constructor(e){super(e);d(this,Ar);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.P)).forEach(i=>p(this,Ar,Fi).call(this,i))}insertp(e){p(this,Ar,Fi).call(this,e.detail.element)}paste(e){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(e.target))}};Ar=new WeakSet,Fi=function(e){e.addEventListener("paste",this)};var Ao={de:{Paragraph:"Absatz"}};var Lr=class extends l{static get name(){return"paragraph"}static get dependencies(){return[h,G]}init(){this._i18n(Ao),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 Tr(this.editor),this._command(r.P),this._toolbar(this._("Paragraph"))}};var xr=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(k.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.PRE)),t.parentElement.removeChild(t))}};var Ir=class extends g{constructor(t){super(t),this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre(t){this.editor.dom.wrap(t.detail.element,r.FIGURE,{attributes:{class:k.name}})}deletepre(t){t.detail.target.localName===r.FIGURE&&t.detail.target.classList.contains(k.name)&&t.detail.target.parentElement.removeChild(t.detail.target)}};var Lo={de:{"Preformatted Text":"Vorformatierter Text"}};var k=class extends l{static get name(){return"preformat"}static get dependencies(){return[h,G,D]}init(){this._i18n(Lo),this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new Ir(this.editor),this._command(r.PRE),this._toolbar(this._("Preformatted Text")),this.editor.filters.add(new xr(this.editor))}};var xo={de:{Quote:"Zitat"}};var Nr=class extends l{static get name(){return"quote"}static get dependencies(){return[h]}init(){this._i18n(xo),this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar(this._("Quote"),a.Q)}};var Io={de:{"Sample Output":"Beispielausgabe"}};var _r=class extends l{static get name(){return"sample"}static get dependencies(){return[h]}init(){this._i18n(Io),this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar(this._("Sample Output"),a.O)}};var wr=class extends L{constructor(t){super(t,Et.name)}_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var No={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern",Section:"Sektion"}};var Et=class extends l{static get name(){return"section"}static get dependencies(){return[h]}init(){this._i18n(No),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 wr(this.editor)),this._command(r.SECTION),this._toolbar(this._("Section"))}};var _o={de:{small:"klein"}};var Rr=class extends l{static get name(){return"small"}static get dependencies(){return[h]}init(){this._i18n(_o),this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar(this._("small"),a.W)}};var Or,Mr=class extends B{constructor(e,i){let n=Object.entries(R).find(([,f])=>f===i)?.[0].toLowerCase();if(!n)throw new Error(u.INVALID_ARGUMENT);super(e,bt.name+"-"+n);d(this,Or,void 0);b(this,Or,i)}execute(){let e=this.editor.dom.getActiveElement();e?.hasAttribute("data-sortable")&&this.editor.dom.sort(e,m(this,Or))}};Or=new WeakMap;var wo={de:{"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"}};var bt=class extends l{static get name(){return"sort"}static get dependencies(){return[h]}init(){this._i18n(wo);let t={[R.FIRST]:this._("Sort to the beginning"),[R.PREV]:this._("Sort before previous element"),[R.NEXT]:this._("Sort after next element"),[R.LAST]:this._("Sort to the end")};Object.entries(t).forEach(([e,i])=>{let n=new Mr(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var Ro={de:{strikethrough:"durchgestrichen"}};var yr=class extends l{static get name(){return"strikethrough"}static get dependencies(){return[h]}init(){this._i18n(Ro),this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar(this._("strikethrough"),a.R)}};var Mo={de:{"strongly emphasized":"stark betont"}};var Dr=class extends l{static get name(){return"strong"}static get dependencies(){return[h]}init(){this._i18n(Mo),this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar(this._("strongly emphasized"),a.S)}};var Oo={de:{Subheading:"Unter\xFCberschrift"}};var Sr=class extends l{static get name(){return"subheading"}static get dependencies(){return[h]}init(){this._i18n(Oo),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(this._("Subheading"))}};var yo={de:{subscript:"tiefgestellt"}};var Cr=class extends l{static get name(){return"subscript"}static get dependencies(){return[h]}init(){this._i18n(yo),this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar(this._("subscript"),a.X)}};var Do={de:{superscript:"hochgestellt"}};var Br=class extends l{static get name(){return"superscript"}static get dependencies(){return[h]}init(){this._i18n(Do),this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar(this._("superscript"),a.Y)}};var Fr=class extends B{constructor(t){super(t,F.name,r.TABLE)}insert({rows:t,cols:e}={}){let i=this.editor.dom.createElement(r.FIGURE,{attributes:{class:F.name}}),n=this.editor.dom.createElement(r.TABLE),f=this.editor.dom.createElement(r.TBODY),c=parseInt(t,10)||1,E=parseInt(e,10)||1;for(let T=0;T<c;T++){let A=this.editor.dom.createElement(r.TR);f.appendChild(A);for(let O=0;O<E;++O)A.appendChild(this.editor.dom.createElement(r.TD))}n.appendChild(f),i.appendChild(n),this.editor.dom.insert(i)}};var Gr=class extends L{constructor(t){super(t,F.name)}_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 Ur=class extends M{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(F.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(t.insertAdjacentElement(x.BEFOREBEGIN,t.querySelector(":scope > "+r.TABLE)),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 Tt,Pr,Rt,fi,pi,So,Hr=class extends g{constructor(e){super(e);d(this,Tt);d(this,Rt);d(this,pi);this.editor.root.addEventListener("inserttable",this),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttable(e){this.editor.dom.wrap(e.detail.element,r.FIGURE,{attributes:{class:F.name}}),e.detail.element.tBodies.length>0&&e.detail.element.tBodies[0].rows[0]&&(!e.detail.element.tHead||!e.detail.element.tFoot)&&(e.detail.element.tHead||p(this,Tt,Pr).call(this,e.detail.element.createTHead(),e.detail.element.tBodies[0].rows[0].cells.length),e.detail.element.tFoot||p(this,Tt,Pr).call(this,e.detail.element.createTFoot(),e.detail.element.tBodies[0].rows[0].cells.length))}inserttd(e){e.detail.element.addEventListener("keydown",this)}insertth(e){e.detail.element.addEventListener("keydown",this)}keydown(e){let i=e.target,n=i.parentElement,f=n.parentElement,c=f instanceof HTMLTableElement?f:f.parentElement,E=[a.LEFT,a.RIGHT,a.UP,a.DOWN],T=I(e,E),A=I(e,E,{ctrl:!0}),O=I(e,E,{alt:!0}),W=I(e,E,{alt:!0,shift:!0});if(i instanceof HTMLTableCellElement&&n instanceof HTMLTableRowElement&&(f instanceof HTMLTableElement||f instanceof HTMLTableSectionElement)&&c instanceof HTMLTableElement&&(T&&p(this,pi,So).call(this,i,e.key)||A||O||W)){let w=i.cellIndex,v=n.cells.length,Lt=f.rows.length,P=f instanceof HTMLTableElement?n.rowIndex:n.sectionRowIndex,gi=w===0,Ei=w===v-1,Ho=P===0,ko=P===Lt-1,Hi=n.rowIndex===0,ki=n.rowIndex===c.rows.length-1;e.preventDefault(),e.stopPropagation(),T?e.key===a.LEFT&&!gi?this.editor.dom.focusEnd(n.cells[w-1]):e.key===a.LEFT&&Hi?this.editor.dom.focusEnd(c.rows[c.rows.length-1].cells[v-1]):e.key===a.LEFT?this.editor.dom.focusEnd(c.rows[n.rowIndex-1].cells[v-1]):e.key===a.RIGHT&&!Ei?n.cells[w+1].focus():e.key===a.RIGHT&&ki?c.rows[0].cells[0].focus():e.key===a.RIGHT?c.rows[n.rowIndex+1].cells[0].focus():e.key===a.UP&&Hi?c.rows[c.rows.length-1].cells[w].focus():e.key===a.UP?c.rows[n.rowIndex-1].cells[w].focus():e.key===a.DOWN&&ki?c.rows[0].cells[w].focus():e.key===a.DOWN&&c.rows[n.rowIndex+1].cells[w].focus():A?(e.key===a.LEFT&&v>1&&gi?Array.from(c.rows).forEach(_=>_.appendChild(_.cells[w])):e.key===a.LEFT&&v>1?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w],_.cells[w-1])):e.key===a.RIGHT&&v>1&&Ei?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w],_.cells[0])):e.key===a.RIGHT&&v>1?Array.from(c.rows).forEach(_=>_.insertBefore(_.cells[w+1],_.cells[w])):e.key===a.UP&&Lt>1&&Ho?f.appendChild(n):e.key===a.UP&&Lt>1?f.insertBefore(n,f.rows[P-1]):e.key===a.DOWN&&Lt>1&&ko?f.insertBefore(n,f.rows[0]):e.key===a.DOWN&&Lt>1&&f.insertBefore(f.rows[P+1],n),i.focus()):O?e.key===a.LEFT?Array.from(c.rows).forEach(_=>p(this,Rt,fi).call(this,_,_.cells[w])):e.key===a.RIGHT?Array.from(c.rows).forEach(_=>p(this,Rt,fi).call(this,_,_.cells[w+1])):e.key===a.UP?p(this,Tt,Pr).call(this,f,v,P):e.key===a.DOWN&&p(this,Tt,Pr).call(this,f,v,P+1):W&&(e.key===a.LEFT&&!gi?Array.from(c.rows).forEach(_=>_.deleteCell(w-1)):e.key===a.RIGHT&&!Ei?Array.from(c.rows).forEach(_=>_.deleteCell(w+1)):e.key===a.UP&&P>0?f.deleteRow(P-1):e.key===a.DOWN&&P<Lt-1&&f.deleteRow(P+1))}}};Tt=new WeakSet,Pr=function(e,i,n=0){let f=e.insertRow(n);for(let c=0;c<i;c++)p(this,Rt,fi).call(this,f)},Rt=new WeakSet,fi=function(e,i=null){let n=e.parentElement.localName===r.THEAD?r.TH:r.TD;e.insertBefore(this.editor.dom.createElement(n),i)},pi=new WeakSet,So=function(e,i){if([a.UP,a.DOWN].includes(i))return!0;let n=this.editor.dom.getSelection(),f=n.anchorNode instanceof HTMLElement?n.anchorNode:e;if(!n.isCollapsed)return!1;if(i===a.LEFT){let E=e.firstChild;return E instanceof HTMLElement&&(E=E.firstChild),n.anchorOffset===0&&[e,E].includes(f)}let c=e.lastChild;return e.lastChild instanceof HTMLBRElement&&e.lastChild.previousSibling&&(c=e.lastChild.previousSibling),c instanceof HTMLElement&&(c=c.lastChild),n.anchorOffset===f.textContent.length&&[e,c].includes(f)};var Co={de:{Cancel:"Abbrechen",Columns:"Spalten","Delete next column":"N\xE4chste Spalte l\xF6schen","Delete next row":"N\xE4chste Zeile l\xF6schen","Delete previous column":"Vorherige Spalte l\xF6schen","Delete previous row":"Vorherige Zeile l\xF6schen",Rows:"Zeilen",Save:"Speichern","Sort after next column":"Hinter die n\xE4chste Spalte sortieren","Sort after next row":"Hinter die n\xE4chste Zeile sortieren","Sort before previous column":"Vor die vorherige Spalte sortieren","Sort before previous row":"Vor die vorherige Zeile sortieren","Sort column to the beginning":"Spalte an den Anfang sortieren","Sort row to the beginning":"Zeile an den Anfang sortieren","Sort column to the end":"Spalte ans Ende sortieren","Sort row to the end":"Zeile ans Ende sortieren",Table:"Tabelle"}};var Mt,ui,kr,Gi,F=class extends l{constructor(){super(...arguments);d(this,Mt);d(this,kr)}static get name(){return"table"}static get dependencies(){return[h,G,D]}init(){this._i18n(Co),this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag(p(this,Mt,ui).call(this,r.THEAD)),this._tag(p(this,Mt,ui).call(this,r.TBODY)),this._tag(p(this,Mt,ui).call(this,r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL]}),this._tag(p(this,kr,Gi).call(this,r.TH)),this._tag(p(this,kr,Gi).call(this,r.TD)),new Hr(this.editor),this.editor.filters.add(new Ur(this.editor)),this.editor.dialogs.set(new Gr(this.editor)),this.editor.commands.set(new Fr(this.editor)),this._toolbar(this._("Table"))}};Mt=new WeakSet,ui=function(e){return{name:e,group:o.TABLESECTION,children:[o.TABLEROW]}},kr=new WeakSet,Gi=function(e){return{name:e,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}};var vr=class extends L{constructor(t){super(t,At.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var Bo={de:{Cancel:"Abbrechen","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Save:"Speichern",Time:"Zeit"}};var At=class extends l{static get name(){return"time"}static get dependencies(){return[h]}init(){this._i18n(Bo),this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new vr(this.editor)),this._command(r.TIME),this._formatbar(this._("Time"),a.T)}};var Fo={de:{underline:"unterstrichen"}};var Kr=class extends l{static get name(){return"underline"}static get dependencies(){return[h]}init(){this._i18n(Fo),this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar(this._("underline"),a.U)}};var Go={de:{"Unordered List":"Ungeordnete Liste"}};var Vr=class extends l{static get name(){return"unorderedlist"}static get dependencies(){return[h,gt]}init(){this._i18n(Go),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(this._("Unordered List"))}};var Uo={de:{Variable:"Variable"}};var jr=class extends l{static get name(){return"variable"}static get dependencies(){return[h]}init(){this._i18n(Uo),this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar(this._("Variable"),a.V)}};var zr=class extends L{constructor(t,e=void 0){super(t,q.name,e)}_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 Wr,Ui,qr=class extends g{constructor(e){super(e);d(this,Wr);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.VIDEO)).forEach(i=>p(this,Wr,Ui).call(this,i))}insertvideo(e){p(this,Wr,Ui).call(this,e.detail.element)}};Wr=new WeakSet,Ui=function(e){let i=e.getAttribute("src");i?(e.setAttribute("src",this.editor.url(i)),e.controls=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:q.name}})):e.parentElement.removeChild(e)};var Po={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID","Insert URL to video":"URL zur Videodatei eingeben",Save:"Speichern",URL:"URL",Video:"Video",Width:"Breite"}};var q=class extends l{static get name(){return"video"}static get dependencies(){return[h,D]}static get config(){return{browser:void 0}}init(){this._i18n(Po),this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new qr(this.editor),this.editor.dialogs.set(new zr(this.editor,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar(this._("Video"))}};var Pi=class extends y{static get defaultConfig(){return{base:{plugins:[Ve,mr,Dr,tr,Kr,yr,ut,ur,Rr,ht,nt,Nr,je,ze,hr,_r,jr,Cr,Br,At,mt,lr,Qe,Lr,er,Sr,Vr,br,rr,H,z,q,V,j,F,k,Et,ft,pt,lt,dt,bt,ct]}}}};export{Pi as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akilli/editor",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "A HTML standards-compliant and dependency-free rich text editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contenteditable",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"start": "npx --yes servor --reload . index.html 20000"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"esbuild": "^0.
|
|
36
|
+
"esbuild": "^0.15.7"
|
|
37
37
|
}
|
|
38
38
|
}
|