efficient-easel 8.2.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.d.ts +10 -1
- package/dist/canvas/index.js +1 -1
- package/dist/chunk-7CIFWFP2.js +57 -0
- package/dist/{chunk-OHMYY3FX.js → chunk-CWTAS5R6.js} +5 -5
- package/dist/{chunk-R2G64ZNC.js → chunk-D6N77AOS.js} +1 -1
- package/dist/{chunk-IZPIXBQQ.js → chunk-DQZYXC3V.js} +1 -1
- package/dist/{chunk-SSORUDHE.js → chunk-FCLW4LEN.js} +7 -7
- package/dist/{chunk-WMQN4PHH.js → chunk-HA33IXEU.js} +1 -1
- package/dist/{chunk-JIKPYPI3.js → chunk-IEKQTWQG.js} +1 -1
- package/dist/chunk-ILXP5VX5.js +1 -0
- package/dist/chunk-K5744MTM.js +11 -0
- package/dist/chunk-KIA6EKAM.js +5 -0
- package/dist/{chunk-5HG62L3A.js → chunk-NOD4ATKF.js} +1 -1
- package/dist/{chunk-YIZ4YXPY.js → chunk-OWW44DVK.js} +1 -1
- package/dist/{chunk-PEDDDWSG.js → chunk-UCLVWF5E.js} +11 -11
- package/dist/{chunk-JSO6F7IY.js → chunk-VF6TCI62.js} +1 -1
- package/dist/{chunk-LGN4F6HL.js → chunk-ZG5T7RSV.js} +3 -3
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.d.ts +5 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +15 -15
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +10 -0
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-66WCYXIN.js +0 -5
- package/dist/chunk-AWJUYMX7.js +0 -1
- package/dist/chunk-E63CSJUL.js +0 -11
- package/dist/chunk-Q6DCUUTQ.js +0 -57
package/dist/canvas/index.d.ts
CHANGED
|
@@ -31,6 +31,15 @@ declare const BLOCK_ATTRIBUTE = "data-puck-component";
|
|
|
31
31
|
* target itself) carrying `attribute`. `null` on bare canvas.
|
|
32
32
|
*/
|
|
33
33
|
declare function nodeIdAt(target: EventTarget | null, attribute?: string): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The box a block DREW, in its frame's viewport (8.2.0). Most blocks draw inside
|
|
36
|
+
* the canvas's wrapper, and the wrapper's own box is the answer. A block whose
|
|
37
|
+
* drawing leaves the wrapper's flow (the website's header bar is
|
|
38
|
+
* `position: fixed`) leaves the wrapper with no height; then the union of what
|
|
39
|
+
* it drew, its child elements, is the box. Never null: a wrapper with nothing
|
|
40
|
+
* drawn is its own empty box.
|
|
41
|
+
*/
|
|
42
|
+
declare function drawnBox(el: Element): Box;
|
|
34
43
|
interface Box {
|
|
35
44
|
left: number;
|
|
36
45
|
top: number;
|
|
@@ -203,4 +212,4 @@ declare function useCanvasLayout(canvas: CanvasTarget | null, { settle }?: {
|
|
|
203
212
|
settle?: readonly number[];
|
|
204
213
|
}): number;
|
|
205
214
|
|
|
206
|
-
export { BLOCK_ATTRIBUTE, type Box, CANVAS_TYPING_EVENT, type CanvasFit, CanvasTarget, type CanvasTypingEvent, WatchOptions, clientPointToLayer, elementScale, fitCanvas, framePointToHost, frameRectToHost, frameRectToLayer, frameScale, isTypingTarget, nodeIdAt, removeCanvasStyle, setCanvasNonce, upsertCanvasStyle, useCanvasEvent, useCanvasFrame, useCanvasLayout, useCanvasStyle };
|
|
215
|
+
export { BLOCK_ATTRIBUTE, type Box, CANVAS_TYPING_EVENT, type CanvasFit, CanvasTarget, type CanvasTypingEvent, WatchOptions, clientPointToLayer, drawnBox, elementScale, fitCanvas, framePointToHost, frameRectToHost, frameRectToLayer, frameScale, isTypingTarget, nodeIdAt, removeCanvasStyle, setCanvasNonce, upsertCanvasStyle, useCanvasEvent, useCanvasFrame, useCanvasLayout, useCanvasStyle };
|
package/dist/canvas/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{BLOCK_ATTRIBUTE,BLOCK_SELECTOR,CANVAS_SELECTOR,CANVAS_TYPING_EVENT,LIST_SELECTOR,clientPointToLayer,elementScale,fitCanvas,framePointToHost,frameRectToHost,frameRectToLayer,frameScale,isFrameReady,isTypingTarget,nodeIdAt,removeCanvasStyle,setCanvasNonce,upsertCanvasStyle,useCanvasEvent,useCanvasFrame,useCanvasLayout,useCanvasStyle,watchCanvasFrame}from"../chunk-
|
|
1
|
+
export{BLOCK_ATTRIBUTE,BLOCK_SELECTOR,CANVAS_SELECTOR,CANVAS_TYPING_EVENT,LIST_SELECTOR,clientPointToLayer,drawnBox,elementScale,fitCanvas,framePointToHost,frameRectToHost,frameRectToLayer,frameScale,isFrameReady,isTypingTarget,nodeIdAt,removeCanvasStyle,setCanvasNonce,upsertCanvasStyle,useCanvasEvent,useCanvasFrame,useCanvasLayout,useCanvasStyle,watchCanvasFrame}from"../chunk-ILXP5VX5.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-BRDCD4LK.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-OWW44DVK.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as k,DEFAULT_PANEL_W as S,clampPanelWidth as v}from"./chunk-DPKWJTNX.js";import{usePartBridge as b}from"./chunk-HA33IXEU.js";import{useSectionOps as x}from"./chunk-VF6TCI62.js";import{useNodeClipboard as w,useNodeContextMenu as z}from"./chunk-D6N77AOS.js";import{PageEditGuardNotices as C}from"./chunk-NCQSBU3O.js";import{ScreenSaveIcon as B,ScreenMainButton as O}from"./chunk-HDUAODXJ.js";import{useBrowserOffline as I}from"./chunk-RKTF5XLP.js";import{useScreenDocument as N}from"./chunk-THZ46DC5.js";import{requestMediaPick as A}from"./chunk-KG7RJWOK.js";import{heldStyle as $,styleShortcut as T}from"./chunk-V7U33NF2.js";import{AddChildRow as P}from"./chunk-5545A3PC.js";import{AddSidePanel as M}from"./chunk-KIA6EKAM.js";import{SidePanelHead as j,PanelShowStrip as L}from"./chunk-XTJCKV6Z.js";import{useEaselSession as E}from"./chunk-O7Q4DDJT.js";import{MediaSidePanel as R}from"./chunk-NOD4ATKF.js";import{useScreenSaveSwitch as V,useScreenNodeKeys as F,useScreenPinned as D,useScreenDocumentLabel as H,useScreenCanvasFrame as W,useScreenInspectorPanel as U,useScreenDevices as J,useScreenPickFollowsSelection as G,useScreenLeftView as K,useScreenAdd as X,SELECTION_MODE as Y,sameInspectorMode as q,useScreenBridges as _,useScreenBlockRules as Q,useScreenBlockLook as Z,useScreenStorageNamespace as ee,useScreenNotify as ne,useScreenCanvasHead as te,isSlotMode as oe,useScreenStyleClipboard as re,useScreenDocumentPass as ie,useScreenCanvasDrag as le,ScreenCanvasTargetProvider as se,isPinnedFirst as de,isPinnedLast as ce,screenSlotsOf as ae}from"./chunk-CWTAS5R6.js";import{ROOT_ZONE as pe,blockNodeActions as ue,TREE_MAX_DEPTH as fe,childSlotsOf as he,slotFieldsOf as me,slotChildrenIn as ge,nestsInTree as ye,newNodeId as ke}from"./chunk-PLVEGYK6.js";import{useMediaPanel as Se,usePanelPick as ve,useCancelPanelPick as be}from"./chunk-R6WTQWAC.js";import{useEaselHost as xe,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ze}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as Ce}from"./chunk-JTUUIVBZ.js";import{useEasel as Be,useEaselApi as Oe,CanvasPassThroughContext as Ie}from"./chunk-K5744MTM.js";import{TreeRow as Ne,Subtree as Ae,LayersTree as $e,TreeGroupLabel as Te,TreeRowAction as Pe,TreeSeam as Me}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Le}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ee,useNodeOps as Re,clickPick as Ve}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Fe,MediaIcon as De}from"./chunk-4VJATVVR.js";import{EaselTopBar as He,TopBarRail as We,TopBarCluster as Ue,EaselIconButton as Je,TopBarDivider as Ge,DeviceSwitch as Ke,InspectorIconButton as Xe,PanelResizeHandle as Ye,MAX_PANEL_W as qe,MIN_PANEL_W as _e,panelWidthVars as Qe}from"./chunk-QVUVDBGA.js";import{DEFAULT_NOTICE_WORDS as Ze,DEFAULT_CHROME_WORDS as en}from"./chunk-Y2G7CU6A.js";import{holderOf as nn,nameOrSomeone as tn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as on}from"./chunk-RE4LP46F.js";import{useWords as rn}from"./chunk-MFIRYGHW.js";import{insertSeams as ln,CanvasDragLayer as sn,CanvasInsert as dn}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as cn}from"./chunk-O2NLQBFX.js";import{createDragSession as an,useTreeDrag as pn,gapToMoveIndex as un}from"./chunk-67GNT6PF.js";import{useCanvasFrame as fn,LIST_SELECTOR as hn,BLOCK_SELECTOR as mn,useCanvasEvent as gn,nodeIdAt as yn,frameRectToHost as kn,BLOCK_ATTRIBUTE as Sn,drawnBox as vn}from"./chunk-ILXP5VX5.js";import{zoneKey as bn,ROOT_ID as xn,ROOT_SLOT as wn,parseZoneKey as zn,find as Cn,DataError as Bn}from"./chunk-KRXQM65X.js";import{useRef as On,useMemo as In,useState as Nn,useEffect as An,useCallback as $n,useLayoutEffect as Tn,Fragment as Pn}from"react";import{ColoredBadge as Mn,toast as jn,groupColors as Ln}from"efficient-shell/ui";import{UndoIcon as En,RedoIcon as Rn,RefreshIcon as Vn,TrashIcon as Fn,EyeOffIcon as Dn,EyeIcon as Hn,DuplicateIcon as Wn}from"efficient-shell/icons/efficient";import{jsx as Un,jsxs as Jn,Fragment as Gn}from"react/jsx-runtime";var Kn=/* @__PURE__ */new WeakSet;function Xn(e,n,t){const o=Cn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Yn({canvas:e,tabs:n,onSelect:t}){const o=On(null),[r,i]=Nn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Tn(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=kn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${Sn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?vn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=kn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Un("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Un("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Un(Mn,{colorClass:Ln("info","solid"),size:"sm",children:e.label})},e.id):null})})}function qn({expand:e}){/* @__PURE__ */
|
|
2
|
+
return Un("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Jn(Gn,e?{children:[
|
|
3
|
+
/* @__PURE__ */Un("path",{d:"M8 9l4-4 4 4"}),
|
|
4
|
+
/* @__PURE__ */Un("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
5
|
+
/* @__PURE__ */Un("path",{d:"M8 4l4 4 4-4"}),
|
|
6
|
+
/* @__PURE__ */Un("path",{d:"M8 20l4-4 4 4"}),
|
|
7
|
+
/* @__PURE__ */Un("path",{d:"M5 12h14"})]})})}var _n=`${hn}, ${mn}`;function Qn(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Zn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const hn=xe(),{target:kn,docId:Sn,capabilities:vn,currentSlug:Ln,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=N(),ft=V(),ht=F(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=vn,{appState:kt,dispatch:St,history:vt,selectedItem:bt,getSelectorForId:xt,config:wt}=Be(e=>e),zt=D(),{first:Ct,firstGroup:Bt,lastGroup:Ot,isSectionGroup:It,sectionGroupZone:Nt,panelOf:At}=zt,$t=At(Ct),Tt=e=>de(zt,e),Pt=e=>ce(zt,e),Mt="node"===zt.firstRow,jt=zt.band??null,Lt=rn("screen",Ce),Et=rn("tree",je),Rt=rn("drag",cn),Vt=rn("notice",Ze),Ft=rn("lock",on),Dt=rn("menu",Le),Ht=rn("styleClipboard",ze),Wt=rn("chrome",en),Ut=H()??`/${Ln}`,Jt=W(),Gt=U(),Kt=x({readOnly:pt}),Xt=x({readOnly:pt,foldIntoHistory:!0}),Yt=On(null),qt=Oe(),_t=In(()=>({...Kt,select:e=>{Yt.current=e,Kt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=qt.config;Yt.current=Ee(e,t,n)}Kt.commitDocument(e,n)}}),[Kt,qt]),Qt=kt.ui,Zt=Qt.leftSideBarVisible,eo=Qt.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=J(),[lo,so]=Nn(oo),co=Se(),ao=mt&&null!==co,po=ve(),uo=be();G(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=K(),[go,yo]=Nn(fo);An(()=>{ho(go)},[go]);const[ko,So]=Nn(0),vo=On(null),bo=On(null),xo=fn(bo,{readySelector:_n}),wo=f(bo);h(bo,xo);const zo=I(),Co=nn(ct),Bo={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Co?Vt.editing({name:tn(Co.name,Ft),noun:Lt.noun}):null,conflict:null!=it,notSaving:Lt.bar.notSaving},Oo=()=>{pt||(rt.failed?lt():dt())};m(bo,xo,Oo);const[Io,No]=Nn(!1),Ao=On(!1),$o=On(!1),[To,Po]=Nn(null),Mo=X(),jo=e=>Po(null===e?null:{zone:pe,index:e}),[Lo,Eo]=Nn([]),[Ro,Vo]=Nn(Y),Fo="puck"===Ro.kind,Do=Io&&!To&&Mo.railTarget?Mo.railTarget(kt.data,{node:bt??null,mode:Ro}):null,Ho=Do?{zone:bn(Do),index:Do.index}:null,Wo=To??Ho,Uo=Wo&&Wo.zone===pe?Wo.index:null,Jo=o(Ro,bt?.props.id),[Go,Ko]=Nn(null);An(()=>{Go&&(r(),Ko(null))},[Go]);const Xo=On(xt);Xo.current=xt;const Yo=$n((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Ko(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Xo.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Cr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),qo=On(null);An(()=>{const e=qo.current;qo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Vo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:At(bt?.type)??Y);const t=bt?.props.id,o=Yt.current;if(Yt.current=null,!t)return;const r=xt(t);Yo(String(t),{scroll:!i(o,r??null,pe)})},[bt?.props.id,Yo]);const _o=$n(e=>{Vo(n=>q(n,e)?n:e),St({type:"setUi",ui:{rightSideBarVisible:!0}})},[St]),Qo=On(()=>{});Qo.current=(e,n)=>{const t=e?ki(e.zone??pe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Vo(e=>q(e,n)?e:n),o!==r&&(qo.current={id:o,mode:n},_t.select(e))};const Zo=$n((e,n)=>Qo.current(e,n),[]),er={kind:Ro.kind,mode:Ro,open:_o,show:e=>Vo(e),reveal:()=>{eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Zo},nr=_(er,{data:kt.data,selected:bt??null,zoneOf:e=>xt(e)?.zone,readOnly:Boolean(pt),select:e=>{Vo(Y),_t.select({index:e})},replace:(e,n)=>_t.replaceComponent(pe,e,n),scrollTo:e=>Wi(e)},{device:lo,refreshes:ko},{setView:yo,reveal:()=>{Zt||St({type:"setUi",ui:{leftSideBarVisible:!0}})}}),tr=nr.pinnedSource??!1,or=nr.resolveLeftView?nr.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",rr=Q(),{isLockedBlock:ir,duplicateBlocked:lr,nestDepth:sr,newSectionNode:dr,canAddTo:cr,blockIsOffered:ar}=rr,pr=Z(),{labelAtLevel:ur,Icon:fr,useProducts:hr}=pr,mr=pr.rowName?(e,n,t)=>pr.rowName(e,n,t):void 0,gr=$n(e=>{St({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Yo(e,{scroll:!0})},[St,Yo]),{selectNode:yr,openPartId:kr}=b({mode:Ro,setMode:Vo,onOpenPart:gr}),[Sr,vr]=Nn(null);we(null!==Sr,()=>vr(null));const br=k(ee()),xr=br.collapsed,wr=br.panelWidths,[zr,Cr]=Nn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(xr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
8
|
+
return new Set}});An(()=>{try{window.localStorage.setItem(xr,JSON.stringify([...zr]))}catch{}},[zr]);const[Br,Or]=Nn(()=>{if("undefined"==typeof window)return{...S};try{const e=window.localStorage.getItem(wr);if(!e)return{...S};const n=JSON.parse(e);return{left:v(Number(n.left)||S.left),right:v(Number(n.right)||S.right)}}catch{return{...S}}});An(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(wr,JSON.stringify(Br))}catch{}},300);return()=>clearTimeout(e)},[Br]);const Ir=$n((e,n)=>Or(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Nr=$n(e=>Ir("left",e),[Ir]),Ar=$n(e=>Ir("right",e),[Ir]),$r=e=>zr.has(e),Tr=e=>Cr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Pr=On(!1),Mr=On(null);An(()=>{if(Pr.current&&!Io){const e=Mr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Lt.add.title)}"]`))?.focus(),Mr.current=null}Pr.current=Io},[Io]),An(()=>{if(!Io||!wo)return;const e=e=>{"Escape"===e.key&&Qi()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[Io,wo]),we(Io,()=>Qi()),An(()=>{!Zt&&Io&&(No(!1),Po(null),Ao.current=!1)},[Zt]),An(()=>{if(!po)return $o.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),void($o.current=!1);Io&&(No(!1),Po(null),$o.current=Ao.current,Ao.current=!1),Zt||($o.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),An(()=>{!Zt&&po&&($o.current=!1,uo())},[Zt]),An(()=>{if(!po||!wo)return;const e=e=>{"Escape"===e.key&&uo()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[po,wo]),we(null!==po,()=>uo());const jr=ne(),Lr=(e,n="success",t)=>{if(jr)return void(t?jr(e,"error"===n?"error":"info",t):jr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Er=On(null),[Rr,Vr]=Nn(0),[Fr,Dr]=Nn(0),Hr=te(),Wr=On(null),Ur=e=>Math.max(0,e.clientHeight-(Wr.current?.offsetHeight??0));An(()=>{const e=Er.current;if(!e)return;const n=()=>{Vr(e.clientWidth),Dr(Ur(e))};n();const t=new ResizeObserver(n);return t.observe(e),Wr.current&&t.observe(Wr.current),()=>t.disconnect()},[]),Tn(()=>{Er.current&&(Vr(Er.current.clientWidth),Dr(Ur(Er.current)))},[Br,Zt,eo]);const Jr=lo===ro?Rr>0?Rr:to[ro]:to[lo],Gr=Rr>0?Math.min(Rr/Jr,"shrink"===io?1:2):1,Kr=Jr*Gr,Xr=Rr>0&&Kr>Rr+1,Yr={width:Kr,height:Fr||"100%",flex:"none",position:"relative"},qr={width:Jr,height:Fr?Fr/Gr:"100%",maxHeight:"none",transform:1!==Gr?`scale(${Gr})`:void 0,transformOrigin:"top left"},_r=()=>St({type:"setUi",ui:{leftSideBarVisible:!Zt}}),Qr=()=>St({type:"setUi",ui:{rightSideBarVisible:!eo}}),Zr=e=>{Io&&(No(!1),Po(null),Ao.current=!1,Zt&&go===e)||po&&($o.current=!1,uo(),Zt&&go===e)||(Zt&&go===e?_r():(yo(e),Zt||St({type:"setUi",ui:{leftSideBarVisible:!0}})))},ei=()=>{A(hn,{accept:"image/*",title:Wt.mediaLibrary})},ni=()=>{Vo(Y),_t.select(null),u()},ti=()=>{Vo($t??Y),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}})},oi=kt.data.content??[],ri=()=>{const e=oi.findIndex(Tt),n=oi.findIndex(Pt);return{floor:e>=0?e+1:0,cap:n>=0?n:oi.length}},ii=wt,li=rr.stripCopy,si=n=>e(n,li),di=w(),ci=Re({data:kt.data,config:ii,readOnly:Boolean(pt),clipboard:di,strip:li?e=>li(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==xn||e.slot!==wn)return{min:0,max:n-1};const{floor:t,cap:o}=ri();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Vo(Y);const t=void 0===n||"node"===n?.kind?n:null;_t.commitDocument(e,t)}}),ai=e=>{const n=Cn(kt.data,wt,e);if(!n)return!1;const t=bn(n.place),o=n.node,r=t===pe?mi(o):Ni(o);return!!ci.remove(e)&&(Lr(Lt.deleted({name:r}),"success",{duration:8e3,action:{label:Lt.bar.undo,onClick:()=>{ci.restore(n.node,n.place)}}}),!0)},pi={...ci,remove:ai},ui=e=>ur(e,"block",wt.components[e]?.label??e),fi=$n(e=>wt.components[e]?.defaultProps??{},[wt]),hi=e=>ur(e,"section",ui(e)),mi=e=>l({type:e.type,props:e.props??{}},hi(e.type),mr),{nodeAddresses:gi,zoneItems:yi}=In(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=fe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of he(wt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(oi,pe,0),{nodeAddresses:e,zoneItems:n}},[oi,wt]),ki=$n(e=>yi.get(e)??[],[yi]),Si=e=>{const n=gi.get(e);return n?ki(n.zone)[n.index]:void 0},vi=e=>ae(rr,wt,e),bi=e=>{if(!rr.slotsOf||e===pe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Si(e.slice(0,n));if(!t)return null;const o=vi(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},xi=(()=>{if(!oe(Ro))return null;const e=`${Ro.nodeId}:${Ro.slot}`;return bi(e)?.slot.panel===Ro.kind?e:null})(),wi=On(null);An(()=>{const e=wi.current;if(wi.current=null,!xi||!oe(Ro))return;const n=Ro.nodeId;Yo(n,{scroll:e!==xi}),Cr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ro]);const zi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=gi.get(e);n&&(n.zone===pe?Ui(n.index):vl(n.zone,n.index,e,Si(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&xi!==i&&(wi.current=i),Zo(null,r),eo||St({type:"setUi",ui:{rightSideBarVisible:!0}}),Wi(o)},Ci=(e,n,t)=>{const o=`${e}:${n}`;if(Cr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;xi!==o&&(wi.current=o);Zo(null,{kind:t,nodeId:e,slot:n})},Bi=(e,n,t)=>{if(pt||!rr.moveSlot)return;const o=Si(e),r=o?vi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Zn,index:n},s=un(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=rr.moveSlot(e,n,s);"string"==typeof d&&Ci(e,d,i.panel)},Oi=hr(),Ii=In(()=>{const e=/* @__PURE__ */new Map;for(const n of Oi??[])e.set(n.slug,n.name);return e},[Oi]),Ni=e=>s(e,ui,pr.plainText,e=>Ii.get(e),pr.rowName),Ai=(e,n)=>{const t=wt.components[e.type]?.fields,o=n===pe||Hl(n)?"section":"block",r=n===pe&&(Tt(e)||Pt(e)||It(e.type)),i="block"===o?d(t):r?null:c(t);return pr.renamePropOf?pr.renamePropOf(e,o,i):i},$i=(e,n,t,o)=>{if(!(!pt&&Sr?.zone===e&&Sr.index===n))return;const r=(t,o)=>{vr(null),o&&((e,n,t)=>{const o=ki(e)[n];if(!o)return;const r=Ai(o,e);r&&_t.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
9
|
+
return Un("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Lt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Ti=t(re(),Ht),Pi=Ti.scope({target:kn,siteId:tt,docId:Sn}),Mi=wt,ji=(e,n)=>n===pe?hi(e):ui(e),Li=(e,n,t)=>{const o=Ti.plan(Pi,t,ji(t.type,e),Mi);o&&(o.changed&&_t.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Lr(o.message))},Ei=z({nodesIn:ki,nodeAt:(e,n)=>ki(e)[n]??null,labelOf:(e,n)=>n===pe?hi(e):ui(e),renamePropOf:Ai,beginRename:(e,n)=>vr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openAddSection:()=>{_t.select(null),qi(null)},openPageSettings:()=>{_t.select(null),Vo(Y)},pageSettingsLabel:Lt.pageSettings,words:{menu:Dt,styleClipboard:Ht,screen:Lt.menu},readOnly:Boolean(pt),collapseAll:()=>Cr(new Set(ki(pe).map(e=>String(e.props.id)))),onPasteRefused:e=>Lr(e?Lt.pasteRefused({name:e.label}):Lt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Jl(e,n),menuRows:nr.menuRows,isLocked:e=>ir(e.type),duplicateBlocked:e=>lr(kt.data,e),permits:e=>ue(wt,e.type),canAddTo:cr,nodeOps:pi,isPinned:(e,n)=>n===pe&&(Tt(e)||Pt(e)),sectionBand:ri,openAddInside:(e,n)=>{e===pe?Ui(n):_t.select({zone:e,index:n}),qi(null)},locate:e=>gi.get(e)??null,rowNameOf:(e,n)=>n===pe?mi(e):Ni(e),selectAt:(e,n,t,o)=>{e===pe?Ui(n):vl(e,n,t,o??"")},slotRung:e=>{const n=bi(e);return n?.slot.panel?{label:n.slot.label,select:()=>zi(n.node,n.slot,!1)}:null},style:{held:()=>$(Pi),canCopy:e=>Ti.rows(Mi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ti.copy(Pi,e,ji(e.type,n),Mi),paste:(e,n,t)=>Li(e,n,t)},keys:ht?{target:wo,selected:()=>{const e=kt.ui.itemSelector;return e?{zone:e.zone??pe,index:e.index}:null},held:()=>di.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Lr(Lt.copied({name:n}))}}:void 0},xo),Ri=On({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});An(()=>{Ri.current={copy:(e,n)=>Ti.copy(Pi,e,ji(e.type,n),Mi),paste:Li,at:()=>{const e=kt.ui.itemSelector;if(!e)return null;const n=e.zone??pe,t=ki(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const Vi=$n(e=>{const n=T(e);if(!n)return;const t=Ri.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);An(()=>{if(!wo)return;const e=e=>Vi(e);return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[Vi,wo]),gn(xo,"keydown",Vi);const Fi=oi.map(e=>e.props.id).join("|");An(()=>{const e=xo?.document??null,n=xo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Eo(e=>e.length?[]:e);const n=oi.findIndex(Pt),t=n>=0?n:oi.length,o=n=>{const t=oi[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(mn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=oi.length>0&&!Tt(oi[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=Qn(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}Eo(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[xo,Fi,lo,Gr,Zt,eo,bt?.props.id]);const Di=xo?.document??null,Hi=xo?.window??null;An(()=>{const e=vo.current;if(!e||!Di||!Hi)return;const n=[],t=()=>{const n=Di.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Hi.scrollTo({left:Hi.scrollX,top:Hi.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Di,Hi]);const Wi=e=>{nr.holdCanvasOn?nr.holdCanvasOn(e):a(e)},Ui=e=>{Vo(Y),_t.select({index:e}),nr.sectionPressed?.(oi[e]);const n=oi[e]?.props?.id;n&&Wi(n)},Ji=e=>{const{floor:n,cap:t}=ri(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Ro.kind!==$t?.kind?oi.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Gi=(e,n)=>{const{floor:t,cap:o}=ri(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(_t.reorderComponent(pe,e,i),_t.select({index:i}),{moved:!0,dest:i})},Ki=(e,n,t,o)=>{Vo(Y),_t.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Lr(Lt.sectionAdded({name:t}))},Xi=(e,n)=>{const t=Ji(n),o=dr(e,{nodeDefaults:fi,newNodeId:ke,sectionLabel:hi,blockIsOffered:ar}),r=o?_t.insertNode(pe,t,o):_t.insertSection(e,t);return Ki(t,r,hi(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of he(wt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=cr(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Yi=(e,n,t)=>{const o=Ji(t),r=_t.insertNode(pe,o,n);return Ki(o,r,e),o},qi=e=>_i(pe,e),_i=(e,n)=>{Mr.current=document.activeElement??null,po&&(Ao.current=$o.current,$o.current=!1,uo()),Po(null===n?null:{zone:e,index:n}),No(!0),Zt||(Ao.current=!0,St({type:"setUi",ui:{leftSideBarVisible:!0}}))},Qi=()=>{No(!1),Po(null),Ao.current&&St({type:"setUi",ui:{leftSideBarVisible:!1}}),Ao.current=!1},Zi=(e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Wl(n,o)){if("section"===e.kind)_t.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;_t.insertNode(n,t,si(e.template.node))}Vo(Y),_t.select({index:t,zone:n})}},el=(e,n)=>pr.rowName?n?Tt(e)?pr.rowName(e,"section",Lt.header):Pt(e)?pr.rowName(e,"section",Lt.footer):It(e.type)?pr.rowName(e,"section",ui(e.type)):mi(e):Ni(e):n?hi(e.type):ui(e.type),nl=e=>n=>{e()},tl=()=>nr.editPinnedSource?.(),ol=(e,n,t)=>{if(pt)return null;const o=ki(e)[n];return o&&!ue(wt,o.type).delete?null:/* @__PURE__ */Un(Pe,{kind:"delete",label:Lt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=ki(e)[n]?.props?.id;null!=t&&ai(String(t))})(e,n),children:/* @__PURE__ */Un(Fn,{size:15})})},rl=e=>pr.rowPreview?.(e)||void 0,il=e=>pr.rowMarks?.(e)??void 0,ll=(e,n,t)=>pr.rowActions?.(e,n,t)??null,sl=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
10
|
+
return Un(Pe,{kind:"eye",label:r?Lt.showNamed({name:o}):Lt.hideNamed({name:o}),onClick:()=>cl(e,n,t),children:/* @__PURE__ */Un(r?Dn:Hn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},dl=e=>{const n=hi(oi[e]?.type??""),t=n?Lt.addSectionBefore({name:n}):Lt.addSectionHere;return vs(pe,e,()=>qi(e),t)},cl=(e,n,t)=>{_t.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},al=e=>me(wt,e),pl=e=>he(wt,e),ul=e=>rr.slotsOf?vi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:ge(e,n.slot)})):[{slot:null,rung:null,kids:pl(e)}],fl=e=>rr.slotsOf?ul(e).flatMap(e=>e.kids):pl(e),hl=e=>Boolean(rr.slotsOf)&&vi(e).some(e=>e.rung),ml=(e,n,t)=>null===t?void 0===n?cr(e):cr(e,n):cr(e,n,t),gl=(e,n,t)=>{const o=ye(wt,e.type,n)&&(t||fl(e).length>0||hl(e));return{collapsible:o,folded:o&&$r(String(e.props.id))}},yl=(e,n,t)=>ul(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>gl(e,r,t(e.type)).collapsible?[String(e.props.id),...yl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),kl=e=>fl(e).length>0||hl(e)||Boolean(cr(e.type)),Sl=e=>Boolean(cr(e)),vl=(e,n,t,o)=>{if(Vo(Y),cr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),_t.select({index:n,zone:e}),a(t)}else _t.select({index:n,zone:e}),Wi(t)},bl=(e,n,t,o,r)=>{const i=`${e}:${n}`;_t.insertComponent(i,t,o),cr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),_t.select({index:o,zone:i})}):_t.select({index:o,zone:i})},xl=(e,n,t)=>{_t.insertComponent(e,n,t),Vo(Y),_t.select({index:t,zone:e})},wl=On(/* @__PURE__ */new Set);An(()=>{oi.forEach(e=>{const n=cr(e.type)?.spec;if(!n)return;const t=e.props.id;if(wl.current.has(t))return;wl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(fi)).forEach((e,t)=>Xt.seedChild(o,t,n.childType,e))})},[oi,Xt,fi]);const zl=On(/* @__PURE__ */new Set);An(()=>{oi.forEach((e,t)=>{const o=e.props.id;if(zl.current.has(o))return;const r=n(e,al(e.type));zl.current.add(o),r&&Xt.replaceComponent(pe,t,{...e,props:r})})},[oi,Xt]),ie(Xt,wt);const Cl=oi.findIndex(Pt),Bl=Cl>=0?oi[Cl]:null,Ol=Mt?oi.findIndex(Tt):-1,Il=Ol>=0?oi[Ol]:null,Nl=zt.groupTab,Al=In(()=>Nl?e=>It(e.type):void 0,[Nl]),$l=Boolean(zt.groupBadge),Tl=zt.groupBadge?/* @__PURE__ */Un("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Un(Mn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,Pl=oi.find(e=>e.type===Bt)??null,Ml=oi.find(e=>e.type===Ot)??null,jl=Cl>=0?Cl:oi.length,Ll=[];oi.forEach(e=>{Pt(e)||(kl(e)&&Ll.push(String(e.props.id)),Ll.push(...yl(e,1,Sl)))}),Bl&&(Ll.push(String(Bl.props.id)),Ll.push(...yl(Bl,1,Sl)));const El=Ll.length>0&&Ll.every(e=>zr.has(e)),Rl=e=>{const n=pr.blockRowName(e,ui);return pr.rowName?pr.rowName(e,"block",n):n},Vl=(e,n,t,o)=>{const r=ki(e)[t];if(!r)return;const i={...zn(e),index:t},l={...zn(n),index:Math.min(Math.max(o,0),ki(n).length)},s=un(i,l);if(e!==n||s!==t)try{ci.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Bn))throw e}},Fl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of pl(e))n.add(r),t(o)};for(const t of al(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Dl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=gi.get(n);if(!e)return null;if(e.zone===pe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Hl=e=>{const n=e.slice(0,e.indexOf(":")),t=oi.find(e=>It(e.type)&&String(e.props.id)===n);return t&&Nt(n)===e?t:null},Wl=(e,n)=>{const t=Hl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,ki(e).length))},Ul=(e,n,t)=>{if(e.rung){const t=Si(e.rung.nodeId),o=t?vi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Zn&&n.index>=0&&n.index<=o}if(n.slot===Zn)return!1;if(e.add)return Kl(e.add,n);const o=bn(n);if(It(e.type))return!1;const r=Hl(o),i=Hl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Wl(o,e.type))&&(n.index>=0&&n.index<=ki(o).length));if(e.zone===pe||o===pe){if(e.zone!==o)return!1;const{floor:t,cap:r}=ri();return n.index>=t&&n.index<=r}if(n.index<0||n.index>ki(o).length)return!1;if(e.zone===o)return!0;const l=Bl&&!zt.lastIsOpen?String(Bl.props.id):null;return(!l||Dl(e.zone)!==l&&Dl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??ki(e)[t];if(!r)return!1;const i=n.split(":")[0],l=gi.get(i),s=l?ki(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Fl(r).has(n))return!1;const d=cr(s.type,sr(kt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(ki(n),r))})(e.zone,o,e.index,t)},Jl=(e,n)=>{const t=bn(e.from),o=e.node;return t===bn(n)?Wl(t,o.type):Ul({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Gl=e=>{const n=e.slice(0,e.indexOf(":")),t=gi.get(n),o=t?ki(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=cr(o.type,sr(kt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ui(r.spec.childType)}]:[]),l=bi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:el(o,t.zone===pe)}},Kl=(e,n)=>{const t=bn(n);if("block"!==e.kind){if(Hl(t)){const o="section"===e.kind?e.type:e.template.node.type;return Wl(t,o)&&n.index>=0&&n.index<=ki(t).length}if(t!==pe)return!1;const{floor:o,cap:r}=ri();return n.index>=o&&n.index<=r}if(t===pe)return!1;const o=Gl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(ki(t))},Xl=(e,n)=>{e.rung?Bi(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&Hl(bn(n)))return void Zi(e,bn(n),n.index);if("section"===e.kind)return void Xi(e.type,n.index);if("template"===e.kind)return void Yi(e.template.name,si(e.template.node),n.index);const t=bn(n),o=Gl(t);o&&(o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(t,e.type,n.index))})(e.add,n):e.zone===pe?Gi(e.index,n.index):Vl(e.zone,bn(n),e.index,n.index)},[Yl]=Nn(()=>an()),ql=pn({keyOf:e=>e.id,readOnly:Boolean(pt),session:Yl,canDrop:Ul,onDrop:Xl,onStep:(e,n)=>{e.rung?Bi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===pe?((e,n)=>{const t=hi(oi[e]?.type??""),o=Gi(e,n<0?e-1:e+2);if(!o.moved)return void Lr(n<0?Lt.sectionFirst({name:t}):Lt.sectionLast({name:t}));const{floor:r,cap:i}=ri();Lr(Lt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Vl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),_l=$n(e=>{const{floor:n,cap:t}=ri(),o=[];for(const r of e.nodes){const e=bn(r.place),i=ki(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Tt(i)||Pt(i)||ir(i.type))continue;if(It(i.type))continue;const l=Boolean(Hl(e)),s=e===pe||l;e===pe&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?hi(i.type):Ni(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=bn(e.list);return n===pe&&0===e.children.length?[{...e,addLabel:Lt.addSection,addAlways:!0}]:e.children.length>0||Boolean(Gl(n)?.choices.length)||Boolean(Hl(n))?[e]:[]}),i=r.flatMap(e=>{const n=bn(e.list);return n===pe||Hl(n)||!Gl(n)?.choices.length?[]:ln(e,Lt.addBlockHere)});return{sources:o,zones:r,seams:i}},[kt.data]),Ql=null==bt?.props.id?null:String(bt.props.id),Zl=$n(e=>{const n=wt,t=e=>!e.item.rung&&null!==Cn(kt.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(Ql);return i||(r(Ve(kt.data,n,o.item.id,Ql,Al))??o)},[kt.data,wt,Ql,Al]),[es,ns]=Nn(null);gn(xo,"mouseover",e=>{if(!Nl)return;const n=yn(e.target),t=n?Xn(kt.data,wt,n):null;t!==es&&ns(t)}),gn(xo,"mouseout",e=>{Nl&&!e.relatedTarget&&ns(null)});const ts=e=>Tt(e)||Pt(e)||It(e.type),os=[];if(Nl){const e=Ql?Xn(kt.data,wt,Ql):null;for(const n of/* @__PURE__ */new Set([e,es])){const e=n?oi.find(e=>String(e.props.id)===n):void 0;if(!e||!ts(e))continue;const t=Nl(e);t&&os.push({id:String(e.props.id),label:t,below:Tt(e)||e.type===Bt})}}const rs=E(),is=On(null);An(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(oi.filter(ts)),t=is.current;if(is.current={doc:Sn,bands:n,index:vt.index},!t||t.doc!==Sn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Kn.has(rs)&&(Kn.add(rs),Lr(e,"success",{action:{label:Lt.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[oi]);const ls=e=>{Vo(Y),_t.select(e.zone===pe?{index:e.index}:{index:e.index,zone:e.zone})},ss=le(),ds=()=>({data:kt.data,device:lo,ops:_t,inspector:er}),cs=ss?.model,as=In(()=>cs?e=>cs(e,_l(e),ds()):_l,[cs,_l,lo]),ps=ss?.measure,us=ps?(e,n)=>ps(e,n,ds()):void 0,fs=ss?.canDrop,hs=fs?(e,n)=>fs(e,n,Ul,ds()):Ul,ms=ss?.drop,gs=ms?(e,n)=>ms(e,n,Xl,ds()):Xl,ys=ss?.pick,ks=ys?e=>ys(e,ls,ds()):ls,Ss=e=>{const n=bn(e),t=bi(n);t&&zi(t.node,t.slot,!1),_i(n,e.index)},vs=(e,n,t,o)=>/* @__PURE__ */Un(Me,{...pt?{}:ql.seam({place:{...zn(e),index:n}}),onAdd:pt?void 0:t,label:o},`seam:${e}:${n}`),bs={rowClick:nl,isCollapsed:$r,toggleCollapse:Tr},xs=e=>{const n=String(e.props.id),t=oi.findIndex(e=>String(e.props.id)===n),o=Nt(n),r=ki(o),i=$r(n),l=ui(e.type),s=pr.rowName?pr.rowName(e,"section",l):l,d=e=>vs(o,e,()=>_i(o,e),Lt.addSectionHere);/* @__PURE__ */
|
|
11
|
+
return Jn(Gn,{children:[
|
|
12
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:e.type,size:13}),name:s,preview:rl(e),marks:il(e),onSelect:()=>Ui(t),nameSlot:$i(pe,t,n,s),selected:Jo===n,badge:Tl,actions:ll(e,pe,t)??void 0,rowProps:{"data-node-id":n,onClick:nl(()=>Ui(t))},fold:{open:!i,label:"section",onToggle:()=>Tr(n)}}),!i&&/* @__PURE__ */Jn(Ae,{children:[r.map((n,t)=>{const r=String(n.props.id),i=mi(n),l=kl(n),s=l&&$r(r),c=()=>vl(o,t,r,e.type),{rowProps:a,...p}=ql.row({item:{id:r,zone:o,index:t,type:n.type},place:{...zn(o),index:t}},{"data-node-id":r,onClick:nl(c)});/* @__PURE__ */
|
|
13
|
+
return Jn(Pn,{children:[d(t),
|
|
14
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:c,nameSlot:$i(o,t,r,i),selected:Jo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Tr(r)}:void 0,actions:/* @__PURE__ */Jn(Gn,{children:[ol(o,t,i),ll(n,o,t),sl(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Un(Ae,{children:Cs(n,2)})]},r)}),d(r.length)]})]})},ws=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=ql.dragging,d=!$r(l)&&s?.rung?.nodeId!==i,c={...zn(l),index:0},a=s&&!s.rung&&Ul(s,c)?c:void 0,p=()=>zi(e,n,!0),{rowProps:u,...f}=ql.row({item:{id:`rung:${l}`,zone:`${i}:${Zn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Zn,index:t},into:a,canDrag:Boolean(rr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:nl(p)}),h=pt?null:rr.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
15
|
+
return Jn(Pn,{children:[n.heading,
|
|
16
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:xi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Tr(l)},actions:h&&h.length>0?/* @__PURE__ */Un(Gn,{children:h.map((t,o)=>/* @__PURE__ */Un(Pe,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ci(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Un(Fn,{size:15}):/* @__PURE__ */Un(Wn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Un(Ae,{children:r})]},l)},zs=(e,n)=>{const t=ul(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
17
|
+
return Un(Gn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ml(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=null!==c&&Boolean(Gl(c)?.choices.length),p=(e,n)=>a?vs(e,n,()=>_i(e,n),Lt.addBlockHere):vs(e,n),u=/* @__PURE__ */Jn(Gn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Jo===String(n.props.id),{collapsible:i,folded:s}=gl(n,l,Sl(n.type)),d=String(n.props.id),c=Rl(n),a=()=>vl(t,o,d,e.type),{rowProps:u,...f}=ql.row({item:{id:d,zone:t,index:o,type:n.type},place:{...zn(t),index:o}},{"data-node-id":d,onClick:nl(a)});/* @__PURE__ */
|
|
18
|
+
return Jn(Pn,{children:[0===o&&p(t,0),
|
|
19
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:c,preview:rl(n),marks:il(n),onSelect:a,nameSlot:$i(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Tr(d)}:void 0,actions:/* @__PURE__ */Jn(Gn,{children:[ol(t,o,c),ll(n,t,o),sl(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Un(Ae,{children:zs(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?ws(e,t.rung,r++,o,u):/* @__PURE__ */Un(Pn,{children:u},t.slot??"")})})},Cs=(e,n)=>{const t=sr(kt?.data,e.type,String(e.props.id)),o=ul(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
20
|
+
return Un(Gn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ml(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>bl(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>_i(n,t):void 0;return vs(n,t,o,n===f&&c?c.addLabel:Lt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Jn(Gn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Jo===String(n.props.id),i=Ni(n),l=String(n.props.id),{collapsible:d,folded:c}=gl(n,s,Sl(n.type)),a=al(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...zn(p),index:ki(p).length}:void 0,f=ql.dragging,h=u&&f&&Ul(f,u)?u:void 0,g=()=>vl(t,o,l,e.type),{rowProps:y,...k}=ql.row({item:{id:l,zone:t,index:o,type:n.type},place:{...zn(t),index:o},into:h,canDrag:!ir(n.type)},{"data-node-id":l,onClick:nl(g)});/* @__PURE__ */
|
|
21
|
+
return Jn(Pn,{children:[0===o&&m(t,0),
|
|
22
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:g,nameSlot:$i(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Tr(l)}:void 0,actions:ir(n.type)?ll(n,t,o)??void 0:/* @__PURE__ */Jn(Gn,{children:[ol(t,o,i),ll(n,t,o),sl(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Un(Ae,{children:Cs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
|
|
23
|
+
/* @__PURE__ */Un(P,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>bl(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?ws(e,o.rung,i++,r,k):/* @__PURE__ */Un(Pn,{children:k},o.slot??"")})})},Bs=(()=>{if(!bt||!Fo)return null;const e=String(bt.type),n=String(bt.props.id),t=cr(e,sr(kt?.data,e,n));if(!t||"footer"===t.source)return null;const o=oi.some(e=>String(e.props?.id)===n),r=Array.isArray(bt.props[t.slot])?bt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:ui(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:el(bt,o),choices:i,onPick:o=>{t.spec?bl(n,t.slot,o,r.length,e):xl(`${n}:${t.slot}`,o,r.length)}}})(),Os=Wo&&Wo.zone!==pe&&!Hl(Wo.zone)?Wo.zone:null,Is=!0===Mo.blocksFirst,Ns=Os?Gl(Os):Is&&Wo?null:Bs,As=Wo&&Hl(Wo.zone)?Wo.zone:null,$s=As&&zt.groupAccepts?e=>Wl(As,e):void 0,Ts=Boolean(To&&Os)||Is&&Boolean(Ns&&Ns.choices.length>0),Ps=Io||null!==po,Ms=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Zt&&!Ps&&or===e.id,onSelect:()=>Zr(e.id)}:e,js=[{id:"add",label:Lt.add.title,icon:/* @__PURE__ */Un("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:Io,onSelect:()=>Io?Qi():qi(null)},...(nr.railLead??[]).map(Ms),{id:"sections",label:Lt.layers,icon:/* @__PURE__ */Un(Fe,{}),active:Zt&&!Ps&&"sections"===or,onSelect:()=>Zr("sections")},...(nr.railTrail??[]).map(Ms)];ao?js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Un(De,{}),active:Zt&&!Io&&(null!==po||"media"===or),onSelect:()=>Zr("media")}):mt&&js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Un(De,{}),onSelect:ei});const Ls=[...nr.railLead??[],...nr.railTrail??[]].find(e=>"panel"in e&&e.id===or),Es=Boolean(jt?.foldable)&&!tr,Rs=jt?.label??(gt?Lt.pageSections:Lt.templateSections),Vs=Es&&$r(et),Fs=/* @__PURE__ */Jn(Gn,{children:[oi.map((e,n)=>{if(Tt(e)||Pt(e)||It(e.type))return null;const t=Jo===String(e.props.id),o=Boolean(e.props._hidden);pl(e);const r=String(e.props.id),i=nr.hasOwnRows?.(e)??!1,l=kl(e)||i,s=l&&$r(r),d=al(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...zn(c),index:ki(c).length}:void 0,p=ql.dragging,u=a&&p&&Ul(p,a)?a:void 0,{rowProps:f,...h}=ql.row({item:{id:r,zone:pe,index:n,type:e.type},place:{...zn(pe),index:n},into:u},{"data-node-id":r,onClick:nl(()=>Ui(n))});/* @__PURE__ */
|
|
24
|
+
return Jn(Pn,{children:[n>0&&dl(n),
|
|
25
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:e.type,size:13}),name:mi(e),preview:rl(e),marks:il(e),onSelect:()=>Ui(n),nameSlot:$i(pe,n,r,mi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Tr(r)}:void 0,actions:/* @__PURE__ */Jn(Gn,{children:[ol(pe,n,mi(e)),ll(e,pe,n),sl(pe,n,e,mi(e))]}),rowProps:f}),kl(e)&&!s&&/* @__PURE__ */Jn(Ae,{children:[Cs(e,1),nr.partRows?.(e,bs)]}),i&&!s&&/* @__PURE__ */Un(Ae,{children:nr.ownRows?.(e,n,bs)})]},String(e.props.id??n))}),!tr&&jl>0&&dl(jl),jt?.addAtEnd&&!tr&&!pt&&/* @__PURE__ */Un(P,{small:!0,label:Lt.addSection,blocked:null,onAdd:()=>qi(jl)})]}),Ds=(e,n,t)=>{const o=String(e.props.id),r=fl(e).length>0||hl(e)||Boolean(cr(e.type)),i=r&&$r(o),l="header"===t?Lt.header:Lt.footer,s=pr.rowName?pr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
26
|
+
return Jn(Gn,{children:[
|
|
27
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:t,size:13}),name:s,preview:rl(e),marks:il(e),badge:Tl,onSelect:()=>Ui(n),nameSlot:$i(pe,n,o,s),selected:Jo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Tr(o)}:void 0,actions:ll(e,pe,n)??void 0,rowProps:{"data-node-id":o,onClick:nl(()=>Ui(n))}}),r&&!i&&/* @__PURE__ */Un(Ae,{children:zs(e,1)})]})};return(nr.wrap??(e=>e))(
|
|
28
|
+
/* @__PURE__ */Un(se,{target:xo,children:/* @__PURE__ */Jn("div",{ref:bo,className:"sf-editor es-editor",style:Qe(Br),onContextMenu:Ei.onEditorContextMenu,...g(hn),children:[
|
|
29
|
+
/* @__PURE__ */Jn(He,{children:[
|
|
30
|
+
/* @__PURE__ */Un(We,{items:js,ariaLabel:Lt.bar.views}),
|
|
31
|
+
/* @__PURE__ */Jn(Ue,{children:[
|
|
32
|
+
/* @__PURE__ */Un(Je,{label:Lt.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Un(En,{})}),
|
|
33
|
+
/* @__PURE__ */Un(Je,{label:Lt.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Un(Rn,{})}),
|
|
34
|
+
/* @__PURE__ */Un(Ge,{}),
|
|
35
|
+
/* @__PURE__ */Un(Ke,{devices:no,value:lo,onChange:so}),
|
|
36
|
+
/* @__PURE__ */Un(Je,{label:Lt.bar.refresh,tip:Lt.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=xo?.document;if(!e)return null;const n=oi.findIndex(Pt),t=n>=0?n:oi.length;let o=null;for(let n=0;n<t;n++){const t=oi[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=bt?.props?.id??oi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),So(e=>e+1)},children:/* @__PURE__ */Un(Vn,{})})]}),
|
|
37
|
+
/* @__PURE__ */Jn(Ue,{kind:"right",style:{minWidth:300},children:[
|
|
38
|
+
/* @__PURE__ */Un(B,{input:Bo,words:Lt.saveStatus}),nr.barLead?.(),nr.barTrail?.(),nr.mainAction||!nr.barMain?/* @__PURE__ */Un(O,{input:Bo,action:nr.mainAction??{label:Lt.done,onPress:()=>{ot(kt.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Oo,bar:Lt.bar,words:Lt.saveStatus}):nr.barMain()]})]}),
|
|
39
|
+
/* @__PURE__ */Un(C,{}),
|
|
40
|
+
/* @__PURE__ */Jn("div",{className:"sf-body",children:[Zt?/* @__PURE__ */Jn(Gn,{children:[
|
|
41
|
+
/* @__PURE__ */Un("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Lt.leftPanel,children:Io?/* @__PURE__ */Un(M,{blocks:Ns,blocksOnly:Ts,sectionAccepts:$s,at:To?{label:(e=>{const n=Hl(e.zone);if(n)return Lt.add.addingTo({name:pr.rowName?el(n,!0):ui(n.type)});if(e.zone===pe){const n=oi[e.index];return n&&!Pt(n)?Lt.add.addingBefore({name:el(n,!0)}):Lt.add.addingAtEnd}const t=Gl(e.zone);return t?Lt.add.addingTo({name:t.parentName}):Lt.add.addingHere})(To),onClear:()=>Po(null)}:void 0,onAdd:e=>{const n=Wo,t=(e,n)=>{To&&Po({zone:e,index:n})};if(n&&"block"!==e.kind&&Hl(n.zone))return Zi(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===Uo)return void Xi(e);const n=Xi(e,Uo);To&&jo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===Uo)return void Yi(e,n);const t=Yi(e,n,Uo);To&&jo(t+1)})(e.template.name,si(e.template.node));if(n&&n.zone!==pe){const o=Gl(n.zone);if(!o)return;return o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Bs?.onPick(e.type)},itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Yl,siteWide:nr.addPanelRow?.(Qi),onClose:Qi,onHide:_r,readOnly:Boolean(pt)}):po&&co?
|
|
42
|
+
/* @__PURE__ */Un(R,{panel:co,pick:po,onHide:_r}):Ls?Ls.panel({onHide:_r,notify:Lr}):"media"===or&&co?/* @__PURE__ */Un(R,{panel:co,pick:null,onHide:_r}):/* @__PURE__ */Jn(Gn,{children:[
|
|
43
|
+
/* @__PURE__ */Un(j,{icon:/* @__PURE__ */Un(Fe,{}),title:Lt.layers,context:Ut,actions:
|
|
44
|
+
/* @__PURE__ */Un(Xe,{label:El?Lt.expandAll:Lt.collapseAll,title:0===Ll.length?Lt.nothingToFold:void 0,disabled:0===Ll.length,onClick:()=>Cr(e=>{const n=new Set(Ll);return El?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Ll])}),children:/* @__PURE__ */Un(qn,{expand:El})}),onHide:_r}),
|
|
45
|
+
/* @__PURE__ */Jn($e,{className:"sf-tree sf-scroll",words:Et,children:[
|
|
46
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"page",size:13}),name:Lt.pageSettings,onSelect:ni,selected:!bt&&Fo,rowProps:{onClick:nl(ni)}}),Pl&&/* @__PURE__ */Jn(Gn,{children:[!$l&&/* @__PURE__ */Un(Te,{children:Lt.header}),xs(Pl)]}),!tr&&yt&&!($l&&Pl)&&/* @__PURE__ */Jn(Gn,{children:[!$l&&/* @__PURE__ */Un(Te,{children:Lt.header}),!Mt&&/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"header",size:13}),name:Lt.header,badge:Tl,onSelect:ti,selected:Ro.kind===$t?.kind,rowProps:{onClick:nl(ti)}})]}),!tr&&Il&&!($l&&Pl)&&Ds(Il,Ol,"header"),!tr&&!Es&&/* @__PURE__ */Un(Te,{children:Rs}),Es?/* @__PURE__ */Jn(Gn,{children:[
|
|
47
|
+
/* @__PURE__ */Un(Ne,{words:Et,icon:null,name:Rs,fold:{open:!Vs,label:Rs,onToggle:()=>Tr(et)}}),!Vs&&/* @__PURE__ */Un(Ae,{children:Fs})]}):Fs,yt&&!$l&&/* @__PURE__ */Un(Te,{children:Lt.footer}),Bl&&!($l&&Ml)&&Ds(Bl,Cl,"footer"),!tr&&!Bl&&yt&&!$l&&/* @__PURE__ */Un(Ne,{words:Et,icon:/* @__PURE__ */Un(fr,{type:"footer",size:13}),name:Lt.footer,onSelect:tl,rowProps:{onClick:nl(tl),title:Lt.editFooter}}),Ml&&xs(Ml),nr.treeFoot?.()]})]})}),
|
|
48
|
+
/* @__PURE__ */Un(Ye,{side:"left",width:Br.left,min:_e,max:qe,defaultWidth:S.left,label:Lt.resizeLeftPanel,onResize:Nr})]}):/* @__PURE__ */Un(L,{side:"left",onShow:_r}),
|
|
49
|
+
/* @__PURE__ */Jn("div",{ref:Er,className:"sf-center sf-scroll","data-sf-canvas-head":Hr?"":void 0,style:{overflowX:Xr?"auto":"hidden",overflowY:"hidden"},children:[Hr&&/* @__PURE__ */Un("div",{ref:Wr,className:"sf-canvas-head",children:/* @__PURE__ */Un(Hr,{device:lo})}),
|
|
50
|
+
/* @__PURE__ */Jn("div",{className:"sf-frame-scaler",style:Yr,children:[
|
|
51
|
+
/* @__PURE__ */Un("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:qr,children:/* @__PURE__ */Jn("div",{className:"sf-preview-host",children:[
|
|
52
|
+
/* @__PURE__ */Un(Ie.Provider,{value:Al,children:/* @__PURE__ */Un(Jt,{},ko)}),
|
|
53
|
+
/* @__PURE__ */Un(sn,{canvas:xo,session:Yl,model:as,measure:us,canDrop:hs,onDrop:gs,choose:Zl,onPick:ks,onZoneAdd:Ss,onSeamAdd:Ss,zoneAddLabel:Lt.canvasAddBlock,words:Rt.canvas,readOnly:Boolean(pt),revision:kt.data}),Lo.length>0&&/* @__PURE__ */Un("div",{className:"sf-preview-gaps",children:Lo.map(e=>
|
|
54
|
+
/* @__PURE__ */Un(dn,{index:e.index,label:Lt.addSectionHere,onInsert:()=>qi(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})}),Nl?/* @__PURE__ */Un(Yn,{canvas:xo,tabs:os,onSelect:e=>{const n=oi.findIndex(n=>String(n.props.id)===e);n>=0&&Ui(n)}}):null]})]}),eo?/* @__PURE__ */Jn(Gn,{children:[
|
|
55
|
+
/* @__PURE__ */Un(y,{value:{selectChild:vl,addChild:bl,childRowName:Ni,blockRowName:Rl},children:/* @__PURE__ */Un(Gt,{mode:Ro,onOpenWebsiteSettings:nr.openSettings??(()=>{}),onOpenSiteStyles:nr.openStyles,onSelectNode:yr,onNotify:Lr,onHidePanel:Qr,nodeActions:bt?ue(wt,bt.type):nt})}),
|
|
56
|
+
/* @__PURE__ */Un(Ye,{side:"right",width:Br.right,min:_e,max:qe,defaultWidth:S.right,label:Lt.resizeSettingsPanel,onResize:Ar})]}):
|
|
57
|
+
/* @__PURE__ */Un(L,{side:"right",onShow:Qr})]}),Ei.menu]})}))}export{tt as ScreenChrome};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-
|
|
2
|
-
return s(t,{height:"fill"})}function
|
|
3
|
-
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var
|
|
4
|
-
return s(
|
|
5
|
-
return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return N().Inspector??
|
|
1
|
+
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-K5744MTM.js";import{Inspector as i}from"./chunk-UCLVWF5E.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},L={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},C={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
|
|
2
|
+
return s(t,{height:"fill"})}function P(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
|
|
3
|
+
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var D=o({});function G({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(D.Provider,{value:n,children:e})}function N(){return u(D)}function T(){return(N().useOwnerName??g)()}function x(){return(N().useDocumentLabel??y)()}function B(n,e,t,r){return(N().useBridges??v)(n,e,t,r)}function F(n){return(N().useStandaloneBridges??v)(n)}function I(n,e){(N().useDocumentPass??b)(n,e)}function A(){return N().blockRules??L}function K(){return N().blockLook??O}function R(){return N().devices??j}function V(){return N().leftView??w}function W(){return N().pinned??C}function E(){return N().saveSwitch??!0}function M(n){e(!0===N().pickFollowsSelection,n)}function H(){return N().add??h}function Q(){return N().storageNamespace||void 0}function U(){return N().styleClipboard??null}function Y(){return N().nodeKeys??!0}function Z(){return N().notify??null}function q(){return N().Canvas??S}function z(){return N().CanvasHead??null}function J(){return N().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return N().Inspector??P}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,G as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,H as useScreenAdd,K as useScreenBlockLook,A as useScreenBlockRules,B as useScreenBridges,J as useScreenCanvasDrag,q as useScreenCanvasFrame,z as useScreenCanvasHead,_ as useScreenCanvasTarget,R as useScreenDevices,x as useScreenDocumentLabel,I as useScreenDocumentPass,nn as useScreenInspectorPanel,V as useScreenLeftView,Y as useScreenNodeKeys,Z as useScreenNotify,T as useScreenOwnerName,N as useScreenParts,M as useScreenPickFollowsSelection,W as useScreenPinned,E as useScreenSaveSwitch,Q as useScreenStorageNamespace,U as useScreenStyleClipboard,F as useStandaloneScreenBridges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{styleMenuItems as e}from"./chunk-V7U33NF2.js";import{useEaselSession as n}from"./chunk-O7Q4DDJT.js";import{ROOT_ZONE as t}from"./chunk-PLVEGYK6.js";import{useHostEscape as o}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-JTUUIVBZ.js";import{EaselMenuItems as r,menuLabel as i}from"./chunk-EA2HTX37.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as d,useCanvasEvent as u,framePointToHost as p}from"./chunk-
|
|
1
|
+
import{styleMenuItems as e}from"./chunk-V7U33NF2.js";import{useEaselSession as n}from"./chunk-O7Q4DDJT.js";import{ROOT_ZONE as t}from"./chunk-PLVEGYK6.js";import{useHostEscape as o}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-JTUUIVBZ.js";import{EaselMenuItems as r,menuLabel as i}from"./chunk-EA2HTX37.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as d,useCanvasEvent as u,framePointToHost as p}from"./chunk-ILXP5VX5.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as y}from"./chunk-KRXQM65X.js";import{useState as h,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,AddIcon as C,PasteIcon as z,SettingsIcon as P,LayersIcon as O,CopyIcon as A}from"efficient-shell/icons/efficient";import{jsx as S}from"react/jsx-runtime";function D(e,n){const o=[],l=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||l.has(n.props.id))break;if(l.add(n.props.id),o.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===t)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<o.length-1;e+=1)o[e].parentType=o[e+1].node.type;return o}var K=c(),T=/* @__PURE__ */new WeakMap;function X(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=T.get(n);return t||(t=c(),T.set(n,t)),t}function j(){return X(n())}function I(e,n,o){if(n===t){const{floor:n,cap:t}=e.sectionBand();return{parentId:y,slot:m,index:Math.min(Math.max(o,n),t)}}const l=n.lastIndexOf(":");return{parentId:n.slice(0,l),slot:n.slice(l+1),index:o}}function M(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 E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?I(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=I(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(d(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||"Backspace"===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=M(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:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function V(n,o){const{zone:l,index:r}=o,i=n.nodeAt(l,r);if(!i)return[];const c=i.props.id,a=n.labelOf(i.type,l),d=Boolean(i.props._hidden),u=n.nodeOps,p=n.isPinned(i,l),f=n.isLocked(i),m=!p&&!f&&!n.duplicateBlocked(i),y=n.permits?.(i)??{duplicate:!0,delete:!0},h=M(n,i,l),k=D(n,o),b=u.held,v=b&&!p?E(n,b,o):null,g=!n.readOnly,w=n.style?e({held:g?n.style.held():null,canCopy:n.style.canCopy(i,l),onCopy:()=>n.style?.copy(i,l),onPaste:()=>n.style?.paste(l,r,i),words:n.words?.styleClipboard}):[];return s({title:a,words:n.words?.menu,layer:{group:"pick",items:k.flatMap((e,o)=>{const l={label:n.rowNameOf(e.node,e.zone),checked:0===o,onClick:()=>n.selectAt(e.zone,e.index,e.node.props.id,e.parentType)},r=e.zone===t?null:n.slotRung?.(e.zone)??null;return r?[l,{label:r.label,checked:!1,onClick:r.select}]:[l]})},actions:{addInside:g&&n.canAddTo(i.type)?()=>n.openAddInside(l,r):void 0,duplicate:g&&m&&y.duplicate?()=>u.duplicate(c):void 0,moveUp:g&&u.canStep(c,-1)?()=>u.step(c,-1):void 0,moveDown:g&&u.canStep(c,1)?()=>u.step(c,1):void 0,copy:h.copy?()=>u.copy(c,a):void 0,cut:g&&h.cut?()=>u.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>u.paste(v)}:void 0,rename:g&&n.renamePropOf(i,l)?()=>n.beginRename(l,r):void 0,hide:!g||f||p?void 0:{hidden:d,run:()=>u.setProps(c,{_hidden:!d})},delete:g&&m&&y.delete?()=>u.remove(c):void 0},style:w,extras:n.menuRows?.(i,l,r)??void 0,pinnedLine:p?B(n).pinned:void 0})}var B=e=>e.words?.screen??l.menu;function R(e){const n=B(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */S(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */S(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=o?[{label:n.addSection,icon:/* @__PURE__ */S(C,{}),onClick:e.openAddSection}]:[],c=e.nodeOps.held,s=I(e,t,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===t)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */S(z,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const d=[r,i,[{label:e.pageSettingsLabel??l.pageSettings,icon:/* @__PURE__ */S(P,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */S(O,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),u={label:"—",onClick:()=>{}};return d.flatMap((e,n)=>n?[u,...e]:e)}function Y(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??a,c=B(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */S(A,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */S(A,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */S(z,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const d=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),u={label:"—",onClick:()=>{}};return d.flatMap((e,n)=>n?[u,...e]:e)}function N(e){return e.shiftKey}function F(e,n){const[t,l]=h(null),r=k(()=>l(null),[]);o(null!==t,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=L(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))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),u(n,"keydown",c);const a=k(n=>{if(N(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]);u(n,"contextmenu",t=>{if(N(t)||!n)return;const o=t.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;t.preventDefault();const c=p(n.frame,t.clientX,t.clientY),s=n.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),u(n,"mousedown",r),u(n,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:t?/* @__PURE__ */S(G,{host:e,target:t,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?V(e,n):"input"===n.kind?Y(e,n.el):R(e);return 0===o.length?null:/* @__PURE__ */S(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),children:/* @__PURE__ */S(r,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,X as nodeClipboardOf,M as nodeClipboardRules,V as nodeMenuItems,L as nodeShortcut,R as pageMenuItems,E as pastePlace,U as runNodeShortcut,Y as textMenuItems,j as useNodeClipboard,F as useNodeContextMenu};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-CWTAS5R6.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-K5744MTM.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
|
|
2
2
|
return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-O2NLQBFX.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-67GNT6PF.js";import{useCanvasLayout as o,useCanvasEvent as s,CANVAS_TYPING_EVENT as i,framePointToHost as c,elementScale as d,frameRectToLayer as u,clientPointToLayer as h}from"./chunk-
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-O2NLQBFX.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-67GNT6PF.js";import{useCanvasLayout as o,useCanvasEvent as s,CANVAS_TYPING_EVENT as i,framePointToHost as c,elementScale as d,frameRectToLayer as u,clientPointToLayer as h}from"./chunk-ILXP5VX5.js";import{withTip as f}from"./chunk-P2VEMZH5.js";import{parseZoneKey as p}from"./chunk-KRXQM65X.js";import{useRef as m,useEffect as g,useState as b,useCallback as x,useMemo as y,useSyncExternalStore as v,useId as w,useLayoutEffect as k}from"react";import{Tooltip as N,IconButton as z,Input as A}from"efficient-shell/ui";import{AddIcon as D,CloseIcon as T,SearchIcon as $}from"efficient-shell/icons/efficient";import{jsxs as C,jsx as M}from"react/jsx-runtime";function S({label:e,onInsert:t,style:n,axis:l="y",className:a,index:r}){const o=["es-canvas-insert","x"===l?"is-x":"",a??""].filter(Boolean).join(" ");/* @__PURE__ */
|
|
2
2
|
return C("div",{className:o,style:n,"data-index":r,children:[
|
|
3
3
|
/* @__PURE__ */M("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(
|
|
5
|
-
/* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??
|
|
6
|
-
/* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:
|
|
7
|
-
/* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),
|
|
4
|
+
/* @__PURE__ */M("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */M(N,{content:e,children:/* @__PURE__ */M(z,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */M(D,{})})})})]})}var E=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,L=e=>e.width*e.height;function j(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>E(e.box,t,n)).sort((e,t)=>L(t.s.box)-L(e.s.box)||e.at-t.at).map(({s:e})=>e)}function B(e,t,n){return j(e,t,n).at(-1)??null}function X(e,t,n){const l="x"===e.axis?t:n;let a=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(a+=1)}return a}function K(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],a=n[t],r=l&&a?(l.left+l.width+a.left)/2:l?l.left+l.width:a?a.left:e.box.left,o=a??l??e.box;return{left:r-1,top:o.top,width:2,height:o.height}}const l=n[t-1],a=n[t],r=l&&a?(l.top+l.height+a.top)/2:l?l.top+l.height:a?a.top:e.box.top;return{left:e.box.left,top:r-1,width:e.box.width,height:2}}function q(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>E(e.box,t,n)).sort((e,t)=>L(e.box)-L(t.box));for(const e of o){const o=X(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:K(e,o)};if(!r(s))return null}return null}function I(e,t,n=12){const l=e.children;if(0===l.length)return[];const a=e.box,r="x"===e.axis,o=r?a.left:a.top,s=o+(r?a.width:a.height),i=e=>r?e.left:e.top,c=e=>r?e.left+e.width:e.top+e.height,d=[];for(let u=0;u<=l.length;u++){const h=l[u-1],f=l[u];let p,m;if(h&&f)p=c(h),m=Math.max(i(f)-p,0);else{const e=h?(c(h)+s)/2:(o+i(f))/2;p=Math.min(Math.max(e,o+n),s-n),m=0}const g=r?{left:p,top:a.top,width:m,height:a.height}:{left:a.left,top:p,width:a.width,height:m};d.push({key:`${e.key}:+${u}`,place:{...e.list,index:u},box:g,axis:e.axis,label:t})}return d}function O(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const a=e.children[l-1],r=e.children[l],o=a.top+a.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:o,width:e.box.width,height:Math.max(r.top-o,0)}})}return n}var P={nodes:[],zones:[]},F="data-puck-dropzone",R="data-puck-component";function V(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function Z(e,t){const{frame:n,document:l}=e,a=e=>u(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),r=[],o=[];for(const e of l.querySelectorAll(`[${F}]`)){const t=e.getAttribute(F)??"";let n;try{n=p(t)}catch{continue}const l=[...e.querySelectorAll(`[${R}]`)].filter(t=>t.parentElement?.closest(`[${F}]`)===e),s=l.map(a);o.push({key:t,list:n,box:a(e),axis:V(s,e),children:s}),l.forEach((e,t)=>{const l=e.getAttribute(R);l&&r.push({id:l,place:{...n,index:t},box:s[t]})})}return{nodes:r,zones:o}}var Q="data-es-empty-cell",Y="data-puck-dropzone",G=140;var H=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function W(u){const{canvas:f,session:p,readOnly:w,words:z=e.canvas}=u,A=m(u);g(()=>{A.current=u});const D=m(null),T=o(f),[$,E]=b(0),L=x(()=>E(e=>e+1),[]),[B,X]=b(P);g(()=>{const e=D.current;f&&e&&X((A.current.measure??Z)(f,e))},[f,T,u.revision,$]);const K=u.model,I=y(()=>K(B),[K,B]),O=v(p.subscribe,p.shown,p.shown),F=u.choose,R=(e,t)=>{const n=j(I.sources,e,t);return 0===n.length?null:F?F(n):n[n.length-1]},[V,G]=b(null),[W,J]=b(null),U=m(null),_=()=>{U.current&&clearTimeout(U.current),U.current=null},ee=()=>{_(),U.current=setTimeout(()=>{p.get()||G(null)},140)};g(()=>_,[]);const te=m(null),ne=m(!1);s(f,i,e=>{ne.current=Boolean(e.detail?.typing),ne.current&&(_(),G(null))}),s(f,"mousemove",e=>{const t=D.current;if(!f||!t)return;const n=c(f.frame,e.clientX,e.clientY,t),l=d(t),a={x:n.x/l,y:n.y/l};if(te.current=a,A.current.readOnly||p.get()||ne.current)return;_();const r=R(a.x,a.y);G(e=>e?.key===r?.key&&e?.box===r?.box?e:r)}),s(f,"mouseout",e=>{e.relatedTarget||(te.current=null,ee())}),s(f,"mouseover",e=>{e.relatedTarget||L()});const le=m(null),ae=x(()=>{le.current?.(),le.current=null,J(null)},[]);g(()=>p.subscribe(()=>{p.get()?L():ae()}),[p,ae,L]),g(()=>ae,[ae]),("undefined"==typeof document?g:k)(()=>{if(p.get())return;const e=te.current;G(t=>w||ne.current?null:e?R(e.x,e.y):t?I.sources.find(e=>e.key===t.key)??null:null)},[I,O,p,w,F]);const re=e=>{const t=p.get(),n=D.current;if(!t||!n)return null;const l=h(n,e.clientX,e.clientY);te.current=l;const a=q(I.zones,l.x,l.y,e=>A.current.canDrop(t.item,e),e=>!!t.from&&r(t.from,e),e=>A.current.fallThrough?.(t.item,e,t.from)??!0);return a?{h:t,t:a}:null},oe={onDragEnter:e=>{if(le.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),r=f?l(f.document):null,o=[];t&&o.push(a(t)),r&&f&&o.push(a(r,f.frame)),le.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=re(e);if(!n)return void J(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const l={zoneKey:n.t.zone.key,line:n.t.line,axis:n.t.zone.axis};J(e=>e&&e.zoneKey===l.zoneKey&&e.line.left===l.line.left&&e.line.top===l.line.top?e:l)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(te.current=null,J(null))},onDrop:e=>{const t=re(e);t&&(e.preventDefault(),p.end(),ae(),A.current.onDrop(t.h.item,t.t.to))}},se={draggable:!w&&!!V,onMouseEnter:_,onMouseLeave:()=>!p.get()&&ee(),onDragStart:e=>{if(V&&!w){p.start({key:V.key,item:V.item,from:V.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",V.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{p.end(),ae()},onClick:()=>{V&&!w&&A.current.onPick?.(V.item)}},{seams:ie=[]}=I,ce=I.zones.filter(e=>0===e.children.length),de=u.onZoneAdd&&!w?ce:[],ue=de.map(e=>e.key).join("\n");return g(()=>{const e=f?.document;if(!e)return;const t=new Set(ue?ue.split("\n"):[]);for(const n of e.querySelectorAll(`[${Y}]`))n.toggleAttribute(Q,t.has(n.getAttribute(Y)??""));return()=>{for(const t of e.querySelectorAll(`[${Q}]`))t.removeAttribute(Q)}},[f,ue,B,T,$]),/* @__PURE__ */C("div",{ref:D,className:"es-canvas-layer",children:[O||!u.onSeamAdd||w?null:ie.map(e=>
|
|
5
|
+
/* @__PURE__ */M(S,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??u.seamLabel??z.addSection,onInsert:()=>u.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),de.length?de.map(e=>/* @__PURE__ */M("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",W?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:H(e.box),onClick:()=>u.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */M("span",{className:"es-canvas-empty-add",children:z.addButton({label:e.addLabel??u.zoneAddLabel??z.addBlock})})},e.key)):null,O?/* @__PURE__ */M("div",{className:"es-canvas-catch",...oe}):null,W&&!ce.some(e=>e.key===W.zoneKey)?/* @__PURE__ */M("div",{className:`es-canvas-line is-${W.axis}`,style:H(W.line)}):null,
|
|
6
|
+
/* @__PURE__ */M("div",{className:"es-canvas-handle-spot",style:V?{"--es-handle-x":`${V.box.left+2}px`,"--es-handle-y":`${Math.max(V.box.top-11,0)}px`}:void 0,children:/* @__PURE__ */M(N,{className:"es-canvas-handle-tip",side:"top",content:!V||w||O?null:V.title??z.handle({label:V.label}),children:/* @__PURE__ */C("div",{className:["es-canvas-handle",V&&!w?"is-shown":"",O?"is-dragging":""].filter(Boolean).join(" "),...se,children:[
|
|
7
|
+
/* @__PURE__ */M("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var J=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function U({groups:t,session:n,itemFor:l,onInsert:a,at:r,hint:o,searchLabel:s,readOnly:i,words:c=e.add}){const d=o??c.hint,u=s??c.search,[h,p]=b(""),m=w(),g=h.trim().toLowerCase(),x=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),y=t.map((e,t)=>({...e,key:x[t],tiles:g?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,g)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>a=>{if(t)a.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),a.dataTransfer.effectAllowed="copy";try{a.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
8
8
|
return C("div",{className:"es-add",children:[r?/* @__PURE__ */C("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */M("span",{children:r.label}),f(c.stop,/* @__PURE__ */M("button",{type:"button",className:"es-add-at-clear","aria-label":c.stop,onClick:r.onClear,children:/* @__PURE__ */M(T,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
10
10
|
/* @__PURE__ */M("p",{className:"es-add-hint",children:d}),
|
|
11
|
-
/* @__PURE__ */M("div",{className:"es-add-find",children:/* @__PURE__ */M(
|
|
11
|
+
/* @__PURE__ */M("div",{className:"es-add-find",children:/* @__PURE__ */M(A,{id:m,type:"search","aria-label":u,placeholder:c.searchPlaceholder({label:u}),value:h,onChange:e=>p(e.target.value),leftIcon:/* @__PURE__ */M($,{size:16,"aria-hidden":"true"}),rightAdornment:h?/* @__PURE__ */M(z,{size:"sm","aria-label":c.clearSearch,onClick:()=>p(""),children:/* @__PURE__ */M(T,{size:12,"aria-hidden":"true"})}):void 0})}),0===y.length?/* @__PURE__ */C("div",{className:"es-add-empty",role:"status",children:[
|
|
12
12
|
/* @__PURE__ */M("div",{className:"es-add-empty-title",children:c.nothing({query:h.trim()})}),
|
|
13
13
|
/* @__PURE__ */M("div",{className:"es-add-empty-sub",children:c.tryAnother})]}):y.map(e=>/* @__PURE__ */C("section",{className:"es-add-group","aria-label":e.title,children:[
|
|
14
14
|
/* @__PURE__ */C("div",{className:"es-add-group-head",children:[
|
|
15
15
|
/* @__PURE__ */M("span",{className:"es-add-group-title",children:e.title}),
|
|
16
16
|
/* @__PURE__ */M("span",{className:"es-add-group-count",children:e.tiles.length})]}),
|
|
17
17
|
/* @__PURE__ */M("div",{className:J(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(i||e.disabled),l=i?void 0:e.disabled?e.disabledReason:e.title??c.tile({label:e.label});return f(l,/* @__PURE__ */C("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":c.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a(e.type),children:[null!=e.cover?/* @__PURE__ */M("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */M("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
|
|
18
|
-
/* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,
|
|
18
|
+
/* @__PURE__ */M("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{U as AddPanel,W as CanvasDragLayer,S as CanvasInsert,P as EMPTY_MEASURE,G as HANDLE_GRACE_MS,q as canvasTarget,E as contains,X as gapInZone,K as gapLine,I as insertSeams,Z as measureCanvas,B as pickSource,O as seamsBetween,j as sourcesAt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useSectionOps as o}from"./chunk-
|
|
1
|
+
import{useSectionOps as o}from"./chunk-VF6TCI62.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-CWTAS5R6.js";import{useEasel as p}from"./chunk-K5744MTM.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=p(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),I?.(t)):i(o=>"part"===o.kind?n:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-
|
|
1
|
+
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-CWTAS5R6.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-JTUUIVBZ.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
|
|
2
2
|
/* @__PURE__ */o("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(a,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
3
3
|
return o(n,{align:"start",triggerClassName:"sf-add-card",items:u,trigger:/* @__PURE__ */c(i,{children:[
|
|
4
4
|
/* @__PURE__ */o("span",{className:"sf-plus sf-plus--sm",children:"+"}),m.addBlockMenu]})})}export{l as AddBlockRow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as t,useEffect as e,useRef as n}from"react";var o=/* @__PURE__ */new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function r(t){const e=t;if(!e||"string"!=typeof e.tagName)return!1;const n=e.tagName.toUpperCase();if("TEXTAREA"===n||"SELECT"===n)return!0;if("INPUT"===n)return!o.has(String(e.type??"text").toLowerCase());if(e.isContentEditable)return!0;const r=e.closest?.("[contenteditable]");return!(!r||"false"===r.getAttribute("contenteditable"))||null!=e.closest?.('[role="textbox"]')}var i="data-puck-component";function c(t,e=i){const n=t;return n&&"function"==typeof n.closest?n.closest(`[${e}]`)?.getAttribute(e)??null:null}function u(t){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{left:e.left,top:e.top,width:e.width,height:e.height};let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of Array.from(t.children)){const t=e.getBoundingClientRect();t.width<=0||t.height<=0||(n=Math.min(n,t.left),o=Math.min(o,t.top),r=Math.max(r,t.right??t.left+t.width),i=Math.max(i,t.bottom??t.top+t.height))}return n===1/0?{left:e.left,top:e.top,width:e.width,height:e.height}:{left:n,top:o,width:r-n,height:i-o}}function s(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function l(t,e,n){const o=t.getBoundingClientRect(),r=n?.getBoundingClientRect()??{left:0,top:0},i=s(t);return{left:o.left-r.left+e.left*i,top:o.top-r.top+e.top*i,width:e.width*i,height:e.height*i}}function d(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function a(t,e,n){const o=l(t,e,n),r=d(n);return{left:o.left/r,top:o.top/r,width:o.width/r,height:o.height/r}}function f(t,e,n){const o=t.getBoundingClientRect(),r=d(t);return{x:(e-o.left)/r,y:(n-o.top)/r}}function h(t,e,n,o){const{left:r,top:i}=l(t,{left:e,top:n,width:0,height:0},o);return{x:r,y:i}}function m({available:t,width:e,maxScale:n=1}){const o=Math.max(0,t);if(!e||e<=0)return{width:o,scale:1,shownWidth:o};const r=o>0?Math.min(o/e,n):1;return{width:e,scale:r,shownWidth:e*r}}var w="data-es-canvas-style",g=/* @__PURE__ */new WeakMap;function p(t,e){e?g.set(t,e):g.delete(t)}function b(t,e,n){const o=t.head??t.documentElement;let r=y(t,e);if(!r){r=t.createElement("style"),r.setAttribute(w,e);const n=g.get(t);n&&r.setAttribute("nonce",n),o.appendChild(r)}return r.textContent!==n&&(r.textContent=n),r}function v(t,e){y(t,e)?.remove()}function y(t,e){for(const n of Array.from(t.querySelectorAll(`style[${w}]`)))if(n.getAttribute(w)===e)return n;return null}var E="[data-puck-component]",A="[data-puck-dropzone]",C="iframe#preview-frame";function L(t){const e=t.contentDocument;if(!e||!t.contentWindow||"loading"===e.readyState||!e.body)return!1;if(t.hasAttribute("srcdoc"))return"about:srcdoc"===e.URL;const n=t.getAttribute("src");return!n||"about:blank"===n||"about:blank"!==e.URL}function x(t,e,{selector:n=C,readySelector:o}={}){let r=null,i=null,c=!1,u=!1,s=null;const l=()=>{s?.observer.disconnect(),s=null},d=()=>{if(u)return;let t=null;if(r&&L(r)){const e=r.contentDocument;(t=>{if(!o||t.querySelector(o))return l(),!0;if(s?.doc!==t){l();const e=t.defaultView?.MutationObserver;if(e){const n=new e(()=>d());n.observe(t,{childList:!0,subtree:!0}),s={doc:t,observer:n}}}return!1})(e)&&(t={frame:r,document:e,window:r.contentWindow})}else l();(t===i||!!t&&!!i&&t.frame===i.frame&&t.document===i.document)&&c||(c=!0,i=t,e(i))},a=()=>d(),f=()=>{const e=t.querySelector?.(n);e!==r?(r?.removeEventListener("load",a),r=e,r?.addEventListener("load",a),d()):d()},h=t.ownerDocument?.defaultView??t.defaultView,m=h?.MutationObserver,w=m?new m(t=>(t=>null!==r&&!r.isConnected||t.some(t=>[...t.addedNodes,...t.removedNodes].some(t=>"IFRAME"===t.nodeName||!!t.querySelector?.("iframe"))))(t)&&f()):null;return w?.observe(t,{childList:!0,subtree:!0}),f(),()=>{u=!0,w?.disconnect(),l(),r?.removeEventListener("load",a),r=null}}function M(n,{selector:o,readySelector:r}={}){const[i,c]=t(null);return e(()=>{const t=n.current;if(!t)return;const e=x(t,c,{selector:o,readySelector:r});return()=>{e(),c(null)}},[n,o,r]),i}var R="easel:canvas-typing";function S(t,o,r,{on:i="document",capture:c=!1}={}){const u=n(r);u.current=r;const s=t?.document??null,l=t?.window??null;e(()=>{const t="window"===i?l:s;if(!t)return;const e=t=>u.current(t);return t.addEventListener(o,e,c),()=>t.removeEventListener(o,e,c)},[s,l,o,i,c])}function k(t,n,o){const r=t?.document??null;e(()=>{if(!r)return;if(!o)return void v(r,n);const t=b(r,n,o),e=r.defaultView?.MutationObserver,i=e?new e(()=>{t.isConnected||b(r,n,o)}):null;return i?.observe(r.head??r.documentElement,{childList:!0}),()=>{i?.disconnect(),v(r,n)}},[r,n,o])}function B(n,{settle:o=[150,450]}={}){const[r,i]=t(0),c=n?.frame??null,u=n?.document??null,s=n?.window??null,l=o.join(",");return e(()=>{if(!c||!u||!s)return;const t=c.ownerDocument.defaultView;let e=!1,n=0;const r=()=>{if(e)return;e=!0;const o=()=>{e=!1,i(t=>t+1)};t?.requestAnimationFrame?n=t.requestAnimationFrame(o):o()},l=[],d=(t,e)=>{t.addEventListener(e,r,!0),l.push(()=>t.removeEventListener(e,r,!0))};d(u,"scroll"),d(s,"resize"),t&&(d(t,"scroll"),d(t,"resize"));const a=t?.ResizeObserver;if(a){const t=new a(r);t.observe(c),u.documentElement&&t.observe(u.documentElement),l.push(()=>t.disconnect())}const f=u.defaultView?.MutationObserver,h=u.body??u.documentElement;if(f&&h){const t=new f(r);t.observe(u===c.ownerDocument?c:h,{childList:!0,subtree:!0}),l.push(()=>t.disconnect())}const m=u.fonts;m&&d(m,"loadingdone");const w=o.map(t=>setTimeout(r,t));return r(),()=>{for(const t of l)t();for(const t of w)clearTimeout(t);n&&t?.cancelAnimationFrame&&t.cancelAnimationFrame(n)}},[c,u,s,l]),r}export{i as BLOCK_ATTRIBUTE,E as BLOCK_SELECTOR,C as CANVAS_SELECTOR,R as CANVAS_TYPING_EVENT,A as LIST_SELECTOR,f as clientPointToLayer,u as drawnBox,d as elementScale,m as fitCanvas,h as framePointToHost,l as frameRectToHost,a as frameRectToLayer,s as frameScale,L as isFrameReady,r as isTypingTarget,c as nodeIdAt,v as removeCanvasStyle,p as setCanvasNonce,b as upsertCanvasStyle,S as useCanvasEvent,M as useCanvasFrame,B as useCanvasLayout,k as useCanvasStyle,x as watchCanvasFrame};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-ECM5F6JJ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-WQASXLXS.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f,drawnBox as h}from"./chunk-ILXP5VX5.js";import{find as m,ROOT_ID as g,getList as v,remove as y,parseZoneKey as w,move as k,duplicate as b,replaceNode as S,createNode as I,insert as C,normalizeData as E,createResolveCache as x,resolveNodeData as D,ROOT_SLOT as O}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as A,fieldsFrom as P,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as z,useEffect as K,useContext as $,useRef as j,useSyncExternalStore as B,useState as L,useMemo as N,useCallback as R,useLayoutEffect as Z}from"react";import{jsx as V,jsxs as F}from"react/jsx-runtime";import{createPortal as T}from"react-dom";import{FloatingBar as H,TextToolbar as X}from"efficient-shell/ui";function W(e){return!["setData","setUi","set"].includes(e.type)}var Y=(e,t,n,o)=>{const r=v(e,t,w(n));return r?.[o]??null},q=(e,t,n,o,r)=>{const i=Y(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function J(e,t,n){return n?"node"===n.kind?m(e,t,n.id)?n:null:n.parentId===g?v(e,t,n)?n:null:m(e,t,n.parentId)&&v(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=_(e,t,n);if(o===e)return e;const r=J(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function _(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...w(t.destinationZone),index:t.destinationIndex},i=I(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=q(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:S(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=q(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),a=Y(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return _(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=Y(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...w(t.destinationZone),index:t.destinationIndex};return{...e,data:k(o,n,r.props.id,i)}}case"remove":{const r=q(o,n,t.zone,t.index,"remove");return{...e,data:y(o,n,r.props.id)}}default:return e}}var ee={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},te={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ne=0,oe=()=>`history-${ne+=1}`;function re(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=E(e.data,t);let l={data:s,selection:null,ui:{...te}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...te,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:oe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,g=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},b=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{g>0?w=w||n:(n?u(!1):l!==t&&b(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},C=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??W(e);I(n,o&&l.data!==n.data)},O=t=>{0===g&&(y=l,w=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(l=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&b(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=J(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},P=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ee,...a,...n}};let z=M();const K=x(),$={resolveCache:K,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([D(r,t,{cache:K,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:K,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=m(n,t,a)?.node;s&&s===m(o,t,a)?.node&&(n=S(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:J(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=m(l.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:K,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(m(l.data,t,e)?.node!==r)return;const o=S(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:J(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&h===l)return f;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?m(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:C,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&P(e)}},getPermissions:z,getItemById:n=>m(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return v(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:C,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:J(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=E(e,t);l={...l,data:r,selection:J(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0),l!==o&&k()},undo(){d>0&&P(d-1)},redo(){d<c.length-1&&P(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=M(),f=null,k())},setConfig(e){e!==t&&(t=e,z=M(),f=null,k())}};return $}function ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ae=z(null),se=z(!0);function le({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return K(()=>{n&&e.resolveAll()},[e,n]),K(()=>{if(t&&"undefined"!=typeof document)return ie(document,e)},[e,t]),/* @__PURE__ */V(ae.Provider,{value:e,children:/* @__PURE__ */V(se.Provider,{value:t,children:o})})}function ce(){const e=$(ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function de(e){const t=ce(),n=j({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return B(t.subscribe,o,o)}function ue(){return function(e){return de(e)}}var pe="data-puck-component",fe="data-puck-dropzone",he={},me="data-es-mirror",ge="undefined"==typeof window?K:Z;function ve(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${me}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(me,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ye({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=j(null),[h,m]=L(null);return ge(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),ge(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ve(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ve(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */V("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?T(t,h):null})}var we=z(null),ke=z(he),be=[];function Se({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ce(),s=de(n=>v(n.appState.data,a.config,{parentId:e,slot:t})??be),l=de(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==g),c=de(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=$(we),u=["es-zone"];return s.length&&u.push("has-children"),e===g&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==g&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */V("div",{className:u.join(" "),[fe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */V(Ee,{node:e},e.props.id))})}function Ie(e,t){return N(()=>{const n={};for(const o of A(P(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
|
+
return V(Se,{parentId:t,slot:o,...e})};return n},[e,t])}function Ce(e){return N(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return V(Se,{parentId:e,slot:t,...n})},[e])}function Ee({node:e}){const t=ce().config.components[e.type],n=e.props.id,o=function(e){const t=j(null);return N(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(pe),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(pe,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=$(ke),i=Ie(t,n),a=Ce(n);if(!t?.render)return null;const s=t.render,l={...M(t),...e.props,...i},c={renderDropZone:a,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */V(s,{...l,puck:c,editMode:!0}):/* @__PURE__ */V("div",{[pe]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */V(s,{...l,puck:c,editMode:!0})})}function xe({metadata:e}){const t=de(e=>e.config),n=de(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ie(t.root,g),i=Ce(g),a=/* @__PURE__ */V(Se,{parentId:g,slot:O}),s=o?/* @__PURE__ */V(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:a}):a;/* @__PURE__ */
|
|
4
|
+
return V(ke.Provider,{value:e??he,children:s})}var De=z(void 0);function Oe(e,t,n){const[o,r]=L(null),i=j(t);return i.current=t,ge(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=h(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Ae({id:e,kind:t,overlay:n}){const o=j(null),r=Oe(o,e?t=>t.querySelector(`[${pe}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */V("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */V(n,{componentId:e,kind:t,children:i}):i}function Pe(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Me({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
|
|
5
|
+
return V(H,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */V("div",{style:{width:"18rem"},children:/* @__PURE__ */V(X,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase})})})}function ze({element:e}){const t=j(null),n=Oe(t,()=>e(),e);/* @__PURE__ */
|
|
6
|
+
return V("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Ke({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w,passThrough:k}){const b=ce(),S=$(De),I=k??S,C=$(se),E=c("canvas",e),x=m??C,[D,O]=L(void 0),A=de(e=>"node"===e.selection?.kind?e.selection.id:null),[P,M]=L(null),[z,B]=L(null),N=j(null),[,R]=L(0),Z=j(w);Z.current=w;const T=j(null),H=e=>{const t=T.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},X=(e,t)=>{N.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=b.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Pe(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>R(e=>e+1),end:e=>{o.close(),N.current?.element===r&&(N.current=null),B(null),H(!1),Z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${pe}]`)?.getAttribute(pe);return a&&b.select(a),N.current={s:i,element:r,target:e},B(()=>r),M(null),H(!0),Z.current?.onChange?.({typing:!0,element:n}),!0};K(()=>()=>N.current?.s.stop("stop"),[]);const W=e=>{const t=N.current?.element();return Boolean(t&&t.contains(e))},Y=e=>{const t=e.closest?.(`[${pe}]`)?.getAttribute(pe);if(!t)return;const n=b.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,b.config,t,o,I)??t},q=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(N.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Z.current?.atSelection?.();n&&X(n,null)&&e.preventDefault()},U=/* @__PURE__ */F("div",{ref:T,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),N.current){if(W(t))return;N.current.s.stop("outside")}const n=Y(t);void 0===n?t.hasAttribute?.(fe)||b.select(null):b.select(n)},onDoubleClick:e=>{const t=Z.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&X(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>q(e),onMouseOver:e=>{if(N.current)return;const t=Y(e.target)??null;t!==P&&M(t)},onMouseLeave:()=>M(null),children:[
|
|
7
|
+
/* @__PURE__ */V(we.Provider,{value:P,children:/* @__PURE__ */V(xe,{metadata:r})}),
|
|
8
|
+
/* @__PURE__ */F("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
|
+
/* @__PURE__ */V(Ae,{id:!z&&P&&P!==A?P:null,kind:"hover",overlay:v}),
|
|
10
|
+
/* @__PURE__ */V(Ae,{id:z?null:A,kind:"selected",overlay:v}),z?/* @__PURE__ */V(ze,{element:z}):null]}),y]}),J=g?/* @__PURE__ */V(g,{document:D,children:U}):U;K(()=>{if(D&&x)return ie(D,b)},[D,x,b]),K(()=>{if(!D)return;const e=e=>{if("Enter"===e.key)return void q(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=b.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,b.config,n.selection);"node"===o?.kind&&b.select(o.id)};return D.addEventListener("keydown",e),()=>D.removeEventListener("keydown",e)},[D,b]);/* @__PURE__ */
|
|
11
|
+
return F("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":z?"":void 0,children:[z&&N.current?.target.toolbar?/* @__PURE__ */V(Me,{s:N.current.s,element:N.current.element,toolbar:N.current.target.toolbar,label:E.textTools}):null,t?/* @__PURE__ */V(ye,{mirrorStyles:l,onDocument:e=>{O(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:J}):/* @__PURE__ */V("div",{id:"preview-frame","data-puck-entry":"",children:J})]})}function $e(e={}){const t=ce(),n=de(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function je(){const e=ce(),n=de(e=>e.config),o=e.resolveCache,r=de(e=>e.selectedItem),i=de(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=N(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?m(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:a,node:l,block:c,parent:f,appState:d.appState}),g=de(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=R((t,r)=>{(async()=>{const i=e.getState();if("root"!==a){const s=i.getItemById(a),l=i.getSelectorForId(a);if(!s||!l)return;const c={...s,props:{...s.props,[t]:r}},{node:d}=await D(c,n,{cache:o,trigger:"replace"}),u=e.getState().getSelectorForId(a);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:d})}const s=i.appState.data.root.props??{},{node:l}=await D({type:"root",props:{...s,[t]:r}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:l.props,readOnly:l.readOnly},recordHistory:!0})})()},[e,n,o,a]);return{id:a,node:l,fields:h,values:l.props,readOnly:g,onChange:v}}export{ye as CanvasFrame,De as CanvasPassThroughContext,te as DEFAULT_UI,Ke as EaselCanvas,le as EaselProvider,xe as EditDocument,ie as bindUndoKeys,re as createEasel,ue as createUseEasel,W as recordsByDefault,G as reduce,U as uiView,de as useEasel,ce as useEaselApi,$e as useEaselNodeOps,je as useSelectedFields,J as validSelection};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,paletteWithoutPinned as o,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as i}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-XTJCKV6Z.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as a}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as p,useScreenBlockRules as m}from"./chunk-CWTAS5R6.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-JTUUIVBZ.js";import{useEasel as f}from"./chunk-K5744MTM.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as y}from"./chunk-O2NLQBFX.js";import{useState as h,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as $,jsxs as B,Fragment as O}from"react/jsx-runtime";var v=e=>`section:${e}`,L=e=>`block:${e}`,T=e=>`template:${e}`;function V({blocks:V,blocksOnly:x,at:A,sectionAccepts:C,onAdd:I,itemFor:N,session:F,siteWide:H,onClose:R,onHide:W,readOnly:w}){const D=f(e=>e.config),J=p(),{labelAtLevel:K,categoryLabel:M,firstSection:Q,Icon:S,Thumbnail:Z}=J,{blockIsOffered:z}=m(),E=u("screen",d).add,P=u("drag",y).add,U=l(),[X,Y]=h([]);b(()=>{let e=!1;const t=e=>z(e,U);return s(U).list().then(o=>{if(e)return;const n=D.components;Y(o.filter(e=>e.node?.type&&n[e.node.type]&&i(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[D,U]);const G=j(()=>e(D,J),[D]),q=e=>({type:v(e.type),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:E.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),_=j(()=>{const e=[];if(V&&V.choices.length>0&&a(V.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${E.inside({name:V.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:L(e.type),label:e.label,icon:/* @__PURE__ */$(S,{type:e.type,size:18}),title:E.tile({name:e.label})}))})}),x)return e;const i=e=>!C||C(e),s=t(G,Q);s&&i(s.type)&&e.push({key:"start",title:E.startBlank,tiles:[q(s)]});const r=X.filter(e=>i(e.node.type));r.length>0&&e.push({key:"templates",title:E.templates,tiles:r.map(e=>{return{type:T(e.id),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.node.type}),keywords:[(t=e.node.type,K(t,"section",D.components[t]?.label??t)),e.node.type]};var t})});const c=o(G,Q);for(const t of Object.keys(D.categories??{})){const o=c.filter(e=>e.cat===t&&i(e.type));0!==o.length&&e.push({key:`category:${t}`,title:n(D,t,M),tiles:o.map(q)})}return e},[V,x,X,G,D,E,C]),ee=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=X.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
|
|
2
|
+
return B(O,{children:[
|
|
3
|
+
/* @__PURE__ */$(r,{icon:/* @__PURE__ */$(g,{size:15}),title:E.title,context:x?E.contextBlocks:E.contextAll,actions:/* @__PURE__ */$(c,{label:E.done,description:E.doneDescription,onClick:R}),onHide:W}),
|
|
4
|
+
/* @__PURE__ */B("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
+
/* @__PURE__ */$(k,{groups:_,session:F,itemFor:e=>N(ee(e)??{kind:"section",type:e}),onInsert:e=>{const t=ee(e);t&&I(t)},at:A,hint:x?E.hintBlocks:E.hint,searchLabel:x?E.searchBlocks:E.searchSections,readOnly:w,words:P}),H&&!x?H:null]})]})}export{V as AddSidePanel,L as blockKey,v as sectionKey,T as templateKey};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useScreenOwnerName as e}from"./chunk-
|
|
1
|
+
import{useScreenOwnerName as e}from"./chunk-CWTAS5R6.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-QVUVDBGA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
|
|
2
2
|
return o(r,{children:[
|
|
3
3
|
/* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
|
|
4
4
|
/* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-K5744MTM.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};
|