efficient-easel 26.12.0 → 26.13.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/README.md +12 -0
- package/dist/{chunk-P4XLNW3E.js → chunk-6FOXOYXW.js} +1 -1
- package/dist/{chunk-7GGNFLHT.js → chunk-BLE3U2GS.js} +1 -1
- package/dist/{chunk-Q3VAJMXS.js → chunk-C4TJN6GR.js} +1 -1
- package/dist/chunk-CLJ3KXYF.js +5 -0
- package/dist/{chunk-BYONFJVQ.js → chunk-CPIWSFGR.js} +2 -2
- package/dist/{chunk-IVSPOIOU.js → chunk-DTVOOBD4.js} +1 -1
- package/dist/chunk-DX7UGNIP.js +17 -0
- package/dist/{chunk-KWGABNNM.js → chunk-FDIGXBUW.js} +1 -1
- package/dist/{chunk-STQDOTHF.js → chunk-H4TUOPI7.js} +1 -1
- package/dist/chunk-ITRBDUAM.js +19 -0
- package/dist/{chunk-CVS3RPO6.js → chunk-JREIRJVH.js} +1 -1
- package/dist/{chunk-W2UMJ7WO.js → chunk-KR2JYQLM.js} +8 -8
- package/dist/{chunk-TOEJCZUO.js → chunk-MGEXTIZH.js} +1 -1
- package/dist/{chunk-QVQ7764L.js → chunk-QPZQFWS6.js} +4 -4
- package/dist/chunk-QYQG36CI.js +1 -0
- package/dist/{chunk-JYVQ62TL.js → chunk-U4TG43PD.js} +1 -1
- package/dist/chunk-XE5LSM3G.js +64 -0
- package/dist/chunk-YIZIW6GJ.js +1 -0
- package/dist/{chunk-I7NHUVP6.js → chunk-ZWQKRSOI.js} +4 -4
- package/dist/easel/index.d.ts +45 -7
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +13 -6
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/device-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.d.ts +1 -2
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/shadow-fields.js +1 -1
- package/dist/screen/lib/document/style-clipboard.js +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/key-scope.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/words.d.ts +2 -0
- package/dist/screen/words.js +1 -1
- package/dist/strings/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4SYDN43N.js +0 -1
- package/dist/chunk-CQVSWONH.js +0 -1
- package/dist/chunk-EVYIDHCK.js +0 -19
- package/dist/chunk-UMRYCN7L.js +0 -16
- package/dist/chunk-UR7YBZJR.js +0 -5
- package/dist/chunk-YQXHRQXH.js +0 -64
package/README.md
CHANGED
|
@@ -1013,6 +1013,18 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
|
|
|
1013
1013
|
`useSelectedFields().readOnly` or `useEasel((s) => s.getPermissions)`
|
|
1014
1014
|
re-renders when the permissions change, and only then; the same permissions
|
|
1015
1015
|
again tell nobody, so it is safe to call from an effect.
|
|
1016
|
+
- **One node's panel writes run in turn.** `onChange` and `onChangeMany` on
|
|
1017
|
+
`useSelectedFields()` wait for that node's resolver, and the writes made
|
|
1018
|
+
during the wait become the next write. `values` shows them at once.
|
|
1019
|
+
`onChangeMany` also takes a function of the latest props (`FieldsPatch`).
|
|
1020
|
+
A press that reads the document waits first: `useSettledAction(action)` (the
|
|
1021
|
+
writes and their render, one press at a time, busy meanwhile, then the latest
|
|
1022
|
+
render's press; `ScreenChrome` passes every main action and Save now through
|
|
1023
|
+
it, and a layer's own `barMain` must do the same), `useSettledPress()` or
|
|
1024
|
+
`writesSettled(easel)`. A resolver error loses its group. A
|
|
1025
|
+
write whose resolver does not answer in 60 seconds lands without the answer;
|
|
1026
|
+
`subscribeLateWrites(easel, listener)` tells the host (`ScreenChrome` shows a
|
|
1027
|
+
toast).
|
|
1016
1028
|
- **A panel that edits the root beside a selection wraps its rows in
|
|
1017
1029
|
`RootHostScope`.** A row that finds its node itself (`useSelectedHost`: a
|
|
1018
1030
|
style row's `ValueAccess`, its sibling keys, the padding row, a phone twin)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-CLJ3KXYF.js";import{useEaselHost as e}from"./chunk-LX23TCTP.js";import{createEasel as r,EaselProvider as o}from"./chunk-ITRBDUAM.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{noControlField as e}from"./chunk-22I55W37.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-
|
|
1
|
+
import{noControlField as e}from"./chunk-22I55W37.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-C4TJN6GR.js";import{deviceMetaOf as n,DEVICE_FIELD_MARKER as t}from"./chunk-YCSZAP7T.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{usePreviewDevice as i}from"./chunk-BSPCSC45.js";import{jsx as c}from"react/jsx-runtime";function u(e){return"mobile"===e?"mobile":"desktop"}var s={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},d="data-sf-device-hidden";function m(){/* @__PURE__ */
|
|
2
2
|
return c("span",{hidden:!0,[d]:""})}function f({tier:e,render:r,...n}){const t=i();return"each"===e?/* @__PURE__ */c(r,{...n,tier:u(t)}):u(t)===e?/* @__PURE__ */c(r,{...n}):/* @__PURE__ */c(m,{})}function l(e){return n(e)?.inner??e}function p(e,r){const n=r.render;return{...r,[t]:{tier:e,inner:r},render:r=>/* @__PURE__ */c(f,{tier:e,render:n,...r})}}function a(){const e=o("screen",r).deviceNote,n=i(),t="desktop"===n?null:e[n];return t?/* @__PURE__ */c("div",{className:"sf-device-scope",children:t}):/* @__PURE__ */c(m,{})}function h(){return e({type:"custom",render:()=>/* @__PURE__ */c(a,{})},"always")}export{d as DEVICE_HIDDEN_ATTR,s as DEVICE_NOTE,p as deviceField,h as deviceNote,u as shownTier,l as withoutDeviceGate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}},s={focus:"Image focus",onDesktop:e=>`${e} on desktop`,pasteLink:"or paste an image URL",pasteName:"Image URL",template:"Templates don’t store images. This slot stays a placeholder. Each website picks its own after it’s created.",templateVideo:"Templates don’t store videos. This slot stays a placeholder. Each website picks its own after it’s created."};export{s as DEFAULT_IMAGE_ROW_WORDS,e as DEFAULT_SCREEN_ADD_WORDS,o as DEFAULT_SCREEN_SAVE_STATUS_WORDS,t as DEFAULT_SCREEN_SHARED_WORDS,n as DEFAULT_SCREEN_WORDS};
|
|
1
|
+
var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,writeLate:"That took too long. Your change is kept, but the last step did not finish.",add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}},s={focus:"Image focus",onDesktop:e=>`${e} on desktop`,pasteLink:"or paste an image URL",pasteName:"Image URL",template:"Templates don’t store images. This slot stays a placeholder. Each website picks its own after it’s created.",templateVideo:"Templates don’t store videos. This slot stays a placeholder. Each website picks its own after it’s created."};export{s as DEFAULT_IMAGE_ROW_WORDS,e as DEFAULT_SCREEN_ADD_WORDS,o as DEFAULT_SCREEN_SAVE_STATUS_WORDS,t as DEFAULT_SCREEN_SHARED_WORDS,n as DEFAULT_SCREEN_WORDS};
|
|
@@ -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-ITRBDUAM.js";import{Inspector as i}from"./chunk-WMC6FE3G.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={},O=()=>b,j=()=>"",C=()=>null,w=()=>{},S={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},B={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},D={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},I={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function N(){/* @__PURE__ */
|
|
2
|
+
return f(r,{height:"fill"})}function P(){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 A=l({});function F({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return f(A.Provider,{value:n,children:e})}function G(){return s(A)}function T(){return(G().useOwnerName??j)()}function x(){return(G().useDocumentLabel??C)()}function M(n,e,t,r){return(G().useBridges??O)(n,e,t,r)}function R(n){return(G().useStandaloneBridges??O)(n)}function Y(n,e){(G().useDocumentPass??w)(n,e)}function E(){return G().blockRules??S}function Q(){return G().blockLook??L}function V(){return G().devices??B}function W(){return G().leftView??D}function X(){return G().pinned??I}function H(){return G().saveSwitch??!0}function K(e){n(!0===G().pickFollowsSelection,e)}function U(){return G().storageNamespace||void 0}function Z(){return G().styleClipboard??null}function q(){return G().nodeKeys??!0}function z(){return G().notify??null}function J(){return G().Canvas??N}function $(){return G().CanvasHead??null}function _(){return G().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 G().Inspector??P}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,F 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,E as useScreenBlockRules,M as useScreenBridges,_ as useScreenCanvasDrag,J as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,V as useScreenDevices,x as useScreenDocumentLabel,Y as useScreenDocumentPass,rn as useScreenInspectorPanel,W as useScreenLeftView,q as useScreenNodeKeys,z as useScreenNotify,T as useScreenOwnerName,G as useScreenParts,K as useScreenPickFollowsSelection,X as useScreenPinned,H as useScreenSaveSwitch,U as useScreenStorageNamespace,Z as useScreenStyleClipboard,R as useStandaloneScreenBridges};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-
|
|
2
|
-
return H(
|
|
1
|
+
import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-C4TJN6GR.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as b,CLAIM_FAIL_OPEN_MS as S,holderOf as I}from"./chunk-YYD257TD.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as E,useMemo as T,useCallback as B,useEffect as C,useRef as A}from"react";import{jsx as H}from"react/jsx-runtime";var L={content:[],root:{},zones:{}};var N=j(null);function D(){const e=R(N);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function O({target:j,addressing:R=o,onHostMessage:D,children:O}){const Y=R,{homeSlug:F,entryMayBounce:M,entryBounce:W,onSwitch:G,tellsHost:K,adapterFor:U,migrateRenamedProps:V,describeMissing:X,onLoadFailed:x}=Y,[Q,J]=E(j),Z=k(),z=d(),_=T(()=>f(z),[z]),q=T(()=>t(z),[z]),$="template"===Q.kind,ee="template"===Q.kind?Q.id:null,re="template"===Q.kind?Q.pageSlug??F??"":"document"===Q.kind?Q.slug??"":Q.slug,ne="page"===Q.kind?Q.siteId??null:null,te=z.blocks,oe=T(()=>U(Q,_,te),[U,_,te,Q.kind,"template"===Q.kind?Q.id:"document"===Q.kind?Q.record:Q.siteId]),ue=oe.capabilities,ae=B(e=>z.documentHooks?.stored?.(e)??e,[z]);C(()=>{m(z,ne)},[z,ne]);const se=A(Q);C(()=>{se.current=Q},[Q]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(D?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Er(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=E(null),[ge,pe]=E(null),[he,ye]=E(null),[we,be]=E(null),Se=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,Se):null,[Pe,je]=E(null),Re=A(null),Ee=A(null),[Te,Be]=E(!1),Ce=A(null),[Ae,He]=E(null),Le=A(null),[Ne,De]=E(null),[Oe,Ye]=E(!1),Fe=A(null);C(()=>{Fe.current=Ne},[Ne]);const[Me,We]=E(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ge=A(Me);C(()=>{Ge.current=Me},[Me]);const Ke=A(()=>Promise.resolve(!1)),Ue=B(e=>{Ee.current=e,Be(!0)},[]),Ve=g({save:async({id:e,data:r})=>{if(p(Ge.current)){if(!await Ke.current(e,r)){if(!p(Ge.current))return void Ue({id:e,data:r});throw new Error("page save did not land")}}else Ue({id:e,data:r})},onFailure:(e,r)=>{0===r&&Z.send("storefront-editor:save-failed")}}),{state:Xe,push:xe,flush:Qe,pause:Je,resume:Ze,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Ve,er=A(Xe);C(()=>{er.current=Xe},[Xe]);const rr=u(Xe),nr=B(()=>{const e=Ee.current;e&&(Ee.current=null,Be(!1),xe(e))},[xe]),tr=A("");tr.current||(tr.current=h());const[or,ur]=E(0),ar=A(!1),[sr,ir]=E(M(j)),lr=A(!1);C(()=>{if(lr.current)return;lr.current=!0;const e=Z.address.search(),r=W(j,e);r?Z.address.load(r):M(j)&&ir(!1)},[j,Z]);const cr=Z.send;C(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void Z.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:X?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Le.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:L,s=V(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=B(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=B(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=B(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=B(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ge.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Le.current,tr.current));if(t.ok)return Le.current=t.value.version??Le.current,Ye(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ge.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Le.current=n.value,Ke.current(e,r,!0)}ze(),Fe.current=u,De(u)}return Ye(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);C(()=>{Ke.current=kr},[kr]);const vr=B(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ce.current=r,p(Ge.current)?xe({id:ke,data:r}):Ue({id:ke,data:r})},[ke,cr,Ue,xe,ae]),gr=B(async()=>{p(Ge.current)&&nr();return await Qe()&&null==Ee.current},[nr,Qe]),pr=A(gr);C(()=>{pr.current=gr},[gr]);const hr=A(fr);C(()=>{hr.current=fr},[fr]);const yr=B(()=>{Z.address.reload()},[Z]),wr=A(()=>Promise.resolve(!1));C(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Le.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const br=null!==Pe;C(()=>{if(!fe||!ke||!de||br)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ge.current,heldWrite:()=>({pending:null!=Ee.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ge.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(b)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,br]);const Sr=B(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=B(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=B(()=>{er.current.paused?(p(Ge.current)&&nr(),Ze()):Je()},[nr,Je,Ze]),jr=B(()=>{qe()},[qe]),Rr=B(e=>{Ce.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Ee.current=null,Be(!1)},setVersion:e=>{Le.current=e},setSaveConflict:De,setAccess:We}),G(e),J(e),Re.current=null,je(null),ve(null),pe(null),ye(null),be(null),Z.address.show(e),"document"!==e.kind&&K(e)&&Z.send("storefront-editor:navigated",{target:e})},[_e,Z,me,G,K]),Er=B(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Ee.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?He(e):Qe().then(r=>{r?Rr(e):He(e)})},[Rr,$e,Qe,F]),Tr=B(()=>He(null),[]),Br=B(()=>{He(e=>(e&&Rr(e),null))},[Rr]),Cr=B(async()=>{const e=Ae;if(!e)return;await gr()&&(He(null),Rr(e))},[Ae,gr,Rr]),Ar=B(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ge.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Le.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Le.current=t.value.version??Le.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
|
|
2
|
+
return H(N.Provider,{value:{target:Q,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ce.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Xe,autoSaveEnabled:!Xe.paused,autoSaveStoppedByConflict:Xe.stopped,hasUnsavedEdits:Xe.pending||Te,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Ar,access:Me,readOnly:null!==I(Me)||null!==Pe||null!==Ne,readOnlyReason:Pe,takeOverEditing:Sr,viewReadOnly:Ir,saveConflict:Ne,saveUnreachable:Oe,reloadFromServer:yr,navigate:Er,pendingNav:Ae,cancelPendingNav:Tr,discardAndNavigate:Br,saveAndNavigate:Cr},children:O})}export{N as ScreenDocumentContext,O as ScreenDocumentProvider,D as useScreenDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-CLJ3KXYF.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-ITRBDUAM.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};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{sidesStartEach as e,SidesInput as n,SidesEachToggle as t}from"./chunk-CLAADE4J.js";import{SettingsDefaultReset as l}from"./chunk-2T22IY3J.js";import{deviceField as o}from"./chunk-BLE3U2GS.js";import{noControlField as a,NoControlMark as i}from"./chunk-22I55W37.js";import{describedAs as r}from"./chunk-LX23TCTP.js";import{withStyleKind as s}from"./chunk-CWELHADJ.js";import{phoneKey as u}from"./chunk-E52W3M5I.js";import{foldMetaOf as c,FOLD_FIELD_MARKER as d}from"./chunk-ANPOR6EY.js";import{useSelectedHost as p,useEasel as f}from"./chunk-ITRBDUAM.js";import{DEFAULT_PANEL_WORDS as b}from"./chunk-56ID6FKZ.js";import{SettingsSwitch as m}from"./chunk-OECWLNKJ.js";import{FieldSelect as h}from"./chunk-KFWNGPW3.js";import{SettingsField as v}from"./chunk-MIX7EGRG.js";import{SettingsSegmented as g}from"./chunk-DX3VILZ3.js";import{useWords as y}from"./chunk-MFIRYGHW.js";import{useState as k}from"react";import{AlignmentIcon as w,BoxJustifyIcon as x,WrapIcon as C,ArrowRightIcon as j,GapIcon as F,WidthIcon as L,PlacementIcon as O,NudgeIcon as S,DesktopIcon as E,BoxXEndIcon as P,BoxXCenterIcon as R,BoxXStartIcon as A,PaddingAllIcon as M,BoxYBetweenIcon as I,BoxYStretchIcon as B,BoxYEndIcon as K,BoxYCenterIcon as W,BoxYStartIcon as T,BoxXBetweenIcon as $,BoxXStretchIcon as G,BoxItemAlignmentIcon as N}from"efficient-shell/icons/efficient";import{textAlignOptions as V,AlignmentGrid as J,PositionInput as D,Slider as H}from"efficient-shell/ui";import{jsx as _,Fragment as z,jsxs as X}from"react/jsx-runtime";var Y=e=>e;function U(e,n){return e("{value} on desktop").replace("{value}",n)}var Z=()=>{};function q(){return null}function Q(e){if(!e.trim())throw new Error("noGlyph() needs a reason naming the ruling that decided it.");/* @__PURE__ */
|
|
2
|
+
return _(q,{},e)}function ee(e){return e.type===q}function ne(e){return ee(e)?void 0:e}function te(e){for(const[n,t]of Object.entries(e))t&&"object"==typeof t&&!c(t)&&s(t,`section:${n}`);return e}function le(e,n){return{type:"custom",[d]:{label:e,level:n},marker:!0,fold:e,render:()=>/* @__PURE__ */_(z,{})}}function oe(e){return le(e,2)}function ae(e){return le(e,1)}var ie=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"Space between",value:"between"},{label:"End",value:"end"}],re=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"End",value:"end"},{label:"Stretch",value:"stretch"}],se="Wrap",ue=[{label:"Wrap",value:"wrap"},{label:"No wrap",value:"nowrap"}],ce="Direction",de=[{label:"Stacked",value:"column"},{label:"One row",value:"row"}],pe={min:-32,max:64,step:2,builtIn:0},fe={min:30,max:100,step:5,fallback:60},be=["top-left","top-center","top-right","left","center","right","bottom-left","bottom-center","bottom-right"],me="bottom-left",he={"top-left":"Top left","top-center":"Top center","top-right":"Top right",left:"Left",center:"Center",right:"Right","bottom-left":"Bottom left","bottom-center":"Bottom center","bottom-right":"Bottom right"},ve=be.map(e=>({value:e,label:he[e]}));function ge(e,n=me){return be.includes(e)?e:n}var ye=40,ke=e=>"number"==typeof e?e:null;function we(e,n,t){const l={};for(const o of["x","y"])t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}var xe=["top","right","bottom","left"],Ce={top:"sectionPaddingTop",right:"sectionPaddingRight",bottom:"sectionPaddingBottom",left:"sectionPaddingLeft"},je=e=>"number"==typeof e?e:null;function Fe(e,n,t){const l={};for(const o of xe)t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}function Le(e){if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const n=e&&"object"==typeof e?e:{};return Object.fromEntries(xe.map(e=>[e,je(n[e])]))}function Oe(e){const n={};for(const t of xe)"number"==typeof e[t]&&(n[t]=e[t]);return Object.keys(n).length?n:void 0}function Se(e,n={}){const t=n=>{const t=n[e];return t&&"object"==typeof t?t:{}},l=e=>Object.hasOwn(n,e)?n[e]:e;return{read:(e,n)=>t(e)[l(n)],write:(n,o,a)=>{const i={...t(n)};return void 0===a?delete i[l(o)]:i[l(o)]=a,{[e]:Object.keys(i).length?i:void 0}}}}function Ee(e,n,t){const l=Pe(e),o=p();if(t)return[t.value,t.onChange];const a=o?.values??{};return[e.read(a,n),e=>l([[n,e]])]}function Pe(e){const n=p();return t=>{n&&n.onChangeMany(n=>{let l={};for(const[o,a]of t)l={...l,...e.write({...n,...l},o,a)};return l})}}var Re={read:(e,n)=>e[n],write:(e,n,t)=>({[n]:t})},Ae={fieldKey:u,ownField:!0,read:(e,n)=>e[u(n)],write:(e,n,t)=>({[u(n)]:t})};function Me(e){return{...Se(e),fieldKey:n=>`_${e}_${n}`}}function Ie({row:e,desktopKey:n,access:t,props:l}){const o=p(),a=o?.values?.[n],[i,r]=Ee(t,n);return t.ownField?e.render({...l,follows:a,twinAccess:t}):e.render({...l,value:i,storedValue:i,follows:a,twinAccess:t,onChange:r})}function Be(e,n,t=Ae,l={}){const a=l.phoneRow??n,i={...a,render:n=>/* @__PURE__ */_(Ie,{row:a,desktopKey:e,access:t,props:n})};return{[e]:o("desktop",n),[t.fieldKey(e)]:o("mobile",i)}}var Ke=["left","center","right"];function We(e,{options:n,value:t,onChange:l,ariaLabel:o,disabled:a=!1}){/* @__PURE__ */
|
|
3
|
+
return _(g,{options:n.map(n=>n.picture?{id:n.value,label:n.picture,title:e(n.title??n.label)}:{id:n.value,label:e(n.label),title:void 0===n.title?void 0:e(n.title)}),value:t,onChange:l,ariaLabel:e(o),disabled:a})}function Te(e,{label:n,value:t,onChange:l,points:o}){const a=o.find(e=>e.disabled),i=o.map(n=>({...n,label:e(n.label),...n.title?{title:e(n.title)}:null}));/* @__PURE__ */
|
|
4
|
+
return _(v,{label:e(n),icon:/* @__PURE__ */_(O,{}),hint:a?.title?e(a.title):void 0,children:/* @__PURE__ */_(J,{label:e(n),value:t,points:i,onChange:l})})}function $e({say:e,label:n,value:t,onChange:l,pointsFor:o}){const{appState:a,selectedItem:i}=f(e=>e),r=i?.props?.id?String(i.props.id):void 0;return Te(e,{label:n,value:t,onChange:l,points:o(a?.data,r)})}function Ge({say:e,o:n}){const t=p(),o=y("panel",b),a=t?.values??{},i={x:ke(a[n.keys.x]),y:ke(a[n.keys.y])},r=e(n.label??"Position"),s=Boolean(i.x||i.y),u=e=>{const l=we(n.keys,i,e);Object.keys(l).length&&t?.onChangeMany(l)},c=/* @__PURE__ */_(D,{label:r,value:i,onChange:u,words:{x:e("Left and right"),y:e("Up and down"),unit:"px"},placeholder:{x:"0",y:"0"},min:n.min,max:n.max,step:n.step??1}),d=/* @__PURE__ */_(l,{words:o,label:r,changed:s,detail:"0 px, 0 px",onReset:()=>u({x:null,y:null})});return null===n.label?/* @__PURE__ */X("div",{className:"sf-position-line",children:[c,d]}):/* @__PURE__ */_(v,{label:r,icon:/* @__PURE__ */_(S,{}),changed:s,action:d,children:c})}var Ne={x:{start:/* @__PURE__ */_(A,{}),center:/* @__PURE__ */_(R,{}),end:/* @__PURE__ */_(P,{}),stretch:/* @__PURE__ */_(G,{}),between:/* @__PURE__ */_($,{})},y:{start:/* @__PURE__ */_(T,{}),center:/* @__PURE__ */_(W,{}),end:/* @__PURE__ */_(K,{}),stretch:/* @__PURE__ */_(B,{}),between:/* @__PURE__ */_(I,{})}},Ve=e=>"row"===e?"row":"column";function Je({say:e,kind:n,label:t,options:l,value:o,onChange:a,o:i}){const r=p(),s="justify"===n==("row"===(i.runs??Ve)(r?.values?.[i.directionKey??"direction"]))?"x":"y";return We(e,{options:l.map(e=>({label:e.label,value:e.value,picture:Ne[s][e.value]})),value:o,onChange:a,ariaLabel:t})}function De(e,n){const t=(e.useFallback??Z)(n);return Object.fromEntries(xe.map(n=>[n,t?.[n]??e.fallback[n]]))}function He({say:e,tier:n,o:t,props:l}){const o=De(t,l),a=p(),i=a?.values??{},r="mobile"===n?t.phoneKeys:t.keys,s=Object.fromEntries(xe.map(e=>[e,je(i[r[e]])])),u="mobile"===n?Object.fromEntries(xe.map(e=>[e,je(i[t.keys[e]])])):null;/* @__PURE__ */
|
|
5
|
+
return _(ze,{say:e,o:t,fallback:o,value:s,follows:u,readOnly:l.readOnly,onChange:e=>{const n=Fe(r,s,e);Object.keys(n).length&&a?.onChangeMany(n)}})}function _e({say:e,o:n,props:t}){const l=De(n,t);/* @__PURE__ */
|
|
6
|
+
return _(ze,{say:e,o:n,fallback:l,value:Le(t.value),follows:"follows"in t?Le(t.follows):null,readOnly:t.readOnly,onChange:e=>t.onChange(Oe(e))})}function ze({say:o,o:a,fallback:i,value:r,follows:s,readOnly:u,onChange:c}){const d=Object.fromEntries(xe.map(e=>[e,String(s?.[e]??i[e])])),[p,f]=k(()=>e(r,d)),m=y("panel",b),h=xe.map(e=>d[e]),g=`${1===new Set(h).size?h[0]:h.join(" / ")}px`;/* @__PURE__ */
|
|
7
|
+
return _(v,{label:o(a.label),icon:a.icon??/* @__PURE__ */_(M,{}),action:/* @__PURE__ */X(z,{children:[
|
|
8
|
+
/* @__PURE__ */_(t,{each:p,label:o("Each side"),onChange:f,disabled:u}),
|
|
9
|
+
/* @__PURE__ */_(l,{words:m,label:o(a.label),changed:xe.some(e=>"number"==typeof r[e]),detail:s?U(o,g):g,disabled:u,onReset:()=>c({top:null,right:null,bottom:null,left:null})})]}),children:/* @__PURE__ */_(n,{label:o(a.label),each:p,value:r,placeholder:d,min:a.min,max:a.max,step:a.step,readOnly:u,onChange:c,words:{sides:{top:o("Padding top"),right:o("Padding right"),bottom:o("Padding bottom"),left:o("Padding left")},vertical:o("Top and bottom"),horizontal:o("Left and right"),unit:"px"}})})}var Xe=e=>""===e||"px"===e?e:` ${e}`;function Ye({label:e,value:n,onChange:t,min:o,max:a,step:i=1,unit:r="",hint:s,emptyLabel:u,inputMax:c,readOnly:d=!1,clears:p,detail:f,resetWords:b}){const m="number"==typeof n,h=p?/* @__PURE__ */_(l,{label:e,changed:m,detail:f??u??(void 0===s?void 0:`${s}${Xe(r)}`),disabled:d,onReset:()=>t(void 0),...b?{words:b}:{}}):void 0;return{track:/* @__PURE__ */_("div",{className:"sf-slider",children:/* @__PURE__ */_(H,{min:o,max:a,step:i,value:n,suffix:r||void 0,showInput:!0,label:e,disabled:d,...p&&void 0!==s?{placeholderValue:s}:{},...u?{emptyLabel:u}:{},...void 0!==c?{inputMax:c}:{},size:"sm",boxSize:"md",className:"sf-slider-track",onChange:e=>{null===e?p&&m&&t(void 0):e!==n&&t(e)}})}),reset:h}}function Ue({caption:e,label:n,value:t,hint:l,emptyLabel:o,...a}){const i=void 0!==l||void 0!==o,r="number"==typeof t,{track:s,reset:u}=Ye({...a,label:n,value:r?t:i?null:a.min,hint:l,emptyLabel:o,clears:i});/* @__PURE__ */
|
|
10
|
+
return _(v,{label:e??n,action:u,children:s})}function Ze({draw:e,props:n,useMax:t,useHint:l}){return e(n,{max:(t??Z)(n),hint:(l??Z)(n)})}function qe(e=Y){function n(n,t,l,o,a,i,s="",u){const c="function"==typeof u?{action:u}:u??{},{action:d,clear:p}=c,f=(r,u)=>{const f="storedValue"in r?r.storedValue:r.value,b="follows"in r,m=b&&!1!==p?.phoneFollows,h=b||void 0!==p,g="number"==typeof r.value,y=void 0===p?i:u.hint??("function"==typeof p.hint?p.hint(r):p.hint)??i,k=m&&"number"==typeof r.follows?r.follows:y,w=Xe(s),x=!p?.emptyLabel||m&&"number"==typeof r.follows?void 0:p.emptyLabel,C=x??`${k}${w}`,j="function"==typeof c.hint?c.hint(r):c.hint,{track:F,reset:L}=Ye({label:e(n),value:g?r.value:h?null:i,onChange:e=>r.onChange(e),min:l,max:u.max??o,step:a,unit:s,hint:h?k:void 0,emptyLabel:x,inputMax:c.inputMax,readOnly:!0===r.readOnly,clears:h,detail:m?U(e,C):C});/* @__PURE__ */
|
|
11
|
+
return _(v,{label:e(n),icon:ne(t),hint:void 0===j?void 0:e(j),action:h?L:d?d(f,r.onChange):void 0,children:F})},b=c.useMax,m=p?.useHint;return{type:"custom",...r({},{type:"number",label:n}),render:b||m?e=>/* @__PURE__ */_(Ze,{draw:f,props:e,useMax:b,useHint:m}):e=>f(e,{})}}function t(n){return We(e,n)}function s(n,o,a,i,s={}){const u=a.map(e=>"string"==typeof e?{label:e,value:e}:e);return{type:"custom",...r({},{type:"radio",label:n,options:u.map(e=>({value:e.value,label:e.label}))}),render:a=>{const{value:r,onChange:c,field:d}=a,p=u.some(e=>e.value===r),f=!0===a.readOnly;if("follows"in a&&!u.some(e=>""===e.value)){const d=s.phoneRest?s.phoneRest(a.follows):a.follows,b=u.find(e=>e.value===d)??u.find(e=>e.value===i);/* @__PURE__ */
|
|
12
|
+
return _(v,{label:e(n),icon:ne(o),action:/* @__PURE__ */_(l,{label:e(n),changed:p,detail:U(e,e(b?.label??"")),disabled:f,onReset:()=>c(void 0)}),children:t({options:u,value:p?r:b?.value??i,onChange:c,ariaLabel:n,disabled:f})})}const b="follows"in a&&s.followsLabel?s.followsLabel(a.follows):void 0;/* @__PURE__ */
|
|
13
|
+
return _(v,{label:e(n),icon:ne(o),action:"follows"in a&&s.followsLabel?/* @__PURE__ */_(l,{label:e(n),changed:null!=r&&""!==r,detail:void 0===b?void 0:U(e,e(b)),disabled:f,onReset:()=>c(void 0)}):void 0,children:t({options:u,value:p?r:r||d?.currentValue||i,onChange:c,ariaLabel:n,disabled:f})})}}}function c(e,n){return n.phone?e.unshift({label:"Match desktop",value:"",picture:/* @__PURE__ */_(E,{})}):n.inherit&&e.unshift({label:n.inherit,value:""}),e}function d(e,n){return n.inherit||n.phone?{...e,render:n=>e.render({...n,onChange:e=>n.onChange(""===e?void 0:e)})}:e}function p(e,n,t,l){if(l.access){const o=l.inherit?"":l.fallback??"left",a=t({...l,phone:!1}),i=e=>{const n="string"==typeof e&&""!==e&&a.some(n=>n.value===e)?e:o;return a.find(e=>e.value===n)?.label};return Be(e,n(l,o),l.access,{phoneRow:n({...l,phone:!0},"",i)})}return{[e]:o("desktop",n(l)),[u(e)]:o("mobile",n({...l,phone:!0},""))}}function f(e){return c(V(e.allow??Ke).map(e=>({label:e.label,value:e.value,picture:e.icon})),e)}function b(e,n=e.fallback??"left",t){return d(s(e.label??"Text alignment",/* @__PURE__ */_(w,{}),f(e),n,t?{followsLabel:t}:{}),e)}function g(e){const n={left:Ne.x.start,center:Ne.x.center,right:Ne.x.end};return c(V((e.allow??Ke).filter(e=>e in n)).map(e=>({label:e.label,value:e.value,picture:n[e.value]})),e)}function y(e,n=e.fallback??"left",t){return d(s(e.label??"Block alignment",/* @__PURE__ */_(x,{}),g(e),n,t?{followsLabel:t}:{}),e)}function k(n,t,l,o,a,i){return{type:"custom",options:o,fallback:a,...r({},{type:"radio",label:t,options:o.map(e=>({value:e.value,label:e.label}))}),render:({value:r,onChange:s,field:u})=>{const c=u.options??o,d=u.fallback??a,p=c.some(e=>e.value===r)?r:d;/* @__PURE__ */
|
|
14
|
+
return _(v,{label:e(t),icon:ne(l),children:/* @__PURE__ */_(Je,{say:e,kind:n,label:t,options:c,value:p,onChange:s,o:i})})}}}function O(e={}){return k("justify","Justify",/* @__PURE__ */_(x,{}),ie,ie[0].value,e)}function S(e={}){return k("align","Item alignment",/* @__PURE__ */_(N,{}),re,"stretch",e)}function P(){const n=se;return{type:"custom",options:ue,fallback:ue[1].value,...r({},{type:"radio",label:n,options:ue.map(e=>({value:e.value,label:e.label}))}),render:({value:t,onChange:l,id:o,name:a})=>{const i=`${o??a??n}-label`;/* @__PURE__ */
|
|
15
|
+
return _(v,{label:e(n),labelId:i,icon:/* @__PURE__ */_(C,{}),action:/* @__PURE__ */_(m,{checked:(r=t,!0===r||"wrap"===r),onChange:e=>l(e?ue[0].value:ue[1].value),ariaLabelledBy:i})});var r}}}function R({offered:e,fallback:n,resolve:t}){const l=t??(t=>e.some(e=>e.value===t)?t:n),o=s(ce,
|
|
16
|
+
/* @__PURE__ */_(j,{}),e.map(e=>({label:e.label,value:e.value})),l(void 0));return{type:"custom",render:e=>o.render({...e,value:l(e.value),onChange:n=>e.onChange(n)})}}function A({min:e,max:t,step:l,builtIn:o,resolve:a,action:i,mark:r}){const s=n("Gap",/* @__PURE__ */_(F,{}),e,t,l,o,"px",i),u=a??(e=>"number"==typeof e?e:o);return{...r,type:"custom",render:e=>s.render({...e,value:u(e.value,e.field),storedValue:e.value,onChange:n=>e.onChange(n)})}}function M(n,{fallback:t=me,pointsFor:l}={}){return{type:"custom",render:({value:o,onChange:a})=>{const i=ge(o,t);return l?/* @__PURE__ */_($e,{say:e,label:n,value:i,onChange:a,pointsFor:l}):Te(e,{label:n,value:i,onChange:a,points:ve})}}}function I(n){return{[n.keys.x]:{type:"custom",render:()=>/* @__PURE__ */_(Ge,{say:e,o:n})},[n.keys.y]:{...a({type:"custom",render:()=>/* @__PURE__ */_(i,{})},"always"),reachedBy:n.keys.x}}}function B(n={}){const t={...Ce,...n.keys},l={keys:t,phoneKeys:Object.fromEntries(xe.map(e=>[e,u(t[e])])),fallback:{top:0,right:0,bottom:0,left:0,...n.fallback},useFallback:n.useFallback,label:n.label??"Padding",icon:n.icon,min:n.min??0,max:n.max??200,step:n.step??4},r=!1!==n.phone,s=!1===n.group?{}:{_gSpacing:oe("Padding")};if(n.object){const t={type:"custom",render:n=>/* @__PURE__ */_(_e,{say:e,o:l,props:n})};return te({...s,...r?Be(n.object.key,t,n.object.phone):{[n.object.key]:t}})}const c=n=>{const t={type:"custom",render:t=>/* @__PURE__ */_(He,{say:e,tier:n,o:l,props:t})};return r?o(n,t):t},d=()=>a({type:"custom",render:()=>/* @__PURE__ */_(i,{})},"always"),p=xe.filter(e=>"top"!==e);return te({...s,[l.keys.top]:c("desktop"),...r?{[l.phoneKeys.top]:c("mobile")}:{},...Object.fromEntries(p.map(e=>[l.keys[e],{...d(),reachedBy:l.keys.top}])),...r?Object.fromEntries(p.map(e=>[l.phoneKeys[e],o("mobile",d())])):{}})}return{slider:n,select:function(n,t,o,a,i){const{note:s,phoneRest:u}="string"==typeof i?{note:i,phoneRest:void 0}:i??{};return{type:"custom",options:o,fallback:a,...s?{note:s}:{},...r({},{type:"select",label:n}),render:i=>{const{value:r,onChange:c,field:d}=i,p=d.options??o,f=d.fallback??a,b=p.some(e=>e.value===r),m="follows"in i,g=m?u?u(i.follows):i.follows:void 0,y=m?p.find(e=>e.value===g)??p.find(e=>e.value===f):void 0,k=b?r:y?.value??f,w=!0===i.readOnly;/* @__PURE__ */
|
|
17
|
+
return _(v,{label:e(n),icon:ne(t),action:m?/* @__PURE__ */_(l,{label:e(n),changed:null!=r&&""!==r,detail:y?U(e,e(y.label)):void 0,disabled:w,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */_(h,{value:k,ariaLabel:e(n),readOnly:w,onChange:c,options:[...s?[{label:e(s),value:"\0note",disabled:!0}]:[],...p.map(n=>({label:e(n.label),value:n.value}))]})})}}},Segmented:t,segmented:s,boxJustifyField:O,boxAlignField:S,boxWrapField:P,directionField:R,gapField:A,placementField:M,PlacementGridView:function(n){return Te(e,n)},positionFields:I,sidesPaddingFields:B,alignmentField:function(e={},n=e.fallback??"left"){return b(e,n)},alignmentFields:function(e="align",n={}){return p(e,b,f,n)},AlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:f(e),value:n,onChange:l,ariaLabel:o,disabled:a})},blockAlignmentField:function(e={},n=e.fallback??"left"){return y(e,n)},blockAlignmentFields:function(e="align",n={}){return p(e,y,g,n)},BlockAlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:g(e),value:n,onChange:l,ariaLabel:o,disabled:a})},boxFieldSet:function(e={}){const t=e.width??fe,l=e.nudge?.limit??40,o=e.direction??{offered:de,fallback:"column"},a=o.resolve??(e=>o.offered.some(n=>n.value===e)?e:o.fallback),i={runs:e=>"row"===a(e)?"row":"column"};return{_gLayout:oe("Layout"),placement:M("Placement",e.placement),width:n("Width",/* @__PURE__ */_(L,{}),t.min,t.max,t.step,t.fallback,"%"),direction:R(o),gap:A(e.gap??pe),justify:O(i),align:S(i),wrap:P(),_gNudge:oe("Nudge"),...I({keys:e.nudge?.keys??{x:"nudgeX",y:"nudgeY"},min:-l,max:l,label:null}),...B(e.padding)}}}}var{slider:Qe,select:en,Segmented:nn,segmented:tn,boxJustifyField:ln,boxAlignField:on,boxWrapField:an,directionField:rn,gapField:sn,placementField:un,PlacementGridView:cn,positionFields:dn,sidesPaddingFields:pn,alignmentField:fn,alignmentFields:bn,AlignmentStrip:mn,blockAlignmentField:hn,blockAlignmentFields:vn,BlockAlignmentStrip:gn,boxFieldSet:yn}=qe();export{he as ANCHOR_LABELS,mn as AlignmentStrip,re as BOX_ALIGN_POINTS,de as BOX_DIRECTIONS,ce as BOX_DIRECTION_LABEL,pe as BOX_GAP,ie as BOX_JUSTIFY_POINTS,ye as BOX_NUDGE_LIMIT,be as BOX_PLACEMENTS,me as BOX_PLACEMENT_DEFAULT,fe as BOX_WIDTH,se as BOX_WRAP_LABEL,ue as BOX_WRAP_POINTS,gn as BlockAlignmentStrip,Re as FLAT_ACCESS,ve as OPEN_PLACEMENT_POINTS,Ae as PHONE_KEY_ACCESS,cn as PlacementGridView,Ce as SIDE_PAD_KEYS,nn as Segmented,Ue as SliderControl,fn as alignmentField,bn as alignmentFields,hn as blockAlignmentField,vn as blockAlignmentFields,on as boxAlignField,qe as boxFieldBuilders,yn as boxFieldSet,ln as boxJustifyField,an as boxWrapField,rn as directionField,sn as gapField,oe as group,ne as iconOf,ee as isNoGlyph,Q as noGlyph,ge as normaliseBoxPlacement,Se as objectAccess,U as onDesktopWords,Me as phoneObjectAccess,Be as phoneTwinFields,un as placementField,dn as positionFields,we as positionPatch,ae as section,tn as segmented,en as select,te as sharedStyleKinds,Le as sidesFromObject,pn as sidesPaddingFields,Fe as sidesPaddingPatch,Oe as sidesToObject,Qe as slider,Pe as useAccessPatch,Ee as useAccessValue};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-CLJ3KXYF.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-C4TJN6GR.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
|
|
2
2
|
/* @__PURE__ */o("span",{children:e.group}),
|
|
3
3
|
/* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
4
4
|
return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-C4TJN6GR.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-JQQFB7EZ.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{useCanvasEvent as d}from"./chunk-TOKMFZPB.js";import{isTypingTarget as p,framePointToHost as f}from"./chunk-FR7EEKFF.js";import{zoneKey as m,ROOT_SLOT as y,ROOT_ID as h}from"./chunk-EUFDQ4KL.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as C,AddIcon as w,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as P,RedoIcon as A,PasteIcon as E,StylesIcon as j,LayersIcon as D,CopyIcon as K}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var L=s(),I=/* @__PURE__ */new WeakMap;function Y(e){if(e.claimsPage)return L;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=I.get(n);return t||(t=s(),I.set(n,t)),t}function F(){return Y(e())}function S(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 B(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?S(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function X(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 U(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=B(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 V(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=B(e,i,t),k=T(e,n),b=d.held,v=b&&!p?R(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...W(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:Q(x?N(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?Z(e).pinned:void 0})}function N(e,n){const o=e.copyItem;if(!o||!n)return null;const l=Z(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */M(w,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */M(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */M(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */M(C,{}),danger:!0,onClick:s("delete")}]}}function Q(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function W(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var Z=e=>e.words?.screen??t.menu;function G(e){const n=Z(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(P,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=S(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):m(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */M(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */M(D,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=Z(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=X(e);if(!o)return;const l=t.selected();if(!l)return;const r=U(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),d(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=f(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),d(t,"mousedown",i),d(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */M($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?V(e,n):"input"===n.kind?J(e,n.el):G(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{L as EASEL_NODE_CLIPBOARD,T as ancestorChain,Y as nodeClipboardOf,B as nodeClipboardRules,V as nodeMenuItems,X as nodeShortcut,G as pageMenuItems,R as pastePlace,U as runNodeShortcut,J as textMenuItems,F as useNodeClipboard,H as useNodeContextMenu};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-JQQFB7EZ.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as y}from"./chunk-HZSZT3BE.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,CANVAS_TYPING_EVENT as k}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as S,related as x,isTypingTarget as C,upsertCanvasStyle as E,removeCanvasStyle as I,WORDS_CLEAR as A,frameRectToHost as D,drawnBox as M}from"./chunk-FR7EEKFF.js";import{queryAllCopies as O}from"./chunk-7UFKEX72.js";import{find as $,ROOT_ID as P,getList as j,remove as z,parseZoneKey as R,move as L,duplicate as B,replaceNode as N,createNode as V,insert as K,normalizeData as T,createResolveCache as Z,slotsOf as F,deepEqual as H,ROOT_SLOT as W,resolveNodeData as q}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as Q,fieldsFrom as Y,drawnBlockCount as U,defaultsFrom as X}from"./chunk-KXM6YRG2.js";import{createContext as G,useEffect as J,useContext as _,useRef as ee,useSyncExternalStore as te,useState as ne,useReducer as oe,useCallback as re,createElement as le,useMemo as ie,useLayoutEffect as se}from"react";import{jsx as ae,jsxs as ce,Fragment as ue}from"react/jsx-runtime";import{createPortal as de}from"react-dom";import{registerModalEscapeInterceptor as pe,FloatingBar as fe,TextToolbar as he,LinkPicker as me}from"efficient-shell/ui";function ge(e){return!["setData","setUi","set"].includes(e.type)}var ye=(e,t,n,o)=>{const r=j(e,t,R(n));return r?.[o]??null},ve=(e,t,n,o,r)=>{const l=ye(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function we(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 be(e,t,n){return n?"node"===n.kind?$(e,t,n.id)?n:null:n.parentId===P?j(e,t,n)?n:null:$(e,t,n.parentId)&&j(e,t,n)?n:null:null}function ke(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 Se(e,t,n){const o=xe(e,t,n);if(o===e)return e;const r=be(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function xe(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 ke(e,n,"function"==typeof t.ui?t.ui(we(e,n)):t.ui);case"set":{const r={data:o,ui:we(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=ke(i,n,l.ui,!0)),i}case"insert":{const r={...R(t.destinationZone),index:t.destinationIndex},l=V(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=ve(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:N(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=ve(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=B(o,n,r.props.id),i=ye(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return xe(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ye(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...R(t.destinationZone),index:t.destinationIndex};return{...e,data:L(o,n,r.props.id,l)}}case"remove":{const r=ve(o,n,t.zone,t.index,"remove");return{...e,data:z(o,n,r.props.id)}}default:return e}}var Ce={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}},Ie=0,Ae=()=>`history-${Ie+=1}`;function De(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=T(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:Ae()}],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:Ae()}],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=Se(c,e,t),c===n)return;const o=e.recordHistory??ge(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=be(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))},E=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Ce,...i,...n}};let A=I();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([q(r,t,{cache:D,trigger:e,metadata:n}),...l.map(o=>q(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=$(r,t,i)?.node;s&&s===$(o,t,i)?.node&&(r=N(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:be(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=$(c.data,t,e)?.node;if(!r)return!1;const l=await q(r,t,{cache:D,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if($(c.data,t,e)?.node!==r)return;const o=N(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:be(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:we(e,t)},o="node"===e.selection?.kind?$(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>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:we(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&E(e)}},getPermissions:A,getItemById:n=>$(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return j(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:be(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=T(e,t);c={...c,data:r,selection:be(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Ae()}],d=0),c!==o&&w()},undo(){d>0&&E(d-1)},redo(){d<u.length-1&&E(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=I(),h=null,w())},setConfig(e){e!==t&&(t=e,A=I(),h=null,w())}};return M}function Me(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&&C(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 Oe=G(null),$e=G(!0);function Pe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return J(()=>{n&&e.resolveAll()},[e,n]),J(()=>{if(t&&"undefined"!=typeof document)return Me(document,e)},[e,t]),/* @__PURE__ */ae(Oe.Provider,{value:e,children:/* @__PURE__ */ae($e.Provider,{value:t,children:o})})}function je(){const e=_(Oe);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ze(e){const t=je(),n=ee({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 te(t.subscribe,o,o)}function Re(){return function(e){return ze(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"],Be="host-tokens";function Ne(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Le){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?E(t,Be,n):I(t,Be)}var Ve="data-easel-block",Ke="data-easel-dropzone",Te={},Ze="data-es-mirror",Fe="undefined"==typeof window?J:se;function He(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 We({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=ee(null),[p,f]=ne(null);return Fe(()=>{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]),Fe(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),S(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){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){Ne(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ne(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ae("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?de(e,p):null})}var qe=G(null),Qe=G(Te),Ye=[];function Ue({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=je(),s=ze(n=>j(n.appState.data,i.config,{parentId:e,slot:t})??Ye),a=ze(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==P),c=ze(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=_(qe),d=["es-zone"];return s.length&&d.push("has-children"),e===P&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==P&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ae("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ae(ot,{node:e},e.props.id))})}function Xe(e,t,n,o){const r=ie(()=>{const n={};for(const o of Q(Y(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ae(Ue,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=U(n[e],o);return r}function Ge(e){return ie(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ae(Ue,{parentId:e,slot:t,...n})},[e])}var Je=["top","bottom","zIndex"];function _e(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function et(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));_e(e,"position",t?"sticky":"relative");for(const n of Je)_e(e,n,t?.[n]??"");return!!t}var tt="data-es-canvas-relative";function nt(e){e.hasAttribute(tt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(tt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(tt,"")),!1)}function ot({node:e}){const t=je().config,n=t.components[e.type],o=e.props.id,r=ee(null),l=function(e,t){return ie(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ve),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Ve,e),n.setAttribute("data-easel-dnd",e),nt(n))},[e,t])}(o,r),i=ee(null),s=!!n?.inline;!function(e,t){const n=ee(!1),o=ee(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=ee(()=>{});Fe(()=>o.current()),Fe(()=>{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?nt(e):et(e));const a=_(Qe),c=Xe(n,o,e.props,t.components),u=Ge(o);if(!n?.render)return null;const d=n.render,p={...X(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ae(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ae("div",{ref:i,[Ve]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ae(d,{...p,editor:f,editMode:!0})})}function rt({metadata:e}){const t=ze(e=>e.config),n=ze(e=>e.appState.data.root).props??{},o=t.root?.render,r=Xe(t.root,P,n,t.components),l=Ge(P),i=/* @__PURE__ */ae(Ue,{parentId:P,slot:W}),s=o?/* @__PURE__ */ae(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ae(Qe.Provider,{value:e??Te,children:s})}var lt=G(void 0),it=G(void 0);function st(e,t,n,o){const r=$(e,t,n);return!!r&&(F(r.node,t).length>0||!1===o.whole)}var at=G(void 0),ct="data-es-chrome",ut=G(void 0);function dt(e){const t=e?.closest?.(`[${ct}]`)??null,n=t?.getAttribute(ct);return t&&n?{id:n,element:t}:null}function pt({element:e,clip:t=!1}){const n=ee(null),o=mt(n,e?()=>e:null,e),r=_(St);/* @__PURE__ */
|
|
6
|
+
return ae("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?kt(o,r):void 0}:{display:"none"}})}var ft={"--es-words-clear":`${A}px`};function ht({element:e,words:t=!1,clip:n=!1}){const o=ee(null),r=mt(o,e?()=>e:null,e),l=_(St);/* @__PURE__ */
|
|
7
|
+
return ae("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?kt(r,l):void 0,...ft}:{display:"none"}})}function mt(e,t,n){return yt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var gt=[];function yt(e,t,n){const[o,r]=ne(gt),l=ee(t);return l.current=t,Fe(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(gt);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=M(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:gt;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),n.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}var vt=A+2,wt=vt+2,bt=1;function kt(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-vt&&t.left<n+vt&&l>e.top-vt&&t.top<o+vt))return null;const i=Math.max(t.left<=e.left&&r>e.left?Math.min(t.left,e.left-bt):t.left,e.left-wt)-e.left,s=Math.max(t.top<=e.top&&l>e.top?Math.min(t.top,e.top-bt):t.top,e.top-wt)-e.top,a=Math.min(r>=n&&t.left<n?Math.max(r,n+bt):r,n+wt)-e.left,c=Math.min(l>=o&&t.top<o?Math.max(l,o+bt):l,o+wt)-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${-wt} ${-wt}h${e.width+2*wt}v${e.height+2*wt}h${-(e.width+2*wt)}z`}${l.map(e=>`M${e.x} ${e.y}h${e.w}v${e.h}h${-e.w}z`).join("")}")`}var St=G([]);function xt({children:e}){const t=ee(null),n=_(ut),o=yt(t,n?e=>Array.from(e.querySelectorAll(`[${ct}]`)):null,n?1:0);/* @__PURE__ */
|
|
8
|
+
return ce("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
|
+
/* @__PURE__ */ae("span",{ref:t,hidden:!0,"aria-hidden":"true"}),
|
|
10
|
+
/* @__PURE__ */ae(St.Provider,{value:o,children:e})]})}function Ct({id:e,kind:t,overlay:n}){const o=ee(null),r=_(it),l=null!==e&&!0===r?.(e),i=yt(o,e?t=>O(t,`[${Ve}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=_(St),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:kt(e,c)}),p=/* @__PURE__ */ce(ue,{children:[
|
|
11
|
+
/* @__PURE__ */ae("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ae("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ae(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Ve}]`)).find(o=>o.getAttribute(Ve)===n&&t(o)?.wrapper===e)??null}function It(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 At({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",v),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=ee(null),[m,g]=ne(!1),[y,b]=ne(null),k=m||null!==y,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},x=()=>{g(!1),b(null),e.resume()};se(()=>{r.current={escape:()=>!!k&&(x(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),se(()=>()=>{r.current=null},[r]);const C=ee(x);C.current=x,J(()=>{if(m)return pe(e=>{const t=c.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(C.current(),!0)},()=>c.current?.querySelector(".es-copy-colors"))},[m]),J(()=>{const n=c.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;g(!1),b(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[k,e,t]),se(()=>{const e=c.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?D(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},f=o.getBoundingClientRect(),h=s?D(s,{left:f.left,top:f.top,width:f.width,height:f.height}):{left:f.left,top:f.top,width:f.width,height:f.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,h.top-6,m.top),bottom:Math.max(a.top+a.height,h.top+h.height+6,m.bottom)},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=a?{run:f(i.color,a),open:m,onToggle:()=>{b(null),m?x():(e.hold(),g(!0))}}:void 0;/* @__PURE__ */
|
|
12
|
+
return ae(fe,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?D(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__ */ae("div",{ref:c,children:/* @__PURE__ */ae(he,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:E,linkOpen:null!==y,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */ce(ue,{children:[m&&a?/* @__PURE__ */ae(h,{colors:a,current:i.color,words:l.colors??v.colors,onPick:t=>e.color(t)}):null,y?
|
|
13
|
+
/* @__PURE__ */ae(me,{className:"es-copy-link es-copy-pop",value:y.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==y.href?()=>{b(null),e.link(null)}:void 0,onCancel:x}):null]})})})})}function Dt({element:e,which:t}){const n=ee(null),o=mt(n,()=>e(),t),r=_(St);/* @__PURE__ */
|
|
14
|
+
return ae("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:kt(o,r),...ft}:{display:"none"}})}function Mt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:S,overlay:C,children:E,typing:I,passThrough:A}){const D=je(),M=_(lt),O=A??M,P=_($e),j=w("canvas",n),z=v??P,[R,L]=ne(void 0),B=ze(e=>"node"===e.selection?.kind?e.selection.id:null),[N,V]=ne(null),[K,T]=ne(null),Z=_(at),H=_(ut),[W,q]=ne(null),[,Q]=oe(e=>e+1,0),[,Y]=oe(e=>e+1,0),U=e=>{Z?.select(e),Y()},[X,G]=ne(null),te=ee(null),re=ee(null),[,le]=ne(0),ie=ee(I);ie.current=I;const se=ee(null),ue=ee(null),de=()=>{if(!B)return null;const e=ie.current?.atSelection?.()?.element()??null;if(!e)return null;const t=ue.current?.ownerDocument;if(Z){const n=Z.selected()&&t?Z.selectedPart?.(t)??null:null;return n&&x(n.element,e)?n.element:null}const n=$(D.getState().appState.data,D.config,B);return n&&0===F(n.node,D.config).length?e:null},pe=ze(e=>e.appState.data),fe=Z?.selected()??null;J(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=B&&!X&&ie.current?.atSelection?.()?B:null,o=n?de():null;e.dispatchEvent(new t(b,{detail:o?{id:n,words:o}:{id:n}}))},[B,X,pe,fe]);const he=e=>{const t=ue.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},me=(e,t)=>{te.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=D.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:It(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>se.current?.escape()??!1,onLinkKey:()=>se.current?.link()??!1,end:e=>{r.close(),te.current?.element===l&&(te.current=null),G(null),he(!1),ie.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${Ve}]`)?.getAttribute(Ve);return s&&D.select(s),te.current={s:i,element:l,target:e},G(()=>l),V(null),he(!0),ie.current?.onChange?.({typing:!0,element:n}),!0},ge=(e,n)=>{const o=e.key;if(!o||!ie.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${Ve}]`),i=l?.getAttribute(Ve);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=ie.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=ie.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};J(()=>()=>te.current?.s.stop("stop"),[]);const ye=e=>{const t=te.current?.element();return Boolean(t&&t.contains(e))},ve=(e,t)=>st(D.getState().appState.data,D.config,e,t),we=e=>{const t=e.closest?.(`[${Ve}]`)?.getAttribute(Ve);if(!t)return;const n=D.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=Z?.partAt(e,t)??null;if(r){const e=a(n.appState.data,D.config,t,r.id,o,Z?.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}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(te.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=ke(),o=void 0===n?ie.current?.atSelection?.():n;o&&me(o,null)&&e.preventDefault()},ke=()=>{const t=ie.current,n=re.current;if(!t?.onCopyText||!n?.copy||n.node!==B)return;const o=ue.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(`[${Ve}]`);if(!n||n.getAttribute(Ve)!==t.getAttribute(Ve))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},Se=(e,n)=>{if(!ie.current?.onCopyText)return null;const o=t(e);return o&&Et(o.wrapper,n)?o.copy:null},xe=ue.current?.ownerDocument??null,Ce=Z?.selected()&&xe&&B?Z.selectedPart?.(xe)??null:null,Ee=Ce&&B&&ve(B,Ce)?Ce.element:null,Ie=H?.selected()??null,Ae=Ie&&xe?Array.from(xe.querySelectorAll(`[${ct}]`)).find(e=>e.getAttribute(ct)===Ie)??null:null,De=X?null:de(),Oe=/* @__PURE__ */ce("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),te.current){if(ye(t))return;te.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?dt(t):null;if(H&&o)return H.select(o.id),q(null),void Q();const r=we(t);if(re.current=void 0!==r?{node:r.node,copy:Se(t,r.node)}:null,void 0!==r)return D.select(r.node),void(Z&&(r.part?.id??null)!==Z.selected()&&U(r.part?.id??null));t.hasAttribute?.(Ke)||(D.select(null),Z?.selected()&&U(null))},onDoubleClick:e=>{const t=ie.current;if(!t||ye(e.target))return;const n=t.at(e.target);n&&me(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>be(e),onMouseOver:e=>{if(te.current)return;const t=H?dt(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==N&&V(null),void(null!==K&&T(null));const n=we(e.target),o=!!n?.part&&ve(n.node,n.part),r=n?.part&&o&&n.part.id!==Z?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==N&&V(l),r?.id===K?.id&&r?.element===K?.element||T(r)},onMouseLeave:()=>{V(null),T(null),q(null)},children:[
|
|
15
|
+
/* @__PURE__ */ae(qe.Provider,{value:N,children:/* @__PURE__ */ae(rt,{metadata:i})}),
|
|
16
|
+
/* @__PURE__ */ce(xt,{children:[
|
|
17
|
+
/* @__PURE__ */ae(Ct,{id:!X&&N&&N!==B?N:null,kind:"hover",overlay:C}),Z?/* @__PURE__ */ae(pt,{clip:!0,element:X||!K||K.id===Z.selected()?null:K.element}):null,De||Ee?/* @__PURE__ */ae(ht,{clip:!0,element:X?null:De??Ee,words:null!==De}):null,H?/* @__PURE__ */ae(pt,{element:X||!W||W.element===Ae?null:W.element}):null,Ae?/* @__PURE__ */ae(ht,{element:X?null:Ae}):null,
|
|
18
|
+
/* @__PURE__ */ae(Ct,{id:X||Ee||De||Ae?null:B,kind:"selected",overlay:C}),X?/* @__PURE__ */ae(Dt,{element:()=>{const e=X?.()??null;return e?Ce&&x(Ce.element,e)?Ce.element:e:null},which:Ce?.element??X}):null]}),E]}),Pe=S?/* @__PURE__ */ae(S,{document:R,children:Oe}):Oe;J(()=>{if(R&&z)return Me(R,D)},[R,z,D]),J(()=>{if(!R)return;const e=e=>{if("Enter"===e.key)return void be(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=D.getState();if("node"!==n.selection?.kind)return;if(Z?.selected())return void U(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,Z]);/* @__PURE__ */
|
|
19
|
+
return ce("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":X?"":void 0,children:[X&&te.current?.target.toolbar?/* @__PURE__ */ae(At,{s:te.current.s,element:te.current.element,toolbar:te.current.target.toolbar,label:j.textTools,keys:se}):null,o?/* @__PURE__ */ae(We,{mirrorStyles:u,onDocument:e=>{L(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:Pe}):/* @__PURE__ */ae("div",{id:"preview-frame","data-easel-entry":"",children:Pe})]})}function Ot(e={}){const t=je(),n=ze(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}var $t=/* @__PURE__ */new WeakMap,Pt=[];function jt(e){let t=$t.get(e);return t||(t={nodes:/* @__PURE__ */new Map,shown:/* @__PURE__ */new Map,listeners:/* @__PURE__ */new Set,lateListeners:/* @__PURE__ */new Set,settled:[]},$t.set(e,t)),t}function zt(e,t){const n=e.nodes.get(t),o=n?[...n.running,...n.next]:Pt;o.length?e.shown.set(t,o):e.shown.delete(t),e.listeners.forEach(e=>e())}function Rt(e,t,n,o){const r=jt(e),l=r.nodes.get(t);l?l.next=[...l.next,n]:r.nodes.set(t,{running:Pt,next:[n]}),zt(r,t),l||Promise.resolve().then(()=>Lt(r,t,o))}function Lt(e,t,n){const o=e.nodes.get(t);if(!o)return;if(!o.next.length)return e.nodes.delete(t),zt(e,t),void(e.nodes.size||e.settled.splice(0).forEach(e=>e()));const r=o.next;o.running=r,o.next=Pt;let l=!0;const i=()=>{l=!1,clearTimeout(a),o.running=Pt,zt(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)}Lt(e,t,n)},6e4);n.run(r,{live:()=>l,landing:i}).catch(e=>{if(!s)throw e}).finally(()=>{s||(l&&i(),Lt(e,t,n))})}function Bt(e){const t=jt(e);return t.nodes.size?new Promise(e=>t.settled.push(e)):Promise.resolve()}function Nt(){const e=je(),t=ee([]),n=ee(!1),[o,r]=ne(!1),[,l]=oe(e=>e+1,0);J(()=>{t.current.splice(0).forEach(e=>e())});return{run:re(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 Vt(e){const t=Nt(),n=ee(e);return n.current=e,{...e,busy:!0===e.busy||t.waiting,onPress:()=>t.run(()=>n.current.onPress())}}function Kt(e,t){const{lateListeners:n}=jt(e);return n.add(t),()=>{n.delete(t)}}var Tt=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype;function Zt(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=Tt(t)?e.indexOf(t):-1;return l>=0?n[l]:o?Zt(e[r],t,n[r]):t})}if(Tt(e)&&Tt(t)&&Tt(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]=Zt(e[r],t[r],n[r]);return o}return t}function Ft(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 Ht(e,t){if(!e.length)return t;try{return{...t,...Ft(e,t)}}catch{return t}}function Wt(){return Xt(ze(e=>e.selectedItem))}function qt(){const e=_(Qt);try{return function(e){const t=ze(e=>e.selectedItem);return Xt("root"===e?null:t)}(e)}catch{return null}}var Qt=G("selected");function Yt({children:e}){return le(Qt.Provider,{value:"root"},e)}function Ut(){return Xt(null)}function Xt(e){const t=je(),n=ze(e=>e.config),r=t.resolveCache,l=ze(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=ie(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?$(u.appState.data,n,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=o({id:i,node:a,block:c,parent:f,appState:u.appState}),m=ze(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=re(e=>{Rt(t,i,e,{landWithoutAnswer:e=>{const n=t.getState();if("root"===i){const o=n.appState.data.root.props??{},r=Ft(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=Ft(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=Ft(e,o.props);if(!r)return;const u={...o,props:{...o.props,...r}},{node:d}=await q(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=Ft(e,u);if(!d)return;const{node:p}=await q({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=re(e=>{const{listeners:n}=jt(t);return n.add(e),()=>{n.delete(e)}},[t]),v=re(()=>jt(t).shown.get(i)??Pt,[t,i]),w=te(y,v,v),b=ie(()=>Ht(w,a.props),[w,a.props]),k=ee({id:i,values:b});k.current={id:i,values:b};const S=re((e,n)=>{const o=t.getState(),r=("root"===i?o.appState.data.root.props:o.getItemById(i)?.props)??{},l=Ht(jt(t).shown.get(i)??Pt,r),s=k.current,a=(s.id===i?s.values:l)[e];H(n,a)&&!H(l[e],a)?g({[e]:n}):g(t=>({[e]:Zt(a,n,t[e])}))},[t,i,g]);return{id:i,node:a,fields:h,values:b,readOnly:m,onChange:S,onChangeMany:g}}export{ct as CHROME_ATTR,ut as CanvasChromeContext,We as CanvasFrame,at as CanvasPartsContext,lt as CanvasPassThroughContext,it as CanvasSharedContext,Ee as DEFAULT_UI,Mt as EaselCanvas,Pe as EaselProvider,rt as EditDocument,Yt as RootHostScope,Me as bindUndoKeys,De as createEasel,Re as createUseEasel,st as partHasOwnBox,ge as recordsByDefault,Se as reduce,Kt as subscribeLateWrites,we as uiView,ze as useEasel,je as useEaselApi,Ot as useEaselNodeOps,Ut as useRootFields,Wt as useSelectedFields,qt as useSelectedHost,Vt as useSettledAction,Nt as useSettledPress,be as validSelection,Bt as writesSettled};
|
|
@@ -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-ITRBDUAM.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};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-GDO4QJ4G.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as r}from"./chunk-N7E6264U.js";import{sharedSectionsOf as l}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SBVIW3KJ.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as p,useScreenPinned as d}from"./chunk-
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */
|
|
4
|
-
/* @__PURE__ */
|
|
5
|
-
return
|
|
6
|
-
/* @__PURE__ */
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-GDO4QJ4G.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as r}from"./chunk-N7E6264U.js";import{sharedSectionsOf as l}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SBVIW3KJ.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as p,useScreenPinned as d}from"./chunk-CLJ3KXYF.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-C4TJN6GR.js";import{useEasel as u}from"./chunk-ITRBDUAM.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SQTVXE5D.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as C}from"react";import{SharedIcon as w,AddIcon as I}from"efficient-shell/icons/efficient";import{ContextMenu as O,toast as T,Dialog as $,Button as E}from"efficient-shell/ui";import{jsx as F,jsxs as x,Fragment as G}from"react/jsx-runtime";function M({name:e,pages:t,onDelete:n,onCancel:o}){const r=h("screen",f).shared,[l,i]=b(!1),s=C(null);/* @__PURE__ */
|
|
2
|
+
return F($,{open:!0,role:"alertdialog",size:"sm",title:r.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */x(G,{children:[
|
|
3
|
+
/* @__PURE__ */F(E,{ref:s,variant:"secondary",onClick:o,children:r.cancel}),
|
|
4
|
+
/* @__PURE__ */F(E,{variant:"danger",loading:l,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:r.deleteShared})]}),children:r.deleteMessage({count:t})})}var S=e=>`section:${e}`,B=e=>`block:${e}`,D=e=>`template:${e}`,J=e=>`shared:${e}`,Q=e=>`preset:${e}`;function W({at:C,placeBlocks:$,canTake:E,onPick:W,itemFor:A,session:H,siteWide:L,onClose:N,onHide:R,readOnly:U}){const z=u(e=>e.config),V=a(),{labelAtLevel:Y,categoryLabel:X,firstSection:K,Icon:P,Thumbnail:_}=V,{blockIsOffered:Z,canAddTo:q}=p(),ee=h("screen",f).add,te=h("drag",g).add,ne=m(),[oe,re]=b([]);v(()=>{let e=!1;const t=e=>Z(e,ne);return r(ne).list().then(n=>{if(e)return;const r=z.components;re(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,ne]);const le=d().shared,ie=h("screen",f).shared,[se,ce]=b([]),[ae,pe]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>Z(e,ne);return l(ne).list().then(n=>{if(e)return;const r=z.components;ce(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,ne,ae]);const[de,me]=b(null),[fe,ue]=b(null),ye=j(()=>e(z,V),[z]),he=e=>Y(e,"section",z.components[e]?.label??e),ke=e=>({type:e.preset?Q(e.preset.key):S(e.type),label:e.name,cover:/* @__PURE__ */F(_,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:ee.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ge=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=oe.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=se.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}if("preset"===n){const e=ye.find(e=>e.preset?.key===o)?.preset;return e?{kind:"preset",preset:e}:null}return null},be=e=>/* @__PURE__ */F("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */F(P,{type:e,size:26})}),ve=j(()=>{const e=t(ye,K),o=/* @__PURE__ */new Map,r=e=>{e.retired||o.has(e.type)||!Z(e.type,ne)||o.set(e.type,e)};for(const t of e?[e]:ye.filter(e=>!e.preset)){const e=q(t.type)?.choices??[];e.forEach(r),e.forEach(e=>q(e.type,1)?.choices?.forEach(r))}$?.forEach(r);const l=new Set(ye.filter(e=>!e.preset).map(e=>e.type)),i=[...o.values()].filter(e=>!l.has(e.type)),s=e=>({type:B(e.type),label:e.label,cover:be(e.type),title:ee.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>!e.preset&&o.has(e.type)?{...ke(e),cover:be(e.type)}:ke(e),p=[];se.length>0&&p.push({key:"shared",title:ie.group,tiles:se.map(e=>({type:J(e.id),label:e.title,cover:/* @__PURE__ */F(_,{type:e.node.type}),mark:/* @__PURE__ */F(w,{size:12}),title:ie.onPages({count:e.used_on.length}),keywords:[he(e.node.type),e.node.type]}))}),oe.length>0&&p.push({key:"templates",title:ee.templates,tiles:oe.map(e=>({type:D(e.id),label:e.name,cover:/* @__PURE__ */F(_,{type:e.node.type}),keywords:[he(e.node.type),e.node.type]}))});const d=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(z.categories??{})){const o=ye.filter(e=>e.cat===t);if(0===o.length)continue;const r=e&&o.some(t=>t.type===e.type)?e:null,l=(r?[r,...o.filter(e=>e.type!==r.type)]:o).map(a);r&&!m&&(l.splice(1,0,...d.map(s)),m=!0),p.push({key:`category:${t}`,title:n(z,t,X),tiles:l})}const f=p.find(e=>e.key?.startsWith("category:"));if(!m&&f&&d.length>0&&(f.tiles=[...f.tiles,...d.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!E)return p;const u=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ge(e.type),n=t?E(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[oe,se,ie,ye,z,ee,E,$,ne]);/* @__PURE__ */
|
|
5
|
+
return x(G,{children:[
|
|
6
|
+
/* @__PURE__ */F(i,{icon:/* @__PURE__ */F(I,{size:15}),title:ee.title,context:ee.contextAll,actions:/* @__PURE__ */F(s,{label:ee.done,description:ee.doneDescription,onClick:N}),onHide:R}),
|
|
7
|
+
/* @__PURE__ */x("div",{className:"sf-addside sf-scroll",children:[
|
|
8
|
+
/* @__PURE__ */F(k,{groups:ve,session:H,itemFor:e=>A(ge(e)??{kind:"section",type:e}),onInsert:W?e=>{const t=ge(e);t&&W(t)}:void 0,onTileMenu:(e,t)=>{const n=ge(e);return"shared"===n?.kind&&!U&&(me({section:n.section,...t}),!0)},at:C,hint:ee.hint,searchLabel:ee.search,readOnly:U,words:te}),L??null]}),de?/* @__PURE__ */F(O,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>me(null),"aria-label":de.section.title,items:y([{label:ie.deleteShared,danger:!0,onClick:()=>{ue(de.section),me(null)}}])}):null,fe?/* @__PURE__ */F(M,{name:fe.title,pages:fe.used_on.length,onDelete:()=>(async e=>{try{await l(ne).remove(e.id)}catch{return void T.error(ie.deleteFailed)}ue(null),le?.removed?.(e),ce(t=>t.filter(t=>t.id!==e.id)),pe(e=>e+1)})(fe),onCancel:()=>ue(null)}):null]})}export{W as AddSidePanel,B as blockKey,Q as presetKey,S as sectionKey,J as sharedKey,D as templateKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenDocument as n}from"./chunk-
|
|
1
|
+
import{useScreenDocument as n}from"./chunk-CPIWSFGR.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C4TJN6GR.js";import{EditNotice as r}from"./chunk-VBEVZZTV.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
|
|
@@ -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-6FOXOYXW.js";import{ScreenChrome as e}from"./chunk-XE5LSM3G.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-CPIWSFGR.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C4TJN6GR.js";import{documentPermissions as s}from"./chunk-YYD257TD.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=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 C=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:()=>{
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(
|
|
5
|
+
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
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]),D=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:D.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:G,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:D.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:D.waitingForAuthorization})}export{G as DocumentScreen,j as ScreenMount};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-DTVOOBD4.js";import{SELECTION_MODE as e}from"./chunk-CLJ3KXYF.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-ITRBDUAM.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),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=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(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{DESIGN_GROUP_KEY as o,BUCKET_KEY as n}from"./chunk-3QB2ZQXK.js";import{withoutDeviceGate as e}from"./chunk-
|
|
1
|
+
import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{DESIGN_GROUP_KEY as o,BUCKET_KEY as n}from"./chunk-3QB2ZQXK.js";import{withoutDeviceGate as e}from"./chunk-BLE3U2GS.js";import{STYLE_KIND as r,fieldKind as s,copyStyle as c,heldStyle as i,planPaste as p,pasteMessage as u}from"./chunk-CWELHADJ.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as a,MEDIA_FIELD_MARKER as l,TEXT_FIELD_MARKER as m,LINK_FIELD_MARKER as h}from"./chunk-ANPOR6EY.js";import{deviceMetaOf as y}from"./chunk-YCSZAP7T.js";var j=/* @__PURE__ */new Set([o.Size,o.Design,o.Layout,o.Position]),w=new Set(Object.values(o)),S=new Set(Object.values(n)),b=new Set(f),k=/* @__PURE__ */new Set(["focal","imageFocal"]),g=[l,m,h];function v(t){return`site:${t??""}`}function A(t){if(!t||"object"!=typeof t)return null;const o=t,n=e(t)??t,c=o[r]??n[r];if("string"==typeof c)return c;const i=o.options??n.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return s(n)}function L(t){const o=t,n=e(t);return g.some(t=>t in o||n&&t in n)}function O(o,e){const r=t(o,e)??{},s=[];let c=!0,i=!1;for(const[t,o]of Object.entries(r))S.has(t)?(c=t===n.Design,i=!1):w.has(t)?c&&(i=j.has(t)):i&&o&&"object"==typeof o&&!t.startsWith("_")&&(a(o)||b.has(t)||k.has(t)||L(o)||"slot"!==o.type&&s.push({path:[t],kind:A(o),counted:"mobile"!==y(o)?.tier}));return s}function d(t,o,n,e,r){c({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function D(t,o,n,e,r,s){const c=i(n);if(!c)return null;const f=p(c,{type:e.type,rows:t(o,e),props:e.props});return{...f,message:u(f,c.sourceLabel,r,s)}}function E(t,o,n,e){d(O,t,o,n,e)}function P(t,o,n,e,r){return D(O,t,o,n,e,r)}var X={scope:t=>v(t.siteId),rows:(t,o)=>O(t,o),copy:(t,o,n,e)=>E(e,t,o,n),plan:(t,o,n,e)=>P(e,t,o,n)};function B(t,o){if(!t&&!o)return X;const n=t?.rows,e=n?(t,o)=>n(t,o):O;return{scope:t?.scope??X.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>d(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>D(e,s,t,n,r,o))}}export{E as copyNodeStyle,O as nodeStyleRows,P as planNodePaste,A as shopFieldKind,v as siteStyleScope,B as styleClipboardOf};
|