@mrakomor/core 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockChrome.cjs +3 -0
- package/dist/blockChrome.mjs +2 -2
- package/dist/blockInsertMenu.cjs +1 -0
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-2VURZA2E.mjs +1 -0
- package/dist/chunk-5VPYPKGA.mjs +1 -0
- package/dist/chunk-BCE45I7Q.mjs +2 -0
- package/dist/chunk-K2DMHAUD.mjs +1 -0
- package/dist/chunk-N4I2WZWF.mjs +1 -0
- package/dist/chunk-NR2BAMSW.mjs +2 -0
- package/dist/chunk-SCFD3XBH.mjs +1 -0
- package/dist/chunk-T7OO472O.mjs +1 -0
- package/dist/{chunk-WX7ESURF.mjs → chunk-VYTSZ4S6.mjs} +1 -1
- package/dist/chunk-YO4ZA6PJ.mjs +2 -0
- package/dist/chunk-ZDMD7SRT.mjs +4 -0
- package/dist/clipboard.cjs +5 -0
- package/dist/clipboard.mjs +3 -3
- package/dist/footer.cjs +5 -0
- package/dist/footer.mjs +2 -2
- package/dist/headline.cjs +5 -0
- package/dist/headline.mjs +1 -1
- package/dist/help.cjs +2 -0
- package/dist/help.mjs +2 -2
- package/dist/index.cjs +7 -0
- package/dist/index.mjs +4 -4
- package/dist/link.cjs +3 -0
- package/dist/link.mjs +2 -2
- package/dist/list.cjs +5 -0
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +5 -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 -2
- package/dist/tts.cjs +9 -0
- package/dist/tts.mjs +3 -3
- package/package.json +67 -27
- package/dist/chunk-4NSVB4MI.mjs +0 -1
- package/dist/chunk-6XPPNCKR.mjs +0 -1
- package/dist/chunk-7UI6TZPX.mjs +0 -1
- package/dist/chunk-F67KYIDS.mjs +0 -2
- package/dist/chunk-JFLCNBDM.mjs +0 -3
- package/dist/chunk-P6HMUYFA.mjs +0 -1
- package/dist/chunk-PMR6XOZ6.mjs +0 -2
- package/dist/chunk-QWAQBTXR.mjs +0 -1
- package/dist/chunk-XQCH2FNS.mjs +0 -1
- package/dist/chunk-XVWRPXC2.mjs +0 -2
- package/dist/chunk-ZDZQ2RVJ.mjs +0 -1
package/dist/list.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.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(n);}}})();var lt=class{next(...e){}error(...e){}complete(...e){}},Ae=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 se=Symbol("@esmj/signals:type"),z=Symbol("@esmj/signals:name");var R=null,Le=false,we=[];function w(e){let t=R;R=null;let n=e();return R=t,n}function _n(){Le=false;let e=mt();for(let n of e)n.get();let t=we;we=[];for(let n of t)n();}function ut(){Le||(Le=true,queueMicrotask(_n));}function Te(e){we.push(e),ut();}var ft=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),In=class extends Ae{#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=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof ht&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{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=()=>w(()=>(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)}},ie=null;function pt(e){ie=new In(e);}pt(()=>{ut();});function mt(){return ie.getPending()}function dt(e){return ie.watch(e)}function gt(e){return ie.unwatch(e)}var L=Symbol("@esmj/signals:no error"),ht=class yt extends lt{#e=true;#r=false;#t=null;#o=this.#p();#l=null;#c=null;#i=0;#s=new Map;#n=L;constructor(t,n){super(),this.#l=t,this.#c=n,this.debug=n?.debug,this[se]="computed",this[z]=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[z],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof yt&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[ft].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=P(this.#a(),this.#c)),(this.#e||this.#n!==L)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==L)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=P(this.#a(),this.#c)),(this.#e||this.#n!==L)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#n!==L)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=L,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#l();}catch(r){this.#n=r;}return R=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=L,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===L&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=L;}};function j(e,t){return new ht(e,t)}function _(e,t){let n,{debug:r,...o}={},s=j(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),dt(s);let i=()=>{n?.(),s.destroy(),gt(s);};return i[Symbol.dispose]=i,i[se]="effect",i[z]=r??null,i.__RX_COMPUTED__=s,i}function P(e,t={}){let n=t?.equals??Object.is,r=0,o=new Ae;function s(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.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,[ft]:o,[se]:"signal",[z]:t?.debug??null};return l}function ae(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var _t=Symbol("node-component"),ce=Symbol("node-internal"),An=Symbol("keep-literal"),pe=Symbol("raw-props");function De(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function Pe(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var Ln=new Set(["template","script"]);function wn(e,t){let n=(e==null?"span":String(e)).trim(),r=n;Ln.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".`),r="span");let o=document.createElement(r);return r==="span"&&(o.style.display="contents"),o.setAttribute(t,ae()),o}function je(e,t,n){let r=wn(e,t);return n?.id&&r.setAttribute("id",n.id),r}var It=null;function $(){return It}function le(e){It=e;}function me(e){return e?.[_t]||null}function Et(e,t){e[_t]=t;}function ue(e,t={disposers:[],id:ae()}){return e?.[ce]?e[ce]:(e&&(e[ce]=t),t)}function Tn(e){return e[ce]}function M(e,t){let n=Tn(e);n||(n=ue(e)),n.disposers.push(t);}function Me(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function O(e,t){let n=$();le(e);try{return t()}finally{le(n);}}var Oe=new Map,fe=new Map,St=new Map;function At(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let s=e[o];o==="children"||n(o)?r[o]=s:s?.[An]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=j(s):r[o]=P(s);}return r}function de(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),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let a="value"in s?s.value:s.get?.call(e),c="value"in i?i.value:i.get?.call(t);return de(a,c)})}function $e(e){return {id:Symbol("context-id"),defaultValue:e}}function Fe(e){let t=$();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function F(e){Te(()=>{setTimeout(e,0);});}function Q(e){let t=e.componentId,n=Oe.get(t);if(n){Oe.delete(t);for(let r of n){let o=r();typeof o=="function"&&Me(fe,t,o);}}}function vn(e){let t=fe.get(e);if(t){fe.delete(e);for(let n of t)n();}}function Mn(e){let t=St.get(e);if(t){St.delete(e);for(let n of t)n();}}function ge(e){if(!e)return;let t=ue(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&&(vn(n.componentId),Mn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;ge(r),r=o;}}}function H(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function xt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function On(e,t,n){let r=ae(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=xt(e)?void 0:e[pe],i={...At(t??{},s),children:n},a=$(),c={disposers:[],id:r,contexts:new Map(a?.contexts)};le(c);let l;if(xt(e)){o.ClassConstructor=e;let f=new e(i);o.classInstance=f,typeof f.onMount=="function"&&Me(Oe,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Me(fe,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(i);le(a);let u=Bn(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ue(f,c),Et(f,o);else ue(u,c),u instanceof Node&&Et(u,o);return u}};return o}function He(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Q(t);});}function Bn(e){return e instanceof Node?e:H(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var bt={className:"class",htmlFor:"for"},Rt=new Set(["value","defaultValue","checked","selected","indeterminate"]),Dn=new Set(["srcdoc"]),Pn=new Set(["href","src","action","formaction","xlink:href"]),jn=new Set(["securitypolicyviolation"]),$n=new Set(["contenteditable","draggable","spellcheck"]);function J(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Lt=Symbol("Fragment");function K(e,t,n){if(e===Lt){let o=document.createDocumentFragment();return Be(o,Nt(n)),o}if(typeof e=="function")return On(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),he(r,t),Be(r,Nt(n)),r}function ve(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Fn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Hn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Dn.has(n)?true:Pn.has(n)&&t!==null&&t!==void 0&&Fn(String(t))}function wt(e){return typeof e!="string"?e:bt[e]?bt[e]:e}function Un(e,t){let n=wt(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 Ct(e,t,n){let r=Un(t,n);if(r===null){e.removeAttribute(t);return}if(Hn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function he(e,t){let n=$();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=wt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(J(o)){let s=_(()=>{O(n,()=>{ve(e,o.get());});});M(e,s);}else if(typeof o=="function"){let s=_(()=>{O(n,()=>{ve(e,o());});});M(e,s);}else ve(e,o);continue}if(r==="style"){if(J(o)){let s=_(()=>{O(n,()=>{Object.assign(e.style,o.get());});});M(e,s);}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 s=r.slice(2).toLowerCase();if(jn.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(J(o)||typeof o=="function"){let s=r,i=_(()=>{O(n,()=>{let a=typeof o=="function"?o():o.get();Rt.has(s)?e[s]=a??"":Ct(e,s,a);});});M(e,i);continue}Rt.has(r)||typeof r=="symbol"?e[r]=o??"":Ct(e,r,o);}}function Nt(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Be(e,t){for(let n of t)Tt(e,n);}function Tt(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"){kt(e,t);return}if(H(t)){He(e,t);return}if(J(t)){kt(e,()=>t.get());return}if(Array.isArray(t)){Be(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function G(e){let t=null,n=e;return H(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 ye(e,t=true){for(let n of e)t&&ge(n),n.remove();}function kt(e,t){let n=$(),r=document.createComment("");e.appendChild(r);let o=[],s=_(()=>{O(n,()=>{let i=t(),{nodes:a,instance:c}=G(i);ye(o),a.length&&r.after(...a),c&&queueMicrotask(()=>Q(c)),o=a;});});M(e,s);}var Ot=class{constructor(e){this.props=e;}};function vt(e,t,n,r){let{equals:o=de,tagName:s="span",...i}=r??{},a=je(s,"data-for",i);he(a,i);let c=$(),l=[],u=new Map,f=j(()=>e()),p=_(()=>{let d=f.get(),y=Array.isArray(d)?d:[],N=[],E=[],B=new Set;for(let g=0;g<y.length;g++){let x=y[g],k=t(x,g);if(B.has(k)){console.error(`For: duplicate key "${String(k)}" detected; ignoring later item at index ${g}`);continue}B.add(k),N.push(x),E.push(k);}let q=new Map(l.map(g=>[g.key,g])),v=[];for(let g=0;g<N.length;g++){let x=E[g],k=N[g],D=q.get(x);if(D)u.get(x).set(k),v.push(D),q.delete(x);else {let it=P(k,{equals:o});u.set(x,it);let bn={...it,set(){}},at={key:x,nodes:[]};O(c,()=>{let Rn=n(bn,g),{nodes:Cn,instance:ct}=G(Rn);at.nodes=Cn,ct&&queueMicrotask(()=>Q(ct));}),v.push(at);}}for(let[g,x]of q)ye(x.nodes),u.delete(g);let I=null;for(let g=v.length-1;g>=0;g--){let x=v[g].nodes;for(let k=x.length-1;k>=0;k--){let D=x[k];(D.parentNode!==a||D.nextSibling!==I)&&a.insertBefore(D,I),I=D;}}l=v;});return M(a,p),a}function Ue(e,t,n,r){if(typeof e=="function")return vt(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:a,children:c,...l}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=De(o),f=Pe(e??{},t);return vt(u,s,f,{...l,equals:i,tagName:a})}Ue[pe]=e=>e!=="each";function Bt(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(ge(e),e.innerHTML=""),H(t)?He(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Kn={abortEarly:true};function Ye(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 Gn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Ye(e.errors[r],n));}function jt(e,t,n,r){if(n!==false){let o=Ye(e.error,t);return {success:false,error:o,errors:[o]}}Gn(e,r,t);}function Ee(e){return e?.abortEarly!==void 0?e:Kn}function qe(e,t){S(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var Z=e=>typeof e=="string"||e instanceof String,Ke=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ge=e=>e===true||e===false,Vn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Yn=e=>typeof e=="function",Wn=e=>Array.isArray(e),Ve=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $t(e,t){let n=C(Ve,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,s])=>`${o}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:s="always"}={}){return S(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=o(l.data,{context:c?.context});if(!Ve(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(s==="missing"){let f={...l.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...l.data,...u}}}),this},S(n,"_parse",(o,s,i)=>{let a=o(s,i),{abortEarly:c}=Ee(i);if(a.success===false)return a;let l={},u=[];for(let f in e){let p=e[f]._parse(a.data[f],i);if(p.success)l[f]=p.data;else {let d=jt(p,f,c,u);if(d)return d}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function We(e){return C(Z,{...e,type:"string"})}function ze(e){return C(Ke,{...e,type:"number"})}function Xe(e){return C(Ge,{...e,type:"boolean"})}function Je(e){return C(Vn,{...e,type:"date"})}function Ft(e){return C(Yn,{...e,type:"function"})}function Ht(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,o="enum",s=C(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function Ut(e,t){let n=C(Wn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,S(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:a}=Ee(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},d=e._parse(i.data[f],p);if(d.success)c.push(d.data);else {let y=jt(d,f,a,l);if(y)return y}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function qt(){return C(()=>true)}function V(e,t){return S(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Kt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof o}" with value: ${Ve(o)?JSON.stringify(o):`"${o}"`}`,r=C(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,S(r,"_parse",(o,s,i)=>{let a=i,c=[];for(let p=0;p<e.length;p++){let d=e[p]._parse(s,a);if(d.success)return d;c.push(d);}let{abortEarly:l}=Ee(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<c.length;p++){let d=c[p].errors;if(d?.length)for(let y=0;y<d.length;y++)d[y].cause?.key&&f.push(Ye(d[y],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Gt(e,t){let n=C(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 Vt(e){let t=C(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,S(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Yt(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 Wt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return V(n=>{let r;return Z(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},Xe({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return V(n=>{if(Ge(n))return Number(n);if(Z(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},ze({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return V(n=>Ge(n)||Ke(n)&&Number.isFinite(n)?String(n):n,We({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return V(n=>{let r;return Z(n)&&(r=n.trim()),Ke(n)&&Number.isFinite(n)||r?new Date(r??n):n},Je({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return S(e,"_parse",(r,o,s)=>{if(Z(o))try{o=JSON.parse(o);}catch{let i={message:typeof n=="function"?n(o):n};return {success:false,error:i,errors:[i]}}return r(o,s)}),e}},zt={},m={object:$t,string:We,number:ze,boolean:Xe,date:Je,function:Ft,enum:Ht,array:Ut,any:qt,preprocess:V,union:Kt,literal:Gt,contextRef:Vt,withContext:Yt,coerce:zt,cast:Wt};function Dt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function S(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function C(e,{type:t="any",name:n,message:r}={}){r=r||Dt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=e(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof r=="function"?r(i):r};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return S(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return qe(this,i=>i===void 0),this},nullable(){return qe(this,i=>i===null),this},nullish(){return qe(this,i=>i==null),this},default(i){return S(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return S(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return S(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||Dt(c),t=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return S(this,"_parse",(u,f,p)=>{let d=u(f,p),{abortEarly:y}=Ee(p);if(!d.success)return d;let N=i(d.data);if(N===true||typeof N=="object"&&N?.success===true)return d;let E={message:typeof a=="function"?a(f):a};return {success:false,error:E,errors:[E]}}),this},clone(){return {...this}}};return Pt.length>0?Pt.reduce((i,a)=>a(i,e,o)??i,s):s}var Pt=[];var Qe=et(),Ze=et(),Xt=et(),zn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function et(){return Math.floor(Math.random()*16777215)}function Xn(){return Ze=(Ze+1)%16777215,Ze}function b(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Xn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Qe>>16&255,Qe>>8&255,Qe&255,Xt>>8&255,Xt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=zn[n.charCodeAt(o)];return r}var Jt=Symbol("block-element"),Jn=Symbol("block-element-body"),ee=Symbol("selectable-element");function Qt(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 Se(e){return Qt(e,Jt)}function Qn(e){return e?Qt(e.startContainer,ee):null}function Zn(e){return e?e[ee]!==void 0?[e]:[...e.children].filter(t=>t[ee]!==void 0):[]}function er(e,t){return t?Zn(e).indexOf(t):-1}function te(e,t){let n=Qn(t);return !n||!e?.contains(n)?null:{element:n,index:er(e,n)}}function Zt(){return window.getSelection()}function ne(){let e=Zt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function tt(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 tr(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 Y(e,t){let n=tr(e,t),r=Zt();r.removeAllRanges(),r.addRange(n);}function en(e){if(!e)return null;let t=nr(e);return t?.firstElementChild??t?.firstChild}function nt(e){if(!e?.[Jt])return null;let t=en(e);return t?me(t)?.classInstance:null}function nr(e){if(!e)return null;for(let t of e.children)if(t[Jn])return t;return null}var xe={INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var tn=$e();var be=class extends Ot{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Fe(tn),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return m.object({component:m.string().default(this.NAMESPACE),properties:m.object().default({}),settings:m.object().default({})}).default({})}static getPropsSchema(){return m.object({state:this.getStateSchema(),observeDOMChanges:m.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(xe.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var W="molecule.paragraph.Paragraph",Re="molecule.list.List";var nn="molecule.headline.";function h(e){return e===`
|
|
3
|
+
`||e===`\r
|
|
4
|
+
`?"":e??""}function U({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},s=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:s},...r?{settings:r}:{}}}function Ce(e){let t="",n=[],r=[];return (e??[]).forEach((o,s)=>{s>0&&(t+=`
|
|
5
|
+
`);let i=t.length;t+=h(o?.text);for(let a of o?.inlineStyleRanges??[])n.push({...a,offset:a.offset+i});for(let a of o?.entityRanges??[])r.push({...a,offset:a.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function T(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function an(e){let t=e?.component??"";return t===W||t.startsWith(nn)}function Ne(e){return Array.isArray(e?.properties?.items)}function rr(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function rn(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function or(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let a=r.find(c=>c.match(i));a&&(s=K(a,{},s));}for(let i of n){let a=o.find(c=>c.match(i));a&&(s=K(a,i,s));}return s}function cn(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=h(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let a=rr([...s,...i],o.length);for(let c=0;c<a.length-1;c+=1){let l=a[c],u=a[c+1];if(l>=u)continue;let f=o.slice(l,u),p=or(f,rn(s,l,u),rn(i,l,u),{inlineStyleComponents:t,entityRangeComponents:n});Bt(r,p);}return r}function re(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let a=r.find(l=>l.match(i));if(a){let l=i.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let c=o.find(l=>l.match(i));if(c){let l=i.textContent.length;t.properties.entityRanges.push({...c.getStateSchema(i).parse(),offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function oe(e,t){let n=h(e.properties.text),r=h(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 on(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function sn(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 ln(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=on(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=sn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=on(e.properties.entityRanges,t),r.properties.entityRanges=sn(e.properties.entityRanges,t),r.componentId=b(),{originalLineState:n,newLineState:r}}var ke=class extends be{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:h(this.getState()?.properties?.text).length;Y(this.element,r);};n(),F(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:h(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),U({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=Ce(n?.properties?.items);return oe(t,T(r))}};function un(){return m.object({length:m.number(),offset:m.number(),style:m.string()})}function fn({type:e,data:t=m.any(),length:n,offset:r}={}){let o=e!=null,s=m.object({type:o?m.string().default(e):m.string(),data:t}),i=n??(o?0:void 0),a=r??(o?0:void 0);return m.object({entity:o?s.default({}):s,length:i==null?m.number():m.number().default(i),offset:a==null?m.number():m.number().default(a)})}function mn(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function rt(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=b();return t.add(r),{...n,componentId:r}})}function dn(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function ot(e,t){return !e||!t?0:tt(e,t.startContainer,t.startOffset)}function gn(e,t){let n=T(e),{originalLineState:r,newLineState:o}=ln(n,t);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:b(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function hn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??b(),depth:o?.depth??0,text:h(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:b(),depth:0,text:h(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:Re,componentId:b(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function st(e,t,{namespace:n=W,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),a=o.slice(t+1),c=U({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),l={component:n,componentId:b(),settings:{},...r?.fromExchangeState(c)??T(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(l),a.length&&u.push({...e,componentId:i.length?b():e.componentId,properties:{...e.properties,items:a}}),{blocks:u,paragraphIndex:i.length?1:0}}function pn(e){return Ne(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function sr(e,t){let n=pn(e),r=pn(t);return n!=null&&n===r}function yn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!sr(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let p=[...e];p.splice(n,1);let d=s.length-1,y=d>=0?h(s[d]?.text).length:0;return {content:p,listIndex:t,cursor:y}}let[a,...c]=i,l=0;if(s.length===0)s.push(a,...c),l=0;else {let p=s.length-1,d=s[p],y=T(d),N=T(a),{state:E,cursor:B}=oe(y,N);s[p]={...d,text:E.properties.text,inlineStyleRanges:E.properties.inlineStyleRanges,entityRanges:E.properties.entityRanges},c.length&&s.push(...c),l=B;}let u={...r,properties:{...r.properties,items:rt(s)}},f=[...e];return f[t]=u,f.splice(n,1),{content:f,listIndex:t,cursor:l}}function En(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=n[r],s=T(o),i=Ce(U({properties:t?.properties}).properties.items),a=T(i),{state:c,cursor:l}=oe(s,a);return {state:{...e,properties:{...e.properties,items:n.map((u,f)=>f===r?{...u,text:c.properties.text,inlineStyleRanges:c.properties.inlineStyleRanges,entityRanges:c.properties.entityRanges}:u)}},cursor:l}}function Sn(e,t){return cn({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function xn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:h(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return re(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:h(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var _e=e=>m.object({componentId:m.string().default(()=>e?.getAttribute?.("data-componentid")||b()),depth:m.number().default(0),text:m.string().default(""),inlineStyleRanges:m.array(un()).default([]),entityRanges:m.array(fn()).default([])}).default({}),Ie=class e extends ke{static get NAMESPACE(){return Re}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 n=mn(t);return m.object({component:m.string().default(e.NAMESPACE),componentId:m.string().default(t?.getAttribute("data-componentid")||b()),properties:m.object({items:m.array(_e()).default([_e().parse()]).transform(rt)}).default({}),settings:m.object({style:m.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:h(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return U({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return hn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return En(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},o=dn(t);if(o.length)n.properties.items=o.map(s=>_e(s).parse(xn(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[_e().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=Se(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(n);if(r===-1)return;let o=this.mrakomor.getContent();o.splice(r,1,t),this.mrakomor.setContent(o);}_buildItemContent(t){return Sn(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",o=Ue(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>K("li",{contentEditable:true,[ee]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let a=s.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===a);return String(l>=0?l:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let a=s.get(),c=a?.text??"";return h(c)?w(()=>this._buildItemContent(a)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor(t){let n=this.getState()?.properties?.items??[],r=n.length-1;if(r<0)return;let o=typeof t=="number"?t:h(n[r]?.text).length,s=()=>{let i=this.element?.querySelector(`li[data-item-index="${r}"]`);i?.isConnected&&Y(i,o);};s(),F(s);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&Y(p,0);};f(),F(f);return}let s=Se(this.element),i=this.mrakomor._getBlockElementIndex(s),a=s?.previousElementSibling??null,c=a?this.mrakomor._getBlockElementIndex(a):-1;if(t===0&&c>=0&&i===c+1){let f=this.mrakomor.getContent(),p=yn(f,c,i);if(p){this.mrakomor._setContentState(p.content.map(d=>this.mrakomor.normalizeComponentState(d))),nt(a)?.setCursor?.(p.cursor);return}}let{blocks:l,paragraphIndex:u}=st(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(W)});this.mrakomor.command.replaceBlockElement({blockElement:Se(this.element),blocks:l,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=ne(),r=te(this.element,n);if(!r)return;let{element:o,index:s}=r,i=ot(o,n),a=this.getState(),c=[...a.properties.items??[]],l=c[s];if(!l)return;if(!h(l.text)){this.#e(s);return}let{before:u,after:f}=gn(l,i);c.splice(s,1,u,f),this._commitState({...a,properties:{...a.properties,items:c}}),F(()=>{let p=this.element?.querySelector(`li[data-item-index="${s+1}"]`);p&&Y(p,0);});}#t(t){let n=ne();if(!n?.collapsed)return;let r=te(this.element,n);if(!r){let a=n.startContainer;if(!(a===this.element||this.element?.contains?.(a)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;ot(o,n)===0&&(t.preventDefault(),this.#e(s));}};function ir(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!an({component:r})||!Ne(o))return;e.preventDefault();let i=nt(n)?.element,a=e.range??ne(),c=te(i,a);if(!c)return;let{index:l}=c,{blocks:u,paragraphIndex:f}=st(o,l,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function ar(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(xe.TRANSFORM_BLOCK_ELEMENT,ir);}}}function cr(){return ar(Ie)}exports.List=Ie;exports.listPlugin=cr;
|
package/dist/list.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{c as List,e as listPlugin}from'./chunk-BCE45I7Q.mjs';import'./chunk-2VURZA2E.mjs';import'./chunk-VYTSZ4S6.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-ZDMD7SRT.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-SCFD3XBH.mjs';import'./chunk-K2DMHAUD.mjs';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';(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(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 p{margin-top:0}
|
|
2
|
+
`,document.head.appendChild(n);}}})();var Ge=class{next(...e){}error(...e){}complete(...e){}},pe=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 X=Symbol("@esmj/signals:type"),V=Symbol("@esmj/signals:name");var S=null,me=false,he=[];function w(e){let t=S;S=null;let n=e();return S=t,n}function an(){me=false;let e=Xe();for(let n of e)n.get();let t=he;he=[];for(let n of t)n();}function Ue(){me||(me=true,queueMicrotask(an));}function de(e){he.push(e),Ue();}var Ye=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),ln=class extends pe{#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=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof Qe&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{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=()=>w(()=>(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)}},z=null;function We(e){z=new ln(e);}We(()=>{Ue();});function Xe(){return z.getPending()}function ze(e){return z.watch(e)}function Je(e){return z.unwatch(e)}var v=Symbol("@esmj/signals:no error"),Qe=class Ze extends Ge{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#l=null;#i=0;#s=new Map;#t=v;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[X]="computed",this[V]=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[V],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Ze&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[Ye].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#l)),(this.#e||this.#t!==v)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==v)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#l)),(this.#e||this.#t!==v)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==v)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=v,this.#u(),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=v,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===v&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=v;}};function P(e,t){return new Qe(e,t)}function _(e,t){let n,{debug:r,...o}={},i=P(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),ze(i);let s=()=>{n?.(),i.destroy(),Je(i);};return s[Symbol.dispose]=s,s[X]="effect",s[V]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new pe;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(c,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let c={get:i,set:a,peek:s,getRevision:l,[Ye]:o,[X]:"signal",[V]:t?.debug??null};return c}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var lt=Symbol("node-component"),Q=Symbol("node-internal"),cn=Symbol("keep-literal"),ne=Symbol("raw-props");var ct=null;function B(){return ct}function Z(e){ct=e;}function _e(e){return e?.[lt]||null}function et(e,t){e[lt]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function pn(e){return e[Q]}function M(e,t){let n=pn(e);n||(n=ee(e)),n.disposers.push(t);}function ye(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function L(e,t){let n=B();Z(e);try{return t()}finally{Z(n);}}var Ee=new Map,te=new Map,tt=new Map;function ut(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?.[cn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=P(i):r[o]=I(i);}return r}function Ne(e){return {id:Symbol("context-id"),defaultValue:e}}function Re(e){let t=B();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function ke(e){de(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ee.get(t);if(n){Ee.delete(t);for(let r of n){let o=r();typeof o=="function"&&ye(te,t,o);}}}function mn(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function hn(e){let t=tt.get(e);if(t){tt.delete(e);for(let n of t)n();}}function oe(e){if(!e)return;let t=ee(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=_e(e);if(n&&(mn(n.componentId),hn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;oe(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function nt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function dn(e,t,n){let r=J(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=nt(e)?void 0:e[ne],s={...ut(t??{},i),children:n},a=B(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(l);let c;if(nt(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&ye(Ee,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&ye(te,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(s);Z(a);let u=gn(c);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ee(f,l),et(f,o);else ee(u,l),u instanceof Node&&et(u,o);return u}};return o}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function gn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var rt={className:"class",htmlFor:"for"},ot=new Set(["value","defaultValue","checked","selected","indeterminate"]),yn=new Set(["srcdoc"]),En=new Set(["href","src","action","formaction","xlink:href"]),Sn=new Set(["securitypolicyviolation"]),bn=new Set(["contenteditable","draggable","spellcheck"]);function U(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var ft=Symbol("Fragment");function D(e,t,n){if(e===ft){let o=document.createDocumentFragment();return Se(o,it(n)),o}if(typeof e=="function")return dn(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),se(r,t),Se(r,it(n)),r}function ge(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function xn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Cn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return yn.has(n)?true:En.has(n)&&t!==null&&t!==void 0&&xn(String(t))}function pt(e){return typeof e!="string"?e:rt[e]?rt[e]:e}function _n(e,t){let n=pt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return bn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function st(e,t,n){let r=_n(t,n);if(r===null){e.removeAttribute(t);return}if(Cn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function se(e,t){let n=B();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=pt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(U(o)){let i=_(()=>{L(n,()=>{ge(e,o.get());});});M(e,i);}else if(typeof o=="function"){let i=_(()=>{L(n,()=>{ge(e,o());});});M(e,i);}else ge(e,o);continue}if(r==="style"){if(U(o)){let i=_(()=>{L(n,()=>{Object.assign(e.style,o.get());});});M(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(Sn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(U(o)||typeof o=="function"){let i=r,s=_(()=>{L(n,()=>{let a=typeof o=="function"?o():o.get();ot.has(i)?e[i]=a??"":st(e,i,a);});});M(e,s);continue}ot.has(r)||typeof r=="symbol"?e[r]=o??"":st(e,r,o);}}function it(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Se(e,t){for(let n of t)mt(e,n);}function mt(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"){at(e,t);return}if(j(t)){Ae(e,t);return}if(U(t)){at(e,()=>t.get());return}if(Array.isArray(t)){Se(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(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 ie(e,t=true){for(let n of e)t&&oe(n),n.remove();}function at(e,t){let n=B(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{L(n,()=>{let s=t(),{nodes:a,instance:l}=F(s);ie(o),a.length&&r.after(...a),l&&queueMicrotask(()=>Y(l)),o=a;});});M(e,i);}var gt=class{constructor(e){this.props=e;}};function yt(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(oe(e),e.innerHTML=""),j(t)?Ae(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var kn={abortEarly:true};function Le(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 An(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Le(e.errors[r],n));}function bt(e,t,n,r){if(n!==false){let o=Le(e.error,t);return {success:false,error:o,errors:[o]}}An(e,r,t);}function ae(e){return e?.abortEarly!==void 0?e:kn}function ve(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,we=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Te=e=>e===true||e===false,vn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),wn=e=>typeof e=="function",Tn=e=>Array.isArray(e),Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xt(e,t){let n=b(Me,{...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,l)=>{let c=s(a,l);if(!c.success)return c;let u=o(c.data,{context:l?.context});if(!Me(u)){let f={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...c.data};for(let m in u)f[m]===void 0&&(f[m]=u[m]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:l}=ae(s);if(a.success===false)return a;let c={},u=[];for(let f in e){let m=e[f]._parse(a.data[f],s);if(m.success)c[f]=m.data;else {let h=bt(m,f,l,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function Oe(e){return b(W,{...e,type:"string"})}function Ie(e){return b(we,{...e,type:"number"})}function Pe(e){return b(Te,{...e,type:"boolean"})}function Be(e){return b(vn,{...e,type:"date"})}function Ct(e){return b(wn,{...e,type:"function"})}function _t(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 Nt(e,t){let n=b(Tn,{...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}=ae(i);if(s.success===false)return s;let l=[],c=[],u=i;for(let f=0;f<s.data.length;f++){let m={...u,context:{...u?.context,index:f}},h=e._parse(s.data[f],m);if(h.success)l.push(h.data);else {let y=bt(h,f,a,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function Rt(){return b(()=>true)}function H(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function kt(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: ${Me(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,l=[];for(let m=0;m<e.length;m++){let h=e[m]._parse(i,a);if(h.success)return h;l.push(h);}let{abortEarly:c}=ae(a),u={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let m=0;m<l.length;m++){let h=l[m].errors;if(h?.length)for(let y=0;y<h.length;y++)h[y].cause?.key&&f.push(Le(h[y],`branch ${m}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function At(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 vt(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 wt(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 Tt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return H(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},Pe({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return H(n=>{if(Te(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},Ie({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return H(n=>Te(n)||we(n)&&Number.isFinite(n)?String(n):n,Oe({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return H(n=>{let r;return W(n)&&(r=n.trim()),we(n)&&Number.isFinite(n)||r?new Date(r??n):n},Be({...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}},Mt={},p={object:xt,string:Oe,number:Ie,boolean:Pe,date:Be,function:Ct,enum:_t,array:Nt,any:Rt,preprocess:H,union:kt,literal:At,contextRef:vt,withContext:wt,coerce:Mt,cast:Tt};function Et(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||Et(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 l=e(s);if(l===true)return {success:true,data:s};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,a){let l=this._parse(s,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=s(u.data)),u}),this},optional(){return ve(this,s=>s===void 0),this},nullable(){return ve(this,s=>s===null),this},nullish(){return ve(this,s=>s==null),this},default(s){return g(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof s=="function"?s({context:c?.context}):s),a(l,c))),this},catch(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof s=="function"?s({input:l,error:u.error}):s}}),this},pipe(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?s._parse(u.data,c):u}),this},refine(s,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||Et(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return g(this,"_parse",(u,f,m)=>{let h=u(f,m),{abortEarly:y}=ae(m);if(!h.success)return h;let R=s(h.data);if(R===true||typeof R=="object"&&R?.success===true)return h;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return St.length>0?St.reduce((s,a)=>a(s,e,o)??s,i):i}var St=[];var je=De(),$e=De(),Lt=De(),Mn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function De(){return Math.floor(Math.random()*16777215)}function Ln(){return $e=($e+1)%16777215,$e}function le(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Ln(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,je>>16&255,je>>8&255,je&255,Lt>>8&255,Lt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Mn[n.charCodeAt(o)];return r}var On=Symbol("block-element"),In=Symbol("block-element-body"),Fe=Symbol("selectable-element");function Ot(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 Pn(e){return e?Ot(e.startContainer,On):null}function Bn(e){return e?Ot(e.startContainer,Fe):null}function It(){return window.getSelection()}function He(){let e=It();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Pt(){let e=He();if(!e)return 0;e.collapse(true);let t=Bn(e),n=Pn(e),r=t??$t(n);return Bt(r,e.startContainer,e.startOffset)}function Bt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)s+=a[c].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 jt(e,t){let n=jn(e,t),r=It();r.removeAllRanges(),r.addRange(n);}function $t(e){if(!e)return null;let t=$n(e);return t?.firstElementChild??t?.firstChild}function $n(e){if(!e)return null;for(let t of e.children)if(t[In])return t;return null}var Dt={INPUT:"mrakomor:input"};var Ft=Ne();var ce=class extends gt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Re(Ft),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return p.object({component:p.string().default(this.NAMESPACE),properties:p.object().default({}),settings:p.object().default({})}).default({})}static getPropsSchema(){return p.object({state:this.getStateSchema(),observeDOMChanges:p.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(Dt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var Ht="molecule.paragraph.Paragraph";function N(e){return e===`
|
|
3
|
+
`||e===`\r
|
|
4
|
+
`?"":e??""}function Gt({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},i=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:i},...r?{settings:r}:{}}}function Ut(e){let t="",n=[],r=[];return (e??[]).forEach((o,i)=>{i>0&&(t+=`
|
|
5
|
+
`);let s=t.length;t+=N(o?.text);for(let a of o?.inlineStyleRanges??[])n.push({...a,offset:a.offset+s});for(let a of o?.entityRanges??[])r.push({...a,offset:a.offset+s});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function Yt(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function Dn(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function Kt(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Fn(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=e;for(let s of t){let a=r.find(l=>l.match(s));a&&(i=D(a,{},i));}for(let s of n){let a=o.find(l=>l.match(s));a&&(i=D(a,s,i));}return i}function Wt(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=N(e.properties.text),i=e.properties.inlineStyleRanges??[],s=e.properties.entityRanges??[];if(!o)return r;let a=Dn([...i,...s],o.length);for(let l=0;l<a.length-1;l+=1){let c=a[l],u=a[l+1];if(c>=u)continue;let f=o.slice(c,u),m=Fn(f,Kt(i,c,u),Kt(s,c,u),{inlineStyleComponents:t,entityRangeComponents:n});yt(r,m);}return r}function ue(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=n;for(let s of e){if(s.nodeType===Node.TEXT_NODE){i+=s.textContent.length;continue}if(s.nodeType!==Node.ELEMENT_NODE||s.nodeName==="BR")continue;let a=r.find(c=>c.match(s));if(a){let c=s.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:i,length:c}),i=ue(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(c=>c.match(s));if(l){let c=s.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(s).parse(),offset:i,length:c}),i=ue(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}i=ue(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});}return i}function Xt(e,t){let n=N(e.properties.text),r=N(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 Vt(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 Hn(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=Vt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=qt(e.properties.entityRanges,t),r.properties.entityRanges=Vt(e.properties.entityRanges,t),r.componentId=le(),{originalLineState:n,newLineState:r}}function zt(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Hn(e.getState(),Pt(e.element));return e.mrakomor.command.insertBlockElement({range:He(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Jt(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return ue(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=N(r.properties.text),r}var fe=class extends ce{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:N(this.getState()?.properties?.text).length;jt(this.element,r);};n(),ke(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:N(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),Gt({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=Ut(n?.properties?.items);return Xt(t,Yt(r))}};function Qt(){return p.object({length:p.number(),offset:p.number(),style:p.string()})}function Zt({type:e,data:t=p.any(),length:n,offset:r}={}){let o=e!=null,i=p.object({type:o?p.string().default(e):p.string(),data:t}),s=n??(o?0:void 0),a=r??(o?0:void 0);return p.object({entity:o?i.default({}):i,length:s==null?p.number():p.number().default(s),offset:a==null?p.number():p.number().default(a)})}function en(e,{component:t,properties:n,settings:r=p.object({}).default({})}){return p.object({component:p.string().default(t),componentId:p.string().default(e?.getAttribute("data-componentid")||le()),properties:p.object(n).default({}),settings:r}).default({})}var K=class e extends fe{static get NAMESPACE(){return Ht}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 en(t,{component:e.NAMESPACE,properties:{entityRanges:p.array(Zt()).default([]),inlineStyleRanges:p.array(Qt()).default([]),text:p.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Jt(this,t)}_buildContent(t){return Wt(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return D("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Fe]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return N(r)?w(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){zt(this,t);}};function Kn(){return {resolveConfig:e=>(e.blockComponents.push(K),e),resolveComponent:e=>{if(e===K.NAMESPACE)return K}}}exports.Paragraph=K;exports.paragraphPlugin=Kn;
|
package/dist/paragraph.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as Paragraph,b as paragraphPlugin}from'./chunk-
|
|
1
|
+
export{a as Paragraph,b as paragraphPlugin}from'./chunk-NR2BAMSW.mjs';import'./chunk-2VURZA2E.mjs';import'./chunk-VYTSZ4S6.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-ZDMD7SRT.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-SCFD3XBH.mjs';import'./chunk-K2DMHAUD.mjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var Ie=class{next(...e){}error(...e){}complete(...e){}},ne=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"),H=Symbol("@esmj/signals:name");var R=null,re=false,Pe=[];function M(e){let t=R;R=null;let n=e();return R=t,n}function Vt(){re=false;let e=je();for(let n of e)n.get();let t=Pe;Pe=[];for(let n of t)n();}function zt(){re||(re=true,queueMicrotask(Vt));}var $e=Symbol("@esmj/signals:internal observable"),T=Symbol("@esmj/signals:original function"),Yt=class extends ne{#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=()=>M(()=>{this.#e.add(e),this.#r();}),e.next[T]=void 0),e instanceof qe&&e.next[T]===void 0){let t=e.next.bind(e);e.next=()=>M(()=>{this.#e.add(e),t(),this.#r();}),e.next[T]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[T]){let n=t.get,r=n.bind(t);t.get=()=>M(()=>(this.#e.delete(t),r())),t.get[T]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[T]?e.next[T]:e.next,e.get=e.get[T]?e.get[T]:e.get,this.#e.delete(e),this.unsubscribe(e)}},V=null;function De(e){V=new Yt(e);}De(()=>{zt();});function je(){return V.getPending()}var w=Symbol("@esmj/signals:no error"),qe=class Ke extends Ie{#e=true;#r=false;#t=null;#o=this.#p();#s=null;#i=null;#c=0;#l=new Map;#n=w;constructor(t,n){super(),this.#s=t,this.#i=n,this.debug=n?.debug,this[U]="computed",this[H]=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.#c}getDebugInfo(){return {name:this[H],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#l.keys()]}}#f(){for(let[t,n]of this.#l)if(t instanceof Ke&&M(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[$e].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=$(this.#a(),this.#i)),(this.#e||this.#n!==w)&&(this.#l.size===0||this.#f()?this.#a():this.#e=false),R&&R.sourceRevisions.set(this,this.#c),this.#n!==w)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=$(this.#a(),this.#i)),(this.#e||this.#n!==w)&&(this.#l.size===0||this.#f()?this.#a():this.#e=false),this.#n!==w)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=w,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#s();}catch(r){this.#n=r;}return R=t,this.#l=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=w,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===w&&this.#t&&this.#t.set(n),this.#c++,n}destroy(){this.#u(),this.#l.clear(),this.#e=true,this.#n=w;}};function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new ne;function i(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(u,r)),e}function s(){return e}function l(f){if(!n(e,f)){e=f,r++,o.next();}return e}function c(){return r}let u={get:i,set:l,peek:s,getRevision:c,[$e]:o,[U]:"signal",[H]:t?.debug??null};return u}var ge=Ee(),ye=Ee(),tt=Ee(),hn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ee(){return Math.floor(Math.random()*16777215)}function mn(){return ye=(ye+1)%16777215,ye}function Q(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=mn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,ge>>16&255,ge>>8&255,ge&255,tt>>8&255,tt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=hn[n.charCodeAt(o)];return r}var gn=Symbol("block-element");var yn=Symbol("selectable-element");function nt(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 rt(e){return e?nt(e.startContainer,gn):null}function ot(e){return e?nt(e.startContainer,yn):null}function En(){return window.getSelection()}function j(){let e=En();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Se(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,l=e.childNodes,c=Math.min(n,l.length);for(let u=0;u<c;u++)s+=l[u].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}var st="molecule.paragraph.Paragraph";var it="molecule.headline.";function I(e){return e===`
|
|
2
|
+
`||e===`\r
|
|
3
|
+
`?"":e??""}function at({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},i=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:i},...r?{settings:r}:{}}}function P(e){let t=e?.component??"";return t===st||t.startsWith(it)}function ut(e,t){let n=I(e.properties.text),r=I(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 lt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function ct(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 xe(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=lt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=ct(e.properties.inlineStyleRanges,t),n.properties.entityRanges=lt(e.properties.entityRanges,t),r.properties.entityRanges=ct(e.properties.entityRanges,t),r.componentId=Q(),{originalLineState:n,newLineState:r}}var be={INPUT:"mrakomor:input"};var ft=class{#e=new Set;pipe(...e){return Sn(...e)(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);}};function Sn(...e){return t=>Array.from(e).reduce((n,r)=>r(n),t)}function pt(e){return e.map((t,n)=>({entry:t,index:n})).sort((t,n)=>{let r=t.entry.order??t.index,o=n.entry.order??n.index;return r!==o?r-o:t.index-n.index}).map(({entry:t})=>t)}var Z=class extends ft{mrakomor;#e=new Map;#r=null;#t=0;#o;constructor(t,n={}){super(),this.mrakomor=t,this.#o=n.sort??pt;}normalize(t,n){throw new Error("Register subclass must implement normalize")}#s(){this.#r=null,this.next(this.list());}#i(t,n=this.#t++){let r=this.normalize(t,n);return r?(this.#e.set(r.id,r),r):null}add(t){if(Array.isArray(t)){let r=[];for(let o of t){let i=this.#i(o,this.#t++);i&&r.push(i);}return r.length&&this.#s(),r}let n=this.#i(t);return n&&this.#s(),n}get(t){return this.#e.get(t)}has(t){return this.#e.has(t)}remove(t){let n=this.#e.delete(t);return n&&this.#s(),n}list(){return this.#r??=this.#o([...this.#e.values()]),this.#r}};var xn={abortEarly:true};function ke(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 bn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(ke(e.errors[r],n));}function mt(e,t,n,r){if(n!==false){let o=ke(e.error,t);return {success:false,error:o,errors:[o]}}bn(e,r,t);}function ee(e){return e?.abortEarly!==void 0?e:xn}function Ce(e,t){C(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var G=e=>typeof e=="string"||e instanceof String,Ne=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Re=e=>e===true||e===false,Cn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Nn=e=>typeof e=="function",Rn=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function gt(e,t){let n=_(_e,{...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 C(this,"_parse",(s,l,c)=>{let u=s(l,c);if(!u.success)return u;let f=o(u.data,{context:c?.context});if(!_e(f)){let p={message:`derive() callback must return a plain object of overrides, got ${f===null?"null":typeof f}`};return {success:false,error:p,errors:[p]}}if(i==="missing"){let p={...u.data};for(let h in f)p[h]===void 0&&(p[h]=f[h]);return {success:true,data:p}}return {success:true,data:{...u.data,...f}}}),this},C(n,"_parse",(o,i,s)=>{let l=o(i,s),{abortEarly:c}=ee(s);if(l.success===false)return l;let u={},f=[];for(let p in e){let h=e[p]._parse(l.data[p],s);if(h.success)u[p]=h.data;else {let m=mt(h,p,c,f);if(m)return m}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:u}}),r}function Ae(e){return _(G,{...e,type:"string"})}function Te(e){return _(Ne,{...e,type:"number"})}function we(e){return _(Re,{...e,type:"boolean"})}function Le(e){return _(Cn,{...e,type:"date"})}function yt(e){return _(Nn,{...e,type:"function"})}function Et(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(l=>`"${l}"`).join(" | ")}, received "${s}".`,o="enum",i=_(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function St(e,t){let n=_(Rn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,C(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:l}=ee(i);if(s.success===false)return s;let c=[],u=[],f=i;for(let p=0;p<s.data.length;p++){let h={...f,context:{...f?.context,index:p}},m=e._parse(s.data[p],h);if(m.success)c.push(m.data);else {let S=mt(m,p,l,u);if(S)return S}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),n}function xt(){return _(()=>true)}function F(e,t){return C(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function bt(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: ${_e(o)?JSON.stringify(o):`"${o}"`}`,r=_(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,C(r,"_parse",(o,i,s)=>{let l=s,c=[];for(let h=0;h<e.length;h++){let m=e[h]._parse(i,l);if(m.success)return m;c.push(m);}let{abortEarly:u}=ee(l),f={message:typeof n=="function"?n(i):n};if(u!==false)return {success:false,error:f,errors:[f]};let p=[];for(let h=0;h<c.length;h++){let m=c[h].errors;if(m?.length)for(let S=0;S<m.length;S++)m[S].cause?.key&&p.push(ke(m[S],`branch ${h}`));}return p.length===0&&p.push(f),{success:false,error:p[0],errors:p}}),r}function Ct(e,t){let n=_(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 Nt(e){let t=_(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,C(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Rt(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 _t={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 G(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},we({...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(Re(n))return Number(n);if(G(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Te({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Re(n)||Ne(n)&&Number.isFinite(n)?String(n):n,Ae({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return G(n)&&(r=n.trim()),Ne(n)&&Number.isFinite(n)||r?new Date(r??n):n},Le({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return C(e,"_parse",(r,o,i)=>{if(G(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}},kt={},E={object:gt,string:Ae,number:Te,boolean:we,date:Le,function:yt,enum:Et,array:St,any:xt,preprocess:F,union:bt,literal:Ct,contextRef:Nt,withContext:Rt,coerce:kt,cast:_t};function dt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function C(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function _(e,{type:t="any",name:n,message:r}={}){r=r||dt(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,l){let c=e(s);if(c===true)return {success:true,data:s};if(typeof c=="object"&&c?.success===true)return c;let u={message:typeof r=="function"?r(s):r};return {success:false,error:u,errors:[u]}},parse(s,l){let c=this._parse(s,l);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(s,l){return this._parse(s,l)},transform(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success&&(f.data=s(f.data)),f}),this},optional(){return Ce(this,s=>s===void 0),this},nullable(){return Ce(this,s=>s===null),this},nullish(){return Ce(this,s=>s==null),this},default(s){return C(this,"_parse",(l,c,u)=>(c===void 0&&(c=typeof s=="function"?s({context:u?.context}):s),l(c,u))),this},catch(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?f:{success:true,data:typeof s=="function"?s({input:c,error:f.error}):s}}),this},pipe(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?s._parse(f.data,u):f}),this},refine(s,{message:l,type:c,jsonSchema:u}={}){if(c&&(l=l||dt(c),t=c),u){let f=[...this._getJsonSchemaHints?.()??[],u];this._getJsonSchemaHints=()=>f;}return C(this,"_parse",(f,p,h)=>{let m=f(p,h),{abortEarly:S}=ee(h);if(!m.success)return m;let k=s(m.data);if(k===true||typeof k=="object"&&k?.success===true)return m;let N={message:typeof l=="function"?l(p):l};return {success:false,error:N,errors:[N]}}),this},clone(){return {...this}}};return ht.length>0?ht.reduce((s,l)=>l(s,e,o)??s,i):i}var ht=[];function _n(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function kn({id:e,label:t,fallback:n=0}){return e??_n(t,n)}var At=E.object({id:E.string().optional(),label:E.string().optional(),keywords:E.array(E.string()).optional(),group:E.string().optional(),order:E.number().default(({context:e})=>e?.index??0),description:E.string().optional(),handler:E.function()}).derive(e=>{let t=kn({id:e.id,label:e.label,fallback:e.order}),n=String(e.label??e.id??`Action ${e.order}`),r=e.keywords?.length?e.keywords.map(String):[n,t];return {id:t,label:n,keywords:r,group:e.group??"actions",...e.description!=null&&e.description!==""?{description:String(e.description)}:{}}});var te=class extends Z{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return At.parse(t,{context:{index:n}})}catch{return null}}};function Tt(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function An(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function wt(e){return e==null||e===""||/\s/.test(e)}function Lt(e,t){if(typeof e!="string"||t<1)return null;let n=e.slice(0,t),r=-1;for(let o=n.length-1;o>=0;o--){let i=n[o];if(i==="/"){let s=o===0?null:n[o-1];if(s===null||/\s/.test(s)){r=o;break}return null}if(!/[\w]/.test(i))return null}return r<0?null:{slashStart:r,slashEnd:t,query:n.slice(r+1)}}function vt(e,t){if(!e)return null;let n=t.inputType??"",r=t.data??null;return n==="insertText"||n==="insertCompositionText"||n==="insertReplacementText"?r==null||r===""?e:/\s/.test(r)||!/^[\w]+$/.test(r)?null:{...e,query:e.query+r,slashEnd:e.slashEnd+r.length}:n==="deleteContentBackward"||n==="deleteContentForward"||n==="deleteByCut"||n==="deleteByDrag"?e.slashEnd<=e.slashStart+1?null:{...e,query:e.query.slice(0,-1),slashEnd:e.slashEnd-1}:n==="insertFromPaste"||n==="insertFromDrop"?null:e}function ve(e){return typeof e?.handler=="function"}function Mt(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(r=>String(r.label??"").toLowerCase().includes(n)?true:(r.keywords??[]).some(i=>String(i).toLowerCase().includes(n))):e.slice()}function Bt(e,t,n,r){let{originalLineState:o}=xe(e,t),i=r&&P(r)?r:e,{newLineState:s}=xe(i,n);return {beforeState:o,afterState:s}}function Ot(e,t){let n=e._getBlockElementState(t);return n&&P(n)?n:null}function Tn(e,t=null){let n=e?.component,r=n?.NAMESPACE;if(!n||!r)return null;let o=I(t?.properties?.text??""),i=t?.properties?.inlineStyleRanges??[],s=t?.properties?.entityRanges??[],l={componentId:Q(),component:r,...e.settings?{settings:e.settings}:{}},c=at({properties:{text:o,inlineStyleRanges:i,entityRanges:s},settings:e.settings});return n.getStateSchema().parse({...n.fromExchangeState(c),...l})}function It(e,t){if(!ve(t))return;let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e;if(!s||!P(s)){t.handler(e);return}let l=Ot(n,r),{beforeState:c,afterState:u}=Bt(s,o,i,l),{state:f}=ut(c,u),p=I(c.properties?.text).length;n.command.replaceBlockElement({blockElement:r,blocks:[n.normalizeComponentState(f)],cursor:p}),t.handler(e);}function Pt(e,t){let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e,l=t?.component?.NAMESPACE;if(!l||!s||!P(s))return;let c=Ot(n,r),{beforeState:u,afterState:f}=Bt(s,o,i,c),p=I(u.properties?.text),h=I(f.properties?.text),m=!p&&!h,S=Tn(t,m?null:f);if(S){if(m){n.command.replaceBlockElement({blockElement:r,blocks:[S],cursor:0});return}n.command.insertBlockElement({blockElement:r,namespace:l,originalLineState:u,newLineState:S,cursor:0});}}function $t(e,t){return {mrakomor:e,blockElement:An(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:j()}}function Dt(){return E.object({id:E.string(),group:E.string().default("general"),description:E.string().default(""),commands:E.array(E.string()).default([]),shortcuts:E.array(E.string()).default([])}).default({})}function wn(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function jt(e){return Dt().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[wn(e)],shortcuts:[]})}var Ln={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function Ft(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(jt(n));}function vn({mrakomor:e}){e.register.slashActions=new te(e);let t=null,n=null,r=[],o=0,i=false;function s(a){return Mt([...e.register.blocks.list(),...e.register.slashActions.list()],a)}function l(){i=false,t=null,n=null,r=[],o=0,e.command.closeMenu?.();}function c(a){if(!t||!a)return;let d=$t(e,t);ve(a)?It(d,a):Pt(d,a),l();}function u(a){if(!t)return;a&&(n=a),r=s(t.query),o=0;let d=i;i=true;let g={entries:r,anchorRect:n??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c};d?e.command.updateMenu?.(g):e.command.openMenu?.(g);}function f(a,d,g,b,y){t={blockElement:a,slashStart:d,slashEnd:g,query:b,baselineState:Tt(e,a)},u(y);}function p(){let a=j();if(!a?.collapsed)return null;let d=rt(a),g=ot(a);if(!d||!g)return null;let b=g.textContent??"",y=Se(g,a.startContainer,a.startOffset);return {blockElement:d,selectable:g,text:b,cursor:y}}function h(a){let g=j()?.getBoundingClientRect?.();return (!g||g.width===0&&g.height===0)&&(g=a.getBoundingClientRect()),g}function m(a){return P(e._getBlockElementState(a))}function S(a){let d=Lt(a.text,a.cursor);if(!d){i&&l();return}f(a.blockElement,d.slashStart,d.slashEnd,d.query,h(a.selectable));}function k(){let a=p();if(!a||!m(a.blockElement)||a.cursor<1||a.text[a.cursor-1]!=="/")return false;let d=a.cursor-1,g=d===0?null:a.text[d-1];return wt(g)?(f(a.blockElement,d,d+1,"",h(a.selectable)),true):false}function N(a){let d=a.data??null,g=a.inputType??"";if(!t){if(d!=="/")return;k();return}if(g==="insertCompositionText"||g==="insertFromPaste"||g==="insertFromDrop"){let x=p();if(!x||x.blockElement!==t.blockElement){l();return}S(x);return}let b=g===""&&d!=null?{inputType:"insertText",data:d}:a,y=vt(t,b);if(!y){l();return}t=y,u();}return {resolveConfig(a){return e.register.slashActions.add(a.slashActions??[]),Ft(e),a},registerCommands(){e.register.help.add(Ln),Ft(e);},onKeyDown(a){if(i){if(a.key==="ArrowDown"){if(a.preventDefault(),!r.length)return;o=(o+1)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="ArrowUp"){if(a.preventDefault(),!r.length)return;o=(o-1+r.length)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="Enter"){a.preventDefault(),a.stopPropagation?.();let d=r[o];d&&c(d);return}a.key==="Escape"&&(a.preventDefault(),l());}},registerHandlers(){e.emitter.on(be.INPUT,N),e.emitter.on(be.CLOSE_MENU,()=>{i=false,t=null,n=null,r=[],o=0;});}}}exports.slashCommandPlugin=vn;
|
package/dist/slashCommand.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$2,b}from'./chunk-WQWE5UCN.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {
|
|
1
|
+
import {a as a$2,b}from'./chunk-WQWE5UCN.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {p,u,j as j$1,w,k as k$1}from'./chunk-ZDMD7SRT.mjs';import {a as a$1}from'./chunk-B6JJAATK.mjs';import {k,e,g,p as p$1,a as a$3}from'./chunk-SCFD3XBH.mjs';import'./chunk-K2DMHAUD.mjs';function X(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function Z({id:e,label:t,fallback:n=0}){return e??X(t,n)}var O=a.object({id:a.string().optional(),label:a.string().optional(),keywords:a.array(a.string()).optional(),group:a.string().optional(),order:a.number().default(({context:e})=>e?.index??0),description:a.string().optional(),handler:a.function()}).derive(e=>{let t=Z({id:e.id,label:e.label,fallback:e.order}),n=String(e.label??e.id??`Action ${e.order}`),l=e.keywords?.length?e.keywords.map(String):[n,t];return {id:t,label:n,keywords:l,group:e.group??"actions",...e.description!=null&&e.description!==""?{description:String(e.description)}:{}}});var A=class extends a$2{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return O.parse(t,{context:{index:n}})}catch{return null}}};function N(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function ee(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function H(e){return e==null||e===""||/\s/.test(e)}function z(e,t){if(typeof e!="string"||t<1)return null;let n=e.slice(0,t),l=-1;for(let o=n.length-1;o>=0;o--){let a=n[o];if(a==="/"){let c=o===0?null:n[o-1];if(c===null||/\s/.test(c)){l=o;break}return null}if(!/[\w]/.test(a))return null}return l<0?null:{slashStart:l,slashEnd:t,query:n.slice(l+1)}}function U(e,t){if(!e)return null;let n=t.inputType??"",l=t.data??null;return n==="insertText"||n==="insertCompositionText"||n==="insertReplacementText"?l==null||l===""?e:/\s/.test(l)||!/^[\w]+$/.test(l)?null:{...e,query:e.query+l,slashEnd:e.slashEnd+l.length}:n==="deleteContentBackward"||n==="deleteContentForward"||n==="deleteByCut"||n==="deleteByDrag"?e.slashEnd<=e.slashStart+1?null:{...e,query:e.query.slice(0,-1),slashEnd:e.slashEnd-1}:n==="insertFromPaste"||n==="insertFromDrop"?null:e}function L(e){return typeof e?.handler=="function"}function $(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(l=>String(l.label??"").toLowerCase().includes(n)?true:(l.keywords??[]).some(a=>String(a).toLowerCase().includes(n))):e.slice()}function j(e,t,n,l){let{originalLineState:o}=w(e,t),a=l&&p(l)?l:e,{newLineState:c}=w(a,n);return {beforeState:o,afterState:c}}function K(e,t){let n=e._getBlockElementState(t);return n&&p(n)?n:null}function te(e,t=null){let n=e?.component,l=n?.NAMESPACE;if(!n||!l)return null;let o=j$1(t?.properties?.text??""),a=t?.properties?.inlineStyleRanges??[],c=t?.properties?.entityRanges??[],u={componentId:a$3(),component:l,...e.settings?{settings:e.settings}:{}},p=k$1({properties:{text:o,inlineStyleRanges:a,entityRanges:c},settings:e.settings});return n.getStateSchema().parse({...n.fromExchangeState(p),...u})}function V(e,t){if(!L(t))return;let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:a,baselineState:c}=e;if(!c||!p(c)){t.handler(e);return}let u$1=K(n,l),{beforeState:p$1,afterState:d}=j(c,o,a,u$1),{state:h}=u(p$1,d),S=j$1(p$1.properties?.text).length;n.command.replaceBlockElement({blockElement:l,blocks:[n.normalizeComponentState(h)],cursor:S}),t.handler(e);}function Y(e,t){let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:a,baselineState:c}=e,u=t?.component?.NAMESPACE;if(!u||!c||!p(c))return;let p$1=K(n,l),{beforeState:d,afterState:h}=j(c,o,a,p$1),S=j$1(d.properties?.text),C=j$1(h.properties?.text),k=!S&&!C,E=te(t,k?null:h);if(E){if(k){n.command.replaceBlockElement({blockElement:l,blocks:[E],cursor:0});return}n.command.insertBlockElement({blockElement:l,namespace:u,originalLineState:d,newLineState:E,cursor:0});}}function v(e,t){return {mrakomor:e,blockElement:ee(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:k()}}function ne(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function G(e){return b().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[ne(e)],shortcuts:[]})}var re={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function J(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(G(n));}function le({mrakomor:e$1}){e$1.register.slashActions=new A(e$1);let t=null,n=null,l=[],o=0,a=false;function c(r){return $([...e$1.register.blocks.list(),...e$1.register.slashActions.list()],r)}function u(){a=false,t=null,n=null,l=[],o=0,e$1.command.closeMenu?.();}function p$2(r){if(!t||!r)return;let s=v(e$1,t);L(r)?V(s,r):Y(s,r),u();}function d(r){if(!t)return;r&&(n=r),l=c(t.query),o=0;let s=a;a=true;let i={entries:l,anchorRect:n??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$2};s?e$1.command.updateMenu?.(i):e$1.command.openMenu?.(i);}function h(r,s,i,y,g){t={blockElement:r,slashStart:s,slashEnd:i,query:y,baselineState:N(e$1,r)},d(g);}function S(){let r=k();if(!r?.collapsed)return null;let s=e(r),i=g(r);if(!s||!i)return null;let y=i.textContent??"",g$1=p$1(i,r.startContainer,r.startOffset);return {blockElement:s,selectable:i,text:y,cursor:g$1}}function C(r){let i=k()?.getBoundingClientRect?.();return (!i||i.width===0&&i.height===0)&&(i=r.getBoundingClientRect()),i}function k$1(r){return p(e$1._getBlockElementState(r))}function E(r){let s=z(r.text,r.cursor);if(!s){a&&u();return}h(r.blockElement,s.slashStart,s.slashEnd,s.query,C(r.selectable));}function Q(){let r=S();if(!r||!k$1(r.blockElement)||r.cursor<1||r.text[r.cursor-1]!=="/")return false;let s=r.cursor-1,i=s===0?null:r.text[s-1];return H(i)?(h(r.blockElement,s,s+1,"",C(r.selectable)),true):false}function W(r){let s=r.data??null,i=r.inputType??"";if(!t){if(s!=="/")return;Q();return}if(i==="insertCompositionText"||i==="insertFromPaste"||i==="insertFromDrop"){let B=S();if(!B||B.blockElement!==t.blockElement){u();return}E(B);return}let y=i===""&&s!=null?{inputType:"insertText",data:s}:r,g=U(t,y);if(!g){u();return}t=g,d();}return {resolveConfig(r){return e$1.register.slashActions.add(r.slashActions??[]),J(e$1),r},registerCommands(){e$1.register.help.add(re),J(e$1);},onKeyDown(r){if(a){if(r.key==="ArrowDown"){if(r.preventDefault(),!l.length)return;o=(o+1)%l.length,e$1.command.updateMenu?.({entries:l,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$2});return}if(r.key==="ArrowUp"){if(r.preventDefault(),!l.length)return;o=(o-1+l.length)%l.length,e$1.command.updateMenu?.({entries:l,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$2});return}if(r.key==="Enter"){r.preventDefault(),r.stopPropagation?.();let s=l[o];s&&p$2(s);return}r.key==="Escape"&&(r.preventDefault(),u());}},registerHandlers(){e$1.emitter.on(a$1.INPUT,W),e$1.emitter.on(a$1.CLOSE_MENU,()=>{a=false,t=null,n=null,l=[],o=0;});}}}export{le as slashCommandPlugin};
|
package/dist/tooltip.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/tooltip/Tooltip.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-tooltip{position:absolute;z-index:9100;display:flex;flex-direction:row;align-items:center;gap:2px;background:#1a1a1a;border-radius:6px;padding:4px 6px;box-shadow:0 3px 10px #00000040;pointer-events:all;white-space:nowrap}.mrakomor-tooltip__btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:4px;color:#fff;cursor:pointer;font-size:13px;font-weight:600;min-width:28px;min-height:28px;padding:0 6px;transition:background .1s}.mrakomor-tooltip__btn:hover{background:#ffffff26}.mrakomor-tooltip__btn--active{background:#ffffff40;color:#7dd3fc}.mrakomor-tooltip__separator{width:1px;height:18px;background:#fff3;margin:0 4px;flex-shrink:0}
|
|
2
|
+
`,document.head.appendChild(n);}}})();var Pe=class{next(...e){}error(...e){}complete(...e){}},de=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 W=Symbol("@esmj/signals:type"),G=Symbol("@esmj/signals:name");var _=null,ge=false,me=[];function j(e){let t=_;_=null;let n=e();return _=t,n}function Nt(){ge=false;let e=$e();for(let n of e)n.get();let t=me;me=[];for(let n of t)n();}function je(){ge||(ge=true,queueMicrotask(Nt));}function he(e){me.push(e),je();}var De=Symbol("@esmj/signals:internal observable"),w=Symbol("@esmj/signals:original function"),Tt=class extends de{#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[w]=void 0),e instanceof qe&&e.next[w]===void 0){let t=e.next.bind(e);e.next=()=>j(()=>{this.#e.add(e),t(),this.#o();}),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=()=>j(()=>(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)}},X=null;function Fe(e){X=new Tt(e);}Fe(()=>{je();});function $e(){return X.getPending()}function Ke(e){return X.watch(e)}function Ge(e){return X.unwatch(e)}var O=Symbol("@esmj/signals:no error"),qe=class Ve extends Pe{#e=true;#o=false;#n=null;#r=this.#p();#u=null;#c=null;#i=0;#s=new Map;#t=O;constructor(t,n){super(),this.#u=t,this.#c=n,this.debug=n?.debug,this[W]="computed",this[G]=n?.debug??null,this.get=this.get.bind(this);}#a(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[G],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Ve&&j(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[De].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=k(this.#l(),this.#c)),(this.#e||this.#t!==O)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),_&&_.sourceRevisions.set(this,this.#i),this.#t!==O)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=k(this.#l(),this.#c)),(this.#e||this.#t!==O)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),this.#t!==O)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=O,this.#a(),this.#r.sourceRevisions.clear();let t=_;_=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return _=t,this.#s=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=O,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===O&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#a(),this.#s.clear(),this.#e=true,this.#t=O;}};function A(e,t){return new qe(e,t)}function L(e,t){let n,{debug:o,...r}={},s=A(()=>{n?.(),n=e();},{equals:()=>false,...r});s.get(),Ke(s);let i=()=>{n?.(),s.destroy(),Ge(s);};return i[Symbol.dispose]=i,i[W]="effect",i[G]=o??null,i.__RX_COMPUTED__=s,i}function k(e,t={}){let n=t?.equals??Object.is,o=0,r=new de;function s(){return _&&(_.dependencies.set(r,r.subscribe(_.observer)),_.sourceRevisions.set(f,o)),e}function i(){return e}function l(d){if(!n(e,d)){e=d,o++,r.next();}return e}function c(){return o}let f={get:s,set:l,peek:i,getRevision:c,[De]:r,[W]:"signal",[G]:t?.debug??null};return f}function z(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Ze=Symbol("node-component"),J=Symbol("node-internal"),et=Symbol("keep-literal"),oe=Symbol("raw-props");function xe(e){let t=()=>e;return t[et]=true,t}function Re(e){let t=null,n=()=>t,o=s=>(t=s??null,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,l){if(Reflect.has(s,i))return Reflect.get(s,i,l);if(!t)return;let c=t[i];return typeof c=="function"?c.bind(t):c},set(s,i,l,c){return Reflect.has(s,i)||!t?Reflect.set(s,i,l,c):(t[i]=l,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var tt=null;function D(){return tt}function Q(e){tt=e;}function re(e){return e?.[Ze]||null}function He(e,t){e[Ze]=t;}function Z(e,t={disposers:[],id:z()}){return e?.[J]?e[J]:(e&&(e[J]=t),t)}function Lt(e){return e[J]}function v(e,t){let n=Lt(e);n||(n=Z(e)),n.disposers.push(t);}function ee(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function B(e,t){let n=D();Q(e);try{return t()}finally{Q(n);}}var te=new Map,ne=new Map,Ue=new Map;function nt(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?.[et]?o[r]=s():s!=null&&typeof s.get=="function"?o[r]=s:typeof s=="function"?o[r]=A(s):o[r]=k(s);}return o}function Ne(e){let t=D();if(!t){console.warn("onMount called outside of a component context");return}ee(te,t.id,e);}function ie(e){he(()=>{setTimeout(e,0);});}function $(e){let t=e.componentId,n=te.get(t);if(n){te.delete(t);for(let o of n){let r=o();typeof r=="function"&&ee(ne,t,r);}}}function At(e){let t=ne.get(e);if(t){ne.delete(e);for(let n of t)n();}}function wt(e){let t=Ue.get(e);if(t){Ue.delete(e);for(let n of t)n();}}function le(e){if(!e)return;let t=Z(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=re(e);if(n&&(At(n.componentId),wt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;le(o),o=r;}}}function P(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ye(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Ot(e,t,n){let o=z(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s=Ye(e)?void 0:e[oe],i={...nt(t??{},s),children:n},l=D(),c={disposers:[],id:o,contexts:new Map(l?.contexts)};Q(c);let f;if(Ye(e)){r.ClassConstructor=e;let E=new e(i);r.classInstance=E,typeof E.onMount=="function"&&ee(te,o,()=>{E.onMount?.();}),typeof E.onUnmount=="function"&&ee(ne,o,()=>{E.onUnmount?.();}),f=E.render();}else f=e(i);Q(l);let d=vt(f);if(r.element=d,d instanceof DocumentFragment&&d.childNodes.length)for(let E of d.childNodes)Z(E,c),He(E,r);else Z(d,c),d instanceof Node&&He(d,r);return d}};return r}function Te(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{$(t);});}function vt(e){return e instanceof Node?e:P(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var We={className:"class",htmlFor:"for"},Xe=new Set(["value","defaultValue","checked","selected","indeterminate"]),Mt=new Set(["srcdoc"]),It=new Set(["href","src","action","formaction","xlink:href"]),Bt=new Set(["securitypolicyviolation"]),Pt=new Set(["contenteditable","draggable","spellcheck"]);function V(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var ot=Symbol("Fragment");function M(e,t,n){if(e===ot){let r=document.createDocumentFragment();return Ee(r,Je(n)),r}if(typeof e=="function")return Ot(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let o=document.createElement(e);return t.id&&o.setAttribute("id",t.id),ce(o,t),Ee(o,Je(n)),o}function ye(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function jt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Dt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Mt.has(n)?true:It.has(n)&&t!==null&&t!==void 0&&jt(String(t))}function rt(e){return typeof e!="string"?e:We[e]?We[e]:e}function Ft(e,t){let n=rt(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Pt.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function ze(e,t,n){let o=Ft(t,n);if(o===null){e.removeAttribute(t);return}if(Dt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function ce(e,t){let n=D();for(let[o,r]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(o!=="id"){if(o=rt(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(V(r)){let s=L(()=>{B(n,()=>{ye(e,r.get());});});v(e,s);}else if(typeof r=="function"){let s=L(()=>{B(n,()=>{ye(e,r());});});v(e,s);}else ye(e,r);continue}if(o==="style"){if(V(r)){let s=L(()=>{B(n,()=>{Object.assign(e.style,r.get());});});v(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(Bt.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,r);continue}if(V(r)||typeof r=="function"){let s=o,i=L(()=>{B(n,()=>{let l=typeof r=="function"?r():r.get();Xe.has(s)?e[s]=l??"":ze(e,s,l);});});v(e,i);continue}Xe.has(o)||typeof o=="symbol"?e[o]=r??"":ze(e,o,r);}}function Je(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Ee(e,t){for(let n of t)st(e,n);}function st(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"){Qe(e,t);return}if(P(t)){Te(e,t);return}if(V(t)){Qe(e,()=>t.get());return}if(Array.isArray(t)){Ee(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function K(e){let t=null,n=e;return P(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 ue(e,t=true){for(let n of e)t&&le(n),n.remove();}function Qe(e,t){let n=D(),o=document.createComment("");e.appendChild(o);let r=[],s=L(()=>{B(n,()=>{let i=t(),{nodes:l,instance:c}=K(i);ue(r),l.length&&o.after(...l),c&&queueMicrotask(()=>$(c)),r=l;});});v(e,s);}function _e(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(le(e),e.innerHTML=""),P(t)?Te(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function ct(e,t){let n=null;if(P(t)?(n=t.$constructor(),queueMicrotask(()=>$(t))):t instanceof Node?n=t:n=document.createTextNode(String(t)),n instanceof HTMLElement){let o=A(()=>!!e()),r=L(()=>{n.style.display=o.get()?"":"none";});v(n,r);}return n}Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var at=Symbol("block-element"),Gt=Symbol("block-element-body"),ae=Symbol("selectable-element");function Ae(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 we(e){return e?Ae(e.startContainer,at):null}function ft(e){return e?Ae(e.startContainer,ae):null}function Oe(e){return Ae(e,ae)}function qt(e){return e?e[ae]!==void 0?[e]:[...e.children].filter(t=>t[ae]!==void 0):[]}function Vt(e,t){return t?qt(e).indexOf(t):-1}function pt(e,t){let n=ft(t);return !n||!e?.contains(n)?null:{element:n,index:Vt(e,n)}}function dt(){return window.getSelection()}function fe(){let e=dt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}var ke=null;function ve(){ke=Me();}function gt(){ke&&Ie(ke);}function Ht(e,t){let n=ft(t);return n||(U(e)??e?.childNodes?.[0]??null)}function H(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,l=e.childNodes,c=Math.min(n,l.length);for(let f=0;f<c;f++)i+=l[f].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let o=0,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=r.nextNode();for(;s;){if(s===t)return o+n;o+=s.textContent.length,s=r.nextNode();}return o}function Me(){let e=fe();if(!e)return null;let t=we(e),n=Ht(t,e);return {start:H(n,e.startContainer,e.startOffset),end:H(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function Ie(e){if(!e)return;let{start:t,end:n,element:o,selectableElement:r}=e,s=r?.isConnected&&r||U(o)||o?.childNodes?.[0];if(!s)return;let i=ut(s,t),l=ut(s,n),c=document.createRange();c.setStart(i.startContainer,i.startOffset),c.setEnd(l.endContainer,l.endOffset);let f=dt();f.removeAllRanges(),f.addRange(c);}function ut(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let o=0,r=[e];for(;r.length>0;){let s=r.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(o+i>=t)return n.setEnd(s,t-o),n.setStart(s,t-o),n;o+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)r.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function U(e){if(!e)return null;let t=Ut(e);return t?.firstElementChild??t?.firstChild}function mt(e){if(!e?.[at])return null;let t=U(e);return t?re(t)?.classInstance:null}function Ut(e){if(!e)return null;for(let t of e.children)if(t[Gt])return t;return null}function ht(e,t,n,o=12){let r=e.getBoundingClientRect(),s=typeof t?.getBoundingClientRect=="function"?t.getBoundingClientRect():t??{left:0,top:0},i=n?.offsetHeight??40;return {x:s.left-r.left,y:s.top-r.top-i-o}}function yt(e,t,n){let o=e._getBlockElementState(t);if(!o)return null;let r=e.register.blocks.getByNamespace(o.component);if(!r)return null;let s=r.toExchangeState(o)?.properties?.items??[];if(!s.length)return null;let i=U(t),l=pt(i,n),c=l?.element??i??t,f=l?.index??0,d=s[f];return d?{Constructor:r,current:o,element:c,itemIndex:f,item:d}:null}function Et(e,t){let n=H(e,t.startContainer,t.startOffset),o=H(e,t.endContainer,t.endOffset);return {offset:n,length:Math.max(0,o-n)}}function Yt(e,t,n,o){let r=e.getRoot()?.querySelector(t);if(!r)return {container:null,dispose:null};let s=document.createElement("div");s.className=n,r.append(s);let i=_e(s,o);return {container:s,dispose:i??null}}function St(e,t,n){return Yt(e,".mrakomor-tools-container",t,n)}var N={KEYDOWN:"mrakomor:keydown",CLICK:"mrakomor:click",SELECTION_CHANGE:"mrakomor:selection-change"};function bt({mrakomor:e,open:t,tooltipElement:n}){let o=k(0),r=k(0),s=k([]),i=null,l=null;function c(){t.set(false),i=null,l=null;}Ne(()=>{let d=e.emitter.on(N.OPEN_TOOLTIP,({element:p,actions:g})=>{i=p,l=Me(),s.set(g??[]),t.set(true),ie(()=>{let{x:y,y:R}=ht(e.getRoot(),p,n);o.set(y),r.set(R);});}),E=e.emitter.on(N.CLOSE_TOOLTIP,c),a=e.emitter.on(N.KEYDOWN,()=>{t.peek()===true&&c();}),S=e.emitter.on(N.CLICK,p=>{if(t.peek()!==true||!n.current||!i)return;let g=p.target;if(!(g instanceof Node)){c();return}n.current.contains(g)||i.contains(g)||g instanceof Element&&g.contains(n.current)||c();});return ()=>{d(),E(),a(),S();}});let f=A(()=>({left:`${o.get()}px`,top:`${r.get()}px`}));return ct(()=>t.get(),M("div",{className:"mrakomor-tooltip",contenteditable:false,style:f,$ref:n},()=>Wt(s.get(),e,l)))}function Wt(e,t,n){if(!e.length)return null;let o=null,r=[];for(let s of e){o!==null&&s.group!==o&&r.push(M("span",{className:"mrakomor-tooltip__separator"})),o=s.group;let i=s.label,l=typeof i=="string"?i:typeof i=="function"?M(i,{}):i;r.push(M("button",{type:"button",className:["mrakomor-tooltip__btn",s.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:s.title??"",onClick:c=>{c.preventDefault(),Ie(n),s.onAction(t);}},l));}return M("span",{style:"display: contents"},r)}function Xt({mrakomor:e}){let n=false,o=null,r=k(false),s=Re();function i(){let a=e.getConfig();return {inlineStyles:a.inlineStyles,entityRanges:a.entityRanges,blockTransforms:e.register.blocks.list()}}function l(a,S){let p=yt(e,a,S);if(!p)return null;let{element:g,item:y}=p;return y.inlineStyleRanges===void 0&&y.entityRanges===void 0?null:[{element:g,inlineStyleRanges:y.inlineStyleRanges??[],entityRanges:y.entityRanges??[]}]}function c(a,S,p,g){let y=[],R=e.getConfig()?.inlineStyles??[],C=e.getConfig()?.entityRanges??[],x=(S?.length?S:[{element:p,inlineStyleRanges:[],entityRanges:[]}]).map(u=>{let{offset:m,length:h}=Et(u.element??p,g);return {item:u,selStart:m,selEnd:m+h}});for(let u of a.inlineStyles){let m=typeof u=="string"?u:u.style,h=R.find(I=>I.style===m);if(!h)continue;let T=x.some(({item:I,selStart:pe,selEnd:Y})=>(I.inlineStyleRanges??[]).some(F=>F.style===m&&F.offset<Y&&F.offset+F.length>pe));y.push({label:h.LABEL??m,title:m.charAt(0)+m.slice(1).toLowerCase(),group:"inline",active:()=>T,onAction:I=>{ve(),I.command.insertInlineStyleRange({style:h.style}),ie(()=>{gt();});}});}for(let u of a.entityRanges){let m=typeof u=="string"?u:u.NAMESPACE,h=C.find(T=>T.NAMESPACE===m);h&&y.push({label:h.LABEL??"\u{1F517}",title:h.NAMESPACE,group:"inline",active:()=>false,onAction:T=>{ve(),T.command.insertEntityRange({namespace:h.NAMESPACE,blockElement:p});}});}return y}function f(a){return {label:a.LABEL??a.NAMESPACE,title:a.LABEL??a.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function d(a,S,p,g){let y=[],R=new Set;for(let C of a.blockTransforms){let b=typeof C=="string"?C:C?.component?.NAMESPACE??C?.NAMESPACE;if(!b||R.has(b)||(R.add(b),b===p.NAMESPACE))continue;let x=e.resolveComponentConstructor(b);x&&y.push({label:x.LABEL??b,title:`Convert to ${x.LABEL??b}`,group:"transform",active:()=>false,onAction:u=>{u.command.transformBlockElement({blockElement:S,namespace:b,range:g});}});}return y}function E(){if(n)return;let a=window.getSelection(),S=e.getRoot();if(!a||a.rangeCount===0){e.command.closeTooltip();return}let p=fe();if(!S.contains(p.commonAncestorContainer)){e.command.closeTooltip();return}if(p.startContainer===s.current&&r.peek()===true)return;let g=we(p);if(!g){e.command.closeTooltip();return}let y=mt(g),R=e._getBlockElementState(g);if(!y||!R){e.command.closeTooltip();return}let C=y.constructor;if(p.collapsed){e.command.closeTooltip();return}let b=Oe(p.startContainer),x=Oe(p.endContainer);if(!b||!x||b!==x){e.command.closeTooltip();return}let u=i(),m=l(g,p),h=[f(C),...d(u,g,C,p),...c(u,m,g,p)];if(h.length===0){e.command.closeTooltip();return}e.command.openTooltip({element:g,actions:h});}return {registerEvents(){N.OPEN_TOOLTIP="mrakomor:open-tooltip",N.CLOSE_TOOLTIP="mrakomor:close-tooltip";},registerCommands(a){a.command.openTooltip=(S,p)=>{a.emit(N.OPEN_TOOLTIP,{...S,options:p});},a.command.closeTooltip=S=>{a.emit(N.CLOSE_TOOLTIP,{options:S});};},registerListeners(){e.emitter.on(N.SELECTION_CHANGE,E),N.OPEN_DIALOG&&e.emitter.on(N.OPEN_DIALOG,()=>{n=true,r.peek()===true&&e.command.closeTooltip();}),N.CLOSE_DIALOG&&e.emitter.on(N.CLOSE_DIALOG,()=>{n=false;});},onMount(){let{dispose:a}=St(e,"mrakomor-tooltip-plugin-container",M(bt,{mrakomor:xe(e),tooltipElement:s,open:r}));o=a;},onUnmount(){o?.(),o=null;}}}exports.Tooltip=bt;exports.tooltipPlugin=Xt;
|
package/dist/tooltip.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
2
|
-
`,document.head.appendChild(i);}}})();function
|
|
1
|
+
import {a as a$1}from'./chunk-5VPYPKGA.mjs';import {o as o$1,A}from'./chunk-ZDMD7SRT.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {q,x,s,k,e as e$1,v,h,m,n as n$1}from'./chunk-SCFD3XBH.mjs';import {d,l,n,b,t,o,f,e}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/tooltip/Tooltip.css",m=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(u){return u.getAttribute("data-mrakomor-css-path")===t});if(!m){var i=document.createElement("style");i.setAttribute("data-mrakomor-css",""),i.setAttribute("data-mrakomor-css-path",t),i.textContent=`.mrakomor-tooltip{position:absolute;z-index:9100;display:flex;flex-direction:row;align-items:center;gap:2px;background:#1a1a1a;border-radius:6px;padding:4px 6px;box-shadow:0 3px 10px #00000040;pointer-events:all;white-space:nowrap}.mrakomor-tooltip__btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:4px;color:#fff;cursor:pointer;font-size:13px;font-weight:600;min-width:28px;min-height:28px;padding:0 6px;transition:background .1s}.mrakomor-tooltip__btn:hover{background:#ffffff26}.mrakomor-tooltip__btn--active{background:#ffffff40;color:#7dd3fc}.mrakomor-tooltip__separator{width:1px;height:18px;background:#fff3;margin:0 4px;flex-shrink:0}
|
|
2
|
+
`,document.head.appendChild(i);}}})();function V({mrakomor:t$1,open:m,tooltipElement:i}){let u=d(0),y=d(0),f=d([]),p=null,C=null;function E(){m.set(false),p=null,C=null;}l(()=>{let v=t$1.emitter.on(a.OPEN_TOOLTIP,({element:n$1,actions:o})=>{p=n$1,C=q(),f.set(o??[]),m.set(true),n(()=>{let{x:s,y:S}=x(t$1.getRoot(),n$1,i);u.set(s),y.set(S);});}),R=t$1.emitter.on(a.CLOSE_TOOLTIP,E),e=t$1.emitter.on(a.KEYDOWN,()=>{m.peek()===true&&E();}),r=t$1.emitter.on(a.CLICK,n=>{if(m.peek()!==true||!i.current||!p)return;let o=n.target;if(!(o instanceof Node)){E();return}i.current.contains(o)||p.contains(o)||o instanceof Element&&o.contains(i.current)||E();});return ()=>{v(),R(),e(),r();}});let _=b(()=>({left:`${u.get()}px`,top:`${y.get()}px`}));return t(()=>m.get(),o("div",{className:"mrakomor-tooltip",contenteditable:false,style:_,$ref:i},()=>J(f.get(),t$1,C)))}function J(t,m,i){if(!t.length)return null;let u=null,y=[];for(let f of t){u!==null&&f.group!==u&&y.push(o("span",{className:"mrakomor-tooltip__separator"})),u=f.group;let p=f.label,C=typeof p=="string"?p:typeof p=="function"?o(p,{}):p;y.push(o("button",{type:"button",className:["mrakomor-tooltip__btn",f.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:f.title??"",onClick:E=>{E.preventDefault(),s(i),f.onAction(m);}},C));}return o("span",{style:"display: contents"},y)}function Q({mrakomor:t}){let i=false,u=null,y=d(false),f$1=f(null);function p(){let e=t.getConfig();return {inlineStyles:e.inlineStyles,entityRanges:e.entityRanges,blockTransforms:t.register.blocks.list()}}function C(e,r){let n=o$1(t,e,r);if(!n)return null;let{element:o,item:s}=n;return s.inlineStyleRanges===void 0&&s.entityRanges===void 0?null:[{element:o,inlineStyleRanges:s.inlineStyleRanges??[],entityRanges:s.entityRanges??[]}]}function E(e,r,n$2,o){let s=[],S=t.getConfig()?.inlineStyles??[],b=t.getConfig()?.entityRanges??[],A$1=(r?.length?r:[{element:n$2,inlineStyleRanges:[],entityRanges:[]}]).map(l=>{let{offset:d,length:a}=A(l.element??n$2,o);return {item:l,selStart:d,selEnd:d+a}});for(let l of e.inlineStyles){let d=typeof l=="string"?l:l.style,a=S.find(T=>T.style===d);if(!a)continue;let L=A$1.some(({item:T,selStart:W,selEnd:X})=>(T.inlineStyleRanges??[]).some(x=>x.style===d&&x.offset<X&&x.offset+x.length>W));s.push({label:a.LABEL??d,title:d.charAt(0)+d.slice(1).toLowerCase(),group:"inline",active:()=>L,onAction:T=>{m(),T.command.insertInlineStyleRange({style:a.style}),n(()=>{n$1();});}});}for(let l of e.entityRanges){let d=typeof l=="string"?l:l.NAMESPACE,a=b.find(L=>L.NAMESPACE===d);a&&s.push({label:a.LABEL??"\u{1F517}",title:a.NAMESPACE,group:"inline",active:()=>false,onAction:L=>{m(),L.command.insertEntityRange({namespace:a.NAMESPACE,blockElement:n$2});}});}return s}function _(e){return {label:e.LABEL??e.NAMESPACE,title:e.LABEL??e.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function v$1(e,r,n,o){let s=[],S=new Set;for(let b of e.blockTransforms){let g=typeof b=="string"?b:b?.component?.NAMESPACE??b?.NAMESPACE;if(!g||S.has(g)||(S.add(g),g===n.NAMESPACE))continue;let A=t.resolveComponentConstructor(g);A&&s.push({label:A.LABEL??g,title:`Convert to ${A.LABEL??g}`,group:"transform",active:()=>false,onAction:l=>{l.command.transformBlockElement({blockElement:r,namespace:g,range:o});}});}return s}function R(){if(i)return;let e=window.getSelection(),r=t.getRoot();if(!e||e.rangeCount===0){t.command.closeTooltip();return}let n=k();if(!r.contains(n.commonAncestorContainer)){t.command.closeTooltip();return}if(n.startContainer===f$1.current&&y.peek()===true)return;let o=e$1(n);if(!o){t.command.closeTooltip();return}let s=v(o),S=t._getBlockElementState(o);if(!s||!S){t.command.closeTooltip();return}let b=s.constructor;if(n.collapsed){t.command.closeTooltip();return}let g=h(n.startContainer),A=h(n.endContainer);if(!g||!A||g!==A){t.command.closeTooltip();return}let l=p(),d=C(o,n),a=[_(b),...v$1(l,o,b,n),...E(l,d,o,n)];if(a.length===0){t.command.closeTooltip();return}t.command.openTooltip({element:o,actions:a});}return {registerEvents(){a.OPEN_TOOLTIP="mrakomor:open-tooltip",a.CLOSE_TOOLTIP="mrakomor:close-tooltip";},registerCommands(e){e.command.openTooltip=(r,n)=>{e.emit(a.OPEN_TOOLTIP,{...r,options:n});},e.command.closeTooltip=r=>{e.emit(a.CLOSE_TOOLTIP,{options:r});};},registerListeners(){t.emitter.on(a.SELECTION_CHANGE,R),a.OPEN_DIALOG&&t.emitter.on(a.OPEN_DIALOG,()=>{i=true,y.peek()===true&&t.command.closeTooltip();}),a.CLOSE_DIALOG&&t.emitter.on(a.CLOSE_DIALOG,()=>{i=false;});},onMount(){let{dispose:e$1}=a$1(t,"mrakomor-tooltip-plugin-container",o(V,{mrakomor:e(t),tooltipElement:f$1,open:y}));u=e$1;},onUnmount(){u?.(),u=null;}}}export{V as Tooltip,Q as tooltipPlugin};
|
package/dist/tts.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';var Qn={abortEarly:true};function st(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 Zn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(st(e.errors[r],n));}function Kt(e,t,n,r){if(n!==false){let o=st(e.error,t);return {success:false,error:o,errors:[o]}}Zn(e,r,t);}function be(e){return e?.abortEarly!==void 0?e:Qn}function tt(e,t){b(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var ae=e=>typeof e=="string"||e instanceof String,nt=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),rt=e=>e===true||e===false,er=e=>e instanceof Date&&!Number.isNaN(e.getTime()),tr=e=>typeof e=="function",nr=e=>Array.isArray(e),ot=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Gt(e,t){let n=R(ot,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,s])=>`${o}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:s="always"}={}){return b(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=o(l.data,{context:c?.context});if(!ot(u)){let p={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:p,errors:[p]}}if(s==="missing"){let p={...l.data};for(let m in u)p[m]===void 0&&(p[m]=u[m]);return {success:true,data:p}}return {success:true,data:{...l.data,...u}}}),this},b(n,"_parse",(o,s,i)=>{let a=o(s,i),{abortEarly:c}=be(i);if(a.success===false)return a;let l={},u=[];for(let p in e){let m=e[p]._parse(a.data[p],i);if(m.success)l[p]=m.data;else {let d=Kt(m,p,c,u);if(d)return d}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function it(e){return R(ae,{...e,type:"string"})}function at(e){return R(nt,{...e,type:"number"})}function ct(e){return R(rt,{...e,type:"boolean"})}function lt(e){return R(er,{...e,type:"date"})}function Yt(e){return R(tr,{...e,type:"function"})}function Wt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,o="enum",s=R(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function zt(e,t){let n=R(nr,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,b(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:a}=be(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let p=0;p<i.data.length;p++){let m={...u,context:{...u?.context,index:p}},d=e._parse(i.data[p],m);if(d.success)c.push(d.data);else {let S=Kt(d,p,a,l);if(S)return S}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function Xt(){return R(()=>true)}function ee(e,t){return b(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Jt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof o}" with value: ${ot(o)?JSON.stringify(o):`"${o}"`}`,r=R(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,b(r,"_parse",(o,s,i)=>{let a=i,c=[];for(let m=0;m<e.length;m++){let d=e[m]._parse(s,a);if(d.success)return d;c.push(d);}let{abortEarly:l}=be(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let p=[];for(let m=0;m<c.length;m++){let d=c[m].errors;if(d?.length)for(let S=0;S<d.length;S++)d[S].cause?.key&&p.push(st(d[S],`branch ${m}`));}return p.length===0&&p.push(u),{success:false,error:p[0],errors:p}}),r}function Qt(e,t){let n=R(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 Zt(e){let t=R(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,b(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function en(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 tn={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return ee(n=>{let r;return ae(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},ct({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return ee(n=>{if(rt(n))return Number(n);if(ae(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},at({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return ee(n=>rt(n)||nt(n)&&Number.isFinite(n)?String(n):n,it({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return ee(n=>{let r;return ae(n)&&(r=n.trim()),nt(n)&&Number.isFinite(n)||r?new Date(r??n):n},lt({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return b(e,"_parse",(r,o,s)=>{if(ae(o))try{o=JSON.parse(o);}catch{let i={message:typeof n=="function"?n(o):n};return {success:false,error:i,errors:[i]}}return r(o,s)}),e}},nn={},f={object:Gt,string:it,number:at,boolean:ct,date:lt,function:Yt,enum:Wt,array:zt,any:Xt,preprocess:ee,union:Jt,literal:Qt,contextRef:Zt,withContext:en,coerce:nn,cast:tn};function Ut(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function b(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function R(e,{type:t="any",name:n,message:r}={}){r=r||Ut(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=e(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof r=="function"?r(i):r};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return tt(this,i=>i===void 0),this},nullable(){return tt(this,i=>i===null),this},nullish(){return tt(this,i=>i==null),this},default(i){return b(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||Ut(c),t=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return b(this,"_parse",(u,p,m)=>{let d=u(p,m),{abortEarly:S}=be(m);if(!d.success)return d;let _=i(d.data);if(_===true||typeof _=="object"&&_?.success===true)return d;let x={message:typeof a=="function"?a(p):a};return {success:false,error:x,errors:[x]}}),this},clone(){return {...this}}};return qt.length>0?qt.reduce((i,a)=>a(i,e,o)??i,s):s}var qt=[];var rn=class{next(...e){}error(...e){}complete(...e){}},ut=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 Ce=Symbol("@esmj/signals:type"),ce=Symbol("@esmj/signals:name");var k=null,ft=false,pt=[];function A(e){let t=k;k=null;let n=e();return k=t,n}function sr(){ft=false;let e=cn();for(let n of e)n.get();let t=pt;pt=[];for(let n of t)n();}function on(){ft||(ft=true,queueMicrotask(sr));}function mt(e){pt.push(e),on();}var sn=Symbol("@esmj/signals:internal observable"),M=Symbol("@esmj/signals:original function"),ir=class extends ut{#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=()=>A(()=>{this.#e.add(e),this.#r();}),e.next[M]=void 0),e instanceof fn&&e.next[M]===void 0){let t=e.next.bind(e);e.next=()=>A(()=>{this.#e.add(e),t(),this.#r();}),e.next[M]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[M]){let n=t.get,r=n.bind(t);t.get=()=>A(()=>(this.#e.delete(t),r())),t.get[M]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[M]?e.next[M]:e.next,e.get=e.get[M]?e.get[M]:e.get,this.#e.delete(e),this.unsubscribe(e)}},Ae=null;function an(e){Ae=new ir(e);}an(()=>{on();});function cn(){return Ae.getPending()}function ln(e){return Ae.watch(e)}function un(e){return Ae.unwatch(e)}var w=Symbol("@esmj/signals:no error"),fn=class pn extends rn{#e=true;#r=false;#t=null;#o=this.#p();#l=null;#c=null;#i=0;#s=new Map;#n=w;constructor(t,n){super(),this.#l=t,this.#c=n,this.debug=n?.debug,this[Ce]="computed",this[ce]=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[ce],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof pn&&A(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[sn].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=Y(this.#a(),this.#c)),(this.#e||this.#n!==w)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),k&&k.sourceRevisions.set(this,this.#i),this.#n!==w)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=Y(this.#a(),this.#c)),(this.#e||this.#n!==w)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#n!==w)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=w,this.#u(),this.#o.sourceRevisions.clear();let t=k;k=this.#o;let n;try{n=this.#l();}catch(r){this.#n=r;}return k=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=w,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===w&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=w;}};function W(e,t){return new fn(e,t)}function N(e,t){let n,{debug:r,...o}={},s=W(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),ln(s);let i=()=>{n?.(),s.destroy(),un(s);};return i[Symbol.dispose]=i,i[Ce]="effect",i[ce]=r??null,i.__RX_COMPUTED__=s,i}function Y(e,t={}){let n=t?.equals??Object.is,r=0,o=new ut;function s(){return k&&(k.dependencies.set(o,o.subscribe(k.observer)),k.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,[sn]:o,[Ce]:"signal",[ce]:t?.debug??null};return l}function Re(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var bn=Symbol("node-component"),ke=Symbol("node-internal"),ar=Symbol("keep-literal"),Ie=Symbol("raw-props");function yt(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function St(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var cr=new Set(["template","script"]);function lr(e,t){let n=(e==null?"span":String(e)).trim(),r=n;cr.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".`),r="span");let o=document.createElement(r);return r==="span"&&(o.style.display="contents"),o.setAttribute(t,Re()),o}function xt(e,t,n){let r=lr(e,t);return n?.id&&r.setAttribute("id",n.id),r}function bt(e){let t=null,n=()=>t,r=s=>(t=s??null,t),o={get:n,set:r,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(o,"current",{get(){return t},set(s){r(s);},enumerable:true,configurable:false}),new Proxy(o,{get(s,i,a){if(Reflect.has(s,i))return Reflect.get(s,i,a);if(!t)return;let c=t[i];return typeof c=="function"?c.bind(t):c},set(s,i,a,c){return Reflect.has(s,i)||!t?Reflect.set(s,i,a,c):(t[i]=a,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var Cn=null;function z(){return Cn}function Ne(e){Cn=e;}function Le(e){return e?.[bn]||null}function mn(e,t){e[bn]=t;}function _e(e,t={disposers:[],id:Re()}){return e?.[ke]?e[ke]:(e&&(e[ke]=t),t)}function ur(e){return e[ke]}function j(e,t){let n=ur(e);n||(n=_e(e)),n.disposers.push(t);}function gt(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function H(e,t){let n=z();Ne(e);try{return t()}finally{Ne(n);}}var ht=new Map,ve=new Map,dn=new Map;function An(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let s=e[o];o==="children"||n(o)?r[o]=s:s?.[ar]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=W(s):r[o]=Y(s);}return r}function Me(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),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let a="value"in s?s.value:s.get?.call(e),c="value"in i?i.value:i.get?.call(t);return Me(a,c)})}function Ct(e){return {id:Symbol("context-id"),defaultValue:e}}function fe(e){let t=z();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function P(e){mt(()=>{setTimeout(e,0);});}function pe(e){let t=e.componentId,n=ht.get(t);if(n){ht.delete(t);for(let r of n){let o=r();typeof o=="function"&>(ve,t,o);}}}function fr(e){let t=ve.get(e);if(t){ve.delete(e);for(let n of t)n();}}function pr(e){let t=dn.get(e);if(t){dn.delete(e);for(let n of t)n();}}function we(e){if(!e)return;let t=_e(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=Le(e);if(n&&(fr(n.componentId),pr(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;we(r),r=o;}}}function X(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function gn(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function mr(e,t,n){let r=Re(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=gn(e)?void 0:e[Ie],i={...An(t??{},s),children:n},a=z(),c={disposers:[],id:r,contexts:new Map(a?.contexts)};Ne(c);let l;if(gn(e)){o.ClassConstructor=e;let p=new e(i);o.classInstance=p,typeof p.onMount=="function"&>(ht,r,()=>{p.onMount?.();}),typeof p.onUnmount=="function"&>(ve,r,()=>{p.onUnmount?.();}),l=p.render();}else l=e(i);Ne(a);let u=dr(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let p of u.childNodes)_e(p,c),mn(p,o);else _e(u,c),u instanceof Node&&mn(u,o);return u}};return o}function At(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{pe(t);});}function dr(e){return e instanceof Node?e:X(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var hn={className:"class",htmlFor:"for"},En=new Set(["value","defaultValue","checked","selected","indeterminate"]),gr=new Set(["srcdoc"]),hr=new Set(["href","src","action","formaction","xlink:href"]),Er=new Set(["securitypolicyviolation"]),yr=new Set(["contenteditable","draggable","spellcheck"]);function ue(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Rn=Symbol("Fragment");function E(e,t,n){if(e===Rn){let o=document.createDocumentFragment();return Et(o,Sn(n)),o}if(typeof e=="function")return mr(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),Pe(r,t),Et(r,Sn(n)),r}function dt(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Sr(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function xr(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return gr.has(n)?true:hr.has(n)&&t!==null&&t!==void 0&&Sr(String(t))}function kn(e){return typeof e!="string"?e:hn[e]?hn[e]:e}function br(e,t){let n=kn(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return yr.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function yn(e,t,n){let r=br(t,n);if(r===null){e.removeAttribute(t);return}if(xr(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function Pe(e,t){let n=z();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=kn(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(ue(o)){let s=N(()=>{H(n,()=>{dt(e,o.get());});});j(e,s);}else if(typeof o=="function"){let s=N(()=>{H(n,()=>{dt(e,o());});});j(e,s);}else dt(e,o);continue}if(r==="style"){if(ue(o)){let s=N(()=>{H(n,()=>{Object.assign(e.style,o.get());});});j(e,s);}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 s=r.slice(2).toLowerCase();if(Er.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(ue(o)||typeof o=="function"){let s=r,i=N(()=>{H(n,()=>{let a=typeof o=="function"?o():o.get();En.has(s)?e[s]=a??"":yn(e,s,a);});});j(e,i);continue}En.has(r)||typeof r=="symbol"?e[r]=o??"":yn(e,r,o);}}function Sn(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Et(e,t){for(let n of t)Nn(e,n);}function Nn(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"){xn(e,t);return}if(X(t)){At(e,t);return}if(ue(t)){xn(e,()=>t.get());return}if(Array.isArray(t)){Et(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function te(e){let t=null,n=e;return X(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 Te(e,t=true){for(let n of e)t&&we(n),n.remove();}function xn(e,t){let n=z(),r=document.createComment("");e.appendChild(r);let o=[],s=N(()=>{H(n,()=>{let i=t(),{nodes:a,instance:c}=te(i);Te(o),a.length&&r.after(...a),c&&queueMicrotask(()=>pe(c)),o=a;});});j(e,s);}var Oe=class{constructor(e){this.props=e;}};function _n(e,t,n,r){let{equals:o=Me,tagName:s="span",...i}=r??{},a=xt(s,"data-for",i);Pe(a,i);let c=z(),l=[],u=new Map,p=W(()=>e()),m=N(()=>{let d=p.get(),S=Array.isArray(d)?d:[],_=[],x=[],K=new Set;for(let h=0;h<S.length;h++){let C=S[h],v=t(C,h);if(K.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${h}`);continue}K.add(v),_.push(C),x.push(v);}let Z=new Map(l.map(h=>[h.key,h])),D=[];for(let h=0;h<_.length;h++){let C=x[h],v=_[h],G=Z.get(C);if(G)u.get(C).set(v),D.push(G),Z.delete(C);else {let $t=Y(v,{equals:o});u.set(C,$t);let zn={...$t,set(){}},Ft={key:C,nodes:[]};H(c,()=>{let Xn=n(zn,h),{nodes:Jn,instance:Vt}=te(Xn);Ft.nodes=Jn,Vt&&queueMicrotask(()=>pe(Vt));}),D.push(Ft);}}for(let[h,C]of Z)Te(C.nodes),u.delete(h);let L=null;for(let h=D.length-1;h>=0;h--){let C=D[h].nodes;for(let v=C.length-1;v>=0;v--){let G=C[v];(G.parentNode!==a||G.nextSibling!==L)&&a.insertBefore(G,L),L=G;}}l=D;});return j(a,m),a}function Rt(e,t,n,r){if(typeof e=="function")return _n(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:a,children:c,...l}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=yt(o),p=St(e??{},t);return _n(u,s,p,{...l,equals:i,tagName:a})}Rt[Ie]=e=>e!=="each";function In(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(we(e),e.innerHTML=""),X(t)?At(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var kt=_t(),Nt=_t(),Ln=_t(),Ar=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function _t(){return Math.floor(Math.random()*16777215)}function Rr(){return Nt=(Nt+1)%16777215,Nt}function y(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Rr(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,kt>>16&255,kt>>8&255,kt&255,Ln>>8&255,Ln&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Ar[n.charCodeAt(o)];return r}var vt=Symbol("block-element"),kr=Symbol("block-element-body"),T=Symbol("selectable-element");function It(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 Nr(e){return e?It(e.startContainer,vt):null}function $(e){return It(e,vt)}function Mn(e){return e?It(e.startContainer,T):null}function _r(e){return e?e[T]!==void 0?[e]:[...e.children].filter(t=>t[T]!==void 0):[]}function vr(e,t){return t?_r(e).indexOf(t):-1}function me(e,t){let n=Mn(t);return !n||!e?.contains(n)?null:{element:n,index:vr(e,n)}}function wn(){return window.getSelection()}function O(){let e=wn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Pn(){let e=O();if(!e)return 0;e.collapse(true);let t=Mn(e),n=Nr(e),r=t??de(n);return Be(r,e.startContainer,e.startOffset)}function Be(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 Ir(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 F(e,t){let n=Ir(e,t),r=wn();r.removeAllRanges(),r.addRange(n);}function de(e){if(!e)return null;let t=Lr(e);return t?.firstElementChild??t?.firstChild}function Lt(e){if(!e?.[vt])return null;let t=de(e);return t?Le(t)?.classInstance:null}function Lr(e){if(!e)return null;for(let t of e.children)if(t[kr])return t;return null}var I="molecule.paragraph.Paragraph",De="molecule.list.List";var Mt="molecule.headline.H1",wt="molecule.headline.H2",Pt="molecule.headline.H3",Tt="molecule.headline.H4",Ot="molecule.headline.H5",Tn="molecule.headline.";function g(e){return e===`
|
|
2
|
+
`||e===`\r
|
|
3
|
+
`?"":e??""}function J({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},s=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:s},...r?{settings:r}:{}}}function je(e){let t="",n=[],r=[];return (e??[]).forEach((o,s)=>{s>0&&(t+=`
|
|
4
|
+
`);let i=t.length;t+=g(o?.text);for(let a of o?.inlineStyleRanges??[])n.push({...a,offset:a.offset+i});for(let a of o?.entityRanges??[])r.push({...a,offset:a.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function B(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function jn(e){let t=e?.component??"";return t===I||t.startsWith(Tn)}function He(e){return Array.isArray(e?.properties?.items)}function Mr(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function On(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function wr(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let a=r.find(c=>c.match(i));a&&(s=E(a,{},s));}for(let i of n){let a=o.find(c=>c.match(i));a&&(s=E(a,i,s));}return s}function re(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=g(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let a=Mr([...s,...i],o.length);for(let c=0;c<a.length-1;c+=1){let l=a[c],u=a[c+1];if(l>=u)continue;let p=o.slice(l,u),m=wr(p,On(s,l,u),On(i,l,u),{inlineStyleComponents:t,entityRangeComponents:n});In(r,m);}return r}function ne(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let a=r.find(l=>l.match(i));if(a){let l=i.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:s,length:l}),s=ne(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let c=o.find(l=>l.match(i));if(c){let l=i.textContent.length;t.properties.entityRanges.push({...c.getStateSchema(i).parse(),offset:s,length:l}),s=ne(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=ne(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function ge(e,t){let n=g(e.properties.text),r=g(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 Bn(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Dn(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 Bt(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=Bn(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Dn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Bn(e.properties.entityRanges,t),r.properties.entityRanges=Dn(e.properties.entityRanges,t),r.componentId=y(),{originalLineState:n,newLineState:r}}function $e(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Bt(e.getState(),Pn(e.element));return e.mrakomor.command.insertBlockElement({range:O(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Fe(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return ne(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=g(r.properties.text),r}(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}
|
|
5
|
+
`,document.head.appendChild(n);}}})();var Ve={INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var Ue=Ct();var qe=class extends Oe{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=fe(Ue),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return f.object({component:f.string().default(this.NAMESPACE),properties:f.object().default({}),settings:f.object().default({})}).default({})}static getPropsSchema(){return f.object({state:this.getStateSchema(),observeDOMChanges:f.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(Ve.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var V=class extends qe{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:g(this.getState()?.properties?.text).length;F(this.element,r);};n(),P(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:g(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),J({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=je(n?.properties?.items);return ge(t,B(r))}};function Ke(){return f.object({length:f.number(),offset:f.number(),style:f.string()})}function Q({type:e,data:t=f.any(),length:n,offset:r}={}){let o=e!=null,s=f.object({type:o?f.string().default(e):f.string(),data:t}),i=n??(o?0:void 0),a=r??(o?0:void 0);return f.object({entity:o?s.default({}):s,length:i==null?f.number():f.number().default(i),offset:a==null?f.number():f.number().default(a)})}function oe(){return f.array(Q()).transform(e=>e.filter(t=>t.entity.type==="atom.tts.Voice")).default([])}function U(e,{component:t,properties:n,settings:r=f.object({}).default({})}){return f.object({component:f.string().default(t),componentId:f.string().default(e?.getAttribute("data-componentid")||y()),properties:f.object(n).default({}),settings:r}).default({})}var Ge=class extends V{constructor(t){super(t),this._level=1;}static getStateSchema(t){return U(t,{component:this.NAMESPACE,properties:{text:f.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=g(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[T]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?A(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}$e(this,t,{namespace:I});}#e(t){if(!O()?.collapsed)return;let r=$(this.element);if(r?.previousElementSibling||g(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:I});let o=()=>{let s=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),i=de(s);i?.isConnected&&F(i,0);};o(),P(o);}};var q=class extends Ge{static getStateSchema(t){return U(t,{component:this.NAMESPACE,properties:{text:f.string().default(t?.textContent??t?.innerText??""),entityRanges:oe()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return Fe(this,t)}_buildContent(t){return re(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}},Ye=class extends q{static get NAMESPACE(){return Mt}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},he=class extends q{static get NAMESPACE(){return wt}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},Ee=class extends q{static get NAMESPACE(){return Pt}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},ye=class extends q{static get NAMESPACE(){return Tt}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},We=class extends q{static get NAMESPACE(){return Ot}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function Pr(){return {resolveConfig:e=>(e.blockComponents.push(he,Ee,ye),e),resolveComponent:e=>{if(e===Ye.NAMESPACE)return Ye;if(e===he.NAMESPACE)return he;if(e===Ee.NAMESPACE)return Ee;if(e===ye.NAMESPACE)return ye;if(e===We.NAMESPACE)return We}}}(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.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}
|
|
6
|
+
`,document.head.appendChild(n);}}})();function ze(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function Se(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=y();return t.add(r),{...n,componentId:r}})}function $n(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function Dt(e,t){return !e||!t?0:Be(e,t.startContainer,t.startOffset)}function Fn(e,t){let n=B(e),{originalLineState:r,newLineState:o}=Bt(n,t);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:y(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function Vn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??y(),depth:o?.depth??0,text:g(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:y(),depth:0,text:g(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:De,componentId:y(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function jt(e,t,{namespace:n=I,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),a=o.slice(t+1),c=J({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),l={component:n,componentId:y(),settings:{},...r?.fromExchangeState(c)??B(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(l),a.length&&u.push({...e,componentId:i.length?y():e.componentId,properties:{...e.properties,items:a}}),{blocks:u,paragraphIndex:i.length?1:0}}function Hn(e){return He(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function Tr(e,t){let n=Hn(e),r=Hn(t);return n!=null&&n===r}function Un(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!Tr(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let m=[...e];m.splice(n,1);let d=s.length-1,S=d>=0?g(s[d]?.text).length:0;return {content:m,listIndex:t,cursor:S}}let[a,...c]=i,l=0;if(s.length===0)s.push(a,...c),l=0;else {let m=s.length-1,d=s[m],S=B(d),_=B(a),{state:x,cursor:K}=ge(S,_);s[m]={...d,text:x.properties.text,inlineStyleRanges:x.properties.inlineStyleRanges,entityRanges:x.properties.entityRanges},c.length&&s.push(...c),l=K;}let u={...r,properties:{...r.properties,items:Se(s)}},p=[...e];return p[t]=u,p.splice(n,1),{content:p,listIndex:t,cursor:l}}function qn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=n[r],s=B(o),i=je(J({properties:t?.properties}).properties.items),a=B(i),{state:c,cursor:l}=ge(s,a);return {state:{...e,properties:{...e.properties,items:n.map((u,p)=>p===r?{...u,text:c.properties.text,inlineStyleRanges:c.properties.inlineStyleRanges,entityRanges:c.properties.entityRanges}:u)}},cursor:l}}function Kn(e,t){return re({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function Gn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:g(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return ne(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:g(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Xe=e=>f.object({componentId:f.string().default(()=>e?.getAttribute?.("data-componentid")||y()),depth:f.number().default(0),text:f.string().default(""),inlineStyleRanges:f.array(Ke()).default([]),entityRanges:f.array(Q()).default([])}).default({}),Je=class e extends V{static get NAMESPACE(){return De}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 n=ze(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||y()),properties:f.object({items:f.array(Xe()).default([Xe().parse()]).transform(Se)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:g(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return J({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return Vn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return qn(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},o=$n(t);if(o.length)n.properties.items=o.map(s=>Xe(s).parse(Gn(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Xe().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=$(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(n);if(r===-1)return;let o=this.mrakomor.getContent();o.splice(r,1,t),this.mrakomor.setContent(o);}_buildItemContent(t){return Kn(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",o=Rt(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>E("li",{contentEditable:true,[T]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let a=s.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===a);return String(l>=0?l:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let a=s.get(),c=a?.text??"";return g(c)?A(()=>this._buildItemContent(a)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor(t){let n=this.getState()?.properties?.items??[],r=n.length-1;if(r<0)return;let o=typeof t=="number"?t:g(n[r]?.text).length,s=()=>{let i=this.element?.querySelector(`li[data-item-index="${r}"]`);i?.isConnected&&F(i,o);};s(),P(s);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let p=()=>{let m=this.element?.querySelector(`li[data-item-index="${t}"]`);m?.isConnected&&F(m,0);};p(),P(p);return}let s=$(this.element),i=this.mrakomor._getBlockElementIndex(s),a=s?.previousElementSibling??null,c=a?this.mrakomor._getBlockElementIndex(a):-1;if(t===0&&c>=0&&i===c+1){let p=this.mrakomor.getContent(),m=Un(p,c,i);if(m){this.mrakomor._setContentState(m.content.map(d=>this.mrakomor.normalizeComponentState(d))),Lt(a)?.setCursor?.(m.cursor);return}}let{blocks:l,paragraphIndex:u}=jt(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(I)});this.mrakomor.command.replaceBlockElement({blockElement:$(this.element),blocks:l,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=O(),r=me(this.element,n);if(!r)return;let{element:o,index:s}=r,i=Dt(o,n),a=this.getState(),c=[...a.properties.items??[]],l=c[s];if(!l)return;if(!g(l.text)){this.#e(s);return}let{before:u,after:p}=Fn(l,i);c.splice(s,1,u,p),this._commitState({...a,properties:{...a.properties,items:c}}),P(()=>{let m=this.element?.querySelector(`li[data-item-index="${s+1}"]`);m&&F(m,0);});}#t(t){let n=O();if(!n?.collapsed)return;let r=me(this.element,n);if(!r){let a=n.startContainer;if(!(a===this.element||this.element?.contains?.(a)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;Dt(o,n)===0&&(t.preventDefault(),this.#e(s));}};function Or(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!jn({component:r})||!He(o))return;e.preventDefault();let i=Lt(n)?.element,a=e.range??O(),c=me(i,a);if(!c)return;let{index:l}=c,{blocks:u,paragraphIndex:p}=jt(o,l,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:p});}function Yn(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(Ve.TRANSFORM_BLOCK_ELEMENT,Or);}}}var Wn=e=>f.object({componentId:f.string().default(()=>y()),depth:f.number().default(0),text:f.string().default(""),entityRanges:oe()}).default({}),Qe=class e extends Je{static getStateSchema(t){let n=ze(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||y()),properties:f.object({items:f.array(Wn()).default([Wn().parse()]).transform(Se)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}getInlineStyleComponents(){return []}parseFromHTML(t){return this.constructor.getStateSchema(t).parse(super.parseFromHTML(t))}};function Br(){return Yn(Qe)}(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(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 p{margin-top:0}
|
|
7
|
+
`,document.head.appendChild(n);}}})();var Ze=class e extends V{static get NAMESPACE(){return I}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 U(t,{component:e.NAMESPACE,properties:{entityRanges:f.array(Q()).default([]),inlineStyleRanges:f.array(Ke()).default([]),text:f.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Fe(this,t)}_buildContent(t){return re(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[T]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?A(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){$e(this,t);}};var se=class e extends Ze{static getStateSchema(t){return U(t,{component:e.NAMESPACE,properties:{entityRanges:oe(),text:f.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function Dr(){return {resolveConfig:e=>(e.blockComponents.push(se),e),resolveComponent:e=>{if(e===se.NAMESPACE)return se}}}var et=class extends Oe{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 f.any()}constructor(t){super(t),this.mrakomor=fe(Ue),this.element=bt();}render(){return E(this.constructor.nodeName,{},this.props.children)}};(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/tts/TtsVoice.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=`.atom-tts-voice{position:relative;border-radius:2px;display:inline-block}.atom-tts-voice:before{content:attr(data-voice-label);position:absolute;top:-1.1em;left:0;font-size:10px;line-height:1;white-space:nowrap;padding:1px 4px;border-radius:3px;pointer-events:none;font-weight:600}.tts-voice--man,.tts-voice--woman{background:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 14%,white);color:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 75%,black)}.tts-voice--man:before,.tts-voice--woman:before{background:var(--tts-voice-color, #1a73e8);color:#fff}.tts-voice-toolbar{display:flex;flex-direction:column;gap:6px}.tts-voice-toolbar__row{display:flex;align-items:center;flex-wrap:wrap;gap:4px;min-width:0}.tts-voice-toolbar__voice{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:12px;background:#fff;color:#333}.tts-voice-toolbar__voice--man,.tts-voice-toolbar__voice--woman{border-color:var(--tts-voice-color, #1a73e8);color:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 75%,black)}.tts-voice-toolbar__voice--active{font-weight:600}.tts-voice-toolbar__voice--man.tts-voice-toolbar__voice--active,.tts-voice-toolbar__voice--woman.tts-voice-toolbar__voice--active{background:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 16%,white)}.tts-voice-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.tts-voice-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.tts-voice-toolbar__btn:hover{background:#f0f0f0;color:#222}.tts-voice-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
|
|
8
|
+
`,document.head.appendChild(n);}}})();var xe=[{id:"Jarda",label:"Voice Jarda",gender:"man",color:"#1a73e8"},{id:"Pavel",label:"Voice Pavel",gender:"man",color:"#1e8e3e"},{id:"Radek",label:"Voice Radek",gender:"man",color:"#00838f"},{id:"Magda",label:"Voice Magda",gender:"woman",color:"#7b1fa2"},{id:"Marketa",label:"Voice Marketa",gender:"woman",color:"#d81b60"},{id:"Silva",label:"Voice Silva",gender:"woman",color:"#c62828"}],jr='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';function Ht(e){return xe.find(t=>t.id===e)??xe[0]}function Hr(e){let t=xe.find(o=>o.id===e);if(t)return t.color;let n=0;for(let o=0;o<e.length;o++)n=n*31+e.charCodeAt(o)|0;return `hsl(${Math.abs(n)%360}, 65%, 45%)`}var ie=class e extends et{#e;static get NAMESPACE(){return "atom.tts.Voice"}static get LABEL(){return "VOICE"}static match(t){return t?.entity?.type===e.NAMESPACE||t?.nodeName==="SPAN"&&t?.getAttribute?.("data-entity-type")===e.NAMESPACE}static getStateSchema(t){let n;if(t?.getAttribute?.("data-state"))try{n=JSON.parse(t.getAttribute("data-state"));}catch{}let r=n?.entity?.data?.voice??t?.getAttribute?.("data-voice")??"";return Q({type:e.NAMESPACE,data:f.object({voice:f.string().default(r)}).default({}),length:n?.length??0,offset:n?.offset??0}).default({})}#r({entity:t,length:n,offset:r}){let o=t.peek()?.data?.voice??"";return E("div",{className:"tts-voice-toolbar"},[E("div",{className:"tts-voice-toolbar__row"},[...xe.map(s=>E("button",{type:"button",className:`tts-voice-toolbar__voice tts-voice-toolbar__voice--${s.gender}${o===s.id?" tts-voice-toolbar__voice--active":""}`,$ref:i=>i?.style.setProperty("--tts-voice-color",s.color),title:s.label,onClick:()=>{t.set({...t.peek(),data:{voice:s.id}}),this.mrakomor.command.closeDialog();}},s.label)),E("span",{className:"tts-voice-toolbar__sep"}),E("button",{type:"button",className:"tts-voice-toolbar__btn tts-voice-toolbar__btn--danger",title:"Remove TTS voice",$dangerouslySetInnerHTML:jr,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:t.peek(),length:n.peek(),offset:r.peek()},blockElement:$(this.element)});}})])])}#t(t){this.mrakomor.command.openDialog({element:this.element,children:this.#r(t)});}onMount(){let{entity:t}=this.props;t.peek()?.data?.voice||this.#t(this.props),this.#e=N(()=>{let n=t.get()?.data?.voice??"";this.element.current?.style.setProperty("--tts-voice-color",Hr(n));});}onUnmount(){this.#e?.();}render(){let{entity:t,length:n,offset:r,children:o}=this.props;return E("span",{className:()=>{let s=t.get()?.data?.voice??"";return `atom-tts-voice tts-voice--${Ht(s||"man1").gender}`},"data-entity-type":this.constructor.NAMESPACE,"data-voice":()=>t.get()?.data?.voice??"","data-voice-label":()=>{let s=t.get()?.data?.voice??"";return s?Ht(s).label:""},$ref:this.element,onClick:s=>{s.preventDefault(),this.#t({entity:t,length:n,offset:r});},"data-state":()=>JSON.stringify({entity:t.get(),length:n.get(),offset:r.get()})},o)}};function $r(){return {resolveConfig:e=>(e.entityRanges.push(ie),e),resolveComponent:e=>{if(e===ie.NAMESPACE)return ie}}}
|
|
9
|
+
exports.TtsHeadlineComponent=q;exports.TtsList=Qe;exports.TtsParagraph=se;exports.TtsVoice=ie;exports.VOICES=xe;exports.getVoice=Ht;exports.ttsHeadlinePlugin=Pr;exports.ttsListPlugin=Br;exports.ttsParagraphPlugin=Dr;exports.ttsVoicePlugin=$r;
|