open-edit 0.1.0 → 0.1.2
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/open-edit.cjs.js +4 -4
- package/dist/open-edit.cjs.js.map +1 -1
- package/dist/open-edit.esm.js +49 -24
- package/dist/open-edit.esm.js.map +1 -1
- package/dist/open-edit.umd.js +4 -4
- package/dist/open-edit.umd.js.map +1 -1
- package/dist/view/code-lang-picker.d.ts +1 -0
- package/dist/view/toolbar.d.ts +1 -0
- package/package.json +1 -1
package/dist/open-edit.cjs.js
CHANGED
|
@@ -54,7 +54,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
54
54
|
border-radius: 50%;
|
|
55
55
|
flex-shrink: 0;
|
|
56
56
|
}
|
|
57
|
-
`,document.head.appendChild(e)}var Ae=[{variant:`info`,label:`Info`,color:`#3b82f6`},{variant:`success`,label:`Success`,color:`#22c55e`},{variant:`warning`,label:`Warning`,color:`#f59e0b`},{variant:`danger`,label:`Danger`,color:`#ef4444`}],je=class{el;editor;config;itemEls=new Map;disabled=!1;locale;calloutPickerEl=null;constructor(e,t,n,r,i=W){this.el=e,this.editor=t,this.locale=i,n?this.config=n:r?this.config=Oe(r,i):this.config=K(i),this.render()}render(){this.el.innerHTML=``,this.el.className=`oe-toolbar`;for(let e of this.config){let t=this.renderItem(e);this.el.appendChild(t)}}renderItem(e){switch(e.type){case`separator`:{let e=document.createElement(`div`);return e.className=`oe-toolbar-sep`,e}case`spacer`:{let e=document.createElement(`div`);return e.className=`oe-toolbar-spacer`,e}case`select`:{let t=document.createElement(`div`);t.className=`oe-toolbar-select-wrap`;let n=document.createElement(`select`);n.className=`oe-toolbar-select`,n.title=e.title;for(let t of e.options){let e=document.createElement(`option`);e.value=t.value,e.textContent=t.label,n.appendChild(e)}return n.addEventListener(`change`,()=>{let e=n.value;this.handleBlockTypeChange(e),setTimeout(()=>this.editor.focus(),0)}),t.appendChild(n),this.itemEls.set(e.id,n),t}case`button`:{let t=document.createElement(`button`);return t.type=`button`,t.className=`oe-toolbar-btn`,t.title=e.title,t.innerHTML=De[e.icon]??e.icon,t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,()=>{this.handleCommand(e.command,e)}),this.itemEls.set(e.id,t),t}}}handleCommand(e,t){let n=this.editor;switch(e){case`bold`:n.chain().toggleMark(`bold`).run();break;case`italic`:n.chain().toggleMark(`italic`).run();break;case`underline`:n.chain().toggleMark(`underline`).run();break;case`code`:n.chain().toggleMark(`code`).run();break;case`bulletList`:n.chain().toggleList(`bullet_list`).run();break;case`orderedList`:n.chain().toggleList(`ordered_list`).run();break;case`blockquote`:n.chain().setBlock(`blockquote`).run();break;case`hr`:n.chain().insertHr().run();break;case`callout`:{let e=t?this.itemEls.get(t.id):null;e&&this.toggleCalloutPicker(e);break}case`undo`:n.chain().undo().run();break;case`redo`:n.chain().redo().run();break;case`alignLeft`:n.chain().setAlign(`left`).run();break;case`alignCenter`:n.chain().setAlign(`center`).run();break;case`alignRight`:n.chain().setAlign(`right`).run();break;case`alignJustify`:n.chain().setAlign(`justify`).run();break;case`link`:this.handleLinkCommand();break;case`image`:this.handleImageCommand();break;case`htmlToggle`:n.toggleHTMLMode?.();break}}toggleCalloutPicker(e){if(this.calloutPickerEl){this.closeCalloutPicker();return}ke();let t=document.createElement(`div`);t.className=`oe-callout-picker`,this.calloutPickerEl=t;for(let{variant:e,label:n,color:r}of Ae){let i=document.createElement(`div`);i.className=`oe-callout-picker-item`,i.innerHTML=`<span class="oe-callout-picker-dot" style="background:${r}"></span>${n}`,i.addEventListener(`mousedown`,t=>{t.preventDefault(),this.closeCalloutPicker(),this.editor.chain().setBlock(`callout`,{variant:e}).run()}),t.appendChild(i)}document.body.appendChild(t);let n=e.getBoundingClientRect();t.style.top=`${n.bottom+4}px`,t.style.left=`${n.left}px`,requestAnimationFrame(()=>{if(!t.isConnected)return;let e=window.innerWidth;n.left+t.offsetWidth>e-8&&(t.style.left=`${e-t.offsetWidth-8}px`)});let r=n=>{!t.contains(n.target)&&n.target!==e&&(this.closeCalloutPicker(),document.removeEventListener(`mousedown`,r,!0))};setTimeout(()=>document.addEventListener(`mousedown`,r,!0),0)}closeCalloutPicker(){this.calloutPickerEl?.remove(),this.calloutPickerEl=null}handleBlockTypeChange(e){switch(e){case`P`:this.editor.chain().setBlock(`paragraph`).run();return;case`H1`:case`H2`:case`H3`:case`H4`:case`H5`:case`H6`:this.editor.chain().setBlock(`heading`,{level:Number(e[1])}).run();return;case`BLOCKQUOTE`:this.editor.chain().setBlock(`blockquote`).run();return;case`PRE`:this.editor.chain().setBlock(`code_block`).run();return;case`bullet_list`:case`ordered_list`:this.editor.chain().setBlock(e).run();return;case`CALLOUT-info`:case`CALLOUT-success`:case`CALLOUT-warning`:case`CALLOUT-danger`:{let t=e.split(`-`)[1];this.editor.chain().setBlock(`callout`,{variant:t}).run();return}default:this.editor.chain().setBlock(`paragraph`).run()}}handleLinkCommand(){let e=window.getSelection(),t=e&&!e.isCollapsed?e.toString():``,n=this.locale.dialogs,r=window.prompt(n.linkUrl,t.startsWith(`http`)?t:`https://`);if(!r)return;let i=window.confirm(n.openInNewTab)?`_blank`:`_self`;this.editor.chain().toggleMark(`link`,{href:r,target:i}).run()}handleImageCommand(){let e=this.locale.dialogs,t=window.prompt(e.imageUrl,`https://`);if(!t)return;let n=window.prompt(e.imageAlt,``)??``;this.editor.chain().insertImage(t,n||void 0).run()}updateActiveState(){if(this.disabled)return;let e=U(this.editor.editorEl),t=this.editor.getActiveBlockType();for(let[n,r]of this.itemEls){let i=this.config.find(e=>(e.type===`button`||e.type===`select`)&&`id`in e&&e.id===n);if(i){if(i.type===`select`){r.value=t;continue}if(i.type===`button`){let a=i.isActive?i.isActive(this.editor):n===`bold`&&e.has(`bold`)||n===`italic`&&e.has(`italic`)||n===`underline`&&e.has(`underline`)||n===`code`&&e.has(`code`)||n===`link`&&e.has(`link`)||n===`bulletList`&&t===`bullet_list`||n===`orderedList`&&t===`ordered_list`;r.classList.toggle(`oe-active`,a)}}}}setDisabled(e){this.disabled=e,this.el.classList.toggle(`oe-toolbar-disabled`,e);for(let t of this.itemEls.values())t instanceof HTMLButtonElement&&(t.disabled=e),t instanceof HTMLSelectElement&&(t.disabled=e)}},Me=class{el;editor;locale;hideTimer=null;constructor(e,t,n=W){this.el=e,this.editor=t,this.locale=n,this.render()}get editorEl(){return this.editor.editorEl}render(){this.el.className=`oe-bubble-toolbar`;let e=this.locale.toolbar,t=this.locale.dialogs,n=[{id:`bold`,icon:`bold`,title:e.bold,action:()=>this.editor.chain().toggleMark(`bold`).run(),isActive:()=>this.editor.isMarkActive(`bold`)},{id:`italic`,icon:`italic`,title:e.italic,action:()=>this.editor.chain().toggleMark(`italic`).run(),isActive:()=>this.editor.isMarkActive(`italic`)},{id:`underline`,icon:`underline`,title:e.underline,action:()=>this.editor.chain().toggleMark(`underline`).run(),isActive:()=>this.editor.isMarkActive(`underline`)},{id:`code_inline`,icon:`code_inline`,title:e.inlineCode,action:()=>this.editor.chain().toggleMark(`code`).run(),isActive:()=>this.editor.isMarkActive(`code`)},{id:`link`,icon:`link`,title:e.insertLink,action:()=>{let e=window.prompt(t.linkUrl,`https://`);if(!e)return;let n=window.confirm(t.openInNewTab)?`_blank`:`_self`;this.editor.chain().toggleMark(`link`,{href:e,target:n}).run()},isActive:()=>this.editor.isMarkActive(`link`)}];for(let e of n){let t=document.createElement(`button`);t.type=`button`,t.className=`oe-bubble-btn`,t.title=e.title,t.innerHTML=De[e.icon]??e.icon,t.dataset.btnId=e.id,t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,()=>{e.action(),this.updateActiveState()}),this.el.appendChild(t)}}onSelectionChange(){let e=window.getSelection();if(!e||e.isCollapsed||!this.editorEl.contains(e.anchorNode)){this.hide();return}this.hideTimer&&clearTimeout(this.hideTimer),setTimeout(()=>{let e=window.getSelection();if(!e||e.isCollapsed){this.hide();return}this.showAtSelection(),this.updateActiveState()},100)}showAtSelection(){let e=window.getSelection();if(!e||e.rangeCount===0)return;let t=e.getRangeAt(0).getBoundingClientRect();if(!t.width&&!t.height){this.hide();return}let n=window.scrollY,r=window.scrollX,i=t.top+n-44-8,a=t.left+r+t.width/2-280/2;i<n+8&&(i=t.bottom+n+8),a<8&&(a=8),a+280>window.innerWidth-8&&(a=window.innerWidth-280-8),this.el.style.top=`${i}px`,this.el.style.left=`${a}px`,this.el.classList.add(`oe-bubble-visible`)}hide(){this.hideTimer=setTimeout(()=>{this.el.classList.remove(`oe-bubble-visible`)},200)}updateActiveState(){let e=U(this.editorEl);this.el.querySelectorAll(`.oe-bubble-btn`).forEach(t=>{let n=t.dataset.btnId??``,r=n===`bold`&&e.has(`bold`)||n===`italic`&&e.has(`italic`)||n===`underline`&&e.has(`underline`)||n===`code_inline`&&e.has(`code`)||n===`link`&&e.has(`link`);t.classList.toggle(`oe-active`,r)})}destroy(){this.hideTimer&&clearTimeout(this.hideTimer),this.el.remove()}},Ne=`openedit-styles`;function Pe(e){if(document.getElementById(Ne))return;let t=document.createElement(`style`);t.id=Ne,t.textContent=Fe(),document.head.appendChild(t)}function Fe(){return`
|
|
57
|
+
`,document.head.appendChild(e)}var Ae=[{variant:`info`,label:`Info`,color:`#3b82f6`},{variant:`success`,label:`Success`,color:`#22c55e`},{variant:`warning`,label:`Warning`,color:`#f59e0b`},{variant:`danger`,label:`Danger`,color:`#ef4444`}],je=class{el;editor;config;itemEls=new Map;disabled=!1;locale;calloutPickerEl=null;calloutPickerCleanup=null;constructor(e,t,n,r,i=W){this.el=e,this.editor=t,this.locale=i,n?this.config=n:r?this.config=Oe(r,i):this.config=K(i),this.render()}render(){this.el.innerHTML=``,this.el.className=`oe-toolbar`;for(let e of this.config){let t=this.renderItem(e);this.el.appendChild(t)}}renderItem(e){switch(e.type){case`separator`:{let e=document.createElement(`div`);return e.className=`oe-toolbar-sep`,e}case`spacer`:{let e=document.createElement(`div`);return e.className=`oe-toolbar-spacer`,e}case`select`:{let t=document.createElement(`div`);t.className=`oe-toolbar-select-wrap`;let n=document.createElement(`select`);n.className=`oe-toolbar-select`,n.title=e.title;for(let t of e.options){let e=document.createElement(`option`);e.value=t.value,e.textContent=t.label,n.appendChild(e)}return n.addEventListener(`change`,()=>{let e=n.value;this.handleBlockTypeChange(e),setTimeout(()=>this.editor.focus(),0)}),t.appendChild(n),this.itemEls.set(e.id,n),t}case`button`:{let t=document.createElement(`button`);return t.type=`button`,t.className=`oe-toolbar-btn`,t.title=e.title,t.innerHTML=De[e.icon]??e.icon,t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,()=>{this.handleCommand(e.command,e)}),this.itemEls.set(e.id,t),t}}}handleCommand(e,t){let n=this.editor;switch(e){case`bold`:n.chain().toggleMark(`bold`).run();break;case`italic`:n.chain().toggleMark(`italic`).run();break;case`underline`:n.chain().toggleMark(`underline`).run();break;case`code`:n.chain().toggleMark(`code`).run();break;case`bulletList`:n.chain().toggleList(`bullet_list`).run();break;case`orderedList`:n.chain().toggleList(`ordered_list`).run();break;case`blockquote`:n.chain().setBlock(`blockquote`).run();break;case`hr`:n.chain().insertHr().run();break;case`callout`:{let e=t?this.itemEls.get(t.id):null;e&&this.toggleCalloutPicker(e);break}case`undo`:n.chain().undo().run();break;case`redo`:n.chain().redo().run();break;case`alignLeft`:n.chain().setAlign(`left`).run();break;case`alignCenter`:n.chain().setAlign(`center`).run();break;case`alignRight`:n.chain().setAlign(`right`).run();break;case`alignJustify`:n.chain().setAlign(`justify`).run();break;case`link`:this.handleLinkCommand();break;case`image`:this.handleImageCommand();break;case`htmlToggle`:n.toggleHTMLMode?.();break}}toggleCalloutPicker(e){if(this.calloutPickerEl){this.closeCalloutPicker();return}ke();let t=document.createElement(`div`);t.className=`oe-callout-picker`,this.calloutPickerEl=t;for(let{variant:e,label:n,color:r}of Ae){let i=document.createElement(`div`);i.className=`oe-callout-picker-item`,i.innerHTML=`<span class="oe-callout-picker-dot" style="background:${r}"></span>${n}`,i.addEventListener(`mousedown`,t=>{t.preventDefault(),this.closeCalloutPicker(),this.editor.chain().setBlock(`callout`,{variant:e}).run()}),t.appendChild(i)}document.body.appendChild(t);let n=e.getBoundingClientRect();t.style.top=`${n.bottom+4}px`,t.style.left=`${n.left}px`,requestAnimationFrame(()=>{if(!t.isConnected)return;let e=window.innerWidth;n.left+t.offsetWidth>e-8&&(t.style.left=`${e-t.offsetWidth-8}px`)});let r=n=>{!t.contains(n.target)&&n.target!==e&&(this.closeCalloutPicker(),document.removeEventListener(`mousedown`,r,!0))};setTimeout(()=>document.addEventListener(`mousedown`,r,!0),0);let i=()=>{this.closeCalloutPicker()};window.addEventListener(`scroll`,i,{passive:!0,capture:!0}),this.calloutPickerCleanup=()=>{window.removeEventListener(`scroll`,i,!0)}}closeCalloutPicker(){this.calloutPickerCleanup?.(),this.calloutPickerCleanup=null,this.calloutPickerEl?.remove(),this.calloutPickerEl=null}handleBlockTypeChange(e){switch(e){case`P`:this.editor.chain().setBlock(`paragraph`).run();return;case`H1`:case`H2`:case`H3`:case`H4`:case`H5`:case`H6`:this.editor.chain().setBlock(`heading`,{level:Number(e[1])}).run();return;case`BLOCKQUOTE`:this.editor.chain().setBlock(`blockquote`).run();return;case`PRE`:this.editor.chain().setBlock(`code_block`).run();return;case`bullet_list`:case`ordered_list`:this.editor.chain().setBlock(e).run();return;case`CALLOUT-info`:case`CALLOUT-success`:case`CALLOUT-warning`:case`CALLOUT-danger`:{let t=e.split(`-`)[1];this.editor.chain().setBlock(`callout`,{variant:t}).run();return}default:this.editor.chain().setBlock(`paragraph`).run()}}handleLinkCommand(){let e=window.getSelection(),t=e&&!e.isCollapsed?e.toString():``,n=this.locale.dialogs,r=window.prompt(n.linkUrl,t.startsWith(`http`)?t:`https://`);if(!r)return;let i=window.confirm(n.openInNewTab)?`_blank`:`_self`;this.editor.chain().toggleMark(`link`,{href:r,target:i}).run()}handleImageCommand(){let e=this.locale.dialogs,t=window.prompt(e.imageUrl,`https://`);if(!t)return;let n=window.prompt(e.imageAlt,``)??``;this.editor.chain().insertImage(t,n||void 0).run()}updateActiveState(){if(this.disabled)return;let e=U(this.editor.editorEl),t=this.editor.getActiveBlockType();for(let[n,r]of this.itemEls){let i=this.config.find(e=>(e.type===`button`||e.type===`select`)&&`id`in e&&e.id===n);if(i){if(i.type===`select`){r.value=t;continue}if(i.type===`button`){let a=i.isActive?i.isActive(this.editor):n===`bold`&&e.has(`bold`)||n===`italic`&&e.has(`italic`)||n===`underline`&&e.has(`underline`)||n===`code`&&e.has(`code`)||n===`link`&&e.has(`link`)||n===`bulletList`&&t===`bullet_list`||n===`orderedList`&&t===`ordered_list`;r.classList.toggle(`oe-active`,a)}}}}setDisabled(e){this.disabled=e,this.el.classList.toggle(`oe-toolbar-disabled`,e);for(let t of this.itemEls.values())t instanceof HTMLButtonElement&&(t.disabled=e),t instanceof HTMLSelectElement&&(t.disabled=e)}},Me=class{el;editor;locale;hideTimer=null;constructor(e,t,n=W){this.el=e,this.editor=t,this.locale=n,this.render()}get editorEl(){return this.editor.editorEl}render(){this.el.className=`oe-bubble-toolbar`;let e=this.locale.toolbar,t=this.locale.dialogs,n=[{id:`bold`,icon:`bold`,title:e.bold,action:()=>this.editor.chain().toggleMark(`bold`).run(),isActive:()=>this.editor.isMarkActive(`bold`)},{id:`italic`,icon:`italic`,title:e.italic,action:()=>this.editor.chain().toggleMark(`italic`).run(),isActive:()=>this.editor.isMarkActive(`italic`)},{id:`underline`,icon:`underline`,title:e.underline,action:()=>this.editor.chain().toggleMark(`underline`).run(),isActive:()=>this.editor.isMarkActive(`underline`)},{id:`code_inline`,icon:`code_inline`,title:e.inlineCode,action:()=>this.editor.chain().toggleMark(`code`).run(),isActive:()=>this.editor.isMarkActive(`code`)},{id:`link`,icon:`link`,title:e.insertLink,action:()=>{let e=window.prompt(t.linkUrl,`https://`);if(!e)return;let n=window.confirm(t.openInNewTab)?`_blank`:`_self`;this.editor.chain().toggleMark(`link`,{href:e,target:n}).run()},isActive:()=>this.editor.isMarkActive(`link`)}];for(let e of n){let t=document.createElement(`button`);t.type=`button`,t.className=`oe-bubble-btn`,t.title=e.title,t.innerHTML=De[e.icon]??e.icon,t.dataset.btnId=e.id,t.addEventListener(`mousedown`,e=>{e.preventDefault()}),t.addEventListener(`click`,()=>{e.action(),this.updateActiveState()}),this.el.appendChild(t)}}onSelectionChange(){let e=window.getSelection();if(!e||e.isCollapsed||!this.editorEl.contains(e.anchorNode)){this.hide();return}this.hideTimer&&clearTimeout(this.hideTimer),setTimeout(()=>{let e=window.getSelection();if(!e||e.isCollapsed){this.hide();return}this.showAtSelection(),this.updateActiveState()},100)}showAtSelection(){let e=window.getSelection();if(!e||e.rangeCount===0)return;let t=e.getRangeAt(0).getBoundingClientRect();if(!t.width&&!t.height){this.hide();return}let n=window.scrollY,r=window.scrollX,i=t.top+n-44-8,a=t.left+r+t.width/2-280/2;i<n+8&&(i=t.bottom+n+8),a<8&&(a=8),a+280>window.innerWidth-8&&(a=window.innerWidth-280-8),this.el.style.top=`${i}px`,this.el.style.left=`${a}px`,this.el.classList.add(`oe-bubble-visible`)}hide(){this.hideTimer=setTimeout(()=>{this.el.classList.remove(`oe-bubble-visible`)},200)}updateActiveState(){let e=U(this.editorEl);this.el.querySelectorAll(`.oe-bubble-btn`).forEach(t=>{let n=t.dataset.btnId??``,r=n===`bold`&&e.has(`bold`)||n===`italic`&&e.has(`italic`)||n===`underline`&&e.has(`underline`)||n===`code_inline`&&e.has(`code`)||n===`link`&&e.has(`link`);t.classList.toggle(`oe-active`,r)})}destroy(){this.hideTimer&&clearTimeout(this.hideTimer),this.el.remove()}},Ne=`openedit-styles`;function Pe(e){if(document.getElementById(Ne))return;let t=document.createElement(`style`);t.id=Ne,t.textContent=Fe(),document.head.appendChild(t)}function Fe(){return`
|
|
58
58
|
/* ── CSS Custom Properties (Light Mode defaults) ────────────────────── */
|
|
59
59
|
:root {
|
|
60
60
|
--oe-bg: #ffffff;
|
|
@@ -674,7 +674,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
674
674
|
.oe-bubble-btn.oe-active {
|
|
675
675
|
background: rgba(255,255,255,0.25);
|
|
676
676
|
}
|
|
677
|
-
`}var Ie=class{editorEl;syncCallback;overlay=null;selectedImg=null;scrollParents=[];boundUpdatePos=null;constructor(e,t){this.editorEl=e,this.syncCallback=t,e.addEventListener(`click`,this.onEditorClick),document.addEventListener(`mousedown`,this.onDocMousedown,!0)}destroy(){this.editorEl.removeEventListener(`click`,this.onEditorClick),document.removeEventListener(`mousedown`,this.onDocMousedown,!0),this.hideOverlay()}onEditorClick=e=>{e.target instanceof HTMLImageElement&&(e.stopPropagation(),this.selectImage(e.target))};onDocMousedown=e=>{if(!this.overlay)return;let t=e.target;this.overlay.contains(t)||t===this.selectedImg||this.hideOverlay()};selectImage(e){this.hideOverlay(),this.selectedImg=e;let t=document.createElement(`div`);t.className=`oe-img-overlay`,Object.assign(t.style,{position:`fixed`,border:`2px solid #3b82f6`,borderRadius:`3px`,zIndex:`9900`,pointerEvents:`none`,boxSizing:`border-box`});for(let n of[`nw`,`ne`,`sw`,`se`]){let r=document.createElement(`div`);r.className=`oe-img-handle oe-img-handle-${n}`,Object.assign(r.style,{position:`absolute`,width:`10px`,height:`10px`,background:`#ffffff`,border:`2px solid #3b82f6`,borderRadius:`2px`,boxSizing:`border-box`,pointerEvents:`all`,cursor:`${n}-resize`,...Le(n)}),r.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this.startResize(t,e,n)}),t.appendChild(r)}let n=document.createElement(`div`);n.className=`oe-img-label`,Object.assign(n.style,{position:`absolute`,bottom:`-26px`,right:`0`,background:`rgba(28,25,23,0.85)`,color:`#fff`,fontSize:`11px`,fontFamily:`monospace`,padding:`2px 6px`,borderRadius:`4px`,whiteSpace:`nowrap`,pointerEvents:`none`}),t.appendChild(n),document.body.appendChild(t),this.overlay=t;let r=()=>{if(!e.isConnected){this.hideOverlay();return}let r=e.getBoundingClientRect();Object.assign(t.style,{top:`${r.top}px`,left:`${r.left}px`,width:`${r.width}px`,height:`${r.height}px`}),n.textContent=`${Math.round(r.width)} × ${Math.round(r.height)}`};r(),this.boundUpdatePos=r,window.addEventListener(`scroll`,r,{passive:!0,capture:!0}),window.addEventListener(`resize`,r,{passive:!0})}hideOverlay(){this.overlay&&=(this.overlay.remove(),null),this.boundUpdatePos&&=(window.removeEventListener(`scroll`,this.boundUpdatePos,!0),window.removeEventListener(`resize`,this.boundUpdatePos),null),this.selectedImg=null}startResize(e,t,n){let r=e.clientX,i=e.clientY,a=t.getBoundingClientRect().width,o=a/(t.getBoundingClientRect().height||1),s=document.body.style.userSelect;document.body.style.userSelect=`none`;let c=e=>{let s=e.clientX-r,c=e.clientY-i,l=n===`ne`||n===`se`,u=n===`sw`||n===`se`,d=l?s:-s,f=u?c:-c,p=Math.abs(d)>=Math.abs(f)?d:f*o,m=Math.max(40,Math.round(a+p)),h=Math.max(20,Math.round(m/o));t.style.width=`${m}px`,t.style.height=`auto`,t.setAttribute(`width`,String(m)),t.setAttribute(`height`,String(h)),this.boundUpdatePos?.()},l=()=>{document.removeEventListener(`mousemove`,c),document.removeEventListener(`mouseup`,l),document.body.style.userSelect=s,this.syncCallback()};document.addEventListener(`mousemove`,c),document.addEventListener(`mouseup`,l)}};function Le(e){let t=`-6px`;switch(e){case`nw`:return{top:t,left:t};case`ne`:return{top:t,right:t};case`sw`:return{bottom:t,left:t};case`se`:return{bottom:t,right:t}}}var Re=`plain.bash.c.cpp.csharp.css.dockerfile.go.graphql.html.java.javascript.json.kotlin.markdown.php.python.ruby.rust.scss.shell.sql.swift.typescript.xml.yaml`.split(`.`),ze=class{editorEl;editor;pickerEl=null;activeIndex=0;filtered=[];targetPreEl=null;onOutside=null;onOutsideTimer=null;constructor(e,t){this.editorEl=e,this.editor=t,this.editorEl.addEventListener(`mousedown`,this.onBadgeMousedown,!0),this.editorEl.addEventListener(`click`,this.onBadgeClick,!0)}onBadgeMousedown=e=>{e.target.classList.contains(`oe-code-lang-badge`)&&(e.preventDefault(),e.stopPropagation())};onBadgeClick=e=>{let t=e.target;if(!t.classList.contains(`oe-code-lang-badge`))return;e.preventDefault(),e.stopPropagation();let n=t.closest(`pre`);if(n){if(this.pickerEl&&this.targetPreEl===n){this.closePicker();return}this.closePicker(),this.targetPreEl=n,this.openPicker(t,n)}};openPicker(e,t){let n=document.createElement(`div`);n.className=`oe-code-lang-picker`,this.pickerEl=n;let r=document.createElement(`input`);r.type=`text`,r.className=`oe-code-lang-picker-input`,r.placeholder=`Filter…`,n.appendChild(r);let i=document.createElement(`div`);i.className=`oe-code-lang-picker-list`,n.appendChild(i),document.body.appendChild(n),this.renderList(i,``);let a=e.getBoundingClientRect();n.style.top=`${a.bottom+4}px`,n.style.left=`${a.left}px`,requestAnimationFrame(()=>{if(!n.isConnected)return;let e=window.innerWidth;a.left+n.offsetWidth>e-8&&(n.style.left=`${e-n.offsetWidth-8}px`),r.focus()}),r.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`)e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,this.filtered.length-1),this.updateActive(i);else if(e.key===`ArrowUp`)e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this.updateActive(i);else if(e.key===`Enter`){e.preventDefault();let n=this.filtered[this.activeIndex];n!==void 0&&this.selectLang(n,t)}else e.key===`Escape`&&this.closePicker()}),r.addEventListener(`input`,()=>{this.activeIndex=0,this.renderList(i,r.value.trim().toLowerCase())}),this.onOutside=e=>{n.contains(e.target)||this.closePicker()},this.onOutsideTimer=setTimeout(()=>{this.onOutsideTimer=null,this.onOutside&&document.addEventListener(`mousedown`,this.onOutside,!0)},0)}renderList(e,t){this.filtered=t?Re.filter(e=>e.includes(t)):Re,e.innerHTML=``,this.filtered.forEach((t,n)=>{let r=document.createElement(`div`);r.className=`oe-code-lang-picker-item`+(n===this.activeIndex?` oe-active`:``),r.textContent=t,r.addEventListener(`mousedown`,e=>{e.preventDefault(),this.selectLang(t,this.targetPreEl)}),e.appendChild(r)})}updateActive(e){e.querySelectorAll(`.oe-code-lang-picker-item`).forEach((e,t)=>{e.classList.toggle(`oe-active`,t===this.activeIndex),t===this.activeIndex&&e.scrollIntoView({block:`nearest`})})}selectLang(e,t){this.closePicker();let n=t.querySelector(`code`);if(n){let e=window.getSelection();if(e){let t=document.createRange();t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}let r=e===`plain`?void 0:e;this.editor.chain().setBlock(`code_block`,{lang:r}).run()}closePicker(){this.onOutsideTimer!==null&&(clearTimeout(this.onOutsideTimer),this.onOutsideTimer=null),this.onOutside&&=(document.removeEventListener(`mousedown`,this.onOutside,!0),null),this.pickerEl?.remove(),this.pickerEl=null,this.targetPreEl=null,this.activeIndex=0,this.filtered=[]}destroy(){this.closePicker(),this.editorEl.removeEventListener(`mousedown`,this.onBadgeMousedown,!0),this.editorEl.removeEventListener(`click`,this.onBadgeClick,!0)}},J={toolbar:{undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,textFormat:`Textformat`,paragraph:`Absatz`,heading:e=>`Überschrift ${e}`,quote:`Zitat`,codeBlock:`Code-Block`,bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,inlineCode:"Inline-Code (Ctrl+`)",alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,justify:`Blocksatz`,bulletList:`Aufzählungsliste`,orderedList:`Nummerierte Liste`,insertLink:`Link einfügen`,insertImage:`Bild einfügen`,blockquote:`Zitat`,horizontalRule:`Trennlinie`,htmlSource:`HTML-Quellcode anzeigen`,calloutInfo:`Hinweis: Info`,calloutSuccess:`Hinweis: Erfolg`,calloutWarning:`Hinweis: Warnung`,calloutDanger:`Hinweis: Gefahr`,insertCallout:`Hinweisbox einfügen`},statusBar:{words:`Wörter`,characters:`Zeichen`,htmlSource:`HTML`},dialogs:{linkUrl:`Link-URL:`,openInNewTab:`In neuem Tab öffnen?`,imageUrl:`Bild-URL:`,imageAlt:`Alternativtext (optional):`},plugins:{ai:{panelTitle:`KI-Assistent`,noSelection:`(Kein Text ausgewählt — gesamtes Dokument wird verwendet)`,customPromptPlaceholder:`Eigene Anweisung eingeben…`,runButton:`Ausführen`,applyButton:`Übernehmen`,generating:`⏳ Wird generiert…`,noApiKey:`⚠️ Kein API-Key konfiguriert. Übergib apiKey oder endpoint beim Erstellen des Plugins.`,errorPrefix:`❌ Fehler: `,actions:{improve:`Verbessern`,shorten:`Kürzen`,expand:`Erweitern`,summarize:`Zusammenfassen`,toGerman:`🇩🇪 Auf Deutsch`,toEnglish:`🇬🇧 To English`}},emoji:{buttonTitle:`Emoji einfügen`,categories:{faces:`Gesichter`,hearts:`Herzen`,gestures:`Gesten`,nature:`Natur`,food:`Essen`,objects:`Objekte`,symbols:`Symbole`}}}},Be={de:J};function Ve(){return Be[(typeof navigator<`u`?navigator.language:``).split(`-`)[0].toLowerCase()]??W}function He(e){return{toolbar:{...W.toolbar,...e.toolbar},statusBar:{...W.statusBar,...e.statusBar},dialogs:{...W.dialogs,...e.dialogs},plugins:{ai:{...W.plugins.ai,actions:{...W.plugins.ai.actions,...e.plugins?.ai?.actions},...e.plugins?.ai},emoji:{...W.plugins.emoji,categories:{...W.plugins.emoji.categories,...e.plugins?.emoji?.categories},...e.plugins?.emoji}}}}var Ue=class{doc;history;root;editorEl;containerEl;toolbar=null;bubbleToolbar=null;imageResizer=null;codeLangPicker=null;plugins=[];options;locale;listeners={change:new Set,selectionchange:new Set,focus:new Set,blur:new Set};isComposing=!1;_isFocused=!1;isUpdating=!1;syncTimer=null;constructor(e){this.options=e,this.locale=e.locale?He(e.locale):Ve(),this.history=new t;let n=typeof e.element==`string`?document.querySelector(e.element):e.element;if(!n)throw Error(`[OpenEdit] Element not found: ${e.element}`);this.root=n,this.doc=e.content?h(e.content):p(),this.containerEl=this.buildContainer(),this.editorEl=this.buildEditorEl(),this.root.appendChild(this.containerEl),Pe(e.theme??`auto`),M(this.doc,this.editorEl),this.toolbar=new je(this.containerEl.querySelector(`.oe-toolbar`),this,e.toolbar,e.toolbarItems,this.locale);let r=document.createElement(`div`);r.className=`oe-bubble-toolbar`,document.body.appendChild(r),this.bubbleToolbar=new Me(r,this,this.locale),this.imageResizer=new Ie(this.editorEl,()=>this.scheduleSyncFromDOM()),this.codeLangPicker=new ze(this.editorEl,this),this.updatePlaceholder(),this.attachEvents(),this.applyTheme(e.theme??`auto`)}buildContainer(){let e=document.createElement(`div`);e.className=`oe-container`,e.innerHTML=`
|
|
677
|
+
`}var Ie=class{editorEl;syncCallback;overlay=null;selectedImg=null;scrollParents=[];boundUpdatePos=null;constructor(e,t){this.editorEl=e,this.syncCallback=t,e.addEventListener(`click`,this.onEditorClick),document.addEventListener(`mousedown`,this.onDocMousedown,!0)}destroy(){this.editorEl.removeEventListener(`click`,this.onEditorClick),document.removeEventListener(`mousedown`,this.onDocMousedown,!0),this.hideOverlay()}onEditorClick=e=>{e.target instanceof HTMLImageElement&&(e.stopPropagation(),this.selectImage(e.target))};onDocMousedown=e=>{if(!this.overlay)return;let t=e.target;this.overlay.contains(t)||t===this.selectedImg||this.hideOverlay()};selectImage(e){this.hideOverlay(),this.selectedImg=e;let t=document.createElement(`div`);t.className=`oe-img-overlay`,Object.assign(t.style,{position:`fixed`,border:`2px solid #3b82f6`,borderRadius:`3px`,zIndex:`9900`,pointerEvents:`none`,boxSizing:`border-box`});for(let n of[`nw`,`ne`,`sw`,`se`]){let r=document.createElement(`div`);r.className=`oe-img-handle oe-img-handle-${n}`,Object.assign(r.style,{position:`absolute`,width:`10px`,height:`10px`,background:`#ffffff`,border:`2px solid #3b82f6`,borderRadius:`2px`,boxSizing:`border-box`,pointerEvents:`all`,cursor:`${n}-resize`,...Le(n)}),r.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),this.startResize(t,e,n)}),t.appendChild(r)}let n=document.createElement(`div`);n.className=`oe-img-label`,Object.assign(n.style,{position:`absolute`,bottom:`-26px`,right:`0`,background:`rgba(28,25,23,0.85)`,color:`#fff`,fontSize:`11px`,fontFamily:`monospace`,padding:`2px 6px`,borderRadius:`4px`,whiteSpace:`nowrap`,pointerEvents:`none`}),t.appendChild(n),document.body.appendChild(t),this.overlay=t;let r=()=>{if(!e.isConnected){this.hideOverlay();return}let r=e.getBoundingClientRect();Object.assign(t.style,{top:`${r.top}px`,left:`${r.left}px`,width:`${r.width}px`,height:`${r.height}px`}),n.textContent=`${Math.round(r.width)} × ${Math.round(r.height)}`};r(),this.boundUpdatePos=r,window.addEventListener(`scroll`,r,{passive:!0,capture:!0}),window.addEventListener(`resize`,r,{passive:!0})}hideOverlay(){this.overlay&&=(this.overlay.remove(),null),this.boundUpdatePos&&=(window.removeEventListener(`scroll`,this.boundUpdatePos,!0),window.removeEventListener(`resize`,this.boundUpdatePos),null),this.selectedImg=null}startResize(e,t,n){let r=e.clientX,i=e.clientY,a=t.getBoundingClientRect().width,o=a/(t.getBoundingClientRect().height||1),s=document.body.style.userSelect;document.body.style.userSelect=`none`;let c=e=>{let s=e.clientX-r,c=e.clientY-i,l=n===`ne`||n===`se`,u=n===`sw`||n===`se`,d=l?s:-s,f=u?c:-c,p=Math.abs(d)>=Math.abs(f)?d:f*o,m=Math.max(40,Math.round(a+p)),h=Math.max(20,Math.round(m/o));t.style.width=`${m}px`,t.style.height=`auto`,t.setAttribute(`width`,String(m)),t.setAttribute(`height`,String(h)),this.boundUpdatePos?.()},l=()=>{document.removeEventListener(`mousemove`,c),document.removeEventListener(`mouseup`,l),document.body.style.userSelect=s,this.syncCallback()};document.addEventListener(`mousemove`,c),document.addEventListener(`mouseup`,l)}};function Le(e){let t=`-6px`;switch(e){case`nw`:return{top:t,left:t};case`ne`:return{top:t,right:t};case`sw`:return{bottom:t,left:t};case`se`:return{bottom:t,right:t}}}var Re=`plain.bash.c.cpp.csharp.css.dockerfile.go.graphql.html.java.javascript.json.kotlin.markdown.php.python.ruby.rust.scss.shell.sql.swift.typescript.xml.yaml`.split(`.`),ze=class{editorEl;editor;pickerEl=null;activeIndex=0;filtered=[];targetPreEl=null;onOutside=null;onOutsideTimer=null;onScroll=null;constructor(e,t){this.editorEl=e,this.editor=t,this.editorEl.addEventListener(`mousedown`,this.onBadgeMousedown,!0),this.editorEl.addEventListener(`click`,this.onBadgeClick,!0)}onBadgeMousedown=e=>{e.target.classList.contains(`oe-code-lang-badge`)&&(e.preventDefault(),e.stopPropagation())};onBadgeClick=e=>{let t=e.target;if(!t.classList.contains(`oe-code-lang-badge`))return;e.preventDefault(),e.stopPropagation();let n=t.closest(`pre`);if(n){if(this.pickerEl&&this.targetPreEl===n){this.closePicker();return}this.closePicker(),this.targetPreEl=n,this.openPicker(t,n)}};openPicker(e,t){let n=document.createElement(`div`);n.className=`oe-code-lang-picker`,this.pickerEl=n;let r=document.createElement(`input`);r.type=`text`,r.className=`oe-code-lang-picker-input`,r.placeholder=`Filter…`,n.appendChild(r);let i=document.createElement(`div`);i.className=`oe-code-lang-picker-list`,n.appendChild(i),document.body.appendChild(n),this.renderList(i,``);let a=e.getBoundingClientRect();n.style.top=`${a.bottom+4}px`,n.style.left=`${a.left}px`,requestAnimationFrame(()=>{if(!n.isConnected)return;let e=window.innerWidth;a.left+n.offsetWidth>e-8&&(n.style.left=`${e-n.offsetWidth-8}px`),r.focus()}),r.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`)e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,this.filtered.length-1),this.updateActive(i);else if(e.key===`ArrowUp`)e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this.updateActive(i);else if(e.key===`Enter`){e.preventDefault();let n=this.filtered[this.activeIndex];n!==void 0&&this.selectLang(n,t)}else e.key===`Escape`&&this.closePicker()}),r.addEventListener(`input`,()=>{this.activeIndex=0,this.renderList(i,r.value.trim().toLowerCase())}),this.onOutside=e=>{n.contains(e.target)||this.closePicker()},this.onOutsideTimer=setTimeout(()=>{this.onOutsideTimer=null,this.onOutside&&document.addEventListener(`mousedown`,this.onOutside,!0)},0),this.onScroll=()=>{this.closePicker()},window.addEventListener(`scroll`,this.onScroll,{passive:!0,capture:!0})}renderList(e,t){this.filtered=t?Re.filter(e=>e.includes(t)):Re,e.innerHTML=``,this.filtered.forEach((t,n)=>{let r=document.createElement(`div`);r.className=`oe-code-lang-picker-item`+(n===this.activeIndex?` oe-active`:``),r.textContent=t,r.addEventListener(`mousedown`,e=>{e.preventDefault(),this.selectLang(t,this.targetPreEl)}),e.appendChild(r)})}updateActive(e){e.querySelectorAll(`.oe-code-lang-picker-item`).forEach((e,t)=>{e.classList.toggle(`oe-active`,t===this.activeIndex),t===this.activeIndex&&e.scrollIntoView({block:`nearest`})})}selectLang(e,t){this.closePicker();let n=t.querySelector(`code`);if(n){let e=window.getSelection();if(e){let t=document.createRange();t.setStart(n,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}}let r=e===`plain`?void 0:e;this.editor.chain().setBlock(`code_block`,{lang:r}).run()}closePicker(){this.onOutsideTimer!==null&&(clearTimeout(this.onOutsideTimer),this.onOutsideTimer=null),this.onOutside&&=(document.removeEventListener(`mousedown`,this.onOutside,!0),null),this.onScroll&&=(window.removeEventListener(`scroll`,this.onScroll,!0),null),this.pickerEl?.remove(),this.pickerEl=null,this.targetPreEl=null,this.activeIndex=0,this.filtered=[]}destroy(){this.closePicker(),this.editorEl.removeEventListener(`mousedown`,this.onBadgeMousedown,!0),this.editorEl.removeEventListener(`click`,this.onBadgeClick,!0)}},J={toolbar:{undo:`Rückgängig (Ctrl+Z)`,redo:`Wiederholen (Ctrl+Y)`,textFormat:`Textformat`,paragraph:`Absatz`,heading:e=>`Überschrift ${e}`,quote:`Zitat`,codeBlock:`Code-Block`,bold:`Fett (Ctrl+B)`,italic:`Kursiv (Ctrl+I)`,underline:`Unterstrichen (Ctrl+U)`,inlineCode:"Inline-Code (Ctrl+`)",alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,justify:`Blocksatz`,bulletList:`Aufzählungsliste`,orderedList:`Nummerierte Liste`,insertLink:`Link einfügen`,insertImage:`Bild einfügen`,blockquote:`Zitat`,horizontalRule:`Trennlinie`,htmlSource:`HTML-Quellcode anzeigen`,calloutInfo:`Hinweis: Info`,calloutSuccess:`Hinweis: Erfolg`,calloutWarning:`Hinweis: Warnung`,calloutDanger:`Hinweis: Gefahr`,insertCallout:`Hinweisbox einfügen`},statusBar:{words:`Wörter`,characters:`Zeichen`,htmlSource:`HTML`},dialogs:{linkUrl:`Link-URL:`,openInNewTab:`In neuem Tab öffnen?`,imageUrl:`Bild-URL:`,imageAlt:`Alternativtext (optional):`},plugins:{ai:{panelTitle:`KI-Assistent`,noSelection:`(Kein Text ausgewählt — gesamtes Dokument wird verwendet)`,customPromptPlaceholder:`Eigene Anweisung eingeben…`,runButton:`Ausführen`,applyButton:`Übernehmen`,generating:`⏳ Wird generiert…`,noApiKey:`⚠️ Kein API-Key konfiguriert. Übergib apiKey oder endpoint beim Erstellen des Plugins.`,errorPrefix:`❌ Fehler: `,actions:{improve:`Verbessern`,shorten:`Kürzen`,expand:`Erweitern`,summarize:`Zusammenfassen`,toGerman:`🇩🇪 Auf Deutsch`,toEnglish:`🇬🇧 To English`}},emoji:{buttonTitle:`Emoji einfügen`,categories:{faces:`Gesichter`,hearts:`Herzen`,gestures:`Gesten`,nature:`Natur`,food:`Essen`,objects:`Objekte`,symbols:`Symbole`}}}},Be={de:J};function Ve(){return Be[(typeof navigator<`u`?navigator.language:``).split(`-`)[0].toLowerCase()]??W}function He(e){return{toolbar:{...W.toolbar,...e.toolbar},statusBar:{...W.statusBar,...e.statusBar},dialogs:{...W.dialogs,...e.dialogs},plugins:{ai:{...W.plugins.ai,actions:{...W.plugins.ai.actions,...e.plugins?.ai?.actions},...e.plugins?.ai},emoji:{...W.plugins.emoji,categories:{...W.plugins.emoji.categories,...e.plugins?.emoji?.categories},...e.plugins?.emoji}}}}var Ue=class{doc;history;root;editorEl;containerEl;toolbar=null;bubbleToolbar=null;imageResizer=null;codeLangPicker=null;plugins=[];options;locale;listeners={change:new Set,selectionchange:new Set,focus:new Set,blur:new Set};isComposing=!1;_isFocused=!1;isUpdating=!1;syncTimer=null;constructor(e){this.options=e,this.locale=e.locale?He(e.locale):Ve(),this.history=new t;let n=typeof e.element==`string`?document.querySelector(e.element):e.element;if(!n)throw Error(`[OpenEdit] Element not found: ${e.element}`);this.root=n,this.doc=e.content?h(e.content):p(),this.containerEl=this.buildContainer(),this.editorEl=this.buildEditorEl(),this.root.appendChild(this.containerEl),Pe(e.theme??`auto`),M(this.doc,this.editorEl),this.toolbar=new je(this.containerEl.querySelector(`.oe-toolbar`),this,e.toolbar,e.toolbarItems,this.locale);let r=document.createElement(`div`);r.className=`oe-bubble-toolbar`,document.body.appendChild(r),this.bubbleToolbar=new Me(r,this,this.locale),this.imageResizer=new Ie(this.editorEl,()=>this.scheduleSyncFromDOM()),this.codeLangPicker=new ze(this.editorEl,this),this.updatePlaceholder(),this.attachEvents(),this.applyTheme(e.theme??`auto`)}buildContainer(){let e=document.createElement(`div`);e.className=`oe-container`,e.innerHTML=`
|
|
678
678
|
<div class="oe-toolbar"></div>
|
|
679
679
|
<div class="oe-content-wrap">
|
|
680
680
|
<div class="oe-editor" contenteditable="true" spellcheck="true"></div>
|
|
@@ -694,7 +694,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
694
694
|
</button>
|
|
695
695
|
</div>
|
|
696
696
|
</div>
|
|
697
|
-
`;let t=this.options.statusBar;return t===!1?e.querySelector(`.oe-statusbar`)?.remove():t!==void 0&&typeof t==`object`&&(t.wordCount===!1&&e.querySelector(`.oe-word-count`)?.remove(),t.charCount===!1&&e.querySelector(`.oe-char-count`)?.remove(),t.elementPath===!1&&e.querySelector(`.oe-statusbar-path`)?.remove(),t.htmlToggle===!1&&(e.querySelector(`.oe-html-toggle`)?.remove(),e.querySelector(`.oe-statusbar-divider`)?.remove())),e}buildEditorEl(){let e=this.containerEl.querySelector(`.oe-editor`);return this.options.placeholder&&(e.dataset.placeholder=this.options.placeholder),this.options.readOnly&&(e.contentEditable=`false`),e}attachEvents(){let e=this.editorEl;e.addEventListener(`input`,this.onInput),e.addEventListener(`compositionstart`,this.onCompositionStart),e.addEventListener(`compositionend`,this.onCompositionEnd),document.addEventListener(`selectionchange`,this.onSelectionChange),e.addEventListener(`focus`,this.onFocus),e.addEventListener(`blur`,this.onBlur),e.addEventListener(`keydown`,this.onKeydown),e.addEventListener(`keydown`,this.onTabInCodeBlock),this.containerEl.querySelector(`.oe-html-toggle`).addEventListener(`click`,this.onHTMLToggleClick),e.addEventListener(`paste`,this.onPaste),e.addEventListener(`drop`,this.onDrop)}onInput=()=>{this.isComposing||this.isUpdating||this.scheduleSyncFromDOM()};onCompositionStart=()=>{this.isComposing=!0};onCompositionEnd=()=>{this.isComposing=!1,this.scheduleSyncFromDOM()};onHTMLToggleClick=()=>{this.toggleHTMLMode()};scheduleSyncFromDOM(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.history.push(this.doc),this.doc=F(this.editorEl),this.updatePlaceholder(),this.updateStatusBar(),this.emit(`change`,this.doc),this.options.onChange?.(this.getHTML())},0)}syncModelFromDOM(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.doc=F(this.editorEl),this.updatePlaceholder(),this.updateStatusBar()},0)}onSelectionChange=()=>{if(!this.editorEl.contains(document.activeElement)&&document.activeElement!==this.editorEl)return;this.toolbar?.updateActiveState(),this.bubbleToolbar?.onSelectionChange(),this.updateElementPath();let e=z(this.editorEl,this.doc);this.emit(`selectionchange`,e)};onFocus=()=>{this._isFocused=!0,this.containerEl.classList.add(`oe-focused`),this.emit(`focus`,void 0)};onBlur=()=>{this._isFocused=!1,this.containerEl.classList.remove(`oe-focused`),this.emit(`blur`,void 0)};onKeydown=e=>{let t=e.ctrlKey||e.metaKey;if(t&&e.key===`z`){e.preventDefault(),this.chain().undo().run();return}if(t&&(e.key===`y`||e.key===`Z`)){e.preventDefault(),this.chain().redo().run();return}if(t&&e.key===`b`){e.preventDefault(),this.chain().toggleMark(`bold`).run();return}if(t&&e.key===`i`){e.preventDefault(),this.chain().toggleMark(`italic`).run();return}if(t&&e.key===`u`){e.preventDefault(),this.chain().toggleMark(`underline`).run();return}if(t&&e.key==="`"){e.preventDefault(),this.chain().toggleMark(`code`).run();return}for(let t of this.plugins)if(t.keymaps){for(let[n,r]of Object.entries(t.keymaps))if(qe(n,e)){e.preventDefault(),r(this);return}}};onTabInCodeBlock=e=>{if(e.key!==`Tab`)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.anchorNode;for(;n&&n!==this.editorEl;){if(n.nodeType===Node.ELEMENT_NODE&&n.tagName===`PRE`){e.preventDefault(),I(`insertText`,e.shiftKey?``:` `);return}n=n.parentNode}};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/html`),n=e.clipboardData?.getData(`text/plain`)??``;if(this.history.push(this.doc),t&&t.trim())I(`insertHTML`,C(h(t)));else if(n){let e=n.trim();if(We(e)){let t=window.getSelection(),n=t&&!t.isCollapsed?t.toString():``;n?I(`insertHTML`,`<a href="${Ke(e)}" target="_blank" rel="noopener noreferrer">${n}</a>`):I(`insertHTML`,`<a href="${Ke(e)}" target="_blank" rel="noopener noreferrer">${e}</a>`)}else Ge(n)?I(`insertHTML`,C(k(n))):I(`insertText`,n)}this.scheduleSyncFromDOM()};onDrop=e=>{let t=e.dataTransfer?.files;if(!t||t.length===0)return;let n=Array.from(t).find(e=>e.type.startsWith(`image/`));n&&this.options.onImageUpload&&(e.preventDefault(),this.options.onImageUpload(n).then(e=>{let t=H(this.editorEl);this.history.push(this.doc),this.doc=L(this.doc,t,e,n.name),this.rerender()}).catch(()=>{}))};isHTMLMode=!1;toggleHTMLMode(){this.containerEl.querySelector(`.oe-content-wrap`);let e=this.editorEl,t=this.containerEl.querySelector(`.oe-html-source`),n=this.containerEl.querySelector(`.oe-html-textarea`),r=this.containerEl.querySelector(`.oe-html-toggle`);if(!this.isHTMLMode)n.value=this.getHTML(),e.style.display=`none`,t.style.display=``,this.isHTMLMode=!0,r.classList.add(`oe-active`),this.toolbar?.setDisabled(!0);else{let i=n.value;this.history.push(this.doc),this.doc=h(i),e.style.display=``,t.style.display=`none`,this.isHTMLMode=!1,r.classList.remove(`oe-active`),this.toolbar?.setDisabled(!1),this.rerender()}}chain(){let e=[],t=!1,n=this,r={toggleMark(t,i){return e.push(()=>{n.editorEl.focus();let e={bold:`bold`,italic:`italic`,underline:`underline`,strikethrough:`strikethrough`};if(t===`code`)if(U(n.editorEl).has(`code`)){let e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer.parentElement.closest(`code`);if(t){let e=t.textContent??``;t.replaceWith(document.createTextNode(e))}}}else{let e=window.getSelection();if(e&&!e.isCollapsed){let t=e.getRangeAt(0),n=document.createElement(`code`);t.surroundContents(n)}}else if(t===`link`){if(i?.href){let e=i.target??`_self`;Ce(i.href,e)}}else{let n=e[t];n&&I(n)}}),r},setBlock(i,a){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=ve(n.doc,e,i,a)}),r},setAlign(i){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=be(n.doc,e,i)}),r},insertImage(i,a){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=L(n.doc,e,i,a)}),r},insertHr(){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=xe(n.doc,e)}),r},toggleList(i){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=ye(n.doc,e,i)}),r},undo(){return t=!0,e.push(()=>{let e=n.history.undo(n.doc);e&&(n.doc=e)}),r},redo(){return t=!0,e.push(()=>{let e=n.history.redo(n.doc);e&&(n.doc=e)}),r},run(){n.isUpdating=!0;for(let t of e)t();n.isUpdating=!1,t?n.rerender():n.syncModelFromDOM(),n.toolbar?.updateActiveState(),n.emit(`change`,n.doc),n.options.onChange?.(n.getHTML())}};return r}rerender(){z(this.editorEl,this.doc),M(this.doc,this.editorEl),this.updatePlaceholder(),this.updateStatusBar(),this.editorEl.focus()}updateStatusBar(){let e=this.editorEl.innerText??``,t=e.trim().split(/\s+/).filter(e=>e.length>0),n=this.containerEl.querySelector(`.oe-word-count`),r=this.containerEl.querySelector(`.oe-char-count`);n&&(n.textContent=`${this.locale.statusBar.words}: ${t.length}`),r&&(r.textContent=`${this.locale.statusBar.characters}: ${e.length}`)}updateElementPath(){let e=this.containerEl.querySelector(`.oe-statusbar-path`);if(!e)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=[],r=t.anchorNode;for(;r&&r!==this.editorEl;)r.nodeType===Node.ELEMENT_NODE&&n.unshift(r.tagName.toLowerCase()),r=r.parentNode;e.textContent=n.join(` › `)}updatePlaceholder(){if(!this.options.placeholder)return;let e=this.editorEl.innerText.trim()===``&&this.editorEl.querySelectorAll(`img, hr`).length===0;this.editorEl.classList.toggle(`oe-empty`,e)}getHTML(){return C(this.doc)}setHTML(e){this.history.push(this.doc),this.doc=h(e),this.rerender()}getMarkdown(){return D(this.doc)}setMarkdown(e){this.history.push(this.doc),this.doc=k(e),this.rerender()}getDocument(){return this.doc}use(e){return this.plugins.push(e),e.onInit?.(this),this}on(e,t){this.listeners[e].add(t)}off(e,t){this.listeners[e].delete(t)}emit(e,t){this.listeners[e].forEach(e=>e(t))}destroy(){this.syncTimer&&clearTimeout(this.syncTimer),document.removeEventListener(`selectionchange`,this.onSelectionChange),this.editorEl.removeEventListener(`input`,this.onInput),this.editorEl.removeEventListener(`compositionstart`,this.onCompositionStart),this.editorEl.removeEventListener(`compositionend`,this.onCompositionEnd),this.editorEl.removeEventListener(`focus`,this.onFocus),this.editorEl.removeEventListener(`blur`,this.onBlur),this.editorEl.removeEventListener(`keydown`,this.onKeydown),this.editorEl.removeEventListener(`keydown`,this.onTabInCodeBlock),this.editorEl.removeEventListener(`paste`,this.onPaste),this.editorEl.removeEventListener(`drop`,this.onDrop),this.containerEl.querySelector(`.oe-html-toggle`)?.removeEventListener(`click`,this.onHTMLToggleClick),this.bubbleToolbar?.destroy(),this.imageResizer?.destroy(),this.codeLangPicker?.destroy(),this.plugins.forEach(e=>e.onDestroy?.(this)),this.root.innerHTML=``}focus(){this.editorEl.focus()}blur(){this.editorEl.blur()}isFocused(){return this._isFocused}getSelection(){return z(this.editorEl,this.doc)}isMarkActive(e){return U(this.editorEl).has(e)}getActiveBlockType(){return Se(this.editorEl)}isEmpty(){return this.editorEl.innerText.trim()===``&&this.editorEl.querySelectorAll(`img, hr`).length===0}applyTheme(e){this.containerEl.dataset.oeTheme=e}};function We(e){return/^https?:\/\/[^\s]{4,}$/.test(e)}function Ge(e){return/^#{1,6} /m.test(e)||/\*\*[^*]+\*\*/.test(e)||/^```/m.test(e)||/^[-*+] /m.test(e)||/^\d+\. /m.test(e)||/^> /m.test(e)||/~~[^~]+~~/.test(e)}function Ke(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`)}function qe(e,t){let n=e.toLowerCase().split(`+`),r=n[n.length-1],i=n.includes(`ctrl`)||n.includes(`meta`),a=n.includes(`shift`),o=n.includes(`alt`);return t.key.toLowerCase()===r&&(t.ctrlKey||t.metaKey)===i&&t.shiftKey===a&&t.altKey===o}var Y=null;function Je(){return Y||(Y=new Promise((e,t)=>{if(window.hljs){e(window.hljs);return}let n=document.createElement(`script`);n.src=`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js`,n.crossOrigin=`anonymous`,n.onload=()=>e(window.hljs),n.onerror=t,document.head.appendChild(n)}),Y)}var Ye=`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/`,Xe=`${Ye}atom-one-dark.min.css`,Ze=`${Ye}atom-one-light.min.css`;function Qe(e,t){let n=`oe-hljs-theme`,r=document.getElementById(n),i;if(i=typeof t==`string`?t:typeof t==`object`?e?t.dark:t.light:e?Xe:Ze,r){r.href=i;return}let a=document.createElement(`link`);a.id=n,a.rel=`stylesheet`,a.href=i,a.crossOrigin=`anonymous`,document.head.appendChild(a)}function $e(e={}){let t,n=null;function r(e){if(!t)return;let n=e.querySelectorAll(`pre code`),r=document.getSelection()?.anchorNode??null;n.forEach(e=>{let n=e.closest(`pre`);n&&r&&n.contains(r)||(delete e.dataset.highlighted,e.removeAttribute(`data-highlighted`),t.highlightElement(e))})}function i(e){n&&clearTimeout(n),n=setTimeout(()=>r(e),400)}return{name:`highlight`,onInit(n){let a=n.editorEl,o=n.containerEl;Qe(e.theme===`dark`||!e.theme&&o?.dataset.oeTheme===`dark`,e.themeUrl),Je().then(e=>{t=e,t?.configure({ignoreUnescapedHTML:!0}),r(a),n.on(`change`,()=>i(a))}).catch(()=>{console.warn(`[OpenEdit] highlight.js failed to load from CDN`)})},onDestroy(){n&&clearTimeout(n)}}}var et={faces:`😀.😄.😅.😂.🤣.😊.😇.🙂.🙃.😉.😍.🥰.😘.😎.🤓.🤩.🥳.😏.😔.😢.😭.😤.😠.🥺.🤔.🤗.😴.🤯.🥸.😶`.split(`.`),hearts:[`❤️`,`🧡`,`💛`,`💚`,`💙`,`💜`,`🖤`,`🤍`,`🤎`,`💕`,`💞`,`💓`,`💗`,`💖`,`💝`,`💘`,`❣️`,`💔`,`❤️🔥`,`💟`],gestures:[`👋`,`🤚`,`🖐`,`✋`,`🖖`,`👌`,`🤌`,`✌️`,`🤞`,`🤟`,`🤘`,`👈`,`👉`,`👆`,`👇`,`☝️`,`👍`,`👎`,`✊`,`👏`,`🙌`,`🫶`,`🤝`,`🙏`],nature:`🌸.🌺.🌻.🌹.🌷.🍀.🌿.🌱.🌲.🌳.🌴.🍁.🍂.🍃.🌊.🌈.☀️.🌙.⭐.🌟.💫.⚡.🔥.💧.🌍.🦋.🐾`.split(`.`),food:[`🍎`,`🍊`,`🍋`,`🍇`,`🍓`,`🍒`,`🍑`,`🥝`,`🍕`,`🍔`,`🌮`,`🌯`,`🍜`,`🍣`,`🍰`,`🎂`,`☕`,`🍵`,`🧃`,`🥤`,`🍺`,`🥂`,`🍾`],objects:[`💡`,`🔑`,`🎵`,`🎮`,`📱`,`💻`,`📷`,`🎯`,`🏆`,`💎`,`🔮`,`📚`,`✏️`,`📝`,`📌`,`🔔`,`💬`,`📧`,`🚀`,`🎁`,`🧩`,`⚙️`,`🔧`,`🎨`],symbols:[`✅`,`❌`,`⚠️`,`ℹ️`,`💯`,`🔴`,`🟡`,`🟢`,`🔵`,`⚫`,`⚪`,`🔶`,`🔷`,`🔸`,`🔹`,`▶️`,`◀️`,`🔝`,`🔛`,`🆕`,`🆒`,`🆓`,`🆙`,`🏳️`,`🏴`]};function tt(e){let t=e.plugins.emoji.categories;return Object.keys(et).map(e=>({label:t[e],emojis:et[e]}))}var nt=`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;function rt(){let e=null,t=null,n=null,r=null,i=W;function a(){e&&=(e.remove(),null),document.removeEventListener(`click`,o,!0)}function o(n){let r=n.target;e&&!e.contains(r)&&!t?.contains(r)&&a()}function s(e){let t=window.getSelection();r&&t?(t.removeAllRanges(),t.addRange(r)):n&&n.focus(),document.execCommand(`insertText`,!1,e),a(),n?.focus()}function c(t){a(),e=document.createElement(`div`),e.className=`oe-emoji-popup`,Object.assign(e.style,{position:`fixed`,zIndex:`99999`,background:`var(--oe-bg, #ffffff)`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`12px`,boxShadow:`0 8px 32px rgba(0,0,0,0.14)`,padding:`10px 12px`,width:`300px`,maxHeight:`260px`,overflowY:`auto`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`});for(let t of tt(i)){let n=document.createElement(`div`);Object.assign(n.style,{fontSize:`10px`,fontWeight:`600`,color:`var(--oe-muted, #78716c)`,textTransform:`uppercase`,letterSpacing:`0.06em`,margin:`6px 0 4px`}),n.textContent=t.label,e.appendChild(n);let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexWrap:`wrap`,gap:`1px`});for(let e of t.emojis){let t=document.createElement(`button`);t.type=`button`,t.textContent=e,t.title=e,Object.assign(t.style,{background:`none`,border:`none`,cursor:`pointer`,padding:`4px`,borderRadius:`6px`,fontSize:`18px`,lineHeight:`1`,transition:`background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.background=`var(--oe-btn-hover-bg, #f5f5f4)`}),t.addEventListener(`mouseleave`,()=>{t.style.background=`none`}),t.addEventListener(`mousedown`,t=>{t.preventDefault(),s(e)}),r.appendChild(t)}e.appendChild(r)}document.body.appendChild(e);let n=t.getBoundingClientRect(),r=n.bottom+4,c=n.left;c+300>window.innerWidth-8&&(c=window.innerWidth-308),c<8&&(c=8),r+260>window.innerHeight-8&&(r=n.top-260-4),e.style.top=`${r}px`,e.style.left=`${c}px`,setTimeout(()=>{document.addEventListener(`click`,o,!0)},0)}return{name:`emoji`,onInit(o){n=o,i=o.locale??W;let s=o.editorEl,l=o.containerEl?.querySelector(`.oe-toolbar`);if(!l)return;document.addEventListener(`selectionchange`,()=>{let e=window.getSelection();e&&e.rangeCount>0&&s.contains(e.anchorNode)&&(r=e.getRangeAt(0).cloneRange())});let u=document.createElement(`button`);u.type=`button`,u.className=`oe-toolbar-btn`,u.title=i.plugins.emoji.buttonTitle,u.innerHTML=nt,t=u,u.addEventListener(`mousedown`,t=>{t.preventDefault();let n=window.getSelection();n&&n.rangeCount>0&&s.contains(n.anchorNode)&&(r=n.getRangeAt(0).cloneRange()),e?a():c(u)}),l.appendChild(u)},onDestroy(){a(),n=null,r=null}}}var X=/\{\{([^{}]+)\}\}/g;function it(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.classList.contains(`oe-template-tag`)||t.tagName===`TEXTAREA`||t.tagName===`SCRIPT`?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=[],r;for(;r=t.nextNode();)(r.textContent??``).includes(`{{`)&&n.push(r);for(let e of n){let t=e.textContent??``;if(X.lastIndex=0,!X.test(t))continue;X.lastIndex=0;let n=[],r=0,i;for(;(i=X.exec(t))!==null;)i.index>r&&n.push({type:`text`,value:t.slice(r,i.index)}),n.push({type:`tag`,value:i[0]}),r=X.lastIndex;r<t.length&&n.push({type:`text`,value:t.slice(r)});let a=document.createDocumentFragment();for(let e of n)if(e.type===`tag`){let t=document.createElement(`span`);t.className=`oe-template-tag`,t.contentEditable=`false`,t.textContent=e.value,a.appendChild(t)}else e.value&&a.appendChild(document.createTextNode(e.value));e.parentNode?.replaceChild(a,e)}}function at(){let e=null;function t(t){e&&clearTimeout(e),e=setTimeout(()=>it(t),200)}return{name:`template-tags`,onInit(e){let n=e.editorEl;e.on(`change`,()=>t(n)),setTimeout(()=>it(n),100)},onDestroy(){e&&clearTimeout(e)}}}var ot=`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`,Z={improve:`Improve the following text stylistically and grammatically. Return only the improved text, no explanations.`,shorten:`Shorten the following text to approximately 50% of its length, keeping all important information. Return only the shortened text.`,expand:`Expand the following text with more details, examples, and context. Return only the expanded text.`,summarize:`Summarize the following text in 2-3 concise sentences. Return only the summary.`,toGerman:`Translate the following text to German. Return only the translation.`,toEnglish:`Translate the following text to English. Return only the translation, no explanations.`};function st(e){let t=e.plugins.ai.actions;return[{label:t.improve,prompt:Z.improve},{label:t.shorten,prompt:Z.shorten},{label:t.expand,prompt:Z.expand},{label:t.summarize,prompt:Z.summarize},{label:t.toGerman,prompt:Z.toGerman},{label:t.toEnglish,prompt:Z.toEnglish}]}async function ct(e,t){let n=t.endpoint??`https://api.anthropic.com/v1/messages`,r=t.model??`claude-sonnet-4-6`,i={"content-type":`application/json`};t.apiKey&&!t.endpoint&&(i[`x-api-key`]=t.apiKey,i[`anthropic-version`]=`2023-06-01`,i[`anthropic-dangerous-direct-browser-access`]=`true`);let a=JSON.stringify({model:r,max_tokens:t.maxTokens??2048,system:`You are a professional writing assistant. Follow the user's instruction exactly and return only the desired result — no introduction, no explanation, no commentary.`,messages:[{role:`user`,content:e}]}),o=await fetch(n,{method:`POST`,headers:i,body:a});if(!o.ok){let e=await o.text().catch(()=>o.statusText);throw Error(`API error ${o.status}: ${e}`)}let s=(await o.json())?.content?.[0]?.text;if(!s)throw Error(`Unexpected response format`);return s}function Q(e,t){Object.assign(e.style,t)}function lt(e={}){!e.apiKey&&!e.endpoint&&console.warn(`[OpenEdit AI] No apiKey or endpoint provided — plugin inactive.`);let t=null,n=null,r=null,i=null,a=``,o=W;function s(){t&&=(t.remove(),null),document.removeEventListener(`click`,c,!0)}function c(e){let r=e.target;t&&!t.contains(r)&&!n?.contains(r)&&s()}function l(e){let t=window.getSelection();t&&t.rangeCount>0&&e.contains(t.anchorNode)?(i=t.getRangeAt(0).cloneRange(),a=t.toString().trim()):(i=null,a=r?.getHTML()??``)}function u(e){if(!r)return;let t=window.getSelection();if(i&&t&&a){t.removeAllRanges(),t.addRange(i);let n=C(h(e));document.execCommand(`insertHTML`,!1,n)}else r.setHTML(e);r.focus()}function d(e){s(),t=document.createElement(`div`),Q(t,{position:`fixed`,zIndex:`99999`,background:`var(--oe-bg, #fff)`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`14px`,boxShadow:`0 12px 40px rgba(0,0,0,0.16)`,padding:`16px`,width:`360px`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`});let n=o.plugins.ai,i=document.createElement(`div`);Q(i,{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`12px`}),i.innerHTML=`${ot}<span style="font-size:13px;font-weight:600;color:var(--oe-text,#1c1917)">${n.panelTitle}</span>`,t.appendChild(i);let l=document.createElement(`div`),d=a||n.noSelection;Q(l,{fontSize:`12px`,color:`var(--oe-text-muted, #78716c)`,background:`var(--oe-btn-hover-bg, #f5f5f4)`,borderRadius:`8px`,padding:`8px 10px`,marginBottom:`12px`,maxHeight:`64px`,overflow:`hidden`,lineHeight:`1.5`}),l.textContent=d.length>140?d.slice(0,140)+`…`:d,t.appendChild(l);let p=document.createElement(`div`);Q(p,{display:`flex`,flexWrap:`wrap`,gap:`6px`,marginBottom:`12px`});for(let e of st(o)){let t=document.createElement(`button`);t.type=`button`,t.textContent=e.label,Q(t,{padding:`5px 10px`,fontSize:`12px`,fontWeight:`500`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`6px`,background:`var(--oe-bg, #fff)`,color:`var(--oe-text, #1c1917)`,cursor:`pointer`,fontFamily:`inherit`,transition:`background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.background=`var(--oe-btn-hover-bg, #f5f5f4)`}),t.addEventListener(`mouseleave`,()=>{t.style.background=`var(--oe-bg, #fff)`}),t.addEventListener(`click`,()=>{let t=a||r?.getHTML()||``;f(`${e.prompt}\n\n${t}`,_,v)}),p.appendChild(t)}t.appendChild(p);let m=document.createElement(`div`);Q(m,{display:`flex`,gap:`6px`,marginBottom:`12px`});let h=document.createElement(`textarea`);h.placeholder=n.customPromptPlaceholder,h.rows=2,Q(h,{flex:`1`,padding:`8px 10px`,fontSize:`12px`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`8px`,background:`var(--oe-bg, #fff)`,color:`var(--oe-text, #1c1917)`,fontFamily:`inherit`,resize:`none`,outline:`none`});let g=document.createElement(`button`);g.type=`button`,g.textContent=n.runButton,Q(g,{padding:`0 14px`,fontSize:`12px`,fontWeight:`600`,border:`none`,borderRadius:`8px`,background:`#1c1917`,color:`#fff`,cursor:`pointer`,fontFamily:`inherit`,alignSelf:`stretch`}),g.addEventListener(`click`,()=>{let e=a||r?.getHTML()||``,t=h.value.trim();t&&f(`${t}\n\n${e}`,_,v)}),m.appendChild(h),m.appendChild(g),t.appendChild(m);let _=document.createElement(`div`);Q(_,{display:`none`,fontSize:`12px`,color:`var(--oe-text, #1c1917)`,background:`var(--oe-btn-hover-bg, #f5f5f4)`,borderRadius:`8px`,padding:`10px`,marginBottom:`10px`,lineHeight:`1.6`,maxHeight:`120px`,overflowY:`auto`}),t.appendChild(_);let v=document.createElement(`button`);v.type=`button`,v.textContent=n.applyButton,v.style.display=`none`,Q(v,{width:`100%`,padding:`9px`,fontSize:`13px`,fontWeight:`600`,border:`none`,borderRadius:`8px`,background:`#1c1917`,color:`#fff`,cursor:`pointer`,fontFamily:`inherit`}),v.addEventListener(`click`,()=>{let e=_.dataset.result??``;e&&(u(e),s())}),t.appendChild(v),document.body.appendChild(t);let y=e.getBoundingClientRect(),b=y.bottom+4,x=y.left;x+360>window.innerWidth-8&&(x=window.innerWidth-368),x<8&&(x=8),b+400>window.innerHeight-8&&(b=y.top-400-4),t.style.top=`${b}px`,t.style.left=`${x}px`,setTimeout(()=>{document.addEventListener(`click`,c,!0)},0)}async function f(t,n,r){let i=o.plugins.ai;if(!e.apiKey&&!e.endpoint){n.style.display=`block`,n.textContent=i.noApiKey;return}n.style.display=`block`,n.textContent=i.generating,r.style.display=`none`;try{let i=await ct(t,e);n.textContent=i.length>400?i.slice(0,400)+`…`:i,n.dataset.result=i,r.style.display=`block`}catch(e){n.textContent=`${i.errorPrefix}${e instanceof Error?e.message:String(e)}`}}return{name:`ai-assistant`,onInit(e){r=e,o=e.locale??W;let c=e.editorEl,u=e.containerEl?.querySelector(`.oe-toolbar`);if(!u)return;document.addEventListener(`selectionchange`,()=>{let e=window.getSelection();e&&e.rangeCount>0&&c.contains(e.anchorNode)&&(i=e.getRangeAt(0).cloneRange(),a=e.isCollapsed?``:e.toString().trim())});let f=document.createElement(`div`);f.className=`oe-toolbar-sep`;let p=document.createElement(`button`);p.type=`button`,p.className=`oe-toolbar-btn`,p.title=o.plugins.ai.panelTitle,p.innerHTML=ot,Q(p,{color:`rgb(99,102,241)`}),n=p,p.addEventListener(`mousedown`,e=>{e.preventDefault(),l(c),t?s():d(p)}),u.appendChild(f),u.appendChild(p),c.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&!e.shiftKey){let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=n.startContainer.textContent??``;if(r.trim()===`/ai`){e.preventDefault();let t=document.createRange();t.setStart(n.startContainer,0),t.setEnd(n.startContainer,r.length),t.deleteContents(),l(c),d(p)}}})},onDestroy(){s(),r=null}}}var ut={"/callout":`info`,"/callout-info":`info`,"/callout-success":`success`,"/callout-warning":`warning`,"/callout-danger":`danger`};function dt(){let e=null,t=null,n=n=>{if(n.key!==`Enter`||n.shiftKey||!e)return;let r=window.getSelection();if(!r||r.rangeCount===0)return;let i=r.getRangeAt(0);if(!i.collapsed)return;let a=i.startContainer;for(;a&&a.parentNode!==e;)a=a.parentNode;if(!a||a.nodeType!==Node.ELEMENT_NODE)return;let o=ut[(a.textContent?.trim()??``).toLowerCase()];o&&(n.preventDefault(),a.innerHTML=``,t?.chain().setBlock(`callout`,{variant:o}).run())};return{name:`callout`,onInit(r){t=r,e=r.editorEl,e&&e.addEventListener(`keydown`,n)},onDestroy(r){e&&e.removeEventListener(`keydown`,n),e=null,t=null},keymaps:{"ctrl+shift+i":e=>(e.chain().setBlock(`callout`,{variant:`info`}).run(),!0)}}}var ft=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4H9.5a4.5 4.5 0 0 0 0 9H13"/></svg>`,pt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,mt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,ht=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1.5" fill="currentColor" stroke="none"/></svg>`,gt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">1.</text><text x="2" y="15" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">2.</text><text x="2" y="21" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">3.</text></svg>`,_t=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="2" y1="12" x2="22" y2="12"/></svg>`,vt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`,yt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`,bt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`,xt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>`;function $(e){return`<span style="font-size:11px;font-weight:700;letter-spacing:-0.5px;line-height:1">H${e}</span>`}function St(){return[{id:`paragraph`,title:`Paragraph`,description:`Plain text block`,icon:ft,keywords:[`paragraph`,`text`,`p`,`normal`],execute:e=>e.chain().setBlock(`paragraph`).run()},{id:`h1`,title:`Heading 1`,description:`Large section title`,icon:$(1),keywords:[`heading`,`h1`,`heading1`,`title`,`1`],execute:e=>e.chain().setBlock(`heading`,{level:1}).run()},{id:`h2`,title:`Heading 2`,description:`Medium section title`,icon:$(2),keywords:[`heading`,`h2`,`heading2`,`2`],execute:e=>e.chain().setBlock(`heading`,{level:2}).run()},{id:`h3`,title:`Heading 3`,description:`Small section title`,icon:$(3),keywords:[`heading`,`h3`,`heading3`,`3`],execute:e=>e.chain().setBlock(`heading`,{level:3}).run()},{id:`h4`,title:`Heading 4`,icon:$(4),keywords:[`heading`,`h4`,`heading4`,`4`],execute:e=>e.chain().setBlock(`heading`,{level:4}).run()},{id:`h5`,title:`Heading 5`,icon:$(5),keywords:[`heading`,`h5`,`heading5`,`5`],execute:e=>e.chain().setBlock(`heading`,{level:5}).run()},{id:`h6`,title:`Heading 6`,icon:$(6),keywords:[`heading`,`h6`,`heading6`,`6`],execute:e=>e.chain().setBlock(`heading`,{level:6}).run()},{id:`quote`,title:`Blockquote`,description:`Indented citation block`,icon:pt,keywords:[`quote`,`blockquote`,`bq`,`citation`],execute:e=>e.chain().setBlock(`blockquote`).run()},{id:`code`,title:`Code Block`,description:`Monospace preformatted code`,icon:mt,keywords:[`code`,`codeblock`,`pre`,`monospace`,`snippet`],execute:e=>e.chain().setBlock(`code_block`).run()},{id:`bullet`,title:`Bullet List`,description:`Unordered list with dots`,icon:ht,keywords:[`ul`,`bullet`,`bulletlist`,`unordered`,`list`,`-`],execute:e=>e.chain().toggleList(`bullet_list`).run()},{id:`numbered`,title:`Numbered List`,description:`Ordered numbered list`,icon:gt,keywords:[`ol`,`numbered`,`orderedlist`,`ordered`,`list`,`1`],execute:e=>e.chain().toggleList(`ordered_list`).run()},{id:`hr`,title:`Divider`,description:`Horizontal rule`,icon:_t,keywords:[`hr`,`divider`,`separator`,`rule`,`---`],execute:e=>e.chain().insertHr().run()},{id:`callout-info`,title:`Callout: Info`,description:`Blue informational callout`,icon:vt,keywords:[`callout`,`info`,`note`,`callout-info`],execute:e=>e.chain().setBlock(`callout`,{variant:`info`}).run()},{id:`callout-success`,title:`Callout: Success`,description:`Green success callout`,icon:yt,keywords:[`callout`,`success`,`done`,`callout-success`],execute:e=>e.chain().setBlock(`callout`,{variant:`success`}).run()},{id:`callout-warning`,title:`Callout: Warning`,description:`Yellow warning callout`,icon:bt,keywords:[`callout`,`warning`,`warn`,`caution`,`callout-warning`],execute:e=>e.chain().setBlock(`callout`,{variant:`warning`}).run()},{id:`callout-danger`,title:`Callout: Danger`,description:`Red danger or error callout`,icon:xt,keywords:[`callout`,`danger`,`error`,`callout-danger`],execute:e=>e.chain().setBlock(`callout`,{variant:`danger`}).run()}]}var Ct=`oe-slash-menu-styles`;function wt(){if(document.getElementById(Ct))return;let e=document.createElement(`style`);e.id=Ct,e.textContent=`
|
|
697
|
+
`;let t=this.options.statusBar;return t===!1?e.querySelector(`.oe-statusbar`)?.remove():t!==void 0&&typeof t==`object`&&(t.wordCount===!1&&e.querySelector(`.oe-word-count`)?.remove(),t.charCount===!1&&e.querySelector(`.oe-char-count`)?.remove(),t.elementPath===!1&&e.querySelector(`.oe-statusbar-path`)?.remove(),t.htmlToggle===!1&&(e.querySelector(`.oe-html-toggle`)?.remove(),e.querySelector(`.oe-statusbar-divider`)?.remove())),e}buildEditorEl(){let e=this.containerEl.querySelector(`.oe-editor`);return this.options.placeholder&&(e.dataset.placeholder=this.options.placeholder),this.options.readOnly&&(e.contentEditable=`false`),e}attachEvents(){let e=this.editorEl;e.addEventListener(`input`,this.onInput),e.addEventListener(`compositionstart`,this.onCompositionStart),e.addEventListener(`compositionend`,this.onCompositionEnd),document.addEventListener(`selectionchange`,this.onSelectionChange),e.addEventListener(`focus`,this.onFocus),e.addEventListener(`blur`,this.onBlur),e.addEventListener(`keydown`,this.onKeydown),e.addEventListener(`keydown`,this.onTabInCodeBlock),this.containerEl.querySelector(`.oe-html-toggle`).addEventListener(`click`,this.onHTMLToggleClick),e.addEventListener(`paste`,this.onPaste),e.addEventListener(`drop`,this.onDrop)}onInput=()=>{this.isComposing||this.isUpdating||this.scheduleSyncFromDOM()};onCompositionStart=()=>{this.isComposing=!0};onCompositionEnd=()=>{this.isComposing=!1,this.scheduleSyncFromDOM()};onHTMLToggleClick=()=>{this.toggleHTMLMode()};scheduleSyncFromDOM(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.history.push(this.doc),this.doc=F(this.editorEl),this.updatePlaceholder(),this.updateStatusBar(),this.emit(`change`,this.doc),this.options.onChange?.(this.getHTML())},0)}syncModelFromDOM(){this.syncTimer&&clearTimeout(this.syncTimer),this.syncTimer=setTimeout(()=>{this.doc=F(this.editorEl),this.updatePlaceholder(),this.updateStatusBar()},0)}onSelectionChange=()=>{if(!this.editorEl.contains(document.activeElement)&&document.activeElement!==this.editorEl)return;this.toolbar?.updateActiveState(),this.bubbleToolbar?.onSelectionChange(),this.updateElementPath();let e=z(this.editorEl,this.doc);this.emit(`selectionchange`,e)};onFocus=()=>{this._isFocused=!0,this.containerEl.classList.add(`oe-focused`),this.emit(`focus`,void 0)};onBlur=()=>{this._isFocused=!1,this.containerEl.classList.remove(`oe-focused`),this.emit(`blur`,void 0)};onKeydown=e=>{let t=e.ctrlKey||e.metaKey;if(t&&e.key===`z`){e.preventDefault(),this.chain().undo().run();return}if(t&&(e.key===`y`||e.key===`Z`)){e.preventDefault(),this.chain().redo().run();return}if(t&&e.key===`b`){e.preventDefault(),this.chain().toggleMark(`bold`).run();return}if(t&&e.key===`i`){e.preventDefault(),this.chain().toggleMark(`italic`).run();return}if(t&&e.key===`u`){e.preventDefault(),this.chain().toggleMark(`underline`).run();return}if(t&&e.key==="`"){e.preventDefault(),this.chain().toggleMark(`code`).run();return}for(let t of this.plugins)if(t.keymaps){for(let[n,r]of Object.entries(t.keymaps))if(qe(n,e)){e.preventDefault(),r(this);return}}};onTabInCodeBlock=e=>{if(e.key!==`Tab`)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.anchorNode;for(;n&&n!==this.editorEl;){if(n.nodeType===Node.ELEMENT_NODE&&n.tagName===`PRE`){e.preventDefault(),I(`insertText`,e.shiftKey?``:` `);return}n=n.parentNode}};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/html`),n=e.clipboardData?.getData(`text/plain`)??``;if(this.history.push(this.doc),t&&t.trim())I(`insertHTML`,C(h(t)));else if(n){let e=n.trim();if(We(e)){let t=window.getSelection(),n=t&&!t.isCollapsed?t.toString():``;n?I(`insertHTML`,`<a href="${Ke(e)}" target="_blank" rel="noopener noreferrer">${n}</a>`):I(`insertHTML`,`<a href="${Ke(e)}" target="_blank" rel="noopener noreferrer">${e}</a>`)}else Ge(n)?I(`insertHTML`,C(k(n))):I(`insertText`,n)}this.scheduleSyncFromDOM()};onDrop=e=>{let t=e.dataTransfer?.files;if(!t||t.length===0)return;let n=Array.from(t).find(e=>e.type.startsWith(`image/`));n&&this.options.onImageUpload&&(e.preventDefault(),this.options.onImageUpload(n).then(e=>{let t=H(this.editorEl);this.history.push(this.doc),this.doc=L(this.doc,t,e,n.name),this.rerender()}).catch(()=>{}))};isHTMLMode=!1;toggleHTMLMode(){this.containerEl.querySelector(`.oe-content-wrap`);let e=this.editorEl,t=this.containerEl.querySelector(`.oe-html-source`),n=this.containerEl.querySelector(`.oe-html-textarea`),r=this.containerEl.querySelector(`.oe-html-toggle`);if(!this.isHTMLMode)n.value=this.getHTML(),e.style.display=`none`,t.style.display=``,this.isHTMLMode=!0,r.classList.add(`oe-active`),this.toolbar?.setDisabled(!0);else{let i=n.value;this.history.push(this.doc),this.doc=h(i),e.style.display=``,t.style.display=`none`,this.isHTMLMode=!1,r.classList.remove(`oe-active`),this.toolbar?.setDisabled(!1),this.rerender()}}chain(){let e=[],t=!1,n=this,r={toggleMark(t,i){return e.push(()=>{n.editorEl.focus();let e={bold:`bold`,italic:`italic`,underline:`underline`,strikethrough:`strikethrough`};if(t===`code`)if(U(n.editorEl).has(`code`)){let e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer.parentElement.closest(`code`);if(t){let e=t.textContent??``;t.replaceWith(document.createTextNode(e))}}}else{let e=window.getSelection();if(e&&!e.isCollapsed){let t=e.getRangeAt(0),n=document.createElement(`code`);t.surroundContents(n)}}else if(t===`link`){if(i?.href){let e=i.target??`_self`;Ce(i.href,e)}}else{let n=e[t];n&&I(n)}}),r},setBlock(i,a){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=ve(n.doc,e,i,a)}),r},setAlign(i){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=be(n.doc,e,i)}),r},insertImage(i,a){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=L(n.doc,e,i,a)}),r},insertHr(){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=xe(n.doc,e)}),r},toggleList(i){return t=!0,e.push(()=>{n.doc=F(n.editorEl);let e=H(n.editorEl);n.history.push(n.doc),n.doc=ye(n.doc,e,i)}),r},undo(){return t=!0,e.push(()=>{let e=n.history.undo(n.doc);e&&(n.doc=e)}),r},redo(){return t=!0,e.push(()=>{let e=n.history.redo(n.doc);e&&(n.doc=e)}),r},run(){n.isUpdating=!0;for(let t of e)t();n.isUpdating=!1,t?n.rerender():n.syncModelFromDOM(),n.toolbar?.updateActiveState(),n.emit(`change`,n.doc),n.options.onChange?.(n.getHTML())}};return r}rerender(){z(this.editorEl,this.doc),M(this.doc,this.editorEl),this.updatePlaceholder(),this.updateStatusBar(),this.editorEl.focus()}updateStatusBar(){let e=this.editorEl.innerText??``,t=e.trim().split(/\s+/).filter(e=>e.length>0),n=this.containerEl.querySelector(`.oe-word-count`),r=this.containerEl.querySelector(`.oe-char-count`);n&&(n.textContent=`${this.locale.statusBar.words}: ${t.length}`),r&&(r.textContent=`${this.locale.statusBar.characters}: ${e.length}`)}updateElementPath(){let e=this.containerEl.querySelector(`.oe-statusbar-path`);if(!e)return;let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=[],r=t.anchorNode;for(;r&&r!==this.editorEl;)r.nodeType===Node.ELEMENT_NODE&&n.unshift(r.tagName.toLowerCase()),r=r.parentNode;e.textContent=n.join(` › `)}updatePlaceholder(){if(!this.options.placeholder)return;let e=this.editorEl.innerText.trim()===``&&this.editorEl.querySelectorAll(`img, hr`).length===0;this.editorEl.classList.toggle(`oe-empty`,e)}getHTML(){return C(this.doc)}setHTML(e){this.history.push(this.doc),this.doc=h(e),this.rerender()}getMarkdown(){return D(this.doc)}setMarkdown(e){this.history.push(this.doc),this.doc=k(e),this.rerender()}getDocument(){return this.doc}use(e){return this.plugins.push(e),e.onInit?.(this),this}on(e,t){this.listeners[e].add(t)}off(e,t){this.listeners[e].delete(t)}emit(e,t){this.listeners[e].forEach(e=>e(t))}destroy(){this.syncTimer&&clearTimeout(this.syncTimer),document.removeEventListener(`selectionchange`,this.onSelectionChange),this.editorEl.removeEventListener(`input`,this.onInput),this.editorEl.removeEventListener(`compositionstart`,this.onCompositionStart),this.editorEl.removeEventListener(`compositionend`,this.onCompositionEnd),this.editorEl.removeEventListener(`focus`,this.onFocus),this.editorEl.removeEventListener(`blur`,this.onBlur),this.editorEl.removeEventListener(`keydown`,this.onKeydown),this.editorEl.removeEventListener(`keydown`,this.onTabInCodeBlock),this.editorEl.removeEventListener(`paste`,this.onPaste),this.editorEl.removeEventListener(`drop`,this.onDrop),this.containerEl.querySelector(`.oe-html-toggle`)?.removeEventListener(`click`,this.onHTMLToggleClick),this.bubbleToolbar?.destroy(),this.imageResizer?.destroy(),this.codeLangPicker?.destroy(),this.plugins.forEach(e=>e.onDestroy?.(this)),this.root.innerHTML=``}focus(){this.editorEl.focus()}blur(){this.editorEl.blur()}isFocused(){return this._isFocused}getSelection(){return z(this.editorEl,this.doc)}isMarkActive(e){return U(this.editorEl).has(e)}getActiveBlockType(){return Se(this.editorEl)}isEmpty(){return this.editorEl.innerText.trim()===``&&this.editorEl.querySelectorAll(`img, hr`).length===0}applyTheme(e){this.containerEl.dataset.oeTheme=e}};function We(e){return/^https?:\/\/[^\s]{4,}$/.test(e)}function Ge(e){return/^#{1,6} /m.test(e)||/\*\*[^*]+\*\*/.test(e)||/^```/m.test(e)||/^[-*+] /m.test(e)||/^\d+\. /m.test(e)||/^> /m.test(e)||/~~[^~]+~~/.test(e)}function Ke(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`)}function qe(e,t){let n=e.toLowerCase().split(`+`),r=n[n.length-1],i=n.includes(`ctrl`)||n.includes(`meta`),a=n.includes(`shift`),o=n.includes(`alt`);return t.key.toLowerCase()===r&&(t.ctrlKey||t.metaKey)===i&&t.shiftKey===a&&t.altKey===o}var Y=null;function Je(){return Y||(Y=new Promise((e,t)=>{if(window.hljs){e(window.hljs);return}let n=document.createElement(`script`);n.src=`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js`,n.crossOrigin=`anonymous`,n.onload=()=>e(window.hljs),n.onerror=t,document.head.appendChild(n)}),Y)}var Ye=`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/`,Xe=`${Ye}atom-one-dark.min.css`,Ze=`${Ye}atom-one-light.min.css`;function Qe(e,t){let n=`oe-hljs-theme`,r=document.getElementById(n),i;if(i=typeof t==`string`?t:typeof t==`object`?e?t.dark:t.light:e?Xe:Ze,r){r.href=i;return}let a=document.createElement(`link`);a.id=n,a.rel=`stylesheet`,a.href=i,a.crossOrigin=`anonymous`,document.head.appendChild(a)}function $e(e={}){let t,n=null;function r(e){if(!t)return;let n=e.querySelectorAll(`pre code`),r=document.getSelection()?.anchorNode??null;n.forEach(e=>{let n=e.closest(`pre`);n&&r&&n.contains(r)||(delete e.dataset.highlighted,e.removeAttribute(`data-highlighted`),t.highlightElement(e))})}function i(e){n&&clearTimeout(n),n=setTimeout(()=>r(e),400)}return{name:`highlight`,onInit(n){let a=n.editorEl,o=n.containerEl;Qe(e.theme===`dark`||!e.theme&&o?.dataset.oeTheme===`dark`,e.themeUrl),Je().then(e=>{t=e,t?.configure({ignoreUnescapedHTML:!0}),r(a),n.on(`change`,()=>i(a))}).catch(()=>{console.warn(`[OpenEdit] highlight.js failed to load from CDN`)})},onDestroy(){n&&clearTimeout(n)}}}var et={faces:`😀.😄.😅.😂.🤣.😊.😇.🙂.🙃.😉.😍.🥰.😘.😎.🤓.🤩.🥳.😏.😔.😢.😭.😤.😠.🥺.🤔.🤗.😴.🤯.🥸.😶`.split(`.`),hearts:[`❤️`,`🧡`,`💛`,`💚`,`💙`,`💜`,`🖤`,`🤍`,`🤎`,`💕`,`💞`,`💓`,`💗`,`💖`,`💝`,`💘`,`❣️`,`💔`,`❤️🔥`,`💟`],gestures:[`👋`,`🤚`,`🖐`,`✋`,`🖖`,`👌`,`🤌`,`✌️`,`🤞`,`🤟`,`🤘`,`👈`,`👉`,`👆`,`👇`,`☝️`,`👍`,`👎`,`✊`,`👏`,`🙌`,`🫶`,`🤝`,`🙏`],nature:`🌸.🌺.🌻.🌹.🌷.🍀.🌿.🌱.🌲.🌳.🌴.🍁.🍂.🍃.🌊.🌈.☀️.🌙.⭐.🌟.💫.⚡.🔥.💧.🌍.🦋.🐾`.split(`.`),food:[`🍎`,`🍊`,`🍋`,`🍇`,`🍓`,`🍒`,`🍑`,`🥝`,`🍕`,`🍔`,`🌮`,`🌯`,`🍜`,`🍣`,`🍰`,`🎂`,`☕`,`🍵`,`🧃`,`🥤`,`🍺`,`🥂`,`🍾`],objects:[`💡`,`🔑`,`🎵`,`🎮`,`📱`,`💻`,`📷`,`🎯`,`🏆`,`💎`,`🔮`,`📚`,`✏️`,`📝`,`📌`,`🔔`,`💬`,`📧`,`🚀`,`🎁`,`🧩`,`⚙️`,`🔧`,`🎨`],symbols:[`✅`,`❌`,`⚠️`,`ℹ️`,`💯`,`🔴`,`🟡`,`🟢`,`🔵`,`⚫`,`⚪`,`🔶`,`🔷`,`🔸`,`🔹`,`▶️`,`◀️`,`🔝`,`🔛`,`🆕`,`🆒`,`🆓`,`🆙`,`🏳️`,`🏴`]};function tt(e){let t=e.plugins.emoji.categories;return Object.keys(et).map(e=>({label:t[e],emojis:et[e]}))}var nt=`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>`;function rt(){let e=null,t=null,n=null,r=null,i=W,a=null;function o(){e&&=(e.remove(),null),document.removeEventListener(`click`,s,!0),a?.(),a=null}function s(n){let r=n.target;e&&!e.contains(r)&&!t?.contains(r)&&o()}function c(e){let t=window.getSelection();r&&t?(t.removeAllRanges(),t.addRange(r)):n&&n.focus(),document.execCommand(`insertText`,!1,e),o(),n?.focus()}function l(t){o(),e=document.createElement(`div`),e.className=`oe-emoji-popup`,Object.assign(e.style,{position:`fixed`,zIndex:`99999`,background:`var(--oe-bg, #ffffff)`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`12px`,boxShadow:`0 8px 32px rgba(0,0,0,0.14)`,padding:`10px 12px`,width:`300px`,maxHeight:`260px`,overflowY:`auto`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`});for(let t of tt(i)){let n=document.createElement(`div`);Object.assign(n.style,{fontSize:`10px`,fontWeight:`600`,color:`var(--oe-muted, #78716c)`,textTransform:`uppercase`,letterSpacing:`0.06em`,margin:`6px 0 4px`}),n.textContent=t.label,e.appendChild(n);let r=document.createElement(`div`);Object.assign(r.style,{display:`flex`,flexWrap:`wrap`,gap:`1px`});for(let e of t.emojis){let t=document.createElement(`button`);t.type=`button`,t.textContent=e,t.title=e,Object.assign(t.style,{background:`none`,border:`none`,cursor:`pointer`,padding:`4px`,borderRadius:`6px`,fontSize:`18px`,lineHeight:`1`,transition:`background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.background=`var(--oe-btn-hover-bg, #f5f5f4)`}),t.addEventListener(`mouseleave`,()=>{t.style.background=`none`}),t.addEventListener(`mousedown`,t=>{t.preventDefault(),c(e)}),r.appendChild(t)}e.appendChild(r)}document.body.appendChild(e);let n=t.getBoundingClientRect(),r=n.bottom+4,l=n.left;l+300>window.innerWidth-8&&(l=window.innerWidth-308),l<8&&(l=8),r+260>window.innerHeight-8&&(r=n.top-260-4),e.style.top=`${r}px`,e.style.left=`${l}px`,setTimeout(()=>{document.addEventListener(`click`,s,!0)},0);let u=()=>{o()};window.addEventListener(`scroll`,u,{passive:!0,capture:!0}),a=()=>{window.removeEventListener(`scroll`,u,!0)}}return{name:`emoji`,onInit(a){n=a,i=a.locale??W;let s=a.editorEl,c=a.containerEl?.querySelector(`.oe-toolbar`);if(!c)return;document.addEventListener(`selectionchange`,()=>{let e=window.getSelection();e&&e.rangeCount>0&&s.contains(e.anchorNode)&&(r=e.getRangeAt(0).cloneRange())});let u=document.createElement(`button`);u.type=`button`,u.className=`oe-toolbar-btn`,u.title=i.plugins.emoji.buttonTitle,u.innerHTML=nt,t=u,u.addEventListener(`mousedown`,t=>{t.preventDefault();let n=window.getSelection();n&&n.rangeCount>0&&s.contains(n.anchorNode)&&(r=n.getRangeAt(0).cloneRange()),e?o():l(u)}),c.appendChild(u)},onDestroy(){o(),n=null,r=null}}}var X=/\{\{([^{}]+)\}\}/g;function it(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.classList.contains(`oe-template-tag`)||t.tagName===`TEXTAREA`||t.tagName===`SCRIPT`?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=[],r;for(;r=t.nextNode();)(r.textContent??``).includes(`{{`)&&n.push(r);for(let e of n){let t=e.textContent??``;if(X.lastIndex=0,!X.test(t))continue;X.lastIndex=0;let n=[],r=0,i;for(;(i=X.exec(t))!==null;)i.index>r&&n.push({type:`text`,value:t.slice(r,i.index)}),n.push({type:`tag`,value:i[0]}),r=X.lastIndex;r<t.length&&n.push({type:`text`,value:t.slice(r)});let a=document.createDocumentFragment();for(let e of n)if(e.type===`tag`){let t=document.createElement(`span`);t.className=`oe-template-tag`,t.contentEditable=`false`,t.textContent=e.value,a.appendChild(t)}else e.value&&a.appendChild(document.createTextNode(e.value));e.parentNode?.replaceChild(a,e)}}function at(){let e=null;function t(t){e&&clearTimeout(e),e=setTimeout(()=>it(t),200)}return{name:`template-tags`,onInit(e){let n=e.editorEl;e.on(`change`,()=>t(n)),setTimeout(()=>it(n),100)},onDestroy(){e&&clearTimeout(e)}}}var ot=`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>`,Z={improve:`Improve the following text stylistically and grammatically. Return only the improved text, no explanations.`,shorten:`Shorten the following text to approximately 50% of its length, keeping all important information. Return only the shortened text.`,expand:`Expand the following text with more details, examples, and context. Return only the expanded text.`,summarize:`Summarize the following text in 2-3 concise sentences. Return only the summary.`,toGerman:`Translate the following text to German. Return only the translation.`,toEnglish:`Translate the following text to English. Return only the translation, no explanations.`};function st(e){let t=e.plugins.ai.actions;return[{label:t.improve,prompt:Z.improve},{label:t.shorten,prompt:Z.shorten},{label:t.expand,prompt:Z.expand},{label:t.summarize,prompt:Z.summarize},{label:t.toGerman,prompt:Z.toGerman},{label:t.toEnglish,prompt:Z.toEnglish}]}async function ct(e,t){let n=t.endpoint??`https://api.anthropic.com/v1/messages`,r=t.model??`claude-sonnet-4-6`,i={"content-type":`application/json`};t.apiKey&&!t.endpoint&&(i[`x-api-key`]=t.apiKey,i[`anthropic-version`]=`2023-06-01`,i[`anthropic-dangerous-direct-browser-access`]=`true`);let a=JSON.stringify({model:r,max_tokens:t.maxTokens??2048,system:`You are a professional writing assistant. Follow the user's instruction exactly and return only the desired result — no introduction, no explanation, no commentary.`,messages:[{role:`user`,content:e}]}),o=await fetch(n,{method:`POST`,headers:i,body:a});if(!o.ok){let e=await o.text().catch(()=>o.statusText);throw Error(`API error ${o.status}: ${e}`)}let s=(await o.json())?.content?.[0]?.text;if(!s)throw Error(`Unexpected response format`);return s}function Q(e,t){Object.assign(e.style,t)}function lt(e={}){!e.apiKey&&!e.endpoint&&console.warn(`[OpenEdit AI] No apiKey or endpoint provided — plugin inactive.`);let t=null,n=null,r=null,i=null,a=``,o=W;function s(){t&&=(t.remove(),null),document.removeEventListener(`click`,c,!0)}function c(e){let r=e.target;t&&!t.contains(r)&&!n?.contains(r)&&s()}function l(e){let t=window.getSelection();t&&t.rangeCount>0&&e.contains(t.anchorNode)?(i=t.getRangeAt(0).cloneRange(),a=t.toString().trim()):(i=null,a=r?.getHTML()??``)}function u(e){if(!r)return;let t=window.getSelection();if(i&&t&&a){t.removeAllRanges(),t.addRange(i);let n=C(h(e));document.execCommand(`insertHTML`,!1,n)}else r.setHTML(e);r.focus()}function d(e){s(),t=document.createElement(`div`),Q(t,{position:`fixed`,zIndex:`99999`,background:`var(--oe-bg, #fff)`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`14px`,boxShadow:`0 12px 40px rgba(0,0,0,0.16)`,padding:`16px`,width:`360px`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`});let n=o.plugins.ai,i=document.createElement(`div`);Q(i,{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`12px`}),i.innerHTML=`${ot}<span style="font-size:13px;font-weight:600;color:var(--oe-text,#1c1917)">${n.panelTitle}</span>`,t.appendChild(i);let l=document.createElement(`div`),d=a||n.noSelection;Q(l,{fontSize:`12px`,color:`var(--oe-text-muted, #78716c)`,background:`var(--oe-btn-hover-bg, #f5f5f4)`,borderRadius:`8px`,padding:`8px 10px`,marginBottom:`12px`,maxHeight:`64px`,overflow:`hidden`,lineHeight:`1.5`}),l.textContent=d.length>140?d.slice(0,140)+`…`:d,t.appendChild(l);let p=document.createElement(`div`);Q(p,{display:`flex`,flexWrap:`wrap`,gap:`6px`,marginBottom:`12px`});for(let e of st(o)){let t=document.createElement(`button`);t.type=`button`,t.textContent=e.label,Q(t,{padding:`5px 10px`,fontSize:`12px`,fontWeight:`500`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`6px`,background:`var(--oe-bg, #fff)`,color:`var(--oe-text, #1c1917)`,cursor:`pointer`,fontFamily:`inherit`,transition:`background 0.1s`}),t.addEventListener(`mouseenter`,()=>{t.style.background=`var(--oe-btn-hover-bg, #f5f5f4)`}),t.addEventListener(`mouseleave`,()=>{t.style.background=`var(--oe-bg, #fff)`}),t.addEventListener(`click`,()=>{let t=a||r?.getHTML()||``;f(`${e.prompt}\n\n${t}`,_,v)}),p.appendChild(t)}t.appendChild(p);let m=document.createElement(`div`);Q(m,{display:`flex`,gap:`6px`,marginBottom:`12px`});let h=document.createElement(`textarea`);h.placeholder=n.customPromptPlaceholder,h.rows=2,Q(h,{flex:`1`,padding:`8px 10px`,fontSize:`12px`,border:`1px solid var(--oe-border, #e7e5e4)`,borderRadius:`8px`,background:`var(--oe-bg, #fff)`,color:`var(--oe-text, #1c1917)`,fontFamily:`inherit`,resize:`none`,outline:`none`});let g=document.createElement(`button`);g.type=`button`,g.textContent=n.runButton,Q(g,{padding:`0 14px`,fontSize:`12px`,fontWeight:`600`,border:`none`,borderRadius:`8px`,background:`#1c1917`,color:`#fff`,cursor:`pointer`,fontFamily:`inherit`,alignSelf:`stretch`}),g.addEventListener(`click`,()=>{let e=a||r?.getHTML()||``,t=h.value.trim();t&&f(`${t}\n\n${e}`,_,v)}),m.appendChild(h),m.appendChild(g),t.appendChild(m);let _=document.createElement(`div`);Q(_,{display:`none`,fontSize:`12px`,color:`var(--oe-text, #1c1917)`,background:`var(--oe-btn-hover-bg, #f5f5f4)`,borderRadius:`8px`,padding:`10px`,marginBottom:`10px`,lineHeight:`1.6`,maxHeight:`120px`,overflowY:`auto`}),t.appendChild(_);let v=document.createElement(`button`);v.type=`button`,v.textContent=n.applyButton,v.style.display=`none`,Q(v,{width:`100%`,padding:`9px`,fontSize:`13px`,fontWeight:`600`,border:`none`,borderRadius:`8px`,background:`#1c1917`,color:`#fff`,cursor:`pointer`,fontFamily:`inherit`}),v.addEventListener(`click`,()=>{let e=_.dataset.result??``;e&&(u(e),s())}),t.appendChild(v),document.body.appendChild(t);let y=e.getBoundingClientRect(),b=y.bottom+4,x=y.left;x+360>window.innerWidth-8&&(x=window.innerWidth-368),x<8&&(x=8),b+400>window.innerHeight-8&&(b=y.top-400-4),t.style.top=`${b}px`,t.style.left=`${x}px`,setTimeout(()=>{document.addEventListener(`click`,c,!0)},0)}async function f(t,n,r){let i=o.plugins.ai;if(!e.apiKey&&!e.endpoint){n.style.display=`block`,n.textContent=i.noApiKey;return}n.style.display=`block`,n.textContent=i.generating,r.style.display=`none`;try{let i=await ct(t,e);n.textContent=i.length>400?i.slice(0,400)+`…`:i,n.dataset.result=i,r.style.display=`block`}catch(e){n.textContent=`${i.errorPrefix}${e instanceof Error?e.message:String(e)}`}}return{name:`ai-assistant`,onInit(e){r=e,o=e.locale??W;let c=e.editorEl,u=e.containerEl?.querySelector(`.oe-toolbar`);if(!u)return;document.addEventListener(`selectionchange`,()=>{let e=window.getSelection();e&&e.rangeCount>0&&c.contains(e.anchorNode)&&(i=e.getRangeAt(0).cloneRange(),a=e.isCollapsed?``:e.toString().trim())});let f=document.createElement(`div`);f.className=`oe-toolbar-sep`;let p=document.createElement(`button`);p.type=`button`,p.className=`oe-toolbar-btn`,p.title=o.plugins.ai.panelTitle,p.innerHTML=ot,Q(p,{color:`rgb(99,102,241)`}),n=p,p.addEventListener(`mousedown`,e=>{e.preventDefault(),l(c),t?s():d(p)}),u.appendChild(f),u.appendChild(p),c.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&!e.shiftKey){let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),r=n.startContainer.textContent??``;if(r.trim()===`/ai`){e.preventDefault();let t=document.createRange();t.setStart(n.startContainer,0),t.setEnd(n.startContainer,r.length),t.deleteContents(),l(c),d(p)}}})},onDestroy(){s(),r=null}}}var ut={"/callout":`info`,"/callout-info":`info`,"/callout-success":`success`,"/callout-warning":`warning`,"/callout-danger":`danger`};function dt(){let e=null,t=null,n=n=>{if(n.key!==`Enter`||n.shiftKey||!e)return;let r=window.getSelection();if(!r||r.rangeCount===0)return;let i=r.getRangeAt(0);if(!i.collapsed)return;let a=i.startContainer;for(;a&&a.parentNode!==e;)a=a.parentNode;if(!a||a.nodeType!==Node.ELEMENT_NODE)return;let o=ut[(a.textContent?.trim()??``).toLowerCase()];o&&(n.preventDefault(),a.innerHTML=``,t?.chain().setBlock(`callout`,{variant:o}).run())};return{name:`callout`,onInit(r){t=r,e=r.editorEl,e&&e.addEventListener(`keydown`,n)},onDestroy(r){e&&e.removeEventListener(`keydown`,n),e=null,t=null},keymaps:{"ctrl+shift+i":e=>(e.chain().setBlock(`callout`,{variant:`info`}).run(),!0)}}}var ft=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 4v16"/><path d="M17 4H9.5a4.5 4.5 0 0 0 0 9H13"/></svg>`,pt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`,mt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,ht=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1.5" fill="currentColor" stroke="none"/></svg>`,gt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">1.</text><text x="2" y="15" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">2.</text><text x="2" y="21" font-size="7" fill="currentColor" stroke="none" font-family="sans-serif" font-weight="700">3.</text></svg>`,_t=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="2" y1="12" x2="22" y2="12"/></svg>`,vt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`,yt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>`,bt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>`,xt=`<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>`;function $(e){return`<span style="font-size:11px;font-weight:700;letter-spacing:-0.5px;line-height:1">H${e}</span>`}function St(){return[{id:`paragraph`,title:`Paragraph`,description:`Plain text block`,icon:ft,keywords:[`paragraph`,`text`,`p`,`normal`],execute:e=>e.chain().setBlock(`paragraph`).run()},{id:`h1`,title:`Heading 1`,description:`Large section title`,icon:$(1),keywords:[`heading`,`h1`,`heading1`,`title`,`1`],execute:e=>e.chain().setBlock(`heading`,{level:1}).run()},{id:`h2`,title:`Heading 2`,description:`Medium section title`,icon:$(2),keywords:[`heading`,`h2`,`heading2`,`2`],execute:e=>e.chain().setBlock(`heading`,{level:2}).run()},{id:`h3`,title:`Heading 3`,description:`Small section title`,icon:$(3),keywords:[`heading`,`h3`,`heading3`,`3`],execute:e=>e.chain().setBlock(`heading`,{level:3}).run()},{id:`h4`,title:`Heading 4`,icon:$(4),keywords:[`heading`,`h4`,`heading4`,`4`],execute:e=>e.chain().setBlock(`heading`,{level:4}).run()},{id:`h5`,title:`Heading 5`,icon:$(5),keywords:[`heading`,`h5`,`heading5`,`5`],execute:e=>e.chain().setBlock(`heading`,{level:5}).run()},{id:`h6`,title:`Heading 6`,icon:$(6),keywords:[`heading`,`h6`,`heading6`,`6`],execute:e=>e.chain().setBlock(`heading`,{level:6}).run()},{id:`quote`,title:`Blockquote`,description:`Indented citation block`,icon:pt,keywords:[`quote`,`blockquote`,`bq`,`citation`],execute:e=>e.chain().setBlock(`blockquote`).run()},{id:`code`,title:`Code Block`,description:`Monospace preformatted code`,icon:mt,keywords:[`code`,`codeblock`,`pre`,`monospace`,`snippet`],execute:e=>e.chain().setBlock(`code_block`).run()},{id:`bullet`,title:`Bullet List`,description:`Unordered list with dots`,icon:ht,keywords:[`ul`,`bullet`,`bulletlist`,`unordered`,`list`,`-`],execute:e=>e.chain().toggleList(`bullet_list`).run()},{id:`numbered`,title:`Numbered List`,description:`Ordered numbered list`,icon:gt,keywords:[`ol`,`numbered`,`orderedlist`,`ordered`,`list`,`1`],execute:e=>e.chain().toggleList(`ordered_list`).run()},{id:`hr`,title:`Divider`,description:`Horizontal rule`,icon:_t,keywords:[`hr`,`divider`,`separator`,`rule`,`---`],execute:e=>e.chain().insertHr().run()},{id:`callout-info`,title:`Callout: Info`,description:`Blue informational callout`,icon:vt,keywords:[`callout`,`info`,`note`,`callout-info`],execute:e=>e.chain().setBlock(`callout`,{variant:`info`}).run()},{id:`callout-success`,title:`Callout: Success`,description:`Green success callout`,icon:yt,keywords:[`callout`,`success`,`done`,`callout-success`],execute:e=>e.chain().setBlock(`callout`,{variant:`success`}).run()},{id:`callout-warning`,title:`Callout: Warning`,description:`Yellow warning callout`,icon:bt,keywords:[`callout`,`warning`,`warn`,`caution`,`callout-warning`],execute:e=>e.chain().setBlock(`callout`,{variant:`warning`}).run()},{id:`callout-danger`,title:`Callout: Danger`,description:`Red danger or error callout`,icon:xt,keywords:[`callout`,`danger`,`error`,`callout-danger`],execute:e=>e.chain().setBlock(`callout`,{variant:`danger`}).run()}]}var Ct=`oe-slash-menu-styles`;function wt(){if(document.getElementById(Ct))return;let e=document.createElement(`style`);e.id=Ct,e.textContent=`
|
|
698
698
|
.oe-slash-menu {
|
|
699
699
|
position: fixed;
|
|
700
700
|
z-index: 10000;
|
|
@@ -779,5 +779,5 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
779
779
|
<div class="oe-slash-menu-title">${e.title}</div>
|
|
780
780
|
${e.description?`<div class="oe-slash-menu-desc">${e.description}</div>`:``}
|
|
781
781
|
</div>
|
|
782
|
-
</div>`).join(``),i.querySelector(`.oe-slash-active`)?.scrollIntoView({block:`nearest`})}}function p(){if(!i)return;a=!0,i.style.display=`block`;let{top:e,left:t}=u();i.style.top=`${e}px`,i.style.left=`${t}px`,requestAnimationFrame(()=>{if(!i)return;let n=d(i,e,t);i.style.top=`${n.top}px`,i.style.left=`${n.left}px`}),f()}function m(){i&&(a=!1,i.style.display=`none`,i.innerHTML=``,o=0,s=[])}function h(e){if(!r||!n)return;let t=c(),i=-1;if(t){let e=t.blockEl;i=Array.from(n.children).indexOf(e),e.innerHTML=``;let r=window.getSelection();if(r){let t=document.createRange();t.setStart(e,0),t.collapse(!0),r.removeAllRanges(),r.addRange(t)}}m(),e.execute(r),i>=0&&requestAnimationFrame(()=>{if(!n)return;let e=n.children[i];if(!e)return;let t=g(e),r=window.getSelection();if(!r)return;let a=document.createRange();if(t)a.setStart(t,t.length);else if(e instanceof HTMLElement&&e.tagName===`HR`){let t=n.children[i+1]??e;a.setStart(t,0)}else a.setStart(e,0);a.collapse(!0),r.removeAllRanges(),r.addRange(a)})}function g(e){for(let t=e.childNodes.length-1;t>=0;t--){let n=g(e.childNodes[t]);if(n)return n}return e.nodeType===Node.TEXT_NODE?e:null}let _=()=>{let e=c();if(!e){a&&m();return}let{query:t}=e;s=l(t),o>=s.length&&(o=0),s.length,p()},v=e=>{if(a)switch(e.key){case`ArrowDown`:e.preventDefault(),e.stopImmediatePropagation(),o=(o+1)%Math.max(s.length,1),f();break;case`ArrowUp`:e.preventDefault(),e.stopImmediatePropagation(),o=(o-1+Math.max(s.length,1))%Math.max(s.length,1),f();break;case`Enter`:s.length>0&&s[o]&&(e.preventDefault(),e.stopImmediatePropagation(),h(s[o]));break;case`Escape`:e.preventDefault(),e.stopImmediatePropagation(),m();break;case`Tab`:s.length>0&&s[o]&&(e.preventDefault(),e.stopImmediatePropagation(),h(s[o]));break}},y=e=>{!a||!i||i.contains(e.target)||m()},b=e=>{let t=e.target.closest(`.oe-slash-menu-item`);if(!t)return;let n=parseInt(t.dataset.index??`0`,10),r=s[n];r&&h(r)},x=()=>{a&&m()};return{name:`slash-commands`,onInit(e){r=e,n=e.editorEl,n&&(wt(),i=document.createElement(`div`),i.className=`oe-slash-menu`,i.style.display=`none`,document.body.appendChild(i),n.addEventListener(`keydown`,v,!0),n.addEventListener(`input`,_),i.addEventListener(`click`,b),document.addEventListener(`click`,y,!0),window.addEventListener(`scroll`,x,{passive:!0}))},onDestroy(e){n&&(n.removeEventListener(`keydown`,v,!0),n.removeEventListener(`input`,_)),i&&=(i.removeEventListener(`click`,b),i.remove(),null),document.removeEventListener(`click`,y,!0),window.removeEventListener(`scroll`,x),n=null,r=null,a=!1}}}function Et(e,t){return new Ue({element:e,...t})}var Dt={create:Et,version:`0.1.
|
|
782
|
+
</div>`).join(``),i.querySelector(`.oe-slash-active`)?.scrollIntoView({block:`nearest`})}}function p(){if(!i)return;a=!0,i.style.display=`block`;let{top:e,left:t}=u();i.style.top=`${e}px`,i.style.left=`${t}px`,requestAnimationFrame(()=>{if(!i)return;let n=d(i,e,t);i.style.top=`${n.top}px`,i.style.left=`${n.left}px`}),f()}function m(){i&&(a=!1,i.style.display=`none`,i.innerHTML=``,o=0,s=[])}function h(e){if(!r||!n)return;let t=c(),i=-1;if(t){let e=t.blockEl;i=Array.from(n.children).indexOf(e),e.innerHTML=``;let r=window.getSelection();if(r){let t=document.createRange();t.setStart(e,0),t.collapse(!0),r.removeAllRanges(),r.addRange(t)}}m(),e.execute(r),i>=0&&requestAnimationFrame(()=>{if(!n)return;let e=n.children[i];if(!e)return;let t=g(e),r=window.getSelection();if(!r)return;let a=document.createRange();if(t)a.setStart(t,t.length);else if(e instanceof HTMLElement&&e.tagName===`HR`){let t=n.children[i+1]??e;a.setStart(t,0)}else a.setStart(e,0);a.collapse(!0),r.removeAllRanges(),r.addRange(a)})}function g(e){for(let t=e.childNodes.length-1;t>=0;t--){let n=g(e.childNodes[t]);if(n)return n}return e.nodeType===Node.TEXT_NODE?e:null}let _=()=>{let e=c();if(!e){a&&m();return}let{query:t}=e;s=l(t),o>=s.length&&(o=0),s.length,p()},v=e=>{if(a)switch(e.key){case`ArrowDown`:e.preventDefault(),e.stopImmediatePropagation(),o=(o+1)%Math.max(s.length,1),f();break;case`ArrowUp`:e.preventDefault(),e.stopImmediatePropagation(),o=(o-1+Math.max(s.length,1))%Math.max(s.length,1),f();break;case`Enter`:s.length>0&&s[o]&&(e.preventDefault(),e.stopImmediatePropagation(),h(s[o]));break;case`Escape`:e.preventDefault(),e.stopImmediatePropagation(),m();break;case`Tab`:s.length>0&&s[o]&&(e.preventDefault(),e.stopImmediatePropagation(),h(s[o]));break}},y=e=>{!a||!i||i.contains(e.target)||m()},b=e=>{let t=e.target.closest(`.oe-slash-menu-item`);if(!t)return;let n=parseInt(t.dataset.index??`0`,10),r=s[n];r&&h(r)},x=()=>{a&&m()};return{name:`slash-commands`,onInit(e){r=e,n=e.editorEl,n&&(wt(),i=document.createElement(`div`),i.className=`oe-slash-menu`,i.style.display=`none`,document.body.appendChild(i),n.addEventListener(`keydown`,v,!0),n.addEventListener(`input`,_),i.addEventListener(`click`,b),document.addEventListener(`click`,y,!0),window.addEventListener(`scroll`,x,{passive:!0}))},onDestroy(e){n&&(n.removeEventListener(`keydown`,v,!0),n.removeEventListener(`input`,_)),i&&=(i.removeEventListener(`click`,b),i.remove(),null),document.removeEventListener(`click`,y,!0),window.removeEventListener(`scroll`,x),n=null,r=null,a=!1}}}function Et(e,t){return new Ue({element:e,...t})}var Dt={create:Et,version:`0.1.2`,locales:{en:W,de:J},plugins:{highlight:$e,emoji:rt,templateTags:at,ai:lt,callout:dt,slashCommands:Tt},markdown:{serialize:D,deserialize:k}};exports.Editor=Ue,exports.OpenEdit=Dt,exports.default=Dt,exports.createAIPlugin=lt,exports.createCalloutPlugin=dt,exports.createEmojiPlugin=rt,exports.createHighlightPlugin=$e,exports.createSlashCommandsPlugin=Tt,exports.createTemplateTagPlugin=at,exports.de=J,exports.deserializeMarkdown=k,exports.en=W,exports.serializeToMarkdown=D;
|
|
783
783
|
//# sourceMappingURL=open-edit.cjs.js.map
|