@mrakomor/core 0.0.10 → 0.0.11

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.
@@ -1,3 +1,3 @@
1
- import {a}from'./chunk-B6JJAATK.mjs';import {c}from'./chunk-YHWQV2DB.mjs';import {o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var o="mrakomor/core/plugin/blockChrome/BlockChrome.css",r=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(c){return c.getAttribute("data-mrakomor-css-path")===o});if(!r){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",o),e.textContent=`.mrakomor-block-element{position:relative;padding-left:52px;margin-bottom:12px}.mrakomor-block-gutter{position:absolute;left:0;top:2px;display:flex;align-items:center;gap:2px;opacity:0;transition:opacity .15s ease;pointer-events:all;user-select:none;z-index:1}.mrakomor-block-element:hover .mrakomor-block-gutter,.mrakomor-block-element--active .mrakomor-block-gutter,.mrakomor-block-drag-active .mrakomor-block-gutter{opacity:1}.mrakomor-block-add,.mrakomor-block-drag{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:#9ca3af;cursor:pointer;font-size:18px;line-height:1;transition:background .1s,color .1s}.mrakomor-block-add:hover,.mrakomor-block-drag:hover{background:#0000000f;color:#374151}.mrakomor-block-drag{cursor:grab}.mrakomor-block-element--dragging .mrakomor-block-drag,.mrakomor-block-drag-active .mrakomor-block-drag{cursor:grabbing}.mrakomor-block-element--dragging{opacity:.5}.mrakomor-block-body{min-width:0}.mrakomor-block-drop-indicator{position:absolute;left:52px;right:0;height:2px;background:#3b82f6;border-radius:1px;pointer-events:none;z-index:2}
1
+ import {a}from'./chunk-B6JJAATK.mjs';import {c}from'./chunk-SCFD3XBH.mjs';import {o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var o="mrakomor/core/plugin/blockChrome/BlockChrome.css",r=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(c){return c.getAttribute("data-mrakomor-css-path")===o});if(!r){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",o),e.textContent=`.mrakomor-block-element{position:relative;padding-left:52px;margin-bottom:12px}.mrakomor-block-gutter{position:absolute;left:0;top:2px;display:flex;align-items:center;gap:2px;opacity:0;transition:opacity .15s ease;pointer-events:all;user-select:none;z-index:1}.mrakomor-block-element:hover .mrakomor-block-gutter,.mrakomor-block-element--active .mrakomor-block-gutter,.mrakomor-block-drag-active .mrakomor-block-gutter{opacity:1}.mrakomor-block-add,.mrakomor-block-drag{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:#9ca3af;cursor:pointer;font-size:18px;line-height:1;transition:background .1s,color .1s}.mrakomor-block-add:hover,.mrakomor-block-drag:hover{background:#0000000f;color:#374151}.mrakomor-block-drag{cursor:grab}.mrakomor-block-element--dragging .mrakomor-block-drag,.mrakomor-block-drag-active .mrakomor-block-drag{cursor:grabbing}.mrakomor-block-element--dragging{opacity:.5}.mrakomor-block-body{min-width:0}.mrakomor-block-drop-indicator{position:absolute;left:52px;right:0;height:2px;background:#3b82f6;border-radius:1px;pointer-events:none;z-index:2}
2
2
  `,document.head.appendChild(e);}}})();var b='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true"><circle cx="4" cy="3" r="1.2"/><circle cx="10" cy="3" r="1.2"/><circle cx="4" cy="7" r="1.2"/><circle cx="10" cy="7" r="1.2"/><circle cx="4" cy="11" r="1.2"/><circle cx="10" cy="11" r="1.2"/></svg>';function f(o,r){for(let e=0;e<r.length;e++){let c=r[e].getBoundingClientRect();if(o<c.top+c.height/2)return e}return r.length}function y(o,r,e,c){if(!o||!r)return;if(e>=c.length){let t=c[c.length-1];if(!t){o.style.display="none";return}let n=r.getBoundingClientRect(),a=t.getBoundingClientRect();o.style.display="block",o.style.top=`${a.bottom-n.top}px`;return}let d=c[e],m=r.getBoundingClientRect(),s=d.getBoundingClientRect();o.style.display="block",o.style.top=`${s.top-m.top}px`;}function k(){return o("div",{className:"mrakomor-block-gutter",contentEditable:false},[o("button",{type:"button",className:"mrakomor-block-add","aria-label":"Insert block",contentEditable:false},"+"),o("button",{type:"button",className:"mrakomor-block-drag","aria-label":"Drag to reorder",contentEditable:false,$dangerouslySetInnerHTML:b})])}function h({mrakomor:o$1}){let r=null,e=null;function c$1(){e?.blockElement&&e.blockElement.classList.remove("mrakomor-block-element--active","mrakomor-block-element--dragging"),e?.handle&&e.handle.releasePointerCapture?.(e.pointerId),r&&(r.style.display="none"),document.body.classList.remove("mrakomor-block-drag-active"),e=null;}function d(t){if(!e||t.pointerId!==e.pointerId)return;let n=o$1.getRoot()?.querySelector(".mrakomor-content");if(!n)return;let a=[...n.querySelectorAll(".mrakomor-block-element")],l=f(t.clientY,a);e.targetIndex=l,y(r,n,l,a);}function m(t){if(!e||t.pointerId!==e.pointerId)return;let{blockElement:n,targetIndex:a}=e;c$1(),o$1.command.moveBlockElement({blockElement:n,targetIndex:a});}function s(t){let n=t.target.closest?.(".mrakomor-block-drag");if(!n)return;t.preventDefault(),t.stopPropagation();let a=n.closest(".mrakomor-block-element");if(!a)return;e&&c$1();let l=o$1._getBlockElementIndex(a);if(l===-1)return;let p=t.pointerId??1;n.setPointerCapture?.(p),a.classList.add("mrakomor-block-element--active","mrakomor-block-element--dragging"),document.body.classList.add("mrakomor-block-drag-active"),e={blockElement:a,pointerId:p,handle:n,fromIndex:l,targetIndex:l};}return {wrapBlockElement(t){return [o(k),o("div",{className:"mrakomor-block-body",[c]:true},t)]},registerHandlers(){o$1.emitter.on(a.CLICK,t=>{let n=t.target?.closest?.(".mrakomor-block-add");if(!n)return;t.preventDefault?.(),t.stopPropagation?.();let a=n.closest(".mrakomor-block-element");a&&o$1.command.openBlockInsertMenu({blockElement:a,anchorRect:n.getBoundingClientRect()});}),o$1.emitter.on(a.KEYDOWN,t=>{t.key==="Escape"&&e&&c$1();});},onMount(){let{signal:t}=o$1.listenerAbortController;document.addEventListener("pointerdown",s,{capture:true,signal:t});let n=o$1.getRoot()?.querySelector(".mrakomor-content");n&&(r=document.createElement("div"),r.className="mrakomor-block-drop-indicator",r.style.display="none",n.append(r)),document.addEventListener("pointermove",d,{signal:t}),document.addEventListener("pointerup",m,{signal:t}),document.addEventListener("pointercancel",m,{signal:t});},onUnmount(){c$1(),r?.remove(),r=null;}}}
3
3
  export{k as BlockChrome,h as blockChromePlugin};
@@ -1 +1 @@
1
- import {a}from'./chunk-B6JJAATK.mjs';import {a as a$1}from'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';function _({mrakomor:n}){let l=null,i;function s(){l&&l.classList.remove("mrakomor-block-element--active"),l=null,i=void 0;}function m(){let e=n._getBlockElementIndex(l);return e!==-1?n._getBlockElements()[e]:n._getBlockElementByComponentId(i)}function r(e){let o=m();if(!o||!e?.component)return;let c=e.component.NAMESPACE,u=e.component.getStateSchema().parse({componentId:a$1(),component:c,...e.settings?{settings:e.settings}:{}});n.command.insertBlockElement({blockElement:o,namespace:c,newLineState:u,cursor:0}),s(),n.command.closeMenu();}return {registerEvents(){a.OPEN_BLOCK_INSERT_MENU="mrakomor:open-block-insert-menu",a.CLOSE_BLOCK_INSERT_MENU="mrakomor:close-block-insert-menu";},registerCommands(e){e.command.openBlockInsertMenu=({blockElement:o,anchorRect:c})=>{e.emit(a.OPEN_BLOCK_INSERT_MENU,{blockElement:o,anchorRect:c});},e.command.closeBlockInsertMenu=()=>{e.emit(a.CLOSE_BLOCK_INSERT_MENU);};},registerHandlers(){n.emitter.on(a.OPEN_BLOCK_INSERT_MENU,({blockElement:e,anchorRect:o})=>{s(),l=e,i=n._getBlockElementState(e)?.componentId,e?.classList.add("mrakomor-block-element--active"),n.command.closeTooltip?.();let c=n.register.blocks.list();n.command.openMenu({entries:c,anchorRect:o,highlightIndex:-1,ariaLabel:"Insert block",onSelect:r});}),n.emitter.on(a.CLOSE_BLOCK_INSERT_MENU,()=>{s(),n.command.closeMenu();}),n.emitter.on(a.CLOSE_MENU,s);}}}export{_ as blockInsertMenuPlugin};
1
+ import {a}from'./chunk-B6JJAATK.mjs';import {a as a$1}from'./chunk-SCFD3XBH.mjs';import'./chunk-K2DMHAUD.mjs';function _({mrakomor:n}){let l=null,i;function s(){l&&l.classList.remove("mrakomor-block-element--active"),l=null,i=void 0;}function m(){let e=n._getBlockElementIndex(l);return e!==-1?n._getBlockElements()[e]:n._getBlockElementByComponentId(i)}function r(e){let o=m();if(!o||!e?.component)return;let c=e.component.NAMESPACE,u=e.component.getStateSchema().parse({componentId:a$1(),component:c,...e.settings?{settings:e.settings}:{}});n.command.insertBlockElement({blockElement:o,namespace:c,newLineState:u,cursor:0}),s(),n.command.closeMenu();}return {registerEvents(){a.OPEN_BLOCK_INSERT_MENU="mrakomor:open-block-insert-menu",a.CLOSE_BLOCK_INSERT_MENU="mrakomor:close-block-insert-menu";},registerCommands(e){e.command.openBlockInsertMenu=({blockElement:o,anchorRect:c})=>{e.emit(a.OPEN_BLOCK_INSERT_MENU,{blockElement:o,anchorRect:c});},e.command.closeBlockInsertMenu=()=>{e.emit(a.CLOSE_BLOCK_INSERT_MENU);};},registerHandlers(){n.emitter.on(a.OPEN_BLOCK_INSERT_MENU,({blockElement:e,anchorRect:o})=>{s(),l=e,i=n._getBlockElementState(e)?.componentId,e?.classList.add("mrakomor-block-element--active"),n.command.closeTooltip?.();let c=n.register.blocks.list();n.command.openMenu({entries:c,anchorRect:o,highlightIndex:-1,ariaLabel:"Insert block",onSelect:r});}),n.emitter.on(a.CLOSE_BLOCK_INSERT_MENU,()=>{s(),n.command.closeMenu();}),n.emitter.on(a.CLOSE_MENU,s);}}}export{_ as blockInsertMenuPlugin};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-T7OO472O.mjs';import {a as a$1}from'./chunk-P7IKAZYZ.mjs';import {j,k,l,u,m}from'./chunk-ZDMD7SRT.mjs';import {a as a$2}from'./chunk-B6JJAATK.mjs';import {t}from'./chunk-SCFD3XBH.mjs';import {n,p,k as k$1}from'./chunk-K2DMHAUD.mjs';var r=class extends p{state;element;mrakomor;constructor(e){super(e);let{state:t,observeDOMChanges:s=true}=e??{};this.state=t,this.element=null,this.mrakomor=k$1(a),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=s;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return a$1.object({component:a$1.string().default(this.NAMESPACE),properties:a$1.object().default({}),settings:a$1.object().default({})}).default({})}static getPropsSchema(){return a$1.object({state:this.getStateSchema(),observeDOMChanges:a$1.boolean().default(true)}).default({})}parseFromHTML(e){return this.constructor.getStateSchema(e).parse()}getState(){if(this._stale){let e=this.element;return this.parseFromHTML(e)}return this.state.peek()}isStale(){return this._stale}#t(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#t();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=e=>{let t=e.target;t instanceof Node&&this.element?.contains(t)&&this.#t();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(a$2.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var S=class extends r{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(e){let t$1=()=>{if(!this.element?.isConnected)return;let s=typeof e=="number"?e:j(this.getState()?.properties?.text).length;t(this.element,s);};t$1(),n(t$1);}onKeydown(e){}static toExchangeState(e){let t=e?.properties,s={text:j(t?.text)};return t?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=t.inlineStyleRanges),t?.entityRanges!==void 0&&(s.entityRanges=t.entityRanges),k({originComponent:this.NAMESPACE,properties:{items:[s]},settings:e?.settings})}static fromExchangeState(e){let t=e?.properties?.items?.[0];return {properties:{text:t?.text??"",inlineStyleRanges:t?.inlineStyleRanges??[],entityRanges:t?.entityRanges??[]},settings:e?.settings}}static appendExchangeState(e,t){let s=l(t?.properties?.items);return u(e,m(s))}};export{S as a};
@@ -0,0 +1,2 @@
1
+ import {a as a$1}from'./chunk-2VURZA2E.mjs';import {b as b$1,a as a$6}from'./chunk-VYTSZ4S6.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {b,j,k,a as a$4,m,l,u,t as t$1,s,w,p as p$1,q as q$1}from'./chunk-ZDMD7SRT.mjs';import {a as a$5}from'./chunk-B6JJAATK.mjs';import {a,f,d,v,k as k$1,j as j$1,t,p}from'./chunk-SCFD3XBH.mjs';import {q,o,a as a$3,n}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var n="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===n});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",n),e.textContent=`.molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth="1"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth="2"]{margin-inline-start:3em}.molecule-list-list li[data-depth="3"]{margin-inline-start:4.5em}
2
+ `,document.head.appendChild(e);}}})();function X(n){if(n?.nodeName==="OL")return "ORDERED";if(n?.nodeName==="UL")return "UNORDERED"}function T(n=[]){let t=new Set;return n.map(e=>{if(e?.componentId&&!t.has(e.componentId))return t.add(e.componentId),e;let r=a();return t.add(r),{...e,componentId:r}})}function Y(n){return n?[...n.children].filter(t=>t.nodeName==="LI"):[]}function M(n,t){return !n||!t?0:p(n,t.startContainer,t.startOffset)}function Z(n,t){let e=m(n),{originalLineState:r,newLineState:s}=w(e,t);return {before:{componentId:n.componentId,depth:n.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:a(),depth:n.depth??0,text:s.properties.text,inlineStyleRanges:s.properties.inlineStyleRanges??[],entityRanges:s.properties.entityRanges??[]}}}function tt(n,{style:t="UNORDERED"}={}){let e=n?.properties?.items,r=Array.isArray(e)&&e.length?e.map(s=>({componentId:s?.componentId??a(),depth:s?.depth??0,text:j(s?.text??""),inlineStyleRanges:[...s?.inlineStyleRanges??[]],entityRanges:[...s?.entityRanges??[]]})):[{componentId:a(),depth:0,text:j(n?.properties?.text??""),inlineStyleRanges:[...n?.properties?.inlineStyleRanges??[]],entityRanges:[...n?.properties?.entityRanges??[]]}];return {component:b,componentId:a(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function P(n,t,{namespace:e=a$4,Constructor:r}={}){let s=n.properties?.items??[],o=s[t];if(!o)return {blocks:[n],paragraphIndex:0};let c=s.slice(0,t),i=s.slice(t+1),a$1=k({properties:{text:o.text,inlineStyleRanges:o.inlineStyleRanges,entityRanges:o.entityRanges}}),l={component:e,componentId:a(),settings:{},...r?.fromExchangeState(a$1)??m(o)},p=[];return c.length&&p.push({...n,properties:{...n.properties,items:c}}),p.push(l),i.length&&p.push({...n,componentId:c.length?a():n.componentId,properties:{...n.properties,items:i}}),{blocks:p,paragraphIndex:c.length?1:0}}function W(n){return q$1(n)?n.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function ct(n,t){let e=W(n),r=W(t);return e!=null&&e===r}function et(n,t,e){if(t<0||e!==t+1||e>=n.length)return null;let r=n[t],s=n[e];if(!ct(r,s))return null;let o=[...r.properties?.items??[]],c=[...s.properties?.items??[]];if(c.length===0){let m=[...n];m.splice(e,1);let h=o.length-1,D=h>=0?j(o[h]?.text).length:0;return {content:m,listIndex:t,cursor:D}}let[i,...a]=c,l=0;if(o.length===0)o.push(i,...a),l=0;else {let m$1=o.length-1,h=o[m$1],D=m(h),ot=m(i),{state:N,cursor:it}=u(D,ot);o[m$1]={...h,text:N.properties.text,inlineStyleRanges:N.properties.inlineStyleRanges,entityRanges:N.properties.entityRanges},a.length&&o.push(...a),l=it;}let p={...r,properties:{...r.properties,items:T(o)}},u$1=[...n];return u$1[t]=p,u$1.splice(e,1),{content:u$1,listIndex:t,cursor:l}}function nt(n,t){let e=n.properties?.items??[],r=e.length-1;if(r<0)return null;let s=e[r],o=m(s),c=l(k({properties:t?.properties}).properties.items),i=m(c),{state:a,cursor:l$1}=u(o,i);return {state:{...n,properties:{...n.properties,items:e.map((p,u)=>u===r?{...p,text:a.properties.text,inlineStyleRanges:a.properties.inlineStyleRanges,entityRanges:a.properties.entityRanges}:p)}},cursor:l$1}}function rt(n,t){return s({properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]}},t)}function st(n,t){let e=Number(n.getAttribute("data-depth")??0)||0,r={properties:{text:j(n.innerText??n.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return t$1(n.childNodes,r,0,t),{componentId:n.getAttribute("data-componentid")||void 0,depth:e,text:j(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var A=n=>a$2.object({componentId:a$2.string().default(()=>n?.getAttribute?.("data-componentid")||a()),depth:a$2.number().default(0),text:a$2.string().default(""),inlineStyleRanges:a$2.array(a$6()).default([]),entityRanges:a$2.array(b$1()).default([])}).default({}),_=class n$1 extends a$1{static get NAMESPACE(){return b}static get LABEL(){return "List"}static get GROUP(){return "lists"}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){let e=X(t);return a$2.object({component:a$2.string().default(n$1.NAMESPACE),componentId:a$2.string().default(t?.getAttribute("data-componentid")||a()),properties:a$2.object({items:a$2.array(A()).default([A().parse()]).transform(T)}).default({}),settings:a$2.object({style:a$2.enum(["ORDERED","UNORDERED"]).default(e??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(s=>{let o={componentId:s?.componentId,text:j(s?.text),depth:s?.depth??0};return s?.inlineStyleRanges!==void 0&&(o.inlineStyleRanges=s.inlineStyleRanges),s?.entityRanges!==void 0&&(o.entityRanges=s.entityRanges),o});return k({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return tt(t,{style:t?.settings?.style})}static appendExchangeState(t,e){return nt(t,e)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let e=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},s=Y(t);if(s.length)e.properties.items=s.map(o=>A(o).parse(st(o,r)));else {let o=this.state?.peek?.()?.properties?.items;e.properties.items=o?.length?structuredClone(o):[A().parse()];}return e.settings={...e.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??e.settings?.style??"UNORDERED"},e}_commitState(t){let e=f(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(e);if(r===-1)return;let s=this.mrakomor.getContent();s.splice(r,1,t),this.mrakomor.setContent(s);}_buildItemContent(t){return rt(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),e=this.state.peek(),r=e.settings?.style==="ORDERED"?"ol":"ul",s=q(()=>this.state.get().properties?.items??[],(o,c)=>o.componentId??String(c),(o$1,c)=>o("li",{contentEditable:true,[d]:true,"data-componentid":()=>o$1.get().componentId,"data-item-index":()=>{let i=o$1.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(p=>p.componentId===i);return String(l>=0?l:c)},"data-depth":()=>String(o$1.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let i=o$1.get(),a=i?.text??"";return j(a)?a$3(()=>this._buildItemContent(i)):"<br>"}}),{tagName:r});return s.className=t,e.componentId&&s.setAttribute("data-componentid",e.componentId),this.element=s,s}onKeydown(t){if(t.key==="Enter"){this.#e(t);return}t.key==="Backspace"&&this.#n(t);}setCursor(t$1){let e=this.getState()?.properties?.items??[],r=e.length-1;if(r<0)return;let s=typeof t$1=="number"?t$1:j(e[r]?.text).length,o=()=>{let c=this.element?.querySelector(`li[data-item-index="${r}"]`);c?.isConnected&&t(c,s);};o(),n(o);}#t(t$1){let e=this.getState(),r=[...e.properties.items??[]],s=r[t$1];if(!s)return;if((s.depth??0)>0){r[t$1]={...s,depth:s.depth-1},this._commitState({...e,properties:{...e.properties,items:r}});let u=()=>{let m=this.element?.querySelector(`li[data-item-index="${t$1}"]`);m?.isConnected&&t(m,0);};u(),n(u);return}let o=f(this.element),c=this.mrakomor._getBlockElementIndex(o),i=o?.previousElementSibling??null,a=i?this.mrakomor._getBlockElementIndex(i):-1;if(t$1===0&&a>=0&&c===a+1){let u=this.mrakomor.getContent(),m=et(u,a,c);if(m){this.mrakomor._setContentState(m.content.map(h=>this.mrakomor.normalizeComponentState(h))),v(i)?.setCursor?.(m.cursor);return}}let{blocks:l,paragraphIndex:p}=P(e,t$1,{Constructor:this.mrakomor.register.blocks.getByNamespace(a$4)});this.mrakomor.command.replaceBlockElement({blockElement:f(this.element),blocks:l,cursor:0,cursorBlockIndex:p});}#e(t$1){t$1.preventDefault();let e=k$1(),r=j$1(this.element,e);if(!r)return;let{element:s,index:o}=r,c=M(s,e),i=this.getState(),a=[...i.properties.items??[]],l=a[o];if(!l)return;if(!j(l.text)){this.#t(o);return}let{before:p,after:u}=Z(l,c);a.splice(o,1,p,u),this._commitState({...i,properties:{...i.properties,items:a}}),n(()=>{let m=this.element?.querySelector(`li[data-item-index="${o+1}"]`);m&&t(m,0);});}#n(t){let e=k$1();if(!e?.collapsed)return;let r=j$1(this.element,e);if(!r){let i=e.startContainer;if(!(i===this.element||this.element?.contains?.(i)))return;t.preventDefault(),this.#t(0);return}let{element:s,index:o}=r;M(s,e)===0&&(t.preventDefault(),this.#t(o));}};function at(n){let{mrakomor:t,blockElement:e,namespace:r}=n;if(!t||!e||!r)return;let s=t._getBlockElementState(e);if(!s||!p$1({component:r})||!q$1(s))return;n.preventDefault();let c=v(e)?.element,i=n.range??k$1(),a=j$1(c,i);if(!a)return;let{index:l}=a,{blocks:p,paragraphIndex:u}=P(s,l,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:e,blocks:p,cursor:0,cursorBlockIndex:u});}function lt(n){return {resolveConfig:t=>(t.blockComponents.push({component:n,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:n,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===n.NAMESPACE)return n},registerCommands(t){t.emitter.on(a$5.TRANSFORM_BLOCK_ELEMENT,at);}}}function Lt(){return lt(_)}export{X as a,T as b,_ as c,lt as d,Lt as e};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-2VURZA2E.mjs';import {d,a as a$3,b}from'./chunk-VYTSZ4S6.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {a as a$1,z,s,j,x}from'./chunk-ZDMD7SRT.mjs';import {d as d$1}from'./chunk-SCFD3XBH.mjs';import {o,a as a$4}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/paragraph/Paragraph.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(a){return a.getAttribute("data-mrakomor-css-path")===e});if(!t){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent=`.mrakomor-content p{margin-top:0}
2
+ `,document.head.appendChild(r);}}})();var n=class e extends a{static get NAMESPACE(){return a$1}static get LABEL(){return "P"}static get KEYWORDS(){return ["p","paragraph","text"]}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){return d(t,{component:e.NAMESPACE,properties:{entityRanges:a$2.array(b()).default([]),inlineStyleRanges:a$2.array(a$3()).default([]),text:a$2.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return z(this,t)}_buildContent(t){return s(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return o("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[d$1]:true,$ref:r=>{this.element=r;},$dangerouslySetInnerHTML:()=>{let r=this.state.get(),a=r.properties?.text??"";return j(a)?a$4(()=>this._buildContent(r)):"<br>"}})}onKeydown(t){x(this,t);}};function L(){return {resolveConfig:e=>(e.blockComponents.push(n),e),resolveComponent:e=>{if(e===n.NAMESPACE)return n}}}export{n as a,L as b};
@@ -0,0 +1 @@
1
+ import {g as g$1}from'./chunk-K2DMHAUD.mjs';var C=E(),S=E(),B=E(),I=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function E(){return Math.floor(Math.random()*16777215)}function k(){return S=(S+1)%16777215,S}function v(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=k(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,C>>16&255,C>>8&255,C&255,B>>8&255,B&255,e>>16&255,e>>8&255,e&255),o="";for(let l=0;l<n.length;l++)o+=I[n.charCodeAt(l)];return o}var x=Symbol("block-element"),M=Symbol("block-element-body"),g=Symbol("selectable-element");function h(t,e){let n=t;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[e]===void 0;)n=n.parentElement;return n??null}function y(t){return t?h(t.startContainer,x):null}function O(t){return h(t,x)}function N(t){return t?h(t.startContainer,g):null}function T(t){return h(t,g)}function _(t){return t?t[g]!==void 0?[t]:[...t.children].filter(e=>e[g]!==void 0):[]}function w(t,e){return e?_(t).indexOf(e):-1}function W(t,e){let n=N(e);return !n||!t?.contains(n)?null:{element:n,index:w(t,n)}}function b(){return window.getSelection()}function p(){let t=b();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function j(){let t=p();if(!t)return 0;t.collapse(true);let e=N(t),n=y(t),o=e??s(n);return d(o,t.startContainer,t.startOffset)}var f=null;function F(){f=L();}function A(){f&&G(f);}function K(){f&&(f={start:f.end,end:f.end,element:f.element},A());}function D(t,e){let n=N(e);return n||(s(t)??t?.childNodes?.[0]??null)}function d(t,e,n){if(!t)return 0;if(e===t){if(e.nodeType===Node.TEXT_NODE)return n;let c=0,u=t.childNodes,a=Math.min(n,u.length);for(let i=0;i<a;i++)c+=u[i].textContent.length;return c}if(e.nodeType===Node.ELEMENT_NODE&&!t.contains(e))return 0;let o=0,l=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=l.nextNode();for(;r;){if(r===e)return o+n;o+=r.textContent.length,r=l.nextNode();}return o}function L(){let t=p();if(!t)return null;let e=y(t),n=D(e,t);return {start:d(n,t.startContainer,t.startOffset),end:d(n,t.endContainer,t.endOffset),element:e,selectableElement:n}}function Y(t=p()){if(!t||t.collapsed)return null;let e=O(t.startContainer),n=O(t.endContainer);if(!e||!n)return null;let o=T(t.startContainer)??s(e),l=T(t.endContainer)??s(n);return {startBlock:e,endBlock:n,startOffset:d(o,t.startContainer,t.startOffset),endOffset:d(l,t.endContainer,t.endOffset)}}function G(t){if(!t)return;let{start:e,end:n,element:o,selectableElement:l}=t,r=l?.isConnected&&l||s(o)||o?.childNodes?.[0];if(!r)return;let c=m(r,e),u=m(r,n),a=document.createRange();a.setStart(c.startContainer,c.startOffset),a.setEnd(u.endContainer,u.endOffset);let i=b();i.removeAllRanges(),i.addRange(a);}function m(t,e){let n=document.createRange();if(!t)return n;if(e<=0)return n.setStart(t,0),n.collapse(true),n;let o=0,l=[t];for(;l.length>0;){let r=l.pop();if(r.nodeType===Node.TEXT_NODE){let c=r.textContent.length;if(o+c>=e)return n.setEnd(r,e-o),n.setStart(r,e-o),n;o+=c;}else if(r.childNodes&&r.childNodes.length>0)for(let c=r.childNodes.length-1;c>=0;c--)l.push(r.childNodes[c]);}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function q(t,e){let n=m(t,e),o=b();o.removeAllRanges(),o.addRange(n);}function s(t){if(!t)return null;let e=H(t);return e?.firstElementChild??e?.firstChild}function z(t){if(!t?.[x])return null;let e=s(t);return e?g$1(e)?.classInstance:null}function H(t){if(!t)return null;for(let e of t.children)if(e[M])return e;return null}function J(t,e,n,o=12){let l=t.getBoundingClientRect(),r=typeof e?.getBoundingClientRect=="function"?e.getBoundingClientRect():e??{left:0,top:0},c=n?.offsetHeight??40;return {x:r.left-l.left,y:r.top-l.top-c-o}}function P(t,e){let n=t.getBoundingClientRect(),o=e?.offsetWidth??420,l=e?.offsetHeight??320,r=16;return {x:Math.max(r,(n.width-o)/2),y:Math.max(r,(n.height-l)/2)}}export{v as a,x as b,M as c,g as d,y as e,O as f,N as g,T as h,_ as i,W as j,p as k,j as l,F as m,A as n,K as o,d as p,L as q,Y as r,G as s,q as t,s as u,z as v,H as w,J as x,P as y};
@@ -1 +1 @@
1
- import {a}from'./chunk-P7IKAZYZ.mjs';import {a as a$1}from'./chunk-YHWQV2DB.mjs';function d(){return a.object({length:a.number(),offset:a.number(),style:a.string()})}function c({type:e,data:n=a.any(),length:r,offset:u}={}){let o=e!=null,a$1=a.object({type:o?a.string().default(e):a.string(),data:n}),f=r??(o?0:void 0),i=u??(o?0:void 0);return a.object({entity:o?a$1.default({}):a$1,length:f==null?a.number():a.number().default(f),offset:i==null?a.number():a.number().default(i)})}function b(){return a.array(c()).transform(e=>e.filter(n=>n.entity.type==="atom.tts.Voice")).default([])}function p(e,{component:n,properties:r,settings:u=a.object({}).default({})}){return a.object({component:a.string().default(n),componentId:a.string().default(e?.getAttribute("data-componentid")||a$1()),properties:a.object(r).default({}),settings:u}).default({})}export{d as a,c as b,b as c,p as d};
1
+ import {a}from'./chunk-P7IKAZYZ.mjs';import {a as a$1}from'./chunk-SCFD3XBH.mjs';function d(){return a.object({length:a.number(),offset:a.number(),style:a.string()})}function c({type:e,data:n=a.any(),length:r,offset:u}={}){let o=e!=null,a$1=a.object({type:o?a.string().default(e):a.string(),data:n}),f=r??(o?0:void 0),i=u??(o?0:void 0);return a.object({entity:o?a$1.default({}):a$1,length:f==null?a.number():a.number().default(f),offset:i==null?a.number():a.number().default(i)})}function b(){return a.array(c()).transform(e=>e.filter(n=>n.entity.type==="atom.tts.Voice")).default([])}function p(e,{component:n,properties:r,settings:u=a.object({}).default({})}){return a.object({component:a.string().default(n),componentId:a.string().default(e?.getAttribute("data-componentid")||a$1()),properties:a.object(r).default({}),settings:u}).default({})}export{d as a,c as b,b as c,p as d};
@@ -0,0 +1,2 @@
1
+ import {a as a$1}from'./chunk-2VURZA2E.mjs';import {d}from'./chunk-VYTSZ4S6.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {j,x,a as a$4,e,f as f$1,g,h,i as i$1}from'./chunk-ZDMD7SRT.mjs';import {d as d$1,k,f,u as u$1,t}from'./chunk-SCFD3XBH.mjs';import {o as o$1,a as a$3,n}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/headline/Headline.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===e});if(!t){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent=`.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}
2
+ `,document.head.appendChild(r);}}})();var o=class extends a$1{constructor(t){super(t),this._level=1;}static getStateSchema(t){return d(t,{component:this.NAMESPACE,properties:{text:a$2.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let r=structuredClone(this.constructor.getStateSchema(t).parse());return r.properties.text=j(r.properties.text),r}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return o$1(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[d$1]:true,$ref:r=>{this.element=r;},$dangerouslySetInnerHTML:()=>{let r=this.state.get(),n=r.properties?.text??"";return j(n)?a$3(()=>this._buildContent(r)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#t(t);return}x(this,t,{namespace:a$4});}#t(t$1){if(!k()?.collapsed)return;let n$1=f(this.element);if(n$1?.previousElementSibling||j(this.getState()?.properties?.text))return;t$1.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:n$1,namespace:a$4});let l=()=>{let b=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),p=u$1(b);p?.isConnected&&t(p,0);};l(),n(l);}},s=class extends o{static get NAMESPACE(){return e}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},c=class extends o{static get NAMESPACE(){return f$1}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},i=class extends o{static get NAMESPACE(){return g}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},a=class extends o{static get NAMESPACE(){return h}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},u=class extends o{static get NAMESPACE(){return i$1}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function w(){return {resolveConfig:e=>(e.blockComponents.push(s,c,i,a,u),e),resolveComponent:e=>{if(e===s.NAMESPACE)return s;if(e===c.NAMESPACE)return c;if(e===i.NAMESPACE)return i;if(e===a.NAMESPACE)return a;if(e===u.NAMESPACE)return u}}}export{o as a,w as b};
@@ -0,0 +1,4 @@
1
+ import {u as u$1,j as j$1,a as a$1,l,k as k$1,p}from'./chunk-SCFD3XBH.mjs';import {r,o}from'./chunk-K2DMHAUD.mjs';var x="molecule.paragraph.Paragraph",F="molecule.list.List",X="molecule.external.ExternalComponent",K="namespace.unknown.UnknownComponent",z="molecule.headline.H1",G="molecule.headline.H2",U="molecule.headline.H3",W="molecule.headline.H4",j="molecule.headline.H5",C="molecule.headline.";function a(t){return t===`
2
+ `||t===`\r
3
+ `?"":t??""}function Y({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{},s=Array.isArray(r.items)?r.items:[{text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]}];return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{items:s},...o?{settings:o}:{}}}function Z(t){let e="",n=[],o=[];return (t??[]).forEach((r,s)=>{s>0&&(e+=`
4
+ `);let i=e.length;e+=a(r?.text);for(let c of r?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of r?.entityRanges??[])o.push({...c,offset:c.offset+i});}),{text:e,inlineStyleRanges:n,entityRanges:o}}function $(t){return {properties:{text:t?.text??"",inlineStyleRanges:t?.inlineStyleRanges??[],entityRanges:t?.entityRanges??[]}}}function b(t,e,n,o){let r=t.toExchangeState(e),s=[...r.properties?.items??[]];if(!s[n])return e;s[n]={...s[n],...o};let i=t.fromExchangeState({...r,properties:{...r.properties,items:s}});return {...e,properties:i?.properties??e.properties,settings:i?.settings??e.settings}}function ee(t,e,n){let o=t._getBlockElementState(e);if(!o)return null;let r=t.register.blocks.getByNamespace(o.component);if(!r)return null;let s=r.toExchangeState(o)?.properties?.items??[];if(!s.length)return null;let i=u$1(e),c=j$1(i,n),p=c?.element??i??e,f=c?.index??0,l=s[f];return l?{Constructor:r,current:o,element:p,itemIndex:f,item:l}:null}function P(t){let e=t?.component??"";return e===x||e.startsWith(C)}function te(t){return Array.isArray(t?.properties?.items)}function ne(t,e){return P(t)&&P(e)&&t.component===e.component}function B(t,e){let n=new Set([0,e]);for(let o of t)n.add(o.offset),n.add(o.offset+o.length);return [...n].sort((o,r)=>o-r)}function _(t,e,n){return t.filter(o=>o.offset<=e&&o.offset+o.length>=n)}function T(t,e,n,{inlineStyleComponents:o$1,entityRangeComponents:r}){let s=t;for(let i of e){let c=o$1.find(p=>p.match(i));c&&(s=o(c,{},s));}for(let i of n){let c=r.find(p=>p.match(i));c&&(s=o(c,i,s));}return s}function oe(t,{inlineStyleComponents:e,entityRangeComponents:n}){let o=document.createDocumentFragment(),r$1=a(t.properties.text),s=t.properties.inlineStyleRanges??[],i=t.properties.entityRanges??[];if(!r$1)return o;let c=B([...s,...i],r$1.length);for(let p=0;p<c.length-1;p+=1){let f=c[p],l=c[p+1];if(f>=l)continue;let g=r$1.slice(f,l),L=T(g,_(s,f,l),_(i,f,l),{inlineStyleComponents:e,entityRangeComponents:n});r(o,L);}return o}function u(t,e,n,{inlineStyleComponents:o,entityRangeComponents:r}){let s=n;for(let i of t){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=o.find(f=>f.match(i));if(c){let f=i.textContent.length;e.properties.inlineStyleRanges.push({style:c.style,offset:s,length:f}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}let p=r.find(f=>f.match(i));if(p){let f=i.textContent.length;e.properties.entityRanges.push({...p.getStateSchema(i).parse(),offset:s,length:f}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});}return s}function k(t,e){let n=a(t.properties.text),o=a(e.properties.text);return {state:{...t,properties:{...e.properties,...t.properties,text:n+o,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(r=>({...r,offset:r.offset+n.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(r=>({...r,offset:r.offset+n.length}))]},settings:{...e.settings,...t.settings}},cursor:n.length}}function re(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],c=s[n],{originalLineState:p}=S(i,o),{newLineState:f}=S(c,r),{state:l,cursor:g}=k(p,f);return s.splice(e,n-e+1,l),{content:s,cursor:g,resultIndex:e}}function M(t,e){return (t??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)}))}function H(t,e){return (t??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)}))}function S(t,e){let n=structuredClone(t),o=structuredClone(t);return n.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),n.properties.inlineStyleRanges=M(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=H(t.properties.inlineStyleRanges,e),n.properties.entityRanges=M(t.properties.entityRanges,e),o.properties.entityRanges=H(t.properties.entityRanges,e),o.componentId=a$1(),{originalLineState:n,newLineState:o}}function se(t,e,{namespace:n=t.constructor.NAMESPACE}={}){if(e.key!=="Enter")return false;e.preventDefault();let{originalLineState:o,newLineState:r}=S(t.getState(),l(t.element));return t.mrakomor.command.insertBlockElement({range:k$1(),cursor:0,newLineState:r,originalLineState:o,namespace:n}),true}function ie(t,e){if(e.key!=="Enter")return false;e.preventDefault();let n=x,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:k$1(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:n}),true}function ce(t,e){let n=t.constructor;if(!e)return n.getStateSchema(e).parse();let o=structuredClone(n.getStateSchema(e).parse());return u(e.childNodes,o,0,{inlineStyleComponents:t.getInlineStyleComponents(),entityRangeComponents:t.getEntityRangeComponents()}),o.properties.text=a(o.properties.text),o}function I(t,e){let n=p(t,e.startContainer,e.startOffset),o=p(t,e.endContainer,e.endOffset);return {offset:n,length:Math.max(0,o-n)}}function v(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(c=>c.style===e&&c.offset<=n&&c.offset+c.length>=s);return i?r.filter(c=>c!==i):[...r,{style:e,offset:n,length:o}]}function w(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function D(t,e){let n=e.offset+e.length,o=[];for(let r of t){if(!w(r,e)){o.push(r);continue}r.offset<e.offset&&o.push({...r,length:e.offset-r.offset});let s=r.offset+r.length;s>n&&o.push({...r,offset:n,length:s-n});}return o}function O(t,e){let n=t??[],o=e?.length??0;if(o===0)return null;let r=e.offset??0,s=e.entity?.type,i=n.find(c=>c.offset===r&&c.length===o&&c.entity?.type===s);return i?n.filter(c=>c!==i):[...D(n,e),e]}function fe(t,e,n,o){if(!e||!n)return null;let{offset:r,length:s}=I(e,n);return s===0?null:v(t??[],{style:o,offset:r,length:s})}function pe(t,e,n,{namespace:o,entityData:r}){if(!e||!n)return null;let s={...r,entity:{type:o,...r?.entity},...I(e,n)};return O(t??[],s)}export{I as A,fe as B,pe as C,x as a,F as b,X as c,K as d,z as e,G as f,U as g,W as h,j as i,a as j,Y as k,Z as l,$ as m,b as n,ee as o,P as p,te as q,ne as r,oe as s,u as t,k as u,re as v,S as w,se as x,ie as y,ce as z};
@@ -1,5 +1,5 @@
1
- 'use strict';var $e=class{next(...e){}error(...e){}complete(...e){}},ge=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var Z=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var I=null,me=false,he=[];function P(e){let t=I;I=null;let n=e();return I=t,n}function vt(){me=false;let e=Ve();for(let n of e)n.get();let t=he;he=[];for(let n of t)n();}function Ue(){me||(me=true,queueMicrotask(vt));}function ye(e){he.push(e),Ue();}var qe=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),Ft=class extends ge{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>P(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof ze&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>P(()=>{this.#e.add(e),t(),this.#r();}),e.next[A]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[A]){let n=t.get,r=n.bind(t);t.get=()=>P(()=>(this.#e.delete(t),r())),t.get[A]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[A]?e.next[A]:e.next,e.get=e.get[A]?e.get[A]:e.get,this.#e.delete(e),this.unsubscribe(e)}},ee=null;function Ge(e){ee=new Ft(e);}Ge(()=>{Ue();});function Ve(){return ee.getPending()}var T=Symbol("@esmj/signals:no error"),ze=class We extends $e{#e=true;#r=false;#n=null;#o=this.#p();#a=null;#c=null;#i=0;#s=new Map;#t=T;constructor(t,n){super(),this.#a=t,this.#c=n,this.debug=n?.debug,this[Z]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[q],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof We&&P(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[qe].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=$(this.#l(),this.#c)),(this.#e||this.#t!==T)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),I&&I.sourceRevisions.set(this,this.#i),this.#t!==T)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=$(this.#l(),this.#c)),(this.#e||this.#t!==T)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),this.#t!==T)throw this.#t;return this.#n.peek()}#l(){this.#r=true,this.#e=false,this.#t=T,this.#u(),this.#o.sourceRevisions.clear();let t=I;I=this.#o;let n;try{n=this.#a();}catch(r){this.#t=r;}return I=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=T,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===T&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=T;}};function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new ge;function s(){return I&&(I.dependencies.set(o,o.subscribe(I.observer)),I.sourceRevisions.set(l,r)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function c(){return r}let l={get:s,set:a,peek:i,getRevision:c,[qe]:o,[Z]:"signal",[q]:t?.debug??null};return l}var jt=Symbol("node-component");function oe(e){return e?.[jt]||null}function Le(e){ye(()=>{setTimeout(e,0);});}var Oe=_e(),Me=_e(),ct=_e(),nn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function _e(){return Math.floor(Math.random()*16777215)}function rn(){return Me=(Me+1)%16777215,Me}function X(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=rn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Oe>>16&255,Oe>>8&255,Oe&255,ct>>8&255,ct&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=nn[n.charCodeAt(o)];return r}var ke=Symbol("block-element"),on=Symbol("block-element-body"),ut=Symbol("selectable-element");function ce(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function Be(e){return e?ce(e.startContainer,ke):null}function le(e){return ce(e,ke)}function sn(e){return e?ce(e.startContainer,ut):null}function at(e){return ce(e,ut)}function ft(){return window.getSelection()}function z(){let e=ft();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function ln(e,t){let n=sn(t);return n||(F(e)??e?.childNodes?.[0]??null)}function Y(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,a=e.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=o.nextNode();for(;s;){if(s===t)return r+n;r+=s.textContent.length,s=o.nextNode();}return r}function pt(){let e=z();if(!e)return null;let t=Be(e),n=ln(t,e);return {start:Y(n,e.startContainer,e.startOffset),end:Y(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function dt(e=z()){if(!e||e.collapsed)return null;let t=le(e.startContainer),n=le(e.endContainer);if(!t||!n)return null;let r=at(e.startContainer)??F(t),o=at(e.endContainer)??F(n);return {startBlock:t,endBlock:n,startOffset:Y(r,e.startContainer,e.startOffset),endOffset:Y(o,e.endContainer,e.endOffset)}}function cn(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(r+i>=t)return n.setEnd(s,t-r),n.setStart(s,t-r),n;r+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)o.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function gt(e,t){let n=cn(e,t),r=ft();r.removeAllRanges(),r.addRange(n);}function F(e){if(!e)return null;let t=an(e);return t?.firstElementChild??t?.firstChild}function mt(e){if(!e?.[ke])return null;let t=F(e);return t?oe(t)?.classInstance:null}function an(e){if(!e)return null;for(let t of e.children)if(t[on])return t;return null}var N="molecule.paragraph.Paragraph";var ht="molecule.headline.";function W(e){return e===`
1
+ 'use strict';var $e=class{next(...e){}error(...e){}complete(...e){}},me=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var Z=Symbol("@esmj/signals:type"),G=Symbol("@esmj/signals:name");var C=null,he=false,xe=[];function P(e){let t=C;C=null;let n=e();return C=t,n}function Bt(){he=false;let e=Ve();for(let n of e)n.get();let t=xe;xe=[];for(let n of t)n();}function qe(){he||(he=true,queueMicrotask(Bt));}function Ee(e){xe.push(e),qe();}var Ge=Symbol("@esmj/signals:internal observable"),T=Symbol("@esmj/signals:original function"),Pt=class extends me{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>P(()=>{this.#e.add(e),this.#r();}),e.next[T]=void 0),e instanceof ze&&e.next[T]===void 0){let t=e.next.bind(e);e.next=()=>P(()=>{this.#e.add(e),t(),this.#r();}),e.next[T]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[T]){let n=t.get,r=n.bind(t);t.get=()=>P(()=>(this.#e.delete(t),r())),t.get[T]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[T]?e.next[T]:e.next,e.get=e.get[T]?e.get[T]:e.get,this.#e.delete(e),this.unsubscribe(e)}},ee=null;function Ue(e){ee=new Pt(e);}Ue(()=>{qe();});function Ve(){return ee.getPending()}var A=Symbol("@esmj/signals:no error"),ze=class We extends $e{#e=true;#r=false;#n=null;#o=this.#d();#a=null;#c=null;#i=0;#s=new Map;#t=A;constructor(t,n){super(),this.#a=t,this.#c=n,this.debug=n?.debug,this[Z]="computed",this[G]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#d(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[G],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof We&&P(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[Ge].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=$(this.#l(),this.#c)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),C&&C.sourceRevisions.set(this,this.#i),this.#t!==A)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=$(this.#l(),this.#c)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),this.#t!==A)throw this.#t;return this.#n.peek()}#l(){this.#r=true,this.#e=false,this.#t=A,this.#u(),this.#o.sourceRevisions.clear();let t=C;C=this.#o;let n;try{n=this.#a();}catch(r){this.#t=r;}return C=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=A,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===A&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=A;}};function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new me;function s(){return C&&(C.dependencies.set(o,o.subscribe(C.observer)),C.sourceRevisions.set(l,r)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function c(){return r}let l={get:s,set:a,peek:i,getRevision:c,[Ge]:o,[Z]:"signal",[G]:t?.debug??null};return l}function Te(e){Ee(()=>{setTimeout(e,0);});}var Me=Be(),ke=Be(),ct=Be(),Zt=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Be(){return Math.floor(Math.random()*16777215)}function en(){return ke=(ke+1)%16777215,ke}function X(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=en(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Me>>16&255,Me>>8&255,Me&255,ct>>8&255,ct&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Zt[n.charCodeAt(o)];return r}var ut=Symbol("block-element"),tn=Symbol("block-element-body"),ie=Symbol("selectable-element");function ce(e,t){let n=e;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[t]===void 0;)n=n.parentElement;return n??null}function Pe(e){return e?ce(e.startContainer,ut):null}function le(e){return ce(e,ut)}function ft(e){return e?ce(e.startContainer,ie):null}function at(e){return ce(e,ie)}function ve(e){return e?e[ie]!==void 0?[e]:[...e.children].filter(t=>t[ie]!==void 0):[]}function nn(e,t){return t?ve(e).indexOf(t):-1}function ae(e,t){let n=ft(t);return !n||!e?.contains(n)?null:{element:n,index:nn(e,n)}}function dt(){return window.getSelection()}function z(){let e=dt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function rn(e,t){let n=ft(t);return n||(F(e)??e?.childNodes?.[0]??null)}function Y(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,a=e.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=o.nextNode();for(;s;){if(s===t)return r+n;r+=s.textContent.length,s=o.nextNode();}return r}function pt(){let e=z();if(!e)return null;let t=Pe(e),n=rn(t,e);return {start:Y(n,e.startContainer,e.startOffset),end:Y(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function gt(e=z()){if(!e||e.collapsed)return null;let t=le(e.startContainer),n=le(e.endContainer);if(!t||!n)return null;let r=at(e.startContainer)??F(t),o=at(e.endContainer)??F(n);return {startBlock:t,endBlock:n,startOffset:Y(r,e.startContainer,e.startOffset),endOffset:Y(o,e.endContainer,e.endOffset)}}function on(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let r=0,o=[e];for(;o.length>0;){let s=o.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(r+i>=t)return n.setEnd(s,t-r),n.setStart(s,t-r),n;r+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)o.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function mt(e,t){let n=on(e,t),r=dt();r.removeAllRanges(),r.addRange(n);}function F(e){if(!e)return null;let t=sn(e);return t?.firstElementChild??t?.firstChild}function sn(e){if(!e)return null;for(let t of e.children)if(t[tn])return t;return null}var b="molecule.paragraph.Paragraph";var ht="molecule.headline.";function W(e){return e===`
2
2
  `||e===`\r
3
- `?"":e??""}function _({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...o,text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]},...r?{settings:r}:{}}}function y(e){let t=e?.component??"";return t===N||t.startsWith(ht)}function j(e){return Array.isArray(e?.properties?.items)}function J(e,t){return y(e)&&y(t)&&e.component===t.component}function L(e,t){let n=W(e.properties.text),r=W(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function Et(e,{startIndex:t,endIndex:n,startOffset:r,endOffset:o}){let s=[...e],i=s[t],a=s[n],{originalLineState:c}=x(i,r),{newLineState:l}=x(a,o),{state:u,cursor:f}=L(c,l);return s.splice(t,n-t+1,u),{content:s,cursor:f,resultIndex:t}}function yt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function xt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function x(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=yt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=xt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=yt(e.properties.entityRanges,t),r.properties.entityRanges=xt(e.properties.entityRanges,t),r.componentId=X(),{originalLineState:n,newLineState:r}}var R={BEFORE_INPUT:"mrakomor:beforeinput"};function un(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function Pe(e,t){if(!e||!t)return null;let n=t.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n!==e;){if(n.nodeName==="LI"&&e.contains(n))return n;n=n.parentElement;}return null}function De(e,t){if(!t)return -1;let n=t.getAttribute?.("data-item-index");if(n!=null&&n!==""){let r=Number(n);if(!Number.isNaN(r))return r}return un(e).indexOf(t)}var Ct="application/x-mrakomor-blocks+json",Nt=1;function O(e){return y(e)?W(e.properties?.text).length:0}function ae(e,t,n){let r=e?.properties?.text??"",o=Math.max(0,Math.min(t,r.length)),s=Math.max(o,Math.min(n,r.length)),{originalLineState:i}=x(e,s),{newLineState:a}=x(i,o);return a}function Lt(e,t,n){let r=_({component:N,properties:{text:e?.text,inlineStyleRanges:e?.inlineStyleRanges,entityRanges:e?.entityRanges},settings:{}});return ae(r,t,n)}function Rt(e){return _({properties:{text:e?.text,inlineStyleRanges:e?.inlineStyleRanges,entityRanges:e?.entityRanges}})}function fn(e,t,n,r,o){let s=e.properties?.items??[],i="",a=[],c=[];for(let l=t;l<=r;l+=1){let u=s[l];if(!u)continue;let f=l===t?n:0,p=l===r?o:(u.text??"").length,h=Lt(u,f,p),m=i.length;i+=h.properties.text??"";for(let g of h.properties.inlineStyleRanges??[])a.push({...g,offset:g.offset+m});for(let g of h.properties.entityRanges??[])c.push({...g,offset:g.offset+m});}return [_({component:N,properties:{text:i,inlineStyleRanges:a,entityRanges:c},settings:{}})]}function pn(e,t,n,r,o){let s=structuredClone(e),i=s.properties?.items??[],a=i[t],c=i[r];if(!a||!c)return s;let{originalLineState:l}=x(Rt(a),n),{newLineState:u}=x(Rt(c),o);return s.properties.items=[...i.slice(0,t),{...a,text:l.properties.text,inlineStyleRanges:l.properties.inlineStyleRanges,entityRanges:l.properties.entityRanges},{...c,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges},...i.slice(r+1)],s}function dn(e,t){let n=e.index,r=e.listItemIndex??-1,o=e.offset??0,s=t.listItemIndex??-1,i=t.endListItemIndex??s;if(n!==t.startIndex||s<0)return {index:n,offset:o,listItemIndex:r};if(s===i)return r!==s||o<=t.startOffset?{index:n,offset:o,listItemIndex:r}:o>=t.endOffset?{index:n,offset:o-(t.endOffset-t.startOffset),listItemIndex:r}:{index:n,offset:t.startOffset,listItemIndex:r};let a=Math.max(0,i-s-1);return r<s||r===s&&o<=t.startOffset?{index:n,offset:o,listItemIndex:r}:r===i&&o>=t.endOffset?{index:n,offset:o-t.endOffset,listItemIndex:s+1}:r>i?{index:n,offset:o,listItemIndex:r-a}:{index:n,offset:t.startOffset,listItemIndex:s}}function ue(e,t){let{startIndex:n,endIndex:r,startOffset:o,endOffset:s,listItemIndex:i=-1,endListItemIndex:a}=t;if(n<0||r<0||n>r)return [];if(n===r){let l=e[n];if(j(l)&&i>=0){let u=a??i,f=l.properties.items[i];return f?u===i?[Lt(f,o,s)]:fn(l,i,o,u,s):[structuredClone(l)]}return y(l)?[ae(l,o,s)]:[structuredClone(l)]}let c=[];for(let l=n;l<=r;l+=1){let u=e[l];l===n&&y(u)?c.push(ae(u,o,O(u))):l===r&&y(u)?c.push(ae(u,0,s)):c.push(structuredClone(u));}return c}function gn(e,t,n,r){let o=structuredClone(e),s=o.properties?.items?.[t];if(!s)return o;let i=_({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),{originalLineState:a}=x(i,n),{newLineState:c}=x(i,r),{state:l}=L(a,c);return o.properties.items[t]={...s,text:l.properties.text,inlineStyleRanges:l.properties.inlineStyleRanges,entityRanges:l.properties.entityRanges},o}function fe(e,t){let{startIndex:n,endIndex:r,startOffset:o,endOffset:s,listItemIndex:i=-1,endListItemIndex:a}=t,c=[...e];if(n===r){let p=c[n];if(j(p)&&i>=0){let m=a??i;return c[n]=m===i?gn(p,i,o,s):pn(p,i,o,m,s),{content:c,resultIndex:n,cursor:o,listItemIndex:i}}if(y(p)){let{originalLineState:m}=x(p,o),{newLineState:g}=x(p,s),{state:E,cursor:k}=L(m,g);return c[n]=E,{content:c,resultIndex:n,cursor:k}}c.splice(n,1);let h=Math.min(n,Math.max(0,c.length-1));return {content:c,resultIndex:h,cursor:0}}if(y(c[n])&&y(c[r]))return Et(c,{startIndex:n,endIndex:r,startOffset:o,endOffset:s});let l=[];y(c[n])&&l.push(x(c[n],o).originalLineState),y(c[r])&&l.push(x(c[r],s).newLineState);let u=l,f=0;if(l.length===2){let p=L(l[0],l[1]);u=[p.state],f=p.cursor;}else l.length===1&&(f=O(l[0]));return c.splice(n,r-n+1,...u),{content:c,resultIndex:u.length?n:Math.max(0,n-1),cursor:f}}function bt(e,{source:t,drop:n,blocks:r}){if(!r?.length)return {content:[...e],resultIndex:Math.max(0,n.index),cursor:n.offset??0,listItemIndex:n.listItemIndex??-1};let o=fe(e,t),s=dn(n,t);return pe(o.content,{index:s.index,offset:s.offset,listItemIndex:s.listItemIndex,blocks:r})}function At(e,t,n){let r=[...e];r.splice(t+1,0,...n);let o=n[n.length-1];return {content:r,resultIndex:t+n.length,cursor:O(o),listItemIndex:-1}}function mn(e,{listIndex:t,itemIndex:n,offset:r,blocks:o}){let s=structuredClone(e[t]),i=s.properties?.items?.[n],a=o.length===1&&y(o[0]);if(!i||!a)return At(e,t,o);let c=_({properties:{text:i.text,inlineStyleRanges:i.inlineStyleRanges,entityRanges:i.entityRanges}}),l=_({properties:{text:o[0].properties?.text,inlineStyleRanges:o[0].properties?.inlineStyleRanges,entityRanges:o[0].properties?.entityRanges}}),{originalLineState:u,newLineState:f}=x(c,r),{state:p}=L(u,l),{state:h,cursor:m}=L(p,f);s.properties.items[n]={...i,text:h.properties.text,inlineStyleRanges:h.properties.inlineStyleRanges,entityRanges:h.properties.entityRanges};let g=[...e];return g[t]=s,{content:g,resultIndex:t,cursor:m,listItemIndex:n}}function pe(e,{index:t,offset:n,blocks:r,listItemIndex:o=-1}){let s=[...e];if(!r?.length)return {content:s,resultIndex:Math.max(0,t),cursor:n??0};if(t<0||t>=s.length){s.push(...r);let m=r[r.length-1];return {content:s,resultIndex:s.length-1,cursor:O(m)}}let i=s[t];if(j(i)&&o>=0)return mn(s,{listIndex:t,itemIndex:o,offset:n??0,blocks:r});if(!y(i))return At(s,t,r);let{originalLineState:a,newLineState:c}=x(i,n??0),l=r[0],u=r[r.length-1],f=[];if(J(a,l)?f.push(L(a,l).state):(O(a)>0&&f.push(a),f.push(l)),r.length>1)f.push(...r.slice(1,-1)),J(u,c)?f.push(L(u,c).state):(f.push(u),O(c)>0&&f.push(c));else {let m=f[f.length-1];if(J(m,c)){let{state:g,cursor:E}=L(m,c);return f[f.length-1]=g,s.splice(t,1,...f),{content:s,resultIndex:t+f.length-1,cursor:E}}O(c)>0&&f.push(c);}s.splice(t,1,...f);let p=r.length>1&&J(u,c),h=t+f.length-1-(p||O(c)===0?0:1);return {content:s,resultIndex:Math.max(t,h),cursor:O(u)}}function St(e){if(!e)return null;try{let t=JSON.parse(e);if(t&&t.v===Nt&&Array.isArray(t.blocks))return t.blocks}catch{return null}return null}function hn(e){return new DOMParser().parseFromString(e,"text/html").body?.textContent??""}function It(e,t=N){return String(e).split(/\r\n|\n|\r/).map(r=>_({component:t,properties:{text:r},settings:{}}))}function yn(e){return j(e)?(e.properties.items??[]).map(t=>t.text??"").join(`
4
- `):y(e)?W(e.properties?.text):""}function xn(e){return e.map(yn).join(`
5
- `)}function En(e){return {v:Nt,blocks:e.map(t=>structuredClone(t))}}function de(e,t){let n=En(t);e.setData(Ct,JSON.stringify(n)),e.setData("text/plain",xn(t));}function ve(e,t=N){if(!e)return [];let n=St(e.getData(Ct));if(n)return n;let r=e.getData("text/plain")??"",o=St(r);if(o)return o;if(r)return It(r,t);let s=e.getData("text/html")??"";return s?It(hn(s),t):[]}function Tt(e){let t=structuredClone(e);return t.componentId=X(),Array.isArray(t.properties?.items)&&(t.properties.items=t.properties.items.map(n=>({...n,componentId:X()}))),t}function H(e){return !!e.target?.closest?.(".mrakomor-content")}function wt(e){return e?.nodeName==="UL"||e?.nodeName==="OL"}function Ot(e){let t=mt(e)?.element;if(wt(t))return t;let n=F(e);return wt(n)?n:n?.querySelector?.("ul, ol")??t??n}function Rn(e,t){let n=Ot(e),r=Pe(n,t),o=Pe(n,{startContainer:t.endContainer??t.startContainer});if(!r)return {listItemIndex:-1,endListItemIndex:-1};let s=De(n,r),i=o?De(n,o):s;return {listItemIndex:s,endListItemIndex:i}}function Q(e){let t=z();if(!t)return null;let n=le(t.startContainer)??Be(t);if(!n)return null;let r=e._getBlockElementIndex(n);if(r<0)return null;let o=e.getContent(),s=j(o[r])?Rn(n,t):{listItemIndex:-1,endListItemIndex:-1};if(t.collapsed){let c=pt();return {collapsed:true,startIndex:r,endIndex:r,startOffset:c?.start??0,endOffset:c?.start??0,listItemIndex:s.listItemIndex,endListItemIndex:s.endListItemIndex}}let i=dt(t),a=e._getBlockElementIndex(i.endBlock);return {collapsed:false,startIndex:r,endIndex:a,startOffset:i.startOffset,endOffset:i.endOffset,listItemIndex:r===a?s.listItemIndex:-1,endListItemIndex:r===a?s.endListItemIndex:-1}}function Sn(e,t,n,r=-1){Le(()=>{let s=e.getRoot()?.querySelectorAll?.(".mrakomor-content .mrakomor-block-element")?.[t],i=F(s);if(r>=0){let a=Ot(s);i=a?.querySelector?.(`li[data-item-index="${r}"]`)??a?.querySelectorAll?.("li")?.[r]??i;}i?.isConnected&&gt(i,n);});}function Mt(e,t){return t.map(n=>{try{return e.normalizeComponentState(Tt(n))}catch{return null}}).filter(Boolean)}function Fe(e,t,n,r,o=-1){let s=t.map(i=>{try{return e.normalizeComponentState(i)}catch{return null}}).filter(Boolean);e.setContent(s),Sn(e,n,r,o);}function In(e){let t=e.mrakomor;if(!t||!H(e)||!e.clipboardData)return;let n=Q(t);if(!n||n.collapsed)return;let r=ue(t.getContent(),n);r.length&&(e.preventDefault(),de(e.clipboardData,r));}function Cn(e){let t=e.mrakomor;if(!t||!H(e)||!e.clipboardData)return;let n=Q(t);if(!n||n.collapsed)return;let r=t.getContent(),o=ue(r,n);if(!o.length)return;e.preventDefault(),de(e.clipboardData,o);let s=fe(r,n);Fe(t,s.content,s.resultIndex,s.cursor,n.listItemIndex);}function Nn(e){let t=e.mrakomor;if(!t||e.target&&!H(e))return;e.preventDefault();let n=Mt(t,ve(e.clipboardData,N));if(!n.length)return;let r=t.getContent(),o=Q(t);if(!o)return;let s=r,i=o.startIndex,a=o.startOffset;if(!o.collapsed){let l=fe(s,o);s=l.content,i=l.resultIndex,a=l.cursor;}let c=pe(s,{index:i,offset:a,blocks:n,listItemIndex:o.listItemIndex});Fe(t,c.content,c.resultIndex,c.cursor,c.listItemIndex??o.listItemIndex);}function Ln(e){return !!e.target?.closest?.("ul, ol, li")}function bn(e){let t=e.inputType;t!=="deleteByDrag"&&t!=="insertFromDrop"||!H(e)||!Ln(e)||e.preventDefault();}function An(e,t){if(typeof document.caretRangeFromPoint=="function")return document.caretRangeFromPoint(e,t);if(typeof document.caretPositionFromPoint=="function"){let n=document.caretPositionFromPoint(e,t);if(!n?.offsetNode)return null;let r=document.createRange();return r.setStart(n.offsetNode,n.offset),r.collapse(true),r}return null}function Tn({root:e,mrakomor:t}){return {registerEvents(){R.COPY="mrakomor:copy",R.CUT="mrakomor:cut",R.PASTE="mrakomor:paste";},registerCommands(n){n.command.copy=(r={})=>{n.emitDomEvent(R.COPY,r);},n.command.cut=(r={})=>{n.emitDomEvent(R.CUT,r);},n.command.paste=(r={})=>{n.emitDomEvent(R.PASTE,r);};},registerHandlers(){t.register.help.add({id:"clipboard.copy",group:"editing",description:"Copy the selection",commands:[],shortcuts:["Mod+C"]}),t.register.help.add({id:"clipboard.cut",group:"editing",description:"Cut the selection",commands:[],shortcuts:["Mod+X"]}),t.register.help.add({id:"clipboard.paste",group:"editing",description:"Paste at the caret or selection",commands:[],shortcuts:["Mod+V"]});},registerListeners(){let{signal:n}=t.listenerAbortController,r=e??t.getRoot(),o=null;function s(l){if(!H(l)||!l.dataTransfer){o=null;return}let u=Q(t);if(!u||u.collapsed||(u.listItemIndex??-1)<0){o=null;return}let f=ue(t.getContent(),u);if(!f.length){o=null;return}o={selection:u,blocks:f},de(l.dataTransfer,f),l.dataTransfer.effectAllowed="copyMove";}function i(l){!o||!H(l)||(l.preventDefault(),l.dataTransfer&&(l.dataTransfer.dropEffect=l.altKey||l.ctrlKey?"copy":"move"));}function a(l){if(!o||!H(l))return;l.preventDefault();let u=An(l.clientX,l.clientY);if(u){u.collapse(true);let E=window.getSelection();E.removeAllRanges(),E.addRange(u);}let f=Mt(t,o?.blocks??ve(l.dataTransfer,N));if(!f.length){o=null;return}let p=Q(t);if(!p){o=null;return}let h=!!o?.selection&&!l.altKey&&!l.ctrlKey,m=t.getContent(),g=h?bt(m,{source:o.selection,drop:{index:p.startIndex,offset:p.startOffset,listItemIndex:p.listItemIndex},blocks:f}):pe(m,{index:p.startIndex,offset:p.startOffset,listItemIndex:p.listItemIndex,blocks:f});Fe(t,g.content,g.resultIndex,g.cursor,g.listItemIndex??p.listItemIndex),o=null;}function c(){o=null;}r.addEventListener("copy",l=>t.emitDomEvent(R.COPY,l),{signal:n}),r.addEventListener("cut",l=>t.emitDomEvent(R.CUT,l),{signal:n}),r.addEventListener("paste",l=>t.emitDomEvent(R.PASTE,l),{signal:n}),r.addEventListener("dragstart",s,{signal:n}),r.addEventListener("dragover",i,{signal:n}),r.addEventListener("drop",a,{signal:n}),r.addEventListener("dragend",c,{signal:n}),t.emitter.on(R.COPY,In),t.emitter.on(R.CUT,Cn),t.emitter.on(R.PASTE,Nn),t.emitter.on(R.BEFORE_INPUT,bn);}}}exports.clipboardPlugin=Tn;
3
+ `?"":e??""}function _(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function x(e){let t=e?.component??"";return t===b||t.startsWith(ht)}function j(e){return Array.isArray(e?.properties?.items)}function J(e,t){return x(e)&&x(t)&&e.component===t.component}function N(e,t){let n=W(e.properties.text),r=W(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(o=>({...o,offset:o.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(o=>({...o,offset:o.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function yt(e,{startIndex:t,endIndex:n,startOffset:r,endOffset:o}){let s=[...e],i=s[t],a=s[n],{originalLineState:c}=E(i,r),{newLineState:l}=E(a,o),{state:u,cursor:f}=N(c,l);return s.splice(t,n-t+1,u),{content:s,cursor:f,resultIndex:t}}function xt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Et(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function E(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=xt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Et(e.properties.inlineStyleRanges,t),n.properties.entityRanges=xt(e.properties.entityRanges,t),r.properties.entityRanges=Et(e.properties.entityRanges,t),r.componentId=X(),{originalLineState:n,newLineState:r}}var S={BEFORE_INPUT:"mrakomor:beforeinput"};var Ct="application/x-mrakomor-blocks+json",Rt=1;function O(e){return x(e)?W(e.properties?.text).length:0}function ue(e,t,n){let r=e?.properties?.text??"",o=Math.max(0,Math.min(t,r.length)),s=Math.max(o,Math.min(n,r.length)),{originalLineState:i}=E(e,s),{newLineState:a}=E(i,o);return a}function bt(e,t,n){let r={component:b,..._(e),settings:{}};return ue(r,t,n)}function ln(e,t,n,r,o){let s=e.properties?.items??[],i="",a=[],c=[];for(let l=t;l<=r;l+=1){let u=s[l];if(!u)continue;let f=l===t?n:0,d=l===r?o:(u.text??"").length,h=bt(u,f,d),m=i.length;i+=h.properties.text??"";for(let g of h.properties.inlineStyleRanges??[])a.push({...g,offset:g.offset+m});for(let g of h.properties.entityRanges??[])c.push({...g,offset:g.offset+m});}return [{component:b,..._({text:i,inlineStyleRanges:a,entityRanges:c}),settings:{}}]}function cn(e,t,n,r,o){let s=structuredClone(e),i=s.properties?.items??[],a=i[t],c=i[r];if(!a||!c)return s;let{originalLineState:l}=E(_(a),n),{newLineState:u}=E(_(c),o);return s.properties.items=[...i.slice(0,t),{...a,text:l.properties.text,inlineStyleRanges:l.properties.inlineStyleRanges,entityRanges:l.properties.entityRanges},{...c,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges},...i.slice(r+1)],s}function an(e,t){let n=e.index,r=e.listItemIndex??-1,o=e.offset??0,s=t.listItemIndex??-1,i=t.endListItemIndex??s;if(n!==t.startIndex||s<0)return {index:n,offset:o,listItemIndex:r};if(s===i)return r!==s||o<=t.startOffset?{index:n,offset:o,listItemIndex:r}:o>=t.endOffset?{index:n,offset:o-(t.endOffset-t.startOffset),listItemIndex:r}:{index:n,offset:t.startOffset,listItemIndex:r};let a=Math.max(0,i-s-1);return r<s||r===s&&o<=t.startOffset?{index:n,offset:o,listItemIndex:r}:r===i&&o>=t.endOffset?{index:n,offset:o-t.endOffset,listItemIndex:s+1}:r>i?{index:n,offset:o,listItemIndex:r-a}:{index:n,offset:t.startOffset,listItemIndex:s}}function fe(e,t){let{startIndex:n,endIndex:r,startOffset:o,endOffset:s,listItemIndex:i=-1,endListItemIndex:a}=t;if(n<0||r<0||n>r)return [];if(n===r){let l=e[n];if(j(l)&&i>=0){let u=a??i,f=l.properties.items[i];return f?u===i?[bt(f,o,s)]:ln(l,i,o,u,s):[structuredClone(l)]}return x(l)?[ue(l,o,s)]:[structuredClone(l)]}let c=[];for(let l=n;l<=r;l+=1){let u=e[l];l===n&&x(u)?c.push(ue(u,o,O(u))):l===r&&x(u)?c.push(ue(u,0,s)):c.push(structuredClone(u));}return c}function un(e,t,n,r){let o=structuredClone(e),s=o.properties?.items?.[t];if(!s)return o;let i=_(s),{originalLineState:a}=E(i,n),{newLineState:c}=E(i,r),{state:l}=N(a,c);return o.properties.items[t]={...s,text:l.properties.text,inlineStyleRanges:l.properties.inlineStyleRanges,entityRanges:l.properties.entityRanges},o}function de(e,t){let{startIndex:n,endIndex:r,startOffset:o,endOffset:s,listItemIndex:i=-1,endListItemIndex:a}=t,c=[...e];if(n===r){let d=c[n];if(j(d)&&i>=0){let m=a??i;return c[n]=m===i?un(d,i,o,s):cn(d,i,o,m,s),{content:c,resultIndex:n,cursor:o,listItemIndex:i}}if(x(d)){let{originalLineState:m}=E(d,o),{newLineState:g}=E(d,s),{state:y,cursor:k}=N(m,g);return c[n]=y,{content:c,resultIndex:n,cursor:k}}c.splice(n,1);let h=Math.min(n,Math.max(0,c.length-1));return {content:c,resultIndex:h,cursor:0}}if(x(c[n])&&x(c[r]))return yt(c,{startIndex:n,endIndex:r,startOffset:o,endOffset:s});let l=[];x(c[n])&&l.push(E(c[n],o).originalLineState),x(c[r])&&l.push(E(c[r],s).newLineState);let u=l,f=0;if(l.length===2){let d=N(l[0],l[1]);u=[d.state],f=d.cursor;}else l.length===1&&(f=O(l[0]));return c.splice(n,r-n+1,...u),{content:c,resultIndex:u.length?n:Math.max(0,n-1),cursor:f}}function Nt(e,{source:t,drop:n,blocks:r}){if(!r?.length)return {content:[...e],resultIndex:Math.max(0,n.index),cursor:n.offset??0,listItemIndex:n.listItemIndex??-1};let o=de(e,t),s=an(n,t);return pe(o.content,{index:s.index,offset:s.offset,listItemIndex:s.listItemIndex,blocks:r})}function Lt(e,t,n){let r=[...e];r.splice(t+1,0,...n);let o=n[n.length-1];return {content:r,resultIndex:t+n.length,cursor:O(o),listItemIndex:-1}}function fn(e,{listIndex:t,itemIndex:n,offset:r,blocks:o}){let s=structuredClone(e[t]),i=s.properties?.items?.[n],a=o.length===1&&x(o[0]);if(!i||!a)return Lt(e,t,o);let c=_(i),l=_(o[0]?.properties),{originalLineState:u,newLineState:f}=E(c,r),{state:d}=N(u,l),{state:h,cursor:m}=N(d,f);s.properties.items[n]={...i,text:h.properties.text,inlineStyleRanges:h.properties.inlineStyleRanges,entityRanges:h.properties.entityRanges};let g=[...e];return g[t]=s,{content:g,resultIndex:t,cursor:m,listItemIndex:n}}function pe(e,{index:t,offset:n,blocks:r,listItemIndex:o=-1}){let s=[...e];if(!r?.length)return {content:s,resultIndex:Math.max(0,t),cursor:n??0};if(t<0||t>=s.length){s.push(...r);let m=r[r.length-1];return {content:s,resultIndex:s.length-1,cursor:O(m)}}let i=s[t];if(j(i)&&o>=0)return fn(s,{listIndex:t,itemIndex:o,offset:n??0,blocks:r});if(!x(i))return Lt(s,t,r);let{originalLineState:a,newLineState:c}=E(i,n??0),l=r[0],u=r[r.length-1],f=[];if(J(a,l)?f.push(N(a,l).state):(O(a)>0&&f.push(a),f.push(l)),r.length>1)f.push(...r.slice(1,-1)),J(u,c)?f.push(N(u,c).state):(f.push(u),O(c)>0&&f.push(c));else {let m=f[f.length-1];if(J(m,c)){let{state:g,cursor:y}=N(m,c);return f[f.length-1]=g,s.splice(t,1,...f),{content:s,resultIndex:t+f.length-1,cursor:y}}O(c)>0&&f.push(c);}s.splice(t,1,...f);let d=r.length>1&&J(u,c),h=t+f.length-1-(d||O(c)===0?0:1);return {content:s,resultIndex:Math.max(t,h),cursor:O(u)}}function St(e){if(!e)return null;try{let t=JSON.parse(e);if(t&&t.v===Rt&&Array.isArray(t.blocks))return t.blocks}catch{return null}return null}function dn(e){return new DOMParser().parseFromString(e,"text/html").body?.textContent??""}function It(e,t=b){return String(e).split(/\r\n|\n|\r/).map(r=>({component:t,..._({text:r}),settings:{}}))}function pn(e){return j(e)?(e.properties.items??[]).map(t=>t.text??"").join(`
4
+ `):x(e)?W(e.properties?.text):""}function gn(e){return e.map(pn).join(`
5
+ `)}function mn(e){return {v:Rt,blocks:e.map(t=>structuredClone(t))}}function ge(e,t){let n=mn(t);e.setData(Ct,JSON.stringify(n)),e.setData("text/plain",gn(t));}function De(e,t=b){if(!e)return [];let n=St(e.getData(Ct));if(n)return n;let r=e.getData("text/plain")??"",o=St(r);if(o)return o;if(r)return It(r,t);let s=e.getData("text/html")??"";return s?It(dn(s),t):[]}function Tt(e){let t=structuredClone(e);return t.componentId=X(),Array.isArray(t.properties?.items)&&(t.properties.items=t.properties.items.map(n=>({...n,componentId:X()}))),t}function H(e,t){return !!t?._getContentRoot()?.contains(e.target)}function hn(e,t){let n=F(e),r=ae(n,t);if(!r)return {listItemIndex:-1,endListItemIndex:-1};let o=ae(n,{startContainer:t.endContainer??t.startContainer});return {listItemIndex:r.index,endListItemIndex:o?.index??r.index}}function Q(e){let t=z();if(!t)return null;let n=le(t.startContainer)??Pe(t);if(!n)return null;let r=e._getBlockElementIndex(n);if(r<0)return null;let o=e.getContent(),s=j(o[r])?hn(n,t):{listItemIndex:-1,endListItemIndex:-1};if(t.collapsed){let c=pt();return {collapsed:true,startIndex:r,endIndex:r,startOffset:c?.start??0,endOffset:c?.start??0,listItemIndex:s.listItemIndex,endListItemIndex:s.endListItemIndex}}let i=gt(t),a=e._getBlockElementIndex(i.endBlock);return {collapsed:false,startIndex:r,endIndex:a,startOffset:i.startOffset,endOffset:i.endOffset,listItemIndex:r===a?s.listItemIndex:-1,endListItemIndex:r===a?s.endListItemIndex:-1}}function xn(e,t,n,r=-1){Te(()=>{let o=e._getBlockElements()[t],s=F(o),i=r>=0?ve(s)[r]??s:s;i?.isConnected&&mt(i,n);});}function At(e,t){return t.map(n=>{try{return e.normalizeComponentState(Tt(n))}catch{return null}}).filter(Boolean)}function Fe(e,t,n,r,o=-1){let s=t.map(i=>{try{return e.normalizeComponentState(i)}catch{return null}}).filter(Boolean);e.setContent(s),xn(e,n,r,o);}function En(e){let t=e.mrakomor;if(!t||!H(e,t)||!e.clipboardData)return;let n=Q(t);if(!n||n.collapsed)return;let r=fe(t.getContent(),n);r.length&&(e.preventDefault(),ge(e.clipboardData,r));}function yn(e){let t=e.mrakomor;if(!t||!H(e,t)||!e.clipboardData)return;let n=Q(t);if(!n||n.collapsed)return;let r=t.getContent(),o=fe(r,n);if(!o.length)return;e.preventDefault(),ge(e.clipboardData,o);let s=de(r,n);Fe(t,s.content,s.resultIndex,s.cursor,n.listItemIndex);}function Sn(e){let t=e.mrakomor;if(!t||e.target&&!H(e,t))return;e.preventDefault();let n=At(t,De(e.clipboardData,b));if(!n.length)return;let r=t.getContent(),o=Q(t);if(!o)return;let s=r,i=o.startIndex,a=o.startOffset;if(!o.collapsed){let l=de(s,o);s=l.content,i=l.resultIndex,a=l.cursor;}let c=pe(s,{index:i,offset:a,blocks:n,listItemIndex:o.listItemIndex});Fe(t,c.content,c.resultIndex,c.cursor,c.listItemIndex??o.listItemIndex);}function In(e){return !!e.target?.closest?.("ul, ol, li")}function Cn(e){let t=e.inputType;t!=="deleteByDrag"&&t!=="insertFromDrop"||!H(e,e.mrakomor)||!In(e)||e.preventDefault();}function Rn(e,t){if(typeof document.caretRangeFromPoint=="function")return document.caretRangeFromPoint(e,t);if(typeof document.caretPositionFromPoint=="function"){let n=document.caretPositionFromPoint(e,t);if(!n?.offsetNode)return null;let r=document.createRange();return r.setStart(n.offsetNode,n.offset),r.collapse(true),r}return null}function bn({root:e,mrakomor:t}){return {registerEvents(){S.COPY="mrakomor:copy",S.CUT="mrakomor:cut",S.PASTE="mrakomor:paste";},registerCommands(n){n.command.copy=(r={})=>{n.emitDomEvent(S.COPY,r);},n.command.cut=(r={})=>{n.emitDomEvent(S.CUT,r);},n.command.paste=(r={})=>{n.emitDomEvent(S.PASTE,r);};},registerHandlers(){t.register.help.add({id:"clipboard.copy",group:"editing",description:"Copy the selection",commands:[],shortcuts:["Mod+C"]}),t.register.help.add({id:"clipboard.cut",group:"editing",description:"Cut the selection",commands:[],shortcuts:["Mod+X"]}),t.register.help.add({id:"clipboard.paste",group:"editing",description:"Paste at the caret or selection",commands:[],shortcuts:["Mod+V"]});},registerListeners(){let{signal:n}=t.listenerAbortController,r=e??t.getRoot(),o=null;function s(l){if(!H(l,t)||!l.dataTransfer){o=null;return}let u=Q(t);if(!u||u.collapsed||(u.listItemIndex??-1)<0){o=null;return}let f=fe(t.getContent(),u);if(!f.length){o=null;return}o={selection:u,blocks:f},ge(l.dataTransfer,f),l.dataTransfer.effectAllowed="copyMove";}function i(l){!o||!H(l,t)||(l.preventDefault(),l.dataTransfer&&(l.dataTransfer.dropEffect=l.altKey||l.ctrlKey?"copy":"move"));}function a(l){if(!o||!H(l,t))return;l.preventDefault();let u=Rn(l.clientX,l.clientY);if(u){u.collapse(true);let y=window.getSelection();y.removeAllRanges(),y.addRange(u);}let f=At(t,o?.blocks??De(l.dataTransfer,b));if(!f.length){o=null;return}let d=Q(t);if(!d){o=null;return}let h=!!o?.selection&&!l.altKey&&!l.ctrlKey,m=t.getContent(),g=h?Nt(m,{source:o.selection,drop:{index:d.startIndex,offset:d.startOffset,listItemIndex:d.listItemIndex},blocks:f}):pe(m,{index:d.startIndex,offset:d.startOffset,listItemIndex:d.listItemIndex,blocks:f});Fe(t,g.content,g.resultIndex,g.cursor,g.listItemIndex??d.listItemIndex),o=null;}function c(){o=null;}r.addEventListener("copy",l=>t.emitDomEvent(S.COPY,l),{signal:n}),r.addEventListener("cut",l=>t.emitDomEvent(S.CUT,l),{signal:n}),r.addEventListener("paste",l=>t.emitDomEvent(S.PASTE,l),{signal:n}),r.addEventListener("dragstart",s,{signal:n}),r.addEventListener("dragover",i,{signal:n}),r.addEventListener("drop",a,{signal:n}),r.addEventListener("dragend",c,{signal:n}),t.emitter.on(S.COPY,En),t.emitter.on(S.CUT,yn),t.emitter.on(S.PASTE,Sn),t.emitter.on(S.BEFORE_INPUT,Cn);}}}exports.clipboardPlugin=bn;
@@ -1,3 +1,3 @@
1
- import {d,e as e$1}from'./chunk-Q7RMVYZR.mjs';import {a as a$1,m,l,s,n,q,r,k,j}from'./chunk-TX4RCFPO.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {i,f,e,o,p,a as a$2,s as s$1,r as r$1,t}from'./chunk-YHWQV2DB.mjs';import {n as n$1}from'./chunk-K2DMHAUD.mjs';var W="application/x-mrakomor-blocks+json",Z=1;function S(n){return l(n)?j(n.properties?.text).length:0}function A(n,t,e){let r=n?.properties?.text??"",o=Math.max(0,Math.min(t,r.length)),s$1=Math.max(o,Math.min(e,r.length)),{originalLineState:l}=s(n,s$1),{newLineState:f}=s(l,o);return f}function tt(n,t,e){let r=k({component:a$1,properties:{text:n?.text,inlineStyleRanges:n?.inlineStyleRanges,entityRanges:n?.entityRanges},settings:{}});return A(r,t,e)}function X(n){return k({properties:{text:n?.text,inlineStyleRanges:n?.inlineStyleRanges,entityRanges:n?.entityRanges}})}function ct(n,t,e,r,o){let s=n.properties?.items??[],l="",f=[],c=[];for(let i=t;i<=r;i+=1){let a=s[i];if(!a)continue;let u=i===t?e:0,d=i===r?o:(a.text??"").length,x=tt(a,u,d),p=l.length;l+=x.properties.text??"";for(let g of x.properties.inlineStyleRanges??[])f.push({...g,offset:g.offset+p});for(let g of x.properties.entityRanges??[])c.push({...g,offset:g.offset+p});}return [k({component:a$1,properties:{text:l,inlineStyleRanges:f,entityRanges:c},settings:{}})]}function at(n,t,e,r,o){let s$1=structuredClone(n),l=s$1.properties?.items??[],f=l[t],c=l[r];if(!f||!c)return s$1;let{originalLineState:i}=s(X(f),e),{newLineState:a}=s(X(c),o);return s$1.properties.items=[...l.slice(0,t),{...f,text:i.properties.text,inlineStyleRanges:i.properties.inlineStyleRanges,entityRanges:i.properties.entityRanges},{...c,text:a.properties.text,inlineStyleRanges:a.properties.inlineStyleRanges,entityRanges:a.properties.entityRanges},...l.slice(r+1)],s$1}function ft(n,t){let e=n.index,r=n.listItemIndex??-1,o=n.offset??0,s=t.listItemIndex??-1,l=t.endListItemIndex??s;if(e!==t.startIndex||s<0)return {index:e,offset:o,listItemIndex:r};if(s===l)return r!==s||o<=t.startOffset?{index:e,offset:o,listItemIndex:r}:o>=t.endOffset?{index:e,offset:o-(t.endOffset-t.startOffset),listItemIndex:r}:{index:e,offset:t.startOffset,listItemIndex:r};let f=Math.max(0,l-s-1);return r<s||r===s&&o<=t.startOffset?{index:e,offset:o,listItemIndex:r}:r===l&&o>=t.endOffset?{index:e,offset:o-t.endOffset,listItemIndex:s+1}:r>l?{index:e,offset:o,listItemIndex:r-f}:{index:e,offset:t.startOffset,listItemIndex:s}}function D(n,t){let{startIndex:e,endIndex:r,startOffset:o,endOffset:s,listItemIndex:l$1=-1,endListItemIndex:f}=t;if(e<0||r<0||e>r)return [];if(e===r){let i=n[e];if(m(i)&&l$1>=0){let a=f??l$1,u=i.properties.items[l$1];return u?a===l$1?[tt(u,o,s)]:ct(i,l$1,o,a,s):[structuredClone(i)]}return l(i)?[A(i,o,s)]:[structuredClone(i)]}let c=[];for(let i=e;i<=r;i+=1){let a=n[i];i===e&&l(a)?c.push(A(a,o,S(a))):i===r&&l(a)?c.push(A(a,0,s)):c.push(structuredClone(a));}return c}function ut(n,t,e,r){let o=structuredClone(n),s$1=o.properties?.items?.[t];if(!s$1)return o;let l=k({properties:{text:s$1.text,inlineStyleRanges:s$1.inlineStyleRanges,entityRanges:s$1.entityRanges}}),{originalLineState:f}=s(l,e),{newLineState:c}=s(l,r),{state:i}=q(f,c);return o.properties.items[t]={...s$1,text:i.properties.text,inlineStyleRanges:i.properties.inlineStyleRanges,entityRanges:i.properties.entityRanges},o}function T(n,t){let{startIndex:e,endIndex:r$1,startOffset:o,endOffset:s$1,listItemIndex:l$1=-1,endListItemIndex:f}=t,c=[...n];if(e===r$1){let d=c[e];if(m(d)&&l$1>=0){let p=f??l$1;return c[e]=p===l$1?ut(d,l$1,o,s$1):at(d,l$1,o,p,s$1),{content:c,resultIndex:e,cursor:o,listItemIndex:l$1}}if(l(d)){let{originalLineState:p}=s(d,o),{newLineState:g}=s(d,s$1),{state:B,cursor:lt}=q(p,g);return c[e]=B,{content:c,resultIndex:e,cursor:lt}}c.splice(e,1);let x=Math.min(e,Math.max(0,c.length-1));return {content:c,resultIndex:x,cursor:0}}if(l(c[e])&&l(c[r$1]))return r(c,{startIndex:e,endIndex:r$1,startOffset:o,endOffset:s$1});let i=[];l(c[e])&&i.push(s(c[e],o).originalLineState),l(c[r$1])&&i.push(s(c[r$1],s$1).newLineState);let a=i,u=0;if(i.length===2){let d=q(i[0],i[1]);a=[d.state],u=d.cursor;}else i.length===1&&(u=S(i[0]));return c.splice(e,r$1-e+1,...a),{content:c,resultIndex:a.length?e:Math.max(0,e-1),cursor:u}}function et(n,{source:t,drop:e,blocks:r}){if(!r?.length)return {content:[...n],resultIndex:Math.max(0,e.index),cursor:e.offset??0,listItemIndex:e.listItemIndex??-1};let o=T(n,t),s=ft(e,t);return M(o.content,{index:s.index,offset:s.offset,listItemIndex:s.listItemIndex,blocks:r})}function nt(n,t,e){let r=[...n];r.splice(t+1,0,...e);let o=e[e.length-1];return {content:r,resultIndex:t+e.length,cursor:S(o),listItemIndex:-1}}function dt(n,{listIndex:t,itemIndex:e,offset:r,blocks:o}){let s$1=structuredClone(n[t]),l$1=s$1.properties?.items?.[e],f=o.length===1&&l(o[0]);if(!l$1||!f)return nt(n,t,o);let c=k({properties:{text:l$1.text,inlineStyleRanges:l$1.inlineStyleRanges,entityRanges:l$1.entityRanges}}),i=k({properties:{text:o[0].properties?.text,inlineStyleRanges:o[0].properties?.inlineStyleRanges,entityRanges:o[0].properties?.entityRanges}}),{originalLineState:a,newLineState:u}=s(c,r),{state:d}=q(a,i),{state:x,cursor:p}=q(d,u);s$1.properties.items[e]={...l$1,text:x.properties.text,inlineStyleRanges:x.properties.inlineStyleRanges,entityRanges:x.properties.entityRanges};let g=[...n];return g[t]=s$1,{content:g,resultIndex:t,cursor:p,listItemIndex:e}}function M(n$1,{index:t,offset:e,blocks:r,listItemIndex:o=-1}){let s$1=[...n$1];if(!r?.length)return {content:s$1,resultIndex:Math.max(0,t),cursor:e??0};if(t<0||t>=s$1.length){s$1.push(...r);let p=r[r.length-1];return {content:s$1,resultIndex:s$1.length-1,cursor:S(p)}}let l$1=s$1[t];if(m(l$1)&&o>=0)return dt(s$1,{listIndex:t,itemIndex:o,offset:e??0,blocks:r});if(!l(l$1))return nt(s$1,t,r);let{originalLineState:f,newLineState:c}=s(l$1,e??0),i=r[0],a=r[r.length-1],u=[];if(n(f,i)?u.push(q(f,i).state):(S(f)>0&&u.push(f),u.push(i)),r.length>1)u.push(...r.slice(1,-1)),n(a,c)?u.push(q(a,c).state):(u.push(a),S(c)>0&&u.push(c));else {let p=u[u.length-1];if(n(p,c)){let{state:g,cursor:B}=q(p,c);return u[u.length-1]=g,s$1.splice(t,1,...u),{content:s$1,resultIndex:t+u.length-1,cursor:B}}S(c)>0&&u.push(c);}s$1.splice(t,1,...u);let d=r.length>1&&n(a,c),x=t+u.length-1-(d||S(c)===0?0:1);return {content:s$1,resultIndex:Math.max(t,x),cursor:S(a)}}function $(n){if(!n)return null;try{let t=JSON.parse(n);if(t&&t.v===Z&&Array.isArray(t.blocks))return t.blocks}catch{return null}return null}function pt(n){return new DOMParser().parseFromString(n,"text/html").body?.textContent??""}function Q(n,t=a$1){return String(n).split(/\r\n|\n|\r/).map(r=>k({component:t,properties:{text:r},settings:{}}))}function gt(n){return m(n)?(n.properties.items??[]).map(t=>t.text??"").join(`
2
- `):l(n)?j(n.properties?.text):""}function mt(n){return n.map(gt).join(`
3
- `)}function xt(n){return {v:Z,blocks:n.map(t=>structuredClone(t))}}function w(n,t){let e=xt(t);n.setData(W,JSON.stringify(e)),n.setData("text/plain",mt(t));}function U(n,t=a$1){if(!n)return [];let e=$(n.getData(W));if(e)return e;let r=n.getData("text/plain")??"",o=$(r);if(o)return o;if(r)return Q(r,t);let s=n.getData("text/html")??"";return s?Q(pt(s),t):[]}function rt(n){let t=structuredClone(n);return t.componentId=a$2(),Array.isArray(t.properties?.items)&&(t.properties.items=t.properties.items.map(e=>({...e,componentId:a$2()}))),t}function P(n){return !!n.target?.closest?.(".mrakomor-content")}function ot(n){return n?.nodeName==="UL"||n?.nodeName==="OL"}function st(n){let t$1=t(n)?.element;if(ot(t$1))return t$1;let e=s$1(n);return ot(e)?e:e?.querySelector?.("ul, ol")??t$1??e}function It(n,t){let e=st(n),r=d(e,t),o=d(e,{startContainer:t.endContainer??t.startContainer});if(!r)return {listItemIndex:-1,endListItemIndex:-1};let s=e$1(e,r),l=o?e$1(e,o):s;return {listItemIndex:s,endListItemIndex:l}}function O(n){let t=i();if(!t)return null;let e$1=f(t.startContainer)??e(t);if(!e$1)return null;let r=n._getBlockElementIndex(e$1);if(r<0)return null;let o$1=n.getContent(),s=m(o$1[r])?It(e$1,t):{listItemIndex:-1,endListItemIndex:-1};if(t.collapsed){let c=o();return {collapsed:true,startIndex:r,endIndex:r,startOffset:c?.start??0,endOffset:c?.start??0,listItemIndex:s.listItemIndex,endListItemIndex:s.endListItemIndex}}let l=p(t),f$1=n._getBlockElementIndex(l.endBlock);return {collapsed:false,startIndex:r,endIndex:f$1,startOffset:l.startOffset,endOffset:l.endOffset,listItemIndex:r===f$1?s.listItemIndex:-1,endListItemIndex:r===f$1?s.endListItemIndex:-1}}function ht(n,t,e,r=-1){n$1(()=>{let s=n.getRoot()?.querySelectorAll?.(".mrakomor-content .mrakomor-block-element")?.[t],l=s$1(s);if(r>=0){let f=st(s);l=f?.querySelector?.(`li[data-item-index="${r}"]`)??f?.querySelectorAll?.("li")?.[r]??l;}l?.isConnected&&r$1(l,e);});}function it(n,t){return t.map(e=>{try{return n.normalizeComponentState(rt(e))}catch{return null}}).filter(Boolean)}function Y(n,t,e,r,o=-1){let s=t.map(l=>{try{return n.normalizeComponentState(l)}catch{return null}}).filter(Boolean);n.setContent(s),ht(n,e,r,o);}function yt(n){let t=n.mrakomor;if(!t||!P(n)||!n.clipboardData)return;let e=O(t);if(!e||e.collapsed)return;let r=D(t.getContent(),e);r.length&&(n.preventDefault(),w(n.clipboardData,r));}function St(n){let t=n.mrakomor;if(!t||!P(n)||!n.clipboardData)return;let e=O(t);if(!e||e.collapsed)return;let r=t.getContent(),o=D(r,e);if(!o.length)return;n.preventDefault(),w(n.clipboardData,o);let s=T(r,e);Y(t,s.content,s.resultIndex,s.cursor,e.listItemIndex);}function Rt(n){let t=n.mrakomor;if(!t||n.target&&!P(n))return;n.preventDefault();let e=it(t,U(n.clipboardData,a$1));if(!e.length)return;let r=t.getContent(),o=O(t);if(!o)return;let s=r,l=o.startIndex,f=o.startOffset;if(!o.collapsed){let i=T(s,o);s=i.content,l=i.resultIndex,f=i.cursor;}let c=M(s,{index:l,offset:f,blocks:e,listItemIndex:o.listItemIndex});Y(t,c.content,c.resultIndex,c.cursor,c.listItemIndex??o.listItemIndex);}function Ct(n){return !!n.target?.closest?.("ul, ol, li")}function Lt(n){let t=n.inputType;t!=="deleteByDrag"&&t!=="insertFromDrop"||!P(n)||!Ct(n)||n.preventDefault();}function Pt(n,t){if(typeof document.caretRangeFromPoint=="function")return document.caretRangeFromPoint(n,t);if(typeof document.caretPositionFromPoint=="function"){let e=document.caretPositionFromPoint(n,t);if(!e?.offsetNode)return null;let r=document.createRange();return r.setStart(e.offsetNode,e.offset),r.collapse(true),r}return null}function Bt({root:n,mrakomor:t}){return {registerEvents(){a.COPY="mrakomor:copy",a.CUT="mrakomor:cut",a.PASTE="mrakomor:paste";},registerCommands(e){e.command.copy=(r={})=>{e.emitDomEvent(a.COPY,r);},e.command.cut=(r={})=>{e.emitDomEvent(a.CUT,r);},e.command.paste=(r={})=>{e.emitDomEvent(a.PASTE,r);};},registerHandlers(){t.register.help.add({id:"clipboard.copy",group:"editing",description:"Copy the selection",commands:[],shortcuts:["Mod+C"]}),t.register.help.add({id:"clipboard.cut",group:"editing",description:"Cut the selection",commands:[],shortcuts:["Mod+X"]}),t.register.help.add({id:"clipboard.paste",group:"editing",description:"Paste at the caret or selection",commands:[],shortcuts:["Mod+V"]});},registerListeners(){let{signal:e}=t.listenerAbortController,r=n??t.getRoot(),o=null;function s(i){if(!P(i)||!i.dataTransfer){o=null;return}let a=O(t);if(!a||a.collapsed||(a.listItemIndex??-1)<0){o=null;return}let u=D(t.getContent(),a);if(!u.length){o=null;return}o={selection:a,blocks:u},w(i.dataTransfer,u),i.dataTransfer.effectAllowed="copyMove";}function l(i){!o||!P(i)||(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=i.altKey||i.ctrlKey?"copy":"move"));}function f(i){if(!o||!P(i))return;i.preventDefault();let a=Pt(i.clientX,i.clientY);if(a){a.collapse(true);let B=window.getSelection();B.removeAllRanges(),B.addRange(a);}let u=it(t,o?.blocks??U(i.dataTransfer,a$1));if(!u.length){o=null;return}let d=O(t);if(!d){o=null;return}let x=!!o?.selection&&!i.altKey&&!i.ctrlKey,p=t.getContent(),g=x?et(p,{source:o.selection,drop:{index:d.startIndex,offset:d.startOffset,listItemIndex:d.listItemIndex},blocks:u}):M(p,{index:d.startIndex,offset:d.startOffset,listItemIndex:d.listItemIndex,blocks:u});Y(t,g.content,g.resultIndex,g.cursor,g.listItemIndex??d.listItemIndex),o=null;}function c(){o=null;}r.addEventListener("copy",i=>t.emitDomEvent(a.COPY,i),{signal:e}),r.addEventListener("cut",i=>t.emitDomEvent(a.CUT,i),{signal:e}),r.addEventListener("paste",i=>t.emitDomEvent(a.PASTE,i),{signal:e}),r.addEventListener("dragstart",s,{signal:e}),r.addEventListener("dragover",l,{signal:e}),r.addEventListener("drop",f,{signal:e}),r.addEventListener("dragend",c,{signal:e}),t.emitter.on(a.COPY,yt),t.emitter.on(a.CUT,St),t.emitter.on(a.PASTE,Rt),t.emitter.on(a.BEFORE_INPUT,Lt);}}}export{Bt as clipboardPlugin};
1
+ import {a as a$1,q as q$1,p,w as w$1,r as r$1,u,v as v$1,m,j as j$1}from'./chunk-ZDMD7SRT.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {k as k$1,f,e,q as q$2,r,u as u$1,j,a as a$2,i,t}from'./chunk-SCFD3XBH.mjs';import {n}from'./chunk-K2DMHAUD.mjs';var Q="application/x-mrakomor-blocks+json",W=1;function y(r){return p(r)?j$1(r.properties?.text).length:0}function T(r,t,e){let n=r?.properties?.text??"",o=Math.max(0,Math.min(t,n.length)),s=Math.max(o,Math.min(e,n.length)),{originalLineState:c}=w$1(r,s),{newLineState:d}=w$1(c,o);return d}function Z(r,t,e){let n={component:a$1,...m(r),settings:{}};return T(n,t,e)}function ot(r,t,e,n,o){let s=r.properties?.items??[],c="",d=[],l=[];for(let i=t;i<=n;i+=1){let a=s[i];if(!a)continue;let f=i===t?e:0,u=i===n?o:(a.text??"").length,x=Z(a,f,u),p=c.length;c+=x.properties.text??"";for(let m of x.properties.inlineStyleRanges??[])d.push({...m,offset:m.offset+p});for(let m of x.properties.entityRanges??[])l.push({...m,offset:m.offset+p});}return [{component:a$1,...m({text:c,inlineStyleRanges:d,entityRanges:l}),settings:{}}]}function st(r,t,e,n,o){let s=structuredClone(r),c=s.properties?.items??[],d=c[t],l=c[n];if(!d||!l)return s;let{originalLineState:i}=w$1(m(d),e),{newLineState:a}=w$1(m(l),o);return s.properties.items=[...c.slice(0,t),{...d,text:i.properties.text,inlineStyleRanges:i.properties.inlineStyleRanges,entityRanges:i.properties.entityRanges},{...l,text:a.properties.text,inlineStyleRanges:a.properties.inlineStyleRanges,entityRanges:a.properties.entityRanges},...c.slice(n+1)],s}function it(r,t){let e=r.index,n=r.listItemIndex??-1,o=r.offset??0,s=t.listItemIndex??-1,c=t.endListItemIndex??s;if(e!==t.startIndex||s<0)return {index:e,offset:o,listItemIndex:n};if(s===c)return n!==s||o<=t.startOffset?{index:e,offset:o,listItemIndex:n}:o>=t.endOffset?{index:e,offset:o-(t.endOffset-t.startOffset),listItemIndex:n}:{index:e,offset:t.startOffset,listItemIndex:n};let d=Math.max(0,c-s-1);return n<s||n===s&&o<=t.startOffset?{index:e,offset:o,listItemIndex:n}:n===c&&o>=t.endOffset?{index:e,offset:o-t.endOffset,listItemIndex:s+1}:n>c?{index:e,offset:o,listItemIndex:n-d}:{index:e,offset:t.startOffset,listItemIndex:s}}function D(r,t){let{startIndex:e,endIndex:n,startOffset:o,endOffset:s,listItemIndex:c=-1,endListItemIndex:d}=t;if(e<0||n<0||e>n)return [];if(e===n){let i=r[e];if(q$1(i)&&c>=0){let a=d??c,f=i.properties.items[c];return f?a===c?[Z(f,o,s)]:ot(i,c,o,a,s):[structuredClone(i)]}return p(i)?[T(i,o,s)]:[structuredClone(i)]}let l=[];for(let i=e;i<=n;i+=1){let a=r[i];i===e&&p(a)?l.push(T(a,o,y(a))):i===n&&p(a)?l.push(T(a,0,s)):l.push(structuredClone(a));}return l}function lt(r,t,e,n){let o=structuredClone(r),s=o.properties?.items?.[t];if(!s)return o;let c=m(s),{originalLineState:d}=w$1(c,e),{newLineState:l}=w$1(c,n),{state:i}=u(d,l);return o.properties.items[t]={...s,text:i.properties.text,inlineStyleRanges:i.properties.inlineStyleRanges,entityRanges:i.properties.entityRanges},o}function A(r,t){let{startIndex:e,endIndex:n,startOffset:o,endOffset:s,listItemIndex:c=-1,endListItemIndex:d}=t,l=[...r];if(e===n){let u$1=l[e];if(q$1(u$1)&&c>=0){let p=d??c;return l[e]=p===c?lt(u$1,c,o,s):st(u$1,c,o,p,s),{content:l,resultIndex:e,cursor:o,listItemIndex:c}}if(p(u$1)){let{originalLineState:p}=w$1(u$1,o),{newLineState:m}=w$1(u$1,s),{state:E,cursor:rt}=u(p,m);return l[e]=E,{content:l,resultIndex:e,cursor:rt}}l.splice(e,1);let x=Math.min(e,Math.max(0,l.length-1));return {content:l,resultIndex:x,cursor:0}}if(p(l[e])&&p(l[n]))return v$1(l,{startIndex:e,endIndex:n,startOffset:o,endOffset:s});let i=[];p(l[e])&&i.push(w$1(l[e],o).originalLineState),p(l[n])&&i.push(w$1(l[n],s).newLineState);let a=i,f=0;if(i.length===2){let u$1=u(i[0],i[1]);a=[u$1.state],f=u$1.cursor;}else i.length===1&&(f=y(i[0]));return l.splice(e,n-e+1,...a),{content:l,resultIndex:a.length?e:Math.max(0,e-1),cursor:f}}function $(r,{source:t,drop:e,blocks:n}){if(!n?.length)return {content:[...r],resultIndex:Math.max(0,e.index),cursor:e.offset??0,listItemIndex:e.listItemIndex??-1};let o=A(r,t),s=it(e,t);return M(o.content,{index:s.index,offset:s.offset,listItemIndex:s.listItemIndex,blocks:n})}function tt(r,t,e){let n=[...r];n.splice(t+1,0,...e);let o=e[e.length-1];return {content:n,resultIndex:t+e.length,cursor:y(o),listItemIndex:-1}}function ct(r,{listIndex:t,itemIndex:e,offset:n,blocks:o}){let s=structuredClone(r[t]),c=s.properties?.items?.[e],d=o.length===1&&p(o[0]);if(!c||!d)return tt(r,t,o);let l=m(c),i=m(o[0]?.properties),{originalLineState:a,newLineState:f}=w$1(l,n),{state:u$1}=u(a,i),{state:x,cursor:p$1}=u(u$1,f);s.properties.items[e]={...c,text:x.properties.text,inlineStyleRanges:x.properties.inlineStyleRanges,entityRanges:x.properties.entityRanges};let m$1=[...r];return m$1[t]=s,{content:m$1,resultIndex:t,cursor:p$1,listItemIndex:e}}function M(r,{index:t,offset:e,blocks:n,listItemIndex:o=-1}){let s=[...r];if(!n?.length)return {content:s,resultIndex:Math.max(0,t),cursor:e??0};if(t<0||t>=s.length){s.push(...n);let p=n[n.length-1];return {content:s,resultIndex:s.length-1,cursor:y(p)}}let c=s[t];if(q$1(c)&&o>=0)return ct(s,{listIndex:t,itemIndex:o,offset:e??0,blocks:n});if(!p(c))return tt(s,t,n);let{originalLineState:d,newLineState:l}=w$1(c,e??0),i=n[0],a=n[n.length-1],f=[];if(r$1(d,i)?f.push(u(d,i).state):(y(d)>0&&f.push(d),f.push(i)),n.length>1)f.push(...n.slice(1,-1)),r$1(a,l)?f.push(u(a,l).state):(f.push(a),y(l)>0&&f.push(l));else {let p=f[f.length-1];if(r$1(p,l)){let{state:m,cursor:E}=u(p,l);return f[f.length-1]=m,s.splice(t,1,...f),{content:s,resultIndex:t+f.length-1,cursor:E}}y(l)>0&&f.push(l);}s.splice(t,1,...f);let u$1=n.length>1&&r$1(a,l),x=t+f.length-1-(u$1||y(l)===0?0:1);return {content:s,resultIndex:Math.max(t,x),cursor:y(a)}}function q(r){if(!r)return null;try{let t=JSON.parse(r);if(t&&t.v===W&&Array.isArray(t.blocks))return t.blocks}catch{return null}return null}function at(r){return new DOMParser().parseFromString(r,"text/html").body?.textContent??""}function v(r,t=a$1){return String(r).split(/\r\n|\n|\r/).map(n=>({component:t,...m({text:n}),settings:{}}))}function ft(r){return q$1(r)?(r.properties.items??[]).map(t=>t.text??"").join(`
2
+ `):p(r)?j$1(r.properties?.text):""}function dt(r){return r.map(ft).join(`
3
+ `)}function ut(r){return {v:W,blocks:r.map(t=>structuredClone(t))}}function w(r,t){let e=ut(t);r.setData(Q,JSON.stringify(e)),r.setData("text/plain",dt(t));}function k(r,t=a$1){if(!r)return [];let e=q(r.getData(Q));if(e)return e;let n=r.getData("text/plain")??"",o=q(n);if(o)return o;if(n)return v(n,t);let s=r.getData("text/html")??"";return s?v(at(s),t):[]}function et(r){let t=structuredClone(r);return t.componentId=a$2(),Array.isArray(t.properties?.items)&&(t.properties.items=t.properties.items.map(e=>({...e,componentId:a$2()}))),t}function P(r,t){return !!t?._getContentRoot()?.contains(r.target)}function pt(r,t){let e=u$1(r),n=j(e,t);if(!n)return {listItemIndex:-1,endListItemIndex:-1};let o=j(e,{startContainer:t.endContainer??t.startContainer});return {listItemIndex:n.index,endListItemIndex:o?.index??n.index}}function O(r$1){let t=k$1();if(!t)return null;let e$1=f(t.startContainer)??e(t);if(!e$1)return null;let n=r$1._getBlockElementIndex(e$1);if(n<0)return null;let o=r$1.getContent(),s=q$1(o[n])?pt(e$1,t):{listItemIndex:-1,endListItemIndex:-1};if(t.collapsed){let l=q$2();return {collapsed:true,startIndex:n,endIndex:n,startOffset:l?.start??0,endOffset:l?.start??0,listItemIndex:s.listItemIndex,endListItemIndex:s.endListItemIndex}}let c=r(t),d=r$1._getBlockElementIndex(c.endBlock);return {collapsed:false,startIndex:n,endIndex:d,startOffset:c.startOffset,endOffset:c.endOffset,listItemIndex:n===d?s.listItemIndex:-1,endListItemIndex:n===d?s.endListItemIndex:-1}}function mt(r,t$1,e,n$1=-1){n(()=>{let o=r._getBlockElements()[t$1],s=u$1(o),c=n$1>=0?i(s)[n$1]??s:s;c?.isConnected&&t(c,e);});}function nt(r,t){return t.map(e=>{try{return r.normalizeComponentState(et(e))}catch{return null}}).filter(Boolean)}function Y(r,t,e,n,o=-1){let s=t.map(c=>{try{return r.normalizeComponentState(c)}catch{return null}}).filter(Boolean);r.setContent(s),mt(r,e,n,o);}function gt(r){let t=r.mrakomor;if(!t||!P(r,t)||!r.clipboardData)return;let e=O(t);if(!e||e.collapsed)return;let n=D(t.getContent(),e);n.length&&(r.preventDefault(),w(r.clipboardData,n));}function xt(r){let t=r.mrakomor;if(!t||!P(r,t)||!r.clipboardData)return;let e=O(t);if(!e||e.collapsed)return;let n=t.getContent(),o=D(n,e);if(!o.length)return;r.preventDefault(),w(r.clipboardData,o);let s=A(n,e);Y(t,s.content,s.resultIndex,s.cursor,e.listItemIndex);}function It(r){let t=r.mrakomor;if(!t||r.target&&!P(r,t))return;r.preventDefault();let e=nt(t,k(r.clipboardData,a$1));if(!e.length)return;let n=t.getContent(),o=O(t);if(!o)return;let s=n,c=o.startIndex,d=o.startOffset;if(!o.collapsed){let i=A(s,o);s=i.content,c=i.resultIndex,d=i.cursor;}let l=M(s,{index:c,offset:d,blocks:e,listItemIndex:o.listItemIndex});Y(t,l.content,l.resultIndex,l.cursor,l.listItemIndex??o.listItemIndex);}function ht(r){return !!r.target?.closest?.("ul, ol, li")}function Ct(r){let t=r.inputType;t!=="deleteByDrag"&&t!=="insertFromDrop"||!P(r,r.mrakomor)||!ht(r)||r.preventDefault();}function St(r,t){if(typeof document.caretRangeFromPoint=="function")return document.caretRangeFromPoint(r,t);if(typeof document.caretPositionFromPoint=="function"){let e=document.caretPositionFromPoint(r,t);if(!e?.offsetNode)return null;let n=document.createRange();return n.setStart(e.offsetNode,e.offset),n.collapse(true),n}return null}function yt({root:r,mrakomor:t}){return {registerEvents(){a.COPY="mrakomor:copy",a.CUT="mrakomor:cut",a.PASTE="mrakomor:paste";},registerCommands(e){e.command.copy=(n={})=>{e.emitDomEvent(a.COPY,n);},e.command.cut=(n={})=>{e.emitDomEvent(a.CUT,n);},e.command.paste=(n={})=>{e.emitDomEvent(a.PASTE,n);};},registerHandlers(){t.register.help.add({id:"clipboard.copy",group:"editing",description:"Copy the selection",commands:[],shortcuts:["Mod+C"]}),t.register.help.add({id:"clipboard.cut",group:"editing",description:"Cut the selection",commands:[],shortcuts:["Mod+X"]}),t.register.help.add({id:"clipboard.paste",group:"editing",description:"Paste at the caret or selection",commands:[],shortcuts:["Mod+V"]});},registerListeners(){let{signal:e}=t.listenerAbortController,n=r??t.getRoot(),o=null;function s(i){if(!P(i,t)||!i.dataTransfer){o=null;return}let a=O(t);if(!a||a.collapsed||(a.listItemIndex??-1)<0){o=null;return}let f=D(t.getContent(),a);if(!f.length){o=null;return}o={selection:a,blocks:f},w(i.dataTransfer,f),i.dataTransfer.effectAllowed="copyMove";}function c(i){!o||!P(i,t)||(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=i.altKey||i.ctrlKey?"copy":"move"));}function d(i){if(!o||!P(i,t))return;i.preventDefault();let a=St(i.clientX,i.clientY);if(a){a.collapse(true);let E=window.getSelection();E.removeAllRanges(),E.addRange(a);}let f=nt(t,o?.blocks??k(i.dataTransfer,a$1));if(!f.length){o=null;return}let u=O(t);if(!u){o=null;return}let x=!!o?.selection&&!i.altKey&&!i.ctrlKey,p=t.getContent(),m=x?$(p,{source:o.selection,drop:{index:u.startIndex,offset:u.startOffset,listItemIndex:u.listItemIndex},blocks:f}):M(p,{index:u.startIndex,offset:u.startOffset,listItemIndex:u.listItemIndex,blocks:f});Y(t,m.content,m.resultIndex,m.cursor,m.listItemIndex??u.listItemIndex),o=null;}function l(){o=null;}n.addEventListener("copy",i=>t.emitDomEvent(a.COPY,i),{signal:e}),n.addEventListener("cut",i=>t.emitDomEvent(a.CUT,i),{signal:e}),n.addEventListener("paste",i=>t.emitDomEvent(a.PASTE,i),{signal:e}),n.addEventListener("dragstart",s,{signal:e}),n.addEventListener("dragover",c,{signal:e}),n.addEventListener("drop",d,{signal:e}),n.addEventListener("dragend",l,{signal:e}),t.emitter.on(a.COPY,gt),t.emitter.on(a.CUT,xt),t.emitter.on(a.PASTE,It),t.emitter.on(a.BEFORE_INPUT,Ct);}}}export{yt as clipboardPlugin};
package/dist/footer.cjs CHANGED
@@ -1,2 +1,5 @@
1
1
  'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/footer/footer.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.mrakomor-footer-plugin-container{display:contents}.mrakomor-footer-container{position:relative;flex:0 0 auto;display:flex;align-items:stretch;justify-content:space-between;gap:0;height:22px;min-height:22px;padding:0;border-top:1px solid #e4e7ec;background:#f3f4f6;color:#5b6472;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:11px;line-height:22px;user-select:none;pointer-events:none}.mrakomor-footer-start,.mrakomor-footer-end{display:flex;align-items:stretch;min-width:0}.mrakomor-footer-end{margin-left:auto;flex-shrink:0}.mrakomor-footer-item{display:inline-flex;align-items:center;max-width:100%;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#5b6472}.mrakomor-footer-item+.mrakomor-footer-item{border-left:1px solid #e0e4ea}.mrakomor-footer-action{display:inline-flex;align-items:center;gap:4px;height:100%;margin:0;padding:0 10px;border:none;border-left:1px solid #e0e4ea;background:transparent;color:inherit;font:inherit;line-height:inherit;cursor:pointer;pointer-events:all}.mrakomor-footer-action:hover{background:#e9edf2;color:#1f2937}.mrakomor-footer-action:focus-visible{outline:1px solid #94a3b8;outline-offset:-1px}.mrakomor-footer-action__icon{font-size:12px;font-weight:700;line-height:1}
2
- `,document.head.appendChild(n);}}})();var pe=class{next(...e){}error(...e){}complete(...e){}},ee=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var U=Symbol("@esmj/signals:type"),P=Symbol("@esmj/signals:name");var m=null,te=false,me=[];function j(e){let t=m;m=null;let n=e();return m=t,n}function We(){te=false;let e=ye();for(let n of e)n.get();let t=me;me=[];for(let n of t)n();}function Xe(){te||(te=true,queueMicrotask(We));}var he=Symbol("@esmj/signals:internal observable"),b=Symbol("@esmj/signals:original function"),Ke=class extends ee{#e=new Set;#o=null;constructor(e){super(),this.#o=e,this.pipe(t=>{let n=t.subscribe.bind(t),o=t.unsubscribe.bind(t);return t.subscribe=r=>{n(r),this.#e.add(r);},t.unsubscribe=r=>{o(r),this.#e.delete(r);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>j(()=>{this.#e.add(e),this.#o();}),e.next[b]=void 0),e instanceof we&&e.next[b]===void 0){let t=e.next.bind(e);e.next=()=>j(()=>{this.#e.add(e),t(),this.#o();}),e.next[b]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[b]){let n=t.get,o=n.bind(t);t.get=()=>j(()=>(this.#e.delete(t),o())),t.get[b]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[b]?e.next[b]:e.next,e.get=e.get[b]?e.get[b]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function ge(e){z=new Ke(e);}ge(()=>{Xe();});function ye(){return z.getPending()}function be(e){return z.watch(e)}function xe(e){return z.unwatch(e)}var x=Symbol("@esmj/signals:no error"),we=class ke extends pe{#e=true;#o=false;#n=null;#r=this.#d();#u=null;#l=null;#s=0;#i=new Map;#t=x;constructor(t,n){super(),this.#u=t,this.#l=n,this.debug=n?.debug,this[U]="computed",this[P]=n?.debug??null,this.get=this.get.bind(this);}#c(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.dependencies.clear();}#d(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#s}getDebugInfo(){return {name:this[P],dirty:this.#e,revision:this.#s,sourceDependencies:[...this.#i.keys()]}}#f(){for(let[t,n]of this.#i)if(t instanceof ke&&j(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[he].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=E(this.#a(),this.#l)),(this.#e||this.#t!==x)&&(this.#i.size===0||this.#f()?this.#a():this.#e=false),m&&m.sourceRevisions.set(this,this.#s),this.#t!==x)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=E(this.#a(),this.#l)),(this.#e||this.#t!==x)&&(this.#i.size===0||this.#f()?this.#a():this.#e=false),this.#t!==x)throw this.#t;return this.#n.peek()}#a(){this.#o=true,this.#e=false,this.#t=x,this.#c(),this.#r.sourceRevisions.clear();let t=m;m=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return m=t,this.#i=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=x,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===x&&this.#n&&this.#n.set(n),this.#s++,n}destroy(){this.#c(),this.#i.clear(),this.#e=true,this.#t=x;}};function M(e,t){return new we(e,t)}function g(e,t){let n,{debug:o,...r}={},i=M(()=>{n?.(),n=e();},{equals:()=>false,...r});i.get(),be(i);let s=()=>{n?.(),i.destroy(),xe(i);};return s[Symbol.dispose]=s,s[U]="effect",s[P]=o??null,s.__RX_COMPUTED__=i,s}function E(e,t={}){let n=t?.equals??Object.is,o=0,r=new ee;function i(){return m&&(m.dependencies.set(r,r.subscribe(m.observer)),m.sourceRevisions.set(d,o)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,o++,r.next();}return e}function c(){return o}let d={get:i,set:a,peek:s,getRevision:c,[he]:r,[U]:"signal",[P]:t?.debug??null};return d}function H(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var $e=Symbol("node-component"),V=Symbol("node-internal"),Ge=Symbol("keep-literal"),Y=Symbol("raw-props");var Re=null;function q(){return Re}function W(e){Re=e;}function Fe(e){return e?.[$e]||null}function Se(e,t){e[$e]=t;}function X(e,t={disposers:[],id:H()}){return e?.[V]?e[V]:(e&&(e[V]=t),t)}function Ze(e){return e[V]}function k(e,t){let n=Ze(e);n||(n=X(e)),n.disposers.push(t);}function oe(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function S(e,t){let n=q();W(e);try{return t()}finally{W(n);}}var re=new Map,K=new Map,ve=new Map;function qe(e,t){let n=typeof t=="function"?t:r=>!!t?.includes(r),o=Object.create(null);for(let r of Object.keys(e)){let i=e[r];r==="children"||n(r)?o[r]=i:i?.[Ge]?o[r]=i():i!=null&&typeof i.get=="function"?o[r]=i:typeof i=="function"?o[r]=M(i):o[r]=E(i);}return o}function _(e){let t=e.componentId,n=re.get(t);if(n){re.delete(t);for(let o of n){let r=o();typeof r=="function"&&oe(K,t,r);}}}function et(e){let t=K.get(e);if(t){K.delete(e);for(let n of t)n();}}function tt(e){let t=ve.get(e);if(t){ve.delete(e);for(let n of t)n();}}function J(e){if(!e)return;let t=X(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=Fe(e);if(n&&(et(n.componentId),tt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;J(o),o=r;}}}function A(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ce(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function nt(e,t,n){let o=H(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let i=Ce(e)?void 0:e[Y],s={...qe(t??{},i),children:n},a=q(),c={disposers:[],id:o,contexts:new Map(a?.contexts)};W(c);let d;if(Ce(e)){r.ClassConstructor=e;let f=new e(s);r.classInstance=f,typeof f.onMount=="function"&&oe(re,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&oe(K,o,()=>{f.onUnmount?.();}),d=f.render();}else d=e(s);W(a);let u=ot(d);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)X(f,c),Se(f,r);else X(u,c),u instanceof Node&&Se(u,r);return u}};return r}function ue(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{_(t);});}function ot(e){return e instanceof Node?e:A(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Ne={className:"class",htmlFor:"for"},je=new Set(["value","defaultValue","checked","selected","indeterminate"]),rt=new Set(["srcdoc"]),it=new Set(["href","src","action","formaction","xlink:href"]),st=new Set(["securitypolicyviolation"]),at=new Set(["contenteditable","draggable","spellcheck"]);function I(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Le=Symbol("Fragment");function v(e,t,n){if(e===Le){let r=document.createDocumentFragment();return ie(r,Me(n)),r}if(typeof e=="function")return nt(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let o=document.createElement(e);return t.id&&o.setAttribute("id",t.id),Q(o,t),ie(o,Me(n)),o}function ne(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function lt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function ut(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return rt.has(n)?true:it.has(n)&&t!==null&&t!==void 0&&lt(String(t))}function Te(e){return typeof e!="string"?e:Ne[e]?Ne[e]:e}function ct(e,t){let n=Te(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return at.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Ee(e,t,n){let o=ct(t,n);if(o===null){e.removeAttribute(t);return}if(ut(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function Q(e,t){let n=q();for(let[o,r]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(o!=="id"){if(o=Te(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(I(r)){let i=g(()=>{S(n,()=>{ne(e,r.get());});});k(e,i);}else if(typeof r=="function"){let i=g(()=>{S(n,()=>{ne(e,r());});});k(e,i);}else ne(e,r);continue}if(o==="style"){if(I(r)){let i=g(()=>{S(n,()=>{Object.assign(e.style,r.get());});});k(e,i);}else typeof r=="object"&&r!==null?Object.assign(e.style,r):e.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let i=o.slice(2).toLowerCase();if(st.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,r);continue}if(I(r)||typeof r=="function"){let i=o,s=g(()=>{S(n,()=>{let a=typeof r=="function"?r():r.get();je.has(i)?e[i]=a??"":Ee(e,i,a);});});k(e,s);continue}je.has(o)||typeof o=="symbol"?e[o]=r??"":Ee(e,o,r);}}function Me(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ie(e,t){for(let n of t)Oe(e,n);}function Oe(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){Ae(e,t);return}if(A(t)){ue(e,t);return}if(I(t)){Ae(e,()=>t.get());return}if(Array.isArray(t)){ie(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function L(e){let t=null,n=e;return A(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function Z(e,t=true){for(let n of e)t&&J(n),n.remove();}function Ae(e,t){let n=q(),o=document.createComment("");e.appendChild(o);let r=[],i=g(()=>{S(n,()=>{let s=t(),{nodes:a,instance:c}=L(s);Z(r),a.length&&o.after(...a),c&&queueMicrotask(()=>_(c)),r=a;});});k(e,i);}function Ie(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(J(e),e.innerHTML=""),A(t)?ue(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function pt(e,t){let n=0;for(let o of t){let i=e.register.blocks.getByNamespace(o?.component)?.toExchangeState(o)?.properties?.text;n+=(i??"").length;}return n}function _e(e){return e.toLocaleString()}function mt({mrakomor:e}){let t=e.get();return v("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[v("div",{className:"mrakomor-footer-start"},[v("span",{className:"mrakomor-footer-item"},()=>{let n=t._getContentState().length;return `${_e(n)} ${n===1?"block":"blocks"}`}),v("span",{className:"mrakomor-footer-item"},()=>{let n=pt(t,t._getContentState());return `${_e(n)} ${n===1?"character":"characters"}`})]),v("div",{className:"mrakomor-footer-end"})])}function ht(e){let t=e.getRoot();return t?t.classList?.contains("mrakomor-editor")?t:t.querySelector(".mrakomor-editor"):null}function gt({mrakomor:e}){let t=null,n=null;return {onMount(){let o=ht(e);o&&(t=document.createElement("div"),t.className="mrakomor-footer-plugin-container",o.append(t),n=Ie(t,v(mt,{mrakomor:e})));},onUnmount(){n?.(),t?.remove(),n=null,t=null;}}}exports.footerPlugin=gt;
2
+ `,document.head.appendChild(n);}}})();var me=class{next(...e){}error(...e){}complete(...e){}},ee=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var z=Symbol("@esmj/signals:type"),P=Symbol("@esmj/signals:name");var m=null,te=false,he=[];function C(e){let t=m;m=null;let n=e();return m=t,n}function Xe(){te=false;let e=xe();for(let n of e)n.get();let t=he;he=[];for(let n of t)n();}function Ke(){te||(te=true,queueMicrotask(Xe));}var ge=Symbol("@esmj/signals:internal observable"),x=Symbol("@esmj/signals:original function"),Ge=class extends ee{#e=new Set;#o=null;constructor(e){super(),this.#o=e,this.pipe(t=>{let n=t.subscribe.bind(t),o=t.unsubscribe.bind(t);return t.subscribe=r=>{n(r),this.#e.add(r);},t.unsubscribe=r=>{o(r),this.#e.delete(r);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>C(()=>{this.#e.add(e),this.#o();}),e.next[x]=void 0),e instanceof we&&e.next[x]===void 0){let t=e.next.bind(e);e.next=()=>C(()=>{this.#e.add(e),t(),this.#o();}),e.next[x]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[x]){let n=t.get,o=n.bind(t);t.get=()=>C(()=>(this.#e.delete(t),o())),t.get[x]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[x]?e.next[x]:e.next,e.get=e.get[x]?e.get[x]:e.get,this.#e.delete(e),this.unsubscribe(e)}},U=null;function ye(e){U=new Ge(e);}ye(()=>{Ke();});function xe(){return U.getPending()}function be(e){return U.watch(e)}function Se(e){return U.unwatch(e)}var b=Symbol("@esmj/signals:no error"),we=class ke extends me{#e=true;#o=false;#n=null;#r=this.#p();#c=null;#l=null;#i=0;#s=new Map;#t=b;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[z]="computed",this[P]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[P],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof ke&&C(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[ge].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=N(this.#a(),this.#l)),(this.#e||this.#t!==b)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),m&&m.sourceRevisions.set(this,this.#i),this.#t!==b)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=N(this.#a(),this.#l)),(this.#e||this.#t!==b)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==b)throw this.#t;return this.#n.peek()}#a(){this.#o=true,this.#e=false,this.#t=b,this.#u(),this.#r.sourceRevisions.clear();let t=m;m=this.#r;let n;try{n=this.#c();}catch(o){this.#t=o;}return m=t,this.#s=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=b,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===b&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=b;}};function A(e,t){return new we(e,t)}function g(e,t){let n,{debug:o,...r}={},s=A(()=>{n?.(),n=e();},{equals:()=>false,...r});s.get(),be(s);let i=()=>{n?.(),s.destroy(),Se(s);};return i[Symbol.dispose]=i,i[z]="effect",i[P]=o??null,i.__RX_COMPUTED__=s,i}function N(e,t={}){let n=t?.equals??Object.is,o=0,r=new ee;function s(){return m&&(m.dependencies.set(r,r.subscribe(m.observer)),m.sourceRevisions.set(p,o)),e}function i(){return e}function a(c){if(!n(e,c)){e=c,o++,r.next();}return e}function u(){return o}let p={get:s,set:a,peek:i,getRevision:u,[ge]:r,[z]:"signal",[P]:t?.debug??null};return p}function H(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Te=Symbol("node-component"),V=Symbol("node-internal"),Je=Symbol("keep-literal"),G=Symbol("raw-props");var Le=null;function I(){return Le}function W(e){Le=e;}function Ie(e){return e?.[Te]||null}function Re(e,t){e[Te]=t;}function X(e,t={disposers:[],id:H()}){return e?.[V]?e[V]:(e&&(e[V]=t),t)}function et(e){return e[V]}function k(e,t){let n=et(e);n||(n=X(e)),n.disposers.push(t);}function oe(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function R(e,t){let n=I();W(e);try{return t()}finally{W(n);}}var re=new Map,K=new Map,Ee=new Map;function $e(e,t){let n=typeof t=="function"?t:r=>!!t?.includes(r),o=Object.create(null);for(let r of Object.keys(e)){let s=e[r];r==="children"||n(r)?o[r]=s:s?.[Je]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=A(s):o[r]=N(s);}return o}function _(e){let t=e.componentId,n=re.get(t);if(n){re.delete(t);for(let o of n){let r=o();typeof r=="function"&&oe(K,t,r);}}}function tt(e){let t=K.get(e);if(t){K.delete(e);for(let n of t)n();}}function nt(e){let t=Ee.get(e);if(t){Ee.delete(e);for(let n of t)n();}}function J(e){if(!e)return;let t=X(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=Ie(e);if(n&&(tt(n.componentId),nt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;J(o),o=r;}}}function M(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ve(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function ot(e,t,n){let o=H(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=ve(e)?void 0:e[G],i={...$e(t??{},s),children:n},a=I(),u={disposers:[],id:o,contexts:new Map(a?.contexts)};W(u);let p;if(ve(e)){r.ClassConstructor=e;let f=new e(i);r.classInstance=f,typeof f.onMount=="function"&&oe(re,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&oe(K,o,()=>{f.onUnmount?.();}),p=f.render();}else p=e(i);W(a);let c=rt(p);if(r.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)X(f,u),Re(f,r);else X(c,u),c instanceof Node&&Re(c,r);return c}};return r}function ce(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{_(t);});}function rt(e){return e instanceof Node?e:M(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Ce={className:"class",htmlFor:"for"},Ne=new Set(["value","defaultValue","checked","selected","indeterminate"]),st=new Set(["srcdoc"]),it=new Set(["href","src","action","formaction","xlink:href"]),at=new Set(["securitypolicyviolation"]),lt=new Set(["contenteditable","draggable","spellcheck"]);function q(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Be=Symbol("Fragment");function S(e,t,n){if(e===Be){let r=document.createDocumentFragment();return se(r,Me(n)),r}if(typeof e=="function")return ot(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let o=document.createElement(e);return t.id&&o.setAttribute("id",t.id),Q(o,t),se(o,Me(n)),o}function ne(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function ct(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function ut(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return st.has(n)?true:it.has(n)&&t!==null&&t!==void 0&&ct(String(t))}function Fe(e){return typeof e!="string"?e:Ce[e]?Ce[e]:e}function ft(e,t){let n=Fe(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return lt.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Ae(e,t,n){let o=ft(t,n);if(o===null){e.removeAttribute(t);return}if(ut(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function Q(e,t){let n=I();for(let[o,r]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(o!=="id"){if(o=Fe(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(q(r)){let s=g(()=>{R(n,()=>{ne(e,r.get());});});k(e,s);}else if(typeof r=="function"){let s=g(()=>{R(n,()=>{ne(e,r());});});k(e,s);}else ne(e,r);continue}if(o==="style"){if(q(r)){let s=g(()=>{R(n,()=>{Object.assign(e.style,r.get());});});k(e,s);}else typeof r=="object"&&r!==null?Object.assign(e.style,r):e.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();if(at.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,r);continue}if(q(r)||typeof r=="function"){let s=o,i=g(()=>{R(n,()=>{let a=typeof r=="function"?r():r.get();Ne.has(s)?e[s]=a??"":Ae(e,s,a);});});k(e,i);continue}Ne.has(o)||typeof o=="symbol"?e[o]=r??"":Ae(e,o,r);}}function Me(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function se(e,t){for(let n of t)Pe(e,n);}function Pe(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){je(e,t);return}if(M(t)){ce(e,t);return}if(q(t)){je(e,()=>t.get());return}if(Array.isArray(t)){se(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function $(e){let t=null,n=e;return M(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function Z(e,t=true){for(let n of e)t&&J(n),n.remove();}function je(e,t){let n=I(),o=document.createComment("");e.appendChild(o);let r=[],s=g(()=>{R(n,()=>{let i=t(),{nodes:a,instance:u}=$(i);Z(r),a.length&&o.after(...a),u&&queueMicrotask(()=>_(u)),r=a;});});k(e,s);}function ue(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(J(e),e.innerHTML=""),M(t)?ce(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function mt(e){return e===`
3
+ `||e===`\r
4
+ `?"":e??""}function _e(e){let t="",n=[],o=[];return (e??[]).forEach((r,s)=>{s>0&&(t+=`
5
+ `);let i=t.length;t+=mt(r?.text);for(let a of r?.inlineStyleRanges??[])n.push({...a,offset:a.offset+i});for(let a of r?.entityRanges??[])o.push({...a,offset:a.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:o}}function ht(e,t){let n=0;for(let o of t){let s=e.register.blocks.getByNamespace(o?.component)?.toExchangeState(o)?.properties?.items;n+=_e(s).text.length;}return n}function De(e){return e.toLocaleString()}function gt({mrakomor:e}){let t=e.get();return S("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[S("div",{className:"mrakomor-footer-start"},[S("span",{className:"mrakomor-footer-item"},()=>{let n=t._getContentState().length;return `${De(n)} ${n===1?"block":"blocks"}`}),S("span",{className:"mrakomor-footer-item"},()=>{let n=ht(t,t._getContentState());return `${De(n)} ${n===1?"character":"characters"}`})]),S("div",{className:"mrakomor-footer-end"})])}function yt(e){let t=e.getRoot();return t?t.classList?.contains("mrakomor-editor")?t:t.querySelector(".mrakomor-editor"):null}function xt({mrakomor:e}){let t=null,n=null;return {onMount(){let o=yt(e);o&&(t=document.createElement("div"),t.className="mrakomor-footer-plugin-container",o.append(t),n=ue(t,S(gt,{mrakomor:e})));},onUnmount(){n?.(),t?.remove(),n=null,t=null;}}}exports.footerPlugin=xt;
package/dist/footer.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {r,o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/footer/footer.css",o=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!o){var t=document.createElement("style");t.setAttribute("data-mrakomor-css",""),t.setAttribute("data-mrakomor-css-path",e),t.textContent=`.mrakomor-footer-plugin-container{display:contents}.mrakomor-footer-container{position:relative;flex:0 0 auto;display:flex;align-items:stretch;justify-content:space-between;gap:0;height:22px;min-height:22px;padding:0;border-top:1px solid #e4e7ec;background:#f3f4f6;color:#5b6472;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:11px;line-height:22px;user-select:none;pointer-events:none}.mrakomor-footer-start,.mrakomor-footer-end{display:flex;align-items:stretch;min-width:0}.mrakomor-footer-end{margin-left:auto;flex-shrink:0}.mrakomor-footer-item{display:inline-flex;align-items:center;max-width:100%;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#5b6472}.mrakomor-footer-item+.mrakomor-footer-item{border-left:1px solid #e0e4ea}.mrakomor-footer-action{display:inline-flex;align-items:center;gap:4px;height:100%;margin:0;padding:0 10px;border:none;border-left:1px solid #e0e4ea;background:transparent;color:inherit;font:inherit;line-height:inherit;cursor:pointer;pointer-events:all}.mrakomor-footer-action:hover{background:#e9edf2;color:#1f2937}.mrakomor-footer-action:focus-visible{outline:1px solid #94a3b8;outline-offset:-1px}.mrakomor-footer-action__icon{font-size:12px;font-weight:700;line-height:1}
2
- `,document.head.appendChild(t);}}})();function l(e,o){let t=0;for(let r of o){let s=e.register.blocks.getByNamespace(r?.component)?.toExchangeState(r)?.properties?.text;t+=(s??"").length;}return t}function i(e){return e.toLocaleString()}function m({mrakomor:e}){let o$1=e.get();return o("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[o("div",{className:"mrakomor-footer-start"},[o("span",{className:"mrakomor-footer-item"},()=>{let t=o$1._getContentState().length;return `${i(t)} ${t===1?"block":"blocks"}`}),o("span",{className:"mrakomor-footer-item"},()=>{let t=l(o$1,o$1._getContentState());return `${i(t)} ${t===1?"character":"characters"}`})]),o("div",{className:"mrakomor-footer-end"})])}function c(e){let o=e.getRoot();return o?o.classList?.contains("mrakomor-editor")?o:o.querySelector(".mrakomor-editor"):null}function f({mrakomor:e}){let o$1=null,t=null;return {onMount(){let r$1=c(e);r$1&&(o$1=document.createElement("div"),o$1.className="mrakomor-footer-plugin-container",r$1.append(o$1),t=r(o$1,o(m,{mrakomor:e})));},onUnmount(){t?.(),o$1?.remove(),t=null,o$1=null;}}}export{f as footerPlugin};
1
+ import {l as l$1}from'./chunk-ZDMD7SRT.mjs';import'./chunk-SCFD3XBH.mjs';import {r,o}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/footer/footer.css",o=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===t});if(!o){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",t),e.textContent=`.mrakomor-footer-plugin-container{display:contents}.mrakomor-footer-container{position:relative;flex:0 0 auto;display:flex;align-items:stretch;justify-content:space-between;gap:0;height:22px;min-height:22px;padding:0;border-top:1px solid #e4e7ec;background:#f3f4f6;color:#5b6472;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:11px;line-height:22px;user-select:none;pointer-events:none}.mrakomor-footer-start,.mrakomor-footer-end{display:flex;align-items:stretch;min-width:0}.mrakomor-footer-end{margin-left:auto;flex-shrink:0}.mrakomor-footer-item{display:inline-flex;align-items:center;max-width:100%;padding:0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#5b6472}.mrakomor-footer-item+.mrakomor-footer-item{border-left:1px solid #e0e4ea}.mrakomor-footer-action{display:inline-flex;align-items:center;gap:4px;height:100%;margin:0;padding:0 10px;border:none;border-left:1px solid #e0e4ea;background:transparent;color:inherit;font:inherit;line-height:inherit;cursor:pointer;pointer-events:all}.mrakomor-footer-action:hover{background:#e9edf2;color:#1f2937}.mrakomor-footer-action:focus-visible{outline:1px solid #94a3b8;outline-offset:-1px}.mrakomor-footer-action__icon{font-size:12px;font-weight:700;line-height:1}
2
+ `,document.head.appendChild(e);}}})();function l(t,o){let e=0;for(let r of o){let m=t.register.blocks.getByNamespace(r?.component)?.toExchangeState(r)?.properties?.items;e+=l$1(m).text.length;}return e}function s(t){return t.toLocaleString()}function c({mrakomor:t}){let o$1=t.get();return o("footer",{className:"mrakomor-footer-container",contentEditable:false,"aria-label":"Editor status"},[o("div",{className:"mrakomor-footer-start"},[o("span",{className:"mrakomor-footer-item"},()=>{let e=o$1._getContentState().length;return `${s(e)} ${e===1?"block":"blocks"}`}),o("span",{className:"mrakomor-footer-item"},()=>{let e=l(o$1,o$1._getContentState());return `${s(e)} ${e===1?"character":"characters"}`})]),o("div",{className:"mrakomor-footer-end"})])}function f(t){let o=t.getRoot();return o?o.classList?.contains("mrakomor-editor")?o:o.querySelector(".mrakomor-editor"):null}function u({mrakomor:t}){let o$1=null,e=null;return {onMount(){let r$1=f(t);r$1&&(o$1=document.createElement("div"),o$1.className="mrakomor-footer-plugin-container",r$1.append(o$1),e=r(o$1,o(c,{mrakomor:t})));},onUnmount(){e?.(),o$1?.remove(),e=null,o$1=null;}}}export{u as footerPlugin};