efficient-easel 25.0.0 → 25.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/{chunk-ZYOQXBJF.js → chunk-6WTWYHC2.js} +3 -3
- package/dist/{chunk-53ME3GAI.js → chunk-BBD3FLU3.js} +14 -14
- package/dist/{chunk-GEPSJJWW.js → chunk-FEP6XMNX.js} +1 -1
- package/dist/{chunk-4Y3TK65H.js → chunk-ITIVCER6.js} +1 -1
- package/dist/{chunk-KTV7ORWF.js → chunk-IW5QXREH.js} +38 -38
- package/dist/chunk-JQQFB7EZ.js +1 -0
- package/dist/{chunk-YFHKE54W.js → chunk-KF3LT7J2.js} +1 -1
- package/dist/chunk-KVIEUWTX.js +11 -0
- package/dist/{chunk-4OMAA45Q.js → chunk-LUHGBFOD.js} +5 -5
- package/dist/{chunk-MBEUSPIN.js → chunk-SQTVXE5D.js} +4 -4
- package/dist/{chunk-FYV6GZXP.js → chunk-UCZQWQNS.js} +1 -1
- package/dist/chunk-UDWXBS46.js +1 -0
- package/dist/{chunk-M4THI4OO.js → chunk-XLC7HWW3.js} +1 -1
- package/dist/{chunk-VIUES5R6.js → chunk-XTDOSL2M.js} +8 -8
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.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 +17 -17
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +91 -3
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LUG22U5L.js +0 -1
- package/dist/chunk-SSDKT4AY.js +0 -9
- package/dist/chunk-ZLOMH2PD.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-KF3LT7J2.js";import{ScreenChrome as e}from"./chunk-IW5QXREH.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-ERB6FAZT.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-S6YOIRXQ.js";import{documentPermissions as s}from"./chunk-YYD257TD.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(n),C=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
5
|
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function A({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),A=t(()=>s(!g),[g]),D=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:D.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:A,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:D.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:D.waitingForAuthorization})}export{A as DocumentScreen,y as ScreenMount};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-LUG22U5L.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{find as b,ROOT_ID as k,getList as S,remove as C,parseZoneKey as E,move as x,duplicate as I,replaceNode as D,createNode as A,insert as O,normalizeData as M,createResolveCache as $,slotsOf as P,resolveNodeData as R,ROOT_SLOT as z}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as L,fieldsFrom as N,drawnBlockCount as j,defaultsFrom as V}from"./chunk-KXM6YRG2.js";import{CANVAS_TYPABLE_EVENT as K,CANVAS_TYPING_EVENT as B}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as T,related as Z,isTypingTarget as F,upsertCanvasStyle as H,removeCanvasStyle as W,WORDS_CLEAR as q,frameRectToHost as U,drawnBox as Y}from"./chunk-FR7EEKFF.js";import{queryAllCopies as Q}from"./chunk-7UFKEX72.js";import{createContext as G,useEffect as X,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,useMemo as oe,useCallback as re,useLayoutEffect as le}from"react";import{jsx as ie,jsxs as se,Fragment as ae}from"react/jsx-runtime";import{createPortal as ce}from"react-dom";import{registerModalEscapeInterceptor as ue,FloatingBar as de,TextToolbar as pe,LinkPicker as fe}from"efficient-shell/ui";function he(e){return!["setData","setUi","set"].includes(e.type)}var me=(e,t,n,o)=>{const r=S(e,t,E(n));return r?.[o]??null},ge=(e,t,n,o,r)=>{const l=me(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ve(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ye(e,t,n){return n?"node"===n.kind?b(e,t,n.id)?n:null:n.parentId===k?S(e,t,n)?n:null:b(e,t,n.parentId)&&S(e,t,n)?n:null:null}function we(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function be(e,t,n){const o=ke(e,t,n);if(o===e)return e;const r=ye(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ke(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 we(e,n,"function"==typeof t.ui?t.ui(ve(e,n)):t.ui);case"set":{const r={data:o,ui:ve(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=we(i,n,l.ui,!0)),i}case"insert":{const r={...E(t.destinationZone),index:t.destinationIndex},l=A(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:O(o,n,r,l)}}case"replace":{const r=ge(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:D(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=ge(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=I(o,n,r.props.id),i=me(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ke(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=me(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...E(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,l)}}case"remove":{const r=ge(o,n,t.zone,t.index,"remove");return{...e,data:C(o,n,r.props.id)}}default:return e}}var Se={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,xe=()=>`history-${Ee+=1}`;function Ie(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=M(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ce}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:xe()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},k=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},C=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&k(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},E=e=>{const n=c;if(c=be(c,e,t),c===n)return;const o=e.recordHistory??he(e);C(n,o&&c.data!==n.data)},x=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&k(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=e=>{const n=c,o=ye(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},C(n,!1))},A=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},O=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Se,...i,...n}};let P=O();const z=$(),L={resolveCache:z,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([R(r,t,{cache:z,trigger:e,metadata:n}),...l.map(o=>R(o,t,{cache:z,trigger:e,metadata:n}))]);x(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=b(r,t,i)?.node;s&&s===b(o,t,i)?.node&&(r=D(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ye(r,t,c.selection)},C(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=b(c.data,t,e)?.node;if(!r)return!1;const l=await R(r,t,{cache:z,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(b(c.data,t,e)?.node!==r)return;const o=D(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ye(o,t,c.selection)},C(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:ve(e,t)},o="node"===e.selection?.kind?b(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:E,history:{back:()=>L.undo(),forward:()=>L.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ve(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&A(e)}},getPermissions:P,getItemById:n=>b(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return S(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:E,batch:x,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){x(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ye(e.data,t,o)},C(n,e.data!==n.data)})},load(e,n={}){const o=c,r=M(e,t);c={...c,data:r,selection:ye(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0),c!==o&&w()},undo(){d>0&&A(d-1)},redo(){d<u.length-1&&A(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,i)||(i=e,P=O(),h=null,w())},setConfig(e){e!==t&&(t=e,P=O(),h=null,w())}};return L}function De(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&&F(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 Ae=G(null),Oe=G(!0);function Me({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return X(()=>{n&&e.resolveAll()},[e,n]),X(()=>{if(t&&"undefined"!=typeof document)return De(document,e)},[e,t]),/* @__PURE__ */ie(Ae.Provider,{value:e,children:/* @__PURE__ */ie(Oe.Provider,{value:t,children:o})})}function $e(){const e=J(Ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Pe(e){const t=$e(),n=_({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 l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ee(t.subscribe,o,o)}function Re(){return function(e){return Pe(e)}}var ze=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Le="host-tokens";function Ne(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of ze){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?H(t,Le,n):W(t,Le)}var je="data-easel-block",Ve="data-easel-dropzone",Ke={},Be="data-es-mirror",Te="undefined"==typeof window?X:le;function Ze(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Be}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Be,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Fe({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=_(null),[p,f]=te(null);return Te(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Te(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),T(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Ze(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Ze(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Ne(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ne(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ie("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ce(e,p):null})}var He=G(null),We=G(Ke),qe=[];function Ue({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=$e(),s=Pe(n=>S(n.appState.data,i.config,{parentId:e,slot:t})??qe),a=Pe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==k),c=Pe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(He),d=["es-zone"];return s.length&&d.push("has-children"),e===k&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==k&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ie("div",{className:d.join(" "),[Ve]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ie(tt,{node:e},e.props.id))})}function Ye(e,t,n,o){const r=oe(()=>{const n={};for(const o of L(N(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
-
return ie(
|
|
3
|
-
return ie(
|
|
4
|
-
/* @__PURE__ */ie("div",{ref:i,[
|
|
5
|
-
return ie(We.Provider,{value:e??
|
|
6
|
-
return ie("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var dt={"--es-words-clear":`${
|
|
7
|
-
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function ft(e,t,n){return mt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var ht=[];function mt(e,t,n){const[o,r]=te(ht),l=_(t);return l.current=t,
|
|
8
|
-
/* @__PURE__ */ie("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ie("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */ie(n,{componentId:e,kind:t,children:d}):d}function vt(e,n){return Array.from(e.querySelectorAll(`[${
|
|
9
|
-
return ie(de,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-JQQFB7EZ.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CANVAS_TYPABLE_EVENT as b,CANVAS_TYPING_EVENT as k}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as S,related as C,isTypingTarget as E,upsertCanvasStyle as x,removeCanvasStyle as I,WORDS_CLEAR as D,frameRectToHost as A,drawnBox as O}from"./chunk-FR7EEKFF.js";import{queryAllCopies as M}from"./chunk-7UFKEX72.js";import{find as $,ROOT_ID as P,getList as R,remove as z,parseZoneKey as N,move as j,duplicate as V,replaceNode as L,createNode as B,insert as K,normalizeData as Z,createResolveCache as F,slotsOf as T,resolveNodeData as H,ROOT_SLOT as W}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as q,fieldsFrom as Q,drawnBlockCount as Y,defaultsFrom as U}from"./chunk-KXM6YRG2.js";import{createContext as X,useEffect as G,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,useMemo as oe,useCallback as re,useLayoutEffect as le}from"react";import{jsx as ie,jsxs as se,Fragment as ae}from"react/jsx-runtime";import{createPortal as ce}from"react-dom";import{registerModalEscapeInterceptor as ue,FloatingBar as de,TextToolbar as pe,LinkPicker as fe}from"efficient-shell/ui";function he(e){return!["setData","setUi","set"].includes(e.type)}var me=(e,t,n,o)=>{const r=R(e,t,N(n));return r?.[o]??null},ge=(e,t,n,o,r)=>{const l=me(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ve(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ye(e,t,n){return n?"node"===n.kind?$(e,t,n.id)?n:null:n.parentId===P?R(e,t,n)?n:null:$(e,t,n.parentId)&&R(e,t,n)?n:null:null}function we(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function be(e,t,n){const o=ke(e,t,n);if(o===e)return e;const r=ye(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ke(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 we(e,n,"function"==typeof t.ui?t.ui(ve(e,n)):t.ui);case"set":{const r={data:o,ui:ve(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=we(i,n,l.ui,!0)),i}case"insert":{const r={...N(t.destinationZone),index:t.destinationIndex},l=B(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=ge(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:L(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=ge(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=V(o,n,r.props.id),i=me(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ke(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=me(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...N(t.destinationZone),index:t.destinationIndex};return{...e,data:j(o,n,r.props.id,l)}}case"remove":{const r=ge(o,n,t.zone,t.index,"remove");return{...e,data:z(o,n,r.props.id)}}default:return e}}var Se={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,xe=()=>`history-${Ee+=1}`;function Ie(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=Z(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ce}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:xe()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=be(c,e,t),c===n)return;const o=e.recordHistory??he(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=e=>{const n=c,o=ye(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},k(n,!1))},x=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Se,...i,...n}};let D=I();const A=F(),O={resolveCache:A,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([H(r,t,{cache:A,trigger:e,metadata:n}),...l.map(o=>H(o,t,{cache:A,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=$(r,t,i)?.node;s&&s===$(o,t,i)?.node&&(r=L(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ye(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=$(c.data,t,e)?.node;if(!r)return!1;const l=await H(r,t,{cache:A,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return C(()=>{const n=c;if($(c.data,t,e)?.node!==r)return;const o=L(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ye(o,t,c.selection)},k(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:ve(e,t)},o="node"===e.selection?.kind?$(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>O.undo(),forward:()=>O.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ve(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&x(e)}},getPermissions:D,getItemById:n=>$(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return R(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:C,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ye(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=Z(e,t);c={...c,data:r,selection:ye(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0),c!==o&&w()},undo(){d>0&&x(d-1)},redo(){d<u.length-1&&x(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,i)||(i=e,D=I(),h=null,w())},setConfig(e){e!==t&&(t=e,D=I(),h=null,w())}};return O}function De(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&&E(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 Ae=X(null),Oe=X(!0);function Me({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return G(()=>{n&&e.resolveAll()},[e,n]),G(()=>{if(t&&"undefined"!=typeof document)return De(document,e)},[e,t]),/* @__PURE__ */ie(Ae.Provider,{value:e,children:/* @__PURE__ */ie(Oe.Provider,{value:t,children:o})})}function $e(){const e=J(Ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Pe(e){const t=$e(),n=_({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 l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ee(t.subscribe,o,o)}function Re(){return function(e){return Pe(e)}}var ze=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Ne="host-tokens";function je(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of ze){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?x(t,Ne,n):I(t,Ne)}var Ve="data-easel-block",Le="data-easel-dropzone",Be={},Ke="data-es-mirror",Ze="undefined"==typeof window?G:le;function Fe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ke}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ke,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Te({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=_(null),[p,f]=te(null);return Ze(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Ze(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),S(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Fe(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Fe(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){je(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>je(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ie("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ce(e,p):null})}var He=X(null),We=X(Be),qe=[];function Qe({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=$e(),s=Pe(n=>R(n.appState.data,i.config,{parentId:e,slot:t})??qe),a=Pe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==P),c=Pe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(He),d=["es-zone"];return s.length&&d.push("has-children"),e===P&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==P&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ie("div",{className:d.join(" "),[Le]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ie(tt,{node:e},e.props.id))})}function Ye(e,t,n,o){const r=oe(()=>{const n={};for(const o of q(Q(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ie(Qe,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=Y(n[e],o);return r}function Ue(e){return oe(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ie(Qe,{parentId:e,slot:t,...n})},[e])}var Xe=["top","bottom","zIndex"];function Ge(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Je(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Ge(e,"position",t?"sticky":"relative");for(const n of Xe)Ge(e,n,t?.[n]??"");return!!t}var _e="data-es-canvas-relative";function et(e){e.hasAttribute(_e)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(_e));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(_e,"")),!1)}function tt({node:e}){const t=$e().config,n=t.components[e.type],o=e.props.id,r=_(null),l=function(e,t){return oe(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ve),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Ve,e),n.setAttribute("data-easel-dnd",e),et(n))},[e,t])}(o,r),i=_(null),s=!!n?.inline;!function(e,t){const n=_(!1),o=_(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=_(()=>{});Ze(()=>o.current()),Ze(()=>{const t=e(),l=t?.ownerDocument.defaultView;if(!t||!l)return;const i=()=>o.current();l.addEventListener("resize",i);const s=l.ResizeObserver,a=s?new s(i):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&l.MutationObserver&&(c=new l.MutationObserver(i),c.observe(e,{attributes:!0}))},r.current(),()=>{l.removeEventListener("resize",i),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:i.current,e=>s?et(e):Je(e));const a=J(We),c=Ye(n,o,e.props,t.components),u=Ue(o);if(!n?.render)return null;const d=n.render,p={...U(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ie("div",{ref:i,[Ve]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0})})}function nt({metadata:e}){const t=Pe(e=>e.config),n=Pe(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ye(t.root,P,n,t.components),l=Ue(P),i=/* @__PURE__ */ie(Qe,{parentId:P,slot:W}),s=o?/* @__PURE__ */ie(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ie(We.Provider,{value:e??Be,children:s})}var ot=X(void 0),rt=X(void 0);function lt(e,t,n,o){const r=$(e,t,n);return!!r&&(T(r.node,t).length>0||!1===o.whole)}var it=X(void 0),st="data-es-chrome",at=X(void 0);function ct(e){const t=e?.closest?.(`[${st}]`)??null,n=t?.getAttribute(st);return t&&n?{id:n,element:t}:null}function ut({element:e}){const t=_(null),n=ft(t,e?()=>e:null,e);/* @__PURE__ */
|
|
6
|
+
return ie("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var dt={"--es-words-clear":`${D}px`};function pt({element:e,words:t=!1}){const n=_(null),o=ft(n,e?()=>e:null,e);/* @__PURE__ */
|
|
7
|
+
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function ft(e,t,n){return mt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var ht=[];function mt(e,t,n){const[o,r]=te(ht),l=_(t);return l.current=t,Ze(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(ht);let o=0;const i=()=>{o=0;const n=e.current?.parentElement??null,i=(l.current?l.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=O(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=i)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:i.length?i:ht;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.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),n.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function gt({id:e,kind:t,overlay:n}){const o=_(null),r=J(rt),l=null!==e&&!0===r?.(e),i=mt(o,e?t=>M(t,`[${Ve}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=`es-canvas-outline is-${t}${l?" is-shared":""}`,u=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),d=/* @__PURE__ */se(ae,{children:[
|
|
8
|
+
/* @__PURE__ */ie("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ie("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */ie(n,{componentId:e,kind:t,children:d}):d}function vt(e,n){return Array.from(e.querySelectorAll(`[${Ve}]`)).find(o=>o.getAttribute(Ve)===n&&t(o)?.wrapper===e)??null}function yt(e,t,n){const o=g(e,n),r=o.text.length,l=e.ownerDocument;if(!t)return[r,r];let i=null;const s=l.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))i=o.at(s.offsetNode,s.offset);else{const n=l.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(i=o.at(n.startContainer,n.startOffset))}if(null===i)return[r,r];const a=o.text;let c=i,u=i;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;u<a.length&&!/\s/.test(a[u]);)u+=1;return[c,u]}function wt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",y),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=_(null),[m,g]=te(!1),[v,b]=te(null),k=m||null!==v,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},C=()=>{g(!1),b(null),e.resume()};le(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),le(()=>()=>{r.current=null},[r]);const E=_(C);E.current=C,G(()=>{if(m)return ue(e=>{const t=c.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>c.current?.querySelector(".es-copy-colors"))},[m]),G(()=>{const n=c.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;g(!1),b(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[k,e,t]),le(()=>{const e=c.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?A(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},f=o.getBoundingClientRect(),h=s?A(s,{left:f.left,top:f.top,width:f.width,height:f.height}):{left:f.left,top:f.top,width:f.width,height:f.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,h.top-6,m.top),bottom:Math.max(a.top+a.height,h.top+h.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=d({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:p(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const x=a?{run:f(i.color,a),open:m,onToggle:()=>{b(null),m?C():(e.hold(),g(!0))}}:void 0;/* @__PURE__ */
|
|
9
|
+
return ie(de,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?A(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__ */ie("div",{ref:c,children:/* @__PURE__ */ie(pe,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:x,linkOpen:null!==v,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */se(ae,{children:[m&&a?/* @__PURE__ */ie(h,{colors:a,current:i.color,words:l.colors??y.colors,onPick:t=>e.color(t)}):null,v?
|
|
10
10
|
/* @__PURE__ */ie(fe,{className:"es-copy-link es-copy-pop",value:v.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==v.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function bt({element:e,which:t}){const n=_(null),o=ft(n,()=>e(),t);/* @__PURE__ */
|
|
11
|
-
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function kt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:
|
|
12
|
-
/* @__PURE__ */ie(He.Provider,{value:
|
|
11
|
+
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function kt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:S,overlay:E,children:x,typing:I,passThrough:D}){const A=$e(),O=J(ot),M=D??O,P=J(Oe),R=w("canvas",n),z=y??P,[N,j]=te(void 0),V=Pe(e=>"node"===e.selection?.kind?e.selection.id:null),[L,B]=te(null),[K,Z]=te(null),F=J(it),H=J(at),[W,q]=te(null),[,Q]=ne(e=>e+1,0),[,Y]=ne(e=>e+1,0),U=e=>{F?.select(e),Y()},[X,ee]=te(null),oe=_(null),re=_(null),[,le]=te(0),ae=_(I);ae.current=I;const ce=_(null),ue=_(null),de=()=>{if(!V)return null;const e=ae.current?.atSelection?.()?.element()??null;if(!e)return null;const t=ue.current?.ownerDocument;if(F){const n=F.selected()&&t?F.selectedPart?.(t)??null:null;return n&&C(n.element,e)?n.element:null}const n=$(A.getState().appState.data,A.config,V);return n&&0===T(n.node,A.config).length?e:null},pe=Pe(e=>e.appState.data),fe=F?.selected()??null;G(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=V&&!X&&ae.current?.atSelection?.()?V:null,o=n?de():null;e.dispatchEvent(new t(b,{detail:o?{id:n,words:o}:{id:n}}))},[V,X,pe,fe]);const he=e=>{const t=ue.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},me=(e,t)=>{oe.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=A.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:yt(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>ce.current?.escape()??!1,onLinkKey:()=>ce.current?.link()??!1,end:e=>{r.close(),oe.current?.element===l&&(oe.current=null),ee(null),he(!1),ae.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${Ve}]`)?.getAttribute(Ve);return s&&A.select(s),oe.current={s:i,element:l,target:e},ee(()=>l),B(null),he(!0),ae.current?.onChange?.({typing:!0,element:n}),!0},ge=(e,n)=>{const o=e.key;if(!o||!ae.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${Ve}]`),i=l?.getAttribute(Ve);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=ae.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(v(e.value,e.rules).text===c?e.value:c),d={ownerId:s.ownerId,slot:s.slot,index:s.index,...s.outer?{outer:s.outer}:{},nodeId:i,key:o};return{value:u,write:t=>{const n=ae.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};G(()=>()=>oe.current?.s.stop("stop"),[]);const ve=e=>{const t=oe.current?.element();return Boolean(t&&t.contains(e))},ye=(e,t)=>lt(A.getState().appState.data,A.config,e,t),we=e=>{const t=e.closest?.(`[${Ve}]`)?.getAttribute(Ve);if(!t)return;const n=A.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,A.config,t,r.id,o,F?.selected()??null,M);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,A.config,t,o,M)??t,part:null}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(oe.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=ke(),o=void 0===n?ae.current?.atSelection?.():n;o&&me(o,null)&&e.preventDefault()},ke=()=>{const t=ae.current,n=re.current;if(!t?.onCopyText||!n?.copy||n.node!==V)return;const o=ue.current,r=o?e(o,n.copy):null,l=r?vt(r,n.node):null;if(!l)return null;const i=t.atSelection?.()??null,s=i?.element()??null;if(!i||!s)return null;if(l.contains(s))return i;const a=function(e,t){const n=e.closest(`[${Ve}]`);if(!n||n.getAttribute(Ve)!==t.getAttribute(Ve))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},Se=(e,n)=>{if(!ae.current?.onCopyText)return null;const o=t(e);return o&&vt(o.wrapper,n)?o.copy:null},Ce=ue.current?.ownerDocument??null,Ee=F?.selected()&&Ce&&V?F.selectedPart?.(Ce)??null:null,xe=Ee&&V&&ye(V,Ee)?Ee.element:null,Ie=H?.selected()??null,Ae=Ie&&Ce?Array.from(Ce.querySelectorAll(`[${st}]`)).find(e=>e.getAttribute(st)===Ie)??null:null,Me=X?null:de(),Re=/* @__PURE__ */se("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),oe.current){if(ve(t))return;oe.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?ct(t):null;if(H&&o)return H.select(o.id),q(null),void Q();const r=we(t);if(re.current=void 0!==r?{node:r.node,copy:Se(t,r.node)}:null,void 0!==r)return A.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&U(r.part?.id??null));t.hasAttribute?.(Le)||(A.select(null),F?.selected()&&U(null))},onDoubleClick:e=>{const t=ae.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&me(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>be(e),onMouseOver:e=>{if(oe.current)return;const t=H?ct(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==L&&B(null),void(null!==K&&Z(null));const n=we(e.target),o=!!n?.part&&ye(n.node,n.part),r=n?.part&&o&&n.part.id!==F?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==L&&B(l),r?.id===K?.id&&r?.element===K?.element||Z(r)},onMouseLeave:()=>{B(null),Z(null),q(null)},children:[
|
|
12
|
+
/* @__PURE__ */ie(He.Provider,{value:L,children:/* @__PURE__ */ie(nt,{metadata:i})}),
|
|
13
13
|
/* @__PURE__ */se("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
14
|
-
/* @__PURE__ */ie(gt,{id:!
|
|
15
|
-
/* @__PURE__ */ie(gt,{id:
|
|
16
|
-
return se("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":
|
|
14
|
+
/* @__PURE__ */ie(gt,{id:!X&&L&&L!==V?L:null,kind:"hover",overlay:E}),F?/* @__PURE__ */ie(ut,{element:X||!K||K.id===F.selected()?null:K.element}):null,Me||xe?/* @__PURE__ */ie(pt,{element:X?null:Me??xe,words:null!==Me}):null,H?/* @__PURE__ */ie(ut,{element:X||!W||W.element===Ae?null:W.element}):null,Ae?/* @__PURE__ */ie(pt,{element:X?null:Ae}):null,
|
|
15
|
+
/* @__PURE__ */ie(gt,{id:X||xe||Me||Ae?null:V,kind:"selected",overlay:E}),X?/* @__PURE__ */ie(bt,{element:()=>{const e=X?.()??null;return e?Ee&&C(Ee.element,e)?Ee.element:e:null},which:Ee?.element??X}):null]}),x]}),ze=S?/* @__PURE__ */ie(S,{document:N,children:Re}):Re;G(()=>{if(N&&z)return De(N,A)},[N,z,A]),G(()=>{if(!N)return;const e=e=>{if("Enter"===e.key)return void be(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=A.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void U(null);const o=s(n.appState.data,A.config,n.selection);"node"===o?.kind&&A.select(o.id)};return N.addEventListener("keydown",e),()=>N.removeEventListener("keydown",e)},[N,A,F]);/* @__PURE__ */
|
|
16
|
+
return se("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":X?"":void 0,children:[X&&oe.current?.target.toolbar?/* @__PURE__ */ie(wt,{s:oe.current.s,element:oe.current.element,toolbar:oe.current.target.toolbar,label:R.textTools,keys:ce}):null,o?/* @__PURE__ */ie(Te,{mirrorStyles:u,onDocument:e=>{j(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:ze}):/* @__PURE__ */ie("div",{id:"preview-frame","data-easel-entry":"",children:ze})]})}function St(e={}){const t=$e(),n=Pe(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ct(){return It(Pe(e=>e.selectedItem))}function Et(){try{return Ct()}catch{return null}}function xt(){return It(null)}function It(e){const t=$e(),n=Pe(e=>e.config),r=t.resolveCache,l=Pe(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=oe(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?$(u.appState.data,n,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=o({id:i,node:a,block:c,parent:f,appState:u.appState}),m=Pe(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=re(e=>{(async()=>{const o=t.getState();if("root"!==i){const l=o.getItemById(i),s=o.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...e}},{node:c}=await H(a,n,{cache:r,trigger:"replace"}),u=t.getState().getSelectorForId(i);if(!u)return;return void t.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const l=o.appState.data.root.props??{},{node:s}=await H({type:"root",props:{...l,...e}},n,{cache:r,trigger:"replace"});t.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[t,n,r,i]),v=re((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{st as CHROME_ATTR,at as CanvasChromeContext,Te as CanvasFrame,it as CanvasPartsContext,ot as CanvasPassThroughContext,rt as CanvasSharedContext,Ce as DEFAULT_UI,kt as EaselCanvas,Me as EaselProvider,nt as EditDocument,De as bindUndoKeys,Ie as createEasel,Re as createUseEasel,lt as partHasOwnBox,he as recordsByDefault,be as reduce,ve as uiView,Pe as useEasel,$e as useEaselApi,St as useEaselNodeOps,xt as useRootFields,Ct as useSelectedFields,Et as useSelectedHost,ye as validSelection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-S6YOIRXQ.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-S6YOIRXQ.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-JQQFB7EZ.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{useCanvasEvent as d}from"./chunk-TOKMFZPB.js";import{isTypingTarget as p,framePointToHost as f}from"./chunk-FR7EEKFF.js";import{zoneKey as m,ROOT_SLOT as y,ROOT_ID as h}from"./chunk-EUFDQ4KL.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as w,AddIcon as C,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as P,RedoIcon as A,PasteIcon as E,StylesIcon as j,LayersIcon as D,CopyIcon as K}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var I=s(),L=/* @__PURE__ */new WeakMap;function Y(e){if(e.claimsPage)return I;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=L.get(n);return t||(t=s(),L.set(n,t)),t}function S(){return Y(e())}function F(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:y,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function X(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function B(e,n,t){const o=e.canPasteAt;if(!o)return m(n.from)===t.zone?F(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=F(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function Q(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=X(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:B(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function U(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=X(e,i,t),k=T(e,n),b=d.held,v=b&&!p?B(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...W(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:N(x?V(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?Z(e).pinned:void 0})}function V(e,n){const o=e.copyItem;if(!o||!n)return null;const l=Z(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */M(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */M(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */M(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */M(w,{}),danger:!0,onClick:s("delete")}]}}function N(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function W(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var Z=e=>e.words?.screen??t.menu;function G(e){const n=Z(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(P,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=F(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):m(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */M(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */M(D,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=Z(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=Q(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),d(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=f(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),d(t,"mousedown",i),d(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */M($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?J(e,n.el):G(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{I as EASEL_NODE_CLIPBOARD,T as ancestorChain,Y as nodeClipboardOf,X as nodeClipboardRules,U as nodeMenuItems,R as nodeShortcut,G as pageMenuItems,B as pastePlace,Q as runNodeShortcut,J as textMenuItems,S as useNodeClipboard,H as useNodeContextMenu};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-LUHGBFOD.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-S6YOIRXQ.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
|
|
2
2
|
/* @__PURE__ */o("span",{children:e.group}),
|
|
3
3
|
/* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
4
4
|
return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
|