@mrakomor/core 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockChrome.cjs +3 -0
- package/dist/blockChrome.mjs +2 -1
- package/dist/blockInsertMenu.cjs +1 -0
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-5VPYPKGA.mjs +1 -0
- package/dist/chunk-G2QV4GOO.mjs +1 -0
- package/dist/chunk-GDID5DFL.mjs +1 -0
- package/dist/chunk-K2DMHAUD.mjs +1 -0
- package/dist/chunk-N4I2WZWF.mjs +1 -0
- package/dist/chunk-P7IKAZYZ.mjs +1 -0
- package/dist/chunk-Q7RMVYZR.mjs +1 -0
- package/dist/chunk-T7OO472O.mjs +1 -0
- package/dist/chunk-TX4RCFPO.mjs +3 -0
- package/dist/chunk-U3MSKB3R.mjs +2 -0
- package/dist/chunk-UC7W4JIH.mjs +2 -0
- package/dist/chunk-WBTDWVEC.mjs +3 -0
- package/dist/chunk-WQWE5UCN.mjs +1 -0
- package/dist/chunk-YHWQV2DB.mjs +1 -0
- package/dist/clipboard.cjs +5 -0
- package/dist/clipboard.mjs +3 -3
- package/dist/footer.cjs +2 -0
- package/dist/footer.mjs +2 -0
- package/dist/headline.cjs +4 -0
- package/dist/headline.mjs +1 -1
- package/dist/help.cjs +2 -0
- package/dist/help.mjs +2 -0
- package/dist/index.cjs +6 -0
- package/dist/index.mjs +4 -1
- package/dist/link.cjs +3 -0
- package/dist/link.mjs +3 -2
- package/dist/list.cjs +5 -0
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +4 -0
- package/dist/paragraph.mjs +1 -1
- package/dist/slashCommand.cjs +3 -0
- package/dist/slashCommand.mjs +1 -1
- package/dist/tooltip.cjs +2 -0
- package/dist/tooltip.mjs +2 -1
- package/dist/tts.cjs +9 -0
- package/dist/tts.mjs +3 -2
- package/package.json +72 -24
- package/dist/chunk-4CNZR6XL.mjs +0 -1
- package/dist/chunk-4K476NKG.mjs +0 -1
- package/dist/chunk-5V6D56TM.mjs +0 -1
- package/dist/chunk-DFL6LPER.mjs +0 -1
- package/dist/chunk-IAGILV5H.mjs +0 -1
- package/dist/chunk-MIXXUTVH.mjs +0 -1
- package/dist/chunk-MWY3XQMH.mjs +0 -3
- package/dist/chunk-O7IO4QXV.mjs +0 -1
- package/dist/chunk-PYVJPCUA.mjs +0 -1
- package/dist/chunk-R6ZAVJUD.mjs +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/blockChrome/BlockChrome.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-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
|
+
`,document.head.appendChild(n);}}})();var pe=class{next(...e){}error(...e){}complete(...e){}},Z=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 K=Symbol("@esmj/signals:type"),D=Symbol("@esmj/signals:name");var h=null,ee=false,ge=[];function v(e){let t=h;h=null;let n=e();return h=t,n}function We(){ee=false;let e=Ee();for(let n of e)n.get();let t=ge;ge=[];for(let n of t)n();}function ze(){ee||(ee=true,queueMicrotask(We));}var be=Symbol("@esmj/signals:internal observable"),y=Symbol("@esmj/signals:original function"),Xe=class extends Z{#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=()=>v(()=>{this.#e.add(e),this.#o();}),e.next[y]=void 0),e instanceof Ce&&e.next[y]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#o();}),e.next[y]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[y]){let n=t.get,o=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),o())),t.get[y]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[y]?e.next[y]:e.next,e.get=e.get[y]?e.get[y]:e.get,this.#e.delete(e),this.unsubscribe(e)}},G=null;function ye(e){G=new Xe(e);}ye(()=>{ze();});function Ee(){return G.getPending()}function ke(e){return G.watch(e)}function xe(e){return G.unwatch(e)}var E=Symbol("@esmj/signals:no error"),Ce=class Se extends pe{#e=true;#o=false;#n=null;#r=this.#d();#a=null;#c=null;#s=0;#i=new Map;#t=E;constructor(t,n){super(),this.#a=t,this.#c=n,this.debug=n?.debug,this[K]="computed",this[D]=n?.debug??null,this.get=this.get.bind(this);}#u(){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[D],dirty:this.#e,revision:this.#s,sourceDependencies:[...this.#i.keys()]}}#f(){for(let[t,n]of this.#i)if(t instanceof Se&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[be].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=w(this.#l(),this.#c)),(this.#e||this.#t!==E)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),h&&h.sourceRevisions.set(this,this.#s),this.#t!==E)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=w(this.#l(),this.#c)),(this.#e||this.#t!==E)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),this.#t!==E)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=E,this.#u(),this.#r.sourceRevisions.clear();let t=h;h=this.#r;let n;try{n=this.#a();}catch(o){this.#t=o;}return h=t,this.#i=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=E,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===E&&this.#n&&this.#n.set(n),this.#s++,n}destroy(){this.#u(),this.#i.clear(),this.#e=true,this.#t=E;}};function R(e,t){return new Ce(e,t)}function g(e,t){let n,{debug:o,...r}={},i=R(()=>{n?.(),n=e();},{equals:()=>false,...r});i.get(),ke(i);let c=()=>{n?.(),i.destroy(),xe(i);};return c[Symbol.dispose]=c,c[K]="effect",c[D]=o??null,c.__RX_COMPUTED__=i,c}function w(e,t={}){let n=t?.equals??Object.is,o=0,r=new Z;function i(){return h&&(h.dependencies.set(r,r.subscribe(h.observer)),h.sourceRevisions.set(a,o)),e}function c(){return e}function s(u){if(!n(e,u)){e=u,o++,r.next();}return e}function l(){return o}let a={get:i,set:s,peek:c,getRevision:l,[be]:r,[K]:"signal",[D]:t?.debug??null};return a}function V(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Me=Symbol("node-component"),H=Symbol("node-internal"),Qe=Symbol("keep-literal"),z=Symbol("raw-props");var Ie=null;function M(){return Ie}function U(e){Ie=e;}function ce(e){return e?.[Me]||null}function Ne(e,t){e[Me]=t;}function Y(e,t={disposers:[],id:V()}){return e?.[H]?e[H]:(e&&(e[H]=t),t)}function tt(e){return e[H]}function x(e,t){let n=tt(e);n||(n=Y(e)),n.disposers.push(t);}function ne(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function C(e,t){let n=M();U(e);try{return t()}finally{U(n);}}var oe=new Map,W=new Map,ve=new Map;function Be(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?.[Qe]?o[r]=i():i!=null&&typeof i.get=="function"?o[r]=i:typeof i=="function"?o[r]=R(i):o[r]=w(i);}return o}function F(e){let t=e.componentId,n=oe.get(t);if(n){oe.delete(t);for(let o of n){let r=o();typeof r=="function"&&ne(W,t,r);}}}function nt(e){let t=W.get(e);if(t){W.delete(e);for(let n of t)n();}}function ot(e){let t=ve.get(e);if(t){ve.delete(e);for(let n of t)n();}}function ae(e){if(!e)return;let t=Y(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=ce(e);if(n&&(nt(n.componentId),ot(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;ae(o),o=r;}}}function I(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function we(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function rt(e,t,n){let o=V(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let i=we(e)?void 0:e[z],c={...Be(t??{},i),children:n},s=M(),l={disposers:[],id:o,contexts:new Map(s?.contexts)};U(l);let a;if(we(e)){r.ClassConstructor=e;let d=new e(c);r.classInstance=d,typeof d.onMount=="function"&&ne(oe,o,()=>{d.onMount?.();}),typeof d.onUnmount=="function"&&ne(W,o,()=>{d.onUnmount?.();}),a=d.render();}else a=e(c);U(s);let u=it(a);if(r.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let d of u.childNodes)Y(d,l),Ne(d,r);else Y(u,l),u instanceof Node&&Ne(u,r);return u}};return r}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{F(t);});}function it(e){return e instanceof Node?e:I(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Re={className:"class",htmlFor:"for"},_e=new Set(["value","defaultValue","checked","selected","indeterminate"]),st=new Set(["srcdoc"]),lt=new Set(["href","src","action","formaction","xlink:href"]),ct=new Set(["securitypolicyviolation"]),at=new Set(["contenteditable","draggable","spellcheck"]);function $(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Pe=Symbol("Fragment");function _(e,t,n){if(e===Pe){let r=document.createDocumentFragment();return re(r,Te(n)),r}if(typeof e=="function")return rt(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),J(o,t),re(o,Te(n)),o}function te(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function ut(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function ft(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return st.has(n)?true:lt.has(n)&&t!==null&&t!==void 0&&ut(String(t))}function De(e){return typeof e!="string"?e:Re[e]?Re[e]:e}function dt(e,t){let n=De(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 Le(e,t,n){let o=dt(t,n);if(o===null){e.removeAttribute(t);return}if(ft(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function J(e,t){let n=M();for(let[o,r]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(o!=="id"){if(o=De(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if($(r)){let i=g(()=>{C(n,()=>{te(e,r.get());});});x(e,i);}else if(typeof r=="function"){let i=g(()=>{C(n,()=>{te(e,r());});});x(e,i);}else te(e,r);continue}if(o==="style"){if($(r)){let i=g(()=>{C(n,()=>{Object.assign(e.style,r.get());});});x(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(ct.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,r);continue}if($(r)||typeof r=="function"){let i=o,c=g(()=>{C(n,()=>{let s=typeof r=="function"?r():r.get();_e.has(i)?e[i]=s??"":Le(e,i,s);});});x(e,c);continue}_e.has(o)||typeof o=="symbol"?e[o]=r??"":Le(e,o,r);}}function Te(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function re(e,t){for(let n of t)je(e,n);}function je(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"){Oe(e,t);return}if(I(t)){Ae(e,t);return}if($(t)){Oe(e,()=>t.get());return}if(Array.isArray(t)){re(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function B(e){let t=null,n=e;return I(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 Q(e,t=true){for(let n of e)t&&ae(n),n.remove();}function Oe(e,t){let n=M(),o=document.createComment("");e.appendChild(o);let r=[],i=g(()=>{C(n,()=>{let c=t(),{nodes:s,instance:l}=B(c);Q(r),s.length&&o.after(...s),l&&queueMicrotask(()=>F(l)),r=s;});});x(e,i);}Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var qe=Symbol("block-element-body");var fe={KEYDOWN:"mrakomor:keydown",CLICK:"mrakomor:click"};var pt='<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 gt(e,t){for(let n=0;n<t.length;n++){let o=t[n].getBoundingClientRect();if(e<o.top+o.height/2)return n}return t.length}function bt(e,t,n,o){if(!e||!t)return;if(n>=o.length){let s=o[o.length-1];if(!s){e.style.display="none";return}let l=t.getBoundingClientRect(),a=s.getBoundingClientRect();e.style.display="block",e.style.top=`${a.bottom-l.top}px`;return}let r=o[n],i=t.getBoundingClientRect(),c=r.getBoundingClientRect();e.style.display="block",e.style.top=`${c.top-i.top}px`;}function Ke(){return _("div",{className:"mrakomor-block-gutter",contentEditable:false},[_("button",{type:"button",className:"mrakomor-block-add","aria-label":"Insert block",contentEditable:false},"+"),_("button",{type:"button",className:"mrakomor-block-drag","aria-label":"Drag to reorder",contentEditable:false,$dangerouslySetInnerHTML:pt})])}function yt({mrakomor:e}){let t=null,n=null;function o(){n?.blockElement&&n.blockElement.classList.remove("mrakomor-block-element--active","mrakomor-block-element--dragging"),n?.handle&&n.handle.releasePointerCapture?.(n.pointerId),t&&(t.style.display="none"),document.body.classList.remove("mrakomor-block-drag-active"),n=null;}function r(s){if(!n||s.pointerId!==n.pointerId)return;let l=e.getRoot()?.querySelector(".mrakomor-content");if(!l)return;let a=[...l.querySelectorAll(".mrakomor-block-element")],u=gt(s.clientY,a);n.targetIndex=u,bt(t,l,u,a);}function i(s){if(!n||s.pointerId!==n.pointerId)return;let{blockElement:l,targetIndex:a}=n;o(),e.command.moveBlockElement({blockElement:l,targetIndex:a});}function c(s){let l=s.target.closest?.(".mrakomor-block-drag");if(!l)return;s.preventDefault(),s.stopPropagation();let a=l.closest(".mrakomor-block-element");if(!a)return;n&&o();let u=e._getBlockElementIndex(a);if(u===-1)return;let d=s.pointerId??1;l.setPointerCapture?.(d),a.classList.add("mrakomor-block-element--active","mrakomor-block-element--dragging"),document.body.classList.add("mrakomor-block-drag-active"),n={blockElement:a,pointerId:d,handle:l,fromIndex:u,targetIndex:u};}return {wrapBlockElement(s){return [_(Ke),_("div",{className:"mrakomor-block-body",[qe]:true},s)]},registerHandlers(){e.emitter.on(fe.CLICK,s=>{let l=s.target?.closest?.(".mrakomor-block-add");if(!l)return;s.preventDefault?.(),s.stopPropagation?.();let a=l.closest(".mrakomor-block-element");a&&e.command.openBlockInsertMenu({blockElement:a,anchorRect:l.getBoundingClientRect()});}),e.emitter.on(fe.KEYDOWN,s=>{s.key==="Escape"&&n&&o();});},onMount(){let{signal:s}=e.listenerAbortController;document.addEventListener("pointerdown",c,{capture:true,signal:s});let l=e.getRoot()?.querySelector(".mrakomor-content");l&&(t=document.createElement("div"),t.className="mrakomor-block-drop-indicator",t.style.display="none",l.append(t)),document.addEventListener("pointermove",r,{signal:s}),document.addEventListener("pointerup",i,{signal:s}),document.addEventListener("pointercancel",i,{signal:s});},onUnmount(){o(),t?.remove(),t=null;}}}
|
|
3
|
+
exports.BlockChrome=Ke;exports.blockChromePlugin=yt;
|
package/dist/blockChrome.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {a}from'./chunk-B6JJAATK.mjs';import {
|
|
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}
|
|
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;}}}
|
|
2
3
|
export{k as BlockChrome,h as blockChromePlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var fe=class{next(...e){}error(...e){}complete(...e){}},G=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 D=Symbol("@esmj/signals:type"),B=Symbol("@esmj/signals:name");var h=null,H=false,de=[];function x(e){let t=h;h=null;let n=e();return h=t,n}function De(){H=false;let e=pe();for(let n of e)n.get();let t=de;de=[];for(let n of t)n();}function Ke(){H||(H=true,queueMicrotask(De));}var he=Symbol("@esmj/signals:internal observable"),g=Symbol("@esmj/signals:original function"),$e=class extends G{#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=()=>x(()=>{this.#e.add(e),this.#o();}),e.next[g]=void 0),e instanceof be&&e.next[g]===void 0){let t=e.next.bind(e);e.next=()=>x(()=>{this.#e.add(e),t(),this.#o();}),e.next[g]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[g]){let n=t.get,o=n.bind(t);t.get=()=>x(()=>(this.#e.delete(t),o())),t.get[g]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[g]?e.next[g]:e.next,e.get=e.get[g]?e.get[g]:e.get,this.#e.delete(e),this.unsubscribe(e)}},K=null;function me(e){K=new $e(e);}me(()=>{Ke();});function pe(){return K.getPending()}var E=Symbol("@esmj/signals:no error"),be=class ye extends fe{#e=true;#o=false;#n=null;#r=this.#d();#u=null;#c=null;#i=0;#s=new Map;#t=E;constructor(t,n){super(),this.#u=t,this.#c=n,this.debug=n?.debug,this[D]="computed",this[B]=n?.debug??null,this.get=this.get.bind(this);}#a(){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.#i}getDebugInfo(){return {name:this[B],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof ye&&x(()=>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=R(this.#l(),this.#c)),(this.#e||this.#t!==E)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),h&&h.sourceRevisions.set(this,this.#i),this.#t!==E)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=R(this.#l(),this.#c)),(this.#e||this.#t!==E)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),this.#t!==E)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=E,this.#a(),this.#r.sourceRevisions.clear();let t=h;h=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return h=t,this.#s=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=E,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===E&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#a(),this.#s.clear(),this.#e=true,this.#t=E;}};function R(e,t={}){let n=t?.equals??Object.is,o=0,r=new G;function i(){return h&&(h.dependencies.set(r,r.subscribe(h.observer)),h.sourceRevisions.set(f,o)),e}function s(){return e}function l(a){if(!n(e,a)){e=a,o++,r.next();}return e}function u(){return o}let f={get:i,set:l,peek:s,getRevision:u,[he]:r,[D]:"signal",[B]:t?.debug??null};return f}var se=le(),ie=le(),Me=le(),rt=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function le(){return Math.floor(Math.random()*16777215)}function st(){return ie=(ie+1)%16777215,ie}function ve(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=st(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,se>>16&255,se>>8&255,se&255,Me>>8&255,Me&255,t>>16&255,t>>8&255,t&255),o="";for(let r=0;r<n.length;r++)o+=rt[n.charCodeAt(r)];return o}var C={};function it({mrakomor:e}){let t=null,n;function o(){t&&t.classList.remove("mrakomor-block-element--active"),t=null,n=void 0;}function r(){let s=e._getBlockElementIndex(t);return s!==-1?e._getBlockElements()[s]:e._getBlockElementByComponentId(n)}function i(s){let l=r();if(!l||!s?.component)return;let u=s.component.NAMESPACE,a=s.component.getStateSchema().parse({componentId:ve(),component:u,...s.settings?{settings:s.settings}:{}});e.command.insertBlockElement({blockElement:l,namespace:u,newLineState:a,cursor:0}),o(),e.command.closeMenu();}return {registerEvents(){C.OPEN_BLOCK_INSERT_MENU="mrakomor:open-block-insert-menu",C.CLOSE_BLOCK_INSERT_MENU="mrakomor:close-block-insert-menu";},registerCommands(s){s.command.openBlockInsertMenu=({blockElement:l,anchorRect:u})=>{s.emit(C.OPEN_BLOCK_INSERT_MENU,{blockElement:l,anchorRect:u});},s.command.closeBlockInsertMenu=()=>{s.emit(C.CLOSE_BLOCK_INSERT_MENU);};},registerHandlers(){e.emitter.on(C.OPEN_BLOCK_INSERT_MENU,({blockElement:s,anchorRect:l})=>{o(),t=s,n=e._getBlockElementState(s)?.componentId,s?.classList.add("mrakomor-block-element--active"),e.command.closeTooltip?.();let u=e.register.blocks.list();e.command.openMenu({entries:u,anchorRect:l,highlightIndex:-1,ariaLabel:"Insert block",onSelect:i});}),e.emitter.on(C.CLOSE_BLOCK_INSERT_MENU,()=>{o(),e.command.closeMenu();}),e.emitter.on(C.CLOSE_MENU,o);}}}exports.blockInsertMenuPlugin=it;
|
package/dist/blockInsertMenu.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-B6JJAATK.mjs';import {
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {r}from'./chunk-K2DMHAUD.mjs';function i(o,t,n,m){let e=o.getRoot()?.querySelector(t);if(!e)return {container:null,dispose:null};let r$1=document.createElement("div");r$1.className=n,e.append(r$1);let c=r(r$1,m);return {container:r$1,dispose:c??null}}function s(o,t,n){return i(o,".mrakomor-tools-container",t,n)}function l(o,t,n){return i(o,".mrakomor-footer-end",t,n)}export{s as a,l as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-T7OO472O.mjs';import {a as a$1}from'./chunk-P7IKAZYZ.mjs';import {k,j,q}from'./chunk-TX4RCFPO.mjs';import {a as a$2}from'./chunk-B6JJAATK.mjs';import {r}from'./chunk-YHWQV2DB.mjs';import {n,p,k as k$1}from'./chunk-K2DMHAUD.mjs';var s=class extends p{state;element;mrakomor;constructor(t){super(t);let{state:e,observeDOMChanges:n=true}=t??{};this.state=e,this.element=null,this.mrakomor=k$1(a),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=n;}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(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}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=t=>{let e=t.target;e instanceof Node&&this.element?.contains(e)&&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 f=class extends s{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let e=()=>{if(!this.element?.isConnected)return;let n=typeof t=="number"?t:j(this.getState()?.properties?.text).length;r(this.element,n);};e(),n(e);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return k({originComponent:this.NAMESPACE,properties:{...t?.properties,text:j(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,e){return q(t,e)}};export{f as a};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var pe=class{next(...e){}error(...e){}complete(...e){}},te=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 V=Symbol("@esmj/signals:type"),D=Symbol("@esmj/signals:name");var p=null,ne=false,re=[];function E(e){let t=p;p=null;let n=e();return p=t,n}function We(){ne=false;let e=be();for(let n of e)n.get();let t=re;re=[];for(let n of t)n();}function ge(){ne||(ne=true,queueMicrotask(We));}function oe(e){re.push(e),ge();}var me=Symbol("@esmj/signals:internal observable"),w=Symbol("@esmj/signals:original function"),Xe=class extends te{#e=new Set;#r=null;constructor(e){super(),this.#r=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=()=>E(()=>{this.#e.add(e),this.#r();}),e.next[w]=void 0),e instanceof xe&&e.next[w]===void 0){let t=e.next.bind(e);e.next=()=>E(()=>{this.#e.add(e),t(),this.#r();}),e.next[w]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[w]){let n=t.get,o=n.bind(t);t.get=()=>E(()=>(this.#e.delete(t),o())),t.get[w]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[w]?e.next[w]:e.next,e.get=e.get[w]?e.get[w]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function ye(e){z=new Xe(e);}ye(()=>{ge();});function be(){return z.getPending()}function we(e){return z.watch(e)}function Se(e){return z.unwatch(e)}var S=Symbol("@esmj/signals:no error"),xe=class ve extends pe{#e=true;#r=false;#n=null;#o=this.#d();#a=null;#l=null;#i=0;#s=new Map;#t=S;constructor(t,n){super(),this.#a=t,this.#l=n,this.debug=n?.debug,this[V]="computed",this[D]=n?.debug??null,this.get=this.get.bind(this);}#c(){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[D],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof ve&&E(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[me].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=R(this.#u(),this.#l)),(this.#e||this.#t!==S)&&(this.#s.size===0||this.#f()?this.#u():this.#e=false),p&&p.sourceRevisions.set(this,this.#i),this.#t!==S)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=R(this.#u(),this.#l)),(this.#e||this.#t!==S)&&(this.#s.size===0||this.#f()?this.#u():this.#e=false),this.#t!==S)throw this.#t;return this.#n.peek()}#u(){this.#r=true,this.#e=false,this.#t=S,this.#c(),this.#o.sourceRevisions.clear();let t=p;p=this.#o;let n;try{n=this.#a();}catch(o){this.#t=o;}return p=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(o=>{this.#t=S,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===S&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=S;}};function C(e,t){return new xe(e,t)}function m(e,t){let n,{debug:o,...r}=t??{},s=C(()=>{n?.(),n=e();},{equals:()=>false,...r});s.get(),we(s);let i=()=>{n?.(),s.destroy(),Se(s);};return i[Symbol.dispose]=i,i[V]="effect",i[D]=o??null,i.__RX_COMPUTED__=s,i}function R(e,t={}){let n=t?.equals??Object.is,o=0,r=new te;function s(){return p&&(p.dependencies.set(r,r.subscribe(p.observer)),p.sourceRevisions.set(d,o)),e}function i(){return e}function u(c){if(!n(e,c)){e=c,o++,r.next();}return e}function l(){return o}let d={get:s,set:u,peek:i,getRevision:l,[me]:r,[V]:"signal",[D]:t?.debug??null};return d}function W(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Ae=Symbol("node-component"),X=Symbol("node-internal"),qe=Symbol("keep-literal"),J=Symbol("raw-props");function ue(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function le(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}function Ke(e){let t=()=>e;return t[qe]=true,t}var Ye=new Set(["template","script"]);function Ge(e,t){let n=(e==null?"span":String(e)).trim(),o=n;Ye.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${e}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),o="span");let r=document.createElement(o);return o==="span"&&(r.style.display="contents"),r.setAttribute(t,W()),r}function ae(e,t,n){let o=Ge(e,t);return n?.id&&o.setAttribute("id",n.id),o}function Je(e){let t=null,n=()=>t,o=s=>(t=s??null,typeof e=="function"&&e(t),t),r={get:n,set:o,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(r,"current",{get(){return t},set(s){o(s);},enumerable:true,configurable:false}),new Proxy(r,{get(s,i,u){if(Reflect.has(s,i))return Reflect.get(s,i,u);if(!t)return;let l=t[i];return typeof l=="function"?l.bind(t):l},set(s,i,u,l){return Reflect.has(s,i)||!t?Reflect.set(s,i,u,l):(t[i]=u,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var Te=null;function y(){return Te}function K(e){Te=e;}function Fe(e){return e?.[Ae]||null}function Ce(e,t){e[Ae]=t;}function Y(e,t={disposers:[],id:W()}){return e?.[X]?e[X]:(e&&(e[X]=t),t)}function Qe(e){return e[X]}function x(e,t){let n=Qe(e);n||(n=Y(e)),n.disposers.push(t);}function _(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function N(e,t){let n=y();K(e);try{return t()}finally{K(n);}}var G=new Map,B=new Map,Ne=new Map;function Oe(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?.[qe]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=C(s):o[r]=R(s);}return o}function Q(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>{let s=Object.getOwnPropertyDescriptor(e,r),i=Object.getOwnPropertyDescriptor(t,r);if(!s||!i)return false;let u="value"in s?s.value:s.get?.call(e),l="value"in i?i.value:i.get?.call(t);return Q(u,l)})}function Ze(e){return {id:Symbol("context-id"),defaultValue:e}}function et(e,t){let n=y();n&&n.contexts.set(e.id,t);}function tt(e){let t=y();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function nt(e){let t=y();if(!t){console.warn("onMount called outside of a component context");return}_(G,t.id,e);}function rt(e){let t=y();if(!t){console.warn("onUnmount called outside of a component context");return}_(B,t.id,e);}function ot(e){oe(()=>{setTimeout(e,0);});}function T(e){let t=e.componentId,n=G.get(t);if(n){G.delete(t);for(let o of n){let r=o();typeof r=="function"&&_(B,t,r);}}}function st(e){let t=B.get(e);if(t){B.delete(e);for(let n of t)n();}}function it(e){let t=Ne.get(e);if(t){Ne.delete(e);for(let n of t)n();}}function U(e){if(!e)return;let t=Y(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&&(st(n.componentId),it(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;U(o),o=r;}}}function k(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ke(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function ut(e,t,n){let o=W(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=ke(e)?void 0:e[J],i={...Oe(t??{},s),children:n},u=y(),l={disposers:[],id:o,contexts:new Map(u?.contexts)};K(l);let d;if(ke(e)){r.ClassConstructor=e;let f=new e(i);r.classInstance=f,typeof f.onMount=="function"&&_(G,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&_(B,o,()=>{f.onUnmount?.();}),d=f.render();}else d=e(i);K(u);let c=lt(d);if(r.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)Y(f,l),Ce(f,r);else Y(c,l),c instanceof Node&&Ce(c,r);return c}};return r}function ce(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{T(t);});}function lt(e){return e instanceof Node?e:k(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var je={className:"class",htmlFor:"for"},Me=new Set(["value","defaultValue","checked","selected","indeterminate"]),at=new Set(["srcdoc"]),ct=new Set(["href","src","action","formaction","xlink:href"]),ft=new Set(["securitypolicyviolation"]),dt=new Set(["contenteditable","draggable","spellcheck"]);function P(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Le=Symbol("Fragment");function ht(e,t,n){if(e===Le){let r=document.createDocumentFragment();return ie(r,Re(n)),r}if(typeof e=="function")return ut(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),Z(o,t),ie(o,Re(n)),o}function se(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function pt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function gt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return at.has(n)?true:ct.has(n)&&t!==null&&t!==void 0&&pt(String(t))}function De(e){return typeof e!="string"?e:je[e]?je[e]:e}function mt(e,t){let n=De(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return dt.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=mt(t,n);if(o===null){e.removeAttribute(t);return}if(gt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function Z(e,t){let n=y();for(let[o,r]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(o!=="id"){if(o=De(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(P(r)){let s=m(()=>{N(n,()=>{se(e,r.get());});});x(e,s);}else if(typeof r=="function"){let s=m(()=>{N(n,()=>{se(e,r());});});x(e,s);}else se(e,r);continue}if(o==="style"){if(P(r)){let s=m(()=>{N(n,()=>{Object.assign(e.style,r.get());});});x(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(ft.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,r);continue}if(P(r)||typeof r=="function"){let s=o,i=m(()=>{N(n,()=>{let u=typeof r=="function"?r():r.get();Me.has(s)?e[s]=u??"":Ee(e,s,u);});});x(e,i);continue}Me.has(o)||typeof o=="symbol"?e[o]=r??"":Ee(e,o,r);}}function Re(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ie(e,t){for(let n of t)Ie(e,n);}function Ie(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"){$e(e,t);return}if(k(t)){ce(e,t);return}if(P(t)){$e(e,()=>t.get());return}if(Array.isArray(t)){ie(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(e){let t=null,n=e;return k(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 ee(e,t=true){for(let n of e)t&&U(n),n.remove();}function $e(e,t){let n=y(),o=document.createComment("");e.appendChild(o);let r=[],s=m(()=>{N(n,()=>{let i=t(),{nodes:u,instance:l}=F(i);ee(r),u.length&&o.after(...u),l&&queueMicrotask(()=>T(l)),r=u;});});x(e,s);}var Pt=class{constructor(e){this.props=e;}};function Pe(e,t,n,o){let{equals:r=Q,tagName:s="span",...i}=o??{},u=ae(s,"data-for",i);Z(u,i);let l=y(),d=[],c=new Map,f=C(()=>e()),$=m(()=>{let A=f.get(),H=Array.isArray(A)?A:[],O=[],j=[],L=new Set;for(let a=0;a<H.length;a++){let h=H[a],g=t(h,a);if(L.has(g)){console.error(`For: duplicate key "${String(g)}" detected; ignoring later item at index ${a}`);continue}L.add(g),O.push(h),j.push(g);}let q=new Map(d.map(a=>[a.key,a])),v=[];for(let a=0;a<O.length;a++){let h=j[a],g=O[a],M=q.get(h);if(M)c.get(h).set(g),v.push(M),q.delete(h);else {let fe=R(g,{equals:r});c.set(h,fe);let Be={...fe,set(){}},de={key:h,nodes:[]};N(l,()=>{let Ue=n(Be,a),{nodes:He,instance:he}=F(Ue);de.nodes=He,he&&queueMicrotask(()=>T(he));}),v.push(de);}}for(let[a,h]of q)ee(h.nodes),c.delete(a);let b=null;for(let a=v.length-1;a>=0;a--){let h=v[a].nodes;for(let g=h.length-1;g>=0;g--){let M=h[g];(M.parentNode!==u||M.nextSibling!==b)&&u.insertBefore(M,b),b=M;}}d=v;});return x(u,$),u}function yt(e,t,n,o){if(typeof e=="function")return Pe(e,t,n,o);let{each:r,keyFn:s,equals:i,tagName:u,children:l,...d}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let c=ue(r),f=le(e??{},t);return Pe(c,s,f,{...d,equals:i,tagName:u})}yt[J]=e=>e!=="each";function _t(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(U(e),e.innerHTML=""),k(t)?ce(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function Bt(e){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("unmount: container not found");U(e),e.innerHTML="";}function Ut(e,t){let n=null;if(k(t)?(n=t.$constructor(),queueMicrotask(()=>T(t))):t instanceof Node?n=t:n=document.createTextNode(String(t)),n instanceof HTMLElement){let o=C(()=>!!e()),r=m(()=>{n.style.display=o.get()?"":"none";});x(n,r);}return n}export{E as a,C as b,m as c,R as d,Ke as e,Je as f,Fe as g,Q as h,Ze as i,et as j,tt as k,nt as l,rt as m,ot as n,ht as o,Pt as p,yt as q,_t as r,Bt as s,Ut as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-T7OO472O.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {p,k,f,o}from'./chunk-K2DMHAUD.mjs';var i=class extends p{static get nodeName(){return "span"}static get NAMESPACE(){return "namespace.EntityRangeElement"}static match(t){return t?.nodeName===this.nodeName.toUpperCase()||t?.entity?.type===this.NAMESPACE}static getStateSchema(t){return a.any()}constructor(t){super(t),this.mrakomor=k(a$1),this.element=f(null);}render(){return o(this.constructor.nodeName,{},this.props.children)}};export{i as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Q={abortEarly:true};function D(e,s){if(s===void 0)return e;let t=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${t}": ${e.message}`,cause:{key:t}}}function U(e,s,t){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)s.push(D(e.errors[r],t));}function O(e,s,t,r){if(t!==false){let a=D(e.error,s);return {success:false,error:a,errors:[a]}}U(e,r,s);}function _(e){return e?.abortEarly!==void 0?e:Q}function x(e,s){g(e,"_parse",(t,r,a)=>{let l=t(r,a);return !l.success&&s(r)?{success:true,data:r}:l});}var b=e=>typeof e=="string"||e instanceof String,v=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),j=e=>e===true||e===false,V=e=>e instanceof Date&&!Number.isNaN(e.getTime()),W=e=>typeof e=="function",Y=e=>Array.isArray(e),N=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function T(e,s){let t=h(N,{...s,type:"object"});t._getDescription=()=>`object({ ${Object.entries(e).map(([a,l])=>`${a}: ${l._getDescription()}`).join(", ")} })`,t._getDefinition=()=>e;let r=t;return r.derive=function(a,{when:l="always"}={}){return g(this,"_parse",(n,i,u)=>{let c=n(i,u);if(!c.success)return c;let o=a(c.data,{context:u?.context});if(!N(o)){let f={message:`derive() callback must return a plain object of overrides, got ${o===null?"null":typeof o}`};return {success:false,error:f,errors:[f]}}if(l==="missing"){let f={...c.data};for(let p in o)f[p]===void 0&&(f[p]=o[p]);return {success:true,data:f}}return {success:true,data:{...c.data,...o}}}),this},g(t,"_parse",(a,l,n)=>{let i=a(l,n),{abortEarly:u}=_(n);if(i.success===false)return i;let c={},o=[];for(let f in e){let p=e[f]._parse(i.data[f],n);if(p.success)c[f]=p.data;else {let m=O(p,f,u,o);if(m)return m}}return o.length>0?{success:false,error:o[0],errors:o}:{success:true,data:c}}),r}function E(e){return h(b,{...e,type:"string"})}function w(e){return h(v,{...e,type:"number"})}function S(e){return h(j,{...e,type:"boolean"})}function k(e){return h(V,{...e,type:"date"})}function q(e){return h(W,{...e,type:"function"})}function I(e,s){let t=n=>e.includes(n),r=n=>`Invalid ${a} value. Expected ${e.map(i=>`"${i}"`).join(" | ")}, received "${n}".`,a="enum",l=h(t,{message:r,...s,type:a});return l._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,l._getDefinition=()=>e,l}function P(e,s){let t=h(Y,{...s,type:"array"});return t._getDescription=()=>`array(${e._getDescription()})`,t._getDefinition=()=>e,g(t,"_parse",(r,a,l)=>{let n=r(a,l),{abortEarly:i}=_(l);if(n.success===false)return n;let u=[],c=[],o=l;for(let f=0;f<n.data.length;f++){let p={...o,context:{...o?.context,index:f}},m=e._parse(n.data[f],p);if(m.success)u.push(m.data);else {let y=O(m,f,i,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),t}function R(){return h(()=>true)}function d(e,s){return g(s,"_parse",(t,r,a)=>(r=e(r),t(r,a))),s}function F(e,s){let t=a=>`Invalid union value. Expected the value to match one of the schemas:${e.map((l,n)=>` ${n+1}. ${l._getDescription()}`).join(",")} but received "${typeof a}" with value: ${N(a)?JSON.stringify(a):`"${a}"`}`,r=h(()=>false,{message:t,...s,type:"union"});return r._getDefinition=()=>e,g(r,"_parse",(a,l,n)=>{let i=n,u=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(l,i);if(m.success)return m;u.push(m);}let{abortEarly:c}=_(i),o={message:typeof t=="function"?t(l):t};if(c!==false)return {success:false,error:o,errors:[o]};let f=[];for(let p=0;p<u.length;p++){let m=u[p].errors;if(m?.length)for(let y=0;y<m.length;y++)m[y].cause?.key&&f.push(D(m[y],`branch ${p}`));}return f.length===0&&f.push(o),{success:false,error:f[0],errors:f}}),r}function H(e,s){let t=h(r=>r===e,{message:r=>s?.message?typeof s.message=="function"?s.message(r):s.message:`Expected literal value "${e}", received "${r}"`,name:s?.name,type:"literal"});return t._getDescription=()=>`literal("${e}")`,t._getDefinition=()=>e,t}function L(e){let s=h(()=>true,{type:"contextRef"});return s._getDescription=()=>`contextRef("${e}")`,g(s,"_parse",(t,r,a)=>({success:true,data:a?.context?.[e]})),s}function z(e,s){return {parse(t,r){let a=e.parse(r?.context??{},r);return s(a).parse(t,r)},safeParse(t,r){let a=e.safeParse(r?.context??{},r);return a.success?s(a.data).safeParse(t,r):a}}}var B={boolean(e){let s=e?.message??(t=>`Cannot cast "${t}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return d(t=>{let r;return b(t)&&(r=t.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||t===1?true:r==="false"||r==="no"||r==="off"||r==="0"||t===0?false:t},S({...e,message:s}))},number(e){let s=e?.message??(t=>`Cannot cast "${t}" to a number. Expected a numeric string or number.`);return d(t=>{if(j(t))return Number(t);if(b(t)){let r=t.trim();if(r==="")return t;let a=Number(r);if(Number.isFinite(a))return a}return t},w({...e,message:s}))},string(e){let s=e?.message??(t=>`Cannot cast "${t}" to string. Expected a string, number, or boolean.`);return d(t=>j(t)||v(t)&&Number.isFinite(t)?String(t):t,E({...e,message:s}))},date(e){let s=e?.message??(t=>`Cannot cast "${t}" to a valid date.`);return d(t=>{let r;return b(t)&&(r=t.trim()),v(t)&&Number.isFinite(t)||r?new Date(r??t):t},k({...e,message:s}))},json(e,s){let t=s?.message??(r=>`Cannot parse "${r}" as JSON.`);return g(e,"_parse",(r,a,l)=>{if(b(a))try{a=JSON.parse(a);}catch{let n={message:typeof t=="function"?t(a):t};return {success:false,error:n,errors:[n]}}return r(a,l)}),e}},G={},M={object:T,string:E,number:w,boolean:S,date:k,function:q,enum:I,array:P,any:R,preprocess:d,union:F,literal:H,contextRef:L,withContext:z,coerce:G,cast:B};function A(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function g(e,s,t){let r=e[s];e[s]=(...a)=>t(r,...a);}function h(e,{type:s="any",name:t,message:r}={}){r=r||A(s);let a={name:t,message:r,type:s},l={_getName(){return t},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(n,i){let u=e(n);if(u===true)return {success:true,data:n};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof r=="function"?r(n):r};return {success:false,error:c,errors:[c]}},parse(n,i){let u=this._parse(n,i);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(n,i){return this._parse(n,i)},transform(n){return g(this,"_parse",(i,u,c)=>{let o=i(u,c);return o.success&&(o.data=n(o.data)),o}),this},optional(){return x(this,n=>n===void 0),this},nullable(){return x(this,n=>n===null),this},nullish(){return x(this,n=>n==null),this},default(n){return g(this,"_parse",(i,u,c)=>(u===void 0&&(u=typeof n=="function"?n({context:c?.context}):n),i(u,c))),this},catch(n){return g(this,"_parse",(i,u,c)=>{let o=i(u,c);return o.success?o:{success:true,data:typeof n=="function"?n({input:u,error:o.error}):n}}),this},pipe(n){return g(this,"_parse",(i,u,c)=>{let o=i(u,c);return o.success?n._parse(o.data,c):o}),this},refine(n,{message:i,type:u,jsonSchema:c}={}){if(u&&(i=i||A(u),s=u),c){let o=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>o;}return g(this,"_parse",(o,f,p)=>{let m=o(f,p),{abortEarly:y}=_(p);if(!m.success)return m;let $=n(m.data);if($===true||typeof $=="object"&&$?.success===true)return m;let C={message:typeof i=="function"?i(f):i};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return J.length>0?J.reduce((n,i)=>i(n,e,a)??n,l):l}var J=[];export{M as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {k as k$1,s,j as j$1,b,a as a$1,q as q$1,o,p,m}from'./chunk-TX4RCFPO.mjs';import {a,n}from'./chunk-YHWQV2DB.mjs';function P(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function T(e=[]){let n=new Set;return e.map(t=>{if(t?.componentId&&!n.has(t.componentId))return n.add(t.componentId),t;let r=a();return n.add(r),{...t,componentId:r}})}function k(e){return e?[...e.children].filter(n=>n.nodeName==="LI"):[]}function F(e,n){if(!e||!n)return null;let t=n.startContainer;for(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);t&&t!==e;){if(t.nodeName==="LI"&&e.contains(t))return t;t=t.parentElement;}return null}function _(e,n){if(!n)return -1;let t=n.getAttribute?.("data-item-index");if(t!=null&&t!==""){let r=Number(t);if(!Number.isNaN(r))return r}return k(e).indexOf(n)}function H(e,n$1){return !e||!n$1?0:n(e,n$1.startContainer,n$1.startOffset)}function j(e,n){let t=k$1({properties:{text:e.text,inlineStyleRanges:e.inlineStyleRanges,entityRanges:e.entityRanges}}),{originalLineState:r,newLineState:s$1}=s(t,n);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:a(),depth:e.depth??0,text:s$1.properties.text,inlineStyleRanges:s$1.properties.inlineStyleRanges??[],entityRanges:s$1.properties.entityRanges??[]}}}function q(e,{style:n="UNORDERED"}={}){let t=e?.properties?.items,r=Array.isArray(t)&&t.length?t.map(s=>({componentId:a(),depth:s?.depth??0,text:j$1(s?.text??""),inlineStyleRanges:[...s?.inlineStyleRanges??[]],entityRanges:[...s?.entityRanges??[]]})):[{componentId:a(),depth:0,text:j$1(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:b,componentId:a(),properties:{items:r},settings:{style:n==="ORDERED"?"ORDERED":"UNORDERED"}}}function z(e,n,{namespace:t=a$1,Constructor:r}={}){let s=e.properties?.items??[],i=s[n];if(!i)return {blocks:[e],paragraphIndex:0};let p=s.slice(0,n),o=s.slice(n+1),l=k$1({properties:{text:i.text,inlineStyleRanges:i.inlineStyleRanges,entityRanges:i.entityRanges}}),a$1={component:t,componentId:a(),settings:{},...r?.fromExchangeState(l)??l},c=[];return p.length&&c.push({...e,properties:{...e.properties,items:p}}),c.push(a$1),o.length&&c.push({...e,componentId:p.length?a():e.componentId,properties:{...e.properties,items:o}}),{blocks:c,paragraphIndex:p.length?1:0}}function O(e){return m(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function B(e,n){let t=O(e),r=O(n);return t!=null&&t===r}function G(e,n,t){if(n<0||t!==n+1||t>=e.length)return null;let r=e[n],s=e[t];if(!B(r,s))return null;let i=[...r.properties?.items??[]],p=[...s.properties?.items??[]];if(p.length===0){let m=[...e];m.splice(t,1);let u=i.length-1,f=u>=0?j$1(i[u]?.text).length:0;return {content:m,listIndex:n,cursor:f}}let[o,...l]=p,a=0;if(i.length===0)i.push(o,...l),a=0;else {let m=i.length-1,u=i[m],f=k$1({properties:{text:u.text,inlineStyleRanges:u.inlineStyleRanges,entityRanges:u.entityRanges}}),b=k$1({properties:{text:o.text,inlineStyleRanges:o.inlineStyleRanges,entityRanges:o.entityRanges}}),{state:x,cursor:C}=q$1(f,b);i[m]={...u,text:x.properties.text,inlineStyleRanges:x.properties.inlineStyleRanges,entityRanges:x.properties.entityRanges},l.length&&i.push(...l),a=C;}let c={...r,properties:{...r.properties,items:T(i)}},d=[...e];return d[n]=c,d.splice(t,1),{content:d,listIndex:n,cursor:a}}function X(e,n){let t=e.properties?.items??[],r=t.length-1;if(r<0)return null;let s=t[r],i=k$1({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),p=k$1({properties:n?.properties}),{state:o,cursor:l}=q$1(i,p);return {state:{...e,properties:{...e.properties,items:t.map((a,c)=>c===r?{...a,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges,entityRanges:o.properties.entityRanges}:a)}},cursor:l}}function J(e,n){return o({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},n)}function K(e,n){let t=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:j$1(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return p(e.childNodes,r,0,n),{componentId:e.getAttribute("data-componentid")||void 0,depth:t,text:j$1(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}export{P as a,T as b,k as c,F as d,_ as e,H as f,j as g,q as h,z as i,G as j,X as k,J as l,K as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {i}from'./chunk-K2DMHAUD.mjs';var e=i();export{e as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {a as a$1,j,i,n}from'./chunk-YHWQV2DB.mjs';import {r,o}from'./chunk-K2DMHAUD.mjs';var d="molecule.paragraph.Paragraph",O="molecule.list.List",F="molecule.external.ExternalComponent",v="namespace.unknown.UnknownComponent",X="molecule.headline.H1",K="molecule.headline.H2",z="molecule.headline.H3",G="molecule.headline.H4",U="molecule.headline.H5",A="molecule.headline.";function a(t){return t===`
|
|
2
|
+
`||t===`\r
|
|
3
|
+
`?"":t??""}function Q({component:t,originComponent:e,properties:n,settings:o}={}){let r=n??{};return {...t?{component:t}:{},...e?{originComponent:e}:{},properties:{...r,text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]},...o?{settings:o}:{}}}function N(t){let e=t?.component??"";return e===d||e.startsWith(A)}function V(t){return Array.isArray(t?.properties?.items)}function Y(t,e){return N(t)&&N(e)&&t.component===e.component}function L(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 C(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 f=o$1.find(c=>c.match(i));f&&(s=o(f,{},s));}for(let i of n){let f=r.find(c=>c.match(i));f&&(s=o(f,i,s));}return s}function Z(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 f=L([...s,...i],r$1.length);for(let c=0;c<f.length-1;c+=1){let l=f[c],p=f[c+1];if(l>=p)continue;let g=r$1.slice(l,p),H=T(g,C(s,l,p),C(i,l,p),{inlineStyleComponents:e,entityRangeComponents:n});r(o,H);}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 f=o.find(l=>l.match(i));if(f){let l=i.textContent.length;e.properties.inlineStyleRanges.push({style:f.style,offset:s,length:l}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}let c=r.find(l=>l.match(i));if(c){let l=i.textContent.length;e.properties.entityRanges.push({...c.getStateSchema(i).parse(),offset:s,length:l}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});}return s}function I(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 $(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],f=s[n],{originalLineState:c}=y(i,o),{newLineState:l}=y(f,r),{state:p,cursor:g}=I(c,l);return s.splice(e,n-e+1,p),{content:s,cursor:g,resultIndex:e}}function P(t,e){return (t??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)}))}function M(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 y(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=P(t.properties.inlineStyleRanges,e),o.properties.inlineStyleRanges=M(t.properties.inlineStyleRanges,e),n.properties.entityRanges=P(t.properties.entityRanges,e),o.properties.entityRanges=M(t.properties.entityRanges,e),o.componentId=a$1(),{originalLineState:n,newLineState:o}}function b(t,e,{namespace:n=t.constructor.NAMESPACE}={}){if(e.key!=="Enter")return false;e.preventDefault();let{originalLineState:o,newLineState:r}=y(t.getState(),j(t.element));return t.mrakomor.command.insertBlockElement({range:i(),cursor:0,newLineState:r,originalLineState:o,namespace:n}),true}function ee(t,e){if(e.key!=="Enter")return false;e.preventDefault();let n=d,o=t.mrakomor.resolveComponentConstructor(n);return t.mrakomor.command.insertBlockElement({range:i(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:n}),true}function te(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 ne(t){return t?{element:t,read(e){return {inlineStyleRanges:e.properties?.inlineStyleRanges,entityRanges:e.properties?.entityRanges}},write(e,{inlineStyleRanges:n,entityRanges:o}){n!==void 0&&(e.properties.inlineStyleRanges=n),o!==void 0&&(e.properties.entityRanges=o);}}:null}function _(t,e){let n$1=n(t,e.startContainer,e.startOffset),o=n(t,e.endContainer,e.endOffset);return {offset:n$1,length:Math.max(0,o-n$1)}}function B(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(f=>f.style===e&&f.offset<=n&&f.offset+f.length>=s);return i?r.filter(f=>f!==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 k(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 D(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(f=>f.offset===r&&f.length===o&&f.entity?.type===s);return i?n.filter(f=>f!==i):[...k(n,e),e]}function oe(t,e,{style:n,range:o}){if(!t||!e?.element||!o)return null;let r=e.read(t);if(r?.inlineStyleRanges===void 0)return null;let{offset:s,length:i}=_(e.element,o);return i===0?null:(e.write(t,{inlineStyleRanges:B(r.inlineStyleRanges??[],{style:n,offset:s,length:i})}),t)}function re(t,e,{state:n,namespace:o,range:r}){if(!t||!e?.element||!r)return null;let s=e.read(t);if(s?.entityRanges===void 0)return null;let i={...n,entity:{type:o,...n?.entity},..._(e.element,r)},f=D(s.entityRanges??[],i);return f===null?null:(e.write(t,{entityRanges:f}),t)}export{d as a,O as b,F as c,v as d,X as e,K as f,z as g,G as h,U as i,a as j,Q as k,N as l,V as m,Y as n,Z as o,u as p,I as q,$ as r,y as s,b as t,ee as u,te as v,ne as w,_ as x,oe as y,re as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-G2QV4GOO.mjs';import {d,a as a$3,b}from'./chunk-GDID5DFL.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {a as a$1,v,o,j,w,t}from'./chunk-TX4RCFPO.mjs';import {d as d$1}from'./chunk-YHWQV2DB.mjs';import {o as o$1,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 v(this,t)}_buildContent(t){return o(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return o$1("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>"}})}getFormattingTarget(t){return w(this.element)}onKeydown(t$1){t(this,t$1);}};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,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-G2QV4GOO.mjs';import {d}from'./chunk-GDID5DFL.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {j,t,a as a$4,e,f as f$1,g,h,i as i$2}from'./chunk-TX4RCFPO.mjs';import {d as d$1,i as i$1,f,s as s$1,r}from'./chunk-YHWQV2DB.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$1){if(t$1.key==="Backspace"){this.#t(t$1);return}t(this,t$1,{namespace:a$4});}#t(t){if(!i$1()?.collapsed)return;let n$1=f(this.element);if(n$1?.previousElementSibling||j(this.getState()?.properties?.text))return;t.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=s$1(b);p?.isConnected&&r(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$2}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,3 @@
|
|
|
1
|
+
import {a as a$1,b as b$2,h,k as k$1,c,m,d,e,l,j as j$1,i as i$1,f as f$1,g}from'./chunk-Q7RMVYZR.mjs';import {a}from'./chunk-G2QV4GOO.mjs';import {b as b$3,a as a$7}from'./chunk-GDID5DFL.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {b as b$1,j,k,a as a$5,l as l$1,m as m$1}from'./chunk-TX4RCFPO.mjs';import {a as a$6}from'./chunk-B6JJAATK.mjs';import {a as a$3,i,f,d as d$1,t,r}from'./chunk-YHWQV2DB.mjs';import {q,o,a as a$4,n}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var m="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===m});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",m),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);}}})();var S=m=>a$2.object({componentId:a$2.string().default(()=>m?.getAttribute?.("data-componentid")||a$3()),depth:a$2.number().default(0),text:a$2.string().default(""),inlineStyleRanges:a$2.array(a$7()).default([]),entityRanges:a$2.array(b$3()).default([])}).default({}),b=class m$1 extends a{static get NAMESPACE(){return b$1}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=a$1(t);return a$2.object({component:a$2.string().default(m$1.NAMESPACE),componentId:a$2.string().default(t?.getAttribute("data-componentid")||a$3()),properties:a$2.object({items:a$2.array(S()).default([S().parse()]).transform(b$2)}).default({}),settings:a$2.object({style:a$2.enum(["ORDERED","UNORDERED"]).default(e??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let e=t?.properties?.items??[],n=e.map(r=>j(r?.text)).join(`
|
|
3
|
+
`),s=e.map(r=>({text:j(r?.text),inlineStyleRanges:r?.inlineStyleRanges??[],entityRanges:r?.entityRanges??[],depth:r?.depth??0}));return k({originComponent:this.NAMESPACE,properties:{text:n,items:s},settings:t?.settings})}static fromExchangeState(t){return h(t,{style:t?.settings?.style})}static appendExchangeState(t,e){return k$1(t,e)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let e=structuredClone(this.constructor.getStateSchema(t).parse()),n={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},s=c(t);if(s.length)e.properties.items=s.map(r=>S(r).parse(m(r,n)));else {let r=this.state?.peek?.()?.properties?.items;e.properties.items=r?.length?structuredClone(r):[S().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}getFormattingTarget(t){let e$1=t??i(),n=d(this.element,e$1);if(!n)return null;let s=e(this.element,n);return s<0?null:{element:n,read(r){let o=r.properties?.items?.[s];return {inlineStyleRanges:o?.inlineStyleRanges,entityRanges:o?.entityRanges}},write(r,{inlineStyleRanges:o,entityRanges:i}){let a=r.properties?.items?.[s];a&&(o!==void 0&&(a.inlineStyleRanges=o),i!==void 0&&(a.entityRanges=i));}}}_commitState(t){let e=f(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),n=this.mrakomor._getBlockElementIndex(e);if(n===-1)return;let s=this.mrakomor.getContent();s.splice(n,1,t),this.mrakomor.setContent(s);}_buildItemContent(t){return l(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),e=this.state.peek(),n=e.settings?.style==="ORDERED"?"ol":"ul",s=q(()=>this.state.get().properties?.items??[],(r,o)=>r.componentId??String(o),(r,o$1)=>o("li",{contentEditable:true,[d$1]:true,"data-componentid":()=>r.get().componentId,"data-item-index":()=>{let i=r.get()?.componentId,c=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===i);return String(c>=0?c:o$1)},"data-depth":()=>String(r.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let i=r.get(),a=i?.text??"";return j(a)?a$4(()=>this._buildItemContent(i)):"<br>"}}),{tagName:n});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){let e=this.getState()?.properties?.items??[],n$1=e.length-1;if(n$1<0)return;let s=typeof t=="number"?t:j(e[n$1]?.text).length,r$1=()=>{let o=this.element?.querySelector(`li[data-item-index="${n$1}"]`);o?.isConnected&&r(o,s);};r$1(),n(r$1);}#t(t$1){let e=this.getState(),n$1=[...e.properties.items??[]],s=n$1[t$1];if(!s)return;if((s.depth??0)>0){n$1[t$1]={...s,depth:s.depth-1},this._commitState({...e,properties:{...e.properties,items:n$1}});let p=()=>{let g=this.element?.querySelector(`li[data-item-index="${t$1}"]`);g?.isConnected&&r(g,0);};p(),n(p);return}let r$1=f(this.element),o=this.mrakomor._getBlockElementIndex(r$1),i=r$1?.previousElementSibling??null,a=i?this.mrakomor._getBlockElementIndex(i):-1;if(t$1===0&&a>=0&&o===a+1){let p=this.mrakomor.getContent(),g=j$1(p,a,o);if(g){this.mrakomor._setContentState(g.content.map(Q=>this.mrakomor.normalizeComponentState(Q))),t(i)?.setCursor?.(g.cursor);return}}let{blocks:c,paragraphIndex:u}=i$1(e,t$1,{Constructor:this.mrakomor.register.blocks.getByNamespace(a$5)});this.mrakomor.command.replaceBlockElement({blockElement:f(this.element),blocks:c,cursor:0,cursorBlockIndex:u});}#e(t){t.preventDefault();let e$1=i(),n$1=d(this.element,e$1);if(!n$1)return;let s=e(this.element,n$1),r$1=f$1(n$1,e$1),o=this.getState(),i$1=[...o.properties.items??[]],a=i$1[s];if(!a)return;if(!j(a.text)){this.#t(s);return}let{before:c,after:u}=g(a,r$1);i$1.splice(s,1,c,u),this._commitState({...o,properties:{...o.properties,items:i$1}}),n(()=>{let p=this.element?.querySelector(`li[data-item-index="${s+1}"]`);p&&r(p,0);});}#n(t){let e$1=i();if(!e$1?.collapsed)return;let n=d(this.element,e$1);if(!n){let o=e$1.startContainer;if(!(o===this.element||this.element?.contains?.(o)))return;t.preventDefault(),this.#t(0);return}let s=e(this.element,n);f$1(n,e$1)===0&&(t.preventDefault(),this.#t(s));}};function W(m){let{mrakomor:t$1,blockElement:e$1,namespace:n}=m;if(!t$1||!e$1||!n)return;let s=t$1._getBlockElementState(e$1);if(!s||!l$1({component:n})||!m$1(s))return;m.preventDefault();let o=t(e$1)?.element,i$2=m.range??i(),a=o?d(o,i$2):null,c=e(o,a);if(c<0)return;let{blocks:u,paragraphIndex:p}=i$1(s,c,{namespace:n,Constructor:t$1.register.blocks.getByNamespace(n)});t$1.command.replaceBlockElement({blockElement:e$1,blocks:u,cursor:0,cursorBlockIndex:p});}function X(m){return {resolveConfig:t=>(t.blockComponents.push({component:m,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:m,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===m.NAMESPACE)return m},registerCommands(t){t.emitter.on(a$6.TRANSFORM_BLOCK_ELEMENT,W);}}}function lt(){return X(b)}export{b as a,X as b,lt as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-P7IKAZYZ.mjs';var u=class{#r=new Set;pipe(...t){return c(...t)(this)}next(...t){Array.from(this.#r).forEach(r=>{typeof r=="function"?r(...t):r.next(...t);});}error(...t){Array.from(this.#r).forEach(r=>{r?.error?.(...t),this.unsubscribe(r);});}complete(...t){Array.from(this.#r).forEach(r=>{r?.complete?.(...t),this.unsubscribe(r);});}subscribe(t){return this.#r.add(t),{unsubscribe:()=>{this.unsubscribe(t);}}}unsubscribe(t){this.#r.delete(t);}};function c(...t){return r=>Array.from(t).reduce((e,s)=>s(e),r)}function a(t){return t.map((r,e)=>({entry:r,index:e})).sort((r,e)=>{let s=r.entry.order??r.index,i=e.entry.order??e.index;return s!==i?s-i:r.index-e.index}).map(({entry:r})=>r)}var h=class extends u{mrakomor;#r=new Map;#t=null;#s=0;#n;constructor(r,e={}){super(),this.mrakomor=r,this.#n=e.sort??a;}normalize(r,e){throw new Error("Register subclass must implement normalize")}#e(){this.#t=null,this.next(this.list());}#i(r,e=this.#s++){let s=this.normalize(r,e);return s?(this.#r.set(s.id,s),s):null}add(r){if(Array.isArray(r)){let s=[];for(let i of r){let o=this.#i(i,this.#s++);o&&s.push(o);}return s.length&&this.#e(),s}let e=this.#i(r);return e&&this.#e(),e}get(r){return this.#r.get(r)}has(r){return this.#r.has(r)}remove(r){let e=this.#r.delete(r);return e&&this.#e(),e}list(){return this.#t??=this.#n([...this.#r.values()]),this.#t}};function l(){return a$1.object({id:a$1.string(),group:a$1.string().default("general"),description:a$1.string().default(""),commands:a$1.array(a$1.string()).default([]),shortcuts:a$1.array(a$1.string()).default([])}).default({})}function g(t){try{return l().parse(t)}catch{return null}}export{h as a,l as b,g as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {g as g$1}from'./chunk-K2DMHAUD.mjs';var g=m(),C=m(),R=m(),k=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function m(){return Math.floor(Math.random()*16777215)}function I(){return C=(C+1)%16777215,C}function H(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=I(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,g>>16&255,g>>8&255,g&255,R>>8&255,R&255,e>>16&255,e>>8&255,e&255),o="";for(let l=0;l<n.length;l++)o+=k[n.charCodeAt(l)];return o}var E=Symbol("block-element"),M=Symbol("block-element-body"),O=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 T(t){return t?h(t.startContainer,E):null}function b(t){return h(t,E)}function y(t){return t?h(t.startContainer,O):null}function B(t){return h(t,O)}function x(){return window.getSelection()}function N(){let t=x();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function X(){let t=N();if(!t)return 0;t.collapse(true);let e=y(t),n=T(t),o=e??s(n);return d(o,t.startContainer,t.startOffset)}var f=null;function v(){f=A();}function _(){f&&D(f);}function W(){f&&(f={start:f.end,end:f.end,element:f.element},_());}function w(t,e){let n=y(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 A(){let t=N();if(!t)return null;let e=T(t),n=w(e,t);return {start:d(n,t.startContainer,t.startOffset),end:d(n,t.endContainer,t.endOffset),element:e,selectableElement:n}}function j(t=N()){if(!t||t.collapsed)return null;let e=b(t.startContainer),n=b(t.endContainer);if(!e||!n)return null;let o=B(t.startContainer)??s(e),l=B(t.endContainer)??s(n);return {startBlock:e,endBlock:n,startOffset:d(o,t.startContainer,t.startOffset),endOffset:d(l,t.endContainer,t.endOffset)}}function D(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=S(r,e),u=S(r,n),a=document.createRange();a.setStart(c.startContainer,c.startOffset),a.setEnd(u.endContainer,u.endOffset);let i=x();i.removeAllRanges(),i.addRange(a);}function S(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 K(t,e){let n=S(t,e),o=x();o.removeAllRanges(),o.addRange(n);}function s(t){if(!t)return null;let e=L(t);return e?.firstElementChild??e?.firstChild}function F(t){if(!t?.[E])return null;let e=s(t);return e?g$1(e)?.classInstance:null}function L(t){if(!t)return null;for(let e of t.children)if(e[M])return e;return null}function Y(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 q(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{H as a,E as b,M as c,O as d,T as e,b as f,y as g,B as h,N as i,X as j,v as k,_ as l,W as m,d as n,A as o,j as p,D as q,K as r,s,F as t,L as u,Y as v,q as w};
|
|
@@ -0,0 +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===`
|
|
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&>(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;
|
package/dist/clipboard.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
`):
|
|
3
|
-
`)}function
|
|
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};
|
package/dist/footer.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
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&<(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;
|
package/dist/footer.mjs
ADDED
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use strict';(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(r){return r.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-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}
|
|
2
|
+
`,document.head.appendChild(n);}}})();var Qe=class{next(...e){}error(...e){}complete(...e){}},ye=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 te=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var S=null,Se=false,be=[];function v(e){let t=S;S=null;let n=e();return S=t,n}function ln(){Se=false;let e=nt();for(let n of e)n.get();let t=be;be=[];for(let n of t)n();}function Ze(){Se||(Se=true,queueMicrotask(ln));}function xe(e){be.push(e),Ze();}var et=Symbol("@esmj/signals:internal observable"),R=Symbol("@esmj/signals:original function"),fn=class extends ye{#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=()=>v(()=>{this.#e.add(e),this.#r();}),e.next[R]=void 0),e instanceof st&&e.next[R]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#r();}),e.next[R]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[R]){let n=t.get,r=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),r())),t.get[R]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[R]?e.next[R]:e.next,e.get=e.get[R]?e.get[R]:e.get,this.#e.delete(e),this.unsubscribe(e)}},ne=null;function tt(e){ne=new fn(e);}tt(()=>{Ze();});function nt(){return ne.getPending()}function rt(e){return ne.watch(e)}function ot(e){return ne.unwatch(e)}var k=Symbol("@esmj/signals:no error"),st=class it extends Qe{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#u=null;#i=0;#s=new Map;#t=k;constructor(t,n){super(),this.#c=t,this.#u=n,this.debug=n?.debug,this[te]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#l(){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 it&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==k)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==k)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==k)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=k,this.#l(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#c();}catch(r){this.#t=r;}return S=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#t=k,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===k&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#l(),this.#s.clear(),this.#e=true,this.#t=k;}};function B(e,t){return new st(e,t)}function _(e,t){let n,{debug:r,...o}={},i=B(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),rt(i);let s=()=>{n?.(),i.destroy(),ot(i);};return s[Symbol.dispose]=s,s[te]="effect",s[q]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new ye;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(l,r)),e}function s(){return e}function a(c){if(!n(e,c)){e=c,r++,o.next();}return e}function u(){return r}let l={get:i,set:a,peek:s,getRevision:u,[et]:o,[te]:"signal",[q]:t?.debug??null};return l}function re(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var dt=Symbol("node-component"),oe=Symbol("node-internal"),pn=Symbol("keep-literal"),ue=Symbol("raw-props");var gt=null;function D(){return gt}function se(e){gt=e;}function Me(e){return e?.[dt]||null}function at(e,t){e[dt]=t;}function ie(e,t={disposers:[],id:re()}){return e?.[oe]?e[oe]:(e&&(e[oe]=t),t)}function dn(e){return e[oe]}function L(e,t){let n=dn(e);n||(n=ie(e)),n.disposers.push(t);}function _e(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function T(e,t){let n=D();se(e);try{return t()}finally{se(n);}}var Ne=new Map,ae=new Map,ut=new Map;function Et(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let i=e[o];o==="children"||n(o)?r[o]=i:i?.[pn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=B(i):r[o]=I(i);}return r}function we(e){return {id:Symbol("context-id"),defaultValue:e}}function Le(e){let t=D();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function U(e){xe(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ne.get(t);if(n){Ne.delete(t);for(let r of n){let o=r();typeof o=="function"&&_e(ae,t,o);}}}function gn(e){let t=ae.get(e);if(t){ae.delete(e);for(let n of t)n();}}function En(e){let t=ut.get(e);if(t){ut.delete(e);for(let n of t)n();}}function Te(e){if(!e)return;let t=ie(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=Me(e);if(n&&(gn(n.componentId),En(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Te(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ct(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function yn(e,t,n){let r=re(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=ct(e)?void 0:e[ue],s={...Et(t??{},i),children:n},a=D(),u={disposers:[],id:r,contexts:new Map(a?.contexts)};se(u);let l;if(ct(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&_e(Ne,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&_e(ae,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);se(a);let c=Sn(l);if(o.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)ie(f,u),at(f,o);else ie(c,u),c instanceof Node&&at(c,o);return c}};return o}function yt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function Sn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var lt={className:"class",htmlFor:"for"},ft=new Set(["value","defaultValue","checked","selected","indeterminate"]),bn=new Set(["srcdoc"]),xn=new Set(["href","src","action","formaction","xlink:href"]),Cn=new Set(["securitypolicyviolation"]),_n=new Set(["contenteditable","draggable","spellcheck"]);function G(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var St=Symbol("Fragment");function le(e,t,n){if(e===St){let o=document.createDocumentFragment();return Ae(o,mt(n)),o}if(typeof e=="function")return yn(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let r=document.createElement(e);return t.id&&r.setAttribute("id",t.id),fe(r,t),Ae(r,mt(n)),r}function Ce(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Nn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function An(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return bn.has(n)?true:xn.has(n)&&t!==null&&t!==void 0&&Nn(String(t))}function bt(e){return typeof e!="string"?e:lt[e]?lt[e]:e}function Rn(e,t){let n=bt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return _n.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function pt(e,t,n){let r=Rn(t,n);if(r===null){e.removeAttribute(t);return}if(An(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function fe(e,t){let n=D();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=bt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(G(o)){let i=_(()=>{T(n,()=>{Ce(e,o.get());});});L(e,i);}else if(typeof o=="function"){let i=_(()=>{T(n,()=>{Ce(e,o());});});L(e,i);}else Ce(e,o);continue}if(r==="style"){if(G(o)){let i=_(()=>{T(n,()=>{Object.assign(e.style,o.get());});});L(e,i);}else typeof o=="object"&&o!==null?Object.assign(e.style,o):e.setAttribute("style",o);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof o=="function"){let i=r.slice(2).toLowerCase();if(Cn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(G(o)||typeof o=="function"){let i=r,s=_(()=>{T(n,()=>{let a=typeof o=="function"?o():o.get();ft.has(i)?e[i]=a??"":pt(e,i,a);});});L(e,s);continue}ft.has(r)||typeof r=="symbol"?e[r]=o??"":pt(e,r,o);}}function mt(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Ae(e,t){for(let n of t)xt(e,n);}function xt(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"){ht(e,t);return}if(j(t)){yt(e,t);return}if(G(t)){ht(e,()=>t.get());return}if(Array.isArray(t)){Ae(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function H(e){let t=null,n=e;return j(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 pe(e,t=true){for(let n of e)t&&Te(n),n.remove();}function ht(e,t){let n=D(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{T(n,()=>{let s=t(),{nodes:a,instance:u}=H(s);pe(o),a.length&&r.after(...a),u&&queueMicrotask(()=>Y(u)),o=a;});});L(e,i);}var Nt=class{constructor(e){this.props=e;}};var Mn={abortEarly:true};function De(e,t){if(t===void 0)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function wn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(De(e.errors[r],n));}function kt(e,t,n,r){if(n!==false){let o=De(e.error,t);return {success:false,error:o,errors:[o]}}wn(e,r,t);}function me(e){return e?.abortEarly!==void 0?e:Mn}function Oe(e,t){g(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var W=e=>typeof e=="string"||e instanceof String,Pe=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ie=e=>e===true||e===false,Ln=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Tn=e=>typeof e=="function",On=e=>Array.isArray(e),Be=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function vt(e,t){let n=b(Be,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,i])=>`${o}: ${i._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:i="always"}={}){return g(this,"_parse",(s,a,u)=>{let l=s(a,u);if(!l.success)return l;let c=o(l.data,{context:u?.context});if(!Be(c)){let f={message:`derive() callback must return a plain object of overrides, got ${c===null?"null":typeof c}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let p in c)f[p]===void 0&&(f[p]=c[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...c}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:u}=me(s);if(a.success===false)return a;let l={},c=[];for(let f in e){let p=e[f]._parse(a.data[f],s);if(p.success)l[f]=p.data;else {let m=kt(p,f,u,c);if(m)return m}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),r}function $e(e){return b(W,{...e,type:"string"})}function je(e){return b(Pe,{...e,type:"number"})}function He(e){return b(Ie,{...e,type:"boolean"})}function Fe(e){return b(Ln,{...e,type:"date"})}function Mt(e){return b(Tn,{...e,type:"function"})}function wt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${s}".`,o="enum",i=b(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Lt(e,t){let n=b(On,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,g(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:a}=me(i);if(s.success===false)return s;let u=[],l=[],c=i;for(let f=0;f<s.data.length;f++){let p={...c,context:{...c?.context,index:f}},m=e._parse(s.data[f],p);if(m.success)u.push(m.data);else {let E=kt(m,f,a,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:u}}),n}function Tt(){return b(()=>true)}function F(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Ot(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((i,s)=>` ${s+1}. ${i._getDescription()}`).join(",")} but received "${typeof o}" with value: ${Be(o)?JSON.stringify(o):`"${o}"`}`,r=b(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,g(r,"_parse",(o,i,s)=>{let a=s,u=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(i,a);if(m.success)return m;u.push(m);}let{abortEarly:l}=me(a),c={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:c,errors:[c]};let f=[];for(let p=0;p<u.length;p++){let m=u[p].errors;if(m?.length)for(let E=0;E<m.length;E++)m[E].cause?.key&&f.push(De(m[E],`branch ${p}`));}return f.length===0&&f.push(c),{success:false,error:f[0],errors:f}}),r}function Pt(e,t){let n=b(r=>r===e,{message:r=>t?.message?typeof t.message=="function"?t.message(r):t.message:`Expected literal value "${e}", received "${r}"`,name:t?.name,type:"literal"});return n._getDescription=()=>`literal("${e}")`,n._getDefinition=()=>e,n}function It(e){let t=b(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,g(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Bt(e,t){return {parse(n,r){let o=e.parse(r?.context??{},r);return t(o).parse(n,r)},safeParse(n,r){let o=e.safeParse(r?.context??{},r);return o.success?t(o.data).safeParse(n,r):o}}}var Dt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return F(n=>{let r;return W(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},He({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return F(n=>{if(Ie(n))return Number(n);if(W(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},je({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ie(n)||Pe(n)&&Number.isFinite(n)?String(n):n,$e({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return W(n)&&(r=n.trim()),Pe(n)&&Number.isFinite(n)||r?new Date(r??n):n},Fe({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return g(e,"_parse",(r,o,i)=>{if(W(o))try{o=JSON.parse(o);}catch{let s={message:typeof n=="function"?n(o):n};return {success:false,error:s,errors:[s]}}return r(o,i)}),e}},$t={},d={object:vt,string:$e,number:je,boolean:He,date:Fe,function:Mt,enum:wt,array:Lt,any:Tt,preprocess:F,union:Ot,literal:Pt,contextRef:It,withContext:Bt,coerce:$t,cast:Dt};function At(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function g(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function b(e,{type:t="any",name:n,message:r}={}){r=r||At(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let u=this._parse(s,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success&&(c.data=s(c.data)),c}),this},optional(){return Oe(this,s=>s===void 0),this},nullable(){return Oe(this,s=>s===null),this},nullish(){return Oe(this,s=>s==null),this},default(s){return g(this,"_parse",(a,u,l)=>(u===void 0&&(u=typeof s=="function"?s({context:l?.context}):s),a(u,l))),this},catch(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?c:{success:true,data:typeof s=="function"?s({input:u,error:c.error}):s}}),this},pipe(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?s._parse(c.data,l):c}),this},refine(s,{message:a,type:u,jsonSchema:l}={}){if(u&&(a=a||At(u),t=u),l){let c=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>c;}return g(this,"_parse",(c,f,p)=>{let m=c(f,p),{abortEarly:E}=me(p);if(!m.success)return m;let N=s(m.data);if(N===true||typeof N=="object"&&N?.success===true)return m;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return Rt.length>0?Rt.reduce((s,a)=>a(s,e,o)??s,i):i}var Rt=[];var Ke=Ve(),qe=Ve(),jt=Ve(),Pn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ve(){return Math.floor(Math.random()*16777215)}function In(){return qe=(qe+1)%16777215,qe}function he(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=In(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Ke>>16&255,Ke>>8&255,Ke&255,jt>>8&255,jt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Pn[n.charCodeAt(o)];return r}var Ht=Symbol("block-element"),Bn=Symbol("block-element-body"),Ge=Symbol("selectable-element");function Ue(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 Dn(e){return e?Ue(e.startContainer,Ht):null}function Ft(e){return Ue(e,Ht)}function $n(e){return e?Ue(e.startContainer,Ge):null}function Kt(){return window.getSelection()}function X(){let e=Kt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function qt(){let e=X();if(!e)return 0;e.collapse(true);let t=$n(e),n=Dn(e),r=t??Ye(n);return Vt(r,e.startContainer,e.startOffset)}function Vt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,u=Math.min(n,a.length);for(let l=0;l<u;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function jn(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 i=o.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(r+s>=t)return n.setEnd(i,t-r),n.setStart(i,t-r),n;r+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)o.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function de(e,t){let n=jn(e,t),r=Kt();r.removeAllRanges(),r.addRange(n);}function Ye(e){if(!e)return null;let t=Hn(e);return t?.firstElementChild??t?.firstChild}function Hn(e){if(!e)return null;for(let t of e.children)if(t[Bn])return t;return null}var Gt={INPUT:"mrakomor:input"};var Ut=we();var ge=class extends Nt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Le(Ut),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(Gt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var We="molecule.paragraph.Paragraph";var Yt="molecule.headline.H1",Wt="molecule.headline.H2",Xt="molecule.headline.H3",zt="molecule.headline.H4",Jt="molecule.headline.H5";function M(e){return e===`
|
|
3
|
+
`||e===`\r
|
|
4
|
+
`?"":e??""}function en({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 tn(e,t){let n=M(e.properties.text),r=M(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 Qt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Zt(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 Fn(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=Qt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Zt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Qt(e.properties.entityRanges,t),r.properties.entityRanges=Zt(e.properties.entityRanges,t),r.componentId=he(),{originalLineState:n,newLineState:r}}function nn(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Fn(e.getState(),qt(e.element));return e.mrakomor.command.insertBlockElement({range:X(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}var Ee=class extends ge{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:M(this.getState()?.properties?.text).length;de(this.element,r);};n(),U(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return en({originComponent:this.NAMESPACE,properties:{...t?.properties,text:M(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return tn(t,n)}};function rn(e,{component:t,properties:n,settings:r=d.object({}).default({})}){return d.object({component:d.string().default(t),componentId:d.string().default(e?.getAttribute("data-componentid")||he()),properties:d.object(n).default({}),settings:r}).default({})}var O=class extends Ee{constructor(t){super(t),this._level=1;}static getStateSchema(t){return rn(t,{component:this.NAMESPACE,properties:{text:d.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse());return n.properties.text=M(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return le(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Ge]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return M(r)?v(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}nn(this,t,{namespace:We});}#e(t){if(!X()?.collapsed)return;let r=Ft(this.element);if(r?.previousElementSibling||M(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:We});let o=()=>{let i=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),s=Ye(i);s?.isConnected&&de(s,0);};o(),U(o);}},z=class extends O{static get NAMESPACE(){return Yt}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},J=class extends O{static get NAMESPACE(){return Wt}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},Q=class extends O{static get NAMESPACE(){return Xt}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},Z=class extends O{static get NAMESPACE(){return zt}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},ee=class extends O{static get NAMESPACE(){return Jt}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function Kn(){return {resolveConfig:e=>(e.blockComponents.push(z,J,Q,Z,ee),e),resolveComponent:e=>{if(e===z.NAMESPACE)return z;if(e===J.NAMESPACE)return J;if(e===Q.NAMESPACE)return Q;if(e===Z.NAMESPACE)return Z;if(e===ee.NAMESPACE)return ee}}}exports.HeadlineComponent=O;exports.headlinePlugin=Kn;
|
package/dist/headline.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-
|
|
1
|
+
export{a as HeadlineComponent,b as headlinePlugin}from'./chunk-UC7W4JIH.mjs';import'./chunk-G2QV4GOO.mjs';import'./chunk-GDID5DFL.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-TX4RCFPO.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';
|