@mrakomor/core 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/blockChrome.cjs +3 -0
  2. package/dist/blockChrome.mjs +2 -1
  3. package/dist/blockInsertMenu.cjs +1 -0
  4. package/dist/blockInsertMenu.mjs +1 -1
  5. package/dist/chunk-5VPYPKGA.mjs +1 -0
  6. package/dist/chunk-G2QV4GOO.mjs +1 -0
  7. package/dist/chunk-GDID5DFL.mjs +1 -0
  8. package/dist/chunk-K2DMHAUD.mjs +1 -0
  9. package/dist/chunk-N4I2WZWF.mjs +1 -0
  10. package/dist/chunk-P7IKAZYZ.mjs +1 -0
  11. package/dist/chunk-Q7RMVYZR.mjs +1 -0
  12. package/dist/chunk-T7OO472O.mjs +1 -0
  13. package/dist/chunk-TX4RCFPO.mjs +3 -0
  14. package/dist/chunk-U3MSKB3R.mjs +2 -0
  15. package/dist/chunk-UC7W4JIH.mjs +2 -0
  16. package/dist/chunk-WBTDWVEC.mjs +3 -0
  17. package/dist/chunk-WQWE5UCN.mjs +1 -0
  18. package/dist/chunk-YHWQV2DB.mjs +1 -0
  19. package/dist/clipboard.cjs +5 -0
  20. package/dist/clipboard.mjs +3 -3
  21. package/dist/footer.cjs +2 -0
  22. package/dist/footer.mjs +2 -0
  23. package/dist/headline.cjs +4 -0
  24. package/dist/headline.mjs +1 -1
  25. package/dist/help.cjs +2 -0
  26. package/dist/help.mjs +2 -0
  27. package/dist/index.cjs +6 -0
  28. package/dist/index.mjs +4 -1
  29. package/dist/link.cjs +3 -0
  30. package/dist/link.mjs +3 -2
  31. package/dist/list.cjs +5 -0
  32. package/dist/list.mjs +1 -1
  33. package/dist/paragraph.cjs +4 -0
  34. package/dist/paragraph.mjs +1 -1
  35. package/dist/slashCommand.cjs +3 -0
  36. package/dist/slashCommand.mjs +1 -1
  37. package/dist/tooltip.cjs +2 -0
  38. package/dist/tooltip.mjs +2 -1
  39. package/dist/tts.cjs +9 -0
  40. package/dist/tts.mjs +3 -2
  41. package/package.json +72 -24
  42. package/dist/chunk-4CNZR6XL.mjs +0 -1
  43. package/dist/chunk-4K476NKG.mjs +0 -1
  44. package/dist/chunk-5V6D56TM.mjs +0 -1
  45. package/dist/chunk-DFL6LPER.mjs +0 -1
  46. package/dist/chunk-IAGILV5H.mjs +0 -1
  47. package/dist/chunk-MIXXUTVH.mjs +0 -1
  48. package/dist/chunk-MWY3XQMH.mjs +0 -3
  49. package/dist/chunk-O7IO4QXV.mjs +0 -1
  50. package/dist/chunk-PYVJPCUA.mjs +0 -1
  51. package/dist/chunk-R6ZAVJUD.mjs +0 -1
package/package.json CHANGED
@@ -1,40 +1,87 @@
1
1
  {
2
2
  "name": "@mrakomor/core",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "imports": {
6
6
  "#src/*.mjs": "./src/*.mjs",
7
7
  "#src/*": "./src/*"
8
8
  },
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.mjs",
9
11
  "exports": {
10
- ".": "./dist/index.mjs",
11
- "./paragraph": "./dist/paragraph.mjs",
12
- "./headline": "./dist/headline.mjs",
13
- "./list": "./dist/list.mjs",
14
- "./link": "./dist/link.mjs",
15
- "./tooltip": "./dist/tooltip.mjs",
16
- "./blockChrome": "./dist/blockChrome.mjs",
17
- "./blockInsertMenu": "./dist/blockInsertMenu.mjs",
18
- "./slashCommand": "./dist/slashCommand.mjs",
19
- "./clipboard": "./dist/clipboard.mjs",
20
- "./tts": "./dist/tts.mjs"
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./paragraph": {
17
+ "import": "./dist/paragraph.mjs",
18
+ "require": "./dist/paragraph.cjs"
19
+ },
20
+ "./headline": {
21
+ "import": "./dist/headline.mjs",
22
+ "require": "./dist/headline.cjs"
23
+ },
24
+ "./list": {
25
+ "import": "./dist/list.mjs",
26
+ "require": "./dist/list.cjs"
27
+ },
28
+ "./link": {
29
+ "import": "./dist/link.mjs",
30
+ "require": "./dist/link.cjs"
31
+ },
32
+ "./tooltip": {
33
+ "import": "./dist/tooltip.mjs",
34
+ "require": "./dist/tooltip.cjs"
35
+ },
36
+ "./blockChrome": {
37
+ "import": "./dist/blockChrome.mjs",
38
+ "require": "./dist/blockChrome.cjs"
39
+ },
40
+ "./blockInsertMenu": {
41
+ "import": "./dist/blockInsertMenu.mjs",
42
+ "require": "./dist/blockInsertMenu.cjs"
43
+ },
44
+ "./slashCommand": {
45
+ "import": "./dist/slashCommand.mjs",
46
+ "require": "./dist/slashCommand.cjs"
47
+ },
48
+ "./clipboard": {
49
+ "import": "./dist/clipboard.mjs",
50
+ "require": "./dist/clipboard.cjs"
51
+ },
52
+ "./footer": {
53
+ "import": "./dist/footer.mjs",
54
+ "require": "./dist/footer.cjs"
55
+ },
56
+ "./help": {
57
+ "import": "./dist/help.mjs",
58
+ "require": "./dist/help.cjs"
59
+ },
60
+ "./tts": {
61
+ "import": "./dist/tts.mjs",
62
+ "require": "./dist/tts.cjs"
63
+ }
21
64
  },
22
65
  "files": [
23
66
  "dist"
24
67
  ],
25
68
  "sideEffects": [
26
69
  "**/*.css",
27
- "./dist/chunk-4CNZR6XL.mjs",
28
- "./dist/chunk-4K476NKG.mjs",
29
- "./dist/chunk-5V6D56TM.mjs",
70
+ "./dist/chunk-5VPYPKGA.mjs",
30
71
  "./dist/chunk-B6JJAATK.mjs",
31
- "./dist/chunk-DFL6LPER.mjs",
32
- "./dist/chunk-IAGILV5H.mjs",
33
- "./dist/chunk-MIXXUTVH.mjs",
34
- "./dist/chunk-MWY3XQMH.mjs",
35
- "./dist/chunk-O7IO4QXV.mjs",
36
- "./dist/chunk-PYVJPCUA.mjs",
37
- "./dist/chunk-R6ZAVJUD.mjs"
72
+ "./dist/chunk-G2QV4GOO.mjs",
73
+ "./dist/chunk-GDID5DFL.mjs",
74
+ "./dist/chunk-K2DMHAUD.mjs",
75
+ "./dist/chunk-N4I2WZWF.mjs",
76
+ "./dist/chunk-P7IKAZYZ.mjs",
77
+ "./dist/chunk-Q7RMVYZR.mjs",
78
+ "./dist/chunk-T7OO472O.mjs",
79
+ "./dist/chunk-TX4RCFPO.mjs",
80
+ "./dist/chunk-U3MSKB3R.mjs",
81
+ "./dist/chunk-UC7W4JIH.mjs",
82
+ "./dist/chunk-WBTDWVEC.mjs",
83
+ "./dist/chunk-WQWE5UCN.mjs",
84
+ "./dist/chunk-YHWQV2DB.mjs"
38
85
  ],
