efficient-easel 27.1.0 → 27.2.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/AddSidePanel-DoCx-ZrM.d.ts +1994 -0
- package/dist/{ScreenDocumentContext-DPW_6gOC.d.ts → ScreenDocumentContext-JQr4hTeP.d.ts} +7 -5
- package/dist/{chunk-P3HXHLES.js → chunk-2Y4CAWZQ.js} +3 -3
- package/dist/{chunk-RTMDZJNE.js → chunk-3RGHXL5V.js} +1 -1
- package/dist/chunk-64NREOML.js +1 -0
- package/dist/chunk-DCBUJ36Q.js +5 -0
- package/dist/{chunk-SEC6NV6Y.js → chunk-DQSRGKSM.js} +4 -4
- package/dist/{chunk-L36E2WCO.js → chunk-HGTDDSFJ.js} +15 -15
- package/dist/{chunk-LAJYMOY3.js → chunk-I4Z75MCX.js} +1 -1
- package/dist/{chunk-QPNNWQ24.js → chunk-JI7GUM3C.js} +1 -1
- package/dist/chunk-LK56FUFT.js +1 -0
- package/dist/chunk-M5UCPD66.js +1 -0
- package/dist/{chunk-XESNAMI3.js → chunk-MMHYTIUY.js} +3 -3
- package/dist/chunk-OSF2H3LO.js +1 -0
- package/dist/{chunk-3FANFZ4D.js → chunk-PTTQWCD7.js} +1 -1
- package/dist/{chunk-WL57KM5C.js → chunk-SR2535CN.js} +17 -17
- package/dist/{chunk-SEH3Q3EL.js → chunk-XGTO4LHI.js} +1 -1
- package/dist/chunk-YCYGY54I.js +8 -0
- package/dist/chunk-ZSP4ZAQ2.js +64 -0
- 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.d.ts +2 -4
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +2 -4
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/SaveControls.d.ts +2 -4
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
- package/dist/screen/components/ScreenMount.d.ts +2 -4
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +2 -4
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/usePartBridge.d.ts +2 -4
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +2 -4
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/add-target-types.d.ts +37 -55
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.d.ts +1 -1
- package/dist/screen/lib/document/block-size-fields.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +1 -1
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.d.ts +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.d.ts +1 -1
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/new-child.d.ts +58 -0
- package/dist/screen/lib/document/new-child.js +1 -0
- package/dist/screen/lib/document/palette-sections.d.ts +2 -4
- package/dist/screen/lib/document/shadow-fields.d.ts +1 -1
- package/dist/screen/lib/document/shadow-fields.js +2 -2
- package/dist/screen/lib/document/slot-section-spec.d.ts +37 -96
- package/dist/screen/lib/document/style-clipboard.d.ts +2 -4
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/style-fields.d.ts +1 -1
- package/dist/screen/lib/document/style-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/document-addressing.d.ts +1 -1
- package/dist/screen/lib/host.d.ts +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/media-panel.d.ts +1 -1
- package/dist/screen/lib/media-picker.d.ts +1 -1
- package/dist/screen/lib/screen-parts.d.ts +20 -1827
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +7 -1
- package/dist/chunk-DTEYSPJE.js +0 -64
- package/dist/chunk-GJ427TZL.js +0 -8
- package/dist/chunk-J5VPNHOW.js +0 -1
- package/dist/chunk-TUIBPB77.js +0 -5
- package/dist/chunk-WW24O7HT.js +0 -1
- package/dist/chunk-XT75WETI.js +0 -1
|
@@ -261,13 +261,15 @@ type EaselToHostMessage =
|
|
|
261
261
|
slug: string;
|
|
262
262
|
}
|
|
263
263
|
/** Open one section of the website's own pages in the host — its Settings
|
|
264
|
-
* (`section: "settings"`, e.g. Selling, where the stock rules live)
|
|
265
|
-
* Shipping (`"shipping"`, the pickup places)
|
|
266
|
-
*
|
|
267
|
-
*
|
|
264
|
+
* (`section: "settings"`, e.g. Selling, where the stock rules live), its
|
|
265
|
+
* Shipping (`"shipping"`, the pickup places) or its Reviews (`"reviews"`,
|
|
266
|
+
* where shoppers' reviews are moderated). For a panel row that reads a
|
|
267
|
+
* website rule or record it does not own and offers to open where it is
|
|
268
|
+
* kept. The admin portal opens that Storefront section; nothing answers
|
|
269
|
+
* back. */
|
|
268
270
|
| {
|
|
269
271
|
type: "storefront-editor:open-site-section";
|
|
270
|
-
section: "settings" | "shipping";
|
|
272
|
+
section: "settings" | "shipping" | "reviews";
|
|
271
273
|
} | {
|
|
272
274
|
type: "storefront-editor:new-page";
|
|
273
275
|
}
|
|
@@ -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-JI7GUM3C.js";import{ScreenChrome as e}from"./chunk-ZSP4ZAQ2.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-OB4KI2AN.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-G2VZ4DET.js";import{documentPermissions as s}from"./chunk-G7J6SGMF.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 N({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
|
-
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{
|
|
5
|
+
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
6
|
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function G({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),G=t(()=>s(!g),[g]),A=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
-
/* @__PURE__ */u(
|
|
7
|
+
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:G,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:A.waitingForAuthorization})}export{G as DocumentScreen,j as ScreenMount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-LX23TCTP.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-HGTDDSFJ.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defaultsFrom as n,blockOf as i}from"./chunk-KXM6YRG2.js";function l(l){return e=>n(i(l,e))??{}}function e(n,i,l){return n?.newChild&&i===n.childType?n.newChild(l):null}function r(n,i){return n?.newChild&&i===n.childType&&n.childLabel?.trim()||null}export{l as configNodeDefaults,r as newChildName,e as newChildOf};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-HGTDDSFJ.js";import{Inspector as i}from"./chunk-SDSBXW3V.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.every(n=>Object.is(t[n],r[n]))}function m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},S=()=>b,O=()=>"",j=()=>null,w=()=>{},C={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},D={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},L={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},B={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
|
|
2
|
+
return f(r,{height:"fill"})}function F(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
|
|
3
|
+
return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var G=l({});function I({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return f(G.Provider,{value:n,children:e})}function T(){return s(G)}function x(){return(T().useOwnerName??O)()}function A(){return(T().useDocumentLabel??j)()}function V(n,e,t,r){return(T().useBridges??S)(n,e,t,r)}function X(n){return(T().useStandaloneBridges??S)(n)}function Y(n,e){(T().useDocumentPass??w)(n,e)}function H(){return T().blockRules??C}function Q(){return T().blockLook??D}function R(){return T().devices??L}function W(){return T().leftView??B}function E(){return T().pinned??N}function J(){return T().saveSwitch??!0}function K(e){n(!0===T().pickFollowsSelection,e)}function M(){return T().storageNamespace||void 0}function Z(){return T().styleClipboard??null}function q(){return T().nodeKeys??!0}function z(){return T().notify??null}function U(){return T().Canvas??P}function $(){return T().CanvasHead??null}function _(){return T().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return T().Inspector??F}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,I as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,Q as useScreenBlockLook,H as useScreenBlockRules,V as useScreenBridges,_ as useScreenCanvasDrag,U as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,R as useScreenDevices,A as useScreenDocumentLabel,Y as useScreenDocumentPass,rn as useScreenInspectorPanel,W as useScreenLeftView,q as useScreenNodeKeys,z as useScreenNotify,x as useScreenOwnerName,T as useScreenParts,K as useScreenPickFollowsSelection,E as useScreenPinned,J as useScreenSaveSwitch,M as useScreenStorageNamespace,Z as useScreenStyleClipboard,X as useStandaloneScreenBridges};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-QEEW4X64.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-QEEW4X64.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{useCanvasLayout as o,useCanvasTyping as i,useCanvasEvent as c,CANVAS_TYPABLE_EVENT as d}from"./chunk-6GJEOER4.js";import{framePointToHost as u,elementScale as h,related as f,WORDS_CLEAR as p,frameRectToLayer as m,clientPointToLayer as g}from"./chunk-FR7EEKFF.js";import{isRepeatCopy as b}from"./chunk-7UFKEX72.js";import{parseZoneKey as y,ROOT_ID as x}from"./chunk-YDTEYXQW.js";import{useRef as v,useEffect as w,useState as k,useCallback as N,useMemo as D,useSyncExternalStore as A,useId as E,useLayoutEffect as T}from"react";import{Tooltip as z,IconButton as M,solidSurfaceStyle as C,Input as $,ItemCount as S}from"efficient-shell/ui";import{AddIcon as j,CloseIcon as L,SearchIcon as O}from"efficient-shell/icons/efficient";import{jsxs as B,jsx as X}from"react/jsx-runtime";function K({label:e,onInsert:t,style:n,axis:l="y",className:r,index:a}){const s=["es-canvas-insert","x"===l?"is-x":"",r??""].filter(Boolean).join(" ");/* @__PURE__ */
|
|
2
2
|
return B("div",{className:s,style:n,"data-index":a,children:[
|
|
3
3
|
/* @__PURE__ */X("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */X("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */X(z,{content:e,children:/* @__PURE__ */X(M,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */X(j,{})})})})]})}var Y=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,I=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>Y(e.box,t,n)).sort((e,t)=>I(t.s.box)-I(e.s.box)||e.at-t.at).map(({s:e})=>e)}function F(e,t,n){return q(e,t,n).at(-1)??null}function R(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function P(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function Q(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>Y(e.box,t,n)).sort((e,t)=>I(e.box)-I(t.box));for(const e of s){const s=R(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:P(e,s)};if(!a(o))return null}return null}function W(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function Z(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var H={nodes:[],zones:[]},V="data-easel-dropzone",G="data-easel-block";function J(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function U(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return
|
|
5
|
-
/* @__PURE__ */X(K,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??E.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */X("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",J?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===
|
|
6
|
-
/* @__PURE__ */X("div",{className:"es-canvas-handle-spot",style:Ce?{"--es-handle-x":`${ae(Ce).left}px`,"--es-handle-y":`${ae(Ce).top}px`}:void 0,children:/* @__PURE__ */X(z,{className:"es-canvas-handle-tip",side:"top",content:!V||
|
|
4
|
+
/* @__PURE__ */X("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */X(z,{content:e,children:/* @__PURE__ */X(M,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */X(j,{})})})})]})}var Y=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,I=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>Y(e.box,t,n)).sort((e,t)=>I(t.s.box)-I(e.s.box)||e.at-t.at).map(({s:e})=>e)}function F(e,t,n){return q(e,t,n).at(-1)??null}function R(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function P(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function Q(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>Y(e.box,t,n)).sort((e,t)=>I(e.box)-I(t.box));for(const e of s){const s=R(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:P(e,s)};if(!a(o))return null}return null}function W(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function Z(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var H={nodes:[],zones:[]},V="data-easel-dropzone",G="data-easel-block";function J(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function U(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return m(e.frame,J(n),t)}function ee(e,t){const{frame:n,document:l}=e,r=e=>m(n,J(e),t),a=[],s=[];for(const e of l.querySelectorAll(`[${V}]`)){if(b(e))continue;const t=e.getAttribute(V)??"";let n;try{n=y(t)}catch{continue}const l=[...e.querySelectorAll(`[${G}]`)].filter(t=>t.parentElement?.closest(`[${V}]`)===e&&!b(t)),o=l.map(r);s.push({key:t,list:n,box:r(e),axis:U(o,e),children:o}),l.forEach((e,t)=>{const l=e.getAttribute(G);l&&a.push({id:l,place:{...n,index:t},box:o[t]})})}return{nodes:a,zones:s}}var te="data-es-empty-cell",ne="data-easel-dropzone",le=140;var re=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),ae=e=>({left:e.left+2,top:Math.max(e.top-11,0)});function se(s){const{canvas:m,session:b,readOnly:y,words:E=e.canvas}=s,M=v(s);w(()=>{M.current=s});const $=v(null),S=o(m),[j,L]=k(0),O=N(()=>L(e=>e+1),[]),[Y,I]=k(H);w(()=>{const e=$.current;m&&e&&I((M.current.measure??ee)(m,e))},[m,S,s.revision,j]);const F=s.model,R=D(()=>F(Y),[F,Y]),P=A(b.subscribe,b.shown,b.shown),W=s.choose,Z=(e,t)=>{const n=q(R.sources,e,t);return 0===n.length?null:W?W(n):n[n.length-1]},[V,G]=k(null),[J,U]=k(null),[le,se]=k(null),oe=v(null),ie=()=>{oe.current&&clearTimeout(oe.current),oe.current=null},ce=()=>{ie(),oe.current=setTimeout(()=>{b.get()||G(null)},140)};w(()=>ie,[]);const de=v(null),ue=i(m),he=v(!1);he.current=ue;const[fe,pe]=k(null),me=v(null),ge=v(V);ge.current=V,w(()=>{ue?(pe(ge.current?.key??me.current?.id??null),ie(),G(null)):pe(null)},[ue]);const[be,ye]=k(null);c(m,d,e=>{const t=e.detail?.id??null,n=t?{id:t,words:e.detail?.words??null}:null;ye(n),n&&(me.current=n)});const xe=e=>{if(!(e&&e.isConnected&&m&&$.current))return null;const t=_(m,$.current,e);return{left:t.left-p,top:t.top-p,width:t.width+2*p,height:t.height+2*p}},ve=!be||ue||y||P?null:xe(be.words)??Y.nodes.find(e=>e.id===be.id)?.box??null;c(m,"mousemove",e=>{const t=$.current;if(!m||!t)return;const n=u(m.frame,e.clientX,e.clientY,t),l=h(t),r={x:n.x/l,y:n.y/l};if(de.current=r,M.current.readOnly||b.get()||he.current)return;ie();const a=Z(r.x,r.y);G(e=>e?.key===a?.key&&e?.box===a?.box?e:a)}),c(m,"mouseout",e=>{e.relatedTarget||(de.current=null,ce())}),c(m,"mouseover",e=>{e.relatedTarget||O()});const we=v(null),ke=N(()=>{we.current?.(),we.current=null,U(null),se(null)},[]);w(()=>b.subscribe(()=>{b.get()?O():ke()}),[b,ke,O]),w(()=>ke,[ke]),("undefined"==typeof document?w:T)(()=>{if(b.get())return;const e=de.current;G(t=>y||he.current?null:e?Z(e.x,e.y):t?R.sources.find(e=>e.key===t.key)??null:null)},[R,P,b,y,W]);const Ne=e=>{const t=b.get(),n=$.current,l=M.current.dropOn;if(!t||!n||!l)return null;const r=g(n,e.clientX,e.clientY);de.current=r;const a=q(R.sources,r.x,r.y);for(let e=a.length-1;e>=0;e-=1)if(l.accepts(t.item,a[e]))return{h:t,source:a[e]};return null},De=e=>{const t=b.get(),n=$.current;if(!t||!n)return null;const l=g(n,e.clientX,e.clientY);de.current=l;const r=Q(R.zones,l.x,l.y,e=>M.current.canDrop(t.item,e),e=>!!t.from&&a(t.from,e),e=>M.current.fallThrough?.(t.item,e,t.from)??!0);return r?{h:t,t:r}:null},Ae={onDragEnter:e=>{if(we.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),a=m?l(m.document):null,s=[];t&&s.push(r(t)),a&&m&&s.push(r(a,m.frame)),we.current=s.length?()=>s.forEach(e=>e()):null},onDragOver:e=>{const n=Ne(e);if(n)return e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed),U(null),void se(e=>e&&e.key===n.source.key&&e.box===n.source.box?e:n.source);se(null);const l=De(e);if(!l)return void U(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const r={zoneKey:l.t.zone.key,line:l.t.line,axis:l.t.zone.axis};U(e=>e&&e.zoneKey===r.zoneKey&&e.line.left===r.line.left&&e.line.top===r.line.top?e:r)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(de.current=null,U(null),se(null))},onDrop:e=>{const t=Ne(e);if(t)return e.preventDefault(),b.end(),ke(),void M.current.dropOn.onDrop(t.h.item,t.source);const n=De(e);n&&(e.preventDefault(),b.end(),ke(),M.current.onDrop(n.h.item,n.t.to))}},Ee={draggable:!y&&!!V,onMouseEnter:ie,onMouseLeave:()=>!b.get()&&ce(),onDragStart:e=>{if(V&&!y){b.start({key:V.key,item:V.item,from:V.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",V.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{b.end(),ke()},onClick:()=>{V&&!y&&M.current.onPick?.(V.item)}},{seams:Te=[]}=R,ze=be?.words??(ue?me.current?.words??null:null),Me=s.tag&&m&&$.current&&!P?(ze&&f(s.tag.element,ze)?xe(ze):null)??_(m,$.current,s.tag.element):null,Ce=V?(be&&be.id===V.key?xe(be.words):null)??V.box:null,$e=ue&&fe&&!s.tag?R.sources.find(e=>e.key===fe)??null:null,Se=$e?xe(ze)??$e.box:null,je=R.zones.filter(e=>0===e.children.length),Le=!s.onZoneAdd||y||ue?[]:je,Oe=Le.map(e=>e.key).join("\n");return w(()=>{const e=m?.document;if(!e)return;const t=new Set(Oe?Oe.split("\n"):[]);for(const n of e.querySelectorAll(`[${ne}]`))n.toggleAttribute(te,t.has(n.getAttribute(ne)??""));return()=>{for(const t of e.querySelectorAll(`[${te}]`))t.removeAttribute(te)}},[m,Oe,Y,S,j]),/* @__PURE__ */B("div",{ref:$,className:"es-canvas-layer",children:[P||!s.onSeamAdd||y||ue?null:Te.map(e=>
|
|
5
|
+
/* @__PURE__ */X(K,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??E.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */X("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",J?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===x?void 0:e.list.parentId,onClick:()=>s.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */X("span",{className:"es-canvas-empty-add",children:E.addButton({label:e.addLabel??s.zoneAddLabel??E.addBlock})})},e.key)):null,P?/* @__PURE__ */X("div",{className:"es-canvas-catch",...Ae}):null,le&&P?/* @__PURE__ */X("div",{className:"es-canvas-target",style:re(le.box),children:s.dropOn?.label?/* @__PURE__ */X("span",{className:"es-canvas-target-label",style:C(),children:s.dropOn.label(P.item,le)}):null}):null,J&&!je.some(e=>e.key===J.zoneKey)?/* @__PURE__ */X("div",{className:`es-canvas-line is-${J.axis}`,style:re(J.line)}):null,ve?/* @__PURE__ */X("span",{className:"es-canvas-hint"+(ve.width<200?" is-below":""),style:{...C(),left:ve.left+ve.width,top:ve.width<200?ve.top+ve.height:ve.top},children:E.typeHint}):null,Me&&s.tag?/* @__PURE__ */X("span",{className:"es-canvas-tag",style:ae(Me),children:s.tag.label}):$e&&Se?/* @__PURE__ */X("span",{className:"es-canvas-tag",style:ae(Se),children:$e.label}):null,
|
|
6
|
+
/* @__PURE__ */X("div",{className:"es-canvas-handle-spot",style:Ce?{"--es-handle-x":`${ae(Ce).left}px`,"--es-handle-y":`${ae(Ce).top}px`}:void 0,children:/* @__PURE__ */X(z,{className:"es-canvas-handle-tip",side:"top",content:!V||y||P?null:V.title??E.handle({label:V.label}),children:/* @__PURE__ */B("div",{className:["es-canvas-handle",V&&!y?"is-shown":"",P?"is-dragging":""].filter(Boolean).join(" "),...Ee,children:[
|
|
7
7
|
/* @__PURE__ */X("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var oe=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function ie({groups:t,session:n,itemFor:l,onInsert:r,onTileMenu:a,at:o,hint:i,searchLabel:c,readOnly:d,words:u=e.add}){const h=i??u.hint,f=c??u.search,[p,m]=k(""),g=E(),b=p.trim().toLowerCase(),y=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),x=t.map((e,t)=>({...e,key:y[t],tiles:b?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,b)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>r=>{if(t)r.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),r.dataTransfer.effectAllowed="copy";try{r.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
8
8
|
return B("div",{className:"es-add",children:[o?/* @__PURE__ */B("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */X("span",{children:o.label}),s(u.stop,/* @__PURE__ */X("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:o.onClear,children:/* @__PURE__ */X(L,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-XT75WETI.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-LDHUPZBK.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-TF6NAIV7.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 y}from"./chunk-MNQDOSAX.js";import{DEFAULT_COPY_WORDS as v}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 x,parseZoneKey as C,move as I,duplicate as E,replaceNode as A,createNode as D,insert as M,normalizeData as O,createResolveCache as $,slotsOf as P,deepEqual as j,ROOT_SLOT as z,resolveNodeData as R}from"./chunk-YDTEYXQW.js";import{topLevelSlotKeys as N,fieldsFrom as L,drawnBlockCount as V,defaultsFrom as B}from"./chunk-KXM6YRG2.js";import{CANVAS_TYPABLE_EVENT as T,onMotionEnd as K,CANVAS_TYPING_EVENT as Z}from"./chunk-6GJEOER4.js";import{setCanvasNonce as F,related as W,isTypingTarget as H,upsertCanvasStyle as q,removeCanvasStyle as Y,WORDS_CLEAR as X,frameRectToHost as U,drawnBox as G}from"./chunk-FR7EEKFF.js";import{queryAllCopies as Q}from"./chunk-7UFKEX72.js";import{createContext as J,useEffect as _,useContext as ee,useRef as te,useSyncExternalStore as ne,useState as oe,useReducer as re,useCallback as le,createElement as ie,useMemo as se,useLayoutEffect as ae}from"react";import{jsx as ce,jsxs as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as pe}from"react-dom";import{registerModalEscapeInterceptor as fe,FloatingBar as he,TextToolbar as me,LinkPicker as ge}from"efficient-shell/ui";function ye(e){return!["setData","setUi","set"].includes(e.type)}var ve=(e,t,n,o)=>{const r=S(e,t,C(n));return r?.[o]??null},we=(e,t,n,o,r)=>{const l=ve(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function be(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 ke(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 Se(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 xe(e,t,n){const o=Ce(e,t,n);if(o===e)return e;const r=ke(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function Ce(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 Se(e,n,"function"==typeof t.ui?t.ui(be(e,n)):t.ui);case"set":{const r={data:o,ui:be(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=Se(i,n,l.ui,!0)),i}case"insert":{const r={...C(t.destinationZone),index:t.destinationIndex},l=D(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:M(o,n,r,l)}}case"replace":{const r=we(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:A(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=we(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=E(o,n,r.props.id),i=ve(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return Ce(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ve(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...C(t.destinationZone),index:t.destinationIndex};return{...e,data:I(o,n,r.props.id,l)}}case"remove":{const r=we(o,n,t.zone,t.index,"remove");return{...e,data:x(o,n,r.props.id)}}default:return e}}var Ie={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ae=0,De=()=>`history-${Ae+=1}`;function Me(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=O(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ee}};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:{...Ee,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:De()}],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:De()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,v=!1;const w=()=>{for(const e of[...f])e()},k=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},x=(t,n)=>{g>0?v=v||n:(n?p(!1):c!==t&&k(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},C=e=>{const n=c;if(c=xe(c,e,t),c===n)return;const o=e.recordHistory??ye(e);x(n,o&&c.data!==n.data)},I=t=>{0===g&&(y=c,v=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,v&&c.data!==n.data?p(!0):c!==n&&k(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=e=>{const n=c,o=ke(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},x(n,!1))},D=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Ie,...i,...n}};let P=M();const j=$(),z={resolveCache:j,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:j,trigger:e,metadata:n}),...l.map(o=>R(o,t,{cache:j,trigger:e,metadata:n}))]);I(()=>{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=A(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:ke(r,t,c.selection)},x(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:j,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return I(()=>{const n=c;if(b(c.data,t,e)?.node!==r)return;const o=A(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ke(o,t,c.selection)},x(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:be(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:C,history:{back:()=>z.undo(),forward:()=>z.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:be(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&D(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:C,batch:I,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){I(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ke(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=c,r=O(e,t);c={...c,data:r,selection:ke(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0),c!==o&&w()},undo(){d>0&&D(d-1)},redo(){d<u.length-1&&D(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=M(),h=null,w())},setConfig(e){e!==t&&(t=e,P=M(),h=null,w())}};return z}function Oe(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&&H(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 $e=J(null),Pe=J(!0);function je({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return _(()=>{n&&e.resolveAll()},[e,n]),_(()=>{if(t&&"undefined"!=typeof document)return Oe(document,e)},[e,t]),/* @__PURE__ */ce($e.Provider,{value:e,children:/* @__PURE__ */ce(Pe.Provider,{value:t,children:o})})}function ze(){const e=ee($e);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Re(e){const t=ze(),n=te({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 ne(t.subscribe,o,o)}function Ne(){return function(e){return Re(e)}}var Le=["--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"],Ve="host-tokens";function Be(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Le){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?q(t,Ve,n):Y(t,Ve)}var Te="data-easel-block",Ke="data-easel-dropzone",Ze={},Fe="data-es-mirror",We="undefined"==typeof window?_:ae;function He(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Fe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Fe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function qe({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=te(null),[p,f]=oe(null);return We(()=>{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]),We(()=>{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),F(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){He(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>He(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Be(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Be(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__ */ce("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?pe(e,p):null})}var Ye=J(null),Xe=J(Ze),Ue=[];function Ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=ze(),s=Re(n=>S(n.appState.data,i.config,{parentId:e,slot:t})??Ue),a=Re(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==k),c=Re(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=ee(Ye),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__ */ce("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ce(rt,{node:e},e.props.id))})}function Qe(e,t,n,o){const r=se(()=>{const n={};for(const o of N(L(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
-
return ce(Ge,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=
|
|
3
|
-
return ce(Ge,{parentId:e,slot:t,...n})},[e])}var _e=["top","bottom","zIndex"];function et(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function tt(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));et(e,"position",t?"sticky":"relative");for(const n of _e)et(e,n,t?.[n]??"");return!!t}var nt="data-es-canvas-relative";function ot(e){e.hasAttribute(nt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(nt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(nt,"")),!1)}function rt({node:e}){const t=ze().config,n=t.components[e.type],o=e.props.id,r=te(null),l=function(e,t){return se(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Te),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Te,e),n.setAttribute("data-easel-dnd",e),ot(n))},[e,t])}(o,r),i=te(null),s=!!n?.inline;!function(e,t){const n=te(!1),o=te(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=te(()=>{});
|
|
4
|
-
/* @__PURE__ */ce("div",{ref:i,[Te]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0})})}function lt({metadata:e}){const t=Re(e=>e.config),n=Re(e=>e.appState.data.root).props??{},o=t.root?.render,r=Qe(t.root,
|
|
5
|
-
return ce(
|
|
6
|
-
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:t?St(o,r):void 0}:{display:"none"}})}var ht={"--es-words-clear":`${
|
|
7
|
-
return ce("div",{ref:o,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height,clipPath:n?St(r,l):void 0,...ht}:{display:"none"}})}function gt(e,t,n){return vt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var yt=[];function vt(e,t,n){const[o,r]=oe(yt),l=te(t);return l.current=t,
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-LK56FUFT.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-LDHUPZBK.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-TF6NAIV7.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 y}from"./chunk-MNQDOSAX.js";import{DEFAULT_COPY_WORDS as v}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CANVAS_TYPABLE_EVENT as b,onMotionEnd as k,CANVAS_TYPING_EVENT as S}from"./chunk-6GJEOER4.js";import{setCanvasNonce as x,related as C,isTypingTarget as I,upsertCanvasStyle as E,removeCanvasStyle as A,WORDS_CLEAR as D,frameRectToHost as M,drawnBox as O}from"./chunk-FR7EEKFF.js";import{queryAllCopies as $}from"./chunk-7UFKEX72.js";import{find as P,ROOT_ID as j,getList as z,remove as R,parseZoneKey as L,move as N,duplicate as V,replaceNode as B,createNode as T,insert as K,normalizeData as F,createResolveCache as Z,slotsOf as H,deepEqual as W,ROOT_SLOT as q,resolveNodeData as Y}from"./chunk-YDTEYXQW.js";import{topLevelSlotKeys as U,fieldsFrom as X,drawnBlockCount as G,defaultsFrom as Q}from"./chunk-KXM6YRG2.js";import{createContext as J,useEffect as _,useContext as ee,useRef as te,useSyncExternalStore as ne,useState as oe,useReducer as re,useCallback as le,createElement as ie,useMemo as se,useLayoutEffect as ae}from"react";import{jsx as ce,jsxs as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as pe}from"react-dom";import{registerModalEscapeInterceptor as fe,FloatingBar as he,TextToolbar as me,LinkPicker as ge}from"efficient-shell/ui";function ye(e){return!["setData","setUi","set"].includes(e.type)}var ve=(e,t,n,o)=>{const r=z(e,t,L(n));return r?.[o]??null},we=(e,t,n,o,r)=>{const l=ve(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function be(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 ke(e,t,n){return n?"node"===n.kind?P(e,t,n.id)?n:null:n.parentId===j?z(e,t,n)?n:null:P(e,t,n.parentId)&&z(e,t,n)?n:null:null}function Se(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 xe(e,t,n){const o=Ce(e,t,n);if(o===e)return e;const r=ke(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function Ce(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 Se(e,n,"function"==typeof t.ui?t.ui(be(e,n)):t.ui);case"set":{const r={data:o,ui:be(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=Se(i,n,l.ui,!0)),i}case"insert":{const r={...L(t.destinationZone),index:t.destinationIndex},l=T(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=we(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:B(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=we(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=V(o,n,r.props.id),i=ve(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return Ce(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ve(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...L(t.destinationZone),index:t.destinationIndex};return{...e,data:N(o,n,r.props.id,l)}}case"remove":{const r=we(o,n,t.zone,t.index,"remove");return{...e,data:R(o,n,r.props.id)}}default:return e}}var Ie={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ae=0,De=()=>`history-${Ae+=1}`;function Me(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=F(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ee}};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:{...Ee,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:De()}],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:De()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,v=!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?v=v||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=xe(c,e,t),c===n)return;const o=e.recordHistory??ye(e);k(n,o&&c.data!==n.data)},x=t=>{0===g&&(y=c,v=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,v&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},C=e=>{const n=c,o=ke(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))},I=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Ie,...i,...n}};let A=E();const D=Z(),M={resolveCache:D,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([Y(r,t,{cache:D,trigger:e,metadata:n}),...l.map(o=>Y(o,t,{cache:D,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=P(r,t,i)?.node;s&&s===P(o,t,i)?.node&&(r=B(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:ke(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=P(c.data,t,e)?.node;if(!r)return!1;const l=await Y(r,t,{cache:D,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(P(c.data,t,e)?.node!==r)return;const o=B(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ke(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:be(e,t)},o="node"===e.selection?.kind?P(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>M.undo(),forward:()=>M.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:be(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&I(e)}},getPermissions:A,getItemById:n=>P(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return z(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: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=>C(e?{kind:"node",id:e}:null),selectSlot:e=>C(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:ke(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=F(e,t);c={...c,data:r,selection:ke(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0),c!==o&&w()},undo(){d>0&&I(d-1)},redo(){d<u.length-1&&I(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,A=E(),h=null,w())},setConfig(e){e!==t&&(t=e,A=E(),h=null,w())}};return M}function Oe(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&&I(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 $e=J(null),Pe=J(!0);function je({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return _(()=>{n&&e.resolveAll()},[e,n]),_(()=>{if(t&&"undefined"!=typeof document)return Oe(document,e)},[e,t]),/* @__PURE__ */ce($e.Provider,{value:e,children:/* @__PURE__ */ce(Pe.Provider,{value:t,children:o})})}function ze(){const e=ee($e);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Re(e){const t=ze(),n=te({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 ne(t.subscribe,o,o)}function Le(){return function(e){return Re(e)}}var Ne=["--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"],Ve="host-tokens";function Be(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Ne){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?E(t,Ve,n):A(t,Ve)}var Te="data-easel-block",Ke="data-easel-dropzone",Fe={},Ze="data-es-mirror",He="undefined"==typeof window?_:ae;function We(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ze}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ze,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function qe({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=te(null),[p,f]=oe(null);return He(()=>{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]),He(()=>{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),x(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){We(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>We(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Be(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Be(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__ */ce("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?pe(e,p):null})}var Ye=J(null),Ue=J(Fe),Xe=[];function Ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=ze(),s=Re(n=>z(n.appState.data,i.config,{parentId:e,slot:t})??Xe),a=Re(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==j),c=Re(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=ee(Ye),d=["es-zone"];return s.length&&d.push("has-children"),e===j&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==j&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ce("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ce(rt,{node:e},e.props.id))})}function Qe(e,t,n,o){const r=se(()=>{const n={};for(const o of U(X(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ce(Ge,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=G(n[e],o);return r}function Je(e){return se(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ce(Ge,{parentId:e,slot:t,...n})},[e])}var _e=["top","bottom","zIndex"];function et(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function tt(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));et(e,"position",t?"sticky":"relative");for(const n of _e)et(e,n,t?.[n]??"");return!!t}var nt="data-es-canvas-relative";function ot(e){e.hasAttribute(nt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(nt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(nt,"")),!1)}function rt({node:e}){const t=ze().config,n=t.components[e.type],o=e.props.id,r=te(null),l=function(e,t){return se(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Te),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Te,e),n.setAttribute("data-easel-dnd",e),ot(n))},[e,t])}(o,r),i=te(null),s=!!n?.inline;!function(e,t){const n=te(!1),o=te(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=te(()=>{});He(()=>o.current()),He(()=>{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?ot(e):tt(e));const a=ee(Ue),c=Qe(n,o,e.props,t.components),u=Je(o);if(!n?.render)return null;const d=n.render,p={...Q(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ce("div",{ref:i,[Te]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0})})}function lt({metadata:e}){const t=Re(e=>e.config),n=Re(e=>e.appState.data.root).props??{},o=t.root?.render,r=Qe(t.root,j,n,t.components),l=Je(j),i=/* @__PURE__ */ce(Ge,{parentId:j,slot:q}),s=o?/* @__PURE__ */ce(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ce(Ue.Provider,{value:e??Fe,children:s})}var it=J(void 0),st=J(void 0);function at(e,t,n,o){const r=P(e,t,n);return!!r&&(H(r.node,t).length>0||!1===o.whole)}var ct=J(void 0),ut="data-es-chrome",dt=J(void 0);function pt(e){const t=e?.closest?.(`[${ut}]`)??null,n=t?.getAttribute(ut);return t&&n?{id:n,element:t}:null}function ft({element:e,clip:t=!1}){const n=te(null),o=gt(n,e?()=>e:null,e),r=ee(xt);/* @__PURE__ */
|
|
6
|
+
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:t?St(o,r):void 0}:{display:"none"}})}var ht={"--es-words-clear":`${D}px`};function mt({element:e,words:t=!1,clip:n=!1}){const o=te(null),r=gt(o,e?()=>e:null,e),l=ee(xt);/* @__PURE__ */
|
|
7
|
+
return ce("div",{ref:o,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height,clipPath:n?St(r,l):void 0,...ht}:{display:"none"}})}function gt(e,t,n){return vt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var yt=[];function vt(e,t,n){const[o,r]=oe(yt),l=te(t);return l.current=t,He(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(yt);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:yt;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;c?.observe(t.documentElement),n.addEventListener("resize",s),n.addEventListener("scroll",s,{capture:!0,passive:!0});const u=k(n,s);return()=>{u(),a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}var wt=D+2,bt=wt+2,kt=1;function St(e,t){const n=e.left+e.width,o=e.top+e.height,r=t.map(t=>{const r=t.left+t.width,l=t.top+t.height;if(!(r>e.left-wt&&t.left<n+wt&&l>e.top-wt&&t.top<o+wt))return null;const i=Math.max(t.left<=e.left&&r>e.left?Math.min(t.left,e.left-kt):t.left,e.left-bt)-e.left,s=Math.max(t.top<=e.top&&l>e.top?Math.min(t.top,e.top-kt):t.top,e.top-bt)-e.top,a=Math.min(r>=n&&t.left<n?Math.max(r,n+kt):r,n+bt)-e.left,c=Math.min(l>=o&&t.top<o?Math.max(l,o+kt):l,o+bt)-e.top;return a>i&&c>s?{x:i,y:s,w:a-i,h:c-s}:null}).filter(e=>null!==e);if(!r.length)return;const l=function(e){if(e.length<2)return e;const t=Array.from(new Set(e.flatMap(e=>[e.x,e.x+e.w]))).sort((e,t)=>e-t),n=Array.from(new Set(e.flatMap(e=>[e.y,e.y+e.h]))).sort((e,t)=>e-t),o=[];for(let r=0;r<n.length-1;r++){const l=o=>e.some(e=>e.x<=t[o]&&t[o+1]<=e.x+e.w&&e.y<=n[r]&&n[r+1]<=e.y+e.h);for(let e=0;e<t.length-1;e++){if(!l(e))continue;let i=e+1;for(;i<t.length-1&&l(i);)i++;const s={x:t[e],y:n[r],w:t[i]-t[e],h:n[r+1]-n[r]},a=o.find(e=>e.x===s.x&&e.w===s.w&&e.y+e.h===s.y);a?a.h+=s.h:o.push(s),e=i-1}}return o}(r);return`path(evenodd, "${`M${-bt} ${-bt}h${e.width+2*bt}v${e.height+2*bt}h${-(e.width+2*bt)}z`}${l.map(e=>`M${e.x} ${e.y}h${e.w}v${e.h}h${-e.w}z`).join("")}")`}var xt=J([]);function Ct({children:e}){const t=te(null),n=ee(dt),o=vt(t,n?e=>Array.from(e.querySelectorAll(`[${ut}]`)):null,n?1:0);/* @__PURE__ */
|
|
8
8
|
return ue("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
9
|
/* @__PURE__ */ce("span",{ref:t,hidden:!0,"aria-hidden":"true"}),
|
|
10
|
-
/* @__PURE__ */ce(xt.Provider,{value:o,children:e})]})}function It({id:e,kind:t,overlay:n}){const o=te(null),r=ee(st),l=null!==e&&!0===r?.(e),i=vt(o,e?t
|
|
11
|
-
/* @__PURE__ */ce("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ce("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ce(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Te}]`)).find(o=>o.getAttribute(Te)===n&&t(o)?.wrapper===e)??null}function At(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 Dt(e,t){const n=t?.closest?.(`[${Te}]`)?.getAttribute(Te)??null;return!1===e.getPermissions(n?{item:e.getItemById(n)}:{root:!0}).edit}function Mt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",v),i=Re(e=>Dt(e,t())),s=e.pressed(),a=new Set(n.offered),c=n.colors&&n.colors.length>0?n.colors:null,m=te(null),[g,y]=oe(!1),[b,k]=oe(null),S=g||null!==b,x=()=>{e.hold(),y(!1),k({href:e.pressed().href})},C=()=>{y(!1),k(null),e.resume()};ae(()=>{r.current={escape:()=>!!S&&(C(),!0),link:()=>!!a.has("link")&&(x(),!0)}}),ae(()=>()=>{r.current=null},[r]);const I=te(C);I.current=C,_(()=>{if(g)return fe(e=>{const t=m.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(I.current(),!0)},()=>m.current?.querySelector(".es-copy-colors"))},[g]),_(()=>{const n=m.current;if(!S||!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;y(!1),k(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)}},[S,e,t]),ae(()=>{const e=m.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&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?
|
|
12
|
-
return ce(he,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
10
|
+
/* @__PURE__ */ce(xt.Provider,{value:o,children:e})]})}function It({id:e,kind:t,overlay:n}){const o=te(null),r=ee(st),l=null!==e&&!0===r?.(e),i=vt(o,e?t=>$(t,`[${Te}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=ee(xt),u=`es-canvas-outline is-${t}${l?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height,clipPath:St(e,c)}),p=/* @__PURE__ */ue(de,{children:[
|
|
11
|
+
/* @__PURE__ */ce("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ce("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ce(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Te}]`)).find(o=>o.getAttribute(Te)===n&&t(o)?.wrapper===e)??null}function At(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 Dt(e,t){const n=t?.closest?.(`[${Te}]`)?.getAttribute(Te)??null;return!1===e.getPermissions(n?{item:e.getItemById(n)}:{root:!0}).edit}function Mt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",v),i=Re(e=>Dt(e,t())),s=e.pressed(),a=new Set(n.offered),c=n.colors&&n.colors.length>0?n.colors:null,m=te(null),[g,y]=oe(!1),[b,k]=oe(null),S=g||null!==b,x=()=>{e.hold(),y(!1),k({href:e.pressed().href})},C=()=>{y(!1),k(null),e.resume()};ae(()=>{r.current={escape:()=>!!S&&(C(),!0),link:()=>!!a.has("link")&&(x(),!0)}}),ae(()=>()=>{r.current=null},[r]);const I=te(C);I.current=C,_(()=>{if(g)return fe(e=>{const t=m.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(I.current(),!0)},()=>m.current?.querySelector(".es-copy-colors"))},[g]),_(()=>{const n=m.current;if(!S||!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;y(!1),k(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)}},[S,e,t]),ae(()=>{const e=m.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&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?M(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},c=o.getBoundingClientRect(),f=s?M(s,{left:c.left,top:c.top,width:c.width,height:c.height}):{left:c.left,top:c.top,width:c.width,height:c.height},h=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,f.top-6,h.top),bottom:Math.max(a.top+a.height,f.top+f.height+6,h.bottom)},y=e.ownerDocument.documentElement,v=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,v.left),top:Math.max(0,v.top),right:Math.min(y.clientWidth||v.right,v.right),bottom:Math.min(y.clientHeight||v.bottom,v.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:v.left,top:v.top,right:v.right,bottom:v.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 E=c?{run:f(s.color,c),open:g,onToggle:()=>{k(null),g?C():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
|
|
12
|
+
return ce(he,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?M(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__ */ce("div",{ref:m,children:/* @__PURE__ */ce(me,{layout:"row",offered:a,pressed:s.marks,onMark:t=>{"link"===t?x():e.press(t)},color:E,linkOpen:null!==b,list:{pressed:s.list,onList:t=>e.list(t)},clear:s.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:i,selected:s.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t),style:s.style,applyStyle:t=>e.textStyle(t)}),windows:/* @__PURE__ */ue(de,{children:[g&&c?/* @__PURE__ */ce(h,{colors:c,current:s.color,words:l.colors??v.colors,onPick:t=>e.color(t)}):null,b?
|
|
13
13
|
/* @__PURE__ */ce(ge,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function Ot({element:e,which:t}){const n=te(null),o=gt(n,()=>e(),t),r=ee(xt);/* @__PURE__ */
|
|
14
|
-
return ce("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,clipPath:St(o,r),...ht}:{display:"none"}})}function $t({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:k,overlay:
|
|
15
|
-
/* @__PURE__ */ce(Ye.Provider,{value:
|
|
14
|
+
return ce("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,clipPath:St(o,r),...ht}:{display:"none"}})}function $t({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:k,overlay:x,children:I,typing:E,passThrough:A}){const D=ze(),M=ee(it),O=A??M,$=ee(Pe),j=w("canvas",n),z=v??$,[R,L]=oe(void 0),N=Re(e=>"node"===e.selection?.kind?e.selection.id:null),[V,B]=oe(null),[T,K]=oe(null),F=ee(ct),Z=ee(dt),[W,q]=oe(null),[,Y]=re(e=>e+1,0),[,U]=re(e=>e+1,0),X=e=>{F?.select(e),U()},[G,Q]=oe(null),J=te(null),ne=Re(e=>!!G&&Dt(e,G()));_(()=>{ne&&J.current?.s.stop("stop")},[ne]);const le=te(null),[,ie]=oe(0),se=te(E);se.current=E;const ae=te(null),de=te(null),pe=()=>{if(!N)return null;const e=se.current?.atSelection?.()?.element()??null;if(!e)return null;const t=de.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=P(D.getState().appState.data,D.config,N);return n&&0===H(n.node,D.config).length?e:null},fe=Re(e=>e.appState.data),he=F?.selected()??null;_(()=>{const e=de.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=N&&!G&&se.current?.atSelection?.()?N:null,o=n?pe():null;e.dispatchEvent(new t(b,{detail:o?{id:n,words:o}:{id:n}}))},[N,G,fe,he]);const me=e=>{const t=de.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(S,{detail:{typing:e}}))},ge=(e,t)=>{J.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=e.element,r=()=>Dt(D.getState(),o());if(r())return!1;const l=ye(e,n),i=l?.write??e.write,s=D.group(),a=m({element:o,value:l?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:At(n,t,e.skip),editable:()=>!r(),write:e=>{r()?queueMicrotask(()=>J.current?.s.stop("stop")):i(e)},remount:e.remount,onSelect:()=>ie(e=>e+1),onEscape:()=>ae.current?.escape()??!1,onLinkKey:()=>ae.current?.link()??!1,end:e=>{s.close(),J.current?.element===o&&(J.current=null),Q(null),me(!1),se.current?.onChange?.({typing:!1,why:e})}});if(!a)return s.close(),!1;const c=n.closest?.(`[${Te}]`)?.getAttribute(Te);return c&&D.select(c),J.current={s:a,element:o,target:e},Q(()=>o),B(null),me(!0),se.current?.onChange?.({typing:!0,element:n}),!0},ye=(e,n)=>{const o=e.key;if(!o||!se.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${Te}]`),i=l?.getAttribute(Te);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=se.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(y(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=se.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};_(()=>()=>J.current?.s.stop("stop"),[]);const ve=e=>{const t=J.current?.element();return Boolean(t&&t.contains(e))},we=(e,t)=>at(D.getState().appState.data,D.config,e,t),be=e=>{const t=e.closest?.(`[${Te}]`)?.getAttribute(Te);if(!t)return;const n=D.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,D.config,t,r.id,o,F?.selected()??null,O);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,D.config,t,o,O)??t,part:null}},ke=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(J.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Se(),o=void 0===n?se.current?.atSelection?.():n;o&&ge(o,null)&&e.preventDefault()},Se=()=>{const t=se.current,n=le.current;if(!t?.onCopyText||!n?.copy||n.node!==N)return;const o=de.current,r=o?e(o,n.copy):null,l=r?Et(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(`[${Te}]`);if(!n||n.getAttribute(Te)!==t.getAttribute(Te))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},xe=(e,n)=>{if(!se.current?.onCopyText)return null;const o=t(e);return o&&Et(o.wrapper,n)?o.copy:null},Ce=de.current?.ownerDocument??null,Ie=F?.selected()&&Ce&&N?F.selectedPart?.(Ce)??null:null,Ee=Ie&&N&&we(N,Ie)?Ie.element:null,Ae=Z?.selected()??null,De=Ae&&Ce?Array.from(Ce.querySelectorAll(`[${ut}]`)).find(e=>e.getAttribute(ut)===Ae)??null:null,Me=G?null:pe(),$e=/* @__PURE__ */ue("div",{ref:de,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),J.current){if(ve(t))return;J.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=Z?pt(t):null;if(Z&&o)return Z.select(o.id),q(null),void Y();const r=be(t);if(le.current=void 0!==r?{node:r.node,copy:xe(t,r.node)}:null,void 0!==r)return D.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&X(r.part?.id??null));t.hasAttribute?.(Ke)||(D.select(null),F?.selected()&&X(null))},onDoubleClick:e=>{const t=se.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&ge(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>ke(e),onMouseOver:e=>{if(J.current)return;const t=Z?pt(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==V&&B(null),void(null!==T&&K(null));const n=be(e.target),o=!!n?.part&&we(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!==V&&B(l),r?.id===T?.id&&r?.element===T?.element||K(r)},onMouseLeave:()=>{B(null),K(null),q(null)},children:[
|
|
15
|
+
/* @__PURE__ */ce(Ye.Provider,{value:V,children:/* @__PURE__ */ce(lt,{metadata:i})}),
|
|
16
16
|
/* @__PURE__ */ue(Ct,{children:[
|
|
17
|
-
/* @__PURE__ */ce(It,{id:!G&&
|
|
18
|
-
/* @__PURE__ */ce(It,{id:G||Ee||Me||De?null:
|
|
19
|
-
return ue("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&J.current?.target.toolbar?/* @__PURE__ */ce(Mt,{s:J.current.s,element:J.current.element,toolbar:J.current.target.toolbar,label:
|
|
17
|
+
/* @__PURE__ */ce(It,{id:!G&&V&&V!==N?V:null,kind:"hover",overlay:x}),F?/* @__PURE__ */ce(ft,{clip:!0,element:G||!T||T.id===F.selected()?null:T.element}):null,Me||Ee?/* @__PURE__ */ce(mt,{clip:!0,element:G?null:Me??Ee,words:null!==Me}):null,Z?/* @__PURE__ */ce(ft,{element:G||!W||W.element===De?null:W.element}):null,De?/* @__PURE__ */ce(mt,{element:G?null:De}):null,
|
|
18
|
+
/* @__PURE__ */ce(It,{id:G||Ee||Me||De?null:N,kind:"selected",overlay:x}),G?/* @__PURE__ */ce(Ot,{element:()=>{const e=G?.()??null;return e?Ie&&C(Ie.element,e)?Ie.element:e:null},which:Ie?.element??G}):null]}),I]}),je=k?/* @__PURE__ */ce(k,{document:R,children:$e}):$e;_(()=>{if(R&&z)return Oe(R,D)},[R,z,D]),_(()=>{if(!R)return;const e=e=>{if("Enter"===e.key)return void ke(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=D.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void X(null);const o=s(n.appState.data,D.config,n.selection);"node"===o?.kind&&D.select(o.id)};return R.addEventListener("keydown",e),()=>R.removeEventListener("keydown",e)},[R,D,F]);/* @__PURE__ */
|
|
19
|
+
return ue("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&J.current?.target.toolbar?/* @__PURE__ */ce(Mt,{s:J.current.s,element:J.current.element,toolbar:J.current.target.toolbar,label:j.textTools,keys:ae}):null,o?/* @__PURE__ */ce(qe,{mirrorStyles:u,onDocument:e=>{L(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:je}):/* @__PURE__ */ce("div",{id:"preview-frame","data-easel-entry":"",children:je})]})}function Pt(e={}){const t=ze(),n=Re(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}var jt=/* @__PURE__ */new WeakMap,zt=[];function Rt(e){let t=jt.get(e);return t||(t={nodes:/* @__PURE__ */new Map,shown:/* @__PURE__ */new Map,listeners:/* @__PURE__ */new Set,lateListeners:/* @__PURE__ */new Set,settled:[]},jt.set(e,t)),t}function Lt(e,t){const n=e.nodes.get(t),o=n?[...n.running,...n.next]:zt;o.length?e.shown.set(t,o):e.shown.delete(t),e.listeners.forEach(e=>e())}function Nt(e,t,n,o){const r=Rt(e),l=r.nodes.get(t);l?l.next=[...l.next,n]:r.nodes.set(t,{running:zt,next:[n]}),Lt(r,t),l||Promise.resolve().then(()=>Vt(r,t,o))}function Vt(e,t,n){const o=e.nodes.get(t);if(!o)return;if(!o.next.length)return e.nodes.delete(t),Lt(e,t),void(e.nodes.size||e.settled.splice(0).forEach(e=>e()));const r=o.next;o.running=r,o.next=zt;let l=!0;const i=()=>{l=!1,clearTimeout(a),o.running=zt,Lt(e,t)};let s=!1;const a=setTimeout(()=>{s=!0,i();try{n.landWithoutAnswer(r)&&(e.lateListeners.forEach(e=>e()),Promise.reject(new Error(`A write to ${t} landed without its resolver's answer after 60000 ms.`)))}catch(e){Promise.reject(e)}Vt(e,t,n)},6e4);n.run(r,{live:()=>l,landing:i}).catch(e=>{if(!s)throw e}).finally(()=>{s||(l&&i(),Vt(e,t,n))})}function Bt(e){const t=Rt(e);return t.nodes.size?new Promise(e=>t.settled.push(e)):Promise.resolve()}function Tt(){const e=ze(),t=te([]),n=te(!1),[o,r]=oe(!1),[,l]=re(e=>e+1,0);_(()=>{t.current.splice(0).forEach(e=>e())});return{run:le(o=>{n.current||(n.current=!0,r(!0),Bt(e).then(()=>new Promise(e=>{t.current.push(e),l()})).then(()=>{n.current=!1,r(!1),o()}))},[e]),waiting:o}}function Kt(e){const t=Tt(),n=te(e);return n.current=e,{...e,busy:!0===e.busy||t.waiting,onPress:()=>t.run(()=>n.current.onPress())}}function Ft(e,t){const{lateListeners:n}=Rt(e);return n.add(t),()=>{n.delete(t)}}var Zt=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype;function Ht(e,t,n){if(t===e)return n;if(Array.isArray(e)&&Array.isArray(t)&&Array.isArray(n)){if(e.length!==n.length||e.some((e,t)=>n.includes(e)&&n[t]!==e))return t;const o=e.length===t.length&&1===t.filter((t,n)=>t!==e[n]).length;return t.map((t,r)=>{if(t===e[r])return n[r];const l=Zt(t)?e.indexOf(t):-1;return l>=0?n[l]:o?Ht(e[r],t,n[r]):t})}if(Zt(e)&&Zt(t)&&Zt(n)){const o={...n};for(const n of Object.keys(e))n in t||delete o[n];for(const r of Object.keys(t))o[r]=Ht(e[r],t[r],n[r]);return o}return t}function Wt(e,t){let n=null;for(const o of e){const e="function"==typeof o?o({...t,...n}):o;e&&(n={...n,...e})}return n}function qt(e,t){if(!e.length)return t;try{return{...t,...Wt(e,t)}}catch{return t}}function Yt(){return Jt(Re(e=>e.selectedItem))}function Ut(){const e=ee(Xt);try{return function(e){const t=Re(e=>e.selectedItem);return Jt("root"===e?null:t)}(e)}catch{return null}}var Xt=J("selected");function Gt({children:e}){return ie(Xt.Provider,{value:"root"},e)}function Qt(){return Jt(null)}function Jt(e){const t=ze(),n=Re(e=>e.config),r=t.resolveCache,l=Re(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=se(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?P(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=Re(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=le(e=>{Nt(t,i,e,{landWithoutAnswer:e=>{const n=t.getState();if("root"===i){const o=n.appState.data.root.props??{},r=Wt(e,o);return!!r&&(t.dispatch({type:"replaceRoot",root:{props:{...o,...r},readOnly:n.appState.data.root.readOnly},recordHistory:!0}),!0)}const o=n.getItemById(i),r=n.getSelectorForId(i);if(!o||!r)return!1;const l=Wt(e,o.props);return!!l&&(t.dispatch({type:"replace",destinationZone:r.zone??"root:default-zone",destinationIndex:r.index,data:{...o,props:{...o.props,...l}}}),!0)},run:async(e,{live:n,landing:o})=>{for(let l=1;;l+=1){const s=t.getState(),a={...r,lastChange:Object.create(r.lastChange)},c=()=>{o(),Object.assign(r.lastChange,a.lastChange)};if("root"!==i){const o=s.getItemById(i);if(!o)return;const r=Wt(e,o.props);if(!r)return;const u={...o,props:{...o.props,...r}},{node:d}=await Y(u,t.config,{cache:a,trigger:"replace"});if(!n())return;const p=t.getState(),f=p.getSelectorForId(i);if(!f)return;if(p.getItemById(i)!==o&&l<5)continue;return c(),void t.dispatch({type:"replace",destinationZone:f.zone??"root:default-zone",destinationIndex:f.index,data:d})}const u=s.appState.data.root.props??{},d=Wt(e,u);if(!d)return;const{node:p}=await Y({type:"root",props:{...u,...d}},t.config,{cache:a,trigger:"replace"});if(!n())return;if(!(t.getState().appState.data.root.props!==s.appState.data.root.props&&l<5))return c(),void t.dispatch({type:"replaceRoot",root:{props:p.props,readOnly:p.readOnly},recordHistory:!0})}}})},[t,r,i]),y=le(e=>{const{listeners:n}=Rt(t);return n.add(e),()=>{n.delete(e)}},[t]),v=le(()=>Rt(t).shown.get(i)??zt,[t,i]),w=ne(y,v,v),b=se(()=>qt(w,a.props),[w,a.props]),k=te({id:i,values:b});k.current={id:i,values:b};const S=le((e,n)=>{const o=t.getState(),r=("root"===i?o.appState.data.root.props:o.getItemById(i)?.props)??{},l=qt(Rt(t).shown.get(i)??zt,r),s=k.current,a=(s.id===i?s.values:l)[e];W(n,a)&&!W(l[e],a)?g({[e]:n}):g(t=>({[e]:Ht(a,n,t[e])}))},[t,i,g]);return{id:i,node:a,fields:h,values:b,readOnly:m,onChange:S,onChangeMany:g}}export{ut as CHROME_ATTR,dt as CanvasChromeContext,qe as CanvasFrame,ct as CanvasPartsContext,it as CanvasPassThroughContext,st as CanvasSharedContext,Ee as DEFAULT_UI,$t as EaselCanvas,je as EaselProvider,lt as EditDocument,Gt as RootHostScope,Oe as bindUndoKeys,Me as createEasel,Le as createUseEasel,at as partHasOwnBox,ye as recordsByDefault,xe as reduce,Ft as subscribeLateWrites,be as uiView,Re as useEasel,ze as useEaselApi,Pt as useEaselNodeOps,Qt as useRootFields,Yt as useSelectedFields,Ut as useSelectedHost,Kt as useSettledAction,Tt as useSettledPress,ke as validSelection,Bt as writesSettled};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styleFieldBuilders as e,keptByRow as s}from"./chunk-
|
|
1
|
+
import{styleFieldBuilders as e,keptByRow as s}from"./chunk-MMHYTIUY.js";import{boxFieldBuilders as o,PHONE_KEY_ACCESS as l,phoneTwinFields as r,section as i}from"./chunk-SR2535CN.js";import{deviceField as t}from"./chunk-ZNLODQD4.js";import{BUTTON_STYLE_KEYS as c,BUTTON_PAD_KEYS as n}from"./chunk-PLTTPHK5.js";import{TextColorIcon as u,GroundIcon as d}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";function a(a){const p=o(a.say),y=e(a.say),m=c,F=a.style,k=a.phone??l;return{...a.padding&&{_dSize:i("Size"),...p.sidesPaddingFields({keys:n,group:!1,...a.padding})},_dDesign:i("Design"),[m.fill]:y.colourField({key:m.fill,access:F,label:"Fill color",icon:/* @__PURE__ */f(d,{}),useFollows:a.follows.useFill,usePresets:a.usePresets,resetTo:a.resetTo,opacity:{key:m.fillOpacity,useUnset:a.follows.useFillOpacity}}),[m.fillOpacity]:s(m.fill),[m.border]:y.borderField({key:m.border,access:F,useFollows:a.follows.useBorder}),[m.text]:y.colourField({key:m.text,access:F,label:"Text color",icon:/* @__PURE__ */f(u,{}),useFollows:a.follows.useText,usePresets:a.usePresets,resetTo:a.resetTo}),[m.corners]:y.cornersField({key:m.corners,access:F,sidesKey:m.cornerSides,useFollows:a.follows.useCorners,useFollowsSides:a.follows.useCornerSides}),[m.cornerSides]:s(m.corners),_dLayout:i("Layout"),...r("align",p.blockAlignmentField({phone:!0},""),k),align:t("desktop",p.blockAlignmentField())}}export{a as buttonFieldSet};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-DCBUJ36Q.js";import{useEaselHost as e}from"./chunk-LX23TCTP.js";import{createEasel as r,EaselProvider as o}from"./chunk-HGTDDSFJ.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
|
|
2
2
|
return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{repeatWrapperAt as t,REPEAT_ATTRIBUTE as e,REPEAT_INDEX_ATTRIBUTE as r}from"./chunk-7UFKEX72.js";import{parseZoneKey as n}from"./chunk-YDTEYXQW.js";var o=`[${e}][${r}]`;function l(l){const c=t(l);if(!c)return null;let i;try{i=n(c.zone)}catch{return null}if(!i.parentId||!i.slot)return null;const{wrapper:a,zone:p,index:f}=c;let s=a.parentElement;for(let t=a.parentElement;t;t=t.parentElement)if(t.getAttribute("data-easel-block")===i.parentId){s=t;break}const d=/* @__PURE__ */new Set;for(const t of Array.from(s?.querySelectorAll(o)??[]))t.getAttribute(e)===p&&d.add(t.getAttribute(r)??"");const m={ownerId:i.parentId,slot:i.slot,index:f,count:Math.max(d.size,f+1)},y=a.parentElement?u(a.parentElement):null;return y&&(m.outer=y),{copy:m,wrapper:a}}function u(t){return l(t)?.copy??null}function c(t,e){return t&&e?t.ownerId===e.ownerId&&t.slot===e.slot&&t.index===e.index&&c(t.outer,e.outer):t===e}function i(t,e){for(const n of Array.from(t.querySelectorAll(o))){if(n.getAttribute(r)!==String(e.index))continue;const t=l(n);if(t?.wrapper===n&&c(t.copy,e))return n}return null}export{i as findCopy,u as repeatCopyAt,l as repeatCopyWithWrapper};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{styleMenuItems as t}from"./chunk-3OOYGEJY.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-G2VZ4DET.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-LK56FUFT.js";import{createNodeClipboard as i,nodeMenuItems as c}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as s}from"./chunk-WK3AFPXY.js";import{easelMenuEntries as a,menuLabel as u}from"./chunk-FIVU2COQ.js";import{useCanvasEvent as d}from"./chunk-6GJEOER4.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-YDTEYXQW.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 T,CopyIcon as Y}from"efficient-shell/icons/efficient";import{jsx as D}from"react/jsx-runtime";function K(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 M=i(),I=/* @__PURE__ */new WeakMap;function L(e){if(e.claimsPage)return M;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",i);let t=I.get(n);return t||(t=i(),I.set(n,t)),t}function S(){return L(e())}function X(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 F(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 R(e,n,t){const o=e.canPasteAt;if(!o)return m(n.from)===t.zone?X(e,t.zone,t.index+1):null;for(const l of K(e,t)){const t=X(e,l.zone,l.index+1);if(o(n,t))return t}return null}function V(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 B(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=F(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:R(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:o,index:r}=n,i=e.nodeAt(o,r);if(!i)return[];const s=i.props.id,a=e.labelOf(i.type,o),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,o),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=F(e,i,o),k=K(e,n),b=d.held,v=b&&!p?R(e,b,n):null,x=!e.readOnly,g=e.style?t({held:x?e.style.held():null,canCopy:e.style.canCopy(i,o),onCopy:()=>e.style?.copy(i,o),onPaste:()=>e.style?.paste(o,r,i),words:e.words?.styleClipboard}):[];return c({title:a,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(s):void 0,...W(x&&!p,e=>d.canStep(s,e),e=>d.step(s,e)),copy:h.copy?()=>d.copy(s,a):void 0,cut:x&&h.cut?()=>d.cut(s,a):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,o)?()=>e.beginRename(o,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(s,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(s):void 0},style:g,extras:N(x?G(e,n.copy):null,e.menuRows?.(i,o,r)),pinnedLine:p?Q(e).pinned:void 0})}function G(e,n){const t=e.copyItem;if(!t||!n)return null;const l=Q(e),r=o.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>t({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */D(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */D(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */D(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */D(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 Q=e=>e.words?.screen??o.menu;function Z(e){const n=Q(e),t=!e.readOnly,r=[];t&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */D(P,{}),shortcut:"⌘Z",onClick:e.history.back}),t&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */D(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,a=X(e,l,e.sectionBand().cap);if(t&&c&&(e.canPasteAt?e.canPasteAt(c,a):m(c.from)===l)){const n=a,t=e.words?.menu??s;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */D(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??o.pageStyles,icon:/* @__PURE__ */D(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */D(T,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.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??s,c=Q(e),a=[];l&&(a.push({label:i.copy,icon:/* @__PURE__ */D(Y,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),a.push({label:i.cut,icon:/* @__PURE__ */D(Y,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),a.push({label:i.paste,icon:/* @__PURE__ */D(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[a,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function $(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=V(e);if(!o)return;const l=t.selected();if(!l)return;const r=B(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__ */D(q,{host:e,target:o,onClose:i}):null,closeMenu:i}}function q({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?J(e,n.el):Z(e);return 0===o.length?null:/* @__PURE__ */D(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":u(o),items:a(o)})}export{M as EASEL_NODE_CLIPBOARD,K as ancestorChain,L as nodeClipboardOf,F as nodeClipboardRules,U as nodeMenuItems,V as nodeShortcut,Z as pageMenuItems,R as pastePlace,B as runNodeShortcut,J as textMenuItems,S as useNodeClipboard,$ as useNodeContextMenu};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as s}from"./chunk-
|
|
1
|
+
import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as s}from"./chunk-SR2535CN.js";import{CornersInput as l,BorderInput as t,SettingsColour as n}from"./chunk-XWTQTANN.js";import{SettingsDefaultReset as i}from"./chunk-2T22IY3J.js";import{noControlField as c,NoControlMark as a}from"./chunk-22I55W37.js";import{normalizeCornerSides as d,CORNER_SIDES as u}from"./chunk-PLTTPHK5.js";import{DEFAULT_PANEL_WORDS as y,DEFAULT_COLOUR_ROW_WORDS as p}from"./chunk-56ID6FKZ.js";import{viewFollows as f}from"./chunk-DIOTWSCO.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CornerIcon as m,BorderAllIcon as b}from"efficient-shell/icons/efficient";import{jsx as g}from"react/jsx-runtime";var v=e=>e;function k(e,o){const r=o.twinAccess;return r?{key:e.key,access:r,ownField:r.ownField}:e}function j(e,r){const l=!e.access||e.ownField?{value:r.value,onChange:r.onChange}:void 0;return s(e.access??o,e.key,l)}function F(e,r){return s(e.access??o,r??"")}function C(e){return{...c({type:"custom",render:()=>/* @__PURE__ */g(a,{})},"always"),reachedBy:e}}function O({o:s,say:l,props:t}){const i=w("colourRow",p),c=w("panel",y),a=s.useFollows(),d=s.usePresets?.(),u=s.opacity?.useUnset?.()??100,f=k(s,t),[h,m]=j(f,t),[b,v]=F(f,s.opacity?.key),C=e(f.access??o),O="string"==typeof h?h:"",B="number"==typeof b,T="follows"in t,A=(T&&"string"==typeof t.follows&&""!==t.follows?t.follows:void 0)??a,x=s.access||T?void 0:"";/* @__PURE__ */
|
|
2
2
|
return g(n,{label:l(s.label),icon:s.icon,hint:s.hint,value:O,onChange:e=>m(""===e?x:e),inherited:A,presets:d,changed:""!==O||B,onReset:()=>{B&&s.opacity?C([[s.key,x],[s.opacity.key,void 0]]):m(x)},resetTo:T?r(l,A.toUpperCase(),t.followsView):s.resetTo?s.resetTo(a.toUpperCase()):a.toUpperCase(),...s.opacity?{opacity:B?b:u,onOpacityChange:e=>v(e)}:{},readOnly:t.readOnly,words:i,resetWords:c})}var B=20;function T({o:e,say:o,props:s}){const l=e.useFollows(),[n,c]=j(k(e,s),s),a=n&&"object"==typeof n?n:{},d="follows"in s,u=d&&s.follows&&"object"==typeof s.follows?s.follows:{},y="number"==typeof u.width?u.width:l.width,p="string"==typeof u.color&&""!==u.color?u.color:l.color,f=Object.keys(a).length>0,w={width:o("Border width"),sides:{top:o("Border top"),right:o("Border right"),bottom:o("Border bottom"),left:o("Border left")},style:o("Border style"),styles:{solid:o("Solid"),dashed:o("Dashed"),dotted:o("Dotted")},color:o("Border color"),unit:"px"};/* @__PURE__ */
|
|
3
|
-
return g(h,{label:o("Border"),icon:/* @__PURE__ */g(b,{}),action:d?/* @__PURE__ */g(i,{label:o("Border"),changed:f,detail:r(o,`${y}px`,s.followsView),disabled:s.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */g(t,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:y,right:y,bottom:y,left:y},style:u.style??"solid",color:p},presets:[p],words:w,styles:e.styles??!1,max:20,readOnly:s.readOnly})})}var A=40,x=()=>null;function
|
|
4
|
-
return g(h,{label:t("Corners"),icon:/* @__PURE__ */g(m,{}),changed:null!==
|
|
3
|
+
return g(h,{label:o("Border"),icon:/* @__PURE__ */g(b,{}),action:d?/* @__PURE__ */g(i,{label:o("Border"),changed:f,detail:r(o,`${y}px`,s.followsView),disabled:s.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */g(t,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:y,right:y,bottom:y,left:y},style:u.style??"solid",color:p},presets:[p],words:w,styles:e.styles??!1,max:20,readOnly:s.readOnly})})}var A=40,x=()=>null;function R({o:s,say:t,props:n}){const c=w("panel",y),a=s.useFollows(),p=(s.useFollowsSides??x)(),b=k(s,n),[v,C]=j(b,n),[O,B]=F(b,s.sidesKey),[T]=F(s,s.sidesKey),[A]=F({key:s.key,access:n.widerAccess},n.widerAccess?s.sidesKey:void 0),R=e(b.access??o),I="follows"in n,K=s.access||I?void 0:null,S=I&&"number"==typeof n.follows?n.follows:a,W="number"==typeof v&&Number.isFinite(v)?v:null,D=(I?f(d(T),d(A)):null)??d(p)??[...u],M=d(O)??D,N=[{value:"tl",label:t("Top left")},{value:"tr",label:t("Top right")},{value:"bl",label:t("Bottom left")},{value:"br",label:t("Bottom right")}];/* @__PURE__ */
|
|
4
|
+
return g(h,{label:t("Corners"),icon:/* @__PURE__ */g(m,{}),changed:null!==W||Array.isArray(O),action:/* @__PURE__ */g(i,{label:t("Corners"),changed:null!==W||Array.isArray(O),detail:I?r(t,`${S}px`,n.followsView):`${S}px`,disabled:n.readOnly,onReset:()=>Array.isArray(O)?R([[s.key,K],[s.sidesKey,K]]):C(K),words:c}),children:/* @__PURE__ */g(l,{label:t("Corners"),value:M,corners:N,onChange:e=>{const o=u.filter(o=>e.includes(o)),r=o.length===D.length&&o.every(e=>D.includes(e));B(r?K:o)},radius:W,onRadiusChange:e=>C(e??K),radiusMin:0,radiusMax:40,radiusStep:s.step??1,radiusPlaceholder:String(S),disabled:n.readOnly})})}function I(e=v){return{colourField:o=>({type:"custom",render:r=>/* @__PURE__ */g(O,{o:o,say:e,props:r})}),borderField:o=>({type:"custom",render:r=>/* @__PURE__ */g(T,{o:o,say:e,props:r})}),cornersField:o=>({type:"custom",render:r=>/* @__PURE__ */g(R,{o:o,say:e,props:r})})}}var{colourField:K,borderField:S,cornersField:W}=I();export{B as BORDER_WIDTH_MAX,A as CORNER_RADIUS_MAX,S as borderField,K as colourField,W as cornersField,C as keptByRow,I as styleFieldBuilders};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-PTTQWCD7.js";import{SELECTION_MODE as e}from"./chunk-DCBUJ36Q.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-HGTDDSFJ.js";import{usePreviewParts as p}from"./chunk-467WWV4I.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),f=o(),{setSelectedPartId:k,setSelectHandler:l}=p(),I=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{l(I)},[l,I]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{k(h)},[h,k]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&f.select(r)},[i,u,f]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-DCBUJ36Q.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-HGTDDSFJ.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|