@akilli/editor 5.0.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.css +1 -1
- package/dist/editor.js +2 -2
- package/dist/editor.woff2 +0 -0
- package/{LICENSE.md → license.md} +0 -0
- package/package.json +4 -4
- package/{README.md → readme.md} +8 -7
package/dist/editor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--editor-block-background: #012022;--editor-block-color: #fff;--editor-border: #01202233;--editor-button-background: #012022;--editor-button-color: #fff;--editor-cancel-background: #e3e7e7;--editor-cancel-color: #012022;--editor-dialog-background: #fff;--editor-dialog-color: #012022;--editor-error: #cc2e2c;--editor-focus: #fcece1;--editor-placeholder: #01202233;--editor-slot: #09575c;--editor-sortover: #012022;--editor-toolbar-background: #fff;--editor-toolbar-color: #012022;--editor-text-block: "Block: " attr(id);--editor-text-editable: "Gimme some text!";--editor-text-root: "Gimme some widgets!";--editor-text-slot: "Focus this slot and gimme some widgets!";--editor-text-tablecol: "Col ";--editor-text-tablebodyrow: "Row ";--editor-text-tablefootrow: "Foot ";--editor-text-tableheadrow: "Head "}akilli-editor[lang=de]{--editor-text-editable: "Gib mir Text!";--editor-text-root: "Gib mir Widgets!";--editor-text-slot: "Fokussiere diesen Slot und gib mir Widgets!";--editor-text-tablecol: "Spalte ";--editor-text-tablebodyrow: "Zeile ";--editor-text-tablefootrow: "Fu\df ";--editor-text-tableheadrow: "Kopf "}::backdrop{--editor-dialog-backdrop: #000000cc}@font-face{font-family:editor;font-display:block;font-style:normal;font-weight:900;src:url(editor.woff2) format("woff2")}akilli-editor{position:relative;display:block}akilli-editor editor-root{display:block;width:100%;padding:.75rem .6875rem .6875rem;overflow:auto;border:.0625rem solid var(--editor-border);border-top:0}akilli-editor editor-root:empty:after{color:var(--editor-placeholder);content:var(--editor-text-root)}akilli-editor editor-root :focus{outline:.25rem dashed var(--editor-focus)}akilli-editor editor-root [contenteditable]{min-height:1.5rem}akilli-editor editor-root [contenteditable=true]:empty:after{color:var(--editor-placeholder);content:var(--editor-text-editable)}akilli-editor editor-root :is(td,th)[contenteditable]{height:1.5rem}akilli-editor editor-root slot[contenteditable]{display:block;padding:.25rem;clear:both;border:.25rem solid var(--editor-slot)}akilli-editor editor-root slot[contenteditable=true]:empty:after{color:var(--editor-slot);content:var(--editor-text-slot)}akilli-editor editor-root [contenteditable=true] :hover{cursor:context-menu}akilli-editor editor-root [data-sortable][data-sort]:hover{cursor:grab}akilli-editor editor-root :is([data-sortover],[contenteditable][data-sortover]){outline:.25rem dashed var(--editor-sortover)}akilli-editor editor-root :is(details,div,section){overflow:auto}akilli-editor editor-root :is(audio,iframe,img,video){pointer-events:none}akilli-editor editor-root :is(thead,tbody,tfoot){counter-reset:rows}akilli-editor editor-root colgroup{display:table-header-group;counter-reset:cols}akilli-editor editor-root col,akilli-editor editor-root :is(colgroup,tr):before{display:table-cell;height:1.5rem;line-height:1.5rem;vertical-align:middle;text-align:center;color:var(--editor-placeholder)}akilli-editor editor-root col:after{counter-increment:cols;content:var(--editor-text-tablecol) counter(cols)}akilli-editor editor-root colgroup:before{content:" "}akilli-editor editor-root tr:before{counter-increment:rows;content:var(--editor-text-tablebodyrow) counter(rows)}akilli-editor editor-root thead tr:before{content:var(--editor-text-tableheadrow) counter(rows)}akilli-editor editor-root tfoot tr:before{content:var(--editor-text-tablefootrow) counter(rows)}akilli-editor editor-root col:focus,akilli-editor editor-root tr:focus:before{background:var(--editor-focus)}akilli-editor editor-root summary{white-space:pre-wrap}akilli-editor editor-root app-block{display:block;padding:.25rem;border:.0625rem solid var(--editor-block-background)}akilli-editor editor-root app-block:before{display:block;margin:-.25rem -.25rem .5rem;padding:.125rem .25rem;color:var(--editor-block-color);background:var(--editor-block-background);content:var(--editor-text-block)}akilli-editor dialog::backdrop{background:var(--editor-dialog-backdrop)}akilli-editor dialog form{padding:.75rem;color:var(--editor-dialog-color);background:var(--editor-dialog-background)}akilli-editor dialog :is(form,fieldset)>:not(:first-child){margin-top:1.5rem}akilli-editor dialog legend{font-size:1.25rem}akilli-editor dialog label{display:block}akilli-editor dialog [data-required] label:after{content:" *"}akilli-editor dialog button{padding:.75rem;color:var(--editor-button-color);background:var(--editor-button-background)}akilli-editor dialog button+button{margin-left:1.5rem}akilli-editor dialog button[type=reset]{color:var(--editor-cancel-color);background:var(--editor-cancel-background)}akilli-editor dialog input:is([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url]),akilli-editor dialog select{width:100%;padding:.71875rem 0;border-bottom:.0625rem solid var(--editor-border)}akilli-editor dialog input:is([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url]):invalid,akilli-editor dialog select:invalid{border-color:var(--editor-error)}akilli-editor editor-toolbar{position:sticky;top:0;display:flex;flex-wrap:wrap;color:var(--editor-toolbar-color);background:var(--editor-toolbar-background);border:.0625rem solid var(--editor-border)}akilli-editor :is(editor-focusbar,editor-formatbar){position:absolute;left:0;display:flex;flex-wrap:wrap;color:var(--editor-toolbar-color);background:var(--editor-toolbar-background);border:.0625rem solid var(--editor-border)}akilli-editor editor-focusbar:empty,akilli-editor editor-focusbar [data-command]{display:none}akilli-editor editor-focusbar[data-alignable] [data-command^=align-],akilli-editor editor-focusbar[data-deletable] [data-command=delete],akilli-editor editor-focusbar[data-sortable] [data-command^=sort-]{display:inline-block}akilli-editor [data-command]{display:inline-block;line-height:1;padding:.25rem .5rem;font-family:editor;font-size:0}akilli-editor [data-command]:focus{color:var(--editor-focus)}akilli-editor [data-command]:before{font-size:1.5rem}akilli-editor [data-command=abbreviation]:before{content:"\e800"}akilli-editor [data-command=align-center]:before{content:"\e801"}akilli-editor [data-command=align-left]:before{content:"\e802"}akilli-editor [data-command=align-none]:before{content:"\e803"}akilli-editor [data-command=align-right]:before{content:"\e804"}akilli-editor [data-command=audio]:before{content:"\e805"}akilli-editor [data-command=block]:before{content:"\e806"}akilli-editor [data-command=blockquote]:before{content:"\e807"}akilli-editor [data-command=bold]:before{content:"\e808"}akilli-editor [data-command=cite]:before{content:"\e809"}akilli-editor [data-command=code]:before{content:"\e80a"}akilli-editor [data-command=data]:before{content:"\e80b"}akilli-editor [data-command=definition]:before{content:"\e80c"}akilli-editor [data-command=delete]:before{content:"\e80d"}akilli-editor [data-command=deletion]:before{content:"\e80e"}akilli-editor [data-command=details]:before{content:"\e80f"}akilli-editor [data-command=division]:before{content:"\e810"}akilli-editor [data-command=emphasis]:before{content:"\e811"}akilli-editor [data-command=heading]:before{content:"\e812"}akilli-editor [data-command=horizontalrule]:before{content:"\e813"}akilli-editor [data-command=iframe]:before{content:"\e814"}akilli-editor [data-command=image]:before{content:"\e815"}akilli-editor [data-command=insertion]:before{content:"\e816"}akilli-editor [data-command=italic]:before{content:"\e817"}akilli-editor [data-command=keyboard]:before{content:"\e818"}akilli-editor [data-command=link]:before{content:"\e819"}akilli-editor [data-command=mark]:before{content:"\e81a"}akilli-editor [data-command=orderedlist]:before{content:"\e81b"}akilli-editor [data-command=paragraph]:before{content:"\e81c"}akilli-editor [data-command=preformat]:before{content:"\e81d"}akilli-editor [data-command=quote]:before{content:"\e81e"}akilli-editor [data-command=sample]:before{content:"\e81f"}akilli-editor [data-command=section]:before{content:"\e820"}akilli-editor [data-command=small]:before{content:"\e821"}akilli-editor [data-command=sort-first]:before{content:"\e822"}akilli-editor [data-command=sort-last]:before{content:"\e823"}akilli-editor [data-command=sort-next]:before{content:"\e824"}akilli-editor [data-command=sort-prev]:before{content:"\e825"}akilli-editor [data-command=strikethrough]:before{content:"\e826"}akilli-editor [data-command=strong]:before{content:"\e827"}akilli-editor [data-command=subheading]:before{content:"\e828"}akilli-editor [data-command=subscript]:before{content:"\e829"}akilli-editor [data-command=superscript]:before{content:"\e82a"}akilli-editor [data-command=table]:before{content:"\e82b"}akilli-editor [data-command=
|
|
1
|
+
:root{--editor-block-background: #012022;--editor-block-color: #fff;--editor-border: #01202233;--editor-button-background: #012022;--editor-button-color: #fff;--editor-cancel-background: #e3e7e7;--editor-cancel-color: #012022;--editor-dialog-background: #fff;--editor-dialog-color: #012022;--editor-error: #cc2e2c;--editor-focus: #fcece1;--editor-placeholder: #01202233;--editor-slot: #09575c;--editor-sortover: #012022;--editor-toolbar-background: #fff;--editor-toolbar-color: #012022;--editor-text-block: "Block: " attr(id);--editor-text-editable: "Gimme some text!";--editor-text-root: "Gimme some widgets!";--editor-text-slot: "Focus this slot and gimme some widgets!";--editor-text-tablecol: "Col ";--editor-text-tablebodyrow: "Row ";--editor-text-tablefootrow: "Foot ";--editor-text-tableheadrow: "Head "}akilli-editor[lang=de]{--editor-text-editable: "Gib mir Text!";--editor-text-root: "Gib mir Widgets!";--editor-text-slot: "Fokussiere diesen Slot und gib mir Widgets!";--editor-text-tablecol: "Spalte ";--editor-text-tablebodyrow: "Zeile ";--editor-text-tablefootrow: "Fu\df ";--editor-text-tableheadrow: "Kopf "}::backdrop{--editor-dialog-backdrop: #000000cc}@font-face{font-family:editor;font-display:block;font-style:normal;font-weight:900;src:url(editor.woff2) format("woff2")}akilli-editor{position:relative;display:block}akilli-editor editor-root{display:block;width:100%;padding:.75rem .6875rem .6875rem;overflow:auto;border:.0625rem solid var(--editor-border);border-top:0}akilli-editor editor-root:empty:after{color:var(--editor-placeholder);content:var(--editor-text-root)}akilli-editor editor-root :focus{outline:.25rem dashed var(--editor-focus)}akilli-editor editor-root [contenteditable]{min-height:1.5rem}akilli-editor editor-root [contenteditable=true]:empty:after{color:var(--editor-placeholder);content:var(--editor-text-editable)}akilli-editor editor-root :is(td,th)[contenteditable]{height:1.5rem}akilli-editor editor-root slot[contenteditable]{display:block;padding:.25rem;clear:both;border:.25rem solid var(--editor-slot)}akilli-editor editor-root slot[contenteditable=true]:empty:after{color:var(--editor-slot);content:var(--editor-text-slot)}akilli-editor editor-root [contenteditable=true] :hover{cursor:context-menu}akilli-editor editor-root [data-sortable][data-sort]:hover{cursor:grab}akilli-editor editor-root :is([data-sortover],[contenteditable][data-sortover]){outline:.25rem dashed var(--editor-sortover)}akilli-editor editor-root :is(details,div,section){overflow:auto}akilli-editor editor-root :is(audio,iframe,img,video){pointer-events:none}akilli-editor editor-root :is(thead,tbody,tfoot){counter-reset:rows}akilli-editor editor-root colgroup{display:table-header-group;counter-reset:cols}akilli-editor editor-root col,akilli-editor editor-root :is(colgroup,tr):before{display:table-cell;height:1.5rem;line-height:1.5rem;vertical-align:middle;text-align:center;color:var(--editor-placeholder)}akilli-editor editor-root col:after{counter-increment:cols;content:var(--editor-text-tablecol) counter(cols)}akilli-editor editor-root colgroup:before{content:" "}akilli-editor editor-root tr:before{counter-increment:rows;content:var(--editor-text-tablebodyrow) counter(rows)}akilli-editor editor-root thead tr:before{content:var(--editor-text-tableheadrow) counter(rows)}akilli-editor editor-root tfoot tr:before{content:var(--editor-text-tablefootrow) counter(rows)}akilli-editor editor-root col:focus,akilli-editor editor-root tr:focus:before{background:var(--editor-focus)}akilli-editor editor-root summary{white-space:pre-wrap}akilli-editor editor-root app-block{display:block;padding:.25rem;border:.0625rem solid var(--editor-block-background)}akilli-editor editor-root app-block:before{display:block;margin:-.25rem -.25rem .5rem;padding:.125rem .25rem;color:var(--editor-block-color);background:var(--editor-block-background);content:var(--editor-text-block)}akilli-editor dialog::backdrop{background:var(--editor-dialog-backdrop)}akilli-editor dialog form{padding:.75rem;color:var(--editor-dialog-color);background:var(--editor-dialog-background)}akilli-editor dialog :is(form,fieldset)>:not(:first-child){margin-top:1.5rem}akilli-editor dialog legend{font-size:1.25rem}akilli-editor dialog label{display:block}akilli-editor dialog [data-required] label:after{content:" *"}akilli-editor dialog button{padding:.75rem;color:var(--editor-button-color);background:var(--editor-button-background)}akilli-editor dialog button+button{margin-left:1.5rem}akilli-editor dialog button[type=reset]{color:var(--editor-cancel-color);background:var(--editor-cancel-background)}akilli-editor dialog input:is([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url]),akilli-editor dialog select{width:100%;padding:.71875rem 0;border-bottom:.0625rem solid var(--editor-border)}akilli-editor dialog input:is([type=email],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=url]):invalid,akilli-editor dialog select:invalid{border-color:var(--editor-error)}akilli-editor editor-toolbar{position:sticky;top:0;display:flex;flex-wrap:wrap;color:var(--editor-toolbar-color);background:var(--editor-toolbar-background);border:.0625rem solid var(--editor-border)}akilli-editor :is(editor-focusbar,editor-formatbar){position:absolute;left:0;display:flex;flex-wrap:wrap;color:var(--editor-toolbar-color);background:var(--editor-toolbar-background);border:.0625rem solid var(--editor-border)}akilli-editor editor-focusbar:empty,akilli-editor editor-focusbar [data-command]{display:none}akilli-editor editor-focusbar[data-alignable] [data-command^=align-],akilli-editor editor-focusbar[data-deletable] [data-command=delete],akilli-editor editor-focusbar[data-sortable] [data-command^=sort-],akilli-editor editor-focusbar[data-tag=col] [data-command^=tablecolumn-],akilli-editor editor-focusbar[data-tag=tr] [data-command^=tablerow-]{display:inline-block}akilli-editor [data-command]{display:inline-block;line-height:1;padding:.25rem .5rem;font-family:editor;font-size:0}akilli-editor [data-command]:focus{color:var(--editor-focus)}akilli-editor [data-command]:before{font-size:1.5rem}akilli-editor [data-command=abbreviation]:before{content:"\e800"}akilli-editor [data-command=align-center]:before{content:"\e801"}akilli-editor [data-command=align-left]:before{content:"\e802"}akilli-editor [data-command=align-none]:before{content:"\e803"}akilli-editor [data-command=align-right]:before{content:"\e804"}akilli-editor [data-command=audio]:before{content:"\e805"}akilli-editor [data-command=block]:before{content:"\e806"}akilli-editor [data-command=blockquote]:before{content:"\e807"}akilli-editor [data-command=bold]:before{content:"\e808"}akilli-editor [data-command=cite]:before{content:"\e809"}akilli-editor [data-command=code]:before{content:"\e80a"}akilli-editor [data-command=data]:before{content:"\e80b"}akilli-editor [data-command=definition]:before{content:"\e80c"}akilli-editor [data-command=delete]:before{content:"\e80d"}akilli-editor [data-command=deletion]:before{content:"\e80e"}akilli-editor [data-command=details]:before{content:"\e80f"}akilli-editor [data-command=division]:before{content:"\e810"}akilli-editor [data-command=emphasis]:before{content:"\e811"}akilli-editor [data-command=heading]:before{content:"\e812"}akilli-editor [data-command=horizontalrule]:before{content:"\e813"}akilli-editor [data-command=iframe]:before{content:"\e814"}akilli-editor [data-command=image]:before{content:"\e815"}akilli-editor [data-command=insertion]:before{content:"\e816"}akilli-editor [data-command=italic]:before{content:"\e817"}akilli-editor [data-command=keyboard]:before{content:"\e818"}akilli-editor [data-command=link]:before{content:"\e819"}akilli-editor [data-command=mark]:before{content:"\e81a"}akilli-editor [data-command=orderedlist]:before{content:"\e81b"}akilli-editor [data-command=paragraph]:before{content:"\e81c"}akilli-editor [data-command=preformat]:before{content:"\e81d"}akilli-editor [data-command=quote]:before{content:"\e81e"}akilli-editor [data-command=sample]:before{content:"\e81f"}akilli-editor [data-command=section]:before{content:"\e820"}akilli-editor [data-command=small]:before{content:"\e821"}akilli-editor [data-command=sort-first]:before{content:"\e822"}akilli-editor [data-command=sort-last]:before{content:"\e823"}akilli-editor [data-command=sort-next]:before{content:"\e824"}akilli-editor [data-command=sort-prev]:before{content:"\e825"}akilli-editor [data-command=strikethrough]:before{content:"\e826"}akilli-editor [data-command=strong]:before{content:"\e827"}akilli-editor [data-command=subheading]:before{content:"\e828"}akilli-editor [data-command=subscript]:before{content:"\e829"}akilli-editor [data-command=superscript]:before{content:"\e82a"}akilli-editor [data-command=table]:before{content:"\e82b"}akilli-editor [data-command=tablecolumn-add]:before{content:"\e82c"}akilli-editor [data-command=tablerow-add]:before{content:"\e82d"}akilli-editor [data-command=time]:before{content:"\e82e"}akilli-editor [data-command=underline]:before{content:"\e82f"}akilli-editor [data-command=unorderedlist]:before{content:"\e830"}akilli-editor [data-command=variable]:before{content:"\e831"}akilli-editor [data-command=video]:before{content:"\e832"}
|
package/dist/editor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=class{static get AUDIO(){return"audio"}static get BLOCK(){return"block"}static get BREAK(){return"break"}static get CAPTION(){return"caption"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get CONTAINER(){return"container"}static get FIGURE(){return"figure"}static get FORMAT(){return"format"}static get HEADING(){return"heading"}static get IFRAME(){return"iframe"}static get IMAGE(){return"image"}static get LIST(){return"list"}static get LISTITEM(){return"listitem"}static get PARAGRAPH(){return"paragraph"}static get PREFORMAT(){return"preformat"}static get QUOTE(){return"quote"}static get ROOT(){return"root"}static get RULE(){return"rule"}static get SLOT(){return"slot"}static get SUMMARY(){return"summary"}static get TABLE(){return"table"}static get TABLECELL(){return"tablecell"}static get TABLEROW(){return"tablerow"}static get TABLESECTION(){return"tablesection"}static get VIDEO(){return"video"}};function v(s){return typeof s<"u"}function V(s){return typeof s=="function"}function b(s){return s&&typeof s=="string"}function M(s){return!v(s)||b(s)}function Se(s){return!v(s)||Array.isArray(s)&&s.length>0}function Me(s){return!v(s)||s instanceof HTMLElement}var R=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get tag(){return this.#r}#o;get dialog(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof T)||!b(e)||!M(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i&&this.editor.tags.get(i),this.#o=this.editor.dialogs.get(e)}execute(){this.dialog?this._openDialog():this._insert(this.#s())}_insert(t={}){if(!this.tag)return;this.#i(t);let e=this.editor.dom.getSelectedElementByName(this.tag.name);this.tag.group!==o.FORMAT?this.editor.dom.insert(this.editor.dom.createElement(this.tag.name,{attributes:t})):e&&Object.keys(t).length>0?e.parentElement.replaceChild(this.editor.dom.createElement(this.tag.name,{attributes:t,html:e.textContent}),e):e?e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e):this.editor.dom.format(this.editor.dom.createElement(this.tag.name,{attributes:t}))}_openDialog(){this.dialog?.open(t=>this._insert(t),this.#s())}#s(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return this.#i(t),t}#i(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])}};var j=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof R))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}findByTagName(t){return Array.from(this.#t.values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var $=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof p))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var r=class{static get A(){return"a"}static get ABBR(){return"abbr"}static get ALL(){return"*"}static get AUDIO(){return"audio"}static get B(){return"b"}static get BLOCK(){return"app-block"}static get BLOCKQUOTE(){return"blockquote"}static get BR(){return"br"}static get BUTTON(){return"button"}static get CITE(){return"cite"}static get CODE(){return"code"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get DATA(){return"data"}static get DEL(){return"del"}static get DETAILS(){return"details"}static get DFN(){return"dfn"}static get DIALOG(){return"dialog"}static get DIV(){return"div"}static get EDITOR(){return"akilli-editor"}static get EM(){return"em"}static get FIELDSET(){return"fieldset"}static get FIGCAPTION(){return"figcaption"}static get FIGURE(){return"figure"}static get FOCUSBAR(){return"editor-focusbar"}static get FORM(){return"form"}static get FORMATBAR(){return"editor-formatbar"}static get H2(){return"h2"}static get H3(){return"h3"}static get HR(){return"hr"}static get I(){return"i"}static get IFRAME(){return"iframe"}static get IMG(){return"img"}static get INPUT(){return"input"}static get INS(){return"ins"}static get KBD(){return"kbd"}static get LABEL(){return"label"}static get LEGEND(){return"legend"}static get LI(){return"li"}static get MARK(){return"mark"}static get OL(){return"ol"}static get P(){return"p"}static get PRE(){return"pre"}static get Q(){return"q"}static get ROOT(){return"editor-root"}static get S(){return"s"}static get SAMP(){return"samp"}static get SECTION(){return"section"}static get SLOT(){return"slot"}static get SMALL(){return"small"}static get STRONG(){return"strong"}static get SUB(){return"sub"}static get SUMMARY(){return"summary"}static get SUP(){return"sup"}static get TABLE(){return"table"}static get TBODY(){return"tbody"}static get TD(){return"td"}static get TFOOT(){return"tfoot"}static get TH(){return"th"}static get THEAD(){return"thead"}static get TIME(){return"time"}static get TOOLBAR(){return"editor-toolbar"}static get TR(){return"tr"}static get U(){return"u"}static get UL(){return"ul"}static get VAR(){return"var"}static get VIDEO(){return"video"}};var B=class{#t;constructor(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t=t,this.register(this.#r.bind(this))}dispatch(t,e=void 0,i=void 0){if(!b(t)||!Me(e)||!Me(i))throw new TypeError("Invalid argument");this.#t.dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!V(t))throw new TypeError("Invalid argument");new MutationObserver(t).observe(this.#t,e)}#e(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))}#r(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(this.#e("insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>this.#e("insert",n,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&this.#e("delete",i,e.target))})}};var E=class{static get FIRST(){return"first"}static get PREV(){return"prev"}static get NEXT(){return"next"}static get LAST(){return"last"}static values(){return[this.FIRST,this.PREV,this.NEXT,this.LAST]}};var Q=class{#t;get editor(){return this.#t}#e;get document(){return this.#e}#r;get window(){return this.#r}#o;get root(){return this.#o}#s={alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""};constructor(t,e){if(!(t instanceof T)||!(e instanceof Document))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=this.document.defaultView,this.#o=this.document.documentElement}registerElement(t,e,i=void 0){v(this.window.customElements.get(t))||this.window.customElements.define(t,e,i?{extends:i}:void 0)}createElement(t,{attributes:e={},html:i=""}={}){let n=this.document.createElement(t);return n.innerHTML=i,Object.entries(e).forEach(([l,c])=>c&&n.setAttribute(l,`${c}`)),n}insert(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))this.insertBefore(t,e);else if(e){let i=this.closest(e,t);i&&this.insertAfter(t,i),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e)}else if(this.editor.tags.allowed(this.editor.root,t))this.insertLastChild(t,this.editor.root);else throw new TypeError("Invalid argument")}insertText(t){let e=this.getSelectedEditable();if(e){let i=this.getRange();i.deleteContents(),i.insertNode(this.createText(t)),i.collapse(),e.normalize()}}format(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getRange(),i=this.getSelectedEditable();if(!e||e.collapsed||!e.toString().trim()||!i||!this.editor.tags.allowed(i,t))return;e.startContainer instanceof Text&&e.startContainer.parentElement!==i&&e.setStartBefore(e.startContainer.parentElement),e.endContainer instanceof Text&&e.endContainer.parentElement!==i&&e.setEndAfter(e.endContainer.parentElement);let n=e.toString(),l=Array.from(e.cloneContents().childNodes).every(c=>c instanceof Text&&!c.textContent.trim()||c instanceof HTMLElement&&c.localName===t.localName);e.deleteContents(),l?e.insertNode(this.createText(n)):(t.textContent=n,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}createTable(t=1,e=1){let i=this.createElement(r.TABLE);return this.insertLastChild(this.createTableHeader(1,e),i),this.insertLastChild(this.createTableBody(t,e),i),this.insertLastChild(this.createTableFooter(1,e),i),i}createTableColumnGroup(t=1){let e=this.createElement(r.COLGROUP);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.COL),e);return e}createTableHeader(t=1,e=1){return this.#i(r.THEAD,t,e)}createTableBody(t=1,e=1){return this.#i(r.TBODY,t,e)}createTableFooter(t=1,e=1){return this.#i(r.TFOOT,t,e)}createTableHeaderRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TH),e);return e}createTableRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TD),e);return e}sort(t,e){if(!(t instanceof HTMLElement)||!E.values().includes(e))throw new TypeError("Invalid argument");if(t.parentElement.children.length<=1)return;let i=t.parentElement,n=i.parentElement,l=t.previousElementSibling,c=t.nextElementSibling,u=i.firstElementChild,f=i.lastElementChild,g=t===u,O=t===f,S=t.localName===r.COL,q=Array.from(i.children).indexOf(t);e===E.PREV&&!g&&l.hasAttribute("data-sortable")?(S&&Array.from(n.rows).forEach(I=>this.insertBefore(I.cells[q],I.cells[q-1])),this.insertBefore(t,l)):e===E.NEXT&&!O&&c.hasAttribute("data-sortable")?(S&&Array.from(n.rows).forEach(I=>this.insertAfter(I.cells[q],I.cells[q+1])),this.insertAfter(t,c)):(e===E.FIRST&&!g||e===E.NEXT&&O)&&u.hasAttribute("data-sortable")?(S&&Array.from(n.rows).forEach(I=>this.insertFirstChild(I.cells[q],I)),this.insertBefore(t,u)):(e===E.LAST&&!O||e===E.PREV&&g)&&f.hasAttribute("data-sortable")&&(S&&Array.from(n.rows).forEach(I=>this.insertLastChild(I.cells[q],I)),this.insertAfter(t,f))}insertBefore(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforebegin",t)}insertAfter(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterend",t)}insertFirstChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterbegin",t)}insertLastChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforeend",t)}delete(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if([r.COL,r.TR].includes(t.localName)&&t.matches(":only-child"))return;if(t.localName===r.COL){let n=Array.from(t.parentElement.children).indexOf(t),l=t.parentElement.parentElement;Array.from(l.rows).forEach(c=>c.removeChild(c.cells[n]))}let e=t.previousElementSibling,i=t.nextElementSibling;t===this.getActiveElement()&&t.blur(),t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if(this.editor.root.contains(t))return!0;let e=t.closest(this.editor.root.localName);return e&&!e.parentElement}closest(t,e){if(!(t instanceof HTMLElement)||!this.contains(t.parentElement))throw new TypeError("Invalid argument");let i=t,n=t.parentElement;do if(this.arbitrary(n)&&this.editor.tags.allowed(n,e))return i;while((i=n)&&(n=n.parentElement)&&this.contains(n))}wrap(t,e,i={}){let n;if(t instanceof HTMLElement){if(t.parentElement.localName!==e&&(n=this.closest(t,e))){let l=this.createElement(e,i);this.insertAfter(l,n),this.insertLastChild(t,l)}}else throw new TypeError("Invalid argument")}getActiveElement(){let t=this.document.activeElement;return t&&this.contains(t)?t:void 0}getSelectedElement(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement&&e===i&&this.contains(e))return e}getSelectedElementByName(t){let e=this.getSelectedElement();return e?.localName===t?e:void 0}getSelectedAttributesByName(t){let e=this.getSelectedElementByName(t),i={};return e&&Array.from(e.attributes).forEach(n=>i[n.nodeName]=n.nodeValue),i}getSelectedEditable(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement){let n=e.closest("[contenteditable=true]"),l=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===l&&this.contains(n))return n}}getSelection(){return this.window.getSelection()}getRange(){let t=this.getSelection();return t.rangeCount>0?t.getRangeAt(0):void 0}setRange(t){let e=this.getSelection();e.removeAllRanges(),e.addRange(t)}selectContents(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}removeClass(t,...e){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.classList.remove(...e),t.classList.length>0||t.removeAttribute("class")}open({url:t,name:e,call:i,params:n={}}){if(!b(t)||!b(e)||!V(i))throw new TypeError("Invalid argument");let l=this.createElement(r.A,{attributes:{href:t}}),c=new URL(l.href);Object.entries(n).forEach(([f,g])=>c.searchParams.set(f,`${g}`));let u=this.window.open(c.toString(),e,this.#a());this.window.addEventListener("message",f=>{f.origin===c.origin&&f.source===u&&(i(f.data),u.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}#i(t,e,i){let n=this.createElement(t);for(let l=0;l<e;l++)this.insertLastChild(t===r.THEAD?this.createTableHeaderRow(i):this.createTableRow(i),n);return n}#a(){let t=Object.assign({},this.#s,{height:`${this.getHeight()}`,width:`${this.getWidth()}`},this.editor.config.base.browser);return Object.entries(t).filter(([,e])=>!!e).map(([e,i])=>`${e}=${i}`).join(",")}};var L=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t=t}filter(t){throw new Error("Not implemented")}};var Y=class{#t=new Set;add(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t.add(t)}filter(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t.forEach(e=>{t.normalize(),e.filter(t)})}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var F=class{name;group;children;attributes;alignable;arbitrary;deletable;editable;empty;focusable;navigable;slotable;sortable;enter;constructor({name:t,group:e,...i}={}){if(!b(t)||!b(e)||!Se(i.children)||!Se(i.attributes)||!M(i.enter))throw new TypeError("Invalid argument");this.name=t,this.group=e,this.children=i.children||[],this.attributes=i.attributes||[],this.arbitrary=i.arbitrary===!0,this.alignable=i.alignable===!0,this.deletable=i.deletable===!0,this.editable=i.editable===!0,this.empty=i.empty===!0,this.focusable=i.focusable===!0,this.navigable=i.navigable===!0,this.slotable=i.slotable===!0,this.sortable=i.sortable===!0,this.enter=i.enter}};var d=class{#t;get editor(){return this.#t}static get name(){throw new Error("Missing name")}static get dependencies(){return[]}static get config(){return{}}constructor(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t=t}init(){throw new Error("Not implemented")}_(t){return this.editor.translate(t)}_i18n(t){t[this.editor.config.base.lang]&&(this.editor.i18n=t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new F(t))}_command(t){this.editor.commands.set(new R(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.toolbar)}_formatbar(t,e=void 0,i=void 0){let n=this._(t),l=this._("Alt"),c=this._("Shift"),u=n+(e?` [${l} + ${c} + ${e}]`:"");this.editor.dom.insertLastChild(this.#e(n,u,e,i),this.editor.formatbar)}_focusbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.focusbar)}#e(t,e,i=void 0,n=void 0){if(!b(t)||!b(e)||!M(i))throw new TypeError("Invalid argument");return this.editor.dom.createElement(r.BUTTON,{attributes:{type:"button",title:e,"data-command":n||this.constructor.name,"data-key":i},html:t})}};var Z=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof d))throw new TypeError("Invalid argument");this.#t.set(t.constructor.name,t)}init(){this.#t.forEach(t=>t.init())}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var X=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof F))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}allowed(t,e,i=!1){let n=i?e:this.get(e)?.group;return!!this.get(t)?.children.includes(n)}freeze(){this.#t.forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(this.#t),Object.freeze(this)}};var T=class{#t;get orig(){return this.#t}#e={};get config(){return this.#e}#r;get dom(){return this.#r}#o;get element(){return this.#o}#s;get toolbar(){return this.#s}#i;get toolbarDispatcher(){return this.#i}#a;get formatbar(){return this.#a}#d;get formatbarDispatcher(){return this.#d}#m;get focusbar(){return this.#m}#l;get focusbarDispatcher(){return this.#l}#c;get root(){return this.#c}#h;get rootDispatcher(){return this.#h}#n={};get i18n(){return this.#n}set i18n(t){this.#n={...this.#n,...t||{}}}#u=new X;get tags(){return this.#u}#f=new Y;get filters(){return this.#f}#p=new $;get dialogs(){return this.#p}#g=new j;get commands(){return this.#g}#E=new Z;get plugins(){return this.#E}static get defaultConfig(){return{}}constructor(t,e={}){if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=new Q(this,this.orig.ownerDocument),this.#o=this.dom.createElement(r.EDITOR),this.#s=this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}}),this.dom.insertLastChild(this.toolbar,this.element),this.#i=new B(this.toolbar),this.#a=this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}}),this.formatbar.hidden=!0,this.dom.insertLastChild(this.formatbar,this.element),this.#d=new B(this.formatbar),this.#m=this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}}),this.focusbar.hidden=!0,this.dom.insertLastChild(this.focusbar,this.element),this.#l=new B(this.focusbar),this.#c=this.dom.createElement(r.ROOT),this.dom.insertLastChild(this.root,this.element),this.#h=new B(this.root)}init(){let t=this.config;this.#e={};let e=this.constructor.defaultConfig.base?.plugins||[],i=e;if(Array.isArray(t.base?.plugins)&&t.base.plugins.length>0){let c=t.base.plugins;t.base?.pluginsDisabled?i=i.filter(u=>!c.includes(u.name)):(i=[],c.forEach(u=>{let f=e.find(g=>g.name===u);f&&i.push(f)}))}let n=new Set,l=c=>{c.dependencies?.forEach(l),n.add(c)};i.map(l),n.forEach(c=>{Object.entries(c.config).forEach(([u,f])=>{this.config[c.name]??={},this.config[c.name][u]=t[c.name]?.[u]||this.constructor.defaultConfig[c.name]?.[u]||f}),this.plugins.set(new c(this))}),this.config.base.lang&&(this.element.lang=this.config.base.lang),this.plugins.init(),this.toolbarDispatcher.dispatch("init"),this.formatbarDispatcher.dispatch("init"),this.focusbarDispatcher.dispatch("init"),this.rootDispatcher.dispatch("init")}freeze(){Object.freeze(this.config),Object.freeze(this.i18n),this.tags.freeze(),this.filters.freeze(),this.dialogs.freeze(),this.commands.freeze(),this.plugins.freeze()}load(){this.orig instanceof HTMLTextAreaElement?(this.orig.form.addEventListener("submit",()=>this.save()),this.setHtml(this.orig.value.replace("/ /g"," "))):this.setHtml(this.orig.innerHTML),this.dom.insertAfter(this.element,this.orig),this.orig.hidden=!0,this.rootDispatcher.dispatch("load")}destroy(){this.element.parentElement.removeChild(this.element),this.orig.hidden=!1,this.rootDispatcher.dispatch("destroy")}getHtml(){let t=this.dom.createElement(this.root.localName,{html:this.root.innerHTML});return this.filters.filter(t),this.rootDispatcher.dispatch("gethtml",t),t.innerHTML}setHtml(t){let e=this.dom.createElement(this.root.localName,{html:t});this.rootDispatcher.dispatch("sethtml",e),this.filters.filter(e),this.root.innerHTML=e.innerHTML}save(){this.orig instanceof HTMLTextAreaElement?this.orig.value=this.getHtml():this.orig.innerHTML=this.getHtml(),this.rootDispatcher.dispatch("save")}translate(t){return this.i18n[t]||t}url(t){let e=this.dom.window.origin||this.dom.window.location.origin,i=this.dom.createElement(r.A,{attributes:{href:t}});return e===i.origin?i.pathname:i.href}static create(t,e={}){let i=new this(t,e);return i.init(),i.freeze(),i.load(),i}};var J=class{#t;get editor(){return this.#t}#e;get form(){return this.#e}#r;constructor(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t=t,this.#e=this.editor.dom.createElement(r.FORM,{attributes:{method:"dialog"}}),this.addFieldset().#o().#s()}addFieldset(){let t=this.editor.dom.createElement(r.FIELDSET);return this.#r?this.editor.dom.insertAfter(t,this.#r):this.editor.dom.insertFirstChild(t,this.#e),this.#r=t,this}addLegend(t){if(!b(t))throw new TypeError("Invalid argument");return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LEGEND,{html:t}),this.#r),this}addTextInput(t,e,i={}){return this.addInput(t,e,i,"text")}addNumberInput(t,e,i={}){return this.addInput(t,e,i,"number")}addInput(t,e,i={},n="text"){if(!b(t)||!b(e)||!b(n))throw new TypeError("Invalid argument");Object.assign(i,{id:`editor-${t}`,name:t,type:n});let l=this.editor.dom.createElement(r.DIV);return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LABEL,{attributes:{for:i.id},html:e}),l),this.editor.dom.insertLastChild(this.editor.dom.createElement(r.INPUT,{attributes:i}),l),i.required&&l.setAttribute("data-required",""),this.editor.dom.insertLastChild(l,this.#r),this}#o(){let t=this.#i("Cancel"),e=this.editor.dom.createElement(r.BUTTON,{attributes:{type:"reset"},html:t});return this.editor.dom.insertLastChild(e,this.#e),this}#s(){let t=this.editor.dom.createElement(r.BUTTON,{html:this.#i("Save")});return this.editor.dom.insertLastChild(t,this.#e),this}#i(t){return this.editor.translate(t)}};var p=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get browserUrl(){return this.#r}#o;get formCreator(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof T)||!b(e)||!M(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i}open(t,e={}){this.browserUrl?this.#s(t,e):this.#i(t,e)}_(t){return this.editor.translate(t)}_prepareForm(){throw new Error("Not implemented")}#s(t,e={}){this.editor.dom.open({url:this.browserUrl,name:this.name,call:t,params:e})}#i(t,e={}){let i=this.editor.dom.getRange();this.#a();let n=this.editor.dom.createElement(r.DIALOG);n.addEventListener("click",c=>c.target===n&&n.close()),n.addEventListener("close",()=>{i&&this.editor.dom.setRange(i),n.returnValue&&t(JSON.parse(n.returnValue)),this.#a()}),this.editor.dom.insertLastChild(n,this.editor.element),this.#o=new J(this.editor),this._prepareForm();let l=this.formCreator.form;l.addEventListener("submit",()=>n.close(JSON.stringify(Object.fromEntries(new FormData(l))))),l.addEventListener("reset",()=>n.close()),new FormData(l).forEach((c,u)=>v(e[u])&&(l.elements[u].value=e[u])),this.editor.dom.insertLastChild(l,n),n.showModal()}#a(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})}};var tt=class extends p{constructor(t){super(t,D.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var A=class{static get NONE(){return"none"}static get LEFT(){return"left"}static get CENTER(){return"center"}static get RIGHT(){return"right"}static values(){return[this.NONE,this.LEFT,this.CENTER,this.RIGHT]}};var a=class{static get A(){return"a"}static get ARROWDOWN(){return"ArrowDown"}static get ARROWLEFT(){return"ArrowLeft"}static get ARROWRIGHT(){return"ArrowRight"}static get ARROWUP(){return"ArrowUp"}static get B(){return"b"}static get BACKSPACE(){return"Backspace"}static get C(){return"c"}static get D(){return"d"}static get DEL(){return"Delete"}static get E(){return"e"}static get END(){return"End"}static get ENTER(){return"Enter"}static get F(){return"f"}static get G(){return"g"}static get HOME(){return"Home"}static get I(){return"i"}static get J(){return"j"}static get K(){return"k"}static get L(){return"l"}static get M(){return"m"}static get O(){return"o"}static get Q(){return"q"}static get R(){return"r"}static get S(){return"s"}static get SPACE(){return" "}static get T(){return"t"}static get TAB(){return"Tab"}static get U(){return"u"}static get V(){return"v"}static get W(){return"w"}static get X(){return"x"}static get Y(){return"y"}static get Z(){return"z"}static isEventFor(t,e,{alt:i=!1,ctrl:n=!1,shift:l=!1}={}){return(Array.isArray(e)&&e.includes(t.key)||t.key===e)&&t.altKey===i&&t.ctrlKey===n&&t.shiftKey===l}};var h=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t=t}handleEvent(t){V(this[t.type])&&this[t.type](t)}_(t){return this.editor.translate(t)}};var et=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-alignable")&&t.addEventListener("keydown",this)}keydown(t){let e={[a.ARROWUP]:A.NONE,[a.ARROWLEFT]:A.LEFT,[a.ARROWDOWN]:A.CENTER,[a.ARROWRIGHT]:A.RIGHT};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.dom.removeClass(t.target,...A.values()),e[t.key]!==A.NONE&&t.target.classList.add(e[t.key]))}};var rt=class extends L{filter(t){let e=this.editor.tags.get(t),i=this.editor.tags.allowed(t,r.P),n=e.editable||e.group===o.FORMAT,l=[],c=(u=null)=>{if(i&&l.length>0){let f=this.editor.dom.createElement(r.P,{html:l.join(" ")});u?this.editor.dom.insertBefore(f,u):this.editor.dom.insertLastChild(f,t),l=[]}};Array.from(t.childNodes).forEach(u=>{let f=u.textContent.trim();if(u instanceof HTMLElement){let g=this.#t(u),O=this.editor.tags.get(g);if(O&&this.editor.tags.allowed(t,g))c(g),this.#e(g,O);else if(O&&O.group===o.FORMAT&&i){let S=this.#e(g,O);S&&(l.push(S.outerHTML),t.removeChild(S))}else!n&&f&&i?(l.push(f),t.removeChild(g)):n&&f?t.replaceChild(this.editor.dom.createText(f),g):t.removeChild(g)}else u instanceof Text?(!n&&f&&i&&l.push(f),(!n||!f)&&t.removeChild(u)):u instanceof Node&&t.removeChild(u)}),c()}#t(t){let e=this.editor.config.base.filter[t.localName];if(!e)return t;let i=this.editor.dom.createElement(e,{html:t.innerHTML});return t.parentElement.replaceChild(i,t),i}#e(t,e){if(Array.from(t.attributes).forEach(i=>!e.attributes.includes(i.name)&&t.removeAttribute(i.name)),t.hasChildNodes()&&this.editor.filters.filter(t),t.hasChildNodes()||e.empty)return t;t.parentElement?.removeChild(t)}};var it=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-deletable")&&t.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&a.isEventFor(t,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var ot=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.contentEditable==="true"?t.addEventListener("keydown",this):t.parentElement.contentEditable==="true"&&t.addEventListener("dblclick",this)}keydown(t){if(a.isEventFor(t,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(a.isEventFor(t,a.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;if(e){if(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")){let i=this.editor.dom.closest(t.target,e);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(e),i)}else if(!(t.target instanceof HTMLParagraphElement)){let i=this.editor.dom.closest(t.target,r.P);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(r.P),i),t.target.parentElement.removeChild(t.target)}}}else a.isEventFor(t,a.BACKSPACE)&&!t.target.textContent&&t.target.hasAttribute("data-deletable")?(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation()):/^[A-Z]$/.test(t.key)&&a.isEventFor(t,t.key,{alt:!0,shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick({target:t}){this.editor.dom.selectContents(t),this.editor.commands.findByTagName(t.localName)?.execute()}};var st=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-focusable")&&t.focus()}};var _=class extends h{insertbutton({target:t,detail:{element:e}}){e.getAttribute("data-command")&&e.addEventListener("click",this),e.tabIndex=e===t.firstElementChild?0:-1,e.addEventListener("keydown",this)}click({target:t}){this.editor.commands.execute(t.getAttribute("data-command"))}keydown(t){if(a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.HOME,a.END])){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWLEFT&&!c?e.focus():t.key===a.ARROWRIGHT&&!u?i.focus():t.key===a.HOME||t.key===a.ARROWRIGHT&&u?n.focus():(t.key===a.END||t.key===a.ARROWLEFT&&c)&&l.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");t.hidden=!1;let{x:i,y:n}=e.getBoundingClientRect(),{x:l,y:c}=this.editor.root.getBoundingClientRect(),u=i-l+t.clientWidth-this.editor.root.clientWidth,f=n-c-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,g=t.clientWidth<this.editor.root.clientWidth?i-l:0;g>0&&u>0&&(g=g>u?(g-u)/2:0),t.style.left=`${g}px`,t.style.top=`${f}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var at=class extends _{constructor(t){super(t),this.editor.focusbar.addEventListener("insertbutton",this),this.editor.root.addEventListener("focusin",this),this.editor.root.addEventListener("focusout",this),this.editor.dom.document.addEventListener("selectionchange",this)}insertbutton(t){super.insertbutton(t),t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("mousedown",this)}mousedown(t){t.preventDefault(),t.stopPropagation()}focusin({target:t}){t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}focusout(){this.#e()}selectionchange(){let t=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!t?this.#e():t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}#t(t){!this.editor.focusbar.children.length||(Object.keys(t.dataset).forEach(e=>this.editor.focusbar.dataset[e]=t.dataset[e]),this.editor.focusbar.dataset.tag=t.localName,this._show(this.editor.focusbar,t))}#e(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(t=>delete this.editor.focusbar.dataset[t])}};var nt=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 dt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-navigable")&&(t.tabIndex=0,t.addEventListener("keydown",this))}keydown(t){if(t.target===t.currentTarget&&a.isEventFor(t,[a.ARROWUP,a.ARROWDOWN,a.HOME,a.END])&&this.#t(t.target)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWUP&&!c&&e.hasAttribute("data-navigable")?e.focus():t.key===a.ARROWDOWN&&!u&&i.hasAttribute("data-navigable")?i.focus():(t.key===a.HOME||t.key===a.ARROWDOWN&&u)&&n.hasAttribute("data-navigable")?n.focus():(t.key===a.END||t.key===a.ARROWUP&&c)&&l.hasAttribute("data-navigable")&&l.focus(),t.preventDefault(),t.stopPropagation()}}#t(t){if(t.contentEditable!=="true")return!0;let e=this.editor.dom.getSelection(),i=this.editor.dom.getSelectedEditable(),n=this.editor.dom.getSelectedElement();return e.isCollapsed&&e.anchorOffset===0&&[i,t.firstChild].includes(n)}};var mt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t instanceof HTMLSlotElement?t.addEventListener("keydown",this):t.hasAttribute("data-slotable")&&!t.querySelector(":scope > "+r.SLOT)&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.SLOT),t)}keydown(t){a.isEventFor(t,a.BACKSPACE)&&t.target.matches(":only-child")?this.editor.dom.delete(t.target.parentElement):!a.isEventFor(t,a.TAB)&&!a.isEventFor(t,a.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var lt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-sortable")&&(t.addEventListener("keydown",this),t.addEventListener("pointerdown",this),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this))}keydown(t){let e={[a.HOME]:E.FIRST,[a.ARROWUP]:E.PREV,[a.ARROWDOWN]:E.NEXT,[a.END]:E.LAST};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{ctrl:!0})&&(this.editor.dom.sort(t.target,e[t.key]),t.preventDefault(),t.stopPropagation())}pointerdown(t){let e=t.target.closest("[data-sortable]");e&&this.editor.dom.contains(e)&&(e.setAttribute("data-sort",""),e.setPointerCapture(t.pointerId))}pointermove(t){let e=t.target.closest("[data-sortable][data-sort]"),i=this.editor.dom.document.elementFromPoint(t.x,t.y);this.#t(),e&&this.editor.dom.contains(e)&&this.#e(e,i)&&i.setAttribute("data-sortover","")}pointerup(t){let e=t.target.closest("[data-sortable][data-sort]");if(e&&this.editor.dom.contains(e)){let i=this.editor.dom.document.elementFromPoint(t.x,t.y),n=i.parentElement;if(this.#t(),e.removeAttribute("data-sort"),e.releasePointerCapture(t.pointerId),this.#e(e,i)){if(e.localName===r.COL&&n===e.parentElement){let l=Array.from(n.children).indexOf(e),c=Array.from(n.children).indexOf(i),u=n.parentElement;Array.from(u.rows).forEach(f=>this.editor.dom.insertBefore(f.cells[l],f.cells[c]))}this.editor.dom.insertBefore(e,i)}}}#t(){this.editor.root.querySelectorAll("[data-sortover]").forEach(t=>t.removeAttribute("data-sortover"))}#e(t,e){return t instanceof HTMLElement&&e instanceof HTMLElement&&this.editor.dom.contains(e)&&![this.editor.root,t].includes(e)&&e.hasAttribute("data-sortable")&&(t.parentElement===e.parentElement||this.editor.dom.arbitrary(t.parentElement)&&this.editor.dom.arbitrary(e.parentElement))&&this.editor.tags.allowed(e.parentElement,t)}};var ct=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){let e=this.editor.tags.get(t);e&&(e.editable&&(t.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.dataset[i]="")}))}};var ht=class extends _{constructor(t){super(t),this.editor.toolbar.addEventListener("insertbutton",this)}};var m=class extends d{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._tag({name:r.ROOT,group:o.ROOT,children:[o.AUDIO,o.BLOCK,o.CONTAINER,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO]}),this._tag({name:r.SLOT,group:o.SLOT,editable:!0,focusable:!0,navigable:!0,sortable:!0}),new ct(this.editor),new ht(this.editor),new nt(this.editor),new at(this.editor),new ot(this.editor),new it(this.editor),new dt(this.editor),new lt(this.editor),new et(this.editor),new st(this.editor),new mt(this.editor),this.editor.filters.add(new rt(this.editor))}};var D=class extends d{static get name(){return"abbreviation"}static get dependencies(){return[m]}init(){this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new tt(this.editor)),this._command(r.ABBR),this._formatbar("Abbreviation",a.A)}};var ut=class extends R{#t;constructor(t,e){if(!A.values().includes(e))throw new TypeError("Invalid argument");super(t,P.name+"-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-alignable")&&(this.editor.dom.removeClass(t,...A.values()),this.#t!==A.NONE&&t.classList.add(this.#t))}};var P=class extends d{static get name(){return"align"}static get dependencies(){return[m]}init(){let t={[A.NONE]:"No alignment",[A.LEFT]:"Align left",[A.CENTER]:"Align center",[A.RIGHT]:"Align right"};Object.entries(t).forEach(([e,i])=>{let n=new ut(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var ft=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Audio")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to audio"),required:"required"}).addTextInput("id",this._("ID"))}};var pt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.AUDIO)).forEach(e=>this.#t(e))}insertaudio({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:H.name}})):t.parentElement.removeChild(t)}};var gt=class extends L{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var Et=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertfigure",this)}insertfigure({detail:{element:t}}){t.querySelector(":scope > "+r.FIGCAPTION)||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.FIGCAPTION),t)}};var x=class extends d{static get name(){return"figure"}static get dependencies(){return[m]}init(){this._tag({name:r.FIGURE,group:o.FIGURE,children:[o.AUDIO,o.CAPTION,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.TABLE,o.VIDEO],attributes:["class"],alignable:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag({name:r.FIGCAPTION,group:o.CAPTION,children:[o.FORMAT],editable:!0,navigable:!0,enter:r.P}),new Et(this.editor),this.editor.filters.add(new gt(this.editor))}};var H=class extends d{static get name(){return"audio"}static get dependencies(){return[m,x]}static get config(){return{browser:void 0}}init(){this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new pt(this.editor),this.editor.dialogs.set(new ft(this.editor,this.constructor.name,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar("Audio")}};var bt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var Tt=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super(),this.attachShadow({mode:"open"})}};var Lt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock({detail:{element:t}}){if(!t.id){t.parentElement.removeChild(t);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.id),i=await fetch(e,{mode:"no-cors"});if(!i.ok)return;let n="";this.editor.config.block.css&&(n=this.editor.config.block.css.split(",").map(c=>`<link rel="stylesheet" href="${c}">`).join(""));let l=await i.text();t.content=n+l}};var At=class extends d{static get name(){return"block"}static get dependencies(){return[m]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this.editor.dom.registerElement(r.BLOCK,Tt),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new Lt(this.editor),this.editor.dialogs.set(new bt(this.editor,this.constructor.name,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar("Block")}};var xt=class extends L{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.BLOCKQUOTE),t),t.parentElement.removeChild(t))}};var Rt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:C.name}})}deleteblockquote({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.parentElement.removeChild(t)}};var wt=class extends L{filter(t){if(t instanceof HTMLPreElement){t.outerHTML=t.outerHTML.replace(/(<br\s*\/?>)/gi,`
|
|
2
|
-
`);return}t.innerHTML=t.innerHTML.replace(/^\s*(<br\s*\/?>\s*)+/gi,"").replace(/\s*(<br\s*\/?>\s*)+$/gi,""),t instanceof HTMLParagraphElement?t.outerHTML=t.outerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"</p><p>"):t.innerHTML=t.innerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"<br>")}};var w=class extends d{static get name(){return"break"}static get dependencies(){return[m]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new wt(this.editor))}};var C=class extends d{static get name(){return"blockquote"}static get dependencies(){return[m,w,x]}init(){this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new Rt(this.editor),this._command(r.BLOCKQUOTE),this._toolbar("Blockquote"),this.editor.filters.add(new xt(this.editor))}};var Ot=class extends d{static get name(){return"bold"}static get dependencies(){return[m]}init(){this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar("bold",a.B)}};var It=class extends d{static get name(){return"cite"}static get dependencies(){return[m]}init(){this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar("Citation",a.Z)}};var yt=class extends d{static get name(){return"code"}static get dependencies(){return[m]}init(){this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar("Code",a.C)}};var Ct=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Nt=class extends d{static get name(){return"data"}static get dependencies(){return[m]}init(){this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new Ct(this.editor,this.constructor.name)),this._command(r.DATA),this._formatbar("Data",a.J)}};var _t=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var St=class extends d{static get name(){return"definition"}static get dependencies(){return[m]}init(){this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new _t(this.editor,this.constructor.name)),this._command(r.DFN),this._formatbar("Definition",a.D)}};var Mt=class extends R{constructor(t){super(t,U.name)}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var U=class extends d{static get name(){return"delete"}static get dependencies(){return[m]}init(){this.editor.commands.set(new Mt(this.editor)),this._focusbar("Delete",this.constructor.name)}};var Bt=class extends d{static get name(){return"deletion"}static get dependencies(){return[m]}init(){this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar("Text Deletion",a.G)}};var vt=class extends L{filter(t){t.querySelectorAll(`${r.SUMMARY}:not(:first-child)`).forEach(e=>e.parentElement.removeChild(e)),t.querySelectorAll(`${r.SUMMARY}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var Ft=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails({detail:{element:t}}){t.open=!0,t.querySelector(`:scope > ${r.SUMMARY}:first-child`)||this.editor.dom.insertFirstChild(this.editor.dom.createElement(r.SUMMARY),t)}insertsummary({detail:{element:t}}){this.#t(t),t.addEventListener("click",this),t.addEventListener("blur",this),t.addEventListener("keydown",this)}click(t){t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0}blur({target:t}){this.#t(t)}keydown(t){a.isEventFor(t,a.SPACE)?(t.preventDefault(),t.stopPropagation(),this.editor.dom.insertText(" ")):a.isEventFor(t,a.ENTER)&&(t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0)}#t(t){t.textContent.trim()?t.querySelectorAll(r.BR+":not(:last-child)").forEach(e=>e.parentElement.removeChild(e)):t.textContent=this._("Details"),t.lastElementChild instanceof HTMLBRElement||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.BR),t)}};var Dt=class extends d{static get name(){return"details"}static get dependencies(){return[m]}init(){this._tag({name:r.DETAILS,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.SUMMARY,o.TABLE,o.VIDEO],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this._tag({name:r.SUMMARY,group:o.SUMMARY,editable:!0,navigable:!0,enter:r.P}),new Ft(this.editor),this._command(r.DETAILS),this._toolbar("Details"),this.editor.filters.add(new vt(this.editor))}};var Pt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var Ht=class extends d{static get name(){return"division"}static get dependencies(){return[m]}init(){this._tag({name:r.DIV,group:o.CONTAINER,children:[o.AUDIO,o.BLOCK,o.FIGURE,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new Pt(this.editor,this.constructor.name)),this._command(r.DIV),this._toolbar("Division")}};var Ut=class extends d{static get name(){return"emphasis"}static get dependencies(){return[m]}init(){this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar("emphasized",a.E)}};var Gt=class extends d{static get name(){return"heading"}static get dependencies(){return[m]}init(){this._tag({name:r.H2,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H2),this._toolbar("Heading")}};var kt=class extends d{static get name(){return"horizontalrule"}static get dependencies(){return[m]}init(){this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar("Horizontal Rule")}};var ve={"CSS class":"CSS-Klasse",Height:"H\xF6he",ID:"ID","Insert CSS class":"CSS-Klasse eingeben",URL:"URL",Width:"Breite",Abbreviation:"Abk\xFCrzung","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen","Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig","No alignment":"Keine Ausrichtung",Audio:"Audio","Insert URL to audio":"URL zur Audiodatei eingeben",Alt:"Alt",Cancel:"Abbrechen",Save:"Speichern",Shift:"Umschalt",Block:"Block",Blockquote:"Blockzitat",bold:"fett",Citation:"Zitatquelle",Code:"Quelltext",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff",Delete:"L\xF6schen","Text Deletion":"Textl\xF6schung",Details:"Details",Division:"Division",emphasized:"betont",Heading:"\xDCberschrift","Horizontal Rule":"Horizontale Linie",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben","Alternative text":"Alternativtext",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist","Text Insertion":"Texteinf\xFCgung",italic:"kursiv","User Input":"Benutzereingabe","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",mark:"markiert","Ordered List":"Geordnete Liste",Paragraph:"Absatz","Preformatted Text":"Vorformatierter Text",Quote:"Zitat","Sample Output":"Beispielausgabe",Section:"Sektion",small:"klein","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",strikethrough:"durchgestrichen","strongly emphasized":"stark betont",Subheading:"Unter\xFCberschrift",subscript:"tiefgestellt",superscript:"hochgestellt",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","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","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Time:"Zeit",underline:"unterstrichen","Unordered List":"Ungeordnete Liste",Variable:"Variable","Insert URL to video":"URL zur Videodatei eingeben",Video:"Video"};var Kt=class extends d{static get name(){return"i18n"}static get dependencies(){return[m]}init(){this._i18n({de:ve})}};var Wt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Iframe")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to embedded page"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var zt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IFRAME)).forEach(e=>this.#t(e))}insertiframe({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.allowFullscreen=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:G.name}})):t.parentElement.removeChild(t)}};var G=class extends d{static get name(){return"iframe"}static get dependencies(){return[m,x]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new zt(this.editor),this.editor.dialogs.set(new Wt(this.editor,this.constructor.name,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar("Iframe")}};var qt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Image")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to image"),required:"required"}).addTextInput("alt",this._("Alternative text"),{placeholder:this._("Text shown when media element is not available")}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Vt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IMG)).forEach(e=>this.#t(e))}insertimg({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:k.name}})):t.parentElement.removeChild(t)}};var k=class extends d{static get name(){return"image"}static get dependencies(){return[m,x]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new Vt(this.editor),this.editor.dialogs.set(new qt(this.editor,this.constructor.name,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar("Image")}};var jt=class extends d{static get name(){return"insertion"}static get dependencies(){return[m]}init(){this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar("Text Insertion",a.F)}};var $t=class extends d{static get name(){return"italic"}static get dependencies(){return[m]}init(){this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar("italic",a.I)}};var Qt=class extends d{static get name(){return"keyboard"}static get dependencies(){return[m]}init(){this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar("User Input",a.K)}};var Yt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var Zt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.A)).forEach(e=>this.#t(e))}inserta({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("href");e?t.setAttribute("href",this.editor.url(e)):t.parentElement.replaceChild(this.editor.dom.createText(t.textContent),t)}};var Xt=class extends d{static get name(){return"link"}static get dependencies(){return[m]}init(){this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new Zt(this.editor),this.editor.dialogs.set(new Yt(this.editor,this.constructor.name)),this._command(r.A),this._formatbar("Link",a.L)}};var Jt=class extends d{static get name(){return"mark"}static get dependencies(){return[m]}init(){this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar("mark",a.M)}};var te=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertli",this),this.editor.root.addEventListener("deleteli",this),this.editor.root.addEventListener("insertol",this),this.editor.root.addEventListener("insertul",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.LI)).forEach(e=>this.#t(e))}insertli({detail:{element:t}}){this.#t(t)}deleteli({detail:{target:t}}){t.children.length===0&&t.parentElement.removeChild(t)}insertol({detail:{element:t}}){this.#e(t)}insertul({detail:{element:t}}){this.#e(t)}#t(t){!(t.parentElement instanceof HTMLOListElement)&&!(t.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(t,r.UL)}#e(t){t.children.length===0&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LI),t)}};var K=class extends d{static get name(){return"list"}static get dependencies(){return[m,w]}init(){this._tag({name:r.LI,group:o.LISTITEM,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.LI}),new te(this.editor)}};var ee=class extends d{static get name(){return"orderedlist"}static get dependencies(){return[m,K]}init(){this._tag({name:r.OL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.OL),this._toolbar("Ordered List")}};var re=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.P)).forEach(e=>e.addEventListener("paste",this))}insertp({detail:{element:t}}){t.addEventListener("paste",this)}paste({target:t}){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(t))}};var ie=class extends d{static get name(){return"paragraph"}static get dependencies(){return[m,w]}init(){this._tag({name:r.P,group:o.PARAGRAPH,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),new re(this.editor),this._command(r.P),this._toolbar("Paragraph")}};var oe=class extends L{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.PRE),t),t.parentElement.removeChild(t))}};var se=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:N.name}})}deletepre({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.parentElement.removeChild(t)}};var N=class extends d{static get name(){return"preformat"}static get dependencies(){return[m,w,x]}init(){this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new se(this.editor),this._command(r.PRE),this._toolbar("Preformatted Text"),this.editor.filters.add(new oe(this.editor))}};var ae=class extends d{static get name(){return"quote"}static get dependencies(){return[m]}init(){this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar("Quote",a.Q)}};var ne=class extends d{static get name(){return"sample"}static get dependencies(){return[m]}init(){this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar("Sample Output",a.O)}};var de=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var me=class extends d{static get name(){return"section"}static get dependencies(){return[m]}init(){this._tag({name:r.SECTION,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new de(this.editor,this.constructor.name)),this._command(r.SECTION),this._toolbar("Section")}};var le=class extends d{static get name(){return"small"}static get dependencies(){return[m]}init(){this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar("small",a.W)}};var ce=class extends R{#t;constructor(t,e){if(!E.values().includes(e))throw new TypeError("Invalid argument");super(t,W.name+"-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-sortable")&&this.editor.dom.sort(t,this.#t)}};var W=class extends d{static get name(){return"sort"}static get dependencies(){return[m]}init(){let t={[E.FIRST]:"Sort to the beginning",[E.PREV]:"Sort before previous element",[E.NEXT]:"Sort after next element",[E.LAST]:"Sort to the end"};Object.entries(t).forEach(([e,i])=>{let n=new ce(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var he=class extends d{static get name(){return"strikethrough"}static get dependencies(){return[m]}init(){this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar("strikethrough",a.R)}};var ue=class extends d{static get name(){return"strong"}static get dependencies(){return[m]}init(){this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar("strongly emphasized",a.S)}};var fe=class extends d{static get name(){return"subheading"}static get dependencies(){return[m]}init(){this._tag({name:r.H3,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H3),this._toolbar("Subheading")}};var pe=class extends d{static get name(){return"subscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar("subscript",a.X)}};var ge=class extends d{static get name(){return"superscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar("superscript",a.Y)}};var Ee=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttd({detail:{element:t}}){t.addEventListener("keydown",this)}insertth({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){let e=t.target,i=e.parentElement,n=e.closest(r.TABLE);if(e instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&n instanceof HTMLTableElement&&a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.ARROWUP,a.ARROWDOWN])&&this.#t(e,t.key)){let l=e.cellIndex,c=i.cells.length,u=l===0,f=l===c-1,g=i.rowIndex===0,O=i.rowIndex===n.rows.length-1;t.preventDefault(),t.stopPropagation(),t.key===a.ARROWLEFT&&!u?this.editor.dom.focusEnd(i.cells[l-1]):t.key===a.ARROWLEFT&&g?this.editor.dom.focusEnd(n.rows[n.rows.length-1].cells[c-1]):t.key===a.ARROWLEFT?this.editor.dom.focusEnd(n.rows[i.rowIndex-1].cells[c-1]):t.key===a.ARROWRIGHT&&!f?i.cells[l+1].focus():t.key===a.ARROWRIGHT&&O?n.rows[0].cells[0].focus():t.key===a.ARROWRIGHT?n.rows[i.rowIndex+1].cells[0].focus():t.key===a.ARROWUP&&g?n.rows[n.rows.length-1].cells[l].focus():t.key===a.ARROWUP?n.rows[i.rowIndex-1].cells[l].focus():t.key===a.ARROWDOWN&&O?n.rows[0].cells[l].focus():t.key===a.ARROWDOWN&&n.rows[i.rowIndex+1].cells[l].focus()}}#t(t,e){if([a.ARROWUP,a.ARROWDOWN].includes(e))return!0;let i=this.editor.dom.getSelection(),n=i.anchorNode instanceof HTMLElement?i.anchorNode:t;if(!i.isCollapsed)return!1;if(e===a.ARROWLEFT){let c=t.firstChild;return c instanceof HTMLElement&&(c=c.firstChild),i.anchorOffset===0&&[t,c].includes(n)}let l=t.lastChild;return t.lastChild instanceof HTMLBRElement&&t.lastChild.previousSibling&&(l=t.lastChild.previousSibling),l instanceof HTMLElement&&(l=l.lastChild),i.anchorOffset===n.textContent.length&&[t,l].includes(n)}};var be=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertcol",this)}insertcol({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){if(a.isEventFor(t,a.ENTER)){let e=t.target.parentElement,i=e.parentElement,n=Array.from(e.children).indexOf(t.target);Array.from(i.rows).forEach(l=>this.editor.dom.insertAfter(this.editor.dom.createElement(l.cells[n].localName),l.cells[n])),this.editor.dom.insertAfter(this.editor.dom.createElement(r.COL),t.target)}else a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var Te=class extends R{constructor(t){super(t,y.name,r.TABLE)}_insert({rows:t,cols:e}={}){this.editor.dom.insert(this.editor.dom.createTable(parseInt(t,10)||1,parseInt(e,10)||1))}};var Le=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Table")).addNumberInput("rows",this._("Rows"),{min:"1",required:"required",value:"1"}).addNumberInput("cols",this._("Columns"),{min:"1",required:"required",value:"1"})}};var Ae=class extends L{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(y.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.TABLE),t),t.parentElement.removeChild(t)):(t instanceof HTMLTableElement&&t.querySelector(`:scope > ${r.THEAD}, :scope > ${r.TFOOT}`)&&!t.querySelector(":scope > "+r.TBODY)||t instanceof HTMLTableSectionElement&&t.rows.length<=0||t instanceof HTMLTableRowElement&&!t.querySelector(`:scope > ${r.TH}:not(:empty), :scope > ${r.TD}:not(:empty)`))&&t.parentElement.removeChild(t)}};var xe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttable",this)}inserttable({detail:{element:t}}){if(this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:y.name}}),t.tBodies.length>0&&t.tBodies[0].rows[0]){let e=t.tBodies[0],i=e.rows[0].cells.length;t.querySelector(":scope > "+r.COLGROUP)||this.editor.dom.insertFirstChild(this.editor.dom.createTableColumnGroup(i),t),t.tHead||this.editor.dom.insertBefore(this.editor.dom.createTableHeader(1,i),e),t.tFoot||this.editor.dom.insertLastChild(this.editor.dom.createTableFooter(1,i),t)}}};var Re=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttr",this)}inserttr({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){a.isEventFor(t,a.ENTER)?this.editor.dom.insertAfter(this.editor.dom.createTableRow(t.target.cells.length),t.target):a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var y=class extends d{static get name(){return"table"}static get dependencies(){return[m,w,x]}init(){this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag({name:r.COLGROUP,group:o.COLGROUP,children:[o.COL]}),this._tag({name:r.COL,group:o.COL,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#t(r.THEAD)),this._tag(this.#t(r.TBODY)),this._tag(this.#t(r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL],deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#e(r.TH)),this._tag(this.#e(r.TD)),new xe(this.editor),new be(this.editor),new Re(this.editor),new Ee(this.editor),this.editor.filters.add(new Ae(this.editor)),this.editor.dialogs.set(new Le(this.editor,this.constructor.name)),this.editor.commands.set(new Te(this.editor)),this._toolbar("Table")}#t(t){return{name:t,group:o.TABLESECTION,children:[o.TABLEROW]}}#e(t){return{name:t,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}}};var we=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var Oe=class extends d{static get name(){return"time"}static get dependencies(){return[m]}init(){this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new we(this.editor,this.constructor.name)),this._command(r.TIME),this._formatbar("Time",a.T)}};var Ie=class extends d{static get name(){return"underline"}static get dependencies(){return[m]}init(){this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar("underline",a.U)}};var ye=class extends d{static get name(){return"unorderedlist"}static get dependencies(){return[m,K]}init(){this._tag({name:r.UL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.UL),this._toolbar("Unordered List")}};var Ce=class extends d{static get name(){return"variable"}static get dependencies(){return[m]}init(){this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar("Variable",a.V)}};var Ne=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Video")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to video"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var _e=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.VIDEO)).forEach(e=>this.#t(e))}insertvideo({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:z.name}})):t.parentElement.removeChild(t)}};var z=class extends d{static get name(){return"video"}static get dependencies(){return[m,x]}static get config(){return{browser:void 0}}init(){this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new _e(this.editor),this.editor.dialogs.set(new Ne(this.editor,this.constructor.name,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar("Video")}};var Be=class extends T{static get defaultConfig(){return{base:{plugins:[Kt,Ot,$t,ue,Ut,Ie,he,Xt,Jt,le,St,D,ae,It,yt,Qt,ne,Ce,pe,ge,Oe,Nt,jt,Bt,ie,Gt,fe,ye,ee,kt,C,k,z,H,G,y,N,me,Dt,Ht,At,P,W,U]}}}};export{Be as default};
|
|
1
|
+
var o=class{static get AUDIO(){return"audio"}static get BLOCK(){return"block"}static get BREAK(){return"break"}static get CAPTION(){return"caption"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get CONTAINER(){return"container"}static get FIGURE(){return"figure"}static get FORMAT(){return"format"}static get HEADING(){return"heading"}static get IFRAME(){return"iframe"}static get IMAGE(){return"image"}static get LIST(){return"list"}static get LISTITEM(){return"listitem"}static get PARAGRAPH(){return"paragraph"}static get PREFORMAT(){return"preformat"}static get QUOTE(){return"quote"}static get ROOT(){return"root"}static get RULE(){return"rule"}static get SLOT(){return"slot"}static get SUMMARY(){return"summary"}static get TABLE(){return"table"}static get TABLECELL(){return"tablecell"}static get TABLEROW(){return"tablerow"}static get TABLESECTION(){return"tablesection"}static get VIDEO(){return"video"}};function B(s){return typeof s<"u"}function W(s){return typeof s=="function"}function b(s){return s&&typeof s=="string"}function S(s){return!B(s)||b(s)}function _e(s){return!B(s)||Array.isArray(s)&&s.length>0}function Me(s){return!B(s)||s instanceof HTMLElement}var T=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get tag(){return this.#r}#o;get dialog(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof L)||!b(e)||!S(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i&&this.editor.tags.get(i),this.#o=this.editor.dialogs.get(e)}execute(){this.dialog?this._openDialog():this._insert(this.#s())}_insert(t={}){if(!this.tag)return;this.#i(t);let e=this.editor.dom.getSelectedElementByName(this.tag.name);this.tag.group!==o.FORMAT?this.editor.dom.insert(this.editor.dom.createElement(this.tag.name,{attributes:t})):e&&Object.keys(t).length>0?e.parentElement.replaceChild(this.editor.dom.createElement(this.tag.name,{attributes:t,html:e.textContent}),e):e?e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e):this.editor.dom.format(this.editor.dom.createElement(this.tag.name,{attributes:t}))}_openDialog(){this.dialog?.open(t=>this._insert(t),this.#s())}#s(){if(!this.tag)return{};let t=this.editor.dom.getSelectedAttributesByName(this.tag.name);return this.#i(t),t}#i(t){Object.keys(t).forEach(e=>this.tag.attributes.includes(e)&&t[e]||delete t[e])}};var z=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof T))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}findByTagName(t){return Array.from(this.#t.values()).find(e=>e.tag?.name===t)}execute(t){this.get(t).execute()}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var q=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof p))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var r=class{static get A(){return"a"}static get ABBR(){return"abbr"}static get ALL(){return"*"}static get AUDIO(){return"audio"}static get B(){return"b"}static get BLOCK(){return"app-block"}static get BLOCKQUOTE(){return"blockquote"}static get BR(){return"br"}static get BUTTON(){return"button"}static get CITE(){return"cite"}static get CODE(){return"code"}static get COL(){return"col"}static get COLGROUP(){return"colgroup"}static get DATA(){return"data"}static get DEL(){return"del"}static get DETAILS(){return"details"}static get DFN(){return"dfn"}static get DIALOG(){return"dialog"}static get DIV(){return"div"}static get EDITOR(){return"akilli-editor"}static get EM(){return"em"}static get FIELDSET(){return"fieldset"}static get FIGCAPTION(){return"figcaption"}static get FIGURE(){return"figure"}static get FOCUSBAR(){return"editor-focusbar"}static get FORM(){return"form"}static get FORMATBAR(){return"editor-formatbar"}static get H2(){return"h2"}static get H3(){return"h3"}static get HR(){return"hr"}static get I(){return"i"}static get IFRAME(){return"iframe"}static get IMG(){return"img"}static get INPUT(){return"input"}static get INS(){return"ins"}static get KBD(){return"kbd"}static get LABEL(){return"label"}static get LEGEND(){return"legend"}static get LI(){return"li"}static get MARK(){return"mark"}static get OL(){return"ol"}static get P(){return"p"}static get PRE(){return"pre"}static get Q(){return"q"}static get ROOT(){return"editor-root"}static get S(){return"s"}static get SAMP(){return"samp"}static get SECTION(){return"section"}static get SLOT(){return"slot"}static get SMALL(){return"small"}static get STRONG(){return"strong"}static get SUB(){return"sub"}static get SUMMARY(){return"summary"}static get SUP(){return"sup"}static get TABLE(){return"table"}static get TBODY(){return"tbody"}static get TD(){return"td"}static get TFOOT(){return"tfoot"}static get TH(){return"th"}static get THEAD(){return"thead"}static get TIME(){return"time"}static get TOOLBAR(){return"editor-toolbar"}static get TR(){return"tr"}static get U(){return"u"}static get UL(){return"ul"}static get VAR(){return"var"}static get VIDEO(){return"video"}};var v=class{#t;constructor(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t=t,this.register(this.#r.bind(this))}dispatch(t,e=void 0,i=void 0){if(!b(t)||!Me(e)||!Me(i))throw new TypeError("Invalid argument");this.#t.dispatchEvent(new CustomEvent(t,{detail:{element:e,target:i}}))}register(t,e={childList:!0,subtree:!0}){if(!W(t))throw new TypeError("Invalid argument");new MutationObserver(t).observe(this.#t,e)}#e(t,e,i){e instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(t,e,i),this.dispatch(`${t}${e.localName.replace("-","")}`,e,i))}#r(t){t.forEach(e=>{e.addedNodes.forEach(i=>{i instanceof HTMLElement&&(this.#e("insert",i,e.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>this.#e("insert",n,e.target)))}),e.removedNodes.forEach(i=>i instanceof HTMLElement&&this.#e("delete",i,e.target))})}};var E=class{static get FIRST(){return"first"}static get PREV(){return"prev"}static get NEXT(){return"next"}static get LAST(){return"last"}static values(){return[this.FIRST,this.PREV,this.NEXT,this.LAST]}};var j=class{#t;get editor(){return this.#t}#e;get document(){return this.#e}#r;get window(){return this.#r}#o;get root(){return this.#o}#s={alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""};constructor(t,e){if(!(t instanceof L)||!(e instanceof Document))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=this.document.defaultView,this.#o=this.document.documentElement}registerElement(t,e,i=void 0){B(this.window.customElements.get(t))||this.window.customElements.define(t,e,i?{extends:i}:void 0)}createElement(t,{attributes:e={},html:i=""}={}){let n=this.document.createElement(t);return n.innerHTML=i,Object.entries(e).forEach(([l,c])=>c&&n.setAttribute(l,`${c}`)),n}insert(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getSelectedEditable();if(e instanceof HTMLSlotElement&&this.editor.tags.allowed(e.parentElement,t))this.insertBefore(t,e);else if(e){let i=this.closest(e,t);i&&this.insertAfter(t,i),e.hasAttribute("data-deletable")&&!e.textContent.trim()&&e.parentElement.removeChild(e)}else if(this.editor.tags.allowed(this.editor.root,t))this.insertLastChild(t,this.editor.root);else throw new TypeError("Invalid argument")}insertText(t){let e=this.getSelectedEditable();if(e){let i=this.getRange();i.deleteContents(),i.insertNode(this.createText(t)),i.collapse(),e.normalize()}}format(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.getRange(),i=this.getSelectedEditable();if(!e||e.collapsed||!e.toString().trim()||!i||!this.editor.tags.allowed(i,t))return;e.startContainer instanceof Text&&e.startContainer.parentElement!==i&&e.setStartBefore(e.startContainer.parentElement),e.endContainer instanceof Text&&e.endContainer.parentElement!==i&&e.setEndAfter(e.endContainer.parentElement);let n=e.toString(),l=Array.from(e.cloneContents().childNodes).every(c=>c instanceof Text&&!c.textContent.trim()||c instanceof HTMLElement&&c.localName===t.localName);e.deleteContents(),l?e.insertNode(this.createText(n)):(t.textContent=n,e.insertNode(t)),i.normalize()}createText(t){return this.document.createTextNode(t)}createTable(t=1,e=1){let i=this.createElement(r.TABLE);return this.insertLastChild(this.createTableHeader(1,e),i),this.insertLastChild(this.createTableBody(t,e),i),this.insertLastChild(this.createTableFooter(1,e),i),i}createTableColumnGroup(t=1){let e=this.createElement(r.COLGROUP);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.COL),e);return e}createTableHeader(t=1,e=1){return this.#i(r.THEAD,t,e)}createTableBody(t=1,e=1){return this.#i(r.TBODY,t,e)}createTableFooter(t=1,e=1){return this.#i(r.TFOOT,t,e)}createTableHeaderRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TH),e);return e}createTableRow(t){let e=this.createElement(r.TR);for(let i=0;i<t;i++)this.insertLastChild(this.createElement(r.TD),e);return e}createTableRowAfter(t){if(!(t instanceof HTMLTableRowElement))throw new TypeError("Invalid argument");this.insertAfter(this.createTableRow(t.cells.length),t)}createTableColumnAfter(t){if(!(t instanceof HTMLTableColElement)||t.localName!==r.COL)throw new TypeError("Invalid argument");let e=t.parentElement,i=e.parentElement,n=Array.from(e.children).indexOf(t);Array.from(i.rows).forEach(l=>this.insertAfter(this.createElement(l.cells[n].localName),l.cells[n])),this.insertAfter(this.createElement(r.COL),t)}sort(t,e){if(!(t instanceof HTMLElement)||!E.values().includes(e))throw new TypeError("Invalid argument");if(t.parentElement.children.length<=1)return;let i=t.parentElement,n=i.parentElement,l=t.previousElementSibling,c=t.nextElementSibling,u=i.firstElementChild,f=i.lastElementChild,g=t===u,O=t===f,M=t.localName===r.COL,K=Array.from(i.children).indexOf(t);e===E.PREV&&!g&&l.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertBefore(I.cells[K],I.cells[K-1])),this.insertBefore(t,l)):e===E.NEXT&&!O&&c.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertAfter(I.cells[K],I.cells[K+1])),this.insertAfter(t,c)):(e===E.FIRST&&!g||e===E.NEXT&&O)&&u.hasAttribute("data-sortable")?(M&&Array.from(n.rows).forEach(I=>this.insertFirstChild(I.cells[K],I)),this.insertBefore(t,u)):(e===E.LAST&&!O||e===E.PREV&&g)&&f.hasAttribute("data-sortable")&&(M&&Array.from(n.rows).forEach(I=>this.insertLastChild(I.cells[K],I)),this.insertAfter(t,f))}insertBefore(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforebegin",t)}insertAfter(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterend",t)}insertFirstChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("afterbegin",t)}insertLastChild(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");e.insertAdjacentElement("beforeend",t)}delete(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if([r.COL,r.TR].includes(t.localName)&&t.matches(":only-child"))return;if(t.localName===r.COL){let n=Array.from(t.parentElement.children).indexOf(t),l=t.parentElement.parentElement;Array.from(l.rows).forEach(c=>c.removeChild(c.cells[n]))}let e=t.previousElementSibling,i=t.nextElementSibling;t===this.getActiveElement()&&t.blur(),t.parentElement.removeChild(t),e instanceof HTMLElement&&e.hasAttribute("data-focusable")?this.focusEnd(e):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}arbitrary(t){return t===this.editor.root||t?.hasAttribute("data-arbitrary")}contains(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");if(this.editor.root.contains(t))return!0;let e=t.closest(this.editor.root.localName);return e&&!e.parentElement}closest(t,e){if(!(t instanceof HTMLElement)||!this.contains(t.parentElement))throw new TypeError("Invalid argument");let i=t,n=t.parentElement;do if(this.arbitrary(n)&&this.editor.tags.allowed(n,e))return i;while((i=n)&&(n=n.parentElement)&&this.contains(n))}wrap(t,e,i={}){let n;if(t instanceof HTMLElement){if(t.parentElement.localName!==e&&(n=this.closest(t,e))){let l=this.createElement(e,i);this.insertAfter(l,n),this.insertLastChild(t,l)}}else throw new TypeError("Invalid argument")}getActiveElement(){let t=this.document.activeElement;return t&&this.contains(t)?t:void 0}getSelectedElement(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement&&e===i&&this.contains(e))return e}getSelectedElementByName(t){let e=this.getSelectedElement();return e?.localName===t?e:void 0}getSelectedAttributesByName(t){let e=this.getSelectedElementByName(t),i={};return e&&Array.from(e.attributes).forEach(n=>i[n.nodeName]=n.nodeValue),i}getSelectedEditable(){let t=this.getSelection(),e=t.anchorNode instanceof Text?t.anchorNode.parentElement:t.anchorNode,i=t.focusNode instanceof Text?t.focusNode.parentElement:t.focusNode;if(e instanceof HTMLElement&&i instanceof HTMLElement){let n=e.closest("[contenteditable=true]"),l=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===l&&this.contains(n))return n}}getSelection(){return this.window.getSelection()}getRange(){let t=this.getSelection();return t.rangeCount>0?t.getRangeAt(0):void 0}setRange(t){let e=this.getSelection();e.removeAllRanges(),e.addRange(t)}selectContents(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");let e=this.document.createRange();e.selectNodeContents(t),this.setRange(e)}focusEnd(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.focus();let e=this.document.createRange();e.selectNodeContents(t),e.collapse(),this.setRange(e)}removeClass(t,...e){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");t.classList.remove(...e),t.classList.length>0||t.removeAttribute("class")}open({url:t,name:e,call:i,params:n={}}){if(!b(t)||!b(e)||!W(i))throw new TypeError("Invalid argument");let l=this.createElement(r.A,{attributes:{href:t}}),c=new URL(l.href);Object.entries(n).forEach(([f,g])=>c.searchParams.set(f,`${g}`));let u=this.window.open(c.toString(),e,this.#a());this.window.addEventListener("message",f=>{f.origin===c.origin&&f.source===u&&(i(f.data),u.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}#i(t,e,i){let n=this.createElement(t);for(let l=0;l<e;l++)this.insertLastChild(t===r.THEAD?this.createTableHeaderRow(i):this.createTableRow(i),n);return n}#a(){let t=Object.assign({},this.#s,{height:`${this.getHeight()}`,width:`${this.getWidth()}`},this.editor.config.base.browser);return Object.entries(t).filter(([,e])=>!!e).map(([e,i])=>`${e}=${i}`).join(",")}};var A=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}filter(t){throw new Error("Not implemented")}};var V=class{#t=new Set;add(t){if(!(t instanceof A))throw new TypeError("Invalid argument");this.#t.add(t)}filter(t){if(!(t instanceof HTMLElement))throw new TypeError("Invalid argument");this.#t.forEach(e=>{t.normalize(),e.filter(t)})}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var F=class{name;group;children;attributes;alignable;arbitrary;deletable;editable;empty;focusable;navigable;slotable;sortable;enter;constructor({name:t,group:e,...i}={}){if(!b(t)||!b(e)||!_e(i.children)||!_e(i.attributes)||!S(i.enter))throw new TypeError("Invalid argument");this.name=t,this.group=e,this.children=i.children||[],this.attributes=i.attributes||[],this.arbitrary=i.arbitrary===!0,this.alignable=i.alignable===!0,this.deletable=i.deletable===!0,this.editable=i.editable===!0,this.empty=i.empty===!0,this.focusable=i.focusable===!0,this.navigable=i.navigable===!0,this.slotable=i.slotable===!0,this.sortable=i.sortable===!0,this.enter=i.enter}};var d=class{#t;get editor(){return this.#t}static get name(){throw new Error("Missing name")}static get dependencies(){return[]}static get config(){return{}}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}init(){throw new Error("Not implemented")}_(t){return this.editor.translate(t)}_i18n(t){t[this.editor.config.base.lang]&&(this.editor.i18n=t[this.editor.config.base.lang])}_tag(t){this.editor.tags.set(new F(t))}_command(t){this.editor.commands.set(new T(this.editor,this.constructor.name,t))}_toolbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.toolbar)}_formatbar(t,e=void 0,i=void 0){let n=this._(t),l=this._("Alt"),c=this._("Shift"),u=n+(e?` [${l} + ${c} + ${e}]`:"");this.editor.dom.insertLastChild(this.#e(n,u,e,i),this.editor.formatbar)}_focusbar(t,e=void 0){let i=this._(t);this.editor.dom.insertLastChild(this.#e(i,i,void 0,e),this.editor.focusbar)}#e(t,e,i=void 0,n=void 0){if(!b(t)||!b(e)||!S(i))throw new TypeError("Invalid argument");return this.editor.dom.createElement(r.BUTTON,{attributes:{type:"button",title:e,"data-command":n||this.constructor.name,"data-key":i},html:t})}};var $=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t)}set(t){if(!(t instanceof d))throw new TypeError("Invalid argument");this.#t.set(t.constructor.name,t)}init(){this.#t.forEach(t=>t.init())}freeze(){this.#t.forEach(t=>Object.freeze(t)),Object.freeze(this.#t),Object.freeze(this)}};var Q=class{#t=new Map;constructor(t=[]){t.forEach(e=>this.set(e))}get(t){return this.#t.get(t instanceof HTMLElement?t.localName:t)}set(t){if(!(t instanceof F))throw new TypeError("Invalid argument");this.#t.set(t.name,t)}allowed(t,e,i=!1){let n=i?e:this.get(e)?.group;return!!this.get(t)?.children.includes(n)}freeze(){this.#t.forEach(t=>{Object.freeze(t.children),Object.freeze(t.attributes),Object.freeze(t)}),Object.freeze(this.#t),Object.freeze(this)}};var L=class{#t;get orig(){return this.#t}#e={};get config(){return this.#e}#r;get dom(){return this.#r}#o;get element(){return this.#o}#s;get toolbar(){return this.#s}#i;get toolbarDispatcher(){return this.#i}#a;get formatbar(){return this.#a}#d;get formatbarDispatcher(){return this.#d}#m;get focusbar(){return this.#m}#l;get focusbarDispatcher(){return this.#l}#c;get root(){return this.#c}#h;get rootDispatcher(){return this.#h}#n={};get i18n(){return this.#n}set i18n(t){this.#n={...this.#n,...t||{}}}#u=new Q;get tags(){return this.#u}#f=new V;get filters(){return this.#f}#p=new q;get dialogs(){return this.#p}#g=new z;get commands(){return this.#g}#E=new $;get plugins(){return this.#E}static get defaultConfig(){return{}}constructor(t,e={}){if(!(t instanceof HTMLElement)||!(e instanceof Object))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=new j(this,this.orig.ownerDocument),this.#o=this.dom.createElement(r.EDITOR),this.#s=this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}}),this.dom.insertLastChild(this.toolbar,this.element),this.#i=new v(this.toolbar),this.#a=this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}}),this.formatbar.hidden=!0,this.dom.insertLastChild(this.formatbar,this.element),this.#d=new v(this.formatbar),this.#m=this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}}),this.focusbar.hidden=!0,this.dom.insertLastChild(this.focusbar,this.element),this.#l=new v(this.focusbar),this.#c=this.dom.createElement(r.ROOT),this.dom.insertLastChild(this.root,this.element),this.#h=new v(this.root)}init(){let t=this.config;this.#e={};let e=this.constructor.defaultConfig.base?.plugins||[],i=e;if(Array.isArray(t.base?.plugins)&&t.base.plugins.length>0){let c=t.base.plugins;t.base?.pluginsDisabled?i=i.filter(u=>!c.includes(u.name)):(i=[],c.forEach(u=>{let f=e.find(g=>g.name===u);f&&i.push(f)}))}let n=new Set,l=c=>{c.dependencies?.forEach(l),n.add(c)};i.map(l),n.forEach(c=>{Object.entries(c.config).forEach(([u,f])=>{this.config[c.name]??={},this.config[c.name][u]=t[c.name]?.[u]||this.constructor.defaultConfig[c.name]?.[u]||f}),this.plugins.set(new c(this))}),this.config.base.lang&&(this.element.lang=this.config.base.lang),this.plugins.init(),this.toolbarDispatcher.dispatch("init"),this.formatbarDispatcher.dispatch("init"),this.focusbarDispatcher.dispatch("init"),this.rootDispatcher.dispatch("init")}freeze(){Object.freeze(this.config),Object.freeze(this.i18n),this.tags.freeze(),this.filters.freeze(),this.dialogs.freeze(),this.commands.freeze(),this.plugins.freeze()}load(){this.orig instanceof HTMLTextAreaElement?(this.orig.form.addEventListener("submit",()=>this.save()),this.setHtml(this.orig.value.replace("/ /g"," "))):this.setHtml(this.orig.innerHTML),this.dom.insertAfter(this.element,this.orig),this.orig.hidden=!0,this.rootDispatcher.dispatch("load")}destroy(){this.element.parentElement.removeChild(this.element),this.orig.hidden=!1,this.rootDispatcher.dispatch("destroy")}getHtml(){let t=this.dom.createElement(this.root.localName,{html:this.root.innerHTML});return this.filters.filter(t),this.rootDispatcher.dispatch("gethtml",t),t.innerHTML}setHtml(t){let e=this.dom.createElement(this.root.localName,{html:t});this.rootDispatcher.dispatch("sethtml",e),this.filters.filter(e),this.root.innerHTML=e.innerHTML}save(){this.orig instanceof HTMLTextAreaElement?this.orig.value=this.getHtml():this.orig.innerHTML=this.getHtml(),this.rootDispatcher.dispatch("save")}translate(t){return this.i18n[t]||t}url(t){let e=this.dom.window.origin||this.dom.window.location.origin,i=this.dom.createElement(r.A,{attributes:{href:t}});return e===i.origin?i.pathname:i.href}static create(t,e={}){let i=new this(t,e);return i.init(),i.freeze(),i.load(),i}};var Y=class{#t;get editor(){return this.#t}#e;get form(){return this.#e}#r;constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t,this.#e=this.editor.dom.createElement(r.FORM,{attributes:{method:"dialog"}}),this.addFieldset().#o().#s()}addFieldset(){let t=this.editor.dom.createElement(r.FIELDSET);return this.#r?this.editor.dom.insertAfter(t,this.#r):this.editor.dom.insertFirstChild(t,this.#e),this.#r=t,this}addLegend(t){if(!b(t))throw new TypeError("Invalid argument");return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LEGEND,{html:t}),this.#r),this}addTextInput(t,e,i={}){return this.addInput(t,e,i,"text")}addNumberInput(t,e,i={}){return this.addInput(t,e,i,"number")}addInput(t,e,i={},n="text"){if(!b(t)||!b(e)||!b(n))throw new TypeError("Invalid argument");Object.assign(i,{id:`editor-${t}`,name:t,type:n});let l=this.editor.dom.createElement(r.DIV);return this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LABEL,{attributes:{for:i.id},html:e}),l),this.editor.dom.insertLastChild(this.editor.dom.createElement(r.INPUT,{attributes:i}),l),i.required&&l.setAttribute("data-required",""),this.editor.dom.insertLastChild(l,this.#r),this}#o(){let t=this.#i("Cancel"),e=this.editor.dom.createElement(r.BUTTON,{attributes:{type:"reset"},html:t});return this.editor.dom.insertLastChild(e,this.#e),this}#s(){let t=this.editor.dom.createElement(r.BUTTON,{html:this.#i("Save")});return this.editor.dom.insertLastChild(t,this.#e),this}#i(t){return this.editor.translate(t)}};var p=class{#t;get editor(){return this.#t}#e;get name(){return this.#e}#r;get browserUrl(){return this.#r}#o;get formCreator(){return this.#o}constructor(t,e,i=void 0){if(!(t instanceof L)||!b(e)||!S(i))throw new TypeError("Invalid argument");this.#t=t,this.#e=e,this.#r=i}open(t,e={}){this.browserUrl?this.#s(t,e):this.#i(t,e)}_(t){return this.editor.translate(t)}_prepareForm(){throw new Error("Not implemented")}#s(t,e={}){this.editor.dom.open({url:this.browserUrl,name:this.name,call:t,params:e})}#i(t,e={}){let i=this.editor.dom.getRange();this.#a();let n=this.editor.dom.createElement(r.DIALOG);n.addEventListener("click",c=>c.target===n&&n.close()),n.addEventListener("close",()=>{i&&this.editor.dom.setRange(i),n.returnValue&&t(JSON.parse(n.returnValue)),this.#a()}),this.editor.dom.insertLastChild(n,this.editor.element),this.#o=new Y(this.editor),this._prepareForm();let l=this.formCreator.form;l.addEventListener("submit",()=>n.close(JSON.stringify(Object.fromEntries(new FormData(l))))),l.addEventListener("reset",()=>n.close()),new FormData(l).forEach((c,u)=>B(e[u])&&(l.elements[u].value=e[u])),this.editor.dom.insertLastChild(l,n),n.showModal()}#a(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(t=>{t.parentElement.removeChild(t)})}};var Z=class extends p{constructor(t){super(t,D.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var x=class{static get NONE(){return"none"}static get LEFT(){return"left"}static get CENTER(){return"center"}static get RIGHT(){return"right"}static values(){return[this.NONE,this.LEFT,this.CENTER,this.RIGHT]}};var X=class extends T{#t;constructor(t,e){if(!x.values().includes(e))throw new TypeError("Invalid argument");super(t,"align-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-alignable")&&(this.editor.dom.removeClass(t,...x.values()),this.#t!==x.NONE&&t.classList.add(this.#t))}};var a=class{static get A(){return"a"}static get ARROWDOWN(){return"ArrowDown"}static get ARROWLEFT(){return"ArrowLeft"}static get ARROWRIGHT(){return"ArrowRight"}static get ARROWUP(){return"ArrowUp"}static get B(){return"b"}static get BACKSPACE(){return"Backspace"}static get C(){return"c"}static get D(){return"d"}static get DEL(){return"Delete"}static get E(){return"e"}static get END(){return"End"}static get ENTER(){return"Enter"}static get F(){return"f"}static get G(){return"g"}static get HOME(){return"Home"}static get I(){return"i"}static get J(){return"j"}static get K(){return"k"}static get L(){return"l"}static get M(){return"m"}static get O(){return"o"}static get Q(){return"q"}static get R(){return"r"}static get S(){return"s"}static get SPACE(){return" "}static get T(){return"t"}static get TAB(){return"Tab"}static get U(){return"u"}static get V(){return"v"}static get W(){return"w"}static get X(){return"x"}static get Y(){return"y"}static get Z(){return"z"}static isEventFor(t,e,{alt:i=!1,ctrl:n=!1,shift:l=!1}={}){return(Array.isArray(e)&&e.includes(t.key)||t.key===e)&&t.altKey===i&&t.ctrlKey===n&&t.shiftKey===l}};var h=class{#t;get editor(){return this.#t}constructor(t){if(!(t instanceof L))throw new TypeError("Invalid argument");this.#t=t}handleEvent(t){W(this[t.type])&&this[t.type](t)}_(t){return this.editor.translate(t)}};var J=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-alignable")&&t.addEventListener("keydown",this)}keydown(t){let e={[a.ARROWUP]:x.NONE,[a.ARROWLEFT]:x.LEFT,[a.ARROWDOWN]:x.CENTER,[a.ARROWRIGHT]:x.RIGHT};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.dom.removeClass(t.target,...x.values()),e[t.key]!==x.NONE&&t.target.classList.add(e[t.key]))}};var tt=class extends A{filter(t){let e=this.editor.tags.get(t),i=this.editor.tags.allowed(t,r.P),n=e.editable||e.group===o.FORMAT,l=[],c=(u=null)=>{if(i&&l.length>0){let f=this.editor.dom.createElement(r.P,{html:l.join(" ")});u?this.editor.dom.insertBefore(f,u):this.editor.dom.insertLastChild(f,t),l=[]}};Array.from(t.childNodes).forEach(u=>{let f=u.textContent.trim();if(u instanceof HTMLElement){let g=this.#t(u),O=this.editor.tags.get(g);if(O&&this.editor.tags.allowed(t,g))c(g),this.#e(g,O);else if(O&&O.group===o.FORMAT&&i){let M=this.#e(g,O);M&&(l.push(M.outerHTML),t.removeChild(M))}else!n&&f&&i?(l.push(f),t.removeChild(g)):n&&f?t.replaceChild(this.editor.dom.createText(f),g):t.removeChild(g)}else u instanceof Text?(!n&&f&&i&&l.push(f),(!n||!f)&&t.removeChild(u)):u instanceof Node&&t.removeChild(u)}),c()}#t(t){let e=this.editor.config.base.filter[t.localName];if(!e)return t;let i=this.editor.dom.createElement(e,{html:t.innerHTML});return t.parentElement.replaceChild(i,t),i}#e(t,e){if(Array.from(t.attributes).forEach(i=>!e.attributes.includes(i.name)&&t.removeAttribute(i.name)),t.hasChildNodes()&&this.editor.filters.filter(t),t.hasChildNodes()||e.empty)return t;t.parentElement?.removeChild(t)}};var et=class extends T{constructor(t){super(t,"delete")}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-deletable")&&this.editor.dom.delete(t)}};var rt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-deletable")&&t.addEventListener("keydown",this)}keydown(t){t.target===t.currentTarget&&a.isEventFor(t,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation())}};var it=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.contentEditable==="true"?t.addEventListener("keydown",this):t.parentElement.contentEditable==="true"&&t.addEventListener("dblclick",this)}keydown(t){if(a.isEventFor(t,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(t.target,r.BR))t.preventDefault(),t.stopPropagation();else if(a.isEventFor(t,a.ENTER)){t.preventDefault(),t.stopPropagation();let e=this.editor.tags.get(t.target)?.enter;if(e){if(t.target.textContent.trim()||!t.target.hasAttribute("data-deletable")){let i=this.editor.dom.closest(t.target,e);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(e),i)}else if(!(t.target instanceof HTMLParagraphElement)){let i=this.editor.dom.closest(t.target,r.P);i&&this.editor.dom.insertAfter(this.editor.dom.createElement(r.P),i),t.target.parentElement.removeChild(t.target)}}}else a.isEventFor(t,a.BACKSPACE)&&!t.target.textContent&&t.target.hasAttribute("data-deletable")?(this.editor.dom.delete(t.target),t.preventDefault(),t.stopPropagation()):/^[A-Z]$/.test(t.key)&&a.isEventFor(t,t.key,{alt:!0,shift:!0})&&(t.preventDefault(),t.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${t.key.toLowerCase()}]`)?.click())}dblclick({target:t}){this.editor.dom.selectContents(t),this.editor.commands.findByTagName(t.localName)?.execute()}};var ot=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-focusable")&&t.focus()}};var _=class extends h{insertbutton({target:t,detail:{element:e}}){e.getAttribute("data-command")&&e.addEventListener("click",this),e.tabIndex=e===t.firstElementChild?0:-1,e.addEventListener("keydown",this)}click({target:t}){this.editor.commands.execute(t.getAttribute("data-command"))}keydown(t){if(a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.HOME,a.END])){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWLEFT&&!c?e.focus():t.key===a.ARROWRIGHT&&!u?i.focus():t.key===a.HOME||t.key===a.ARROWRIGHT&&u?n.focus():(t.key===a.END||t.key===a.ARROWLEFT&&c)&&l.focus(),t.preventDefault(),t.stopPropagation()}}_show(t,e){if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new TypeError("Invalid argument");t.hidden=!1;let{x:i,y:n}=e.getBoundingClientRect(),{x:l,y:c}=this.editor.root.getBoundingClientRect(),u=i-l+t.clientWidth-this.editor.root.clientWidth,f=n-c-e.scrollTop+this.editor.root.offsetTop-t.clientHeight,g=t.clientWidth<this.editor.root.clientWidth?i-l:0;g>0&&u>0&&(g=g>u?(g-u)/2:0),t.style.left=`${g}px`,t.style.top=`${f}px`}_hide(t){t.hidden=!0,t.removeAttribute("style")}};var st=class extends _{constructor(t){super(t),this.editor.focusbar.addEventListener("insertbutton",this),this.editor.root.addEventListener("focusin",this),this.editor.root.addEventListener("focusout",this),this.editor.dom.document.addEventListener("selectionchange",this)}insertbutton(t){super.insertbutton(t),t.detail.element.getAttribute("data-command")&&t.detail.element.addEventListener("mousedown",this)}mousedown(t){t.preventDefault(),t.stopPropagation()}focusin({target:t}){t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}focusout(){this.#e()}selectionchange(){let t=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!t?this.#e():t instanceof HTMLElement&&t.hasAttribute("data-focusable")&&this.#t(t)}#t(t){!this.editor.focusbar.children.length||(Object.keys(t.dataset).forEach(e=>this.editor.focusbar.dataset[e]=t.dataset[e]),this.editor.focusbar.dataset.tag=t.localName,this._show(this.editor.focusbar,t))}#e(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(t=>delete this.editor.focusbar.dataset[t])}};var at=class extends _{constructor(t){super(t),this.editor.formatbar.addEventListener("insertbutton",this),this.editor.dom.document.addEventListener("selectionchange",this)}selectionchange(){let t=this.editor.dom.getSelectedEditable();t&&!this.editor.dom.getSelection().isCollapsed&&this.editor.tags.allowed(t,o.FORMAT,!0)?this._show(this.editor.formatbar,t):this._hide(this.editor.formatbar)}};var nt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-navigable")&&(t.tabIndex=0,t.addEventListener("keydown",this))}keydown(t){if(t.target===t.currentTarget&&a.isEventFor(t,[a.ARROWUP,a.ARROWDOWN,a.HOME,a.END])&&this.#t(t.target)){let e=t.target.previousElementSibling,i=t.target.nextElementSibling,n=t.target.parentElement.firstElementChild,l=t.target.parentElement.lastElementChild,c=t.target===n,u=t.target===l;t.key===a.ARROWUP&&!c&&e.hasAttribute("data-navigable")?e.focus():t.key===a.ARROWDOWN&&!u&&i.hasAttribute("data-navigable")?i.focus():(t.key===a.HOME||t.key===a.ARROWDOWN&&u)&&n.hasAttribute("data-navigable")?n.focus():(t.key===a.END||t.key===a.ARROWUP&&c)&&l.hasAttribute("data-navigable")&&l.focus(),t.preventDefault(),t.stopPropagation()}}#t(t){if(t.contentEditable!=="true")return!0;let e=this.editor.dom.getSelection(),i=this.editor.dom.getSelectedEditable(),n=this.editor.dom.getSelectedElement();return e.isCollapsed&&e.anchorOffset===0&&[i,t.firstChild].includes(n)}};var dt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t instanceof HTMLSlotElement?t.addEventListener("keydown",this):t.hasAttribute("data-slotable")&&!t.querySelector(":scope > "+r.SLOT)&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.SLOT),t)}keydown(t){a.isEventFor(t,a.BACKSPACE)&&t.target.matches(":only-child")?this.editor.dom.delete(t.target.parentElement):!a.isEventFor(t,a.TAB)&&!a.isEventFor(t,a.TAB,{shift:!0})&&(t.preventDefault(),t.stopPropagation())}};var mt=class extends T{#t;constructor(t,e){if(!E.values().includes(e))throw new TypeError("Invalid argument");super(t,"sort-"+e),this.#t=e}execute(){let t=this.editor.dom.getActiveElement();t?.hasAttribute("data-sortable")&&this.editor.dom.sort(t,this.#t)}};var lt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){t.hasAttribute("data-sortable")&&(t.addEventListener("keydown",this),t.addEventListener("pointerdown",this),t.addEventListener("pointermove",this),t.addEventListener("pointerup",this))}keydown(t){let e={[a.HOME]:E.FIRST,[a.ARROWUP]:E.PREV,[a.ARROWDOWN]:E.NEXT,[a.END]:E.LAST};t.target===t.currentTarget&&a.isEventFor(t,Object.keys(e),{ctrl:!0})&&(this.editor.dom.sort(t.target,e[t.key]),t.preventDefault(),t.stopPropagation())}pointerdown(t){let e=t.target.closest("[data-sortable]");e&&this.editor.dom.contains(e)&&(e.setAttribute("data-sort",""),e.setPointerCapture(t.pointerId))}pointermove(t){let e=t.target.closest("[data-sortable][data-sort]"),i=this.editor.dom.document.elementFromPoint(t.x,t.y);this.#t(),e&&this.editor.dom.contains(e)&&this.#e(e,i)&&i.setAttribute("data-sortover","")}pointerup(t){let e=t.target.closest("[data-sortable][data-sort]");if(e&&this.editor.dom.contains(e)){let i=this.editor.dom.document.elementFromPoint(t.x,t.y),n=i.parentElement;if(this.#t(),e.removeAttribute("data-sort"),e.releasePointerCapture(t.pointerId),this.#e(e,i)){if(e.localName===r.COL&&n===e.parentElement){let l=Array.from(n.children).indexOf(e),c=Array.from(n.children).indexOf(i),u=n.parentElement;Array.from(u.rows).forEach(f=>this.editor.dom.insertBefore(f.cells[l],f.cells[c]))}this.editor.dom.insertBefore(e,i)}}}#t(){this.editor.root.querySelectorAll("[data-sortover]").forEach(t=>t.removeAttribute("data-sortover"))}#e(t,e){return t instanceof HTMLElement&&e instanceof HTMLElement&&this.editor.dom.contains(e)&&![this.editor.root,t].includes(e)&&e.hasAttribute("data-sortable")&&(t.parentElement===e.parentElement||this.editor.dom.arbitrary(t.parentElement)&&this.editor.dom.arbitrary(e.parentElement))&&this.editor.tags.allowed(e.parentElement,t)}};var ct=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insert",this)}insert({detail:{element:t}}){let e=this.editor.tags.get(t);e&&(e.editable&&(t.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{e[i]&&(t.dataset[i]="")}))}};var ht=class extends _{constructor(t){super(t),this.editor.toolbar.addEventListener("insertbutton",this)}};var m=class extends d{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._tag({name:r.ROOT,group:o.ROOT,children:[o.AUDIO,o.BLOCK,o.CONTAINER,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO]}),this._tag({name:r.SLOT,group:o.SLOT,editable:!0,focusable:!0,navigable:!0,sortable:!0}),new ct(this.editor),new ht(this.editor),new at(this.editor),new st(this.editor),new it(this.editor),new rt(this.editor),new nt(this.editor),new lt(this.editor),new J(this.editor),new ot(this.editor),new dt(this.editor),this.editor.filters.add(new tt(this.editor)),this.#t(),this.#e(),this.#r()}#t(){let t={[x.NONE]:"No alignment",[x.LEFT]:"Align left",[x.CENTER]:"Align center",[x.RIGHT]:"Align right"};Object.entries(t).forEach(([e,i])=>{let n=new X(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}#e(){let t={[E.FIRST]:"Sort to the beginning",[E.PREV]:"Sort before previous element",[E.NEXT]:"Sort after next element",[E.LAST]:"Sort to the end"};Object.entries(t).forEach(([e,i])=>{let n=new mt(this.editor,e);this.editor.commands.set(n),this._focusbar(i,n.name)})}#r(){this.editor.commands.set(new et(this.editor)),this._focusbar("Delete","delete")}};var D=class extends d{static get name(){return"abbreviation"}static get dependencies(){return[m]}init(){this._tag({name:r.ABBR,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Z(this.editor)),this._command(r.ABBR),this._formatbar("Abbreviation",a.A)}};var ut=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Audio")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to audio"),required:"required"}).addTextInput("id",this._("ID"))}};var ft=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.AUDIO)).forEach(e=>this.#t(e))}insertaudio({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:H.name}})):t.parentElement.removeChild(t)}};var pt=class extends A{filter(t){t.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var gt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertfigure",this)}insertfigure({detail:{element:t}}){t.querySelector(":scope > "+r.FIGCAPTION)||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.FIGCAPTION),t)}};var R=class extends d{static get name(){return"figure"}static get dependencies(){return[m]}init(){this._tag({name:r.FIGURE,group:o.FIGURE,children:[o.AUDIO,o.CAPTION,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.TABLE,o.VIDEO],attributes:["class"],alignable:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag({name:r.FIGCAPTION,group:o.CAPTION,children:[o.FORMAT],editable:!0,navigable:!0,enter:r.P}),new gt(this.editor),this.editor.filters.add(new pt(this.editor))}};var H=class extends d{static get name(){return"audio"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.AUDIO,group:o.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new ft(this.editor),this.editor.dialogs.set(new ut(this.editor,this.constructor.name,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar("Audio")}};var Et=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var bt=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(t){this.shadowRoot.innerHTML=t}constructor(){super(),this.attachShadow({mode:"open"})}};var Tt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.BLOCK)).forEach(e=>e.id||e.parentElement.removeChild(e))}async insertappblock({detail:{element:t}}){if(!t.id){t.parentElement.removeChild(t);return}if(!this.editor.config.block.api)return;let e=this.editor.config.block.api.replace("{id}",t.id),i=await fetch(e,{mode:"no-cors"});if(!i.ok)return;let n="";this.editor.config.block.css&&(n=this.editor.config.block.css.split(",").map(c=>`<link rel="stylesheet" href="${c}">`).join(""));let l=await i.text();t.content=n+l}};var Lt=class extends d{static get name(){return"block"}static get dependencies(){return[m]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this.editor.dom.registerElement(r.BLOCK,bt),this._tag({name:r.BLOCK,group:o.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new Tt(this.editor),this.editor.dialogs.set(new Et(this.editor,this.constructor.name,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar("Block")}};var At=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.querySelector(":scope > "+r.BLOCKQUOTE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.BLOCKQUOTE),t),t.parentElement.removeChild(t))}};var xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:C.name}})}deleteblockquote({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(C.name)&&t.parentElement.removeChild(t)}};var Rt=class extends A{filter(t){if(t instanceof HTMLPreElement){t.outerHTML=t.outerHTML.replace(/(<br\s*\/?>)/gi,`
|
|
2
|
+
`);return}t.innerHTML=t.innerHTML.replace(/^\s*(<br\s*\/?>\s*)+/gi,"").replace(/\s*(<br\s*\/?>\s*)+$/gi,""),t instanceof HTMLParagraphElement?t.outerHTML=t.outerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"</p><p>"):t.innerHTML=t.innerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"<br>")}};var w=class extends d{static get name(){return"break"}static get dependencies(){return[m]}init(){this._tag({name:r.BR,group:o.BREAK,empty:!0}),this.editor.filters.add(new Rt(this.editor))}};var C=class extends d{static get name(){return"blockquote"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.BLOCKQUOTE,group:o.QUOTE,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new xt(this.editor),this._command(r.BLOCKQUOTE),this._toolbar("Blockquote"),this.editor.filters.add(new At(this.editor))}};var wt=class extends d{static get name(){return"bold"}static get dependencies(){return[m]}init(){this._tag({name:r.B,group:o.FORMAT}),this._command(r.B),this._formatbar("bold",a.B)}};var Ot=class extends d{static get name(){return"cite"}static get dependencies(){return[m]}init(){this._tag({name:r.CITE,group:o.FORMAT}),this._command(r.CITE),this._formatbar("Citation",a.Z)}};var It=class extends d{static get name(){return"code"}static get dependencies(){return[m]}init(){this._tag({name:r.CODE,group:o.FORMAT}),this._command(r.CODE),this._formatbar("Code",a.C)}};var yt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Ct=class extends d{static get name(){return"data"}static get dependencies(){return[m]}init(){this._tag({name:r.DATA,group:o.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new yt(this.editor,this.constructor.name)),this._command(r.DATA),this._formatbar("Data",a.J)}};var Nt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var _t=class extends d{static get name(){return"definition"}static get dependencies(){return[m]}init(){this._tag({name:r.DFN,group:o.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Nt(this.editor,this.constructor.name)),this._command(r.DFN),this._formatbar("Definition",a.D)}};var Mt=class extends d{static get name(){return"deletion"}static get dependencies(){return[m]}init(){this._tag({name:r.DEL,group:o.FORMAT}),this._command(r.DEL),this._formatbar("Text Deletion",a.G)}};var St=class extends A{filter(t){t.querySelectorAll(`${r.SUMMARY}:not(:first-child)`).forEach(e=>e.parentElement.removeChild(e)),t.querySelectorAll(`${r.SUMMARY}:only-child`).forEach(e=>e.parentElement.removeChild(e))}};var vt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails({detail:{element:t}}){t.open=!0,t.querySelector(`:scope > ${r.SUMMARY}:first-child`)||this.editor.dom.insertFirstChild(this.editor.dom.createElement(r.SUMMARY),t)}insertsummary({detail:{element:t}}){this.#t(t),t.addEventListener("click",this),t.addEventListener("blur",this),t.addEventListener("keydown",this)}click(t){t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0}blur({target:t}){this.#t(t)}keydown(t){a.isEventFor(t,a.SPACE)?(t.preventDefault(),t.stopPropagation(),this.editor.dom.insertText(" ")):a.isEventFor(t,a.ENTER)&&(t.preventDefault(),t.stopPropagation(),t.target.parentElement.open=!0)}#t(t){t.textContent.trim()?t.querySelectorAll(r.BR+":not(:last-child)").forEach(e=>e.parentElement.removeChild(e)):t.textContent=this._("Details"),t.lastElementChild instanceof HTMLBRElement||this.editor.dom.insertLastChild(this.editor.dom.createElement(r.BR),t)}};var Bt=class extends d{static get name(){return"details"}static get dependencies(){return[m]}init(){this._tag({name:r.DETAILS,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.SUMMARY,o.TABLE,o.VIDEO],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this._tag({name:r.SUMMARY,group:o.SUMMARY,editable:!0,navigable:!0,enter:r.P}),new vt(this.editor),this._command(r.DETAILS),this._toolbar("Details"),this.editor.filters.add(new St(this.editor))}};var Ft=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var Dt=class extends d{static get name(){return"division"}static get dependencies(){return[m]}init(){this._tag({name:r.DIV,group:o.CONTAINER,children:[o.AUDIO,o.BLOCK,o.FIGURE,o.IFRAME,o.IMAGE,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new Ft(this.editor,this.constructor.name)),this._command(r.DIV),this._toolbar("Division")}};var Ht=class extends d{static get name(){return"emphasis"}static get dependencies(){return[m]}init(){this._tag({name:r.EM,group:o.FORMAT}),this._command(r.EM),this._formatbar("emphasized",a.E)}};var Pt=class extends d{static get name(){return"heading"}static get dependencies(){return[m]}init(){this._tag({name:r.H2,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H2),this._toolbar("Heading")}};var Ut=class extends d{static get name(){return"horizontalrule"}static get dependencies(){return[m]}init(){this._tag({name:r.HR,group:o.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar("Horizontal Rule")}};var ve={"CSS class":"CSS-Klasse",Height:"H\xF6he",ID:"ID","Insert CSS class":"CSS-Klasse eingeben",URL:"URL",Width:"Breite",Abbreviation:"Abk\xFCrzung","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Audio:"Audio","Insert URL to audio":"URL zur Audiodatei eingeben","Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig",Alt:"Alt",Cancel:"Abbrechen",Delete:"L\xF6schen","No alignment":"Keine Ausrichtung",Save:"Speichern",Shift:"Umschalt","Sort after next element":"Hinter das n\xE4chste Element sortieren","Sort before previous element":"Vor das vorherige Element sortieren","Sort to the beginning":"An den Anfang sortieren","Sort to the end":"Ans Ende sortieren",Block:"Block",Blockquote:"Blockzitat",bold:"fett",Citation:"Zitatquelle",Code:"Quelltext",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff","Text Deletion":"Textl\xF6schung",Details:"Details",Division:"Division",emphasized:"betont",Heading:"\xDCberschrift","Horizontal Rule":"Horizontale Linie",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben","Alternative text":"Alternativtext",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist","Text Insertion":"Texteinf\xFCgung",italic:"kursiv","User Input":"Benutzereingabe","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",mark:"markiert","Ordered List":"Geordnete Liste",Paragraph:"Absatz","Preformatted Text":"Vorformatierter Text",Quote:"Zitat","Sample Output":"Beispielausgabe",Section:"Sektion",small:"klein",strikethrough:"durchgestrichen","strongly emphasized":"stark betont",Subheading:"Unter\xFCberschrift",subscript:"tiefgestellt",superscript:"hochgestellt","Add column":"Spalte hinzuf\xFCgen","Add row":"Zeile hinzuf\xFCgen",Columns:"Spalten",Rows:"Zeilen",Table:"Tabelle","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Time:"Zeit",underline:"unterstrichen","Unordered List":"Ungeordnete Liste",Variable:"Variable","Insert URL to video":"URL zur Videodatei eingeben",Video:"Video"};var Gt=class extends d{static get name(){return"i18n"}static get dependencies(){return[m]}init(){this._i18n({de:ve})}};var kt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Iframe")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to embedded page"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Kt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IFRAME)).forEach(e=>this.#t(e))}insertiframe({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.allowFullscreen=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:P.name}})):t.parentElement.removeChild(t)}};var P=class extends d{static get name(){return"iframe"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IFRAME,group:o.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new Kt(this.editor),this.editor.dialogs.set(new kt(this.editor,this.constructor.name,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar("Iframe")}};var Wt=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Image")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to image"),required:"required"}).addTextInput("alt",this._("Alternative text"),{placeholder:this._("Text shown when media element is not available")}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var zt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.IMG)).forEach(e=>this.#t(e))}insertimg({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:U.name}})):t.parentElement.removeChild(t)}};var U=class extends d{static get name(){return"image"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.IMG,group:o.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new zt(this.editor),this.editor.dialogs.set(new Wt(this.editor,this.constructor.name,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar("Image")}};var qt=class extends d{static get name(){return"insertion"}static get dependencies(){return[m]}init(){this._tag({name:r.INS,group:o.FORMAT}),this._command(r.INS),this._formatbar("Text Insertion",a.F)}};var jt=class extends d{static get name(){return"italic"}static get dependencies(){return[m]}init(){this._tag({name:r.I,group:o.FORMAT}),this._command(r.I),this._formatbar("italic",a.I)}};var Vt=class extends d{static get name(){return"keyboard"}static get dependencies(){return[m]}init(){this._tag({name:r.KBD,group:o.FORMAT}),this._command(r.KBD),this._formatbar("User Input",a.K)}};var $t=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var Qt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.A)).forEach(e=>this.#t(e))}inserta({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("href");e?t.setAttribute("href",this.editor.url(e)):t.parentElement.replaceChild(this.editor.dom.createText(t.textContent),t)}};var Yt=class extends d{static get name(){return"link"}static get dependencies(){return[m]}init(){this._tag({name:r.A,group:o.FORMAT,attributes:["href"]}),new Qt(this.editor),this.editor.dialogs.set(new $t(this.editor,this.constructor.name)),this._command(r.A),this._formatbar("Link",a.L)}};var Zt=class extends d{static get name(){return"mark"}static get dependencies(){return[m]}init(){this._tag({name:r.MARK,group:o.FORMAT}),this._command(r.MARK),this._formatbar("mark",a.M)}};var Xt=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertli",this),this.editor.root.addEventListener("deleteli",this),this.editor.root.addEventListener("insertol",this),this.editor.root.addEventListener("insertul",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.LI)).forEach(e=>this.#t(e))}insertli({detail:{element:t}}){this.#t(t)}deleteli({detail:{target:t}}){t.children.length===0&&t.parentElement.removeChild(t)}insertol({detail:{element:t}}){this.#e(t)}insertul({detail:{element:t}}){this.#e(t)}#t(t){!(t.parentElement instanceof HTMLOListElement)&&!(t.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(t,r.UL)}#e(t){t.children.length===0&&this.editor.dom.insertLastChild(this.editor.dom.createElement(r.LI),t)}};var G=class extends d{static get name(){return"list"}static get dependencies(){return[m,w]}init(){this._tag({name:r.LI,group:o.LISTITEM,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.LI}),new Xt(this.editor)}};var Jt=class extends d{static get name(){return"orderedlist"}static get dependencies(){return[m,G]}init(){this._tag({name:r.OL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.OL),this._toolbar("Ordered List")}};var te=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.P)).forEach(e=>e.addEventListener("paste",this))}insertp({detail:{element:t}}){t.addEventListener("paste",this)}paste({target:t}){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(t))}};var ee=class extends d{static get name(){return"paragraph"}static get dependencies(){return[m,w]}init(){this._tag({name:r.P,group:o.PARAGRAPH,children:[o.BREAK,o.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),new te(this.editor),this._command(r.P),this._toolbar("Paragraph")}};var re=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.querySelector(":scope > "+r.PRE)&&!t.querySelector(":scope > "+r.FIGCAPTION)&&(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.PRE),t),t.parentElement.removeChild(t))}};var ie=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre({detail:{element:t}}){this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:N.name}})}deletepre({detail:{target:t}}){t.localName===r.FIGURE&&t.classList.contains(N.name)&&t.parentElement.removeChild(t)}};var N=class extends d{static get name(){return"preformat"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.PRE,group:o.PREFORMAT,children:[o.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new ie(this.editor),this._command(r.PRE),this._toolbar("Preformatted Text"),this.editor.filters.add(new re(this.editor))}};var oe=class extends d{static get name(){return"quote"}static get dependencies(){return[m]}init(){this._tag({name:r.Q,group:o.FORMAT}),this._command(r.Q),this._formatbar("Quote",a.Q)}};var se=class extends d{static get name(){return"sample"}static get dependencies(){return[m]}init(){this._tag({name:r.SAMP,group:o.FORMAT}),this._command(r.SAMP),this._formatbar("Sample Output",a.O)}};var ae=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var ne=class extends d{static get name(){return"section"}static get dependencies(){return[m]}init(){this._tag({name:r.SECTION,group:o.CONTAINER,children:[o.AUDIO,o.FIGURE,o.HEADING,o.IFRAME,o.IMAGE,o.LIST,o.PARAGRAPH,o.PREFORMAT,o.QUOTE,o.RULE,o.TABLE,o.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new ae(this.editor,this.constructor.name)),this._command(r.SECTION),this._toolbar("Section")}};var de=class extends d{static get name(){return"small"}static get dependencies(){return[m]}init(){this._tag({name:r.SMALL,group:o.FORMAT}),this._command(r.SMALL),this._formatbar("small",a.W)}};var me=class extends d{static get name(){return"strikethrough"}static get dependencies(){return[m]}init(){this._tag({name:r.S,group:o.FORMAT}),this._command(r.S),this._formatbar("strikethrough",a.R)}};var le=class extends d{static get name(){return"strong"}static get dependencies(){return[m]}init(){this._tag({name:r.STRONG,group:o.FORMAT}),this._command(r.STRONG),this._formatbar("strongly emphasized",a.S)}};var ce=class extends d{static get name(){return"subheading"}static get dependencies(){return[m]}init(){this._tag({name:r.H3,group:o.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H3),this._toolbar("Subheading")}};var he=class extends d{static get name(){return"subscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUB,group:o.FORMAT}),this._command(r.SUB),this._formatbar("subscript",a.X)}};var ue=class extends d{static get name(){return"superscript"}static get dependencies(){return[m]}init(){this._tag({name:r.SUP,group:o.FORMAT}),this._command(r.SUP),this._formatbar("superscript",a.Y)}};var fe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttd({detail:{element:t}}){t.addEventListener("keydown",this)}insertth({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){let e=t.target,i=e.parentElement,n=e.closest(r.TABLE);if(e instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&n instanceof HTMLTableElement&&a.isEventFor(t,[a.ARROWLEFT,a.ARROWRIGHT,a.ARROWUP,a.ARROWDOWN])&&this.#t(e,t.key)){let l=e.cellIndex,c=i.cells.length,u=l===0,f=l===c-1,g=i.rowIndex===0,O=i.rowIndex===n.rows.length-1;t.preventDefault(),t.stopPropagation(),t.key===a.ARROWLEFT&&!u?this.editor.dom.focusEnd(i.cells[l-1]):t.key===a.ARROWLEFT&&g?this.editor.dom.focusEnd(n.rows[n.rows.length-1].cells[c-1]):t.key===a.ARROWLEFT?this.editor.dom.focusEnd(n.rows[i.rowIndex-1].cells[c-1]):t.key===a.ARROWRIGHT&&!f?i.cells[l+1].focus():t.key===a.ARROWRIGHT&&O?n.rows[0].cells[0].focus():t.key===a.ARROWRIGHT?n.rows[i.rowIndex+1].cells[0].focus():t.key===a.ARROWUP&&g?n.rows[n.rows.length-1].cells[l].focus():t.key===a.ARROWUP?n.rows[i.rowIndex-1].cells[l].focus():t.key===a.ARROWDOWN&&O?n.rows[0].cells[l].focus():t.key===a.ARROWDOWN&&n.rows[i.rowIndex+1].cells[l].focus()}}#t(t,e){if([a.ARROWUP,a.ARROWDOWN].includes(e))return!0;let i=this.editor.dom.getSelection(),n=i.anchorNode instanceof HTMLElement?i.anchorNode:t;if(!i.isCollapsed)return!1;if(e===a.ARROWLEFT){let c=t.firstChild;return c instanceof HTMLElement&&(c=c.firstChild),i.anchorOffset===0&&[t,c].includes(n)}let l=t.lastChild;return t.lastChild instanceof HTMLBRElement&&t.lastChild.previousSibling&&(l=t.lastChild.previousSibling),l instanceof HTMLElement&&(l=l.lastChild),i.anchorOffset===n.textContent.length&&[t,l].includes(n)}};var pe=class extends T{constructor(t){super(t,"tablecolumn-add")}execute(){let t=this.editor.dom.getActiveElement();t?.localName===r.COL&&this.editor.dom.createTableColumnAfter(t)}};var ge=class extends h{constructor(t){super(t),this.editor.root.addEventListener("insertcol",this)}insertcol({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){a.isEventFor(t,a.ENTER)?this.editor.dom.createTableColumnAfter(t.target):a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var Ee=class extends T{constructor(t){super(t,y.name,r.TABLE)}_insert({rows:t,cols:e}={}){this.editor.dom.insert(this.editor.dom.createTable(parseInt(t,10)||1,parseInt(e,10)||1))}};var be=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Table")).addNumberInput("rows",this._("Rows"),{min:"1",required:"required",value:"1"}).addNumberInput("cols",this._("Columns"),{min:"1",required:"required",value:"1"})}};var Te=class extends A{filter(t){t instanceof HTMLElement&&t.localName===r.FIGURE&&t.classList.contains(y.name)&&t.querySelector(":scope > "+r.TABLE)&&!t.querySelector(":scope > "+r.FIGCAPTION)?(this.editor.dom.insertBefore(t.querySelector(":scope > "+r.TABLE),t),t.parentElement.removeChild(t)):(t instanceof HTMLTableElement&&t.querySelector(`:scope > ${r.THEAD}, :scope > ${r.TFOOT}`)&&!t.querySelector(":scope > "+r.TBODY)||t instanceof HTMLTableSectionElement&&t.rows.length<=0||t instanceof HTMLTableRowElement&&!t.querySelector(`:scope > ${r.TH}:not(:empty), :scope > ${r.TD}:not(:empty)`))&&t.parentElement.removeChild(t)}};var Le=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttable",this)}inserttable({detail:{element:t}}){if(this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:y.name}}),t.tBodies.length>0&&t.tBodies[0].rows[0]){let e=t.tBodies[0],i=e.rows[0].cells.length;t.querySelector(":scope > "+r.COLGROUP)||this.editor.dom.insertFirstChild(this.editor.dom.createTableColumnGroup(i),t),t.tHead||this.editor.dom.insertBefore(this.editor.dom.createTableHeader(1,i),e),t.tFoot||this.editor.dom.insertLastChild(this.editor.dom.createTableFooter(1,i),t)}}};var Ae=class extends T{constructor(t){super(t,"tablerow-add")}execute(){let t=this.editor.dom.getActiveElement();t instanceof HTMLTableRowElement&&this.editor.dom.createTableRowAfter(t)}};var xe=class extends h{constructor(t){super(t),this.editor.root.addEventListener("inserttr",this)}inserttr({detail:{element:t}}){t.addEventListener("keydown",this)}keydown(t){a.isEventFor(t,a.ENTER)?this.editor.dom.createTableRowAfter(t.target):a.isEventFor(t,a.BACKSPACE)&&this.editor.dom.delete(t.target)}};var y=class extends d{static get name(){return"table"}static get dependencies(){return[m,w,R]}init(){this._tag({name:r.TABLE,group:o.TABLE,children:[o.TABLESECTION],deletable:!0,navigable:!0}),this._tag({name:r.COLGROUP,group:o.COLGROUP,children:[o.COL]}),this._tag({name:r.COL,group:o.COL,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#t(r.THEAD)),this._tag(this.#t(r.TBODY)),this._tag(this.#t(r.TFOOT)),this._tag({name:r.TR,group:o.TABLEROW,children:[o.TABLECELL],deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag(this.#e(r.TH)),this._tag(this.#e(r.TD)),new Le(this.editor),new ge(this.editor),new xe(this.editor),new fe(this.editor),this.editor.filters.add(new Te(this.editor)),this.editor.dialogs.set(new be(this.editor,this.constructor.name)),this.editor.commands.set(new Ee(this.editor)),this.editor.commands.set(new pe(this.editor)),this.editor.commands.set(new Ae(this.editor)),this._toolbar("Table"),this._focusbar("Add column","tablecolumn-add"),this._focusbar("Add row","tablerow-add")}#t(t){return{name:t,group:o.TABLESECTION,children:[o.TABLEROW]}}#e(t){return{name:t,group:o.TABLECELL,children:[o.BREAK,o.FORMAT],editable:!0,empty:!0}}};var Re=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var we=class extends d{static get name(){return"time"}static get dependencies(){return[m]}init(){this._tag({name:r.TIME,group:o.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new Re(this.editor,this.constructor.name)),this._command(r.TIME),this._formatbar("Time",a.T)}};var Oe=class extends d{static get name(){return"underline"}static get dependencies(){return[m]}init(){this._tag({name:r.U,group:o.FORMAT}),this._command(r.U),this._formatbar("underline",a.U)}};var Ie=class extends d{static get name(){return"unorderedlist"}static get dependencies(){return[m,G]}init(){this._tag({name:r.UL,group:o.LIST,children:[o.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.UL),this._toolbar("Unordered List")}};var ye=class extends d{static get name(){return"variable"}static get dependencies(){return[m]}init(){this._tag({name:r.VAR,group:o.FORMAT}),this._command(r.VAR),this._formatbar("Variable",a.V)}};var Ce=class extends p{_prepareForm(){this.formCreator.addLegend(this._("Video")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to video"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Ne=class extends h{constructor(t){super(t),this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml({detail:{element:t}}){Array.from(t.getElementsByTagName(r.VIDEO)).forEach(e=>this.#t(e))}insertvideo({detail:{element:t}}){this.#t(t)}#t(t){let e=t.getAttribute("src");e?(t.setAttribute("src",this.editor.url(e)),t.controls=!0,this.editor.dom.wrap(t,r.FIGURE,{attributes:{class:k.name}})):t.parentElement.removeChild(t)}};var k=class extends d{static get name(){return"video"}static get dependencies(){return[m,R]}static get config(){return{browser:void 0}}init(){this._tag({name:r.VIDEO,group:o.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new Ne(this.editor),this.editor.dialogs.set(new Ce(this.editor,this.constructor.name,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar("Video")}};var Se=class extends L{static get defaultConfig(){return{base:{plugins:[Gt,wt,jt,le,Ht,Oe,me,Yt,Zt,de,_t,D,oe,Ot,It,Vt,se,ye,he,ue,we,Ct,qt,Mt,ee,Pt,ce,Ie,Jt,Ut,C,U,k,H,P,y,N,ne,Bt,Dt,Lt]}}}};export{Se as default};
|
package/dist/editor.woff2
CHANGED
|
Binary file
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akilli/editor",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "A HTML standards-compliant and dependency-free rich text editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contenteditable",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"lint:fix": "prettier --write '**/*.js'",
|
|
30
30
|
"build": "npm run build:clean && npm run build:font && npm run build:css && npm run build:js",
|
|
31
31
|
"build:clean": "rm -rf dist",
|
|
32
|
-
"build:font": "mkdir -p dist && cp
|
|
33
|
-
"build:css": "esbuild
|
|
34
|
-
"build:js": "esbuild
|
|
32
|
+
"build:font": "mkdir -p dist && cp build/editor.woff2 dist/editor.woff2",
|
|
33
|
+
"build:css": "esbuild build/editor.css --minify --outfile=dist/editor.css",
|
|
34
|
+
"build:js": "esbuild build/AkilliEditor.js --minify --bundle --outfile=dist/editor.js --target=es2022 --format=esm",
|
|
35
35
|
"release:patch": "npm ci && npm run lint:check && npm version patch && npm publish",
|
|
36
36
|
"release:minor": "npm ci && npm run lint:check && npm version minor && npm publish",
|
|
37
37
|
"release:major": "npm ci && npm run lint:check && npm version major && npm publish",
|
package/{README.md → readme.md}
RENAMED
|
@@ -10,13 +10,15 @@ https://akilli.github.io/editor/demo
|
|
|
10
10
|
|
|
11
11
|
## Development
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Use the editor [source version](build/AkilliEditor.js) directly or the bundled and minified
|
|
14
|
+
[dist version](dist/editor.js) of it. If you use the source version all changes in the code take effect immediately,
|
|
15
|
+
whereas the dist version needs to rebuild with
|
|
14
16
|
|
|
15
17
|
```
|
|
16
18
|
npm run build
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
The demo offers both versions and can be started with either
|
|
20
22
|
|
|
21
23
|
```
|
|
22
24
|
npm start
|
|
@@ -28,8 +30,7 @@ or
|
|
|
28
30
|
docker compose up -d
|
|
29
31
|
```
|
|
30
32
|
|
|
31
|
-
In both cases the demo is accessible at
|
|
32
|
-
http://localhost:20000/demo/index.html
|
|
33
|
+
In both cases the demo is accessible at http://localhost:20000/demo/index.html
|
|
33
34
|
|
|
34
35
|
## Info
|
|
35
36
|
|
|
@@ -79,8 +80,8 @@ wheter a row or a column currently is focused.
|
|
|
79
80
|
|
|
80
81
|
### `Backspace` key handling
|
|
81
82
|
|
|
82
|
-
Certain editable elements like p. e. paragraphs and headings remove themselves if they contain no text and the
|
|
83
|
-
`Backspace` key is pressed. Other (pseudo) elements like p. e. table rows and colums do the same.
|
|
83
|
+
Certain editable elements like p. e. paragraphs and headings remove themselves if they contain no text and the
|
|
84
|
+
`Backspace` key is pressed. Other (pseudo) elements like p. e. table rows and colums do the same.
|
|
84
85
|
|
|
85
86
|
### Sortable elements
|
|
86
87
|
|
|
@@ -108,7 +109,7 @@ class `left`, `center` or `right`. This is done by combining the `Shift` key wit
|
|
|
108
109
|
|
|
109
110
|
Each formatting command registers a keyboard shortcut in the form `Alt` + `Shift` + a letter. If you hover a formatbar
|
|
110
111
|
button for such a text-level element, the actual keyboard shortcut will be shown. Using such a shortcut will execute the
|
|
111
|
-
corresponding command.
|
|
112
|
+
corresponding command.
|
|
112
113
|
|
|
113
114
|
In addition to that, you can also doubleclick on a text-level element to execute the corresponding command.
|
|
114
115
|
|