efficient-easel 6.1.0 → 6.3.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/index.d.ts +14 -2
- package/dist/canvas/index.js +1 -1
- package/dist/canvas-typing-Dec_zyuM.d.ts +49 -0
- package/dist/chunk-AWJUYMX7.js +1 -0
- package/dist/chunk-AYNU4FYF.js +14 -0
- package/dist/chunk-B4ZNYLZX.js +5 -0
- package/dist/{chunk-MTG37BOC.js → chunk-CJBU4E4L.js} +1 -1
- package/dist/{chunk-O7IPFJGX.js → chunk-DQLK3QQ2.js} +1 -1
- package/dist/chunk-DSUMM2WF.js +10 -0
- package/dist/chunk-EXCKAZKN.js +5 -0
- package/dist/{chunk-IH2O5CZO.js → chunk-H3WBX7FN.js} +1 -1
- package/dist/chunk-HAUTMX4H.js +65 -0
- package/dist/{chunk-B6WEYEMH.js → chunk-I6U2G7L4.js} +1 -1
- package/dist/chunk-JIWPANGM.js +1 -0
- package/dist/chunk-LVUDUQNL.js +1 -0
- package/dist/{chunk-U32MAI4R.js → chunk-PRRFBVJ2.js} +3 -3
- package/dist/{chunk-7WAC3IXR.js → chunk-QPQXKKSC.js} +1 -1
- package/dist/chunk-T5HFGW57.js +1 -0
- package/dist/{chunk-CRWFB7MU.js → chunk-X4OF36J2.js} +11 -11
- package/dist/copy/index.d.ts +73 -16
- package/dist/copy/index.js +18 -18
- package/dist/drag/index.js +1 -1
- package/dist/easel/easel.css +17 -0
- package/dist/easel/index.d.ts +47 -2
- 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/package.json +1 -1
- package/dist/chunk-7XFNHML2.js +0 -1
- package/dist/chunk-BVKNVCGX.js +0 -9
- package/dist/chunk-LSBQ74U4.js +0 -65
- package/dist/chunk-MOCX5MQ7.js +0 -14
- package/dist/chunk-MTRFMGBO.js +0 -1
- package/dist/chunk-PAELDYYS.js +0 -1
- package/dist/chunk-TNV2BVL2.js +0 -5
- package/dist/chunk-VOKBME2Y.js +0 -5
- package/dist/chunk-ZNCEOSXO.js +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{TreeSeam as e}from"./chunk-4JSBIW5H.js";import{FieldSelect as n}from"./chunk-OZ72A6MY.js";import{SettingsField as t,SETTINGS_BUCKETS as l,SettingsGroup as r}from"./chunk-3ZJSLHHI.js";import{DEFAULT_TREE_WORDS as a}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as o}from"./chunk-KFV7N2DJ.js";import{EaselMenuItems as i}from"./chunk-EA2HTX37.js";import{FieldNumber as s}from"./chunk-66LWADFP.js";import{SettingsSegmented as c}from"./chunk-QLD57GBB.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-FFYXVAAL.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:n,icon:t,noun:l,items:r,onChange:o,newItem:s,summary:c,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",d).list,U=u("tree",a),_=l??Q.item,ee=!w&&!G&&("number"!=typeof x||r.length<x),ne=r.length<=k,te=e=>!!K&&!K(r[e],e),le=e=>!w&&!G&&W&&!ne&&!te(e),re=e=>ee&&(!X||X(r[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>=r.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}}o(H(r,e,n));const a=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);a!==$&&T(a),he(Q.moved({n:n+1,total:r.length}))},be=e=>{ee&&(o(A(r,e,s())),J?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&T($+1)):T(e))},ge=e=>{le(e)&&(o(E(r,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<r.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<r.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)&&(o(A(r,e+1,R(r[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=r.slice();t[e]=n,o(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:[t?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:t}):null,
|
|
4
|
-
/* @__PURE__ */j("span",{className:"es-list-count",children:r.length})]}):null,Z?/* @__PURE__ */j("div",{className:"es-list-above",children:Z}):null,r.length?/* @__PURE__ */D(g,{"aria-label":
|
|
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(
|
|
6
|
-
/* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(
|
|
3
|
+
/* @__PURE__ */D("span",{className:"es-list-label",children:[t?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:t}):null,n]}),
|
|
4
|
+
/* @__PURE__ */j("span",{className:"es-list-count",children:r.length})]}):null,Z?/* @__PURE__ */j("div",{className:"es-list-above",children:Z}):null,r.length?/* @__PURE__ */D(g,{"aria-label":n,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[r.map((n,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(e,{...ve.seam({place:{...B,index:t}}),onAdd:ee?()=>be(t):void 0,label:Q.addHere({noun:_})},`seam-${t}`):null,
|
|
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(n,t):Q.locked,/* @__PURE__ */j("span",{className:"es-list-lock",role:"img","aria-label":V?V(n,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(n,t,xe(t))}):void 0,children:J?/* @__PURE__ */j("div",{className:"es-list-row-main",children:J(n,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(n,t)}):null,
|
|
6
|
+
/* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(n,t)}),/* @__PURE__ */j("span",c?{className:"es-list-row-summary",children:c(n,t)}:{className:"es-list-row-summary"}),
|
|
7
7
|
/* @__PURE__ */j(I,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},t)]}),
|
|
8
|
-
/* @__PURE__ */j(
|
|
8
|
+
/* @__PURE__ */j(e,{...ve.seam({place:{...B,index:r.length}})})]}):null,w||G?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(r.length),children:Q.add({noun:_})}),
|
|
9
9
|
/* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<r.length?
|
|
10
10
|
/* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(i,{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:a,readOnly:o,context:i,renderers:s}){const[c,d]=C(!0),u=l&&"object"==typeof l?l:{};/* @__PURE__ */
|
|
11
11
|
return j(r,{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=>a({...u,[e]:n}),readOnly:o,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(
|
|
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(e){const{field:l,name:r,id:a,value:o,onChange:i,readOnly:d,context:u,renderers:m}=e;if(!l||l.marker||!1===l.visible)return null;const p=m?.[l.type];if(p)return p({field:l,name:r,id:a,value:o,onChange:i,readOnly:d});switch(l.type){case"custom":{const e={...u,field:l,name:r,id:a,value:o,onChange:i,readOnly:d};return l.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
13
13
|
return j(t,{label:J(l,r),htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(T,{id:a,value:"string"==typeof o?o:null==o?"":String(o),onChange:i,placeholder:l.placeholder,multiline:"textarea"===l.type,readOnly:d})});case"number":/* @__PURE__ */
|
|
14
|
-
return j(t,{label:J(l,r),htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(s,{id:a,value:"number"==typeof o?o:void 0,onChange:i,min:l.min,max:l.max,step:l.step,placeholder:l.placeholder,readOnly:d})});case"select":{const
|
|
15
|
-
return j(t,{label:J(l,r),labelId:
|
|
14
|
+
return j(t,{label:J(l,r),htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(s,{id:a,value:"number"==typeof o?o:void 0,onChange:i,min:l.min,max:l.max,step:l.step,placeholder:l.placeholder,readOnly:d})});case"select":{const e=`${a}-label`;/* @__PURE__ */
|
|
15
|
+
return j(t,{label:J(l,r),labelId:e,htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(n,{id:a,value:o,options:l.options,onChange:i,readOnly:d,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
|
|
16
16
|
return j(t,{label:J(l,r),icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(c,{ariaLabel:J(l,r),value:o,options:l.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||d})),onChange:e=>{d||i(e)}})});case"object":/* @__PURE__ */
|
|
17
|
-
return j(K,{...
|
|
18
|
-
return j(V,{...
|
|
17
|
+
return j(K,{...e,field:l});case"array":/* @__PURE__ */
|
|
18
|
+
return j(V,{...e,field:l});case"slot":return null}}var W=e=>l.includes(e);function X(e){let n,t=l[0];const r=[],a=/* @__PURE__ */new Set;for(const[l,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:l,title:o.fold}:o.marker&&!1===o.fold&&(n=void 0),o.marker||!1===o.visible||(r.push(n?{name:l,field:o,bucket:t,fold:n}:{name:l,field:o,bucket:t}),"slot"!==o.type&&a.add(t)));return{rows:r,buckets:l.filter(e=>a.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:a,tab:i,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",o),O=$(),I=p??`es-insp${O.replace(/:/g,"")}`,S=X(e),[F,P]=C(void 0),L=i??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(r,{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:r,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:r,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,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
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===i&&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};
|
package/dist/copy/index.d.ts
CHANGED
|
@@ -5,6 +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-Dec_zyuM.js';
|
|
8
9
|
|
|
9
10
|
type CellWords = NonNullable<CopyWords['cells']>;
|
|
10
11
|
interface CopyCell {
|
|
@@ -397,9 +398,27 @@ interface CopyBoxProps {
|
|
|
397
398
|
|
|
398
399
|
declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, actions, align, glyphs, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, toolbar, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
|
|
399
400
|
|
|
400
|
-
|
|
401
|
+
interface PasteData {
|
|
402
|
+
/** The clipboard's `text/html`, when there is one. */
|
|
403
|
+
html?: string;
|
|
404
|
+
/** The clipboard's `text/plain`. */
|
|
405
|
+
text?: string;
|
|
406
|
+
}
|
|
407
|
+
interface PasteOptions {
|
|
408
|
+
/** The document the box lives in — the HTML is read in an inert template
|
|
409
|
+
* of it. */
|
|
410
|
+
doc: Document;
|
|
411
|
+
/** A one-line box joins every line with a space. */
|
|
412
|
+
multiline: boolean;
|
|
413
|
+
/** The host's rules, which the result must read back under. */
|
|
414
|
+
rules?: readonly InlineRule[];
|
|
415
|
+
}
|
|
416
|
+
/** Turn a clipboard's contents into the grammar, filtered. */
|
|
417
|
+
declare function pasteToMarkup(data: PasteData, opts: PasteOptions): string;
|
|
418
|
+
/** The clipboard type a copy from a text box (the panel's, or words typed on the canvas) carries, so a paste back in keeps
|
|
401
419
|
* every mark (the HTML filter keeps only bold, italic and links). */
|
|
402
420
|
declare const MARKUP_CLIPBOARD_TYPE = "application/x-efficient-markup";
|
|
421
|
+
|
|
403
422
|
/** What the host can ask of the box, in SAVED offsets. */
|
|
404
423
|
interface RichHandle {
|
|
405
424
|
/** The selection, or null when it is not in the box. */
|
|
@@ -520,23 +539,61 @@ declare function setBullet(value: string, rules: readonly InlineRule[], index: n
|
|
|
520
539
|
/** The words `vs..ve` as markup, marks and bullets included — for a copy. */
|
|
521
540
|
declare function markupOfRange(value: string, rules: readonly InlineRule[], vs: number, ve: number): string;
|
|
522
541
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
542
|
+
/**
|
|
543
|
+
* `richInput` — what one `beforeinput` does to the saved string, written once.
|
|
544
|
+
*
|
|
545
|
+
* Two places let a person type the same string: the panel's text box
|
|
546
|
+
* (`RichBox`) and the words on the editor's canvas (card [DESIGN] Typing On
|
|
547
|
+
* The Canvas, Lewis 2026-10-14). Both cancel every `beforeinput` — the browser
|
|
548
|
+
* is used for the caret and the selection and for nothing else — and make the
|
|
549
|
+
* edit on the string with ./rich-model. This is that decision, as a pure
|
|
550
|
+
* function: given the string, the visible selection and the event's
|
|
551
|
+
* `inputType` and data, the edit to apply (and whether it is typing, which
|
|
552
|
+
* joins an undo burst, or an edit, which does not), a history or format key to
|
|
553
|
+
* hand back to the host, or `null` for nothing — an input the grammar cannot
|
|
554
|
+
* say is refused.
|
|
555
|
+
*
|
|
556
|
+
* Moved out of `RichBox` unchanged; its specs (tests/copy-rich.test.tsx) hold
|
|
557
|
+
* that it behaves as it did.
|
|
558
|
+
*/
|
|
559
|
+
|
|
560
|
+
/** Marks pressed with nothing selected, and a pending colour: the next typed words take them. */
|
|
561
|
+
interface RichPending {
|
|
562
|
+
add?: readonly MarkStyle[];
|
|
563
|
+
drop?: readonly string[];
|
|
564
|
+
color?: string | null;
|
|
528
565
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
566
|
+
type RichInputResult = {
|
|
567
|
+
kind: 'type' | 'edit';
|
|
568
|
+
edit: RichEdit;
|
|
569
|
+
range: [number, number];
|
|
570
|
+
} | {
|
|
571
|
+
kind: 'history';
|
|
572
|
+
dir: 'undo' | 'redo';
|
|
573
|
+
} | {
|
|
574
|
+
kind: 'format';
|
|
575
|
+
style: 'bold' | 'italic' | 'strike';
|
|
576
|
+
} | null;
|
|
577
|
+
interface RichInputEvent {
|
|
578
|
+
value: string;
|
|
579
|
+
rules: readonly InlineRule[];
|
|
580
|
+
/** A many-line box: Enter makes a new line. A one-line box takes none. */
|
|
534
581
|
multiline: boolean;
|
|
535
|
-
/** The
|
|
536
|
-
|
|
582
|
+
/** The event's `inputType`. */
|
|
583
|
+
inputType: string;
|
|
584
|
+
/** The event's `data`, or its plain-text `dataTransfer`. */
|
|
585
|
+
data?: string | null;
|
|
586
|
+
/** The pasted or dropped HTML, when there is some. */
|
|
587
|
+
html?: string | null;
|
|
588
|
+
/** The document a paste is parsed in. */
|
|
589
|
+
doc: Document;
|
|
590
|
+
/** The visible selection. */
|
|
591
|
+
sel: [number, number];
|
|
592
|
+
/** The range a delete names for itself (`getTargetRanges`), in visible offsets. */
|
|
593
|
+
target?: [number, number] | null;
|
|
594
|
+
pending?: RichPending | null;
|
|
537
595
|
}
|
|
538
|
-
|
|
539
|
-
declare function pasteToMarkup(data: PasteData, opts: PasteOptions): string;
|
|
596
|
+
declare function richInput(e: RichInputEvent): RichInputResult;
|
|
540
597
|
|
|
541
598
|
/**
|
|
542
599
|
* THE BOX'S OWN UNDO (0.94.0) — what ⌘Z and ⇧⌘Z step through while a copy
|
|
@@ -591,4 +648,4 @@ interface CaretEdit {
|
|
|
591
648
|
*/
|
|
592
649
|
declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
|
|
593
650
|
|
|
594
|
-
export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxLastTool, type CopyBoxProps, type CopyCase, type CopyCell, type CopyCellPreset, CopyCells, type CopyThemeColor, CopyWords, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInsert, type RichLayout, type RichLine, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, type ToolbarMark, ariaShortcut, createHistory, editVisible, insertSelection, markSelection, markupOfRange, newLine, pasteToMarkup, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
|
|
651
|
+
export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxLastTool, type CopyBoxProps, type CopyCase, type CopyCell, type CopyCellPreset, CopyCells, type CopyThemeColor, CopyWords, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, type ToolbarMark, ariaShortcut, createHistory, editVisible, insertSelection, markSelection, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
|
package/dist/copy/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{FieldNumber as t}from"../chunk-66LWADFP.js";import{SettingsSegmented as n,SettingsSwitch as r}from"../chunk-QLD57GBB.js";import"../chunk-FFYXVAAL.js";import{GoldTextInput as l}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as o,applyMark as a,STANDARD_MARKUP as s,writeMarkedLines as i,sameMarks as c,markedLines as u,spanFor as d,markupTools as h,marksIn as p,findLink as f,markedAt as m,listIn as g,colorIn as b,clearStyle as y,isSafeLinkHref as v,toggleMark as k,colorOver as x,setList as w,unlinkAt as S,removeLink as E,linkOver as C,writeLink as D}from"../chunk-546BBOPE.js";import{useWords as N}from"../chunk-MFIRYGHW.js";import{withTip as L}from"../chunk-P2VEMZH5.js";import{Tooltip as M,ColorSwatch as T,ColorPickerPanel as B,Button as R,IconButton as j,registerModalEscapeInterceptor as P,textToolbarRows as z,TextToolbar as O,LinkPicker as F}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as W,useState as K,useLayoutEffect as $,useEffect as H,useId as A}from"react";import{AlignJustifyIcon as I,AlignRightIcon as q,AlignCenterIcon as U,AlignLeftIcon as V,ParagraphSpacingIcon as Y,LetterSpacingIcon as Z,TextLinesIcon as G,TextSizeIcon as J,ClearMarksIcon as X,LinkIcon as Q,QuietIcon as _,EmphasisIcon as ee,StrikeIcon as te,ItalicIcon as ne,BoldIcon as re}from"efficient-shell/icons/efficient";import{jsx as le,jsxs as oe,Fragment as ae}from"react/jsx-runtime";var se=["left","center","right","justify"],ie=e.align,ce={left:/* @__PURE__ */le(V,{}),center:/* @__PURE__ */le(U,{}),right:/* @__PURE__ */le(q,{}),justify:/* @__PURE__ */le(I,{})},ue={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function de(e,t=ie){return se.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:ce[e],title:t[e]}))}var he=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function pe(e){if(e.every(e=>e.label===ie[e.id]))return e.length>3?ue.four:ue.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(he.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function fe(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function me(e,t,n,r=a){const{start:l,end:o}=fe(e,n);return r(e,l,o,t)}function ge(e,t,n){const{start:r,end:l}=fe(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}var be=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),ye=/* @__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 ve(e,t){const n=t.rules??s,r=e.html&&""!==e.html.trim()?function(e,t,n){const r=t.createElement("template");r.innerHTML=e;const l=[[]],o=()=>l[l.length-1],a=()=>{const e=o();for(;e.length>0&&" "===e[e.length-1].ch;)e.pop();e.length>0&&l.push([])},s=(e,t,n,r)=>{if(3===e.nodeType){for(const a of e.textContent??""){const e=/\s/.test(a)?" ":a,s=o();" "===e&&(0===s.length&&l.length>1||" "===s[s.length-1]?.ch)||s.push({ch:e,bold:t,italic:n,href:r})}return}if(1!==e.nodeType&&11!==e.nodeType)return;const i=e,c=1===e.nodeType?i.localName:"";if(be.has(c))return;if("br"===c)return void l.push([]);let u=t,d=n,h=r;if("b"!==c&&"strong"!==c||(u=!0),"i"!==c&&"em"!==c||(d=!0),"a"===c){const e=(i.getAttribute("href")??"").trim();h=v(e)?e:null}const p=1===e.nodeType?i.style:null;if(p){const e=p.fontWeight;"bold"===e||"bolder"===e||Number(e)>=600?u=!0:("normal"===e||"lighter"===e||""!==e&&Number(e)<600)&&(u=!1),"italic"===p.fontStyle||"oblique"===p.fontStyle?d=!0:"normal"===p.fontStyle&&(d=!1)}const f=ye.has(c);f&&a();for(const t of[...e.childNodes])s(t,u,d,h);f&&a()};s(r.content,!1,!1,null);for(;l.length>1&&0===l[l.length-1].length;)l.pop();return l.map(e=>function(e,t){const n=t=>e.map((n,r)=>n[t]&&(" "!==n.ch||Boolean(e[r-1]?.[t])&&Boolean(e[r+1]?.[t]))),r=[{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 l of r){const r=ke(e,l.bold?n("bold"):null,l.italic?n("italic"):null,l.links),o=i([r]).text;if(c([r],u(o,t)))return o}return e.map(e=>e.ch).join("")}(e,n))}(e.html,t.doc,n):(e.text??"").replace(/\r\n?/g,"\n").split("\n");return t.multiline?r.join("\n"):1===r.length?r[0]:r.map(e=>e.trim()).filter(e=>""!==e).join(" ")}function ke(e,t,n,r){let l=0,o=null,a=null,s=null;return{bullet:!1,chars:e.map((e,i)=>{const c=r?e.href:null;return o=null===c?null:o&&o.href===c?o:d(++l,"link",c),a=t?.[i]?a??d(++l,"bold"):null,s=n?.[i]?s??d(++l,"italic"):null,{ch:e.ch,at:-1,marks:[o,a,s].filter(e=>null!==e)}})}}var xe=/^([0-9]{1,3})\. $/;function we(e,t){const n=e.split("\n"),r=u(e,t);let l=0,o=0;const a=r.map((e,t)=>{const r=!e.bullet&&null==e.number&&"- "===n[t],a=null!=e.number||e.bullet?null:xe.exec(n[t]),s=e.bullet||r,i=a?a[1]:e.number??null,c=r||a?[]:e.chars,u=c.map(e=>e.ch).join(""),d=null!=i?i.length+2:s?2:0,h={bullet:s,number:i,chars:c,start:l,src:l+d,vis:o,text:u};return l+=n[t].length+1,o+=u.length+1,h});return{lines:a,text:a.map(e=>e.text).join("\n")}}function Se(e,t){const{lines:n}=e;for(let e=0;e<n.length;e+=1){const r=n[e];if(t<=r.vis+r.text.length||e===n.length-1)return[r,Math.max(0,Math.min(t-r.vis,r.text.length)),e]}return[n[0],0,0]}function Ee(e,t){const[n,r]=Se(e,t);if(0===r)return n.src;let l=0;for(const e of n.chars){if(r<=l+e.ch.length)return e.at+(r-l);l+=e.ch.length}return n.src}function Ce(e,t){const[n,r]=Se(e,t);let l=0;for(const e of n.chars){if(r===l)return e.at;l+=e.ch.length}return Ee(e,t)}function De(e,t){const{lines:n}=e;let r=n[0];for(const e of n)t>=e.start&&(r=e);let l=0;for(const e of r.chars){if(!(t>=e.at+e.ch.length)){t>e.at&&(l+=t-e.at);break}l+=e.ch.length}return r.vis+l}function Ne(e,t,n){return[De(e,t),De(e,n)]}function Le(e,t,n){return t===n?[Ee(e,t),Ee(e,t)]:[Ce(e,t),Ee(e,n)]}function Me(e,t){let n=0;for(let r=0;r<e.chars.length;r+=1){if(n>=t)return r;n+=e.chars[r].ch.length}return e.chars.length}function Te(e,t,n,r,l){const o=we(e,t),[a,s,h]=Se(o,Math.min(n,r)),[p,f,m]=Se(o,Math.max(n,r)),g=Me(a,s),b=Me(p,f),y=a.chars.slice(0,g),v=p.chars.slice(b),k=n!==r&&a.chars[g]&&(h!==m||g<b)?a.chars[g].marks:function(e,t){const n=e.chars[t-1],r=e.chars[t],l=(e,t)=>{const n=e.findIndex(e=>"link"===e.kind);return-1===n||t?e:e.slice(0,n)};if(n){const e=n.marks.find(e=>"link"===e.kind),t=Boolean(e&&r?.marks.some(t=>t.id===e.id));return l(n.marks,t)}return r?l(r.marks,!1):[]}(a,g);let x=(w=o.lines,Math.max(0,...w.flatMap(e=>e.chars.flatMap(e=>e.marks.map(e=>e.id))))+1);var w;const S=e=>{let n;if(void 0!==l.markup){const e=x;n=u(l.markup,t).map(t=>({bullet:t.bullet,number:t.number??null,chars:t.chars.map(t=>({...t,at:-1,marks:t.marks.map(t=>({...t,id:t.id+e}))}))}))}else{let t=a.number??null;n=(l.text??"").split("\n").map((n,r)=>(r>0&&null!=t&&(t=function(e){return String(Number(e)+1).padStart(e.length,"0")}(t)),{bullet:a.bullet,number:t,chars:[...n].map(t=>({ch:t,at:-1,marks:e??[]}))}))}const r=n.map(e=>e.chars.map(e=>e.ch).join("")).join("\n"),s={bullet:a.bullet,number:a.number??null,chars:[...y,...n[0].chars]},i=n.slice(1);if(i.length>0){const e=i[i.length-1];i[i.length-1]={...e,chars:[...e.chars,...v]}}else s.chars.push(...v);return{lines:[...o.lines.slice(0,h).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n})),s,...i,...o.lines.slice(m+1).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n}))],shown:r}},E=void 0!==l.markup?[null]:[(e=>{let t=e.filter(e=>!l.drop?.some(t=>e.kind===t||"highlight"===t&&"accent"===e.kind));for(const e of l.add??[]){if(t.some(t=>t.kind===e))continue;const n=d(x++,e);n&&(t=[...t,n])}if(void 0!==l.color){t=t.filter(e=>"color"!==e.kind);const e=null===l.color?null:d(x++,"color",l.color);e&&(t=[...t,e])}return t})(k),k,[]];let C="",D="";for(const e of E){const n=S(e),r=i(n.lines).text;if(C=r,D=n.shown,c(n.lines,we(r,t).lines))break}return{text:C,caret:Math.min(n,r)+D.length}}function Be(e,t,n,r){const l=we(e,t),[o,,a]=Se(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?Te(e,t,n,r,{text:"\n"}):Re(e,t,a,!1,n)}function Re(e,t,n,r,l){const o=we(e,t).lines.map(({bullet:e,number:t,chars:l},o)=>o===n?{bullet:r,number:null,chars:l}:{bullet:e,number:t,chars:l});return{text:i(o).text,caret:l}}function je(e,t,n,r){const l=we(e,t),[o,a,s]=Se(l,Math.min(n,r)),[c,u,d]=Se(l,Math.max(n,r)),h=l.lines.slice(s,d+1).map(({bullet:e,number:t,chars:n},r)=>{const l=0===r?Me(o,a):0,i=r===d-s?Me(c,u):n.length;return{bullet:e,number:t,chars:n.slice(l,i)}});return i(h).text}var Pe="application/x-efficient-markup";function ze(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 Oe(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 Fe(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 We(e,t,n){if(n<0){const n=e.charCodeAt(t-1);return t-(n>=56320&&n<=57343&&t>=2?2:1)}const r=e.charCodeAt(t);return t+(r>=55296&&r<=56319?2:1)}function Ke({value:e,rules:t,multiline:n,readOnly:r=!1,placeholder:l,ariaLabel:o,handle:a,onEdit:s,onSelect:i,onHistory:c,onFormat:u,pending:d,onCommit:h,onCancel:p}){const f=W(null),m=W(null),g=W(null),b=W(null),y=W(null),v=W(e),[k,x]=K(0),w=W({value:e,rules:t,multiline:n,readOnly:r,pending:d,onEdit:s,onHistory:c,onFormat:u});w.current={value:e,rules:t,multiline:n,readOnly:r,pending:d,onEdit:s,onHistory:c,onFormat:u};const S=()=>{const e=f.current,t=m.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Oe(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Oe(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},E=(e,t)=>{const n=f.current,r=m.current;if(!n||!r)return;const[l,o]=Fe(r,e),[a,s]=Fe(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};a.current={getSource(){const e=S(),t=m.current;if(!e||!t)return null;const[n,r]=Le(t.layout,e[0],e[1]);return{start:n,end:r}},setSource(e,t,n){b.current={text:n,src:[e,t]},x(e=>e+1)},focus(){f.current?.focus()},rangeOf(e,t){const n=f.current,r=m.current;if(!n||!r)return null;const[l,o]=Ne(r.layout,e,t),[a,s]=Fe(r,l),[i,c]=Fe(r,o),u=n.ownerDocument.createRange();return u.setStart(a,s),u.setEnd(i,c),u}},$(()=>{const n=f.current;if(!n||y.current)return;const r=b.current?null:S();m.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=ze(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,we(e,t)),g.current=e;const l=b.current;if(!l||l.text!==e)return void(r&&n.ownerDocument.activeElement===n&&E(r[0],Math.min(r[1],m.current.layout.text.length)));b.current=null;const o=m.current.layout,[a,s]=l.vis??Ne(o,l.src[0],l.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),E(a,s)},[e,t,k]);const C=(e,t,n)=>{const r=m.current,[l,o]=Le(r.layout,t[0],t[1]);b.current={text:e.text,vis:[e.caret,e.caret]},e.text!==w.current.value?w.current.onEdit(e.text,{start:l,end:o},n):x(e=>e+1)};H(()=>{const e=f.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=w.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=m.current,i=S();if(!s||!i)return;let[c,u]=i;const d="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0;d&&!d.collapsed&&t.inputType.startsWith("delete")&&(c=Oe(s,e,d.startContainer,d.startOffset),u=Oe(s,e,d.endContainer,d.endOffset));const h=s.layout.text,p=t.inputType;if("historyUndo"!==p&&"historyRedo"!==p)if("formatBold"!==p&&"formatItalic"!==p&&"formatStrikeThrough"!==p)if("insertParagraph"!==p&&"insertLineBreak"!==p){if(p.startsWith("insert")){let o=t.data??t.dataTransfer?.getData("text/plain")??"";if("insertFromDrop"===p||"insertFromPaste"===p){const a=ve({html:t.dataTransfer?.getData("text/html"),text:o},{doc:e.ownerDocument,multiline:l,rules:r});return void C(Te(n,r,c,u,{markup:a}),[c,u],"edit")}return l||(o=o.replace(/\s*\r?\n\s*/g," ")),void C(Te(n,r,c,u,{text:o,add:a?.add,drop:a?.drop,color:a?.color}),[c,u],"type")}if(p.startsWith("delete")){if(c===u){const e=p.includes("Backward"),t=s.layout.lines.findIndex(e=>c>=e.vis&&c<=e.vis+e.text.length),l=s.layout.lines[t];if(e&&l&&c===l.vis&&(l.bullet||null!=l.number))return void C(Re(n,r,t,!1,c),[c,u],"edit");if(e?0===c:c===h.length)return;e?c=We(h,c,-1):u=We(h,u,1)}C(Te(n,r,c,u,{text:""}),[c,u],"type")}}else l&&C(Be(n,r,c,u),[c,u],"edit");else w.current.onFormat("formatBold"===p?"bold":"formatItalic"===p?"italic":"strike");else w.current.onHistory("historyUndo"===p?"undo":"redo")},n=()=>{y.current||x(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),H(()=>{const e=f.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=a.current?.getSource();e&&i(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const D=(n,l=!1)=>{const o=S();if(!o||o[0]===o[1])return;n.preventDefault();const a=m.current;n.clipboardData.setData("text/plain",a.layout.text.slice(o[0],o[1])),n.clipboardData.setData(Pe,je(e,t,o[0],o[1])),l&&!r&&C(Te(e,t,o[0],o[1],{text:""}),o,"edit")};/* @__PURE__ */
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */
|
|
4
|
-
return
|
|
5
|
-
return
|
|
6
|
-
return
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */
|
|
12
|
-
/* @__PURE__ */
|
|
13
|
-
return
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */
|
|
1
|
+
import{DEFAULT_COPY_WORDS as e}from"../chunk-AUT242JK.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,pasteToMarkup as o,richInput as a,editVisible as s,MARKUP_CLIPBOARD_TYPE as i,markupOfRange as c}from"../chunk-JIWPANGM.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-JIWPANGM.js";import{FieldNumber as u}from"../chunk-66LWADFP.js";import{SettingsSegmented as d,SettingsSwitch as p}from"../chunk-QLD57GBB.js";import"../chunk-FFYXVAAL.js";import{GoldTextInput as f}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as h,applyMark as m,markupTools as g,marksIn as y,STANDARD_MARKUP as v,findLink as b,markedAt as k,listIn as x,colorIn as w,spanFor as S,clearStyle as E,toggleMark as C,colorOver as D,setList as N,unlinkAt as L,removeLink as T,linkOver as M,writeLink as P}from"../chunk-546BBOPE.js";import{useWords as R}from"../chunk-MFIRYGHW.js";import{withTip as B}from"../chunk-P2VEMZH5.js";import{Tooltip as O,ColorSwatch as z,ColorPickerPanel as K,Button as F,IconButton as W,registerModalEscapeInterceptor as $,textToolbarRows as j,TextToolbar as H,LinkPicker as A}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as I,useState as V,useLayoutEffect as U,useEffect as q,useId as Y}from"react";import{AlignJustifyIcon as G,AlignRightIcon as J,AlignCenterIcon as _,AlignLeftIcon as Z,ParagraphSpacingIcon as X,LetterSpacingIcon as Q,TextLinesIcon as ee,TextSizeIcon as te,ClearMarksIcon as ne,LinkIcon as re,QuietIcon as le,EmphasisIcon as oe,StrikeIcon as ae,ItalicIcon as se,BoldIcon as ie}from"efficient-shell/icons/efficient";import{jsx as ce,jsxs as ue,Fragment as de}from"react/jsx-runtime";var pe=["left","center","right","justify"],fe=e.align,he={left:/* @__PURE__ */ce(Z,{}),center:/* @__PURE__ */ce(_,{}),right:/* @__PURE__ */ce(J,{}),justify:/* @__PURE__ */ce(G,{})},me={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function ge(e,t=fe){return pe.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:he[e],title:t[e]}))}var ye=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function ve(e){if(e.every(e=>e.label===fe[e.id]))return e.length>3?me.four:me.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(ye.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function be(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function ke(e,t,n,r=m){const{start:l,end:o}=be(e,n);return r(e,l,o,t)}function xe(e,t,n){const{start:r,end:l}=be(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function we(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 Se(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 Ee(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 Ce({value:e,rules:l,multiline:u,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]=V(0),M=I({value:e,rules:l,multiline:u,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v});M.current={value:e,rules:l,multiline:u,readOnly:d,pending:b,onEdit:m,onHistory:y,onFormat:v};const P=()=>{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=Se(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Se(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},R=(e,t)=>{const n=w.current,r=S.current;if(!n||!r)return;const[l,o]=Ee(r,e),[a,s]=Ee(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};h.current={getSource(){const e=P(),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]=Ee(l,o),[c,u]=Ee(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},U(()=>{const n=w.current;if(!n||D.current)return;const o=C.current?null:P();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=we(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&&R(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(),R(i,c)},[e,l,L]);const B=(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)};q(()=>{const e=w.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:s}=M.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const i=S.current,c=P();if(!i||!c)return;const u="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,d=u&&!u.collapsed?[Se(i,e,u.startContainer,u.startOffset),Se(i,e,u.endContainer,u.endOffset)]:null,p=a({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:s});p&&("history"!==p.kind?"format"!==p.kind?B(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)}},[]),q(()=>{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=P();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(i,c(e,l,r[0],r[1])),n&&!d&&B(s(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
|
|
2
|
+
return ue("div",{className:"es-rich-wrap",children:[p&&""===e?/* @__PURE__ */ce("div",{className:"es-rich-placeholder","aria-hidden":"true",children:p}):null,
|
|
3
|
+
/* @__PURE__ */ce("div",{ref:w,className:`es-rich${u?" is-multiline":" is-single"}${d?" is-off":""}`,contentEditable:!d,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":u,"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||u||(t.preventDefault(),e!==N.current&&k?.(e),N.current=e)},onCompositionStart:()=>{const e=P()??[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?B(s(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=P();if(!n)return;const r=t.clipboardData.getData(i),a=r?u?r:r.replace(/\s*\r?\n\s*/g," "):o({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:u,rules:l});B(s(e,l,n[0],n[1],{markup:a}),n,"edit")}})]})}var De={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ce(te,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ce(ee,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ce(Q,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ce(X,{}),unit:"px",step:1,shiftStep:10,min:0}};function Ne(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Le({cells:t,words:n,readOnly:r=!1}){const l=n??e.cells;/* @__PURE__ */
|
|
4
|
+
return ce("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
|
+
return ce(u,{value:Ne(e.value,t),styleValue:Ne(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 Te=e=>e.preventDefault();function Me({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
|
+
return ue("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:e=>{"INPUT"!==e.target.tagName&&e.preventDefault()},children:[
|
|
7
|
+
/* @__PURE__ */ce("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
8
|
+
/* @__PURE__ */ce("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:e.map(e=>/* @__PURE__ */ce(O,{content:`${e.label} · ${e.value.toUpperCase()}`,children:/* @__PURE__ */ce(z,{color:e.value,size:"sm",className:"es-copy-theme-swatch","data-color":e.name,"aria-label":e.label,selected:t===e.name,onMouseDown:Te,onClick:()=>r(e.name)})},e.name))}),
|
|
9
|
+
/* @__PURE__ */ce("span",{className:"es-copy-pop-label",children:n.any}),
|
|
10
|
+
/* @__PURE__ */ce(K,{className:"es-copy-any",value:l??"",onChange:e=>{e!==t&&r(e)},label:n.title,dragWrites:"end"}),
|
|
11
|
+
/* @__PURE__ */ce("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ce(F,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:Te,onClick:()=>r(null),children:n.remove})})]})}var Pe=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var Re=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function Be(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 Oe(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 ze=/* @__PURE__ */new Set([...h,"clear"]),Ke={bold:/* @__PURE__ */ce(ie,{size:16}),italic:/* @__PURE__ */ce(se,{size:16}),strike:/* @__PURE__ */ce(ae,{size:16}),highlight:/* @__PURE__ */ce(oe,{size:16}),quiet:/* @__PURE__ */ce(le,{size:16}),link:/* @__PURE__ */ce(re,{size:16}),clear:/* @__PURE__ */ce(ne,{size:16})};function Fe(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 We={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function $e({tools:t,onApply:n,disabled:r=!1,actions:l,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=R("copy",e),d=("string"==typeof t[0]?g(t).map(e=>({...e,...u.marks[e.style]})):t).filter(e=>!ze.has(e.style));return 0!==d.length||l||o?/* @__PURE__ */ue("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??Ke[e.style],l=c===e.style||Boolean(i?.[e.style]),o="link"===e.style&&Boolean(i);return B(e.title,/* @__PURE__ */ce(W,{onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:r,"aria-label":e.name??e.title,"aria-keyshortcuts":Fe(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":We[e.style]?` ${We[e.style]}`:""}${l?" is-active":""}`,children:t??e.label},e.style))}),l?/* @__PURE__ */ue(de,{children:[
|
|
12
|
+
/* @__PURE__ */ce("span",{className:"es-copy-bar-split","aria-hidden":"true"}),l]}):null,o?/* @__PURE__ */ce("span",{className:"es-copy-bar-end",children:o}):null]}):null}function je({target:e,onChange:t}){const n=I(null);return U(()=>{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 He=["bold","italic","underline","strike","sup","sub"];function Ae({value:t,onChange:n,onCommit:r,onCancel:a,multiline:s=!1,placeholder:i,ariaLabel:c,className:u,readOnly:h=!1,rules:O,tools:z=[],writeMark:K,actions:W,align:G,glyphs:J,barLabel:_,renderFooter:Z,inputRef:X,barShows:Q="always",richText:ee=!0,defaultShowMarks:te=!1,toolbar:re="final",colors:le,cells:oe,letterCase:ae,lastTool:se}){const ie="final"===re,pe=R("copy",e),fe=I(null),he=X??fe,[me,ye]=V(!1),[be,we]=V(null),Se=I(l()).current,Ee=I(null);q(()=>{const e=Ee.current;e&&t===e.to?Ee.current=null:e&&t===e.from||(Ee.current=null,Se.reset())},[t,Se]);const De=e=>{Ee.current={from:Ee.current?.from??t,to:e},n(e)},Ne=e=>({text:t,start:e?.selectionStart??be?.start??t.length,end:e?.selectionEnd??be?.end??t.length}),[Te,Ke]=V(te),Fe=ee&&!(s&&Te),We=I(null),Ae=Y(),[Ie,Ve]=V(null),[Ue,qe]=V(!1),Ye=()=>{if(!Fe)return he.current;const e=We.current?.getSource()??be;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Ge=je({target:he,onChange:De}),Je=e=>(we({start:e.selectionStart,end:e.selectionEnd}),e),_e=(e,n)=>{if(!Fe)return void Ge(t=>(n&&Se.record(Ne(t),"edit",Date.now()),Je(e(t))));const r=Ye(),l=Je(e(r));n&&Se.record(Ne(r),"edit",Date.now()),Ve(null),l.text!==t&&De(l.text),We.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ze=e=>_e(e,!0),Xe=e=>_e(t=>{const n=Ne(t),r=Se[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Qe=I(null);U(()=>{const e=Qe.current;e&&(Qe.current=null,Fe?We.current?.setSource(e.start,e.end,t):(he.current?.focus(),he.current?.setSelectionRange(e.start,e.end),we(e)))},[Fe]);const[et,tt]=V(null),nt=O??v,rt=("string"==typeof z[0]?g(z):z).filter(e=>!ze.has(e.style)),lt=ie?("string"==typeof z[0]?z:z.map(e=>e.style)).filter(e=>!ze.has(e)):rt.map(e=>e.style),ot={};if(be&&(Fe||ie)){const e=y(t,be.start,be.end,nt);for(const t of lt){const n=e.has(t)||"highlight"===t&&e.has("accent");ot[t]=!!Ie?.add.includes(t)||!Ie?.drop.includes(t)&&n}ie&&(ot.link=e.has("link"))}else if(be)for(const e of lt)ot[e]="link"===e?null!==b(t,be.start,be.end):k(t,be.start,be.end,e);const at=()=>{const e=Ye(),n=e?.selectionStart??t.length;return{start:n,end:e?.selectionEnd??n}},st={sup:"sub",sub:"sup"},it=e=>{if(ie&&"link"!==e&&S(0,e)){const{start:n,end:r}=at(),l=st[e];if(n===r){if(!Fe)return void Ze(n=>ke(t,e,n,(e,t,n,r)=>m(e,t,n,r,nt,pe.placeholders)));const o=y(t,n,r,nt),a=Ie&&Ie.at===n?Ie:null,s=o.has(e),i=!!a?.add.includes(e)||!a?.drop.includes(e)&&s;let c=(a?.add??[]).filter(t=>t!==e),u=(a?.drop??[]).filter(t=>t!==e);return i&&s?u.push(e):i||s||c.push(e),!i&&l&&(c=c.filter(e=>e!==l),o.has(l)&&(u=[...u.filter(e=>e!==l),l])),void Ve(c.length||u.length||void 0!==a?.color?{add:c,drop:u,color:a?.color,at:n}:null)}return void Ze(()=>{let o=t,a=n,s=r;if(l&&!y(o,a,s,nt).has(e)&&y(o,a,s,nt).has(l)){const e=C(o,a,s,l,nt);({text:o,selectionStart:a,selectionEnd:s}=e)}return C(o,a,s,e,nt)})}if("clear"===e)return void Ze(n=>ke(t,e,n,(e,t,n)=>m(e,t,n,"clear",nt)));if("link"!==e&&Fe&&S(0,e)){const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;if(r===l){const n=y(t,r,l,nt),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 Ve(i.length||c.length?{add:i,drop:c,at:r}:null)}return void Ze(n=>C(t,n?.selectionStart??r,n?.selectionEnd??l,e,nt))}if("link"!==e){const n=K??((e,t,n,r)=>m(e,t,n,r,v,pe.placeholders));return void Ze(r=>ke(t,e,r,n))}const n=Ye(),r=n?.selectionStart??t.length,l=n?.selectionEnd??r;qe(!1),tt({start:r,end:l,link:b(t,r,l)})},ct=Boolean(be&&be.start!==be.end),ut=be?x(t,be.start,be.end,nt):null,dt=be?Ie&&void 0!==Ie.color&&Ie.at===be.start?Ie.color:w(t,be.start,be.end,nt):null,pt=dt?dt.startsWith("#")?dt:le?.find(e=>e.name===dt)?.value:void 0,ft=e=>{Fe?e?We.current?.setSource(e.start,e.end,t):We.current?.focus():(he.current?.focus(),e&&he.current?.setSelectionRange(e.start,e.end))},ht=()=>{const e=et;tt(null),ft(e?{start:e.start,end:e.end}:be)},mt=()=>{const e=yt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));qe(!1),t&&ft(be)},gt=I(mt);gt.current=mt,q(()=>{if(Ue)return $(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"))},[Ue]);const yt=I(null),vt=Ue||null!==et;q(()=>{const e=yt.current;if(!vt||!e)return;const t=e.ownerDocument,n=()=>{qe(!1),tt(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=et??(Ue?be??{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=Fe?null:e.querySelector(".es-gold-layer"),r=Fe?We.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?Re(t):Re(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=Pe(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=Pe(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:Be(e),parent:Oe(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"},U(()=>{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,Ue,et,bt?.start,bt?.end,Fe]);const xt=e=>et&&/* @__PURE__ */ce(A,{className:e?"es-copy-link es-copy-pop":"es-copy-link",value:et.link?.href??"",onApply:e=>{const n=et;tt(null),Ze(()=>Fe?M(t,n.start,n.end,e,nt):P(t,n.start,n.end,e))},onRemove:et.link?()=>{const e=et.link,n=et;tt(null),e&&Ze(()=>Fe?L(t,n.start,n.end,nt):T(t,e))}:void 0,onCancel:ht}),wt=G?ge(G.allow,pe.align):[],St="always"===Q||me||null!==et||Ue,Et=le&&le.length>0?{run:pt,open:Ue,onToggle:()=>{tt(null),Ue?mt():qe(!0)}}:void 0,Ct=St&&ie&&se?se({className:"rosh-tb-btn",disabled:h,selected:ct,keepCaret:e=>e.preventDefault(),insert:e=>Ze(n=>xe(t,e,n))}):void 0,Dt=new Set(lt),Nt=G?{value:G.value,allow:G.allow,onChange:G.onChange,disabled:G.disabled}:void 0,Lt={pressed:ut,onList:e=>{const{start:n,end:r}=at(),l=x(t,n,r,nt);Ze(()=>N(t,n,r,l===e?null:e,nt))}},Tt=j({offered:Dt,color:Et,last:Ct,alignment:Nt,list:Lt,letterCase:ae}),Mt=ie&&St&&(He.some(e=>Dt.has(e))||Boolean(Et));/* @__PURE__ */
|
|
13
|
+
return ue("div",{ref:yt,className:"es-copy"+(u?` ${u}`:""),onFocus:()=>ye(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ye(!1)},onKeyDown:e=>{const t=e.target===he.current||Boolean(e.target.closest?.(".es-rich"));if(h||!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 Xe(l||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(ie){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!lt.includes(t))return;return e.preventDefault(),e.stopPropagation(),void it(t)}const a=rt.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),it(a.style))},onPaste:e=>{const n=he.current;if(h||!n||e.target!==n)return;e.preventDefault();const r=o({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:s,rules:nt});Ze(e=>xe(t,r,e))},style:le&&le.length>0?Object.fromEntries(le.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const e=he.current;e&&e.ownerDocument.activeElement===e&&we({start:e.selectionStart??t.length,end:e.selectionEnd??t.length})},children:[St&&ie&&(Tt.words||Tt.paragraph)?
|
|
14
|
+
/* @__PURE__ */ce(H,{className:"es-copy-toolbar","aria-label":_??pe.formatting,offered:Dt,pressed:ot,onMark:e=>it(e),color:Et,linkOpen:null!==et,last:Ct,alignment:Nt,list:Lt,letterCase:ae,disabled:h,windows:/* @__PURE__ */ue(de,{children:[Ue&&le&&le.length>0?/* @__PURE__ */ce(Me,{colors:le,current:dt,words:pe.colors??e.colors,onPick:e=>{const{start:n,end:r}=at();if(n!==r)Ze(()=>D(t,n,r,e,nt));else{if(!Fe)return;Ve({add:Ie?.add??[],drop:Ie?.drop??[],color:e,at:n})}}}):null,et?xt(!0):null]})}):null,ie&&oe&&oe.length>0?/* @__PURE__ */ce(Le,{cells:oe,words:pe.cells??e.cells,readOnly:h}):null,St&&!ie?/* @__PURE__ */ce($e,{tools:z,disabled:h,actions:W,glyphs:J,ariaLabel:_,pressed:ot,open:et?"link":null,onApply:it,align:G?/* @__PURE__ */ce(d,{options:wt,value:G.value,onChange:G.onChange,ariaLabel:pe.alignment,disabled:h||G.disabled,fit:ve(wt)}):null}):null,Fe?/* @__PURE__ */ce(Ce,{value:t,rules:nt,multiline:s,readOnly:h,placeholder:i,ariaLabel:c,handle:We,pending:Ie??void 0,onEdit:(e,n,r)=>{Se.record({text:t,start:n.start,end:n.end},r,Date.now()),Ve(null),De(e)},onSelect:e=>{we(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Ie||e.start===Ie.at&&e.end===Ie.at||Ve(null)},onHistory:Xe,onFormat:e=>{lt.includes(e)&&it(e)},onCommit:r,onCancel:a}):/* @__PURE__ */ce(f,{value:t,onInput:e=>{Se.record(Ne(null),"type",Date.now()),De(e)},onCommit:r,onCancel:a,multiline:s,placeholder:i,ariaLabel:c,rules:O,disabled:h,inputRef:he,className:"es-copy-box"}),et&&!ie?xt(!1):null,Z?Z({focused:me,insert:e=>Ze(n=>xe(t,e,n))}):null,ee&&s||Mt?
|
|
15
|
+
/* @__PURE__ */ue("div",{className:"es-copy-marks",children:[ee&&s?/* @__PURE__ */ue(de,{children:[
|
|
16
|
+
/* @__PURE__ */ce(p,{checked:Te,onChange:()=>{const e=Ye();Qe.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:be,Ve(null),Ke(e=>!e)},ariaLabelledBy:Ae,disabled:h}),
|
|
17
|
+
/* @__PURE__ */ce("span",{id:Ae,className:"es-copy-marks-label",children:pe.showMarks??"Show marks"})]}):null,Mt?B(ct?void 0:pe.clearStyleEmpty??"Select words first",/* @__PURE__ */ue(F,{variant:"secondary",size:"sm",className:"es-copy-clear",disabled:h||!ct,onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:e,end:n}=at();if(e===n)return;const r=E(t,e,n,nt);r.text!==t&&Ze(()=>r)},children:[
|
|
18
|
+
/* @__PURE__ */ce(ne,{size:16}),pe.clearStyle??"Clear style"]})):null]}):null]})}export{pe as COPY_ALIGNS,me as COPY_ALIGN_FIT,he as COPY_ALIGN_GLYPHS,fe as COPY_ALIGN_LABELS,De as COPY_CELLS,Me as ColorWindow,Ae as CopyBox,Le as CopyCells,$e as MarkBar,Ce as RichBox,Fe as ariaShortcut,ge as copyAlignOptions,xe as insertSelection,ke as markSelection,je as useCaretEdit};
|
package/dist/drag/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{AddPanel,CanvasDragLayer,EMPTY_MEASURE,HANDLE_GRACE_MS,canvasTarget,contains,gapInZone,gapLine,measureCanvas,pickSource,seamsBetween,sourcesAt}from"../chunk-
|
|
1
|
+
export{AddPanel,CanvasDragLayer,EMPTY_MEASURE,HANDLE_GRACE_MS,canvasTarget,contains,gapInZone,gapLine,measureCanvas,pickSource,seamsBetween,sourcesAt}from"../chunk-AYNU4FYF.js";import"../chunk-O2NLQBFX.js";export{AUTO_SCROLL_EDGE,AUTO_SCROLL_MAX_SPEED,autoScrollDelta,autoScrollSpeed,createDragSession,dropEffectFor,dropOnRow,frameScrollBox,gapToMoveIndex,isNoOpDrop,scrollBoxOf,scrollParent,startAutoScroll,stepGap,useTreeDrag}from"../chunk-67GNT6PF.js";import"../chunk-AWJUYMX7.js";import"../chunk-P2VEMZH5.js";import"../chunk-KRXQM65X.js";import"../chunk-NKB3KVAB.js";
|
package/dist/easel/easel.css
CHANGED
|
@@ -88,3 +88,20 @@
|
|
|
88
88
|
outline: 1px solid color-mix(in srgb, var(--es-accent, #2563eb) 60%, transparent);
|
|
89
89
|
outline-offset: -1px;
|
|
90
90
|
}
|
|
91
|
+
/* The words being typed (EaselCanvas `typing`, Lewis 2026-10-14): ONE frame,
|
|
92
|
+
a 2px line in the selection's accent, 4px clear of the words, with a thin
|
|
93
|
+
ring of the ink that reads ON the accent just outside it — so the frame
|
|
94
|
+
shows round a button whose own fill is the accent, and on a dark photo. */
|
|
95
|
+
.es-canvas-outline.is-typing {
|
|
96
|
+
outline: 2px solid var(--es-accent);
|
|
97
|
+
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
|
+
}
|
package/dist/easel/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { S as SlotAddress, D as Data, P as Place } from '../types-41704JE4.js';
|
|
|
7
7
|
import { c as ResolveTrigger, a as ResolveCache, R as ResolvableItem } from '../resolve-D68pb3Bx.js';
|
|
8
8
|
import * as react from 'react';
|
|
9
9
|
import { ReactNode, CSSProperties, ComponentType, ReactElement } from 'react';
|
|
10
|
+
import { C as CanvasTypingEnd } from '../canvas-typing-Dec_zyuM.js';
|
|
11
|
+
import { InlineRule } from '../markup/index.js';
|
|
10
12
|
import { b as NodeOpsHost, C as ClipboardEntry } from '../useNodeOps-CLbZyd43.js';
|
|
11
13
|
import { I as InspectorFields } from '../types-OUl0mK1k.js';
|
|
12
14
|
import '../buckets-Tj-nkBpg.js';
|
|
@@ -326,6 +328,40 @@ type CanvasOverlay = ComponentType<{
|
|
|
326
328
|
kind: 'selected' | 'hover';
|
|
327
329
|
children: ReactNode;
|
|
328
330
|
}>;
|
|
331
|
+
/** Words on the canvas a person may type in place: where they are drawn, and how they are written. */
|
|
332
|
+
interface CanvasTypingTarget {
|
|
333
|
+
/** The element the page drew the words in — read again after a redraw. */
|
|
334
|
+
element: () => HTMLElement | null;
|
|
335
|
+
/** The saved string. */
|
|
336
|
+
value: string;
|
|
337
|
+
rules: readonly InlineRule[];
|
|
338
|
+
/** The field has lines: Shift+Enter makes one. */
|
|
339
|
+
multiline: boolean;
|
|
340
|
+
/** The host's ONE writer for these words — the panel's text box's. */
|
|
341
|
+
write: (next: string) => void;
|
|
342
|
+
/** Draw the words afresh (after an IME composition wrote into them). */
|
|
343
|
+
remount?: () => void;
|
|
344
|
+
}
|
|
345
|
+
type CanvasTypingState = {
|
|
346
|
+
typing: true;
|
|
347
|
+
element: HTMLElement;
|
|
348
|
+
} | {
|
|
349
|
+
typing: false;
|
|
350
|
+
why: CanvasTypingEnd;
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Typing the words on the canvas in place (Lewis 2026-10-14, for Victor): the
|
|
354
|
+
* canvas owns the gesture — a single click selects, a double-click types — and
|
|
355
|
+
* the host says which words may be typed and how they are written.
|
|
356
|
+
*/
|
|
357
|
+
interface CanvasTyping {
|
|
358
|
+
/** The words under `target` the host lets a person type, or null. */
|
|
359
|
+
at: (target: Element) => CanvasTypingTarget | null;
|
|
360
|
+
/** The words of the selection, for Enter to type them from the keyboard. */
|
|
361
|
+
atSelection?: () => CanvasTypingTarget | null;
|
|
362
|
+
/** Typing started or ended: the host's text toolbar comes to the words, its panel follows. */
|
|
363
|
+
onChange?: (state: CanvasTypingState) => void;
|
|
364
|
+
}
|
|
329
365
|
interface EaselCanvasProps {
|
|
330
366
|
/** Draw in an iframe of the easel's own (default), or straight into the page. */
|
|
331
367
|
frame?: boolean;
|
|
@@ -375,12 +411,21 @@ interface EaselCanvasProps {
|
|
|
375
411
|
overlay?: CanvasOverlay;
|
|
376
412
|
/** Drawn inside the frame, after the document — a host's canvas-only layer. */
|
|
377
413
|
children?: ReactNode;
|
|
414
|
+
/**
|
|
415
|
+
* Type the words on the canvas in place (Lewis 2026-10-14): a double-click
|
|
416
|
+
* on words `typing.at` offers types them where they are; a single click
|
|
417
|
+
* still only selects. While typing, the outlines stand down and one frame
|
|
418
|
+
* is drawn round the words, the whole session is one undo step, and the
|
|
419
|
+
* canvas root carries `data-es-typing`. Left out, a double-click is two
|
|
420
|
+
* clicks, as before.
|
|
421
|
+
*/
|
|
422
|
+
typing?: CanvasTyping;
|
|
378
423
|
}
|
|
379
424
|
/**
|
|
380
425
|
* `<Puck.Preview>`, ours: the document for editing, its outlines, and the
|
|
381
426
|
* clicks that select. Must sit under an `EaselProvider`.
|
|
382
427
|
*/
|
|
383
|
-
declare function EaselCanvas({ frame, className, style, metadata, mirrorStyles, onDocument, height, title, nonce, hotkeys, frameWrapper: FrameWrapper, overlay, children, }: EaselCanvasProps): ReactElement;
|
|
428
|
+
declare function EaselCanvas({ frame, className, style, metadata, mirrorStyles, onDocument, height, title, nonce, hotkeys, frameWrapper: FrameWrapper, overlay, children, typing, }: EaselCanvasProps): ReactElement;
|
|
384
429
|
|
|
385
430
|
/**
|
|
386
431
|
* THE PARTS, ON THE STORE (blueprint step 5.2).
|
|
@@ -475,4 +520,4 @@ declare function bindUndoKeys(doc: Document, easel: Pick<Easel, 'undo' | 'redo'>
|
|
|
475
520
|
leaveTyping?: boolean;
|
|
476
521
|
}): () => void;
|
|
477
522
|
|
|
478
|
-
export { CanvasFrame, type CanvasFrameProps, type CanvasOverlay, type CanvasSlotProps, DEFAULT_UI, type Easel, EaselAction, EaselCanvas, type EaselCanvasProps, EaselConfig, EaselCore, type EaselOptions, EaselProvider, type EaselProviderProps, EaselUi, EaselView, EditDocument, NodeSelection, Permissions, type SelectedFields, bindUndoKeys, createEasel, createUseEasel, recordsByDefault, reduce, uiView, useEasel, useEaselApi, useEaselNodeOps, useSelectedFields, validSelection };
|
|
523
|
+
export { CanvasFrame, type CanvasFrameProps, type CanvasOverlay, type CanvasSlotProps, type CanvasTyping, type CanvasTypingState, type CanvasTypingTarget, DEFAULT_UI, type Easel, EaselAction, EaselCanvas, type EaselCanvasProps, EaselConfig, EaselCore, type EaselOptions, EaselProvider, type EaselProviderProps, EaselUi, EaselView, EditDocument, NodeSelection, Permissions, type SelectedFields, bindUndoKeys, createEasel, createUseEasel, recordsByDefault, reduce, uiView, useEasel, useEaselApi, useEaselNodeOps, useSelectedFields, validSelection };
|
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-DSUMM2WF.js";import"../chunk-AELNNAFM.js";import"../chunk-YRLPFZW3.js";import"../chunk-UK2FQOUT.js";import"../chunk-JIWPANGM.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-X4OF36J2.js";import"../chunk-4JSBIW5H.js";export{FieldSelect,FieldSlider,optionFor}from"../chunk-OZ72A6MY.js";import"../chunk-3ZJSLHHI.js";import"../chunk-K56YDHYQ.js";import"../chunk-KFV7N2DJ.js";export{useResolvedFields}from"../chunk-YRLPFZW3.js";import"../chunk-EA2HTX37.js";export{FieldNumber}from"../chunk-66LWADFP.js";import"../chunk-QLD57GBB.js";import"../chunk-FFYXVAAL.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-CJBU4E4L.js";import"../../chunk-HQ4VVRIC.js";import"../../chunk-EXCKAZKN.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-MCHMF32I.js";import"../../chunk-DSUMM2WF.js";import"../../chunk-AELNNAFM.js";import"../../chunk-X4OF36J2.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-3ZJSLHHI.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-UK2FQOUT.js";import"../../chunk-JIWPANGM.js";import"../../chunk-66LWADFP.js";import"../../chunk-QLD57GBB.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{blockKey,AddSidePanel as default,sectionKey,templateKey}from"../../chunk-
|
|
1
|
+
export{blockKey,AddSidePanel as default,sectionKey,templateKey}from"../../chunk-B4ZNYLZX.js";import"../../chunk-5ZBY24K7.js";import"../../chunk-PA3PNTVV.js";import"../../chunk-BVN33R76.js";import"../../chunk-PFNIVZPN.js";import"../../chunk-KQMML6JM.js";import"../../chunk-KCOBHPN6.js";import"../../chunk-O7Q4DDJT.js";import"../../chunk-RSCMJIWS.js";import"../../chunk-HQ4VVRIC.js";import"../../chunk-EXCKAZKN.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-MCHMF32I.js";import"../../chunk-DSUMM2WF.js";import"../../chunk-AELNNAFM.js";import"../../chunk-X4OF36J2.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-3ZJSLHHI.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-UK2FQOUT.js";import"../../chunk-UB4TLWVJ.js";import"../../chunk-Y2G7CU6A.js";import"../../chunk-THWO5YVZ.js";import"../../chunk-RE4LP46F.js";import"../../chunk-MJM6SFD3.js";import"../../chunk-2OAZYSWJ.js";import"../../chunk-JIWPANGM.js";import"../../chunk-66LWADFP.js";import"../../chunk-QLD57GBB.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.js";import"../../chunk-MFIRYGHW.js";import"../../chunk-AYNU4FYF.js";import"../../chunk-O2NLQBFX.js";import"../../chunk-67GNT6PF.js";import"../../chunk-AWJUYMX7.js";import"../../chunk-P2VEMZH5.js";import"../../chunk-KRXQM65X.js";import"../../chunk-NKB3KVAB.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{MediaSidePanel as default}from"../../chunk-
|
|
1
|
+
export{MediaSidePanel as default}from"../../chunk-DQLK3QQ2.js";import"../../chunk-EXCKAZKN.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-DSUMM2WF.js";import"../../chunk-AELNNAFM.js";import"../../chunk-X4OF36J2.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-3ZJSLHHI.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-UK2FQOUT.js";import"../../chunk-UB4TLWVJ.js";import"../../chunk-Y2G7CU6A.js";import"../../chunk-THWO5YVZ.js";import"../../chunk-RE4LP46F.js";import"../../chunk-MJM6SFD3.js";import"../../chunk-2OAZYSWJ.js";import"../../chunk-JIWPANGM.js";import"../../chunk-66LWADFP.js";import"../../chunk-QLD57GBB.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.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";
|