39
86
  "scripts": {
40
87
  "preversion": "npm run build && npm run lint && npm test && npm run types",
@@ -62,9 +109,10 @@
62
109
  "access": "public"
63
110
  },
64
111
  "dependencies": {
65
- "@esmj/dom": "^0.3.0",
112
+ "@esmj/dom": "^0.4.1",
66
113
  "@esmj/emitter": "^0.4.3",
67
- "@esmj/schema": "^0.9.1"
114
+ "@esmj/observable": "^0.2.2",
115
+ "@esmj/schema": "^0.9.2"
68
116
  },
69
117
  "devDependencies": {
70
118
  "@biomejs/biome": "^2.5.10",
@@ -1 +0,0 @@
1
- import {b,a}from'./chunk-O7IO4QXV.mjs';import {j}from'./chunk-MWY3XQMH.mjs';import {l,J,n,i}from'./chunk-DFL6LPER.mjs';var s=class extends n{state;element;mrakomor;constructor(t){super(t);let{state:r,observeDOMChanges:o=true}=t??{};this.state=r,this.element=null,this.mrakomor=i(b),this._stale=false,this._observer=null,this._observeDOMChanges=o;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return a.object({component:a.string().default(this.NAMESPACE),properties:a.object().default({}),settings:a.object().default({})}).default({})}static getPropsSchema(){return a.object({state:this.getStateSchema(),observeDOMChanges:a.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()}onMount(){this.element&&this._observeDOMChanges&&(this._observer=new MutationObserver(()=>{this._stale=true;}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null,this._stale=false);}};var m=class extends s{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let r=()=>{if(!this.element?.isConnected)return;let o=typeof t=="number"?t:j(this.getState()?.properties?.text).length;J(this.element,o);};r(),l(r);}onKeydown(t){}getFormattingTarget(t){return null}};export{m as a};
@@ -1 +0,0 @@
1
- import {p}from'./chunk-DFL6LPER.mjs';function c(e,r,s){let n=e.getRoot()?.querySelector(".mrakomor-tools-container");if(!n)return {container:null,dispose:null};let o=document.createElement("div");o.className=r,n.append(o);let i=p(o,s);return {container:o,dispose:i??null}}export{c as a};
@@ -1 +0,0 @@
1
- import {r,a,l,k as k$1,p,n,j,o}from'./chunk-MWY3XQMH.mjs';import {s,F as F$1}from'./chunk-DFL6LPER.mjs';function w(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function O(e=[]){let n=new Set;return e.map(t=>{if(t?.componentId&&!n.has(t.componentId))return n.add(t.componentId),t;let r=s();return n.add(r),{...t,componentId:r}})}function D(e,n){if(!e||!n)return null;let t=n.startContainer;for(t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);t&&t!==e;){if(t.nodeName==="LI"&&e.contains(t))return t;t=t.parentElement;}return null}function k(e,n){if(!n)return -1;let t=n.getAttribute?.("data-item-index");if(t!=null&&t!==""){let r=Number(t);if(!Number.isNaN(r))return r}return [...e.querySelectorAll("li")].indexOf(n)}function B(e,n){return !e||!n?0:F$1(e,n.startContainer,n.startOffset)}function F(e,n){let t={properties:{text:e.text??"",inlineStyleRanges:e.inlineStyleRanges??[],entityRanges:e.entityRanges??[]}},{originalLineState:r$1,newLineState:i}=r(t,n);return {before:{componentId:e.componentId,depth:e.depth??0,text:r$1.properties.text,inlineStyleRanges:r$1.properties.inlineStyleRanges??[],entityRanges:r$1.properties.entityRanges??[]},after:{componentId:s(),depth:e.depth??0,text:i.properties.text,inlineStyleRanges:i.properties.inlineStyleRanges??[],entityRanges:i.properties.entityRanges??[]}}}function M(e,n){let t=e.properties?.items??[],r=t[n];if(!r)return {blocks:[e],paragraphIndex:0};let i=t.slice(0,n),o=t.slice(n+1),p={component:a,componentId:s(),properties:{text:r.text??"",inlineStyleRanges:r.inlineStyleRanges??[],entityRanges:r.entityRanges??[]},settings:{}},s$1=[];return i.length&&s$1.push({...e,properties:{...e.properties,items:i}}),s$1.push(p),o.length&&s$1.push({...e,componentId:i.length?s():e.componentId,properties:{...e.properties,items:o}}),{blocks:s$1,paragraphIndex:i.length?1:0}}function P(e,n,t){if(n<0||t!==n+1||t>=e.length)return null;let r=e[n],i=e[t];if(!l(r)||!k$1(i))return null;let o=r.properties?.items??[],p$1=o.length-1;if(p$1<0)return null;let s=o[p$1],S={properties:{text:s.text??"",inlineStyleRanges:s.inlineStyleRanges??[],entityRanges:s.entityRanges??[]}},L={properties:{text:i.properties?.text??"",inlineStyleRanges:i.properties?.inlineStyleRanges??[],entityRanges:i.properties?.entityRanges??[]}},{state:l$1,cursor:N}=p(S,L),b={...r,properties:{...r.properties,items:o.map((g,A)=>A===p$1?{...g,text:l$1.properties.text,inlineStyleRanges:l$1.properties.inlineStyleRanges,entityRanges:l$1.properties.entityRanges}:g)}},c=[...e];return c[n]=b,c.splice(t,1),{content:c,listIndex:n,cursor:N}}function U(e,n$1){return n({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},n$1)}function q(e,n){let t=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:j(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return o(e.childNodes,r,0,n),{componentId:e.getAttribute("data-componentid")||void 0,depth:t,text:j(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}export{w as a,O as b,D as c,k as d,B as e,F as f,M as g,P as h,U as i,q as j};
@@ -1 +0,0 @@
1
- var me=class{next(...e){}error(...e){}complete(...e){}},K=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 q=Symbol("@esmj/signals:type"),T=Symbol("@esmj/signals:name");var h=null,J=false,Z=[];function v(e){let t=h;h=null;let n=e();return h=t,n}function Ke(){J=false;let e=xe();for(let n of e)n.get();let t=Z;Z=[];for(let n of t)n();}function be(){J||(J=true,queueMicrotask(Ke));}function Q(e){Z.push(e),be();}var ye=Symbol("@esmj/signals:internal observable"),b=Symbol("@esmj/signals:original function"),Je=class extends K{#e=new Set;#o=null;constructor(e){super(),this.#o=e,this.pipe(t=>{let n=t.subscribe.bind(t),o=t.unsubscribe.bind(t);return t.subscribe=r=>{n(r),this.#e.add(r);},t.unsubscribe=r=>{o(r),this.#e.delete(r);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>v(()=>{this.#e.add(e),this.#o();}),e.next[b]=void 0),e instanceof Ee&&e.next[b]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#o();}),e.next[b]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[b]){let n=t.get,o=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),o())),t.get[b]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[b]?e.next[b]:e.next,e.get=e.get[b]?e.get[b]:e.get,this.#e.delete(e),this.unsubscribe(e)}},P=null;function Se(e){P=new Je(e);}Se(()=>{be();});function xe(){return P.getPending()}function Ce(e){return P.watch(e)}function we(e){return P.unwatch(e)}var y=Symbol("@esmj/signals:no error"),Ee=class Ne extends me{#e=true;#o=false;#n=null;#r=this.#d();#c=null;#u=null;#i=0;#s=new Map;#t=y;constructor(t,n){super(),this.#c=t,this.#u=n,this.debug=n?.debug,this[q]="computed",this[T]=n?.debug??null,this.get=this.get.bind(this);}#a(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.dependencies.clear();}#d(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[T],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Ne&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[ye].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=E(this.#l(),this.#u)),(this.#e||this.#t!==y)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),h&&h.sourceRevisions.set(this,this.#i),this.#t!==y)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=E(this.#l(),this.#u)),(this.#e||this.#t!==y)&&(this.#s.size===0||this.#f()?this.#l():this.#e=false),this.#t!==y)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=y,this.#a(),this.#r.sourceRevisions.clear();let t=h;h=this.#r;let n;try{n=this.#c();}catch(o){this.#t=o;}return h=t,this.#s=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=y,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===y&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#a(),this.#s.clear(),this.#e=true,this.#t=y;}};function N(e,t){return new Ee(e,t)}function g(e,t){let n,{debug:o,...r}={},s=N(()=>{n?.(),n=e();},{equals:()=>false,...r});s.get(),Ce(s);let i=()=>{n?.(),s.destroy(),we(s);};return i[Symbol.dispose]=i,i[q]="effect",i[T]=o??null,i.__RX_COMPUTED__=s,i}function E(e,t={}){let n=t?.equals??Object.is,o=0,r=new K;function s(){return h&&(h.dependencies.set(r,r.subscribe(h.observer)),h.sourceRevisions.set(c,o)),e}function i(){return e}function l(f){if(!n(e,f)){e=f,o++,r.next();}return e}function u(){return o}let c={get:s,set:l,peek:i,getRevision:u,[ye]:r,[q]:"signal",[T]:t?.debug??null};return c}function j(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Ae=Symbol("node-component"),F=Symbol("node-internal"),Be=Symbol("keep-literal");function Ze(e){let t=()=>e;return t[Be]=true,t}function Qe(e){let t=null,n=()=>t,o=s=>(t=s??null,typeof e=="function"&&e(t),t),r={get:n,set:o,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(r,"current",{get(){return t},set(s){o(s);},enumerable:true,configurable:false}),new Proxy(r,{get(s,i,l){if(Reflect.has(s,i))return Reflect.get(s,i,l);if(!t)return;let u=t[i];return typeof u=="function"?u.bind(t):u},set(s,i,l,u){return Reflect.has(s,i)||!t?Reflect.set(s,i,l,u):(t[i]=l,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var Ie=null;function m(){return Ie}function H(e){Ie=e;}function z(e){return e?.[Ae]||null}function ve(e,t){e[Ae]=t;}function X(e,t={disposers:[],id:j()}){return e?.[F]?e[F]:(e&&(e[F]=t),t)}function et(e){return e[F]}function S(e,t){let n=et(e);n||(n=X(e)),n.disposers.push(t);}function B(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function x(e,t){let n=m();H(e);try{return t()}finally{H(n);}}var U=new Map,I=new Map,ke=new Map;function De(e){let t=Object.create(null);for(let n of Object.keys(e)){let o=e[n];n==="children"?t[n]=o:o?.[Be]?t[n]=o():o!=null&&typeof o.get=="function"?t[n]=o:typeof o=="function"?t[n]=N(o):t[n]=E(o);}return t}function G(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?false:n.every(r=>{let s=Object.getOwnPropertyDescriptor(e,r),i=Object.getOwnPropertyDescriptor(t,r);if(!s||!i)return false;let l="value"in s?s.value:s.get?.call(e),u="value"in i?i.value:i.get?.call(t);return G(l,u)})}function tt(e){return {id:Symbol("context-id"),defaultValue:e}}function nt(e,t){let n=m();n&&n.contexts.set(e.id,t);}function ot(e){let t=m();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function rt(e){let t=m();if(!t){console.warn("onMount called outside of a component context");return}B(U,t.id,e);}function st(e){let t=m();if(!t){console.warn("onUnmount called outside of a component context");return}B(I,t.id,e);}function it(e){Q(()=>{setTimeout(e,0);});}function D(e){let t=e.componentId,n=U.get(t);if(n){U.delete(t);for(let o of n){let r=o();typeof r=="function"&&B(I,t,r);}}}function lt(e){let t=I.get(e);if(t){I.delete(e);for(let n of t)n();}}function ut(e){let t=ke.get(e);if(t){ke.delete(e);for(let n of t)n();}}function L(e){if(!e)return;let t=X(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=z(e);if(n&&(lt(n.componentId),ut(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;L(o),o=r;}}}function k(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function ct(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function at(e,t,n){let o=j(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s={...De(t??{}),children:n},i=m(),l={disposers:[],id:o,contexts:new Map(i?.contexts)};H(l);let u;if(ct(e)){r.ClassConstructor=e;let f=new e(s);r.classInstance=f,typeof f.onMount=="function"&&B(U,o,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&B(I,o,()=>{f.onUnmount?.();}),u=f.render();}else u=e(s);H(i);let c=ft(u);if(r.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)X(f,l),ve(f,r);else X(c,l),c instanceof Node&&ve(c,r);return c}};return r}function ne(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{D(t);});}function ft(e){return e instanceof Node?e:k(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Re={className:"class",htmlFor:"for"},Me=new Set(["value","defaultValue","checked","selected","indeterminate"]),dt=new Set(["srcdoc"]),ht=new Set(["href","src","action","formaction","xlink:href"]),pt=new Set(["securitypolicyviolation"]),gt=new Set(["contenteditable","draggable","spellcheck"]);function A(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Le=Symbol("Fragment");function mt(e,t,n){if(e===Le){let r=document.createDocumentFragment();return te(r,Oe(n)),r}if(typeof e=="function")return at(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),xt(o,t),te(o,Oe(n)),o}function ee(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function bt(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function yt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return dt.has(n)?true:ht.has(n)&&t!==null&&t!==void 0&&bt(String(t))}function _e(e){return typeof e!="string"?e:Re[e]?Re[e]:e}function St(e,t){let n=_e(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return gt.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Te(e,t,n){let o=St(t,n);if(o===null){e.removeAttribute(t);return}if(yt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function xt(e,t){let n=m();for(let[o,r]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(o!=="id"){if(o=_e(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(A(r)){let s=g(()=>{x(n,()=>{ee(e,r.get());});});S(e,s);}else if(typeof r=="function"){let s=g(()=>{x(n,()=>{ee(e,r());});});S(e,s);}else ee(e,r);continue}if(o==="style"){if(A(r)){let s=g(()=>{x(n,()=>{Object.assign(e.style,r.get());});});S(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(pt.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,r);continue}if(A(r)||typeof r=="function"){let s=o,i=g(()=>{x(n,()=>{let l=typeof r=="function"?r():r.get();Me.has(s)?e[s]=l??"":Te(e,s,l);});});S(e,i);continue}Me.has(o)||typeof o=="symbol"?e[o]=r??"":Te(e,o,r);}}function Oe(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function te(e,t){for(let n of t)$e(e,n);}function $e(e,t){if(!(t==null||t===false||t===true)){if(t instanceof Node){e.appendChild(t);return}if(typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(String(t)));return}if(typeof t=="function"){je(e,t);return}if(k(t)){ne(e,t);return}if(A(t)){je(e,()=>t.get());return}if(Array.isArray(t)){te(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function oe(e){let t=null,n=e;return k(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function re(e,t=true){for(let n of e)t&&L(n),n.remove();}function je(e,t){let n=m(),o=document.createComment("");e.appendChild(o);let r=[],s=g(()=>{x(n,()=>{let i=t(),{nodes:l,instance:u}=oe(i);re(r),l.length&&o.after(...l),u&&queueMicrotask(()=>D(u)),r=l;});});S(e,s);}var Kt=class{constructor(e){this.props=e;}};function Jt(e,t,n){let o=document.createElement("span");o.style.display="contents",o.setAttribute("data-each",j());let r=m(),s=[],i=new Map,l=N(()=>e()),u=g(()=>{let c=l.get(),f=[],$=[],de=new Set;for(let a=0;a<c.length;a++){let d=c[a],p=t(d,a);if(de.has(p)){console.error(`Each: duplicate key "${String(p)}" detected; ignoring later item at index ${a}`);continue}de.add(p),f.push(d),$.push(p);}let W=new Map(s.map(a=>[a.key,a])),M=[];for(let a=0;a<f.length;a++){let d=$[a],p=f[a],w=W.get(d);if(w)i.get(d).set(p),M.push(w),W.delete(d);else {let he=E(p,{equals:G});i.set(d,he);let ze={...he,set(){}},pe={key:d,nodes:[]};x(r,()=>{let Ge=n(ze,a),{nodes:Ve,instance:ge}=oe(Ge);pe.nodes=Ve,ge&&queueMicrotask(()=>D(ge));}),M.push(pe);}}for(let[a,d]of W)re(d.nodes),i.delete(a);let Y=null;for(let a=M.length-1;a>=0;a--){let d=M[a].nodes;for(let p=d.length-1;p>=0;p--){let w=d[p];(w.parentNode!==o||w.nextSibling!==Y)&&o.insertBefore(w,Y),Y=w;}}s=M;});return S(o,u),o}function Zt(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(L(e),e.innerHTML=""),k(t)?ne(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function Qt(e){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("unmount: container not found");L(e),e.innerHTML="";}function en(e,t){let n=null;if(k(t)?(n=t.$constructor(),queueMicrotask(()=>D(t))):t instanceof Node?n=t:n=document.createTextNode(String(t)),n instanceof HTMLElement){let o=N(()=>!!e()),r=g(()=>{n.style.display=o.get()?"":"none";});S(n,r);}return n}var se=ue(),ie=ue(),qe=ue(),Ct=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function ue(){return Math.floor(Math.random()*16777215)}function wt(){return ie=(ie+1)%16777215,ie}function sn(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=wt(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,se>>16&255,se>>8&255,se&255,qe>>8&255,qe&255,t>>16&255,t>>8&255,t&255),o="";for(let r=0;r<n.length;r++)o+=Ct[n.charCodeAt(r)];return o}var ce=Symbol("block-element"),Et=Symbol("block-element-body"),He=Symbol("selectable-element");function V(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 Xe(e){return e?V(e.startContainer,ce):null}function Pe(e){return V(e,ce)}function Ue(e){return e?V(e.startContainer,He):null}function Fe(e){return V(e,He)}function ae(){return window.getSelection()}function fe(){let e=ae();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function ln(){let e=fe();if(!e)return 0;e.collapse(true);let t=Ue(e),n=Xe(e),o=t??R(n);return _(o,e.startContainer,e.startOffset)}var C=null;function un(){C=kt();}function Nt(){C&&Rt(C);}function cn(){C&&(C={start:C.end,end:C.end,element:C.element},Nt());}function vt(e,t){let n=Ue(t);return n||(R(e)??e?.childNodes?.[0]??null)}function _(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,l=e.childNodes,u=Math.min(n,l.length);for(let c=0;c<u;c++)i+=l[c].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 kt(){let e=fe();if(!e)return null;let t=Xe(e),n=vt(t,e);return {start:_(n,e.startContainer,e.startOffset),end:_(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function an(e=fe()){if(!e||e.collapsed)return null;let t=Pe(e.startContainer),n=Pe(e.endContainer);if(!t||!n)return null;let o=Fe(e.startContainer)??R(t),r=Fe(e.endContainer)??R(n);return {startBlock:t,endBlock:n,startOffset:_(o,e.startContainer,e.startOffset),endOffset:_(r,e.endContainer,e.endOffset)}}function Rt(e){if(!e)return;let{start:t,end:n,element:o,selectableElement:r}=e,s=r?.isConnected&&r||R(o)||o?.childNodes?.[0];if(!s)return;let i=le(s,t),l=le(s,n),u=document.createRange();u.setStart(i.startContainer,i.startOffset),u.setEnd(l.endContainer,l.endOffset);let c=ae();c.removeAllRanges(),c.addRange(u);}function le(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 fn(e,t){let n=le(e,t),o=ae();o.removeAllRanges(),o.addRange(n);}function R(e){if(!e)return null;let t=Mt(e);return t?.firstElementChild??t?.firstChild}function dn(e){if(!e?.[ce])return null;let t=R(e);return t?z(t)?.classInstance:null}function Mt(e){if(!e)return null;for(let t of e.children)if(t[Et])return t;return null}function hn(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}}export{fe as A,ln as B,un as C,Nt as D,cn as E,_ as F,kt as G,an as H,Rt as I,fn as J,R as K,dn as L,Mt as M,hn as N,v as a,N as b,E as c,Ze as d,Qe as e,z as f,tt as g,nt as h,ot as i,rt as j,st as k,it as l,mt as m,Kt as n,Jt as o,Zt as p,Qt as q,en as r,sn as s,ce as t,Et as u,He as v,Xe as w,Pe as x,Ue as y,Fe as z};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-4CNZR6XL.mjs';import {g,a as a$2}from'./chunk-O7IO4QXV.mjs';import {j,s as s$1,a as a$4,e,f,g as g$1,h,i as i$1}from'./chunk-MWY3XQMH.mjs';import {m,a as a$3,v,A,x,l,K,J}from'./chunk-DFL6LPER.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/headline/Headline.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(n){return n.getAttribute("data-mrakomor-css-path")===e});if(!t){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent='".mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}\\n"',document.head.appendChild(r);}}})();var o=class extends a$1{constructor(t){super(t),this._level=1;}static getStateSchema(t){return g(t,{component:this.NAMESPACE,properties:{text:a$2.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let r=structuredClone(this.constructor.getStateSchema(t).parse());return r.properties.text=j(r.properties.text),r}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return m(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[v]:true,$ref:r=>{this.element=r;},$dangerouslySetInnerHTML:()=>{let r=this.state.get(),n=r.properties?.text??"";return j(n)?a$3(()=>this._buildContent(r)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#t(t);return}s$1(this,t,{namespace:a$4});}#t(t){if(!A()?.collapsed)return;let n=x(this.element);if(n?.previousElementSibling||j(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:n,namespace:a$4});let l$1=()=>{let b=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),p=K(b);p?.isConnected&&J(p,0);};l$1(),l(l$1);}},s=class extends o{static get NAMESPACE(){return e}static get LABEL(){return "H1"}static get KEYWORDS(){return ["h1","title","heading"]}constructor(t){super(t),this._level=1;}},c=class extends o{static get NAMESPACE(){return f}static get LABEL(){return "H2"}static get KEYWORDS(){return ["h2","heading"]}constructor(t){super(t),this._level=2;}},i=class extends o{static get NAMESPACE(){return g$1}static get LABEL(){return "H3"}static get KEYWORDS(){return ["h3","heading"]}constructor(t){super(t),this._level=3;}},a=class extends o{static get NAMESPACE(){return h}static get LABEL(){return "H4"}static get KEYWORDS(){return ["h4","heading"]}constructor(t){super(t),this._level=4;}},u=class extends o{static get NAMESPACE(){return i$1}static get LABEL(){return "H5"}static get KEYWORDS(){return ["h5","heading"]}constructor(t){super(t),this._level=5;}};function w(){return {resolveConfig:e=>(e.blockComponents.push(s,c,i,a,u),e),resolveComponent:e=>{if(e===s.NAMESPACE)return s;if(e===c.NAMESPACE)return c;if(e===i.NAMESPACE)return i;if(e===a.NAMESPACE)return a;if(e===u.NAMESPACE)return u}}}export{o as a,w as b};
@@ -1 +0,0 @@
1
- import {a as a$1,b as b$1,j,c,d,i,g,e,f,h}from'./chunk-5V6D56TM.mjs';import {a}from'./chunk-4CNZR6XL.mjs';import {a as a$2,e as e$1,d as d$1}from'./chunk-O7IO4QXV.mjs';import {b,j as j$1,l as l$1,k}from'./chunk-MWY3XQMH.mjs';import {a as a$4}from'./chunk-B6JJAATK.mjs';import {s,A,m,o,a as a$3,v,l,x,J,L}from'./chunk-DFL6LPER.mjs';(function(){if(!(typeof document>"u")){var l="mrakomor/core/plugin/list/List.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===l});if(!t){var e=document.createElement("style");e.setAttribute("data-mrakomor-css",""),e.setAttribute("data-mrakomor-css-path",l),e.textContent='".molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth=\\"1\\"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth=\\"2\\"]{margin-inline-start:3em}.molecule-list-list li[data-depth=\\"3\\"]{margin-inline-start:4.5em}\\n"',document.head.appendChild(e);}}})();var E=l=>a$2.object({componentId:a$2.string().default(()=>l?.getAttribute?.("data-componentid")||s()),depth:a$2.number().default(0),text:a$2.string().default(""),inlineStyleRanges:a$2.array(d$1()).default([]),entityRanges:a$2.array(e$1()).default([])}).default({}),R=class l$1 extends a{static get NAMESPACE(){return b}static get LABEL(){return "List"}static get GROUP(){return "lists"}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){let e=a$1(t);return a$2.object({component:a$2.string().default(l$1.NAMESPACE),componentId:a$2.string().default(t?.getAttribute("data-componentid")||s()),properties:a$2.object({items:a$2.array(E()).default([E().parse()]).transform(b$1)}).default({}),settings:a$2.object({style:a$2.enum(["ORDERED","UNORDERED"]).default(e??"UNORDERED")}).default({})}).default({})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let e=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},n=[...t.querySelectorAll("li")];return e.properties.items=n.length?n.map(o=>E(o).parse(j(o,r))):[E().parse()],e.settings={...e.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??e.settings?.style??"UNORDERED"},e}getFormattingTarget(t){let e=t??A(),r=c(this.element,e);if(!r)return null;let n=d(this.element,r);return n<0?null:{element:r,read(o){let s=o.properties?.items?.[n];return {inlineStyleRanges:s?.inlineStyleRanges,entityRanges:s?.entityRanges}},write(o,{inlineStyleRanges:s,entityRanges:a}){let i=o.properties?.items?.[n];i&&(s!==void 0&&(i.inlineStyleRanges=s),a!==void 0&&(i.entityRanges=a));}}}_commitState(t){let e=this.mrakomor.getContent(),r=e.findIndex(n=>n.componentId===t.componentId);r!==-1&&(e.splice(r,1,t),this.mrakomor.setContent(e));}_buildItemContent(t){return i(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),e=this.state.peek(),r=e.settings?.style==="ORDERED"?"ol":"ul";return m(r,{className:t,"data-componentid":e.componentId,$ref:n=>{this.element=n;}},o(()=>this.state.get().properties?.items??[],(n,o)=>n.componentId??String(o),(n,o)=>m("li",{contentEditable:true,[v]:true,"data-componentid":()=>n.get().componentId,"data-item-index":()=>{let s=n.get()?.componentId,i=(this.state.get().properties?.items??[]).findIndex(c=>c.componentId===s);return String(i>=0?i:o)},"data-depth":()=>String(n.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let s=n.get(),a=s?.text??"";return j$1(a)?a$3(()=>this._buildItemContent(s)):"<br>"}})))}onKeydown(t){if(t.key==="Enter"){this.#e(t);return}t.key==="Backspace"&&this.#n(t);}setCursor(t){let e=this.getState()?.properties?.items??[],r=e.length-1;if(r<0)return;let n=typeof t=="number"?t:j$1(e[r]?.text).length,o=()=>{let s=this.element?.querySelector(`li[data-item-index="${r}"]`);s?.isConnected&&J(s,n);};o(),l(o);}#t(t){let e=this.getState(),r=[...e.properties.items??[]],n=r[t];if(!n)return;if((n.depth??0)>0){r[t]={...n,depth:n.depth-1},this._commitState({...e,properties:{...e.properties,items:r}});let a=()=>{let i=this.element?.querySelector(`li[data-item-index="${t}"]`);i?.isConnected&&J(i,0);};a(),l(a);return}let{blocks:o,paragraphIndex:s}=g(e,t);this.mrakomor.command.replaceBlockElement({blockElement:x(this.element),blocks:o,cursor:0,cursorBlockIndex:s});}#e(t){t.preventDefault();let e$1=A(),r=c(this.element,e$1);if(!r)return;let n=d(this.element,r),o=e(r,e$1),s=this.getState(),a=[...s.properties.items??[]],i=a[n];if(!i)return;if(!j$1(i.text)){this.#t(n);return}let{before:c$1,after:y}=f(i,o);a.splice(n,1,c$1,y),this._commitState({...s,properties:{...s.properties,items:a}}),l(()=>{let k=this.element?.querySelector(`li[data-item-index="${n+1}"]`);k&&J(k,0);});}#n(t){let e$1=A(),r=c(this.element,e$1);if(!r||!e$1.collapsed)return;let n=d(this.element,r);e(r,e$1)===0&&(t.preventDefault(),this.#t(n));}};function H(l){let{mrakomor:t,blockElement:e,previousBlockElement:r}=l;if(!t||!e||!r)return;let n=t._getBlockElementIndex(r),o=t._getBlockElementIndex(e);if(n===-1||o===-1)return;let s=t.getContent(),a=s[n],i=s[o];if(!l$1(a)||!k(i))return;let c=h(s,n,o);c&&(l.preventDefault(),t._setContentState(c.content.map(y=>t.normalizeComponentState(y))),L(r)?.setCursor?.(c.cursor));}function z(l){return {resolveConfig:t=>(t.blockComponents.push({component:l,id:"list:ul",label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:l,id:"list:ol",label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===l.NAMESPACE)return l},registerCommands(t){t.emitter.on(a$4.MERGE_BLOCK_ELEMENT,H);}}}function nt(){return z(R)}export{R as a,z as b,nt as c};
@@ -1,3 +0,0 @@
1
- import {p,s,B as B$1,A as A$1,F as F$1,m}from'./chunk-DFL6LPER.mjs';var d="molecule.paragraph.Paragraph",k="molecule.list.List",D="molecule.external.ExternalComponent",O="namespace.unknown.UnknownComponent",F="molecule.headline.H1",v="molecule.headline.H2",X="molecule.headline.H3",K="molecule.headline.H4",z="molecule.headline.H5",A="molecule.headline.";function a(t){return t===`
2
- `||t===`\r
3
- `?"":t??""}function N(t){let e=t?.component??"";return e===d||e.startsWith(A)}function q(t){return Array.isArray(t?.properties?.items)}function J(t,e){return N(t)&&N(e)&&t.component===e.component}function _(t,e){let r=new Set([0,e]);for(let o of t)r.add(o.offset),r.add(o.offset+o.length);return [...r].sort((o,n)=>o-n)}function C(t,e,r){return t.filter(o=>o.offset<=e&&o.offset+o.length>=r)}function H(t,e,r,{inlineStyleComponents:o,entityRangeComponents:n}){let s=t;for(let i of e){let f=o.find(p=>p.match(i));f&&(s=m(f,{},s));}for(let i of r){let f=n.find(p=>p.match(i));f&&(s=m(f,i,s));}return s}function Q(t,{inlineStyleComponents:e,entityRangeComponents:r}){let o=document.createDocumentFragment(),n=a(t.properties.text),s=t.properties.inlineStyleRanges??[],i=t.properties.entityRanges??[];if(!n)return o;let f=_([...s,...i],n.length);for(let p$1=0;p$1<f.length-1;p$1+=1){let l=f[p$1],c=f[p$1+1];if(l>=c)continue;let g=n.slice(l,c),P=H(g,C(s,l,c),C(i,l,c),{inlineStyleComponents:e,entityRangeComponents:r});p(o,P);}return o}function u(t,e,r,{inlineStyleComponents:o,entityRangeComponents:n}){let s=r;for(let i of t){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let f=o.find(l=>l.match(i));if(f){let l=i.textContent.length;e.properties.inlineStyleRanges.push({style:f.style,offset:s,length:l}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:n});continue}let p=n.find(l=>l.match(i));if(p){let l=i.textContent.length;e.properties.entityRanges.push({...p.getStateSchema(i).parse(),offset:s,length:l}),s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:n});continue}s=u(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:n});}return s}function L(t,e){let r=a(t.properties.text),o=a(e.properties.text);return {state:{...t,properties:{...e.properties,...t.properties,text:r+o,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(n=>({...n,offset:n.offset+r.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(n=>({...n,offset:n.offset+r.length}))]},settings:{...e.settings,...t.settings}},cursor:r.length}}function V(t,{startIndex:e,endIndex:r,startOffset:o,endOffset:n}){let s=[...t],i=s[e],f=s[r],{originalLineState:p}=x(i,o),{newLineState:l}=x(f,n),{state:c,cursor:g}=L(p,l);return s.splice(e,r-e+1,c),{content:s,cursor:g,resultIndex:e}}function x(t,e){let r=structuredClone(t),o=structuredClone(t);return r.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),r.properties.inlineStyleRanges=(t.properties.inlineStyleRanges??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)})),o.properties.inlineStyleRanges=(t.properties.inlineStyleRanges??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)})),r.properties.entityRanges=(t.properties.entityRanges??[]).filter(n=>n.offset<e).map(n=>({...n,length:Math.min(n.length,e-n.offset)})),o.properties.entityRanges=(t.properties.entityRanges??[]).filter(n=>n.offset+n.length>e).map(n=>({...n,offset:Math.max(0,n.offset-e),length:n.offset+n.length-Math.max(n.offset,e)})),o.componentId=s(),{originalLineState:r,newLineState:o}}function Y(t,e,{namespace:r=t.constructor.NAMESPACE}={}){if(e.key!=="Enter")return false;e.preventDefault();let{originalLineState:o,newLineState:n}=x(t.getState(),B$1(t.element));return t.mrakomor.command.insertBlockElement({range:A$1(),cursor:0,newLineState:n,originalLineState:o,namespace:r}),true}function Z(t,e){if(e.key!=="Enter")return false;e.preventDefault();let r=d,o=t.mrakomor.resolveComponentConstructor(r);return t.mrakomor.command.insertBlockElement({range:A$1(),cursor:0,newLineState:t.mrakomor.normalizeComponentState(o.getStateSchema().parse({})),namespace:r}),true}function $(t,e){let r=t.constructor;if(!e)return r.getStateSchema(e).parse();let o=structuredClone(r.getStateSchema(e).parse());return u(e.childNodes,o,0,{inlineStyleComponents:t.getInlineStyleComponents(),entityRangeComponents:t.getEntityRangeComponents()}),o.properties.text=a(o.properties.text),o}function b(t){return t?{element:t,read(e){return {inlineStyleRanges:e.properties?.inlineStyleRanges,entityRanges:e.properties?.entityRanges}},write(e,{inlineStyleRanges:r,entityRanges:o}){r!==void 0&&(e.properties.inlineStyleRanges=r),o!==void 0&&(e.properties.entityRanges=o);}}:null}function M(t,e){let r=F$1(t,e.startContainer,e.startOffset),o=F$1(t,e.endContainer,e.endOffset);return {offset:r,length:Math.max(0,o-r)}}function T(t,{style:e,offset:r,length:o}){let n=t??[],s=r+o,i=n.find(f=>f.style===e&&f.offset<=r&&f.offset+f.length>=s);return i?n.filter(f=>f!==i):[...n,{style:e,offset:r,length:o}]}function I(t,e){return t.offset<e.offset+e.length&&e.offset<t.offset+t.length}function B(t,e){let r=e.offset+e.length,o=[];for(let n of t){if(!I(n,e)){o.push(n);continue}n.offset<e.offset&&o.push({...n,length:e.offset-n.offset});let s=n.offset+n.length;s>r&&o.push({...n,offset:r,length:s-r});}return o}function w(t,e){let r=t??[],o=e?.length??0;if(o===0)return null;let n=e.offset??0,s=e.entity?.type,i=r.find(f=>f.offset===n&&f.length===o&&f.entity?.type===s);return i?r.filter(f=>f!==i):[...B(r,e),e]}function ee(t,e,{style:r,range:o}){if(!t||!e?.element||!o)return null;let n=e.read(t);if(n?.inlineStyleRanges===void 0)return null;let{offset:s,length:i}=M(e.element,o);return i===0?null:(e.write(t,{inlineStyleRanges:T(n.inlineStyleRanges??[],{style:r,offset:s,length:i})}),t)}function te(t,e,{state:r,namespace:o,range:n}){if(!t||!e?.element||!n)return null;let s=e.read(t);if(s?.entityRanges===void 0)return null;let i={...r,entity:{type:o,...r?.entity},...M(e.element,n)},f=w(s.entityRanges??[],i);return f===null?null:(e.write(t,{entityRanges:f}),t)}export{d as a,k as b,D as c,O as d,F as e,v as f,X as g,K as h,z as i,a as j,N as k,q as l,J as m,Q as n,u as o,L as p,V as q,x as r,Y as s,Z as t,$ as u,b as v,M as w,ee as x,te as y};
@@ -1 +0,0 @@
1
- import {g,s}from'./chunk-DFL6LPER.mjs';var G={abortEarly:true};function x(e,s){if(s===void 0)return e;let t=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${t}": ${e.message}`,cause:{key:t}}}function U(e,s,t){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)s.push(x(e.errors[r],t));}function I(e,s,t,r){if(t!==false){let a=x(e.error,s);return {success:false,error:a,errors:[a]}}U(e,r,s);}function $(e){return e?.abortEarly!==void 0?e:G}function E(e,s){y(e,"_parse",(t,r,a)=>{let l=t(r,a);return !l.success&&s(r)?{success:true,data:r}:l});}var _=e=>typeof e=="string"||e instanceof String,D=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),S=e=>e===true||e===false,W=e=>e instanceof Date&&!Number.isNaN(e.getTime()),X=e=>typeof e=="function",K=e=>Array.isArray(e),R=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function q(e,s){let t=h(R,{...s,type:"object"});return t._getDescription=()=>`object({ ${Object.entries(e).map(([r,a])=>`${r}: ${a._getDescription()}`).join(", ")} })`,t._getDefinition=()=>e,y(t,"_parse",(r,a,l)=>{let n=r(a,l),{abortEarly:u}=$(l);if(n.success===false)return n;let i={},f=[];for(let c in e){let m=e[c]._parse(n.data[c],l);if(m.success)i[c]=m.data;else {let p=I(m,c,u,f);if(p)return p}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:i}}),t}function N(e){return h(_,{...e,type:"string"})}function v(e){return h(D,{...e,type:"number"})}function C(e){return h(S,{...e,type:"boolean"})}function k(e){return h(W,{...e,type:"date"})}function F(e){return h(X,{...e,type:"function"})}function H(e,s){let t=n=>e.includes(n),r=n=>`Invalid ${a} value. Expected ${e.map(u=>`"${u}"`).join(" | ")}, received "${n}".`,a="enum",l=h(t,{message:r,...s,type:a});return l._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,l._getDefinition=()=>e,l}function M(e,s){let t=h(K,{...s,type:"array"});return t._getDescription=()=>`array(${e._getDescription()})`,t._getDefinition=()=>e,y(t,"_parse",(r,a,l)=>{let n=r(a,l),{abortEarly:u}=$(l);if(n.success===false)return n;let i=[],f=[];for(let c=0;c<n.data.length;c++){let m=e._parse(n.data[c],l);if(m.success)i.push(m.data);else {let p=I(m,c,u,f);if(p)return p}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:i}}),t}function V(){return h(()=>true)}function d(e,s){return y(s,"_parse",(t,r,a)=>(r=e(r),t(r,a))),s}function L(e,s){let t=a=>`Invalid union value. Expected the value to match one of the schemas:${e.map((l,n)=>` ${n+1}. ${l._getDescription()}`).join(",")} but received "${typeof a}" with value: ${R(a)?JSON.stringify(a):`"${a}"`}`,r=h(()=>false,{message:t,...s,type:"union"});return r._getDefinition=()=>e,y(r,"_parse",(a,l,n)=>{let u=n,i=[];for(let p=0;p<e.length;p++){let g=e[p]._parse(l,u);if(g.success)return g;i.push(g);}let{abortEarly:f}=$(u),c={message:typeof t=="function"?t(l):t};if(f!==false)return {success:false,error:c,errors:[c]};let m=[];for(let p=0;p<i.length;p++){let g=i[p].errors;if(g?.length)for(let b=0;b<g.length;b++)g[b].cause?.key&&m.push(x(g[b],`branch ${p}`));}return m.length===0&&m.push(c),{success:false,error:m[0],errors:m}}),r}function P(e,s){let t=h(r=>r===e,{message:r=>s?.message?typeof s.message=="function"?s.message(r):s.message:`Expected literal value "${e}", received "${r}"`,name:s?.name,type:"literal"});return t._getDescription=()=>`literal("${e}")`,t._getDefinition=()=>e,t}var z={boolean(e){let s=e?.message??(t=>`Cannot cast "${t}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return d(t=>{let r;return _(t)&&(r=t.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||t===1?true:r==="false"||r==="no"||r==="off"||r==="0"||t===0?false:t},C({...e,message:s}))},number(e){let s=e?.message??(t=>`Cannot cast "${t}" to a number. Expected a numeric string or number.`);return d(t=>{if(S(t))return Number(t);if(_(t)){let r=t.trim();if(r==="")return t;let a=Number(r);if(Number.isFinite(a))return a}return t},v({...e,message:s}))},string(e){let s=e?.message??(t=>`Cannot cast "${t}" to string. Expected a string, number, or boolean.`);return d(t=>S(t)||D(t)&&Number.isFinite(t)?String(t):t,N({...e,message:s}))},date(e){let s=e?.message??(t=>`Cannot cast "${t}" to a valid date.`);return d(t=>{let r;return _(t)&&(r=t.trim()),D(t)&&Number.isFinite(t)||r?new Date(r??t):t},k({...e,message:s}))},json(e,s){let t=s?.message??(r=>`Cannot parse "${r}" as JSON.`);return y(e,"_parse",(r,a,l)=>{if(_(a))try{a=JSON.parse(a);}catch{let n={message:typeof t=="function"?t(a):t};return {success:false,error:n,errors:[n]}}return r(a,l)}),e}},B={},o={object:q,string:N,number:v,boolean:C,date:k,function:F,enum:H,array:M,any:V,preprocess:d,union:L,literal:P,coerce:B,cast:z};function T(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function y(e,s,t){let r=e[s];e[s]=(...a)=>t(r,...a);}function h(e,{type:s="any",name:t,message:r}={}){r=r||T(s);let a={name:t,message:r,type:s},l={_getName(){return t},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(n,u){let i=e(n);if(i===true)return {success:true,data:n};if(typeof i=="object"&&i?.success===true)return i;let f={message:typeof r=="function"?r(n):r};return {success:false,error:f,errors:[f]}},parse(n,u){let i=this._parse(n,u);if(!i.success)throw i=i,new Error(i.error.message,{cause:i.error.cause});return i.data},safeParse(n,u){return this._parse(n,u)},transform(n){return y(this,"_parse",(u,i,f)=>{let c=u(i,f);return c.success&&(c.data=n(c.data)),c}),this},optional(){return E(this,n=>n===void 0),this},nullable(){return E(this,n=>n===null),this},nullish(){return E(this,n=>n==null),this},default(n){return y(this,"_parse",(u,i,f)=>(i===void 0&&(i=typeof n=="function"?n():n),u(i,f))),this},catch(n){return y(this,"_parse",(u,i,f)=>{let c=u(i,f);return c.success?c:{success:true,data:typeof n=="function"?n({input:i,error:c.error}):n}}),this},pipe(n){return y(this,"_parse",(u,i,f)=>{let c=u(i,f);return c.success?n._parse(c.data,f):c}),this},refine(n,{message:u,type:i,jsonSchema:f}={}){if(i&&(u=u||T(i),s=i),f){let c=[...this._getJsonSchemaHints?.()??[],f];this._getJsonSchemaHints=()=>c;}return y(this,"_parse",(c,m,p)=>{let g=c(m,p),{abortEarly:b}=$(p);if(!g.success)return g;let j=n(g.data);if(j===true||typeof j=="object"&&j?.success===true)return g;let w={message:typeof u=="function"?u(m):u};return {success:false,error:w,errors:[w]}}),this},clone(){return {...this}}};return J.length>0?J.reduce((n,u)=>u(n,e,a)??n,l):l}var J=[];function Q(e){return e!=null&&typeof e=="object"&&(typeof Element>"u"?e.nodeType===1:e instanceof Element)}function ae(){return o.object({root:o.any().refine(Q,{message:"root must be a DOM Element"}),id:o.string().optional(),debug:o.boolean().optional(),content:o.array(o.any()).optional(),plugins:o.array(o.function()).optional(),blockComponents:o.array(o.any().refine(e=>typeof e=="function"||e!=null&&typeof e=="object"&&typeof e.component=="function",{message:"blockComponents entry must be a constructor or registration"})).optional(),inlineStyles:o.array(o.function()).optional(),entityRanges:o.array(o.function()).optional(),tooltip:o.any().optional()})}function oe(){return o.object({length:o.number(),offset:o.number(),style:o.string()})}function Y({type:e,data:s=o.any(),length:t,offset:r}={}){let a=e!=null,l=o.object({type:a?o.string().default(e):o.string(),data:s}),n=t??(a?0:void 0),u=r??(a?0:void 0);return o.object({entity:a?l.default({}):l,length:n==null?o.number():o.number().default(n),offset:u==null?o.number():o.number().default(u)})}function ie(){return o.array(Y()).transform(e=>e.filter(s=>s.entity.type==="atom.tts.Voice")).default([])}function ue(e,{component:s$1,properties:t,settings:r=o.object({}).default({})}){return o.object({component:o.string().default(s$1),componentId:o.string().default(e?.getAttribute("data-componentid")||s()),properties:o.object(t).default({}),settings:r}).default({})}var fe=g();export{o as a,fe as b,ae as c,oe as d,Y as e,ie as f,ue as g};
@@ -1 +0,0 @@
1
- import {a,b}from'./chunk-O7IO4QXV.mjs';import {n,i as i$1,e,m}from'./chunk-DFL6LPER.mjs';var i=class extends n{static get nodeName(){return "span"}static get NAMESPACE(){return "namespace.EntityRangeElement"}static match(t){return t?.nodeName===this.nodeName.toUpperCase()||t?.entity?.type===this.NAMESPACE}static getStateSchema(t){return a.any()}constructor(t){super(t),this.mrakomor=i$1(b),this.element=e(null);}render(){return m(this.constructor.nodeName,{},this.props.children)}};export{i as a};
@@ -1 +0,0 @@
1
- import {a}from'./chunk-4CNZR6XL.mjs';import {g,a as a$2,d,e}from'./chunk-O7IO4QXV.mjs';import {a as a$1,u,n as n$1,j,v as v$1,s}from'./chunk-MWY3XQMH.mjs';import {m,a as a$3,v}from'./chunk-DFL6LPER.mjs';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/paragraph/Paragraph.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(a){return a.getAttribute("data-mrakomor-css-path")===e});if(!t){var r=document.createElement("style");r.setAttribute("data-mrakomor-css",""),r.setAttribute("data-mrakomor-css-path",e),r.textContent='".mrakomor-content p{margin-top:0}\\n"',document.head.appendChild(r);}}})();var n=class e$1 extends a{static get NAMESPACE(){return a$1}static get LABEL(){return "P"}static get KEYWORDS(){return ["p","paragraph","text"]}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){return g(t,{component:e$1.NAMESPACE,properties:{entityRanges:a$2.array(e()).default([]),inlineStyleRanges:a$2.array(d()).default([]),text:a$2.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return u(this,t)}_buildContent(t){return n$1(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return m("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[v]:true,$ref:r=>{this.element=r;},$dangerouslySetInnerHTML:()=>{let r=this.state.get(),a=r.properties?.text??"";return j(a)?a$3(()=>this._buildContent(r)):"<br>"}})}getFormattingTarget(t){return v$1(this.element)}onKeydown(t){s(this,t);}};function L(){return {resolveConfig:e=>(e.blockComponents.push(n),e),resolveComponent:e=>{if(e===n.NAMESPACE)return n}}}export{n as a,L as b};