efficient-easel 7.0.3 → 7.1.0
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/{canvas-typing-U7TV-iax.d.ts → canvas-typing-Cnvlsh_V.d.ts} +7 -2
- package/dist/{chunk-2OZF3UTH.js → chunk-3QGESV36.js} +52 -52
- package/dist/{chunk-LC62L4P2.js → chunk-5POZQNAJ.js} +1 -1
- package/dist/{chunk-5AVEAO36.js → chunk-5WKEKFMB.js} +1 -1
- package/dist/{chunk-6UNFME6S.js → chunk-6F2SGZ7F.js} +1 -1
- package/dist/{chunk-UMUNJM5I.js → chunk-CCIBI2BA.js} +1 -1
- package/dist/{chunk-DDOJANIE.js → chunk-HKQB5ITX.js} +1 -1
- package/dist/{chunk-FKZOKR5K.js → chunk-LRB6UP6D.js} +3 -3
- package/dist/{chunk-FKXEPECH.js → chunk-PG3QGGTU.js} +4 -4
- package/dist/chunk-POBSVKN7.js +5 -0
- package/dist/{chunk-GV3EVHZM.js → chunk-RKOWJG5O.js} +1 -1
- package/dist/{chunk-CRWFB7MU.js → chunk-UCAM256Q.js} +16 -16
- package/dist/{chunk-A6X355SX.js → chunk-VGTNT6UW.js} +1 -1
- package/dist/{chunk-P6EIA5NH.js → chunk-WF5IIVDD.js} +8 -8
- package/dist/chunk-WQASXLXS.js +1 -0
- package/dist/{chunk-JVTSUA2U.js → chunk-XY5AE7DQ.js} +1 -1
- package/dist/copy/index.d.ts +1 -1
- package/dist/copy/index.js +10 -10
- package/dist/easel/easel.css +13 -16
- package/dist/easel/index.d.ts +4 -1
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-B3PXQMFN.js +0 -5
- package/dist/chunk-CIHKZMNR.js +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{FieldSelect as e}from"./chunk-OZ72A6MY.js";import{TreeSeam as n}from"./chunk-4JSBIW5H.js";import{
|
|
1
|
+
import{FieldSelect as e}from"./chunk-OZ72A6MY.js";import{TreeSeam as n}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as t}from"./chunk-K56YDHYQ.js";import{EaselMenuItems as l}from"./chunk-EA2HTX37.js";import{SettingsField as r,SETTINGS_BUCKETS as a,SettingsGroup as o}from"./chunk-3ZJSLHHI.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-66LWADFP.js";import{DEFAULT_FIELDS_WORDS as c}from"./chunk-FFYXVAAL.js";import{SettingsSegmented as d}from"./chunk-QLD57GBB.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{useTreeDrag as m,gapToMoveIndex as p}from"./chunk-67GNT6PF.js";import{withTip as h}from"./chunk-P2VEMZH5.js";import{Textarea as f,Input as b,SortableList as g,ListRow as v,ContextMenu as y,tabPanelId as k,Tabs as x,tabButtonId as w}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as N,useState as C,useLayoutEffect as O,useId as $}from"react";import{jsx as j,jsxs as D}from"react/jsx-runtime";import{ChevronIcon as I,LockIcon as S,MoveUpIcon as F,MoveDownIcon as P,DuplicateIcon as L,TrashIcon as M}from"efficient-shell/icons/efficient";function T({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:a=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */j(f,{id:e,size:"sm",className:"es-fin",value:c,rows:a,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */j(b,{id:e,size:"sm",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function A(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function H(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function E(e,n){return e.filter((e,t)=>t!==n)}function R(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var z='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Y({label:e,icon:r,noun:a,items:o,onChange:i,newItem:s,summary:d,itemName:f,thumb:b,min:k=0,max:x,readOnly:w=!1,open:$,onOpen:T,renderItem:Y,renderRow:J,canRemove:K,lockedReason:V,fixed:G=!1,removeOnRow:W=!0,canDuplicate:X,above:Z,head:q=!0}){const Q=u("fields",c).list,U=u("tree",t),_=a??Q.item,ee=!w&&!G&&("number"!=typeof x||o.length<x),ne=o.length<=k,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!G&&W&&!ne&&!te(e),re=e=>ee&&(!X||X(o[e],e)),ae=(e,n)=>f?f(e,n):Q.itemName({noun:_,n:n+1}),oe=N([]),ie=N(null),[se,ce]=C(null),de=N(null),[ue,me]=C(null),[pe,he]=C("");O(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(z)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(z)].indexOf(l),r=l;ie.current={index:n,nth:e,start:"number"==typeof r.selectionStart?r.selectionStart:null,end:"number"==typeof r.selectionEnd?r.selectionEnd:null}}i(H(o,e,n));const r=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}($,e,n);r!==$&&T(r),he(Q.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(A(o,e,s())),J?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&T($+1)):T(e))},ge=e=>{le(e)&&(i(E(o,e)),$===e?T(null):null!==$&&$>e&&T($-1))},ve=m({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=p({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:Q.moveUp,icon:/* @__PURE__ */j(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:Q.moveDown,icon:/* @__PURE__ */j(P,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),re(e)&&n.push({label:Q.duplicate,icon:/* @__PURE__ */j(L,{size:14}),onClick:()=>(e=>{re(e)&&(i(A(o,e+1,R(o[e]))),null!==$&&$>e&&T($+1))})(e)}),le(e)&&n.push({label:Q.delete,icon:/* @__PURE__ */j(M,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
|
|
2
2
|
return D("div",{className:"es-list",children:[q?/* @__PURE__ */D("div",{className:"es-list-head",children:[
|
|
3
|
-
/* @__PURE__ */D("span",{className:"es-list-label",children:[
|
|
4
|
-
/* @__PURE__ */j("span",{className:"es-list-count",children:
|
|
3
|
+
/* @__PURE__ */D("span",{className:"es-list-label",children:[r?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:r}):null,e]}),
|
|
4
|
+
/* @__PURE__ */j("span",{className:"es-list-count",children:o.length})]}):null,Z?/* @__PURE__ */j("div",{className:"es-list-above",children:Z}):null,o.length?/* @__PURE__ */D(g,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,t)=>{const l=ve.row({item:t,place:{...B,index:t}}),r=l.draggable&&se!==t,a=!J&&$===t,o=!w&&!G&&W&&te(t),i=["es-list-row",J?"is-inline":"is-item",a?"is-open":"",r?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[t>0?/* @__PURE__ */j(n,{...ve.seam({place:{...B,index:t}}),onAdd:ee?()=>be(t):void 0,label:Q.addHere({noun:_})},`seam-${t}`):null,
|
|
5
5
|
/* @__PURE__ */j(v,{className:i,flat:!!J,active:a,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(t,"up"===e?t-1:t+1):void 0,rowRef:e=>{oe.current[t]=e},rowProps:{...l.rowProps,draggable:r||void 0,onPointerDown:e=>{const n=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!n&&n===n.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!r,de.current=n&&!r?n:null,ce(r?t:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(t,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const n=e.currentTarget.ownerDocument,l=e=>e.preventDefault();n.addEventListener("contextmenu",l,{capture:!0,once:!0}),n.defaultView?.setTimeout(()=>n.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void ke(t,r.left+24,r.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||G||!W?void 0:o?h(V?V(e,t):Q.locked,/* @__PURE__ */j("span",{className:"es-list-lock",role:"img","aria-label":V?V(e,t):Q.locked,children:/* @__PURE__ */j(S,{size:13})})):h(Q.deleteItem({noun:_}),/* @__PURE__ */j("button",{type:"button",className:"es-list-x","aria-label":Q.deleteItem({noun:_}),disabled:!le(t),onClick:()=>ge(t),children:"×"})),below:a?/* @__PURE__ */j("div",{className:"es-list-item",children:Y(e,t,xe(t))}):void 0,children:J?/* @__PURE__ */j("div",{className:"es-list-row-main",children:J(e,t,xe(t))}):/* @__PURE__ */D("button",{type:"button",className:"es-list-open","aria-expanded":a,onClick:()=>T(a?null:t),children:[b?/* @__PURE__ */j("span",{className:"es-list-thumb","aria-hidden":"true",children:b(e,t)}):null,
|
|
6
|
-
/* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(e,t)}),/* @__PURE__ */j("span",
|
|
6
|
+
/* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(e,t)}),/* @__PURE__ */j("span",d?{className:"es-list-row-summary",children:d(e,t)}:{className:"es-list-row-summary"}),
|
|
7
7
|
/* @__PURE__ */j(I,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},t)]}),
|
|
8
|
-
/* @__PURE__ */j(n,{...ve.seam({place:{...B,index:
|
|
9
|
-
/* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<
|
|
10
|
-
/* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(
|
|
11
|
-
return j(
|
|
12
|
-
return j(Y,{label:J(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:h,onChange:r,newItem:()=>R({...e.defaultItemProps??{}}),summary:f?(e,n)=>f(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:m,onOpen:p,renderItem:(l,r,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(G,{field:c,name:`${n}[${r}].${e}`,id:`${t}-${r}-${e}`,value:l?.[e],onChange:n=>s({...l,[e]:n}),readOnly:a,context:o,renderers:i},e))})}function G(n){const{field:
|
|
13
|
-
return j(
|
|
14
|
-
return j(
|
|
15
|
-
return j(
|
|
16
|
-
return j(
|
|
17
|
-
return j(K,{...n,field:
|
|
18
|
-
return j(V,{...n,field:
|
|
19
|
-
return D("div",{className:"es-insp",children:[E?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":h??N.settings,idPrefix:I,value:M,onChange:e=>{const n=e;void 0===
|
|
8
|
+
/* @__PURE__ */j(n,{...ve.seam({place:{...B,index:o.length}})})]}):null,w||G?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:Q.add({noun:_})}),
|
|
9
|
+
/* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<o.length?
|
|
10
|
+
/* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(l,{items:ye(ue.index),onClose:()=>me(null)})}):null]})}var J=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function K({field:e,name:n,id:t,value:l,onChange:r,readOnly:a,context:i,renderers:s}){const[c,d]=C(!0),u=l&&"object"==typeof l?l:{};/* @__PURE__ */
|
|
11
|
+
return j(o,{id:`${t}-group`,title:J(e,n),open:c,onToggle:d,children:Object.entries(e.objectFields).map(([e,l])=>/* @__PURE__ */j(G,{field:l,name:`${n}.${e}`,id:`${t}-${e}`,value:u[e],onChange:n=>r({...u,[e]:n}),readOnly:a,context:i,renderers:s},e))})}function V({field:e,name:n,id:t,value:l,onChange:r,readOnly:a,context:o,renderers:i,openItem:s,onOpenItem:c}){const[d,u]=C(null),m=c?s??null:d,p=c??u,h=Array.isArray(l)?l:[],f=e.getItemSummary;/* @__PURE__ */
|
|
12
|
+
return j(Y,{label:J(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:h,onChange:r,newItem:()=>R({...e.defaultItemProps??{}}),summary:f?(e,n)=>f(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:m,onOpen:p,renderItem:(l,r,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(G,{field:c,name:`${n}[${r}].${e}`,id:`${t}-${r}-${e}`,value:l?.[e],onChange:n=>s({...l,[e]:n}),readOnly:a,context:o,renderers:i},e))})}function G(n){const{field:t,name:l,id:a,value:o,onChange:i,readOnly:c,context:u,renderers:m}=n;if(!t||t.marker||!1===t.visible)return null;const p=m?.[t.type];if(p)return p({field:t,name:l,id:a,value:o,onChange:i,readOnly:c});switch(t.type){case"custom":{const e={...u,field:t,name:l,id:a,value:o,onChange:i,readOnly:c};return t.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
13
|
+
return j(r,{label:J(t,l),htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(T,{id:a,value:"string"==typeof o?o:null==o?"":String(o),onChange:i,placeholder:t.placeholder,multiline:"textarea"===t.type,readOnly:c})});case"number":/* @__PURE__ */
|
|
14
|
+
return j(r,{label:J(t,l),htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(s,{id:a,value:"number"==typeof o?o:void 0,onChange:i,min:t.min,max:t.max,step:t.step,placeholder:t.placeholder,readOnly:c})});case"select":{const n=`${a}-label`;/* @__PURE__ */
|
|
15
|
+
return j(r,{label:J(t,l),labelId:n,htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(e,{id:a,value:o,options:t.options,onChange:i,readOnly:c,ariaLabelledBy:n})})}case"radio":/* @__PURE__ */
|
|
16
|
+
return j(r,{label:J(t,l),icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(d,{ariaLabel:J(t,l),value:o,options:t.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||c})),onChange:e=>{c||i(e)}})});case"object":/* @__PURE__ */
|
|
17
|
+
return j(K,{...n,field:t});case"array":/* @__PURE__ */
|
|
18
|
+
return j(V,{...n,field:t});case"slot":return null}}var W=e=>a.includes(e);function X(e){let n,t=a[0];const l=[],r=/* @__PURE__ */new Set;for(const[a,o]of Object.entries(e))o&&(W(o.bucket)&&((o.marker||o.bucket!==t)&&(n=void 0),t=o.bucket),o.marker&&"string"==typeof o.fold?n={key:a,title:o.fold}:o.marker&&!1===o.fold&&(n=void 0),o.marker||!1===o.visible||(l.push(n?{name:a,field:o,bucket:t,fold:n}:{name:a,field:o,bucket:t}),"slot"!==o.type&&r.add(t)));return{rows:l,buckets:a.filter(e=>r.has(e))}}function Z(e){return new Map(X(e).rows.map(e=>[e.name,e.bucket]))}function q(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function Q({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,tab:a,onTab:s,tabs:c=!0,tabIcons:d,renderers:m,idPrefix:p,ariaLabel:h,lead:f,children:b,leadFold:g,closedFolds:v,onFold:y}){const N=u("panel",i),O=$(),I=p??`es-insp${O.replace(/:/g,"")}`,S=X(e),[F,P]=C(void 0),L=a??F,M=L&&S.buckets.includes(L)?L:S.buckets[0],[T,A]=C(null),H=T&&T.panel===I&&S.rows.some(e=>e.name===T.name)?T:null,E=c&&S.buckets.length>1,R=E&&M?k(I,M):`${I}-rows`,[z,B]=C(()=>/* @__PURE__ */new Set),Y=v??z,J=(e,n)=>/* @__PURE__ */j(o,{title:e.title,open:!Y.has(e.key),onToggle:n=>((e,n)=>{void 0===v&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),y?.(e,n)})(e.key,n),id:`${I}-fold-${e.key}`,children:n}),K=e=>E&&e!==M,V=({name:e,field:a,bucket:o})=>/* @__PURE__ */j("div",{className:"es-insp-row","data-field":e,"data-bucket":o,hidden:!!K(o)||void 0,children:/* @__PURE__ */j(G,{field:a,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,renderers:m,openItem:H&&H.name===e?H.index:null,onOpenItem:n=>A(null===n?null:{panel:I,name:e,index:n})})},e);/* @__PURE__ */
|
|
19
|
+
return D("div",{className:"es-insp",children:[E?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":h??N.settings,idPrefix:I,value:M,onChange:e=>{const n=e;void 0===a&&P(n),s?.(n)},items:S.buckets.map(e=>{const n=N.buckets[e],t=d?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */j("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
|
|
20
20
|
/* @__PURE__ */D("div",{className:"es-insp-rows",id:R,role:E?"tabpanel":void 0,"aria-labelledby":E&&M?w(I,M):void 0,children:[f?g?/* @__PURE__ */j("div",{className:"es-insp-band","data-fold":g.key,children:J(g,f)}):f:null,q(S.rows).map((e,n)=>{if(!e.fold)return e.rows.map(V);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
|
|
21
21
|
return j("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!K(t)&&!l)||void 0,children:J(e.fold,e.rows.map(V))},`fold-${e.fold.key}-${n}`)}),b]})]})}export{T as FieldText,Q as Inspector,G as InspectorField,Y as ListField,Z as bucketsOf,R as copyItem,A as insertAt,J as labelOf,H as moveTo,X as planFields,E as removeAt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-PG3QGGTU.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-WF5IIVDD.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
|
|
2
2
|
return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-SOZUYCQZ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-CIHKZMNR.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f}from"./chunk-AWJUYMX7.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as k,replaceNode as b,createNode as S,insert as I,normalizeData as C,createResolveCache as E,resolveNodeData as x,ROOT_SLOT as D}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as P,useEffect as Z,useContext as z,useRef as K,useSyncExternalStore as R,useState as B,useMemo as N,useCallback as $,useLayoutEffect as j}from"react";import{jsx as L,jsxs as V}from"react/jsx-runtime";import{createPortal as F}from"react-dom";import{FloatingBar as H,TextToolbar as Y}from"efficient-shell/ui";function T(e){return!["setData","setUi","set"].includes(e.type)}var W=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},U=(e,t,n,o,r)=>{const i=W(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function q(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function X(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=J(e,t,n);if(o===e)return e;const r=X(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function J(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(q(e,n)):t.ui);case"set":{const r={data:o,ui:q(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:I(o,n,r,i)}}case"replace":{const r=U(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:b(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=U(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=W(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return J(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=W(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=U(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var _={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},te=0,ne=()=>`history-${te+=1}`;function oe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=C(e.data,t);let l={data:s,selection:null,ui:{...ee}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...ee,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:ne()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,m=null,v=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{v>0?w=w||n:(n?u(!1):l!==t&&S(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},D=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??T(e);I(n,o&&l.data!==n.data)},O=t=>{0===v&&(y=l,w=!1),v+=1;try{t()}catch(e){throw v-=1,0===v&&y&&(l=y,y=null),e}if(v-=1,v>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&S(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=X(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{..._,...a,...n}};let Z=P();const z=E(),K={resolveCache:z,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([x(r,t,{cache:z,trigger:e,metadata:n}),...i.map(o=>x(o,t,{cache:z,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=h(n,t,a)?.node;s&&s===h(o,t,a)?.node&&(n=b(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:X(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=h(l.data,t,e)?.node;if(!r)return!1;const i=await x(r,t,{cache:z,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(h(l.data,t,e)?.node!==r)return;const o=b(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:X(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&m===l)return f;const e=l,o={data:e.data,ui:q(e,t)},r="node"===e.selection?.kind?h(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>K.undo(),forward:()=>K.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:q(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:Z,getItemById:n=>h(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:X(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=C(e,t);l={...l,data:r,selection:X(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,Z=P(),f=null,k())},setConfig(e){e!==t&&(t=e,Z=P(),f=null,k())}};return K}function re(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ie=P(null),ae=P(!0);function se({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return Z(()=>{n&&e.resolveAll()},[e,n]),Z(()=>{if(t&&"undefined"!=typeof document)return re(document,e)},[e,t]),/* @__PURE__ */L(ie.Provider,{value:e,children:/* @__PURE__ */L(ae.Provider,{value:t,children:o})})}function le(){const e=z(ie);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ce(e){const t=le(),n=K({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return R(t.subscribe,o,o)}function de(){return function(e){return ce(e)}}var ue="data-puck-component",pe="data-puck-dropzone",fe={},he="data-es-mirror",me="undefined"==typeof window?Z:j;function ge(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${he}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(he,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ve({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=K(null),[h,m]=B(null);return me(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),me(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ge(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ge(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */L("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?F(t,h):null})}var ye=P(null),we=P(fe),ke=[];function be({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=le(),s=ce(n=>g(n.appState.data,a.config,{parentId:e,slot:t})??ke),l=ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=z(ye),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */L("div",{className:u.join(" "),[pe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */L(Ce,{node:e},e.props.id))})}function Se(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of O(A(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
1
|
+
import{toItemSelector as e,fromItemSelector as t,useNodeOps as n,parentStep as o,clickPick as r}from"./chunk-SOZUYCQZ.js";import{DEFAULT_CANVAS_WORDS as i}from"./chunk-TBY3DFKS.js";import{useResolvedFields as a}from"./chunk-YRLPFZW3.js";import{startCanvasTyping as s,textMap as l}from"./chunk-WQASXLXS.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f}from"./chunk-AWJUYMX7.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as k,replaceNode as b,createNode as S,insert as I,normalizeData as C,createResolveCache as E,resolveNodeData as x,ROOT_SLOT as D}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as P,useEffect as z,useContext as Z,useRef as B,useSyncExternalStore as K,useState as R,useMemo as $,useCallback as j,useLayoutEffect as N}from"react";import{jsx as L,jsxs as V}from"react/jsx-runtime";import{createPortal as F}from"react-dom";import{FloatingBar as Y,TextToolbar as H}from"efficient-shell/ui";function T(e){return!["setData","setUi","set"].includes(e.type)}var W=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},X=(e,t,n,o,r)=>{const i=W(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(t,n){const{selection:o}=t;return{...t.ui,itemSelector:e(t.data,n,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function q(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function Q(e,n,o,r=!1){const{itemSelector:i,selectedSlot:a,...s}=o;let l=e.selection;var c;return"itemSelector"in o&&(l=t(e.data,n,i??null)),"selectedSlot"in o&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=J(e,t,n);if(o===e)return e;const r=q(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function J(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:I(o,n,r,i)}}case"replace":{const r=X(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:b(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=X(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=W(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return J(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=W(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=X(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var _={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},te=0,ne=()=>`history-${te+=1}`;function oe(n){let o=n.config;const r=n.now??(()=>Date.now()),i=n.historyCoalesceMs??250;let a=n.permissions??{};const s=C(n.data,o);let l={data:s,selection:null,ui:{...ee}};if(n.ui){const{itemSelector:e,selectedSlot:r,...i}=n.ui;l={data:s,selection:r?{kind:"slot",...r}:t(s,o,e??null),ui:{...ee,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:ne()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,m=null,v=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(e,t)=>{v>0?w=w||t:(t?u(!1):l!==e&&S(),l.data!==e.data&&n.onChange?.(l.data),l!==e&&k())},D=e=>{const t=l;if(l=G(l,e,o),l===t)return;const n=e.recordHistory??T(e);I(t,n&&l.data!==t.data)},O=e=>{0===v&&(y=l,w=!1),v+=1;try{e()}catch(e){throw v-=1,0===v&&y&&(l=y,y=null),e}if(v-=1,v>0||!y)return;const t=y;y=null,w&&l.data!==t.data?u(!0):l!==t&&S(),l.data!==t.data&&n.onChange?.(l.data),l!==t&&k()},A=e=>{const t=l,n=q(l.data,o,e);var r,i;(r=n,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:n},I(t,!1))},M=e=>{const t=l;d=e,l=c[d].core,l.data!==t.data&&n.onChange?.(l.data),l!==t&&k()},P=()=>(e={})=>{const t=e.root?o.root?.permissions:o.components[e.item?.type??e.type??""]?.permissions;return{..._,...a,...t}};let z=P();const Z=E(),B={resolveCache:Z,async resolveAll({trigger:e="load",metadata:t}={}){const n=l.data,r={type:"root",props:{...n.root.props??{}}},i=[...n.content,...Object.values(n.zones??{}).flat()],[a,...s]=await Promise.all([x(r,o,{cache:Z,trigger:e,metadata:t}),...i.map(n=>x(n,o,{cache:Z,trigger:e,metadata:t}))]);O(()=>{const e=l;let t=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=h(t,o,a)?.node;s&&s===h(n,o,a)?.node&&(t=b(t,o,a,e.node))}),a.didChange&&t.root===n.root&&(t={...t,root:{...t.root,props:a.node.props,readOnly:a.node.readOnly??t.root.readOnly}}),t!==l.data&&(l={...l,data:t,selection:q(t,o,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:t="replace",metadata:n}={}){const r=h(l.data,o,e)?.node;if(!r)return!1;const i=await x(r,o,{cache:Z,trigger:t,metadata:n});if(!i.didChange)return!1;let a=!1;return O(()=>{const t=l;if(h(l.data,o,e)?.node!==r)return;const n=b(l.data,o,e,i.node);n!==l.data&&(l={...l,data:n,selection:q(n,o,l.selection)},I(t,!1),a=!0)}),a},get config(){return o},getState(){if(f&&m===l)return f;const t=l,n={data:t.data,ui:U(t,o)},r="node"===t.selection?.kind?h(t.data,o,t.selection.id)?.node??null:null;return f={appState:n,selection:t.selection,selectedItem:r,config:o,dispatch:D,history:{back:()=>B.undo(),forward:()=>B.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,o)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:z,getItemById:e=>h(t.data,o,e)?.node,getItemBySelector:e=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(t.data,o,e),getSelectorForId:n=>{const r=e(t.data,o,{kind:"node",id:n});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=t,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const t=l,n=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:q(e.data,o,n)},I(t,e.data!==t.data)})},load(e,t={}){const n=l,r=C(e,o);l={...l,data:r,selection:q(r,o,t.selection??l.selection)},t.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0),l!==n&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=P(),f=null,k())},setConfig(e){e!==o&&(o=e,z=P(),f=null,k())}};return B}function re(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ie=P(null),ae=P(!0);function se({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return z(()=>{n&&e.resolveAll()},[e,n]),z(()=>{if(t&&"undefined"!=typeof document)return re(document,e)},[e,t]),/* @__PURE__ */L(ie.Provider,{value:e,children:/* @__PURE__ */L(ae.Provider,{value:t,children:o})})}function le(){const e=Z(ie);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ce(e){const t=le(),n=B({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return K(t.subscribe,o,o)}function de(){return function(e){return ce(e)}}var ue="data-puck-component",pe="data-puck-dropzone",fe={},he="data-es-mirror",me="undefined"==typeof window?z:N;function ge(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${he}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(he,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ve({children:e,id:t="preview-frame",title:n,className:o,style:r,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",i),f=B(null),[h,m]=R(null);return me(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),me(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ge(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ge(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */L("iframe",{ref:f,id:t,title:n??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",o??""].filter(Boolean).join(" "),style:r,children:h?F(e,h):null})}var ye=P(null),we=P(fe),ke=[];function be({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=le(),s=ce(n=>g(n.appState.data,a.config,{parentId:e,slot:t})??ke),l=ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=Z(ye),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */L("div",{className:u.join(" "),[pe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */L(Ce,{node:e},e.props.id))})}function Se(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of O(A(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
2
2
|
return L(be,{parentId:n,slot:e,...t})};return i}function Ie(e){return function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
-
return L(be,{parentId:e,slot:t,...n})}}function Ce({node:e}){const t=le().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=
|
|
4
|
-
return L(we.Provider,{value:e??fe,children:i})}function xe(e,t,n){const[o,r]=
|
|
5
|
-
return L(
|
|
6
|
-
return L("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Pe({frame:
|
|
7
|
-
/* @__PURE__ */L(ye.Provider,{value:D,children:/* @__PURE__ */L(Ee,{metadata:
|
|
3
|
+
return L(be,{parentId:e,slot:t,...n})}}function Ce({node:e}){const t=le().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=B(null);return $(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ue),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ue,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),i=Z(we);if(!n?.render)return null;const a=n.render,s=Se(t,e.type,o,{...M(n),...e.props}),l={renderDropZone:Ie(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...i,...n.metadata}};return n.inline?/* @__PURE__ */L(a,{...s,puck:l,editMode:!0}):/* @__PURE__ */L("div",{[ue]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */L(a,{...s,puck:l,editMode:!0})})}function Ee({metadata:e}){const t=ce(e=>e.config),n=ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */L(be,{parentId:m,slot:D}),i=o?/* @__PURE__ */L(o,{id:"puck-root",...Se(t,"root",m,n),puck:{renderDropZone:Ie(m),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
|
|
4
|
+
return L(we.Provider,{value:e??fe,children:i})}function xe(e,t,n){const[o,r]=R(null),i=B(t);return i.current=t,me(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function De({id:e,kind:t,overlay:n}){const o=B(null),r=xe(o,e?t=>t.querySelector(`[${ue}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */L("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */L(n,{componentId:e,kind:t,children:i}):i}function Oe(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Ae({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
|
|
5
|
+
return L(Y,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */L("div",{style:{width:"18rem"},children:/* @__PURE__ */L(H,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase})})})}function Me({element:e}){const t=B(null),n=xe(t,()=>e(),e);/* @__PURE__ */
|
|
6
|
+
return L("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Pe({frame:e=!0,className:t,style:n,metadata:a,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w}){const k=le(),b=Z(ae),S=c("canvas",i),I=m??b,[C,E]=R(void 0),x=ce(e=>"node"===e.selection?.kind?e.selection.id:null),[D,O]=R(null),[A,M]=R(null),P=B(null),[,K]=R(0),$=B(w);$.current=w;const j=B(null),N=e=>{const t=j.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},F=(e,t)=>{P.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Oe(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>K(e=>e+1),end:e=>{o.close(),P.current?.element===r&&(P.current=null),M(null),N(!1),$.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${ue}]`)?.getAttribute(ue);return a&&k.select(a),P.current={s:i,element:r,target:e},M(()=>r),O(null),N(!0),$.current?.onChange?.({typing:!0,element:n}),!0};z(()=>()=>P.current?.s.stop("stop"),[]);const Y=e=>{const t=P.current?.element();return Boolean(t&&t.contains(e))},H=e=>{const t=e.closest?.(`[${ue}]`)?.getAttribute(ue);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null;return r(n.appState.data,k.config,t,o)??t},T=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(P.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button, a[href]"))return;const n=$.current?.atSelection?.();n&&F(n,null)&&e.preventDefault()},W=/* @__PURE__ */V("div",{ref:j,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),P.current){if(Y(t))return;P.current.s.stop("outside")}const n=H(t);void 0===n?t.hasAttribute?.(pe)||k.select(null):k.select(n)},onDoubleClick:e=>{const t=$.current;if(!t||Y(e.target))return;const n=t.at(e.target);n&&F(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>T(e),onMouseOver:e=>{if(P.current)return;const t=H(e.target)??null;t!==D&&O(t)},onMouseLeave:()=>O(null),children:[
|
|
7
|
+
/* @__PURE__ */L(ye.Provider,{value:D,children:/* @__PURE__ */L(Ee,{metadata:a})}),
|
|
8
8
|
/* @__PURE__ */V("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
9
|
/* @__PURE__ */L(De,{id:!A&&D&&D!==x?D:null,kind:"hover",overlay:v}),
|
|
10
|
-
/* @__PURE__ */L(De,{id:A?null:x,kind:"selected",overlay:v}),A?/* @__PURE__ */L(Me,{element:A}):null]}),y]}),
|
|
11
|
-
return V("div",{className:"es-canvas"+(
|
|
10
|
+
/* @__PURE__ */L(De,{id:A?null:x,kind:"selected",overlay:v}),A?/* @__PURE__ */L(Me,{element:A}):null]}),y]}),X=g?/* @__PURE__ */L(g,{document:C,children:W}):W;z(()=>{if(C&&I)return re(C,k)},[C,I,k]),z(()=>{if(!C)return;const e=e=>{if("Enter"===e.key)return void T(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=k.getState();if("node"!==n.selection?.kind)return;const r=o(n.appState.data,k.config,n.selection);"node"===r?.kind&&k.select(r.id)};return C.addEventListener("keydown",e),()=>C.removeEventListener("keydown",e)},[C,k]);/* @__PURE__ */
|
|
11
|
+
return V("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"","data-es-typing":A?"":void 0,children:[A&&P.current?.target.toolbar?/* @__PURE__ */L(Ae,{s:P.current.s,element:P.current.element,toolbar:P.current.target.toolbar,label:S.textTools}):null,e?/* @__PURE__ */L(ve,{mirrorStyles:l,onDocument:e=>{E(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:X}):/* @__PURE__ */L("div",{id:"preview-frame","data-puck-entry":"",children:X})]})}function ze(e={}){const t=le(),o=ce(e=>e.appState.data);return n({...e,data:o,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ze(){const e=le(),t=ce(e=>e.config),n=e.resolveCache,o=ce(e=>e.selectedItem),r=ce(e=>e.appState.data.root),i=o?o.props.id:"root",s=r.props??{},l=$(()=>o||{type:"root",props:s},[o,s]),c=o?t.components[o.type]:t.root,d=e.getState(),u=o?h(d.appState.data,t,i):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:m}=a({id:i,node:l,block:c,parent:f,appState:d.appState}),g=ce(e=>!1===e.getPermissions(o?{item:o}:{root:!0}).edit),v=j((o,r)=>{(async()=>{const a=e.getState();if("root"!==i){const s=a.getItemById(i),l=a.getSelectorForId(i);if(!s||!l)return;const c={...s,props:{...s.props,[o]:r}},{node:d}=await x(c,t,{cache:n,trigger:"replace"}),u=e.getState().getSelectorForId(i);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:d})}const s=a.appState.data.root.props??{},{node:l}=await x({type:"root",props:{...s,[o]:r}},t,{cache:n,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:l.props,readOnly:l.readOnly},recordHistory:!0})})()},[e,t,n,i]);return{id:i,node:l,fields:m,values:l.props,readOnly:g,onChange:v}}export{ve as CanvasFrame,ee as DEFAULT_UI,Pe as EaselCanvas,se as EaselProvider,Ee as EditDocument,re as bindUndoKeys,oe as createEasel,de as createUseEasel,T as recordsByDefault,G as reduce,U as uiView,ce as useEasel,le as useEaselApi,ze as useEaselNodeOps,Ze as useSelectedFields,q as validSelection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as s,setList as a,isSafeLinkHref as c}from"./chunk-546BBOPE.js";var u=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),d=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function h(l,o){const i=o.rules??t,s=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const s=[[]],a=()=>s[s.length-1],h=()=>{const t=a();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&s.push([])},p=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=a();" "===t&&(0===o.length&&s.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(u.has(o))return;if("br"===o)return void s.push([]);let i=e,f=n,m=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(f=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();m=c(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?f=!0:"normal"===g.fontStyle&&(f=!1)}const b=d.has(o);b&&h();for(const e of[...t.childNodes])p(e,i,f,m);b&&h()};p(i.content,!1,!1,null);for(;s.length>1&&0===s[s.length-1].length;)s.pop();return s.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const s of i){const i=f(t,s.bold?o("bold"):null,s.italic?o("italic"):null,s.links),a=e([i]).text;if(n([i],r(a,l)))return a}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?s.join("\n"):1===s.length?s[0]:s.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function f(t,e,n,r){let o=0,i=null,s=null,a=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),s=e?.[c]?s??l(++o,"bold"):null,a=n?.[c]?a??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,s,a].filter(t=>null!==t)}})}}var p="application/x-efficient-markup",m=/^([0-9]{1,3})\. $/;function g(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const s=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:m.exec(n[e]),s=t.bullet||r,a=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=a?a.length+2:s?2:0,h={bullet:s,number:a,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:s,text:s.map(t=>t.text).join("\n")}}function b(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function k(t,e){const[n,r]=b(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function x(t,e){const[n,r]=b(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return k(t,e)}function v(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function y(t,e,n){return[v(t,e),v(t,n)]}function w(t,e,n){return e===n?[k(t,e),k(t,e)]:[x(t,e),k(t,n)]}function D(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function T(t,o,i,s,a){const c=g(t,o),[u,d,h]=b(c,Math.min(i,s)),[f,p,m]=b(c,Math.max(i,s)),k=D(u,d),x=D(f,p),v=u.chars.slice(0,k),y=f.chars.slice(x),w=i!==s&&u.chars[k]&&(h!==m||k<x)?u.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,k);let T=(A=c.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const M=t=>{let e;if(void 0!==a.markup){const t=T;e=r(a.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(a.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...y]}}else l.chars.push(...y);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},E=void 0!==a.markup?[null]:[(t=>{let e=t.filter(t=>!a.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of a.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==a.color){e=e.filter(t=>"color"!==t.kind);const t=null===a.color?null:l(T++,"color",a.color);t&&(e=[...e,t])}return e})(w),w,[]];let N="",S="";for(const t of E){const r=M(t),l=e(r.lines).text;if(N=l,S=r.shown,n(r.lines,g(l,o).lines))break}return{text:N,caret:Math.min(i,s)+S.length}}function A(t,e,n,r){const l=g(t,e),[o,,i]=b(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?T(t,e,n,r,{text:"\n"}):M(t,e,i,!1,n)}function M(t,n,r,l,o){const i=g(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function E(t,n,r,l){const o=g(t,n),[i,s,a]=b(o,Math.min(r,l)),[c,u,d]=b(o,Math.max(r,l)),h=o.lines.slice(a,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?D(i,s):0,o=r===d-a?D(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function N(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function S(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,s]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,s]=t.target);const a=[i,s];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:A(e,n,i,s),range:a}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=h({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:T(e,n,i,s,{markup:l}),range:a}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:T(e,n,i,s,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:a}}if(l.startsWith("delete")){const t=g(e,n),r=t.text;if(i===s){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:M(e,n,c,!1,i),range:a};if(o?0===i:i===r.length)return null;o?i=N(r,i,-1):s=N(r,s,1)}return{kind:"type",edit:T(e,n,i,s,{text:""}),range:[i,s]}}return null}var B=1e3;function C(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,s){const a="type"===i&&"type"===r&&s-l<1e3;r=i,l=s,n=[],a||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var j={sup:"sub",sub:"sup"};function q(t){const{value:e,rules:n,start:r,end:l,style:s,pending:a}=t,c=j[s];if(r===l){const t=o(e,r,l,n),i=a&&a.at===r?a:null,u=t.has(s),d=!!i?.add.includes(s)||!i?.drop.includes(s)&&u;let h=(i?.add??[]).filter(t=>t!==s),f=(i?.drop??[]).filter(t=>t!==s);return d&&u?f.push(s):d||u||h.push(s),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let u=e,d=r,h=l;if(c&&!o(u,d,h,n).has(s)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,s,n)}}var F=/^(block|list-item|flex|grid|table|flow-root)$/;function L(t){const e=t.ownerDocument.defaultView;return!!e&&F.test(e.getComputedStyle(t).display)}function O(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const s=()=>{i&&(o+="\n",i=!1)},a=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&s(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){s(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=L(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;a(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),a(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function P(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(O(e,t.skip).text!==g(n,r).text)return null;const l=t.now??(()=>Date.now()),i=C();let c=e,u=!1,d=null,f=null,m=[t.caret[0],t.caret[1]],b=null;const k=()=>t.onSelect?.(),x={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},v=()=>c.ownerDocument,D=()=>v().defaultView?.getSelection()??null,A=()=>{if(!f)return!0;J();const e=O(c,t.skip);if(e.text!==g(n,r).text)return!1;const[l,o]=f,[i,s]=e.dom(l),[a,u]=e.dom(o);return v().activeElement!==c&&c.focus({preventScroll:!0}),D()?.setBaseAndExtent(i,s,a,u),m=f,M=f,f=null,k(),!0};let M=null;const N=()=>{if(!M)return!1;const t=D(),e=t?.anchorNode??null;return!(e&&e.isConnected&&c.contains(e))||e===c&&0===t.anchorOffset&&(0!==M[0]||0!==M[1])},B=()=>{f=M,A()},j=()=>{A(),v().activeElement===c&&N()&&B();const e=D();if(!(e&&e.anchorNode&&e.focusNode&&c.contains(e.anchorNode)&&c.contains(e.focusNode)))return m;const n=O(c,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return m=r<=l?[r,l]:[l,r],m},F=t=>{const e=v().defaultView;t<=0||!e?M=null:e.requestAnimationFrame(()=>{u||f||(J(),v().activeElement===c?(N()&&(B(),k()),F(t-1)):M=null)})},L=(t,e)=>{f=[t,e];const n=t=>{if(u)return;if(A())return void F(3);const e=v().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},P=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),L(e.caret,e.caret),k()):L(e.caret,e.caret)},V=t=>w(g(n,r),t[0],t[1]),W=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[s,a]=y(g(n,r),e.selectionStart,e.selectionEnd);L(s,a),k()},I=t=>{if(u)return;const e=j(),[l,o]=V(e),i=q({value:n,rules:r,start:l,end:o,style:t,pending:b});if("pending"===i.kind)return b=i.pending,void k();W(i.result,e)},K=e=>{n=e.text,t.write(n),L(e.start,e.end)},R=e=>{u||(u=!0,Q.removeEventListener("selectionchange",X),G(c),t.end(e))},U=(t,e)=>{const l=j();!u&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",g(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(p,E(n,r,l[0],l[1])),e&&P(T(n,r,l[0],l[1],{text:""}),l,"edit"))},$=t=>t.preventDefault(),z=()=>{t.remount?.()},H=[["keydown",t=>{if(u||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void R("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void R("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=j(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?i.redo(r):i.undo(r);l&&K(l)}}],["beforeinput",e=>{if(u)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=j(),o=O(c,t.skip),s="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,a=s&&!s.collapsed?[o.at(s.startContainer,s.startOffset),o.at(s.endContainer,s.endOffset)]:null,d=S({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:v(),sel:l,target:a,pending:b&&b.at===V(l)[0]?b:null});if(d){if("type"!==d.kind&&"edit"!==d.kind||(b=null),"history"===d.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===d.dir?i.undo(t):i.redo(t);return void(e&&K(e))}"format"!==d.kind?P(d.edit,d.range,d.kind):I(d.style)}}],["compositionstart",()=>{d=j()}],["compositionend",e=>{const o=d;if(d=null,!u&&o)if(e.data){const s=T(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=s.text,t.write(n),z(),L(s.caret,s.caret)}else z(),L(o[0],o[0])}],["paste",e=>{if(u)return;e.preventDefault();const l=j(),o=e.clipboardData,i=o?.getData(p)??"",s=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):h({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:v(),multiline:t.multiline,rules:r});P(T(n,r,l[0],l[1],{markup:s}),l,"edit")}],["copy",t=>U(t,!1)],["cut",t=>U(t,!0)],["drop",$],["dragstart",$],["blur",e=>{if(u||null!==d)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{u||(n.isConnected&&n===t.element()?n.ownerDocument.activeElement!==n&&R("blur"):L(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}]];function Z(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of H)t.addEventListener(e,n)}function G(t){for(const[e,n]of H)t.removeEventListener(e,n);null===x.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",x.contenteditable),null===x.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",x.spellcheck),t.removeAttribute("data-es-typing")}function J(){const e=t.element();e&&e!==c&&(G(c),c=e,Z(c))}const Q=c.ownerDocument;function X(){u||k()}return Q.addEventListener("selectionchange",X),Z(c),c.focus({preventScroll:!0}),L(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=g(t,r).text.length,[l,o]=j();n=t,i.reset(),L(Math.min(l,e),Math.min(o,e))},stop(t="stop"){R(t)},pressed(){const[t,e]=V(j()),l=o(n,t,e,r),i={};for(const e of["bold","italic","underline","strike","sup","sub","link"]){const n=l.has(e),r=b&&b.at===t?b:null;i[e]=!!r?.add.includes(e)||!r?.drop.includes(e)&&n}return{marks:i,list:s(n,t,e,r)}},press:I,list(e){if(u||!t.multiline)return;const l=j(),[o,i]=V(l),c=s(n,o,i,r);W(a(n,o,i,c===e?null:e,r),l)}}}export{p as MARKUP_CLIPBOARD_TYPE,B as TYPING_BURST_MS,C as createHistory,T as editVisible,q as markPress,E as markupOfRange,A as newLine,h as pasteToMarkup,S as richInput,g as richLayout,w as selectionToSource,y as selectionToVisible,M as setBullet,P as startCanvasTyping,O as textMap,k as toSource,x as toSourceStart,v as toVisible};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-M6F6LS3H.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{
|
|
1
|
+
import{DEFAULT_TEXT_STYLES_WORDS as o}from"./chunk-M6F6LS3H.js";import{DEFAULT_PICK_WORDS as r}from"./chunk-ZAOM6PFH.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{DEFAULT_NODE_MENU_WORDS as m}from"./chunk-WK3AFPXY.js";import{DEFAULT_SCREEN_WORDS as n}from"./chunk-5F3PKNT7.js";import{DEFAULT_CANVAS_WORDS as c}from"./chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as s}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as f}from"./chunk-KFV7N2DJ.js";import{DEFAULT_SAVE_WORDS as p}from"./chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as e,DEFAULT_NOTICE_WORDS as i}from"./chunk-Y2G7CU6A.js";import{DEFAULT_LOCK_WORDS as u}from"./chunk-RE4LP46F.js";import{DEFAULT_RAIL_WORDS as k}from"./chunk-2OAZYSWJ.js";import{DEFAULT_COPY_WORDS as j}from"./chunk-AUT242JK.js";import{DEFAULT_FIELDS_WORDS as h}from"./chunk-FFYXVAAL.js";import{DEFAULT_DRAG_WORDS as l}from"./chunk-O2NLQBFX.js";var F={notice:i,lock:u,save:p,chrome:e,rail:k,tree:s,panel:f,fields:h,pick:r,drag:l,menu:m,styleClipboard:t,copy:j,canvas:c,textStyles:o,screen:n},a=o=>"object"==typeof o&&null!==o;function Y(o,r){const t={};for(const m of Object.keys(o)){const n=o[m],c=r[m];null==c?t[m]=n:a(n)?t[m]=a(c)?Y(n,c):n:t[m]=typeof c==typeof n?c:n}return t}function y(o,r){return r?Y(o,r):o}export{F as DEFAULT_EASEL_STRINGS,y as mergeEaselStrings};
|
package/dist/copy/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { C as CopyWords, a as CopyAlign } from '../words-BAnsDT16.js';
|
|
|
5
5
|
export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-BAnsDT16.js';
|
|
6
6
|
import { TextToolbarCase, TextToolbarMark } from 'efficient-shell/ui';
|
|
7
7
|
export { TextToolbar, TextToolbarProps } from 'efficient-shell/ui';
|
|
8
|
-
export { C as CanvasTypingEnd, a as CanvasTypingOptions, b as CanvasTypingSession, T as TextMap, s as startCanvasTyping, t as textMap } from '../canvas-typing-
|
|
8
|
+
export { C as CanvasTypingEnd, a as CanvasTypingOptions, b as CanvasTypingSession, T as TextMap, s as startCanvasTyping, t as textMap } from '../canvas-typing-Cnvlsh_V.js';
|
|
9
9
|
|
|
10
10
|
type CellWords = NonNullable<CopyWords['cells']>;
|
|
11
11
|
interface CopyCell {
|
package/dist/copy/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,markPress as o,pasteToMarkup as a,richInput as s,editVisible as i,MARKUP_CLIPBOARD_TYPE as c,markupOfRange as u}from"../chunk-
|
|
1
|
+
import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,markPress as o,pasteToMarkup as a,richInput as s,editVisible as i,MARKUP_CLIPBOARD_TYPE as c,markupOfRange as u}from"../chunk-WQASXLXS.js";export{MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-WQASXLXS.js";import{FieldNumber as d}from"../chunk-66LWADFP.js";import"../chunk-FFYXVAAL.js";import{GoldTextInput as p}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as f,applyMark as h,markupTools as m,marksIn as g,STANDARD_MARKUP as y,findLink as v,markedAt as b,listIn as k,colorIn as x,spanFor as w,clearStyle as S,toggleMark as E,colorOver as C,setList as D,unlinkAt as N,removeLink as L,linkOver as T,writeLink as M}from"../chunk-546BBOPE.js";import{SettingsSegmented as R,SettingsSwitch as B}from"../chunk-QLD57GBB.js";import{useWords as P}from"../chunk-MFIRYGHW.js";import{withTip as O}from"../chunk-P2VEMZH5.js";import{Tooltip as z,ColorSwatch as K,ColorPickerPanel as F,Button as W,IconButton as $,registerModalEscapeInterceptor as j,textToolbarRows as H,TextToolbar as A,LinkPicker as V}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as I,useState as U,useLayoutEffect as q,useEffect as X,useId as Y}from"react";import{AlignJustifyIcon as _,AlignRightIcon as G,AlignCenterIcon as Q,AlignLeftIcon as Z,ParagraphSpacingIcon as J,LetterSpacingIcon as ee,TextLinesIcon as te,TextSizeIcon as ne,ClearMarksIcon as re,LinkIcon as le,QuietIcon as oe,EmphasisIcon as ae,StrikeIcon as se,ItalicIcon as ie,BoldIcon as ce}from"efficient-shell/icons/efficient";import{jsx as ue,jsxs as de,Fragment as pe}from"react/jsx-runtime";var fe=["left","center","right","justify"],he=e.align,me={left:/* @__PURE__ */ue(Z,{}),center:/* @__PURE__ */ue(Q,{}),right:/* @__PURE__ */ue(G,{}),justify:/* @__PURE__ */ue(_,{})},ge={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function ye(e,t=he){return fe.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:me[e],title:t[e]}))}var ve=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function be(e){if(e.every(e=>e.label===he[e.id]))return e.length>3?ge.four:ge.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(ve.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=h){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Se(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ee(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function Ce(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function De({value:e,rules:l,multiline:o,readOnly:d=!1,placeholder:p,ariaLabel:f,handle:h,onEdit:m,onSelect:g,onHistory:y,onFormat:v,pending:b,onCommit:k,onCancel:x}){const w=I(null),S=I(null),E=I(null),C=I(null),D=I(null),N=I(e),[L,T]=U(0),M=I({value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v});M.current={value:e,rules:l,multiline:o,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v};const R=()=>{const e=w.current,t=S.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ee(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ee(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},B=(e,t)=>{const n=w.current,r=S.current;if(!n||!r)return;const[l,o]=Ce(r,e),[a,s]=Ce(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};h.current={getSource(){const e=R(),t=S.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},T(e=>e+1)},focus(){w.current?.focus()},rangeOf(e,n){const r=w.current,l=S.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,i]=Ce(l,o),[c,u]=Ce(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},q(()=>{const n=w.current;if(!n||D.current)return;const o=C.current?null:R();S.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Se(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&B(o[0],Math.min(o[1],S.current.layout.text.length)));C.current=null;const s=S.current.layout,[i,c]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),B(i,c)},[e,l,L]);const P=(e,t,r)=>{const l=S.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==M.current.value?M.current.onEdit(e.text,{start:o,end:a},r):T(e=>e+1)};X(()=>{const e=w.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=M.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const i=S.current,c=R();if(!i||!c)return;const u="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,d=u&&!u.collapsed?[Ee(i,e,u.startContainer,u.startOffset),Ee(i,e,u.endContainer,u.endOffset)]:null,p=s({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:d,pending:a});p&&("history"!==p.kind?"format"!==p.kind?P(p.edit,p.range,p.kind):M.current.onFormat(p.style):M.current.onHistory(p.dir))},n=()=>{D.current||T(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),X(()=>{const e=w.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=h.current?.getSource();e&&g(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const O=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=S.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(c,u(e,l,r[0],r[1])),n&&!d&&P(i(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
|
|
2
2
|
return de("div",{className:"es-rich-wrap",children:[p&&""===e?/* @__PURE__ */ue("div",{className:"es-rich-placeholder","aria-hidden":"true",children:p}):null,
|
|
3
|
-
/* @__PURE__ */ue("div",{ref:w,className:`es-rich${o?" is-multiline":" is-single"}${d?" is-off":""}`,contentEditable:!d,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":f,"aria-readonly":d||void 0,"aria-placeholder":p,tabIndex:d?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&k?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),x?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&k?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=M.current;e.data?P(i(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):T(e=>e+1)},onCopy:e=>O(e),onCut:e=>O(e,!0),onPaste:t=>{if(t.preventDefault(),d)return;const n=R();if(!n)return;const r=t.clipboardData.getData(c),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):a({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});P(i(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Ne={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ue(ne,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ue(te,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ue(ee,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ue(
|
|
3
|
+
/* @__PURE__ */ue("div",{ref:w,className:`es-rich${o?" is-multiline":" is-single"}${d?" is-off":""}`,contentEditable:!d,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":f,"aria-readonly":d||void 0,"aria-placeholder":p,tabIndex:d?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&k?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),x?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&k?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=M.current;e.data?P(i(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):T(e=>e+1)},onCopy:e=>O(e),onCut:e=>O(e,!0),onPaste:t=>{if(t.preventDefault(),d)return;const n=R();if(!n)return;const r=t.clipboardData.getData(c),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):a({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});P(i(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Ne={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ue(ne,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ue(te,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ue(ee,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ue(J,{}),unit:"px",step:1,shiftStep:10,min:0}};function Le(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:t,words:n,readOnly:r=!1}){const l=n??e.cells;/* @__PURE__ */
|
|
4
4
|
return ue("div",{className:"es-copy-cells",children:t.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?l[e.nameKey]:e.key),o=e.unit??"",a=e.step??1;/* @__PURE__ */
|
|
5
5
|
return ue(d,{value:Le(e.value,t),styleValue:Le(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:a,shiftStep:e.shiftStep,icon:e.icon,unit:o||void 0,steppers:"compact",readOnly:r,ariaLabel:n,title:l.tip({name:n,step:a,unit:o})},e.key)})})}var Me=e=>e.preventDefault();function Re({colors:e,current:t,words:n,onPick:r}){const l=null===t?null:t.startsWith("#")?t.toLowerCase():e.find(e=>e.name===t)?.value.toLowerCase()??null;/* @__PURE__ */
|
|
6
6
|
return de("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:e=>{"INPUT"!==e.target.tagName&&e.preventDefault()},children:[
|
|
7
7
|
/* @__PURE__ */ue("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
8
8
|
/* @__PURE__ */ue("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:e.map(e=>/* @__PURE__ */ue(z,{content:`${e.label} · ${e.value.toUpperCase()}`,children:/* @__PURE__ */ue(K,{color:e.value,size:"sm",className:"es-copy-theme-swatch","data-color":e.name,"aria-label":e.label,selected:t===e.name,onMouseDown:Me,onClick:()=>r(e.name)})},e.name))}),
|
|
9
9
|
/* @__PURE__ */ue("span",{className:"es-copy-pop-label",children:n.any}),
|
|
10
|
-
/* @__PURE__ */ue(
|
|
11
|
-
/* @__PURE__ */ue("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ue(
|
|
12
|
-
/* @__PURE__ */ue("span",{className:"es-copy-bar-split","aria-hidden":"true"}),l]}):null,o?/* @__PURE__ */ue("span",{className:"es-copy-bar-end",children:o}):null]}):null}function
|
|
13
|
-
return de("div",{ref:yt,className:"es-copy"+(d?` ${d}`:""),onFocus:()=>ve(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ve(!1)},onKeyDown:e=>{const t=e.target===me.current||Boolean(e.target.closest?.(".es-rich"));if(
|
|
14
|
-
/* @__PURE__ */ue(A,{className:"es-copy-toolbar","aria-label":
|
|
10
|
+
/* @__PURE__ */ue(F,{className:"es-copy-any",value:l??"",onChange:e=>{e!==t&&r(e)},label:n.title,dragWrites:"end"}),
|
|
11
|
+
/* @__PURE__ */ue("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ue(W,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:Me,onClick:()=>r(null),children:n.remove})})]})}var Be=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var Pe=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function Oe(e){const t=e.ownerDocument,n=t.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=t.defaultView?.getComputedStyle.bind(t.defaultView);for(let o=e.parentElement;o&&o!==n&&o!==t.body;o=o.parentElement){const e=l?.(o);if(!e||"visible"===e.overflowX&&"visible"===e.overflowY)continue;const t=o.getBoundingClientRect();if(0===t.width&&0===t.height)continue;const n=t.left+o.clientLeft,a=t.top+o.clientTop;r.left=Math.max(r.left,n),r.top=Math.max(r.top,a),r.right=Math.min(r.right,n+(o.clientWidth||t.width)),r.bottom=Math.min(r.bottom,a+(o.clientHeight||t.height))}return r}function ze(e){const t=e.offsetParent??e.parentElement;if(!t)return{left:0,top:0};const n=t.getBoundingClientRect();return{left:n.left+t.clientLeft-t.scrollLeft,top:n.top+t.clientTop-t.scrollTop}}var Ke=/* @__PURE__ */new Set([...f,"clear"]),Fe={bold:/* @__PURE__ */ue(ce,{size:16}),italic:/* @__PURE__ */ue(ie,{size:16}),strike:/* @__PURE__ */ue(se,{size:16}),highlight:/* @__PURE__ */ue(ae,{size:16}),quiet:/* @__PURE__ */ue(oe,{size:16}),link:/* @__PURE__ */ue(le,{size:16}),clear:/* @__PURE__ */ue(re,{size:16})};function We(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var $e={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function je({tools:t,onApply:n,disabled:r=!1,actions:l,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=P("copy",e),d=("string"==typeof t[0]?m(t).map(e=>({...e,...u.marks[e.style]})):t).filter(e=>!Ke.has(e.style));return 0!==d.length||l||o?/* @__PURE__ */de("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??Fe[e.style],l=c===e.style||Boolean(i?.[e.style]),o="link"===e.style&&Boolean(i);return O(e.title,/* @__PURE__ */ue($,{onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:r,"aria-label":e.name??e.title,"aria-keyshortcuts":We(e.shortcut),"aria-pressed":o||!i&&!c?void 0:l,pressed:o?l:void 0,"aria-haspopup":o?"dialog":void 0,"aria-expanded":o?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":$e[e.style]?` ${$e[e.style]}`:""}${l?" is-active":""}`,children:t??e.label},e.style))}),l?/* @__PURE__ */de(pe,{children:[
|
|
12
|
+
/* @__PURE__ */ue("span",{className:"es-copy-bar-split","aria-hidden":"true"}),l]}):null,o?/* @__PURE__ */ue("span",{className:"es-copy-bar-end",children:o}):null]}):null}function He({target:e,onChange:t}){const n=I(null);return q(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Ae=["bold","italic","underline","strike","sup","sub"];function Ve({value:t,onChange:n,onCommit:r,onCancel:s,multiline:i=!1,placeholder:c,ariaLabel:u,className:d,readOnly:f=!1,rules:z,tools:K=[],writeMark:F,actions:$,align:_,glyphs:G,barLabel:Q,renderFooter:Z,inputRef:J,barShows:ee="always",richText:te=!0,defaultShowMarks:ne=!1,toolbar:le="final",colors:oe,cells:ae,letterCase:se,lastTool:ie}){const ce="final"===le,fe=P("copy",e),he=I(null),me=J??he,[ge,ve]=U(!1),[ke,Se]=U(null),Ee=I(l()).current,Ce=I(null);X(()=>{const e=Ce.current;e&&t===e.to?Ce.current=null:e&&t===e.from||(Ce.current=null,Ee.reset())},[t,Ee]);const Ne=e=>{Ce.current={from:Ce.current?.from??t,to:e},n(e)},Le=e=>({text:t,start:e?.selectionStart??ke?.start??t.length,end:e?.selectionEnd??ke?.end??t.length}),[Me,Fe]=U(ne),We=te&&!(i&&Me),$e=I(null),Ve=Y(),[Ie,Ue]=U(null),[qe,Xe]=U(!1),Ye=()=>{if(!We)return me.current;const e=$e.current?.getSource()??ke;return e?{selectionStart:e.start,selectionEnd:e.end}:null},_e=He({target:me,onChange:Ne}),Ge=e=>(Se({start:e.selectionStart,end:e.selectionEnd}),e),Qe=(e,n)=>{if(!We)return void _e(t=>(n&&Ee.record(Le(t),"edit",Date.now()),Ge(e(t))));const r=Ye(),l=Ge(e(r));n&&Ee.record(Le(r),"edit",Date.now()),Ue(null),l.text!==t&&Ne(l.text),$e.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ze=e=>Qe(e,!0),Je=e=>Qe(t=>{const n=Le(t),r=Ee[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),et=I(null);q(()=>{const e=et.current;e&&(et.current=null,We?$e.current?.setSource(e.start,e.end,t):(me.current?.focus(),me.current?.setSelectionRange(e.start,e.end),Se(e)))},[We]);const[tt,nt]=U(null),rt=z??y,lt=("string"==typeof K[0]?m(K):K).filter(e=>!Ke.has(e.style)),ot=ce?("string"==typeof K[0]?K:K.map(e=>e.style)).filter(e=>!Ke.has(e)):lt.map(e=>e.style),at={};if(ke&&(We||ce)){const e=g(t,ke.start,ke.end,rt);for(const t of ot){const n=e.has(t)||"highlight"===t&&e.has("accent");at[t]=!!Ie?.add.includes(t)||!Ie?.drop.includes(t)&&n}ce&&(at.link=e.has("link"))}else if(ke)for(const e of ot)at[e]="link"===e?null!==v(t,ke.start,ke.end):b(t,ke.start,ke.end,e);const st=()=>{const e=Ye(),n=e?.selectionStart??t.length;return{start:n,end:e?.selectionEnd??n}},it=e=>{if(ce&&"link"!==e&&w(0,e)){const{start:n,end:r}=st();if(n===r&&!We)return void Ze(n=>xe(t,e,n,(e,t,n,r)=>h(e,t,n,r,rt,fe.placeholders)));const l=o({value:t,rules:rt,start:n,end:r,style:e,pending:Ie});return void("pending"===l.kind?Ue(l.pending):Ze(()=>l.result))}if("clear"===e)return void Ze(n=>xe(t,e,n,(e,t,n)=>h(e,t,n,"clear",rt)));if("link"!==e&&We&&w(0,e)){const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;if(r===l){const n=g(t,r,l,rt),o=n.has(e)||"highlight"===e&&n.has("accent"),a=Ie&&Ie.at===r?Ie:null,s=!!a?.add.includes(e)||!a?.drop.includes(e)&&o,i=(a?.add??[]).filter(t=>t!==e),c=(a?.drop??[]).filter(t=>t!==e);return s&&o?c.push(e):s||o||i.push(e),void Ue(i.length||c.length?{add:i,drop:c,at:r}:null)}return void Ze(n=>E(t,n?.selectionStart??r,n?.selectionEnd??l,e,rt))}if("link"!==e){const n=F??((e,t,n,r)=>h(e,t,n,r,y,fe.placeholders));return void Ze(r=>xe(t,e,r,n))}const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;Xe(!1),nt({start:r,end:l,link:v(t,r,l)})},ct=Boolean(ke&&ke.start!==ke.end),ut=ke?k(t,ke.start,ke.end,rt):null,dt=ke?Ie&&void 0!==Ie.color&&Ie.at===ke.start?Ie.color:x(t,ke.start,ke.end,rt):null,pt=dt?dt.startsWith("#")?dt:oe?.find(e=>e.name===dt)?.value:void 0,ft=e=>{We?e?$e.current?.setSource(e.start,e.end,t):$e.current?.focus():(me.current?.focus(),e&&me.current?.setSelectionRange(e.start,e.end))},ht=()=>{const e=tt;nt(null),ft(e?{start:e.start,end:e.end}:ke)},mt=()=>{const e=yt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Xe(!1),t&&ft(ke)},gt=I(mt);gt.current=mt,X(()=>{if(qe)return j(e=>{const t=yt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(gt.current(),!0)},()=>yt.current?.querySelector(".es-copy-colors"))},[qe]);const yt=I(null),vt=qe||null!==tt;X(()=>{const e=yt.current;if(!vt||!e)return;const t=e.ownerDocument,n=()=>{Xe(!1),nt(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[vt]);const bt=tt??(qe?ke??{start:t.length,end:t.length}:null),kt=I(()=>{});kt.current=()=>{const e=yt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!bt)return;const n=We?null:e.querySelector(".es-gold-layer"),r=We?$e.current?.rangeOf(bt.start,bt.end)??null:n?function(e,t,n){const r=e.ownerDocument,l=r.createTreeWalker(e,4),o=e=>{let t=e,n=null;for(let e=l.nextNode();e;e=l.nextNode()){if(t<=e.data.length)return[e,t];t-=e.data.length,n=e}return n?[n,n.data.length]:null},a=o(t);l.currentNode=e;const s=o(n);if(!a||!s)return null;const i=r.createRange();return i.setStart(a[0],a[1]),i.setEnd(s[0],s[1]),i}(n,bt.start,bt.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,a=r?function(e,t){const n=("function"==typeof e.getClientRects?[...e.getClientRects()]:[]).filter(e=>e.height>0);if(n.length>0){const t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():n[0];return t.height>0?Pe(t):Pe(n[0])}if(!t)return null;const r=t.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=function({anchor:e,size:t,within:n,clip:r,parent:l,gap:o=8}){const a=Math.max(n.left,r.left),s=Math.min(n.right,r.right)-t.width,i=Be(e.left,a,s),c=r.bottom-(e.bottom+o),u=e.top-o-r.top,d=t.height>c&&(t.height<=u||u>c),p=d?e.top-o-t.height:e.bottom+o,f=e.left+Math.min((e.right-e.left)/2,10),h=Be(f-5-i,10,t.width-10-10);return{top:p-l.top,left:i-l.left,above:d,point:h}}({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:Oe(e),parent:ze(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},q(()=>{const e=yt.current;if(!vt||!e)return;const t=()=>kt.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[vt,qe,tt,bt?.start,bt?.end,We]);const xt=e=>tt&&/* @__PURE__ */ue(V,{className:e?"es-copy-link es-copy-pop":"es-copy-link",value:tt.link?.href??"",onApply:e=>{const n=tt;nt(null),Ze(()=>We?T(t,n.start,n.end,e,rt):M(t,n.start,n.end,e))},onRemove:tt.link?()=>{const e=tt.link,n=tt;nt(null),e&&Ze(()=>We?N(t,n.start,n.end,rt):L(t,e))}:void 0,onCancel:ht}),wt=_?ye(_.allow,fe.align):[],St="always"===ee||ge||null!==tt||qe,Et=oe&&oe.length>0?{run:pt,open:qe,onToggle:()=>{nt(null),qe?mt():Xe(!0)}}:void 0,Ct=St&&ce&&ie?ie({className:"rosh-tb-btn",disabled:f,selected:ct,keepCaret:e=>e.preventDefault(),insert:e=>Ze(n=>we(t,e,n))}):void 0,Dt=new Set(ot),Nt=_?{value:_.value,allow:_.allow,onChange:_.onChange,disabled:_.disabled}:void 0,Lt={pressed:ut,onList:e=>{const{start:n,end:r}=st(),l=k(t,n,r,rt);Ze(()=>D(t,n,r,l===e?null:e,rt))}},Tt=H({offered:Dt,color:Et,last:Ct,alignment:Nt,list:Lt,letterCase:se}),Mt=ce&&St&&(Ae.some(e=>Dt.has(e))||Boolean(Et));/* @__PURE__ */
|
|
13
|
+
return de("div",{ref:yt,className:"es-copy"+(d?` ${d}`:""),onFocus:()=>ve(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ve(!1)},onKeyDown:e=>{const t=e.target===me.current||Boolean(e.target.closest?.(".es-rich"));if(f||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void Je(l||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(ce){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!ot.includes(t))return;return e.preventDefault(),e.stopPropagation(),void it(t)}const a=lt.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),it(a.style))},onPaste:e=>{const n=me.current;if(f||!n||e.target!==n)return;e.preventDefault();const r=a({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:i,rules:rt});Ze(e=>we(t,r,e))},style:oe&&oe.length>0?Object.fromEntries(oe.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const e=me.current;e&&e.ownerDocument.activeElement===e&&Se({start:e.selectionStart??t.length,end:e.selectionEnd??t.length})},children:[St&&ce&&(Tt.words||Tt.paragraph)?
|
|
14
|
+
/* @__PURE__ */ue(A,{className:"es-copy-toolbar","aria-label":Q??fe.formatting,offered:Dt,pressed:at,onMark:e=>it(e),color:Et,linkOpen:null!==tt,last:Ct,alignment:Nt,list:Lt,letterCase:se,disabled:f,windows:/* @__PURE__ */de(pe,{children:[qe&&oe&&oe.length>0?/* @__PURE__ */ue(Re,{colors:oe,current:dt,words:fe.colors??e.colors,onPick:e=>{const{start:n,end:r}=st();if(n!==r)Ze(()=>C(t,n,r,e,rt));else{if(!We)return;Ue({add:Ie?.add??[],drop:Ie?.drop??[],color:e,at:n})}}}):null,tt?xt(!0):null]})}):null,ce&&ae&&ae.length>0?/* @__PURE__ */ue(Te,{cells:ae,words:fe.cells??e.cells,readOnly:f}):null,St&&!ce?/* @__PURE__ */ue(je,{tools:K,disabled:f,actions:$,glyphs:G,ariaLabel:Q,pressed:at,open:tt?"link":null,onApply:it,align:_?/* @__PURE__ */ue(R,{options:wt,value:_.value,onChange:_.onChange,ariaLabel:fe.alignment,disabled:f||_.disabled,fit:be(wt)}):null}):null,We?/* @__PURE__ */ue(De,{value:t,rules:rt,multiline:i,readOnly:f,placeholder:c,ariaLabel:u,handle:$e,pending:Ie??void 0,onEdit:(e,n,r)=>{Ee.record({text:t,start:n.start,end:n.end},r,Date.now()),Ue(null),Ne(e)},onSelect:e=>{Se(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Ie||e.start===Ie.at&&e.end===Ie.at||Ue(null)},onHistory:Je,onFormat:e=>{ot.includes(e)&&it(e)},onCommit:r,onCancel:s}):/* @__PURE__ */ue(p,{value:t,onInput:e=>{Ee.record(Le(null),"type",Date.now()),Ne(e)},onCommit:r,onCancel:s,multiline:i,placeholder:c,ariaLabel:u,rules:z,disabled:f,inputRef:me,className:"es-copy-box"}),tt&&!ce?xt(!1):null,Z?Z({focused:ge,insert:e=>Ze(n=>we(t,e,n))}):null,te&&i||Mt?
|
|
15
15
|
/* @__PURE__ */de("div",{className:"es-copy-marks",children:[te&&i?/* @__PURE__ */de(pe,{children:[
|
|
16
|
-
/* @__PURE__ */ue(
|
|
17
|
-
/* @__PURE__ */ue("span",{id:
|
|
18
|
-
/* @__PURE__ */ue(re,{size:16}),fe.clearStyle??"Clear style"]})):null]}):null]})}export{fe as COPY_ALIGNS,ge as COPY_ALIGN_FIT,me as COPY_ALIGN_GLYPHS,he as COPY_ALIGN_LABELS,Ne as COPY_CELLS,Re as ColorWindow,
|
|
16
|
+
/* @__PURE__ */ue(B,{checked:Me,onChange:()=>{const e=Ye();et.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ke,Ue(null),Fe(e=>!e)},ariaLabelledBy:Ve,disabled:f}),
|
|
17
|
+
/* @__PURE__ */ue("span",{id:Ve,className:"es-copy-marks-label",children:fe.showMarks??"Show marks"})]}):null,Mt?O(ct?void 0:fe.clearStyleEmpty??"Select words first",/* @__PURE__ */de(W,{variant:"secondary",size:"sm",className:"es-copy-clear",disabled:f||!ct,onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:e,end:n}=st();if(e===n)return;const r=S(t,e,n,rt);r.text!==t&&Ze(()=>r)},children:[
|
|
18
|
+
/* @__PURE__ */ue(re,{size:16}),fe.clearStyle??"Clear style"]})):null]}):null]})}export{fe as COPY_ALIGNS,ge as COPY_ALIGN_FIT,me as COPY_ALIGN_GLYPHS,he as COPY_ALIGN_LABELS,Ne as COPY_CELLS,Re as ColorWindow,Ve as CopyBox,Te as CopyCells,je as MarkBar,De as RichBox,We as ariaShortcut,ye as copyAlignOptions,we as insertSelection,xe as markSelection,He as useCaretEdit};
|
package/dist/easel/easel.css
CHANGED
|
@@ -75,33 +75,30 @@
|
|
|
75
75
|
outline: none;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/* The outline colour, declared ONCE for the selection, the hover and the
|
|
79
|
+
words being typed. The accent, with a fallback: the outlines draw inside
|
|
80
|
+
the canvas frame, which holds the page's sheet and not the chrome's tokens. */
|
|
78
81
|
.es-canvas-outline {
|
|
82
|
+
--es-canvas-outline-colour: var(--es-accent, #2563eb);
|
|
79
83
|
pointer-events: none;
|
|
80
84
|
box-sizing: border-box;
|
|
81
85
|
z-index: 2147483000;
|
|
82
86
|
}
|
|
83
87
|
.es-canvas-outline.is-selected {
|
|
84
|
-
outline: 2px solid var(--es-
|
|
88
|
+
outline: 2px solid var(--es-canvas-outline-colour);
|
|
85
89
|
outline-offset: -1px;
|
|
86
90
|
}
|
|
87
91
|
.es-canvas-outline.is-hover {
|
|
88
|
-
outline: 1px solid color-mix(in srgb, var(--es-
|
|
92
|
+
outline: 1px solid color-mix(in srgb, var(--es-canvas-outline-colour) 60%, transparent);
|
|
89
93
|
outline-offset: -1px;
|
|
90
94
|
}
|
|
91
|
-
/* The words being typed (EaselCanvas `typing`, Lewis 2026-10-14): ONE
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
/* The words being typed (EaselCanvas `typing`, Lewis 2026-10-14): ONE plain
|
|
96
|
+
box round the whole words, like an input — a 2px line in the selection's
|
|
97
|
+
colour, 4px clear of them, with the selection outline's square corners. It
|
|
98
|
+
is measured from the words' bounding box, so words on three lines get one
|
|
99
|
+
rectangle, not a line round each. Its colour is the one outline colour
|
|
100
|
+
above: without its fallback the outline is not drawn in the canvas. */
|
|
95
101
|
.es-canvas-outline.is-typing {
|
|
96
|
-
outline: 2px solid var(--es-
|
|
102
|
+
outline: 2px solid var(--es-canvas-outline-colour);
|
|
97
103
|
outline-offset: 4px;
|
|
98
|
-
border-radius: var(--radius-sm);
|
|
99
|
-
}
|
|
100
|
-
.es-canvas-outline.is-typing::after {
|
|
101
|
-
content: '';
|
|
102
|
-
position: absolute;
|
|
103
|
-
inset: -8px;
|
|
104
|
-
border: 1px solid color-mix(in srgb, var(--on-accent) 85%, transparent);
|
|
105
|
-
border-radius: var(--radius-sm);
|
|
106
|
-
pointer-events: none;
|
|
107
104
|
}
|
package/dist/easel/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { c as ResolveTrigger, a as ResolveCache, R as ResolvableItem } from '../
|
|
|
8
8
|
import * as react from 'react';
|
|
9
9
|
import { ReactNode, CSSProperties, ComponentType, ReactElement } from 'react';
|
|
10
10
|
import { TextToolbarProps } from 'efficient-shell/ui';
|
|
11
|
-
import { C as CanvasTypingEnd } from '../canvas-typing-
|
|
11
|
+
import { C as CanvasTypingEnd } from '../canvas-typing-Cnvlsh_V.js';
|
|
12
12
|
import { InlineRule } from '../markup/index.js';
|
|
13
13
|
import { b as NodeOpsHost, C as ClipboardEntry } from '../useNodeOps-CTQN3wky.js';
|
|
14
14
|
import { I as InspectorFields } from '../types-OUl0mK1k.js';
|
|
@@ -338,6 +338,9 @@ interface CanvasTypingTarget {
|
|
|
338
338
|
rules: readonly InlineRule[];
|
|
339
339
|
/** The field has lines: Shift+Enter makes one. */
|
|
340
340
|
multiline: boolean;
|
|
341
|
+
/** A selector for elements the page draws among the words that are not
|
|
342
|
+
* words (the email's paragraph gap). Left out, every text node is a word. */
|
|
343
|
+
skip?: string;
|
|
341
344
|
/** The host's ONE writer for these words — the panel's text box's. */
|
|
342
345
|
write: (next: string) => void;
|
|
343
346
|
/** Draw the words afresh (after an IME composition wrote into them). */
|
package/dist/easel/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{CanvasFrame,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-
|
|
1
|
+
export{CanvasFrame,DEFAULT_UI,EaselCanvas,EaselProvider,EditDocument,bindUndoKeys,createEasel,createUseEasel,recordsByDefault,reduce,uiView,useEasel,useEaselApi,useEaselNodeOps,useSelectedFields,validSelection}from"../chunk-WF5IIVDD.js";import"../chunk-SOZUYCQZ.js";import"../chunk-TBY3DFKS.js";import"../chunk-YRLPFZW3.js";import"../chunk-WQASXLXS.js";import"../chunk-546BBOPE.js";import"../chunk-MFIRYGHW.js";import"../chunk-AWJUYMX7.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
|
package/dist/fields/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{FieldText,Inspector,InspectorField,LinkPicker,ListField,bucketsOf,copyItem,insertAt,labelOf,moveTo,planFields,removeAt}from"../chunk-
|
|
1
|
+
export{FieldText,Inspector,InspectorField,LinkPicker,ListField,bucketsOf,copyItem,insertAt,labelOf,moveTo,planFields,removeAt}from"../chunk-UCAM256Q.js";export{FieldSelect,FieldSlider,optionFor}from"../chunk-OZ72A6MY.js";import"../chunk-4JSBIW5H.js";import"../chunk-K56YDHYQ.js";export{useResolvedFields}from"../chunk-YRLPFZW3.js";import"../chunk-EA2HTX37.js";import"../chunk-3ZJSLHHI.js";import"../chunk-KFV7N2DJ.js";export{FieldNumber}from"../chunk-66LWADFP.js";import"../chunk-FFYXVAAL.js";import"../chunk-QLD57GBB.js";import"../chunk-MFIRYGHW.js";import"../chunk-67GNT6PF.js";import"../chunk-P2VEMZH5.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{AddBlockRow as default}from"../../chunk-
|
|
1
|
+
export{AddBlockRow as default}from"../../chunk-6F2SGZ7F.js";import"../../chunk-HQ4VVRIC.js";import"../../chunk-PG3QGGTU.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-5F3PKNT7.js";import"../../chunk-WF5IIVDD.js";import"../../chunk-SOZUYCQZ.js";import"../../chunk-TBY3DFKS.js";import"../../chunk-UCAM256Q.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-3ZJSLHHI.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-WQASXLXS.js";import"../../chunk-66LWADFP.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.js";import"../../chunk-QLD57GBB.js";import"../../chunk-MFIRYGHW.js";import"../../chunk-67GNT6PF.js";import"../../chunk-AWJUYMX7.js";import"../../chunk-P2VEMZH5.js";import"../../chunk-KRXQM65X.js";import"../../chunk-NKB3KVAB.js";
|