@mrakomor/core 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockChrome.mjs +1 -1
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-2VURZA2E.mjs +1 -0
- package/dist/chunk-BCE45I7Q.mjs +2 -0
- package/dist/chunk-NR2BAMSW.mjs +2 -0
- package/dist/chunk-SCFD3XBH.mjs +1 -0
- package/dist/{chunk-GDID5DFL.mjs → chunk-VYTSZ4S6.mjs} +1 -1
- package/dist/chunk-YO4ZA6PJ.mjs +2 -0
- package/dist/chunk-ZDMD7SRT.mjs +4 -0
- package/dist/clipboard.cjs +4 -4
- package/dist/clipboard.mjs +3 -3
- package/dist/footer.cjs +4 -1
- package/dist/footer.mjs +2 -2
- package/dist/headline.cjs +3 -2
- package/dist/headline.mjs +1 -1
- package/dist/index.cjs +5 -4
- package/dist/index.mjs +4 -4
- package/dist/link.cjs +3 -3
- package/dist/link.mjs +2 -2
- package/dist/list.cjs +3 -3
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +3 -2
- package/dist/paragraph.mjs +1 -1
- package/dist/slashCommand.cjs +2 -2
- package/dist/slashCommand.mjs +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.mjs +2 -2
- package/dist/tts.cjs +8 -8
- package/dist/tts.mjs +3 -3
- package/package.json +8 -9
- package/dist/chunk-G2QV4GOO.mjs +0 -1
- package/dist/chunk-Q7RMVYZR.mjs +0 -1
- package/dist/chunk-TX4RCFPO.mjs +0 -3
- package/dist/chunk-U3MSKB3R.mjs +0 -2
- package/dist/chunk-UC7W4JIH.mjs +0 -2
- package/dist/chunk-WBTDWVEC.mjs +0 -3
- package/dist/chunk-YHWQV2DB.mjs +0 -1
package/dist/paragraph.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
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,de=[];function w(e){let t=S;S=null;let n=e();return S=t,n}function on(){me=false;let e=Xe();for(let n of e)n.get();let t=de;de=[];for(let n of t)n();}function Ue(){me||(me=true,queueMicrotask(on));}function he(e){de.push(e),Ue();}var Ye=Symbol("@esmj/signals:internal observable"),k=Symbol("@esmj/signals:original function"),sn=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[k]=void 0),e instanceof Qe&&e.next[k]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{this.#e.add(e),t(),this.#r();}),e.next[k]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[k]){let n=t.get,r=n.bind(t);t.get=()=>w(()=>(this.#e.delete(t),r())),t.get[k]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[k]?e.next[k]:e.next,e.get=e.get[k]?e.get[k]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function We(e){z=new sn(e);}We(()=>{Ue();});function Xe(){return z.getPending()}function ze(e){return z.watch(e)}function Je(e){return z.unwatch(e)}var A=Symbol("@esmj/signals:no error"),Qe=class Ze extends Ge{#e=true;#r=false;#n=null;#o=this.#p();#l=null;#u=null;#i=0;#s=new Map;#t=A;constructor(t,n){super(),this.#l=t,this.#u=n,this.debug=n?.debug,this[X]="computed",this[V]=n?.debug??null,this.get=this.get.bind(this);}#c(){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.#u)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==A)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==A)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=A,this.#c(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#l();}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=A,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===A&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=A;}};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(l,r)),e}function s(){return e}function a(c){if(!n(e,c)){e=c,r++,o.next();}return e}function u(){return r}let l={get:i,set:a,peek:s,getRevision:u,[Ye]:o,[X]:"signal",[V]:t?.debug??null};return l}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var ut=Symbol("node-component"),Q=Symbol("node-internal"),an=Symbol("keep-literal"),ne=Symbol("raw-props");var lt=null;function B(){return lt}function Z(e){lt=e;}function _e(e){return e?.[ut]||null}function et(e,t){e[ut]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function cn(e){return e[Q]}function M(e,t){let n=cn(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 ct(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?.[an]?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){he(()=>{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 fn(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function pn(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&&(fn(n.componentId),pn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;oe(r),r=o;}}}function $(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function nt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function mn(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={...ct(t??{},i),children:n},a=B(),u={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(u);let l;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?.();}),l=f.render();}else l=e(s);Z(a);let c=dn(l);if(o.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)ee(f,u),et(f,o);else ee(c,u),c instanceof Node&&et(c,o);return c}};return o}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function dn(e){return e instanceof Node?e:$(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"]),hn=new Set(["srcdoc"]),gn=new Set(["href","src","action","formaction","xlink:href"]),yn=new Set(["securitypolicyviolation"]),En=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 mn(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 Sn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function bn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return hn.has(n)?true:gn.has(n)&&t!==null&&t!==void 0&&Sn(String(t))}function pt(e){return typeof e!="string"?e:rt[e]?rt[e]:e}function xn(e,t){let n=pt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return En.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=xn(t,n);if(r===null){e.removeAttribute(t);return}if(bn(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(yn.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($(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 $(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:u}=F(s);ie(o),a.length&&r.after(...a),u&&queueMicrotask(()=>Y(u)),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=""),$(t)?Ae(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Nn={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 Rn(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]}}Rn(e,r,t);}function ae(e){return e?.abortEarly!==void 0?e:Nn}function we(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,ve=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Te=e=>e===true||e===false,kn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),An=e=>typeof e=="function",wn=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,u)=>{let l=s(a,u);if(!l.success)return l;let c=o(l.data,{context:u?.context});if(!Me(c)){let f={message:`derive() callback must return a plain object of overrides, got ${c===null?"null":typeof c}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let m in c)f[m]===void 0&&(f[m]=c[m]);return {success:true,data:f}}return {success:true,data:{...l.data,...c}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:u}=ae(s);if(a.success===false)return a;let l={},c=[];for(let f in e){let m=e[f]._parse(a.data[f],s);if(m.success)l[f]=m.data;else {let d=bt(m,f,u,c);if(d)return d}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),r}function Oe(e){return b(W,{...e,type:"string"})}function Ie(e){return b(ve,{...e,type:"number"})}function Pe(e){return b(Te,{...e,type:"boolean"})}function Be(e){return b(kn,{...e,type:"date"})}function Ct(e){return b(An,{...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(wn,{...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 u=[],l=[],c=i;for(let f=0;f<s.data.length;f++){let m={...c,context:{...c?.context,index:f}},d=e._parse(s.data[f],m);if(d.success)u.push(d.data);else {let y=bt(d,f,a,l);if(y)return y}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:u}}),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,u=[];for(let m=0;m<e.length;m++){let d=e[m]._parse(i,a);if(d.success)return d;u.push(d);}let{abortEarly:l}=ae(a),c={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:c,errors:[c]};let f=[];for(let m=0;m<u.length;m++){let d=u[m].errors;if(d?.length)for(let y=0;y<d.length;y++)d[y].cause?.key&&f.push(Le(d[y],`branch ${m}`));}return f.length===0&&f.push(c),{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 wt(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 vt(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)||ve(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()),ve(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:wt,withContext:vt,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 u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let u=this._parse(s,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success&&(c.data=s(c.data)),c}),this},optional(){return we(this,s=>s===void 0),this},nullable(){return we(this,s=>s===null),this},nullish(){return we(this,s=>s==null),this},default(s){return g(this,"_parse",(a,u,l)=>(u===void 0&&(u=typeof s=="function"?s({context:l?.context}):s),a(u,l))),this},catch(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?c:{success:true,data:typeof s=="function"?s({input:u,error:c.error}):s}}),this},pipe(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?s._parse(c.data,l):c}),this},refine(s,{message:a,type:u,jsonSchema:l}={}){if(u&&(a=a||Et(u),t=u),l){let c=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>c;}return g(this,"_parse",(c,f,m)=>{let d=c(f,m),{abortEarly:y}=ae(m);if(!d.success)return d;let N=s(d.data);if(N===true||typeof N=="object"&&N?.success===true)return d;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 $e=De(),je=De(),Lt=De(),vn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function De(){return Math.floor(Math.random()*16777215)}function Tn(){return je=(je+1)%16777215,je}function ue(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Tn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,$e>>16&255,$e>>8&255,$e&255,Lt>>8&255,Lt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=vn[n.charCodeAt(o)];return r}var Mn=Symbol("block-element"),Ln=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 On(e){return e?Ot(e.startContainer,Mn):null}function In(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=In(e),n=On(e),r=t??Bn(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,u=Math.min(n,a.length);for(let l=0;l<u;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function Pn(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 $t(e,t){let n=Pn(e,t),r=It();r.removeAllRanges(),r.addRange(n);}function Bn(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[Ln])return t;return null}var jt={INPUT:"mrakomor:input"};var Dt=Ne();var le=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(Dt),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(jt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var Ft="molecule.paragraph.Paragraph";function v(e){return e===`
|
|
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
3
|
`||e===`\r
|
|
4
|
-
`?"":e??""}function
|
|
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';
|
package/dist/slashCommand.cjs
CHANGED
|
@@ -1,3 +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
|
|
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
2
|
`||e===`\r
|
|
3
|
-
`?"":e??""}function P(e){let t=e?.component??"";return t===st||t.startsWith(it)}function at(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 ut(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 be(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=ut(e.properties.inlineStyleRanges,t),n.properties.entityRanges=lt(e.properties.entityRanges,t),r.properties.entityRanges=ut(e.properties.entityRanges,t),r.componentId=Q(),{originalLineState:n,newLineState:r}}var xe={INPUT:"mrakomor:input"};var ct=class{#e=new Set;pipe(...e){return En(...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 En(...e){return t=>Array.from(e).reduce((n,r)=>r(n),t)}function ft(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 ct{mrakomor;#e=new Map;#r=null;#t=0;#o;constructor(t,n={}){super(),this.mrakomor=t,this.#o=n.sort??ft;}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 Sn={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 ht(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:Sn}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,xn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Cn=e=>typeof e=="function",Nn=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function mt(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,u)=>{let c=s(l,u);if(!c.success)return c;let f=o(c.data,{context:u?.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={...c.data};for(let h in f)p[h]===void 0&&(p[h]=f[h]);return {success:true,data:p}}return {success:true,data:{...c.data,...f}}}),this},C(n,"_parse",(o,i,s)=>{let l=o(i,s),{abortEarly:u}=ee(s);if(l.success===false)return l;let c={},f=[];for(let p in e){let h=e[p]._parse(l.data[p],s);if(h.success)c[p]=h.data;else {let m=ht(h,p,u,f);if(m)return m}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:c}}),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 _(xn,{...e,type:"date"})}function gt(e){return _(Cn,{...e,type:"function"})}function yt(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 Et(e,t){let n=_(Nn,{...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 u=[],c=[],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)u.push(m.data);else {let S=ht(m,p,l,c);if(S)return S}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function St(){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,u=[];for(let h=0;h<e.length;h++){let m=e[h]._parse(i,l);if(m.success)return m;u.push(m);}let{abortEarly:c}=ee(l),f={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:f,errors:[f]};let p=[];for(let h=0;h<u.length;h++){let m=u[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 xt(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 Ct(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 Nt(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 Rt={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}},_t={},E={object:mt,string:Ae,number:Te,boolean:we,date:Le,function:gt,enum:yt,array:Et,any:St,preprocess:F,union:bt,literal:xt,contextRef:Ct,withContext:Nt,coerce:_t,cast:Rt};function pt(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||pt(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 u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,l){let u=this._parse(s,l);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,l){return this._parse(s,l)},transform(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);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,u,c)=>(u===void 0&&(u=typeof s=="function"?s({context:c?.context}):s),l(u,c))),this},catch(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);return f.success?f:{success:true,data:typeof s=="function"?s({input:u,error:f.error}):s}}),this},pipe(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);return f.success?s._parse(f.data,c):f}),this},refine(s,{message:l,type:u,jsonSchema:c}={}){if(u&&(l=l||pt(u),t=u),c){let f=[...this._getJsonSchemaHints?.()??[],c];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 dt.length>0?dt.reduce((s,l)=>l(s,e,o)??s,i):i}var dt=[];function Rn(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function _n({id:e,label:t,fallback:n=0}){return e??Rn(t,n)}var kt=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=_n({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 kt.parse(t,{context:{index:n}})}catch{return null}}};function At(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function kn(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function Tt(e){return e==null||e===""||/\s/.test(e)}function wt(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 Lt(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 vt(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 Mt(e,t,n,r){let{originalLineState:o}=be(e,t),i=r&&P(r)?r:e,{newLineState:s}=be(i,n);return {beforeState:o,afterState:s}}function Ot(e,t){let n=e._getBlockElementState(t);return n&&P(n)?n:null}function An(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}:{}},u={properties:{text:o,inlineStyleRanges:i,entityRanges:s},...e.settings?{settings:e.settings}:{}};return n.getStateSchema().parse({...n.fromExchangeState(u),...l})}function Bt(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:u,afterState:c}=Mt(s,o,i,l),{state:f}=at(u,c),p=I(u.properties?.text).length;n.command.replaceBlockElement({blockElement:r,blocks:[n.normalizeComponentState(f)],cursor:p}),t.handler(e);}function It(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 u=Ot(n,r),{beforeState:c,afterState:f}=Mt(s,o,i,u),p=I(c.properties?.text),h=I(f.properties?.text),m=!p&&!h,S=An(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:c,newLineState:S,cursor:0});}}function Pt(e,t){return {mrakomor:e,blockElement:kn(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:j()}}function $t(){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 Tn(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function Dt(e){return $t().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[Tn(e)],shortcuts:[]})}var wn={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function jt(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(Dt(n));}function Ln({mrakomor:e}){e.register.slashActions=new te(e);let t=null,n=null,r=[],o=0,i=false;function s(a){return vt([...e.register.blocks.list(),...e.register.slashActions.list()],a)}function l(){i=false,t=null,n=null,r=[],o=0,e.command.closeMenu?.();}function u(a){if(!t||!a)return;let d=Pt(e,t);ve(a)?Bt(d,a):It(d,a),l();}function c(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:u};d?e.command.updateMenu?.(g):e.command.openMenu?.(g);}function f(a,d,g,x,y){t={blockElement:a,slashStart:d,slashEnd:g,query:x,baselineState:At(e,a)},c(y);}function p(){let a=j();if(!a?.collapsed)return null;let d=rt(a),g=ot(a);if(!d||!g)return null;let x=g.textContent??"",y=Se(g,a.startContainer,a.startOffset);return {blockElement:d,selectable:g,text:x,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=wt(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 Tt(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 b=p();if(!b||b.blockElement!==t.blockElement){l();return}S(b);return}let x=g===""&&d!=null?{inputType:"insertText",data:d}:a,y=Lt(t,x);if(!y){l();return}t=y,c();}return {resolveConfig(a){return e.register.slashActions.add(a.slashActions??[]),jt(e),a},registerCommands(){e.register.help.add(wn),jt(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:u});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:u});return}if(a.key==="Enter"){a.preventDefault(),a.stopPropagation?.();let d=r[o];d&&u(d);return}a.key==="Escape"&&(a.preventDefault(),l());}},registerHandlers(){e.emitter.on(xe.INPUT,N),e.emitter.on(xe.CLOSE_MENU,()=>{i=false,t=null,n=null,r=[],o=0;});}}}exports.slashCommandPlugin=Ln;
|
|
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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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){}},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"),H=Symbol("@esmj/signals:name");var T=null,de=false,ge=[];function K(e){let t=T;T=null;let n=e();return T=t,n}function xt(){de=false;let e=$e();for(let n of e)n.get();let t=ge;ge=[];for(let n of t)n();}function je(){de||(de=true,queueMicrotask(xt));}function me(e){ge.push(e),je();}var De=Symbol("@esmj/signals:internal observable"),I=Symbol("@esmj/signals:original function"),Ct=class extends pe{#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=()=>K(()=>{this.#e.add(e),this.#o();}),e.next[I]=void 0),e instanceof qe&&e.next[I]===void 0){let t=e.next.bind(e);e.next=()=>K(()=>{this.#e.add(e),t(),this.#o();}),e.next[I]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[I]){let n=t.get,o=n.bind(t);t.get=()=>K(()=>(this.#e.delete(t),o())),t.get[I]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[I]?e.next[I]:e.next,e.get=e.get[I]?e.get[I]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function Fe(e){z=new Ct(e);}Fe(()=>{je();});function $e(){return z.getPending()}function Ke(e){return z.watch(e)}function Ge(e){return z.unwatch(e)}var B=Symbol("@esmj/signals:no error"),qe=class Ve extends Pe{#e=true;#o=false;#n=null;#r=this.#p();#u=null;#c=null;#s=0;#i=new Map;#t=B;constructor(t,n){super(),this.#u=t,this.#c=n,this.debug=n?.debug,this[X]="computed",this[H]=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.#s}getDebugInfo(){return {name:this[H],dirty:this.#e,revision:this.#s,sourceDependencies:[...this.#i.keys()]}}#f(){for(let[t,n]of this.#i)if(t instanceof Ve&&K(()=>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=_(this.#l(),this.#c)),(this.#e||this.#t!==B)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),T&&T.sourceRevisions.set(this,this.#s),this.#t!==B)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=_(this.#l(),this.#c)),(this.#e||this.#t!==B)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),this.#t!==B)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=B,this.#a(),this.#r.sourceRevisions.clear();let t=T;T=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return T=t,this.#i=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=B,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===B&&this.#n&&this.#n.set(n),this.#s++,n}destroy(){this.#a(),this.#i.clear(),this.#e=true,this.#t=B;}};function O(e,t){return new qe(e,t)}function w(e,t){let n,{debug:o,...r}={},i=O(()=>{n?.(),n=e();},{equals:()=>false,...r});i.get(),Ke(i);let s=()=>{n?.(),i.destroy(),Ge(i);};return s[Symbol.dispose]=s,s[X]="effect",s[H]=o??null,s.__RX_COMPUTED__=i,s}function _(e,t={}){let n=t?.equals??Object.is,o=0,r=new pe;function i(){return T&&(T.dependencies.set(r,r.subscribe(T.observer)),T.sourceRevisions.set(a,o)),e}function s(){return e}function l(p){if(!n(e,p)){e=p,o++,r.next();}return e}function u(){return o}let a={get:i,set:l,peek:s,getRevision:u,[De]:r,[X]:"signal",[H]:t?.debug??null};return a}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Ze=Symbol("node-component"),Q=Symbol("node-internal"),et=Symbol("keep-literal"),re=Symbol("raw-props");function be(e){let t=()=>e;return t[et]=true,t}function Ce(e){let t=null,n=()=>t,o=i=>(t=i??null,t),r={get:n,set:o,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(r,"current",{get(){return t},set(i){o(i);},enumerable:true,configurable:false}),new Proxy(r,{get(i,s,l){if(Reflect.has(i,s))return Reflect.get(i,s,l);if(!t)return;let u=t[s];return typeof u=="function"?u.bind(t):u},set(i,s,l,u){return Reflect.has(i,s)||!t?Reflect.set(i,s,l,u):(t[s]=l,true)},has(i,s){return Reflect.has(i,s)||!!t&&s in t}})}var tt=null;function G(){return tt}function Z(e){tt=e;}function ie(e){return e?.[Ze]||null}function He(e,t){e[Ze]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function Tt(e){return e[Q]}function P(e,t){let n=Tt(e);n||(n=ee(e)),n.disposers.push(t);}function te(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function D(e,t){let n=G();Z(e);try{return t()}finally{Z(n);}}var ne=new Map,oe=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 i=e[r];r==="children"||n(r)?o[r]=i:i?.[et]?o[r]=i():i!=null&&typeof i.get=="function"?o[r]=i:typeof i=="function"?o[r]=O(i):o[r]=_(i);}return o}function Re(e){let t=G();if(!t){console.warn("onMount called outside of a component context");return}te(ne,t.id,e);}function le(e){me(()=>{setTimeout(e,0);});}function q(e){let t=e.componentId,n=ne.get(t);if(n){ne.delete(t);for(let o of n){let r=o();typeof r=="function"&&te(oe,t,r);}}}function _t(e){let t=oe.get(e);if(t){oe.delete(e);for(let n of t)n();}}function Lt(e){let t=Ue.get(e);if(t){Ue.delete(e);for(let n of t)n();}}function ce(e){if(!e)return;let t=ee(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=ie(e);if(n&&(_t(n.componentId),Lt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;ce(o),o=r;}}}function F(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ye(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function wt(e,t,n){let o=J(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let i=Ye(e)?void 0:e[re],s={...nt(t??{},i),children:n},l=G(),u={disposers:[],id:o,contexts:new Map(l?.contexts)};Z(u);let a;if(Ye(e)){r.ClassConstructor=e;let c=new e(s);r.classInstance=c,typeof c.onMount=="function"&&te(ne,o,()=>{c.onMount?.();}),typeof c.onUnmount=="function"&&te(oe,o,()=>{c.onUnmount?.();}),a=c.render();}else a=e(s);Z(l);let p=kt(a);if(r.element=p,p instanceof DocumentFragment&&p.childNodes.length)for(let c of p.childNodes)ee(c,u),He(c,r);else ee(p,u),p instanceof Node&&He(p,r);return p}};return r}function Ne(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{q(t);});}function kt(e){return e instanceof Node?e:F(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"]),At=new Set(["srcdoc"]),Ot=new Set(["href","src","action","formaction","xlink:href"]),vt=new Set(["securitypolicyviolation"]),Mt=new Set(["contenteditable","draggable","spellcheck"]);function Y(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var ot=Symbol("Fragment");function j(e,t,n){if(e===ot){let r=document.createDocumentFragment();return ye(r,Je(n)),r}if(typeof e=="function")return wt(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),ue(o,t),ye(o,Je(n)),o}function he(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function It(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Bt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return At.has(n)?true:Ot.has(n)&&t!==null&&t!==void 0&&It(String(t))}function rt(e){return typeof e!="string"?e:We[e]?We[e]:e}function Pt(e,t){let n=rt(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Mt.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=Pt(t,n);if(o===null){e.removeAttribute(t);return}if(Bt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function ue(e,t){let n=G();for(let[o,r]of Reflect.ownKeys(t).map(i=>[i,t[i]]))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(Y(r)){let i=w(()=>{D(n,()=>{he(e,r.get());});});P(e,i);}else if(typeof r=="function"){let i=w(()=>{D(n,()=>{he(e,r());});});P(e,i);}else he(e,r);continue}if(o==="style"){if(Y(r)){let i=w(()=>{D(n,()=>{Object.assign(e.style,r.get());});});P(e,i);}else typeof r=="object"&&r!==null?Object.assign(e.style,r):e.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let i=o.slice(2).toLowerCase();if(vt.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,r);continue}if(Y(r)||typeof r=="function"){let i=o,s=w(()=>{D(n,()=>{let l=typeof r=="function"?r():r.get();Xe.has(i)?e[i]=l??"":ze(e,i,l);});});P(e,s);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 ye(e,t){for(let n of t)it(e,n);}function it(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(F(t)){Ne(e,t);return}if(Y(t)){Qe(e,()=>t.get());return}if(Array.isArray(t)){ye(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function V(e){let t=null,n=e;return F(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 ae(e,t=true){for(let n of e)t&&ce(n),n.remove();}function Qe(e,t){let n=G(),o=document.createComment("");e.appendChild(o);let r=[],i=w(()=>{D(n,()=>{let s=t(),{nodes:l,instance:u}=V(s);ae(r),l.length&&o.after(...l),u&&queueMicrotask(()=>q(u)),r=l;});});P(e,i);}function Te(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(ce(e),e.innerHTML=""),F(t)?Ne(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function ct(e,t){let n=null;if(F(t)?(n=t.$constructor(),queueMicrotask(()=>q(t))):t instanceof Node?n=t:n=document.createTextNode(String(t)),n instanceof HTMLElement){let o=O(()=>!!e()),r=w(()=>{n.style.display=o.get()?"":"none";});P(n,r);}return n}function Ft(e,t,n,o){let r=e.getRoot()?.querySelector(t);if(!r)return {container:null,dispose:null};let i=document.createElement("div");i.className=n,r.append(i);let s=Te(i,o);return {container:i,dispose:s??null}}function ut(e,t,n){return Ft(e,".mrakomor-tools-container",t,n)}Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var ft=Symbol("block-element"),$t=Symbol("block-element-body"),pt=Symbol("selectable-element");function we(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 ke(e){return e?we(e.startContainer,ft):null}function Kt(e){return e?we(e.startContainer,pt):null}function Ae(e){return we(e,pt)}function dt(){return window.getSelection()}function fe(){let e=dt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}var _e=null;function Oe(){_e=ve();}function gt(){_e&&Me(_e);}function Gt(e,t){let n=Kt(t);return n||(Ie(e)??e?.childNodes?.[0]??null)}function W(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,l=e.childNodes,u=Math.min(n,l.length);for(let a=0;a<u;a++)s+=l[a].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let o=0,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=r.nextNode();for(;i;){if(i===t)return o+n;o+=i.textContent.length,i=r.nextNode();}return o}function ve(){let e=fe();if(!e)return null;let t=ke(e),n=Gt(t,e);return {start:W(n,e.startContainer,e.startOffset),end:W(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function Me(e){if(!e)return;let{start:t,end:n,element:o,selectableElement:r}=e,i=r?.isConnected&&r||Ie(o)||o?.childNodes?.[0];if(!i)return;let s=at(i,t),l=at(i,n),u=document.createRange();u.setStart(s.startContainer,s.startOffset),u.setEnd(l.endContainer,l.endOffset);let a=dt();a.removeAllRanges(),a.addRange(u);}function at(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 i=r.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(o+s>=t)return n.setEnd(i,t-o),n.setStart(i,t-o),n;o+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)r.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function Ie(e){if(!e)return null;let t=qt(e);return t?.firstElementChild??t?.firstChild}function mt(e){if(!e?.[ft])return null;let t=Ie(e);return t?ie(t)?.classInstance:null}function qt(e){if(!e)return null;for(let t of e.children)if(t[$t])return t;return null}function ht(e,t,n,o=12){let r=e.getBoundingClientRect(),i=typeof t?.getBoundingClientRect=="function"?t.getBoundingClientRect():t??{left:0,top:0},s=n?.offsetHeight??40;return {x:i.left-r.left,y:i.top-r.top-s-o}}function yt(e,t){let n=W(e,t.startContainer,t.startOffset),o=W(e,t.endContainer,t.endOffset);return {offset:n,length:Math.max(0,o-n)}}var R={KEYDOWN:"mrakomor:keydown",CLICK:"mrakomor:click",SELECTION_CHANGE:"mrakomor:selection-change"};function Et({mrakomor:e,open:t,tooltipElement:n}){let o=_(0),r=_(0),i=_([]),s=null,l=null;function u(){t.set(false),s=null,l=null;}Re(()=>{let p=e.emitter.on(R.OPEN_TOOLTIP,({element:h,actions:g})=>{s=h,l=ve(),i.set(g??[]),t.set(true),le(()=>{let{x:E,y:b}=ht(e.getRoot(),h,n);o.set(E),r.set(b);});}),c=e.emitter.on(R.CLOSE_TOOLTIP,u),m=e.emitter.on(R.KEYDOWN,()=>{t.peek()===true&&u();}),d=e.emitter.on(R.CLICK,h=>{if(t.peek()!==true||!n.current||!s)return;let g=h.target;if(!(g instanceof Node)){u();return}n.current.contains(g)||s.contains(g)||g instanceof Element&&g.contains(n.current)||u();});return ()=>{p(),c(),m(),d();}});let a=O(()=>({left:`${o.get()}px`,top:`${r.get()}px`}));return ct(()=>t.get(),j("div",{className:"mrakomor-tooltip",contenteditable:false,style:a,$ref:n},()=>Vt(i.get(),e,l)))}function Vt(e,t,n){if(!e.length)return null;let o=null,r=[];for(let i of e){o!==null&&i.group!==o&&r.push(j("span",{className:"mrakomor-tooltip__separator"})),o=i.group;let s=i.label,l=typeof s=="string"?s:typeof s=="function"?j(s,{}):s;r.push(j("button",{type:"button",className:["mrakomor-tooltip__btn",i.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:i.title??"",onClick:u=>{u.preventDefault(),Me(n),i.onAction(t);}},l));}return j("span",{style:"display: contents"},r)}function Ht({mrakomor:e}){let n=false,o=null,r=_(false),i=Ce();function s(){let c=e.getConfig();return {inlineStyles:c.inlineStyles,entityRanges:c.entityRanges,blockTransforms:e.register.blocks.list()}}function l(c,m,d,h,g){let E=[],b=e.getConfig()?.inlineStyles??[],y=e.getConfig()?.entityRanges??[],x=g?.read?.(m)??{inlineStyleRanges:m?.properties?.inlineStyleRanges,entityRanges:m?.properties?.entityRanges},C=g?.element??d,f=x?.inlineStyleRanges??[],{offset:S,length:N}=yt(C,h),v=S+N;for(let k of c.inlineStyles){let M=typeof k=="string"?k:k.style,L=b.find(A=>A.style===M);if(!L)continue;let $=f.some(A=>A.style===M&&A.offset<v&&A.offset+A.length>S);E.push({label:L.LABEL??M,title:M.charAt(0)+M.slice(1).toLowerCase(),group:"inline",active:()=>$,onAction:A=>{Oe(),A.command.insertInlineStyleRange({style:L.style}),le(()=>{gt();});}});}for(let k of c.entityRanges){let M=typeof k=="string"?k:k.NAMESPACE,L=y.find($=>$.NAMESPACE===M);L&&E.push({label:L.LABEL??"\u{1F517}",title:L.NAMESPACE,group:"inline",active:()=>false,onAction:$=>{Oe(),$.command.insertEntityRange({namespace:L.NAMESPACE,blockElement:d});}});}return E}function u(c){return {label:c.LABEL??c.NAMESPACE,title:c.LABEL??c.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function a(c,m,d,h){let g=[],E=new Set;for(let b of c.blockTransforms){let y=typeof b=="string"?b:b?.component?.NAMESPACE??b?.NAMESPACE;if(!y||E.has(y)||(E.add(y),y===d.NAMESPACE))continue;let x=e.resolveComponentConstructor(y);x&&g.push({label:x.LABEL??y,title:`Convert to ${x.LABEL??y}`,group:"transform",active:()=>false,onAction:C=>{C.command.transformBlockElement({blockElement:m,namespace:y,range:h});}});}return g}function p(){if(n)return;let c=window.getSelection(),m=e.getRoot();if(!c||c.rangeCount===0){e.command.closeTooltip();return}let d=fe();if(!m.contains(d.commonAncestorContainer)){e.command.closeTooltip();return}if(d.startContainer===i.current&&r.peek()===true)return;let h=ke(d);if(!h){e.command.closeTooltip();return}let g=mt(h),E=e._getBlockElementState(h);if(!g||!E){e.command.closeTooltip();return}let b=g.constructor;if(d.collapsed){e.command.closeTooltip();return}let y=Ae(d.startContainer),x=Ae(d.endContainer);if(!y||!x||y!==x){e.command.closeTooltip();return}let C=s(),f=g.getFormattingTarget?.(d)??null,S=[u(b),...a(C,h,b,d),...l(C,E,h,d,f)];if(S.length===0){e.command.closeTooltip();return}e.command.openTooltip({element:h,actions:S});}return {registerEvents(){R.OPEN_TOOLTIP="mrakomor:open-tooltip",R.CLOSE_TOOLTIP="mrakomor:close-tooltip";},registerCommands(c){c.command.openTooltip=(m,d)=>{c.emit(R.OPEN_TOOLTIP,{...m,options:d});},c.command.closeTooltip=m=>{c.emit(R.CLOSE_TOOLTIP,{options:m});};},registerListeners(){e.emitter.on(R.SELECTION_CHANGE,p),R.OPEN_DIALOG&&e.emitter.on(R.OPEN_DIALOG,()=>{n=true,r.peek()===true&&e.command.closeTooltip();}),R.CLOSE_DIALOG&&e.emitter.on(R.CLOSE_DIALOG,()=>{n=false;});},onMount(){let{dispose:c}=ut(e,"mrakomor-tooltip-plugin-container",j(Et,{mrakomor:be(e),tooltipElement:i,open:r}));o=c;},onUnmount(){o?.(),o=null;}}}exports.Tooltip=Et;exports.tooltipPlugin=Ht;
|
|
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-5VPYPKGA.mjs';import {
|
|
2
|
-
`,document.head.appendChild(i);}}})();function V({mrakomor:t$1,open:
|
|
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};
|