efficient-easel 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.d.ts +14 -2
- package/dist/canvas/index.js +1 -1
- package/dist/canvas-typing-Dec_zyuM.d.ts +49 -0
- package/dist/chunk-AWJUYMX7.js +1 -0
- package/dist/chunk-AYNU4FYF.js +14 -0
- package/dist/chunk-B4ZNYLZX.js +5 -0
- package/dist/{chunk-MTG37BOC.js → chunk-CJBU4E4L.js} +1 -1
- package/dist/{chunk-O7IPFJGX.js → chunk-DQLK3QQ2.js} +1 -1
- package/dist/chunk-DSUMM2WF.js +10 -0
- package/dist/chunk-EXCKAZKN.js +5 -0
- package/dist/{chunk-IH2O5CZO.js → chunk-H3WBX7FN.js} +1 -1
- package/dist/chunk-HAUTMX4H.js +65 -0
- package/dist/{chunk-B6WEYEMH.js → chunk-I6U2G7L4.js} +1 -1
- package/dist/chunk-JIWPANGM.js +1 -0
- package/dist/chunk-LVUDUQNL.js +1 -0
- package/dist/{chunk-U32MAI4R.js → chunk-PRRFBVJ2.js} +3 -3
- package/dist/{chunk-7WAC3IXR.js → chunk-QPQXKKSC.js} +1 -1
- package/dist/chunk-T5HFGW57.js +1 -0
- package/dist/{chunk-CRWFB7MU.js → chunk-X4OF36J2.js} +11 -11
- package/dist/copy/index.d.ts +73 -16
- package/dist/copy/index.js +18 -18
- package/dist/drag/index.js +1 -1
- package/dist/easel/easel.css +17 -0
- package/dist/easel/index.d.ts +47 -2
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7XFNHML2.js +0 -1
- package/dist/chunk-BVKNVCGX.js +0 -9
- package/dist/chunk-LSBQ74U4.js +0 -65
- package/dist/chunk-MOCX5MQ7.js +0 -14
- package/dist/chunk-MTRFMGBO.js +0 -1
- package/dist/chunk-PAELDYYS.js +0 -1
- package/dist/chunk-TNV2BVL2.js +0 -5
- package/dist/chunk-VOKBME2Y.js +0 -5
- package/dist/chunk-ZNCEOSXO.js +0 -1
package/dist/canvas/index.d.ts
CHANGED
|
@@ -153,7 +153,19 @@ declare function removeCanvasStyle(doc: Document, key: string): void;
|
|
|
153
153
|
* or its document actually changes (a Refresh remount, a document swap).
|
|
154
154
|
*/
|
|
155
155
|
declare function useCanvasFrame(rootRef: RefObject<Element | null>, { selector, readySelector }?: WatchOptions): CanvasTarget | null;
|
|
156
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Said on the canvas document when typing on the canvas starts or stops
|
|
158
|
+
* (`EaselCanvas`'s `typing`): what floats over the canvas for blocks — the
|
|
159
|
+
* drag handle and its name — stands down while words are typed, so nothing
|
|
160
|
+
* sits on the words (Lewis 2026-10-14).
|
|
161
|
+
*/
|
|
162
|
+
declare const CANVAS_TYPING_EVENT = "easel:canvas-typing";
|
|
163
|
+
type CanvasTypingEvent = CustomEvent<{
|
|
164
|
+
typing: boolean;
|
|
165
|
+
}>;
|
|
166
|
+
type CanvasEventMap = DocumentEventMap & WindowEventMap & {
|
|
167
|
+
[CANVAS_TYPING_EVENT]: CanvasTypingEvent;
|
|
168
|
+
};
|
|
157
169
|
/**
|
|
158
170
|
* Listen for `type` in the canvas — on its document (default) or its window.
|
|
159
171
|
* Re-binds when the canvas document is replaced, and always calls the LATEST
|
|
@@ -191,4 +203,4 @@ declare function useCanvasLayout(canvas: CanvasTarget | null, { settle }?: {
|
|
|
191
203
|
settle?: readonly number[];
|
|
192
204
|
}): number;
|
|
193
205
|
|
|
194
|
-
export { BLOCK_ATTRIBUTE, type Box, type CanvasFit, CanvasTarget, WatchOptions, clientPointToLayer, elementScale, fitCanvas, framePointToHost, frameRectToHost, frameRectToLayer, frameScale, isTypingTarget, nodeIdAt, removeCanvasStyle, setCanvasNonce, upsertCanvasStyle, useCanvasEvent, useCanvasFrame, useCanvasLayout, useCanvasStyle };
|
|
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 };
|
package/dist/canvas/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{BLOCK_SELECTOR,CANVAS_SELECTOR,LIST_SELECTOR,
|
|
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-AWJUYMX7.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { InlineRule } from './markup/index.js';
|
|
2
|
+
|
|
3
|
+
interface TextMap {
|
|
4
|
+
/** The words as drawn: text in order, a `<br>` or a new block line as `\n`. */
|
|
5
|
+
text: string;
|
|
6
|
+
/** The visible offset of a DOM point inside the root. */
|
|
7
|
+
at: (node: Node, offset: number) => number;
|
|
8
|
+
/** The DOM point of a visible offset. */
|
|
9
|
+
dom: (v: number) => [Node, number];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read the words a renderer drew, whatever its markup: text nodes in order;
|
|
13
|
+
* a `<br>` is a line break, and so is the start of a block-level child after
|
|
14
|
+
* some words (a line the renderer drew as its own block).
|
|
15
|
+
*/
|
|
16
|
+
declare function textMap(root: HTMLElement): TextMap;
|
|
17
|
+
/** Why typing ended. */
|
|
18
|
+
type CanvasTypingEnd = 'escape' | 'enter' | 'blur' | 'outside' | 'stop';
|
|
19
|
+
interface CanvasTypingOptions {
|
|
20
|
+
/** The element the page drew the words in. Read again after every redraw:
|
|
21
|
+
* a host that draws them afresh may hand back a new one. */
|
|
22
|
+
element: () => HTMLElement | null;
|
|
23
|
+
/** The saved string. */
|
|
24
|
+
value: string;
|
|
25
|
+
rules: readonly InlineRule[];
|
|
26
|
+
/** The field has lines: Shift+Enter makes one. */
|
|
27
|
+
multiline: boolean;
|
|
28
|
+
/** The visible selection to start with. */
|
|
29
|
+
caret: [number, number];
|
|
30
|
+
/** The host's ONE writer — the same the panel's text box writes through. */
|
|
31
|
+
write: (next: string) => void;
|
|
32
|
+
/** Typing ended; the words are what was last written. */
|
|
33
|
+
end: (why: CanvasTypingEnd) => void;
|
|
34
|
+
/** The browser wrote into the words (a composition): draw them afresh. */
|
|
35
|
+
remount?: () => void;
|
|
36
|
+
now?: () => number;
|
|
37
|
+
}
|
|
38
|
+
interface CanvasTypingSession {
|
|
39
|
+
/** The string as the session last wrote or was told. */
|
|
40
|
+
readonly value: string;
|
|
41
|
+
/** The host wrote the string from elsewhere (the panel's text box). */
|
|
42
|
+
update: (next: string) => void;
|
|
43
|
+
/** End typing. Once: a second call does nothing. */
|
|
44
|
+
stop: (why?: CanvasTypingEnd) => void;
|
|
45
|
+
}
|
|
46
|
+
/** Start typing in the words `element()` drew, or `null` where they are not the string's. */
|
|
47
|
+
declare function startCanvasTyping(o: CanvasTypingOptions): CanvasTypingSession | null;
|
|
48
|
+
|
|
49
|
+
export { type CanvasTypingEnd as C, type TextMap as T, type CanvasTypingOptions as a, type CanvasTypingSession as b, startCanvasTyping as s, textMap as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as e,useEffect as t,useRef as n}from"react";var o=/* @__PURE__ */new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function r(e){const t=e;if(!t||"string"!=typeof t.tagName)return!1;const n=t.tagName.toUpperCase();if("TEXTAREA"===n||"SELECT"===n)return!0;if("INPUT"===n)return!o.has(String(t.type??"text").toLowerCase());if(t.isContentEditable)return!0;const r=t.closest?.("[contenteditable]");return!(!r||"false"===r.getAttribute("contenteditable"))||null!=t.closest?.('[role="textbox"]')}var c="data-puck-component";function i(e,t=c){const n=e;return n&&"function"==typeof n.closest?n.closest(`[${t}]`)?.getAttribute(t)??null:null}function u(e){const t=e.offsetWidth;if(!t)return 1;const n=e.getBoundingClientRect().width;return n>0?n/t:1}function s(e,t,n){const o=e.getBoundingClientRect(),r=n?.getBoundingClientRect()??{left:0,top:0},c=u(e);return{left:o.left-r.left+t.left*c,top:o.top-r.top+t.top*c,width:t.width*c,height:t.height*c}}function l(e){const t=e.offsetWidth;if(!t)return 1;const n=e.getBoundingClientRect().width;return n>0?n/t:1}function a(e,t,n){const o=s(e,t,n),r=l(n);return{left:o.left/r,top:o.top/r,width:o.width/r,height:o.height/r}}function d(e,t,n){const o=e.getBoundingClientRect(),r=l(e);return{x:(t-o.left)/r,y:(n-o.top)/r}}function f(e,t,n,o){const{left:r,top:c}=s(e,{left:t,top:n,width:0,height:0},o);return{x:r,y:c}}function m({available:e,width:t,maxScale:n=1}){const o=Math.max(0,e);if(!t||t<=0)return{width:o,scale:1,shownWidth:o};const r=o>0?Math.min(o/t,n):1;return{width:t,scale:r,shownWidth:t*r}}var h="data-es-canvas-style",w=/* @__PURE__ */new WeakMap;function b(e,t){t?w.set(e,t):w.delete(e)}function v(e,t,n){const o=e.head??e.documentElement;let r=g(e,t);if(!r){r=e.createElement("style"),r.setAttribute(h,t);const n=w.get(e);n&&r.setAttribute("nonce",n),o.appendChild(r)}return r.textContent!==n&&(r.textContent=n),r}function p(e,t){g(e,t)?.remove()}function g(e,t){for(const n of Array.from(e.querySelectorAll(`style[${h}]`)))if(n.getAttribute(h)===t)return n;return null}var y="[data-puck-component]",E="[data-puck-dropzone]",A="iframe#preview-frame";function L(e){const t=e.contentDocument;if(!t||!e.contentWindow||"loading"===t.readyState||!t.body)return!1;if(e.hasAttribute("srcdoc"))return"about:srcdoc"===t.URL;const n=e.getAttribute("src");return!n||"about:blank"===n||"about:blank"!==t.URL}function C(e,t,{selector:n=A,readySelector:o}={}){let r=null,c=null,i=!1,u=!1,s=null;const l=()=>{s?.observer.disconnect(),s=null},a=()=>{if(u)return;let e=null;if(r&&L(r)){const t=r.contentDocument;(e=>{if(!o||e.querySelector(o))return l(),!0;if(s?.doc!==e){l();const t=e.defaultView?.MutationObserver;if(t){const n=new t(()=>a());n.observe(e,{childList:!0,subtree:!0}),s={doc:e,observer:n}}}return!1})(t)&&(e={frame:r,document:t,window:r.contentWindow})}else l();(e===c||!!e&&!!c&&e.frame===c.frame&&e.document===c.document)&&i||(i=!0,c=e,t(c))},d=()=>a(),f=()=>{const t=e.querySelector?.(n);t!==r?(r?.removeEventListener("load",d),r=t,r?.addEventListener("load",d),a()):a()},m=e.ownerDocument?.defaultView??e.defaultView,h=m?.MutationObserver,w=h?new h(e=>(e=>null!==r&&!r.isConnected||e.some(e=>[...e.addedNodes,...e.removedNodes].some(e=>"IFRAME"===e.nodeName||!!e.querySelector?.("iframe"))))(e)&&f()):null;return w?.observe(e,{childList:!0,subtree:!0}),f(),()=>{u=!0,w?.disconnect(),l(),r?.removeEventListener("load",d),r=null}}function S(n,{selector:o,readySelector:r}={}){const[c,i]=e(null);return t(()=>{const e=n.current;if(!e)return;const t=C(e,i,{selector:o,readySelector:r});return()=>{t(),i(null)}},[n,o,r]),c}var x="easel:canvas-typing";function R(e,o,r,{on:c="document",capture:i=!1}={}){const u=n(r);u.current=r;const s=e?.document??null,l=e?.window??null;t(()=>{const e="window"===c?l:s;if(!e)return;const t=e=>u.current(e);return e.addEventListener(o,t,i),()=>e.removeEventListener(o,t,i)},[s,l,o,c,i])}function M(e,n,o){const r=e?.document??null;t(()=>{if(!r)return;if(!o)return void p(r,n);const e=v(r,n,o),t=r.defaultView?.MutationObserver,c=t?new t(()=>{e.isConnected||v(r,n,o)}):null;return c?.observe(r.head??r.documentElement,{childList:!0}),()=>{c?.disconnect(),p(r,n)}},[r,n,o])}function k(n,{settle:o=[150,450]}={}){const[r,c]=e(0),i=n?.frame??null,u=n?.document??null,s=n?.window??null,l=o.join(",");return t(()=>{if(!i||!u||!s)return;const e=i.ownerDocument.defaultView;let t=!1,n=0;const r=()=>{if(t)return;t=!0;const o=()=>{t=!1,c(e=>e+1)};e?.requestAnimationFrame?n=e.requestAnimationFrame(o):o()},l=[],a=(e,t)=>{e.addEventListener(t,r,!0),l.push(()=>e.removeEventListener(t,r,!0))};a(u,"scroll"),a(s,"resize"),e&&(a(e,"scroll"),a(e,"resize"));const d=e?.ResizeObserver;if(d){const e=new d(r);e.observe(i),u.documentElement&&e.observe(u.documentElement),l.push(()=>e.disconnect())}const f=u.defaultView?.MutationObserver,m=u.body??u.documentElement;if(f&&m){const e=new f(r);e.observe(u===i.ownerDocument?i:m,{childList:!0,subtree:!0}),l.push(()=>e.disconnect())}const h=u.fonts;h&&a(h,"loadingdone");const w=o.map(e=>setTimeout(r,e));return r(),()=>{for(const e of l)e();for(const e of w)clearTimeout(e);n&&e?.cancelAnimationFrame&&e.cancelAnimationFrame(n)}},[i,u,s,l]),r}export{c as BLOCK_ATTRIBUTE,y as BLOCK_SELECTOR,A as CANVAS_SELECTOR,x as CANVAS_TYPING_EVENT,E as LIST_SELECTOR,d as clientPointToLayer,l as elementScale,m as fitCanvas,f as framePointToHost,s as frameRectToHost,a as frameRectToLayer,u as frameScale,L as isFrameReady,r as isTypingTarget,i as nodeIdAt,p as removeCanvasStyle,b as setCanvasNonce,v as upsertCanvasStyle,R as useCanvasEvent,S as useCanvasFrame,k as useCanvasLayout,M as useCanvasStyle,C as watchCanvasFrame};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-O2NLQBFX.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}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-AWJUYMX7.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 y,useCallback as b,useMemo as v,useSyncExternalStore as x,useId as k,useLayoutEffect as w}from"react";import{Tooltip as N,Input as A,IconButton as z}from"efficient-shell/ui";import{jsxs as D,jsx as T}from"react/jsx-runtime";import{CloseIcon as C,SearchIcon as $}from"efficient-shell/icons/efficient";var S=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,E=e=>e.width*e.height;function L(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>S(e.box,t,n)).sort((e,t)=>E(t.s.box)-E(e.s.box)||e.at-t.at).map(({s:e})=>e)}function M(e,t,n){return L(e,t,n).at(-1)??null}function j(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function B(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,o=r??l??e.box;return{left:a-1,top:o.top,width:2,height:o.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function K(e,t,n,l,r=()=>!1,a=()=>!0){const o=e.filter(e=>S(e.box,t,n)).sort((e,t)=>E(e.box)-E(t.box));for(const e of o){const o=j(e,t,n),s={...e.list,index:o};if(r(s))return null;if(l(s))return{zone:e,to:s,line:B(e,o)};if(!a(s))return null}return null}function X(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],o=r.top+r.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(a.top-o,0)}})}return n}var q={nodes:[],zones:[]},O="data-puck-dropzone",P="data-puck-component";function F(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 R(e,t){const{frame:n,document:l}=e,r=e=>u(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),a=[],o=[];for(const e of l.querySelectorAll(`[${O}]`)){const t=e.getAttribute(O)??"";let n;try{n=p(t)}catch{continue}const l=[...e.querySelectorAll(`[${P}]`)].filter(t=>t.parentElement?.closest(`[${O}]`)===e),s=l.map(r);o.push({key:t,list:n,box:r(e),axis:F(s,e),children:s}),l.forEach((e,t)=>{const l=e.getAttribute(P);l&&a.push({id:l,place:{...n,index:t},box:s[t]})})}return{nodes:a,zones:o}}var Y="data-es-empty-cell",Z="data-puck-dropzone",I=140;var Q=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function V(u){const{canvas:f,session:p,readOnly:k,words:A=e.canvas}=u,z=m(u);g(()=>{z.current=u});const C=m(null),$=o(f),[S,E]=y(0),M=b(()=>E(e=>e+1),[]),[j,B]=y(q);g(()=>{const e=C.current;f&&e&&B((z.current.measure??R)(f,e))},[f,$,u.revision,S]);const X=u.model,O=v(()=>X(j),[X,j]),P=x(p.subscribe,p.shown,p.shown),F=u.choose,I=(e,t)=>{const n=L(O.sources,e,t);return 0===n.length?null:F?F(n):n[n.length-1]},[V,W]=y(null),[G,H]=y(null),J=m(null),U=()=>{J.current&&clearTimeout(J.current),J.current=null},_=()=>{U(),J.current=setTimeout(()=>{p.get()||W(null)},140)};g(()=>U,[]);const ee=m(null),te=m(!1);s(f,i,e=>{te.current=Boolean(e.detail?.typing),te.current&&(U(),W(null))}),s(f,"mousemove",e=>{const t=C.current;if(!f||!t)return;const n=c(f.frame,e.clientX,e.clientY,t),l=d(t),r={x:n.x/l,y:n.y/l};if(ee.current=r,z.current.readOnly||p.get()||te.current)return;U();const a=I(r.x,r.y);W(e=>e?.key===a?.key&&e?.box===a?.box?e:a)}),s(f,"mouseout",e=>{e.relatedTarget||(ee.current=null,_())}),s(f,"mouseover",e=>{e.relatedTarget||M()});const ne=m(null),le=b(()=>{ne.current?.(),ne.current=null,H(null)},[]);g(()=>p.subscribe(()=>{p.get()?M():le()}),[p,le,M]),g(()=>le,[le]),("undefined"==typeof document?g:w)(()=>{if(p.get())return;const e=ee.current;W(t=>k?null:e?I(e.x,e.y):t?O.sources.find(e=>e.key===t.key)??null:null)},[O,P,p,k,F]);const re=e=>{const t=p.get(),n=C.current;if(!t||!n)return null;const l=h(n,e.clientX,e.clientY);ee.current=l;const r=K(O.zones,l.x,l.y,e=>z.current.canDrop(t.item,e),e=>!!t.from&&a(t.from,e),e=>z.current.fallThrough?.(t.item,e,t.from)??!0);return r?{h:t,t:r}:null},ae={onDragEnter:e=>{if(ne.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),a=f?l(f.document):null,o=[];t&&o.push(r(t)),a&&f&&o.push(r(a,f.frame)),ne.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=re(e);if(!n)return void H(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};H(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)||(ee.current=null,H(null))},onDrop:e=>{const t=re(e);t&&(e.preventDefault(),p.end(),le(),z.current.onDrop(t.h.item,t.t.to))}},oe={draggable:!k&&!!V,onMouseEnter:U,onMouseLeave:()=>!p.get()&&_(),onDragStart:e=>{if(V&&!k){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(),le()},onClick:()=>{V&&!k&&z.current.onPick?.(V.item)}},{seams:se=[]}=O,ie=O.zones.filter(e=>0===e.children.length),ce=u.onZoneAdd&&!k?ie:[],de=ce.map(e=>e.key).join("\n");return g(()=>{const e=f?.document;if(!e)return;const t=new Set(de?de.split("\n"):[]);for(const n of e.querySelectorAll(`[${Z}]`))n.toggleAttribute(Y,t.has(n.getAttribute(Z)??""));return()=>{for(const t of e.querySelectorAll(`[${Y}]`))t.removeAttribute(Y)}},[f,de,j,$,S]),/* @__PURE__ */D("div",{ref:C,className:"es-canvas-layer",children:[P||!u.onSeamAdd||k?null:se.map(e=>/* @__PURE__ */T("div",{className:"es-canvas-seam",style:{left:e.box.left,top:e.box.top+e.box.height/2-8,width:e.box.width,height:16},children:/* @__PURE__ */T("button",{type:"button",className:"es-canvas-seam-add",onClick:()=>u.onSeamAdd?.(e.place),children:A.addButton({label:u.seamLabel??A.addSection})})},e.key)),ce.length?ce.map(e=>/* @__PURE__ */T("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",G?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:Q(e.box),onClick:()=>u.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */T("span",{className:"es-canvas-empty-add",children:A.addButton({label:e.addLabel??u.zoneAddLabel??A.addBlock})})},e.key)):null,P?/* @__PURE__ */T("div",{className:"es-canvas-catch",...ae}):null,G&&!ie.some(e=>e.key===G.zoneKey)?/* @__PURE__ */T("div",{className:`es-canvas-line is-${G.axis}`,style:Q(G.line)}):null,
|
|
2
|
+
/* @__PURE__ */T("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__ */T(N,{className:"es-canvas-handle-tip",side:"top",content:!V||k||P?null:V.title??A.handle({label:V.label}),children:/* @__PURE__ */D("div",{className:["es-canvas-handle",V&&!k?"is-shown":"",P?"is-dragging":""].filter(Boolean).join(" "),...oe,children:[
|
|
3
|
+
/* @__PURE__ */T("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var W=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function G({groups:t,session:n,itemFor:l,onInsert:r,at:a,hint:o,searchLabel:s,readOnly:i,words:c=e.add}){const d=o??c.hint,u=s??c.search,[h,p]=y(""),m=k(),g=h.trim().toLowerCase(),b=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),v=t.map((e,t)=>({...e,key:b[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),x=(e,t)=>r=>{if(t)r.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),r.dataTransfer.effectAllowed="copy";try{r.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
4
|
+
return D("div",{className:"es-add",children:[a?/* @__PURE__ */D("div",{className:"es-add-at",role:"status",children:[
|
|
5
|
+
/* @__PURE__ */T("span",{children:a.label}),f(c.stop,/* @__PURE__ */T("button",{type:"button",className:"es-add-at-clear","aria-label":c.stop,onClick:a.onClear,children:/* @__PURE__ */T(C,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
6
|
+
/* @__PURE__ */T("p",{className:"es-add-hint",children:d}),
|
|
7
|
+
/* @__PURE__ */T("div",{className:"es-add-find",children:/* @__PURE__ */T(A,{id:m,type:"search","aria-label":u,placeholder:c.searchPlaceholder({label:u}),value:h,onChange:e=>p(e.target.value),leftIcon:/* @__PURE__ */T($,{size:16,"aria-hidden":"true"}),rightAdornment:h?/* @__PURE__ */T(z,{size:"sm","aria-label":c.clearSearch,onClick:()=>p(""),children:/* @__PURE__ */T(C,{size:12,"aria-hidden":"true"})}):void 0})}),0===v.length?/* @__PURE__ */D("div",{className:"es-add-empty",role:"status",children:[
|
|
8
|
+
/* @__PURE__ */T("div",{className:"es-add-empty-title",children:c.nothing({query:h.trim()})}),
|
|
9
|
+
/* @__PURE__ */T("div",{className:"es-add-empty-sub",children:c.tryAnother})]}):v.map(e=>/* @__PURE__ */D("section",{className:"es-add-group","aria-label":e.title,children:[
|
|
10
|
+
/* @__PURE__ */D("div",{className:"es-add-group-head",children:[
|
|
11
|
+
/* @__PURE__ */T("span",{className:"es-add-group-title",children:e.title}),
|
|
12
|
+
/* @__PURE__ */T("span",{className:"es-add-group-count",children:e.tiles.length})]}),
|
|
13
|
+
/* @__PURE__ */T("div",{className:W(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__ */D("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:x(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&r(e.type),children:[null!=e.cover?/* @__PURE__ */T("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */T("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
|
|
14
|
+
/* @__PURE__ */T("span",{className:"es-add-tile-label",children:e.label})]},e.type))})})]},e.key))]})}export{G as AddPanel,V as CanvasDragLayer,q as EMPTY_MEASURE,I as HANDLE_GRACE_MS,K as canvasTarget,S as contains,j as gapInZone,B as gapLine,R as measureCanvas,M as pickSource,X as seamsBetween,L as sourcesAt};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{blockTypesIn as e}from"./chunk-5ZBY24K7.js";import{buildPaletteSections as t,pinnedSection as o,paletteWithoutPinned as n,categoryLabel as i}from"./chunk-PA3PNTVV.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-PFNIVZPN.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-EXCKAZKN.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-MCHMF32I.js";import{useEasel as f}from"./chunk-DSUMM2WF.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-AYNU4FYF.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-O2NLQBFX.js";import{useState as y,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as $,jsxs as F,Fragment as N}from"react/jsx-runtime";var B=e=>`section:${e}`,O=e=>`block:${e}`,v=e=>`template:${e}`;function I({blocks:I,blocksOnly:x,at:A,onAdd:V,itemFor:C,session:H,siteWide:L,onClose:M,onHide:D,readOnly:P}){const Y=f(e=>e.config),w=p(),{labelAtLevel:K,categoryLabel:Q,firstSection:R,Icon:S,Thumbnail:T}=w,{blockIsOffered:W}=m(),Z=u("screen",d).add,z=u("drag",h).add,E=l(),[U,X]=y([]);b(()=>{let t=!1;const o=e=>W(e,E);return s(E).list().then(n=>{if(t)return;const i=Y.components;X(n.filter(t=>t.node?.type&&i[t.node.type]&&e(t.node).every(o)))}).catch(()=>{}),()=>{t=!0}},[Y,E]);const G=j(()=>t(Y,w),[Y]),J=e=>({type:B(e.type),label:e.name,cover:/* @__PURE__ */$(T,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:Z.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),q=j(()=>{const e=[];if(I&&I.choices.length>0&&a(I.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${Z.inside({name:I.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:O(e.type),label:e.label,icon:/* @__PURE__ */$(S,{type:e.type,size:18}),title:Z.tile({name:e.label})}))})}),x)return e;const t=o(G,R);t&&e.push({key:"start",title:Z.startBlank,tiles:[J(t)]}),U.length>0&&e.push({key:"templates",title:Z.templates,tiles:U.map(e=>{return{type:v(e.id),label:e.name,cover:/* @__PURE__ */$(T,{type:e.node.type}),keywords:[(t=e.node.type,K(t,"section",Y.components[t]?.label??t)),e.node.type]};var t})});const s=n(G,R);for(const t of Object.keys(Y.categories??{})){const o=s.filter(e=>e.cat===t);0!==o.length&&e.push({key:`category:${t}`,title:i(Y,t,Q),tiles:o.map(J)})}return e},[I,x,U,G,Y,Z]),_=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=U.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
|
|
2
|
+
return F(N,{children:[
|
|
3
|
+
/* @__PURE__ */$(r,{icon:/* @__PURE__ */$(g,{size:15}),title:Z.title,context:x?Z.contextBlocks:Z.contextAll,actions:/* @__PURE__ */$(c,{label:Z.done,description:Z.doneDescription,onClick:M}),onHide:D}),
|
|
4
|
+
/* @__PURE__ */F("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
+
/* @__PURE__ */$(k,{groups:q,session:H,itemFor:e=>C(_(e)??{kind:"section",type:e}),onInsert:e=>{const t=_(e);t&&V(t)},at:A,hint:x?Z.hintBlocks:Z.hint,searchLabel:x?Z.searchBlocks:Z.searchSections,readOnly:P,words:z}),L&&!x?L:null]})]})}export{I as AddSidePanel,O as blockKey,B as sectionKey,v as templateKey};
|
|
@@ -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-EXCKAZKN.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-MCHMF32I.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useScreenOwnerName as e}from"./chunk-
|
|
1
|
+
import{useScreenOwnerName as e}from"./chunk-EXCKAZKN.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-UB4TLWVJ.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};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-AELNNAFM.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-UK2FQOUT.js";import{startCanvasTyping as s,textMap as l}from"./chunk-JIWPANGM.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,CANVAS_TYPING_EVENT as p}from"./chunk-AWJUYMX7.js";import{find as f,ROOT_ID as m,getList as h,remove as v,parseZoneKey as y,move as g,duplicate as k,replaceNode as w,createNode as b,insert as S,normalizeData as I,createResolveCache as C,resolveNodeData as E,ROOT_SLOT as x}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as D,fieldsFrom as O,defaultsFrom as A}from"./chunk-NKB3KVAB.js";import{createContext as M,useEffect as P,useContext as N,useRef as z,useSyncExternalStore as K,useState as $,useMemo as j,useCallback as Z,useLayoutEffect as R}from"react";import{jsx as B,jsxs as L}from"react/jsx-runtime";import{createPortal as F}from"react-dom";function V(e){return!["setData","setUi","set"].includes(e.type)}var H=(e,t,n,o)=>{const r=h(e,t,y(n));return r?.[o]??null},T=(e,t,n,o,r)=>{const i=H(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 W(e,t,n){return n?"node"===n.kind?f(e,t,n.id)?n:null:n.parentId===m?h(e,t,n)?n:null:f(e,t,n.parentId)&&h(e,t,n)?n:null:null}function Y(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 q(e,t,n){const o=X(e,t,n);if(o===e)return e;const r=W(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function X(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 Y(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=Y(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=b(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:S(o,n,r,i)}}case"replace":{const r=T(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:w(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=T(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=H(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return X(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=H(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:g(o,n,r.props.id,i)}}case"remove":{const r=T(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var G={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},J={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Q=0,_=()=>`history-${Q+=1}`;function ee(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=I(e.data,t);let l={data:s,selection:null,ui:{...J}};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:{...J,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:_()}],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:_()}],d=c.length-1)},p=/* @__PURE__ */new Set;let m=null,v=null,y=0,g=null,k=!1;const b=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},x=(t,n)=>{y>0?k=k||n:(n?u(!1):l!==t&&S(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&b())},D=e=>{const n=l;if(l=q(l,e,t),l===n)return;const o=e.recordHistory??V(e);x(n,o&&l.data!==n.data)},O=t=>{0===y&&(g=l,k=!1),y+=1;try{t()}catch(e){throw y-=1,0===y&&g&&(l=g,g=null),e}if(y-=1,y>0||!g)return;const n=g;g=null,k&&l.data!==n.data?u(!0):l!==n&&S(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&b()},A=e=>{const n=l,o=W(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},x(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&b()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...G,...a,...n}};let N=P();const z=C(),K={resolveCache:z,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([E(r,t,{cache:z,trigger:e,metadata:n}),...i.map(o=>E(o,t,{cache:z,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=f(n,t,a)?.node;s&&s===f(o,t,a)?.node&&(n=w(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:W(n,t,l.selection)},x(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=f(l.data,t,e)?.node;if(!r)return!1;const i=await E(r,t,{cache:z,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(f(l.data,t,e)?.node!==r)return;const o=w(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:W(o,t,l.selection)},x(n,!1),a=!0)}),a},get config(){return t},getState(){if(m&&v===l)return m;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?f(e.data,t,e.selection.id)?.node??null:null;return m={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>K.undo(),forward:()=>K.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&&M(e)}},getPermissions:N,getItemById:n=>f(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return h(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}},v=e,m},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,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:W(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=l,r=I(e,t);l={...l,data:r,selection:W(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:_()}],d=0),l!==o&&b()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(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,N=P(),m=null,b())},setConfig(e){e!==t&&(t=e,N=P(),m=null,b())}};return K}function te(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 ne=M(null),oe=M(!0);function re({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return P(()=>{n&&e.resolveAll()},[e,n]),P(()=>{if(t&&"undefined"!=typeof document)return te(document,e)},[e,t]),/* @__PURE__ */B(ne.Provider,{value:e,children:/* @__PURE__ */B(oe.Provider,{value:t,children:o})})}function ie(){const e=N(ne);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ae(e){const t=ie(),n=z({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 K(t.subscribe,o,o)}function se(){return function(e){return ae(e)}}var le="data-puck-component",ce="data-puck-dropzone",de={},ue="data-es-mirror",pe="undefined"==typeof window?P:R;function fe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${ue}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(ue,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function me({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=z(null),[m,h]=$(null);return pe(()=>{const e=f.current,t=m?.ownerDocument.defaultView;if("auto"!==l||!e||!m||!t)return;const n=()=>{e.style.height=`${Math.ceil(m.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(m),()=>r?.disconnect()},[m,l]),pe(()=>{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),h(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){fe(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>fe(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),h(null),s?.(null)}},[]),/* @__PURE__ */B("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:m?F(t,m):null})}var he=M(null),ve=M(de),ye=[];function ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ie(),s=ae(n=>h(n.appState.data,a.config,{parentId:e,slot:t})??ye),l=ae(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ae(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=N(he),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */B("div",{className:u.join(" "),[ce]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */B(be,{node:e},e.props.id))})}function ke(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of D(O(r)))i[e]=function(t={}){/* @__PURE__ */
|
|
2
|
+
return B(ge,{parentId:n,slot:e,...t})};return i}function we(e){return function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return B(ge,{parentId:e,slot:t,...n})}}function be({node:e}){const t=ie().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=z(null);return j(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(le),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(le,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),i=N(ve);if(!n?.render)return null;const a=n.render,s=ke(t,e.type,o,{...A(n),...e.props}),l={renderDropZone:we(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...i,...n.metadata}};return n.inline?/* @__PURE__ */B(a,{...s,puck:l,editMode:!0}):/* @__PURE__ */B("div",{[le]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */B(a,{...s,puck:l,editMode:!0})})}function Se({metadata:e}){const t=ae(e=>e.config),n=ae(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */B(ge,{parentId:m,slot:x}),i=o?/* @__PURE__ */B(o,{id:"puck-root",...ke(t,"root",m,n),puck:{renderDropZone:we(m),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
|
|
4
|
+
return B(ve.Provider,{value:e??de,children:i})}function Ie(e,t,n){const[o,r]=$(null),i=z(t);return i.current=t,pe(()=>{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=e.getBoundingClientRect(),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 Ce({id:e,kind:t,overlay:n}){const o=z(null),r=Ie(o,e?t=>t.querySelector(`[${le}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */B("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__ */B(n,{componentId:e,kind:t,children:i}):i}function Ee(e,t){const n=l(e),o=n.text.length,r=e.ownerDocument;if(!t)return[o,o];let i=null;const a=r.caretPositionFromPoint?.(t.x,t.y);if(a&&e.contains(a.offsetNode))i=n.at(a.offsetNode,a.offset);else{const o=r.caretRangeFromPoint?.(t.x,t.y);o&&e.contains(o.startContainer)&&(i=n.at(o.startContainer,o.startOffset))}if(null===i)return[o,o];const s=n.text;let c=i,d=i;for(;c>0&&!/\s/.test(s[c-1]);)c-=1;for(;d<s.length&&!/\s/.test(s[d]);)d+=1;return[c,d]}function xe({element:e}){const t=z(null),n=Ie(t,()=>e(),e);/* @__PURE__ */
|
|
5
|
+
return B("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 De({frame:e=!0,className:t,style:n,metadata:o,mirrorStyles:r,onDocument:l,height:c,title:d,nonce:u,hotkeys:f,frameWrapper:m,overlay:h,children:v,typing:y}){const g=ie(),k=N(oe),w=f??k,[b,S]=$(void 0),I=ae(e=>"node"===e.selection?.kind?e.selection.id:null),[C,E]=$(null),[x,D]=$(null),O=z(null),A=z(y);A.current=y;const M=z(null),K=e=>{const t=M.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(p,{detail:{typing:e}}))},j=(e,t)=>{O.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=g.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,caret:Ee(n,t),write:e.write,remount:e.remount,end:e=>{o.close(),O.current?.element===r&&(O.current=null),D(null),K(!1),A.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${le}]`)?.getAttribute(le);return a&&g.select(a),O.current={s:i,element:r},D(()=>r),E(null),K(!0),A.current?.onChange?.({typing:!0,element:n}),!0};P(()=>()=>O.current?.s.stop("stop"),[]);const Z=e=>{const t=O.current?.element();return Boolean(t&&t.contains(e))},R=e=>{const t=e.closest?.(`[${le}]`)?.getAttribute(le);if(!t)return;const n=g.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,g.config,t,o)??t},F=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(O.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button, a[href]"))return;const n=A.current?.atSelection?.();n&&j(n,null)&&e.preventDefault()},V=/* @__PURE__ */L("div",{ref:M,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),O.current){if(Z(t))return;O.current.s.stop("outside")}const n=R(t);void 0===n?t.hasAttribute?.(ce)||g.select(null):g.select(n)},onDoubleClick:e=>{const t=A.current;if(!t||Z(e.target))return;const n=t.at(e.target);n&&j(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>F(e),onMouseOver:e=>{if(O.current)return;const t=R(e.target)??null;t!==C&&E(t)},onMouseLeave:()=>E(null),children:[
|
|
6
|
+
/* @__PURE__ */B(he.Provider,{value:C,children:/* @__PURE__ */B(Se,{metadata:o})}),
|
|
7
|
+
/* @__PURE__ */L("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
8
|
+
/* @__PURE__ */B(Ce,{id:!x&&C&&C!==I?C:null,kind:"hover",overlay:h}),
|
|
9
|
+
/* @__PURE__ */B(Ce,{id:x?null:I,kind:"selected",overlay:h}),x?/* @__PURE__ */B(xe,{element:x}):null]}),v]}),H=m?/* @__PURE__ */B(m,{document:b,children:V}):V;P(()=>{if(b&&w)return te(b,g)},[b,w,g]),P(()=>{if(!b)return;const e=e=>{if("Enter"===e.key)return void F(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=g.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,g.config,n.selection);"node"===o?.kind&&g.select(o.id)};return b.addEventListener("keydown",e),()=>b.removeEventListener("keydown",e)},[b,g]);/* @__PURE__ */
|
|
10
|
+
return B("div",{className:"es-canvas"+(t?` ${t}`:""),style:n,"data-puck-preview":"","data-es-typing":x?"":void 0,children:e?/* @__PURE__ */B(me,{mirrorStyles:r,onDocument:e=>{S(e??void 0),l?.(e)},height:c,title:d,nonce:u,children:H}):/* @__PURE__ */B("div",{id:"preview-frame","data-puck-entry":"",children:H})})}function Oe(e={}){const t=ie(),n=ae(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ae(){const e=ie(),n=ae(e=>e.config),o=e.resolveCache,r=ae(e=>e.selectedItem),i=ae(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=j(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?f(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,m=p?d.getItemById(p)??null:null,{fields:h}=t({id:a,node:l,block:c,parent:m,appState:d.appState}),v=ae(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),y=Z((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 E(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 E({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:v,onChange:y}}export{me as CanvasFrame,J as DEFAULT_UI,De as EaselCanvas,re as EaselProvider,Se as EditDocument,te as bindUndoKeys,ee as createEasel,se as createUseEasel,V as recordsByDefault,q as reduce,U as uiView,ae as useEasel,ie as useEaselApi,Oe as useEaselNodeOps,Ae as useSelectedFields,W as validSelection};
|
|
@@ -0,0 +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-DSUMM2WF.js";import{Inspector as i}from"./chunk-X4OF36J2.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=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},L={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},S={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function C(){/* @__PURE__ */
|
|
2
|
+
return s(t,{height:"fill"})}function D(){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 P=o({});function F({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(P.Provider,{value:n,children:e})}function G(){return u(P)}function N(){return(G().useOwnerName??g)()}function x(){return(G().useDocumentLabel??y)()}function B(n,e,t,r){return(G().useBridges??v)(n,e,t,r)}function I(n){return(G().useStandaloneBridges??v)(n)}function T(n,e){(G().useDocumentPass??b)(n,e)}function A(){return G().blockRules??O}function R(){return G().blockLook??j}function W(){return G().devices??w}function K(){return G().leftView??L}function M(){return G().pinned??S}function V(){return G().saveSwitch??!0}function E(n){e(!0===G().pickFollowsSelection,n)}function H(){return G().add??h}function J(){return G().storageNamespace||void 0}function Q(){return G().styleClipboard??null}function U(){return G().nodeKeys??!0}function X(){return G().notify??null}function Y(){return G().Canvas??C}function Z(){return G().CanvasHead??null}function q(){return G().canvasDrag??null}var z=o(null);function $({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(z.Provider,{value:n,children:e})}function _(){return u(z)}function nn(){return G().Inspector??D}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,F as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,H as useScreenAdd,R as useScreenBlockLook,A as useScreenBlockRules,B as useScreenBridges,q as useScreenCanvasDrag,Y as useScreenCanvasFrame,Z as useScreenCanvasHead,_ as useScreenCanvasTarget,W as useScreenDevices,x as useScreenDocumentLabel,T as useScreenDocumentPass,nn as useScreenInspectorPanel,K as useScreenLeftView,U as useScreenNodeKeys,X as useScreenNotify,N as useScreenOwnerName,G as useScreenParts,E as useScreenPickFollowsSelection,M as useScreenPinned,V as useScreenSaveSwitch,J as useScreenStorageNamespace,Q as useScreenStyleClipboard,I as useStandaloneScreenBridges};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-EXCKAZKN.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-DSUMM2WF.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};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{dedupeSlotChildren as e}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as n}from"./chunk-BXQBCW3P.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as i}from"./chunk-2GVCAIPX.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as a}from"./chunk-TBF5CVPA.js";import{scrollPreviewToSection as c,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,editorRootFocus as m}from"./chunk-QPQXKKSC.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as k,clampPanelWidth as S}from"./chunk-6TOYXESC.js";import{usePartBridge as v}from"./chunk-T5HFGW57.js";import{useSectionOps as w}from"./chunk-I6U2G7L4.js";import{useNodeClipboard as x,useNodeContextMenu as b}from"./chunk-LVUDUQNL.js";import{PageEditGuardNotices as z}from"./chunk-HQWQLDCB.js";import{useScreenDocument as B}from"./chunk-WZMU646D.js";import{requestMediaPick as C}from"./chunk-KG7RJWOK.js";import{heldStyle as N,styleShortcut as O}from"./chunk-V7U33NF2.js";import{AddChildRow as I}from"./chunk-5545A3PC.js";import{AddSidePanel as $}from"./chunk-B4ZNYLZX.js";import{SidePanelHead as P,PanelShowStrip as T}from"./chunk-PFNIVZPN.js";import{MediaSidePanel as A}from"./chunk-DQLK3QQ2.js";import{useScreenSaveSwitch as M,useScreenNodeKeys as j,useScreenPinned as L,useScreenDocumentLabel as R,useScreenCanvasFrame as E,useScreenInspectorPanel as F,useScreenDevices as V,useScreenPickFollowsSelection as W,useScreenLeftView as U,useScreenAdd as D,SELECTION_MODE as H,sameInspectorMode as G,useScreenBridges as Q,useScreenBlockRules as X,useScreenBlockLook as Y,useScreenStorageNamespace as J,useScreenNotify as K,useScreenCanvasHead as _,isSlotMode as Z,useScreenStyleClipboard as q,useScreenDocumentPass as ee,useScreenCanvasDrag as ne,ScreenCanvasTargetProvider as te,isPinnedFirst as oe,isPinnedLast as re,screenSlotsOf as ie}from"./chunk-EXCKAZKN.js";import{ROOT_ZONE as le,blockNodeActions as se,TREE_MAX_DEPTH as de,childSlotsOf as ae,slotFieldsOf as ce,slotChildrenIn as pe,nestsInTree as ue,newNodeId as fe}from"./chunk-PLVEGYK6.js";import{useMediaPanel as he,usePanelPick as me,useCancelPanelPick as ge}from"./chunk-R6WTQWAC.js";import{useEaselHost as ye,useHostEscape as ke}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-MCHMF32I.js";import{useEasel as we,useEaselApi as xe}from"./chunk-DSUMM2WF.js";import{TreeRow as be,Subtree as ze,LayersTree as Be,TreeGroupLabel as Ce,TreeRowAction as Ne,TreeSeam as Oe}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Ie}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as $e}from"./chunk-WK3AFPXY.js";import{toItemSelector as Pe,useNodeOps as Te,clickPick as Ae}from"./chunk-UK2FQOUT.js";import{LayersIcon as Me,MediaIcon as je}from"./chunk-4VJATVVR.js";import{DEFAULT_SAVE_WORDS as Le,saveIndicator as Re}from"./chunk-H6DDIBQ4.js";import{EaselTopBar as Ee,TopBarRail as Fe,TopBarCluster as Ve,EaselIconButton as We,TopBarDivider as Ue,DeviceSwitch as De,InspectorIconButton as He,PanelResizeHandle as Ge,MAX_PANEL_W as Qe,MIN_PANEL_W as Xe,panelWidthVars as Ye,SaveState as Je,SaveStateToggle as Ke}from"./chunk-UB4TLWVJ.js";import{DEFAULT_CHROME_WORDS as _e}from"./chunk-Y2G7CU6A.js";import{useWords as Ze}from"./chunk-MFIRYGHW.js";import{CanvasDragLayer as qe}from"./chunk-AYNU4FYF.js";import{DEFAULT_DRAG_WORDS as en}from"./chunk-O2NLQBFX.js";import{createDragSession as nn,useTreeDrag as tn,gapToMoveIndex as on}from"./chunk-67GNT6PF.js";import{useCanvasFrame as rn,LIST_SELECTOR as ln,BLOCK_SELECTOR as sn,useCanvasEvent as dn}from"./chunk-AWJUYMX7.js";import{zoneKey as an,ROOT_ID as cn,ROOT_SLOT as pn,parseZoneKey as un,DataError as fn,find as hn}from"./chunk-KRXQM65X.js";import{useRef as mn,useMemo as gn,useState as yn,useEffect as kn,useCallback as Sn,useLayoutEffect as vn,Fragment as wn}from"react";import{Tooltip as xn,Button as bn,toast as zn}from"efficient-shell/ui";import{UndoIcon as Bn,RedoIcon as Cn,TrashIcon as Nn,EyeOffIcon as On,EyeIcon as In,DuplicateIcon as $n}from"efficient-shell/icons/efficient";import{jsx as Pn,jsxs as Tn,Fragment as An}from"react/jsx-runtime";function Mn({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i,words:l,saveWords:s}){if(null!==t)/* @__PURE__ */return Pn(Je,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
|
|
2
|
+
return Pn(Je,{tone:e.pending?"off-unsaved":"off",label:l.notSaving,role:"status"});const{tone:d,label:a}=Re(e,s),c=e.failed&&!e.paused&&/* @__PURE__ */Pn(bn,{variant:"secondary",size:"sm",onClick:i,children:l.retry});/* @__PURE__ */
|
|
3
|
+
return Tn(An,o?{children:[
|
|
4
|
+
/* @__PURE__ */Pn(Ke,{pressed:e.paused,onToggle:r,title:e.paused?l.autoSaveOff:l.autoSaveOn,children:/* @__PURE__ */Pn(Je,{tone:d,label:a})}),c]}:{children:[
|
|
5
|
+
/* @__PURE__ */Pn(Je,{tone:d,label:a,role:"status"}),c]})}function jn({expand:e}){/* @__PURE__ */
|
|
6
|
+
return Pn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Tn(An,e?{children:[
|
|
7
|
+
/* @__PURE__ */Pn("path",{d:"M8 9l4-4 4 4"}),
|
|
8
|
+
/* @__PURE__ */Pn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
9
|
+
/* @__PURE__ */Pn("path",{d:"M8 4l4 4 4-4"}),
|
|
10
|
+
/* @__PURE__ */Pn("path",{d:"M8 20l4-4 4 4"}),
|
|
11
|
+
/* @__PURE__ */Pn("path",{d:"M5 12h14"})]})})}var Ln=`${ln}, ${sn}`;function Rn(e,n,t){const o=t-n;if(o<6)return null;if(o<26)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+13),t-13))}}var En="__rungs";var Fn="screen:band",Vn={duplicate:!0,delete:!0};function Wn(){const Re=ye(),{target:Je,docId:Ke,capabilities:ln,currentSlug:Wn,siteId:Un,onPublish:Dn,saveState:Hn,saveConflict:Gn,retrySave:Qn,toggleAutoSave:Xn,readOnly:Yn,readOnlyReason:Jn=null}=B(),Kn=M(),_n=j(),{mediaEditing:Zn,hasEditGuard:qn,hasPinnedChrome:et}=ln,{appState:nt,dispatch:tt,history:ot,selectedItem:rt,getSelectorForId:it,config:lt}=we(e=>e),st=L(),{first:dt,firstGroup:at,lastGroup:ct,isSectionGroup:pt,sectionGroupZone:ut,panelOf:ft}=st,ht=ft(dt),mt=e=>oe(st,e),gt=e=>re(st,e),yt="node"===st.firstRow,kt=st.band??null,St=Ze("screen",ve),vt=Ze("tree",Ie),wt=Ze("drag",en),xt=Ze("save",Le),bt=Ze("menu",$e),zt=Ze("styleClipboard",Se),Bt=Ze("chrome",_e),Ct=R()??`/${Wn}`,Nt=E(),Ot=F(),It=w({readOnly:Yn}),$t=w({readOnly:Yn,foldIntoHistory:!0}),Pt=mn(null),Tt=xe(),At=gn(()=>({...It,select:e=>{Pt.current=e,It.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Tt.config;Pt.current=Pe(e,t,n)}It.commitDocument(e,n)}}),[It,Tt]),Mt=nt.ui,jt=Mt.leftSideBarVisible,Lt=Mt.rightSideBarVisible,{options:Rt,widths:Et,initial:Ft,fluid:Vt,fit:Wt}=V(),[Ut,Dt]=yn(Ft),Ht=he(),Gt=Zn&&null!==Ht,Qt=me(),Xt=ge();W(rt?.props.id);const{read:Yt,write:Jt,forSelection:Kt}=U(),[_t,Zt]=yn(Yt);kn(()=>{Jt(_t)},[_t]);const[qt,eo]=yn(0),no=mn(null),to=mn(null),oo=rn(to,{readySelector:Ln}),ro=f(to);h(to,oo);const[io,lo]=yn(!1),so=mn(!1),ao=mn(!1),[co,po]=yn(null),uo=D(),fo=e=>po(null===e?null:{zone:le,index:e}),[ho,mo]=yn([]),[go,yo]=yn(H),ko="puck"===go.kind,So=io&&!co&&uo.railTarget?uo.railTarget(nt.data,{node:rt??null,mode:go}):null,vo=So?{zone:an(So),index:So.index}:null,wo=co??vo,xo=wo&&wo.zone===le?wo.index:null,bo=t(go,rt?.props.id),[zo,Bo]=yn(null);kn(()=>{zo&&(o(),Bo(null))},[zo]);const Co=mn(it);Co.current=it;const No=Sn((e,{scroll:n})=>{Zt(n=>Kt(e,n)),n&&Bo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Co.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&or(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Oo=mn(null);kn(()=>{const e=Oo.current;Oo.current=null;const n=null==rt?.props.id?null:String(rt.props.id);yo(e&&e.id===n?e.mode:ft(rt?.type)??H);const t=rt?.props.id,o=Pt.current;if(Pt.current=null,!t)return;const i=it(t);No(String(t),{scroll:!r(o,i??null,le)})},[rt?.props.id,No]);const Io=Sn(e=>{yo(n=>G(n,e)?n:e),tt({type:"setUi",ui:{rightSideBarVisible:!0}})},[tt]),$o=mn(()=>{});$o.current=(e,n)=>{const t=e?Yr(e.zone??le)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==rt?.props.id?null:String(rt.props.id);yo(e=>G(e,n)?e:n),o!==r&&(Oo.current={id:o,mode:n},At.select(e))};const Po=Sn((e,n)=>$o.current(e,n),[]),To={kind:go.kind,mode:go,open:Io,show:e=>yo(e),reveal:()=>{Lt||tt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Po},Ao=Q(To,{data:nt.data,selected:rt??null,zoneOf:e=>it(e)?.zone,readOnly:Boolean(Yn),select:e=>{yo(H),At.select({index:e})},replace:(e,n)=>At.replaceComponent(le,e,n),scrollTo:e=>Si(e)},{device:Ut,refreshes:qt},{setView:Zt,reveal:()=>{jt||tt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Mo=Ao.pinnedSource??!1,jo=Ao.resolveLeftView?Ao.resolveLeftView(_t,Gt):"media"===_t&&Gt?_t:"sections",Lo=X(),{isLockedBlock:Ro,duplicateBlocked:Eo,nestDepth:Fo,newSectionNode:Vo,canAddTo:Wo,blockIsOffered:Uo}=Lo,Do=Y(),{labelAtLevel:Ho,Icon:Go,useProducts:Qo}=Do,Xo=Do.rowName?(e,n,t)=>Do.rowName(e,n,t):void 0,Yo=Sn(e=>{tt({type:"setUi",ui:{rightSideBarVisible:!0}}),c(e),No(e,{scroll:!0})},[tt,No]),{selectNode:Jo,openPartId:Ko}=v({mode:go,setMode:yo,onOpenPart:Yo}),[_o,Zo]=yn(null);ke(null!==_o,()=>Zo(null));const qo=y(J()),er=qo.collapsed,nr=qo.panelWidths,[tr,or]=yn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(er);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
12
|
+
return new Set}});kn(()=>{try{window.localStorage.setItem(er,JSON.stringify([...tr]))}catch{}},[tr]);const[rr,ir]=yn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(nr);if(!e)return{...k};const n=JSON.parse(e);return{left:S(Number(n.left)||k.left),right:S(Number(n.right)||k.right)}}catch{return{...k}}});kn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(nr,JSON.stringify(rr))}catch{}},300);return()=>clearTimeout(e)},[rr]);const lr=Sn((e,n)=>ir(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),sr=Sn(e=>lr("left",e),[lr]),dr=Sn(e=>lr("right",e),[lr]),ar=e=>tr.has(e),cr=e=>or(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),pr=mn(!1),ur=mn(null);kn(()=>{if(pr.current&&!io){const e=ur.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??to.current?.querySelector(`button[aria-label="${CSS.escape(St.add.title)}"]`))?.focus(),ur.current=null}pr.current=io},[io]),kn(()=>{if(!io||!ro)return;const e=e=>{"Escape"===e.key&&Oi()};return ro.addEventListener("keydown",e),()=>ro.removeEventListener("keydown",e)},[io,ro]),ke(io,()=>Oi()),kn(()=>{!jt&&io&&(lo(!1),po(null),so.current=!1)},[jt]),kn(()=>{if(!Qt)return ao.current&&tt({type:"setUi",ui:{leftSideBarVisible:!1}}),void(ao.current=!1);io&&(lo(!1),po(null),ao.current=so.current,so.current=!1),jt||(ao.current=!0,tt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[Qt]),kn(()=>{!jt&&Qt&&(ao.current=!1,Xt())},[jt]),kn(()=>{if(!Qt||!ro)return;const e=e=>{"Escape"===e.key&&Xt()};return ro.addEventListener("keydown",e),()=>ro.removeEventListener("keydown",e)},[Qt,ro]),ke(null!==Qt,()=>Xt());const fr=K(),hr=(e,n="success")=>{fr?fr(e,"error"===n?"error":"info"):"error"===n?zn.error(e,{duration:3200,sound:!1}):zn.success(e,{duration:1900,sound:!1})},mr=mn(null),[gr,yr]=yn(0),[kr,Sr]=yn(0),vr=_(),wr=mn(null),xr=e=>Math.max(0,e.clientHeight-(wr.current?.offsetHeight??0));kn(()=>{const e=mr.current;if(!e)return;const n=()=>{yr(e.clientWidth),Sr(xr(e))};n();const t=new ResizeObserver(n);return t.observe(e),wr.current&&t.observe(wr.current),()=>t.disconnect()},[]),vn(()=>{mr.current&&(yr(mr.current.clientWidth),Sr(xr(mr.current)))},[rr,jt,Lt]);const br=Ut===Vt?gr>0?gr:Et[Vt]:Et[Ut],zr=gr>0?Math.min(gr/br,"shrink"===Wt?1:2):1,Br=br*zr,Cr=gr>0&&Br>gr+1,Nr={width:Br,height:kr||"100%",flex:"none",position:"relative"},Or={width:br,height:kr?kr/zr:"100%",maxHeight:"none",transform:1!==zr?`scale(${zr})`:void 0,transformOrigin:"top left"},Ir=()=>tt({type:"setUi",ui:{leftSideBarVisible:!jt}}),$r=()=>tt({type:"setUi",ui:{rightSideBarVisible:!Lt}}),Pr=e=>{io&&(lo(!1),po(null),so.current=!1,jt&&_t===e)||Qt&&(ao.current=!1,Xt(),jt&&_t===e)||(jt&&_t===e?Ir():(Zt(e),jt||tt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Tr=()=>{C(Re,{accept:"image/*",title:Bt.mediaLibrary})},Ar=()=>{yo(H),At.select(null),u()},Mr=()=>{yo(ht??H),Lt||tt({type:"setUi",ui:{rightSideBarVisible:!0}})},jr=nt.data.content??[],Lr=()=>{const e=jr.findIndex(mt),n=jr.findIndex(gt);return{floor:e>=0?e+1:0,cap:n>=0?n:jr.length}},Rr=lt,Er=Lo.stripCopy,Fr=e=>i(e,Er),Vr=x(),Wr=Te({data:nt.data,config:Rr,readOnly:Boolean(Yn),clipboard:Vr,strip:Er?e=>Er(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==cn||e.slot!==pn)return{min:0,max:n-1};const{floor:t,cap:o}=Lr();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&yo(H);const t=void 0===n||"node"===n?.kind?n:null;At.commitDocument(e,t)}}),Ur=e=>Ho(e,"block",lt.components[e]?.label??e),Dr=Sn(e=>lt.components[e]?.defaultProps??{},[lt]),Hr=e=>Ho(e,"section",Ur(e)),Gr=e=>l({type:e.type,props:e.props??{}},Hr(e.type),Xo),{nodeAddresses:Qr,zoneItems:Xr}=gn(()=>{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>=de)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ae(lt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(jr,le,0),{nodeAddresses:e,zoneItems:n}},[jr,lt]),Yr=Sn(e=>Xr.get(e)??[],[Xr]),Jr=e=>{const n=Qr.get(e);return n?Yr(n.zone)[n.index]:void 0},Kr=e=>ie(Lo,lt,e),_r=e=>{if(!Lo.slotsOf||e===le)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Jr(e.slice(0,n));if(!t)return null;const o=Kr(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}},Zr=(()=>{if(!Z(go))return null;const e=`${go.nodeId}:${go.slot}`;return _r(e)?.slot.panel===go.kind?e:null})(),qr=mn(null);kn(()=>{const e=qr.current;if(qr.current=null,!Zr||!Z(go))return;const n=go.nodeId;No(n,{scroll:e!==Zr}),or(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[go]);const ei=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Qr.get(e);n&&(n.zone===le?vi(n.index):Ki(n.zone,n.index,e,Jr(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Zr!==i&&(qr.current=i),Po(null,r),Lt||tt({type:"setUi",ui:{rightSideBarVisible:!0}}),Si(o)},ni=(e,n,t)=>{const o=`${e}:${n}`;if(or(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;Zr!==o&&(qr.current=o);Po(null,{kind:t,nodeId:e,slot:n})},ti=(e,n,t)=>{if(Yn||!Lo.moveSlot)return;const o=Jr(e),r=o?Kr(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:En,index:n},s=on(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=Lo.moveSlot(e,n,s);"string"==typeof d&&ni(e,d,i.panel)},oi=Qo(),ri=gn(()=>{const e=/* @__PURE__ */new Map;for(const n of oi??[])e.set(n.slug,n.name);return e},[oi]),ii=e=>s(e,Ur,Do.plainText,e=>ri.get(e),Do.rowName),li=(e,n)=>{const t=lt.components[e.type]?.fields,o=n===le||hl(n)?"section":"block",r=n===le&&(mt(e)||gt(e)||pt(e.type)),i="block"===o?d(t):r?null:a(t);return Do.renamePropOf?Do.renamePropOf(e,o,i):i},si=(e,n,t,o)=>{if(!(!Yn&&_o?.zone===e&&_o.index===n))return;const r=(t,o)=>{Zo(null),o&&((e,n,t)=>{const o=Yr(e)[n];if(!o)return;const r=li(o,e);r&&At.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
13
|
+
return Pn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":St.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)},di=n(q(),zt),ai=di.scope({target:Je,siteId:Un,docId:Ke}),ci=lt,pi=(e,n)=>n===le?Hr(e):Ur(e),ui=(e,n,t)=>{const o=di.plan(ai,t,pi(t.type,e),ci);o&&(o.changed&&At.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),hr(o.message))},fi=b({nodesIn:Yr,nodeAt:(e,n)=>Yr(e)[n]??null,labelOf:(e,n)=>n===le?Hr(e):Ur(e),renamePropOf:li,beginRename:(e,n)=>Zo({zone:e,index:n}),history:{hasPast:ot.hasPast,hasFuture:ot.hasFuture,back:()=>ot.back(),forward:()=>ot.forward()},openAddSection:()=>{At.select(null),Ci(null)},openPageSettings:()=>{At.select(null),yo(H)},pageSettingsLabel:St.pageSettings,words:{menu:bt,styleClipboard:zt,screen:St.menu},readOnly:Boolean(Yn),collapseAll:()=>or(new Set(Yr(le).map(e=>String(e.props.id)))),onPasteRefused:e=>hr(e?St.pasteRefused({name:e.label}):St.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>gl(e,n),menuRows:Ao.menuRows,isLocked:e=>Ro(e.type),duplicateBlocked:e=>Eo(nt.data,e),permits:e=>se(lt,e.type),canAddTo:Wo,nodeOps:Wr,isPinned:(e,n)=>n===le&&(mt(e)||gt(e)),sectionBand:Lr,openAddInside:(e,n)=>{e===le?vi(n):At.select({zone:e,index:n}),Ci(null)},locate:e=>Qr.get(e)??null,rowNameOf:(e,n)=>n===le?Gr(e):ii(e),selectAt:(e,n,t,o)=>{e===le?vi(n):Ki(e,n,t,o??"")},slotRung:e=>{const n=_r(e);return n?.slot.panel?{label:n.slot.label,select:()=>ei(n.node,n.slot,!1)}:null},style:{held:()=>N(ai),canCopy:e=>di.rows(ci,e).some(e=>!1!==e.counted),copy:(e,n)=>di.copy(ai,e,pi(e.type,n),ci),paste:(e,n,t)=>ui(e,n,t)},keys:_n?{target:ro,selected:()=>{const e=nt.ui.itemSelector;return e?{zone:e.zone??le,index:e.index}:null},held:()=>Vr.get(),readOnly:Boolean(Yn),onDone:({done:e,name:n})=>{"copied"===e&&hr(St.copied({name:n}))}}:void 0},oo),hi=mn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});kn(()=>{hi.current={copy:(e,n)=>di.copy(ai,e,pi(e.type,n),ci),paste:ui,at:()=>{const e=nt.ui.itemSelector;if(!e)return null;const n=e.zone??le,t=Yr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Yn)}});const mi=Sn(e=>{const n=O(e);if(!n)return;const t=hi.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))},[]);kn(()=>{if(!ro)return;const e=e=>mi(e);return ro.addEventListener("keydown",e),()=>ro.removeEventListener("keydown",e)},[mi,ro]),dn(oo,"keydown",mi);const gi=jr.map(e=>e.props.id).join("|");kn(()=>{const e=oo?.document??null,n=oo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void mo(e=>e.length?[]:e);const n=jr.findIndex(gt),t=n>=0?n:jr.length,o=n=>{const t=jr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(sn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=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=Rn(l&&s?(s.bottom+l.top)/2:l?l.top:s.bottom,Math.max(-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}mo(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()}},[oo,gi,Ut,zr,jt,Lt,rt?.props.id]);const yi=oo?.document??null,ki=oo?.window??null;kn(()=>{const e=no.current;if(!e||!yi||!ki)return;const n=[],t=()=>{const n=yi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&ki.scrollTo({left:ki.scrollX,top:ki.scrollY+t,behavior:"instant"}),!0};return no.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[yi,ki]);const Si=e=>{Ao.holdCanvasOn?Ao.holdCanvasOn(e):c(e)},vi=e=>{yo(H),At.select({index:e}),Ao.sectionPressed?.(jr[e]);const n=jr[e]?.props?.id;n&&Si(n)},wi=e=>{const{floor:n,cap:t}=Lr(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=rt&&go.kind!==ht?.kind?jr.findIndex(e=>e.props.id===rt.props.id):-1;return o(r>=0?r+1:t)},xi=(e,n)=>{const{floor:t,cap:o}=Lr(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(At.reorderComponent(le,e,i),At.select({index:i}),{moved:!0,dest:i})},bi=(e,n,t,o)=>{yo(H),At.select(o?{index:o.index,zone:o.zone}:{index:e}),c(n),hr(St.sectionAdded({name:t}))},zi=(e,n)=>{const t=wi(n),o=Vo(e,{nodeDefaults:Dr,newNodeId:fe,sectionLabel:Hr,blockIsOffered:Uo}),r=o?At.insertNode(le,t,o):At.insertSection(e,t);return bi(t,r,Hr(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:a}of ae(lt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Wo(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:a,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},Bi=(e,n,t)=>{const o=wi(t),r=At.insertNode(le,o,n);return bi(o,r,e),o},Ci=e=>Ni(le,e),Ni=(e,n)=>{ur.current=document.activeElement??null,Qt&&(so.current=ao.current,ao.current=!1,Xt()),po(null===n?null:{zone:e,index:n}),lo(!0),jt||(so.current=!0,tt({type:"setUi",ui:{leftSideBarVisible:!0}}))},Oi=()=>{lo(!1),po(null),so.current&&tt({type:"setUi",ui:{leftSideBarVisible:!1}}),so.current=!1},Ii=(e,n,t)=>{if("section"===e.kind)At.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;At.insertNode(n,t,Fr(e.template.node))}yo(H),At.select({index:t,zone:n})},$i=(e,n)=>Do.rowName?n?mt(e)?Do.rowName(e,"section",St.header):gt(e)?Do.rowName(e,"section",St.footer):pt(e.type)?Do.rowName(e,"section",Ur(e.type)):Gr(e):ii(e):n?Hr(e.type):Ur(e.type),Pi=e=>n=>{e()},Ti=()=>Ao.editPinnedSource?.(),Ai=(e,n,t)=>{if(Yn)return null;const o=Yr(e)[n];return o&&!se(lt,o.type).delete?null:/* @__PURE__ */Pn(Ne,{kind:"delete",label:St.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Yr(e)[n]?.props?.id;null!=t&&Wr.remove(String(t))})(e,n),children:/* @__PURE__ */Pn(Nn,{size:15})})},Mi=e=>Do.rowPreview?.(e)||void 0,ji=e=>Do.rowMarks?.(e)??void 0,Li=(e,n,t)=>Do.rowActions?.(e,n,t)??null,Ri=(e,n,t,o)=>{if(Yn)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
14
|
+
return Pn(Ne,{kind:"eye",label:r?St.showNamed({name:o}):St.hideNamed({name:o}),onClick:()=>Fi(e,n,t),children:/* @__PURE__ */Pn(r?On:In,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Ei=e=>{const n=Hr(jr[e]?.type??""),t=n?St.addSectionBefore({name:n}):St.addSectionHere;return El(le,e,()=>Ci(e),t)},Fi=(e,n,t)=>{At.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Vi=e=>ce(lt,e),Wi=e=>ae(lt,e),Ui=e=>Lo.slotsOf?Kr(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:pe(e,n.slot)})):[{slot:null,rung:null,kids:Wi(e)}],Di=e=>Lo.slotsOf?Ui(e).flatMap(e=>e.kids):Wi(e),Hi=e=>Boolean(Lo.slotsOf)&&Kr(e).some(e=>e.rung),Gi=(e,n,t)=>null===t?void 0===n?Wo(e):Wo(e,n):Wo(e,n,t),Qi=(e,n,t)=>{const o=ue(lt,e.type,n)&&(t||Di(e).length>0||Hi(e));return{collapsible:o,folded:o&&ar(String(e.props.id))}},Xi=(e,n,t)=>Ui(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Qi(e,r,t(e.type)).collapsible?[String(e.props.id),...Xi(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Yi=e=>Di(e).length>0||Hi(e)||Boolean(Wo(e.type)),Ji=e=>Boolean(Wo(e)),Ki=(e,n,t,o)=>{if(yo(H),Wo(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),At.select({index:n,zone:e}),c(t)}else At.select({index:n,zone:e}),Si(t)},_i=(e,n,t,o,r)=>{const i=`${e}:${n}`;At.insertComponent(i,t,o),Wo(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),At.select({index:o,zone:i})}):At.select({index:o,zone:i})},Zi=(e,n,t)=>{At.insertComponent(e,n,t),yo(H),At.select({index:t,zone:e})},qi=mn(/* @__PURE__ */new Set);kn(()=>{jr.forEach(e=>{const n=Wo(e.type)?.spec;if(!n)return;const t=e.props.id;if(qi.current.has(t))return;qi.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(Dr)).forEach((e,t)=>$t.seedChild(o,t,n.childType,e))})},[jr,$t,Dr]);const el=mn(/* @__PURE__ */new Set);kn(()=>{jr.forEach((n,t)=>{const o=n.props.id;if(el.current.has(o))return;const r=e(n,Vi(n.type));el.current.add(o),r&&$t.replaceComponent(le,t,{...n,props:r})})},[jr,$t]),ee($t,lt);const nl=jr.findIndex(gt),tl=nl>=0?jr[nl]:null,ol=yt?jr.findIndex(mt):-1,rl=ol>=0?jr[ol]:null,il=jr.find(e=>e.type===at)??null,ll=jr.find(e=>e.type===ct)??null,sl=nl>=0?nl:jr.length,dl=[];jr.forEach(e=>{gt(e)||(Yi(e)&&dl.push(String(e.props.id)),dl.push(...Xi(e,1,Ji)))}),tl&&(dl.push(String(tl.props.id)),dl.push(...Xi(tl,1,Ji)));const al=dl.length>0&&dl.every(e=>tr.has(e)),cl=e=>{const n=Do.blockRowName(e,Ur);return Do.rowName?Do.rowName(e,"block",n):n},pl=(e,n,t,o)=>{const r=Yr(e)[t];if(!r)return;const i={...un(e),index:t},l={...un(n),index:Math.min(Math.max(o,0),Yr(n).length)},s=on(i,l);if(e!==n||s!==t)try{Wr.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof fn))throw e}},ul=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Wi(e))n.add(r),t(o)};for(const t of Vi(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},fl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Qr.get(n);if(!e)return null;if(e.zone===le)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},hl=e=>{const n=e.slice(0,e.indexOf(":")),t=jr.find(e=>pt(e.type)&&String(e.props.id)===n);return t&&ut(n)===e?t:null},ml=(e,n,t)=>{if(e.rung){const t=Jr(e.rung.nodeId),o=t?Kr(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===En&&n.index>=0&&n.index<=o}if(n.slot===En)return!1;if(e.add)return kl(e.add,n);const o=an(n);if(pt(e.type))return!1;const r=hl(o),i=hl(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=Yr(o).length);if(e.zone===le||o===le){if(e.zone!==o)return!1;const{floor:t,cap:r}=Lr();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Yr(o).length)return!1;if(e.zone===o)return!0;const l=tl&&!st.lastIsOpen?String(tl.props.id):null;return(!l||fl(e.zone)!==l&&fl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Yr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Qr.get(i),s=l?Yr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&ul(r).has(n))return!1;const d=Wo(s.type,Fo(nt?.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?.(Yr(n),r))})(e.zone,o,e.index,t)},gl=(e,n)=>{const t=an(e.from);if(t===an(n))return!0;const o=e.node;return ml({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},yl=e=>{const n=e.slice(0,e.indexOf(":")),t=Qr.get(n),o=t?Yr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Wo(o.type,Fo(nt?.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:Ur(r.spec.childType)}]:[]),l=_r(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:$i(o,t.zone===le)}},kl=(e,n)=>{const t=an(n);if("block"!==e.kind){if(hl(t))return n.index>=0&&n.index<=Yr(t).length;if(t!==le)return!1;const{floor:e,cap:o}=Lr();return n.index>=e&&n.index<=o}if(t===le)return!1;const o=yl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Yr(t))},Sl=(e,n)=>{e.rung?ti(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&hl(an(n)))return void Ii(e,an(n),n.index);if("section"===e.kind)return void zi(e.type,n.index);if("template"===e.kind)return void Bi(e.template.name,Fr(e.template.node),n.index);const t=an(n),o=yl(t);o&&(o.target.spec?_i(o.parentId,o.target.slot,e.type,n.index,o.parent.type):Zi(t,e.type,n.index))})(e.add,n):e.zone===le?xi(e.index,n.index):pl(e.zone,an(n),e.index,n.index)},[vl]=yn(()=>nn()),wl=tn({keyOf:e=>e.id,readOnly:Boolean(Yn),session:vl,canDrop:ml,onDrop:Sl,onStep:(e,n)=>{e.rung?ti(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===le?((e,n)=>{const t=Hr(jr[e]?.type??""),o=xi(e,n<0?e-1:e+2);if(!o.moved)return void hr(n<0?St.sectionFirst({name:t}):St.sectionLast({name:t}));const{floor:r,cap:i}=Lr();hr(St.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):pl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),xl=Sn(e=>{const{floor:n,cap:t}=Lr(),o=[];for(const r of e.nodes){const e=an(r.place),i=Yr(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(mt(i)||gt(i)||Ro(i.type))continue;if(pt(i.type))continue;const l=Boolean(hl(e)),s=e===le||l;e===le&&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?Hr(i.type):ii(i),from:r.place})}return{sources:o,zones:e.zones.flatMap(e=>{const n=an(e.list);return n===le&&0===e.children.length?[{...e,addLabel:St.addSection,addAlways:!0}]:e.children.length>0||Boolean(yl(n)?.choices.length)||Boolean(hl(n))?[e]:[]})}},[nt.data]),bl=null==rt?.props.id?null:String(rt.props.id),zl=Sn(e=>{const n=lt,t=e=>!e.item.rung&&null!==hn(nt.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(bl);return i||(r(Ae(nt.data,n,o.item.id,bl))??o)},[nt.data,lt,bl]),Bl=e=>{yo(H),At.select(e.zone===le?{index:e.index}:{index:e.index,zone:e.zone})},Cl=ne(),Nl=()=>({data:nt.data,device:Ut,ops:At,inspector:To}),Ol=Cl?.model,Il=gn(()=>Ol?e=>Ol(e,xl(e),Nl()):xl,[Ol,xl,Ut]),$l=Cl?.measure,Pl=$l?(e,n)=>$l(e,n,Nl()):void 0,Tl=Cl?.canDrop,Al=Tl?(e,n)=>Tl(e,n,ml,Nl()):ml,Ml=Cl?.drop,jl=Ml?(e,n)=>Ml(e,n,Sl,Nl()):Sl,Ll=Cl?.pick,Rl=Ll?e=>Ll(e,Bl,Nl()):Bl,El=(e,n,t,o)=>/* @__PURE__ */Pn(Oe,{...Yn?{}:wl.seam({place:{...un(e),index:n}}),onAdd:Yn?void 0:t,label:o},`seam:${e}:${n}`),Fl={rowClick:Pi,isCollapsed:ar,toggleCollapse:cr},Vl=e=>{const n=String(e.props.id),t=jr.findIndex(e=>String(e.props.id)===n),o=ut(n),r=Yr(o),i=ar(n),l=Ur(e.type),s=Do.rowName?Do.rowName(e,"section",l):l,d=e=>El(o,e,()=>Ni(o,e),St.addSectionHere);/* @__PURE__ */
|
|
15
|
+
return Tn(An,{children:[
|
|
16
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:e.type,size:13}),name:s,preview:Mi(e),marks:ji(e),onSelect:()=>vi(t),nameSlot:si(le,t,n,s),selected:bo===n,actions:Li(e,le,t)??void 0,rowProps:{"data-node-id":n,onClick:Pi(()=>vi(t))},fold:{open:!i,label:"section",onToggle:()=>cr(n)}}),!i&&/* @__PURE__ */Tn(ze,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Gr(n),l=Yi(n),s=l&&ar(r),a=()=>Ki(o,t,r,e.type),{rowProps:c,...p}=wl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...un(o),index:t}},{"data-node-id":r,onClick:Pi(a)});/* @__PURE__ */
|
|
17
|
+
return Tn(wn,{children:[d(t),
|
|
18
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:n.type,size:13}),name:i,preview:Mi(n),marks:ji(n),onSelect:a,nameSlot:si(o,t,r,i),selected:bo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>cr(r)}:void 0,actions:/* @__PURE__ */Tn(An,{children:[Ai(o,t,i),Li(n,o,t),Ri(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */Pn(ze,{children:Dl(n,2)})]},r)}),d(r.length)]})]})},Wl=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=wl.dragging,d=!ar(l)&&s?.rung?.nodeId!==i,a={...un(l),index:0},c=s&&!s.rung&&ml(s,a)?a:void 0,p=()=>ei(e,n,!0),{rowProps:u,...f}=wl.row({item:{id:`rung:${l}`,zone:`${i}:${En}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:En,index:t},into:c,canDrag:Boolean(Lo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Pi(p)}),h=Yn?null:Lo.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
19
|
+
return Tn(wn,{children:[n.heading,
|
|
20
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Zr===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>cr(l)},actions:h&&h.length>0?/* @__PURE__ */Pn(An,{children:h.map((t,o)=>/* @__PURE__ */Pn(Ne,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Yn||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&ni(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__ */Pn(Nn,{size:15}):/* @__PURE__ */Pn($n,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Pn(ze,{children:r})]},l)},Ul=(e,n)=>{const t=Ui(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
21
|
+
return Pn(An,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Gi(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=null!==a&&Boolean(yl(a)?.choices.length),p=(e,n)=>c?El(e,n,()=>Ni(e,n),St.addBlockHere):El(e,n),u=/* @__PURE__ */Tn(An,{children:[i.map(({child:n,zone:t,index:o})=>{const r=bo===String(n.props.id),{collapsible:i,folded:s}=Qi(n,l,Ji(n.type)),d=String(n.props.id),a=cl(n),c=()=>Ki(t,o,d,e.type),{rowProps:u,...f}=wl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...un(t),index:o}},{"data-node-id":d,onClick:Pi(c)});/* @__PURE__ */
|
|
22
|
+
return Tn(wn,{children:[0===o&&p(t,0),
|
|
23
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:n.type,size:13}),name:a,preview:Mi(n),marks:ji(n),onSelect:c,nameSlot:si(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>cr(d)}:void 0,actions:/* @__PURE__ */Tn(An,{children:[Ai(t,o,a),Li(n,t,o),Ri(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Pn(ze,{children:Ul(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==a?null:p(a,0)]});return t.rung?Wl(e,t.rung,r++,o,u):/* @__PURE__ */Pn(wn,{children:u},t.slot??"")})})},Dl=(e,n)=>{const t=Fo(nt?.data,e.type,String(e.props.id)),o=Ui(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
24
|
+
return Pn(An,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Gi(e.type,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=a&&!a.fixed?`${u}:${a.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(n,t)=>{const o=n===f&&a&&!a.addBlocked?.(c)?()=>_i(e.props.id,a.slot,a.childType,t,e.type):n===h?()=>Ni(n,t):void 0;return El(n,t,o,n===f&&a?a.addLabel:St.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===f)),k=/* @__PURE__ */Tn(An,{children:[l.map(({child:n,zone:t,index:o})=>{const r=bo===String(n.props.id),i=ii(n),l=String(n.props.id),{collapsible:d,folded:a}=Qi(n,s,Ji(n.type)),c=Vi(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...un(p),index:Yr(p).length}:void 0,f=wl.dragging,h=u&&f&&ml(f,u)?u:void 0,g=()=>Ki(t,o,l,e.type),{rowProps:y,...k}=wl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...un(t),index:o},into:h,canDrag:!Ro(n.type)},{"data-node-id":l,onClick:Pi(g)});/* @__PURE__ */
|
|
25
|
+
return Tn(wn,{children:[0===o&&m(t,0),
|
|
26
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:n.type,size:13}),name:i,preview:Mi(n),marks:ji(n),onSelect:g,nameSlot:si(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!a,label:"group",onToggle:()=>cr(l)}:void 0,actions:Ro(n.type)?Li(n,t,o)??void 0:/* @__PURE__ */Tn(An,{children:[Ai(t,o,i),Li(n,t,o),Ri(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */Pn(ze,{children:Dl(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
|
|
27
|
+
/* @__PURE__ */Pn(I,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>_i(e.props.id,a.slot,a.childType,c.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?Wl(e,o.rung,i++,r,k):/* @__PURE__ */Pn(wn,{children:k},o.slot??"")})})},Hl=(()=>{if(!rt||!ko)return null;const e=String(rt.type),n=String(rt.props.id),t=Wo(e,Fo(nt?.data,e,n));if(!t||"footer"===t.source)return null;const o=jr.some(e=>String(e.props?.id)===n),r=Array.isArray(rt.props[t.slot])?rt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:Ur(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:$i(rt,o),choices:i,onPick:o=>{t.spec?_i(n,t.slot,o,r.length,e):Zi(`${n}:${t.slot}`,o,r.length)}}})(),Gl=wo&&wo.zone!==le&&!hl(wo.zone)?wo.zone:null,Ql=!0===uo.blocksFirst,Xl=Gl?yl(Gl):Ql&&wo?null:Hl,Yl=Boolean(co&&Gl)||Ql&&Boolean(Xl&&Xl.choices.length>0),Jl=io||null!==Qt,Kl=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:jt&&!Jl&&jo===e.id,onSelect:()=>Pr(e.id)}:e,_l=[{id:"add",label:St.add.title,icon:/* @__PURE__ */Pn("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:io,onSelect:()=>io?Oi():Ci(null)},...(Ao.railLead??[]).map(Kl),{id:"sections",label:St.layers,icon:/* @__PURE__ */Pn(Me,{}),active:jt&&!Jl&&"sections"===jo,onSelect:()=>Pr("sections")},...(Ao.railTrail??[]).map(Kl)];Gt?_l.push({id:"media",label:St.railMedia,icon:/* @__PURE__ */Pn(je,{}),active:jt&&!io&&(null!==Qt||"media"===jo),onSelect:()=>Pr("media")}):Zn&&_l.push({id:"media",label:St.railMedia,icon:/* @__PURE__ */Pn(je,{}),onSelect:Tr});const Zl=[...Ao.railLead??[],...Ao.railTrail??[]].find(e=>"panel"in e&&e.id===jo),ql=Boolean(kt?.foldable)&&!Mo,es=kt?.label??(qn?St.pageSections:St.templateSections),ns=ql&&ar(Fn),ts=/* @__PURE__ */Tn(An,{children:[jr.map((e,n)=>{if(mt(e)||gt(e)||pt(e.type))return null;const t=bo===String(e.props.id),o=Boolean(e.props._hidden);Wi(e);const r=String(e.props.id),i=Ao.hasOwnRows?.(e)??!1,l=Yi(e)||i,s=l&&ar(r),{rowProps:d,...a}=wl.row({item:{id:r,zone:le,index:n,type:e.type},place:{...un(le),index:n}},{"data-node-id":r,onClick:Pi(()=>vi(n))});/* @__PURE__ */
|
|
28
|
+
return Tn(wn,{children:[n>0&&Ei(n),
|
|
29
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:e.type,size:13}),name:Gr(e),preview:Mi(e),marks:ji(e),onSelect:()=>vi(n),nameSlot:si(le,n,r,Gr(e)),selected:t,hidden:o,...a,fold:l?{open:!s,label:"section",onToggle:()=>cr(r)}:void 0,actions:/* @__PURE__ */Tn(An,{children:[Ai(le,n,Gr(e)),Li(e,le,n),Ri(le,n,e,Gr(e))]}),rowProps:d}),Yi(e)&&!s&&/* @__PURE__ */Tn(ze,{children:[Dl(e,1),Ao.partRows?.(e,Fl)]}),i&&!s&&/* @__PURE__ */Pn(ze,{children:Ao.ownRows?.(e,n,Fl)})]},String(e.props.id??n))}),!Mo&&sl>0&&Ei(sl),kt?.addAtEnd&&!Mo&&!Yn&&/* @__PURE__ */Pn(I,{small:!0,label:St.addSection,blocked:null,onAdd:()=>Ci(sl)})]}),os=(e,n,t)=>{const o=String(e.props.id),r=Di(e).length>0||Hi(e)||Boolean(Wo(e.type)),i=r&&ar(o),l="header"===t?St.header:St.footer,s=Do.rowName?Do.rowName(e,"section",l):l;/* @__PURE__ */
|
|
30
|
+
return Tn(An,{children:[
|
|
31
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:t,size:13}),name:s,preview:Mi(e),marks:ji(e),onSelect:()=>vi(n),nameSlot:si(le,n,o,s),selected:bo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>cr(o)}:void 0,actions:Li(e,le,n)??void 0,rowProps:{"data-node-id":o,onClick:Pi(()=>vi(n))}}),r&&!i&&/* @__PURE__ */Pn(ze,{children:Ul(e,1)})]})};return(Ao.wrap??(e=>e))(
|
|
32
|
+
/* @__PURE__ */Pn(te,{target:oo,children:/* @__PURE__ */Tn("div",{ref:to,className:"sf-editor es-editor",style:Ye(rr),onContextMenu:fi.onEditorContextMenu,...m(Re),children:[
|
|
33
|
+
/* @__PURE__ */Tn(Ee,{children:[
|
|
34
|
+
/* @__PURE__ */Pn(Fe,{items:_l,ariaLabel:St.bar.views}),
|
|
35
|
+
/* @__PURE__ */Tn(Ve,{children:[
|
|
36
|
+
/* @__PURE__ */Pn(We,{label:St.bar.undo,disabled:Boolean(Yn)||!ot.hasPast,onClick:()=>ot.back(),children:/* @__PURE__ */Pn(Bn,{})}),
|
|
37
|
+
/* @__PURE__ */Pn(We,{label:St.bar.redo,disabled:Boolean(Yn)||!ot.hasFuture,onClick:()=>ot.forward(),children:/* @__PURE__ */Pn(Cn,{})}),
|
|
38
|
+
/* @__PURE__ */Pn(Ue,{}),
|
|
39
|
+
/* @__PURE__ */Pn(De,{devices:Rt,value:Ut,onChange:Dt})]}),
|
|
40
|
+
/* @__PURE__ */Tn(Ve,{kind:"right",style:{minWidth:300},children:[
|
|
41
|
+
/* @__PURE__ */Pn(Mn,{saveState:Hn,notSaving:Boolean(Yn)||null!=Gn,readOnlyReason:Jn,toggle:Kn,onToggle:Xn,onRetry:Qn,words:St.bar,saveWords:xt}),Ao.barLead?.(),
|
|
42
|
+
/* @__PURE__ */Pn(xn,{content:St.bar.refreshTip,side:"bottom",children:/* @__PURE__ */Pn(bn,{variant:"secondary",onClick:()=>{no.current=(()=>{const e=oo?.document;if(!e)return null;const n=jr.findIndex(gt),t=n>=0?n:jr.length;let o=null;for(let n=0;n<t;n++){const t=jr[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=rt?.props?.id??jr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),eo(e=>e+1)},children:St.bar.refresh})}),Ao.barTrail?.(),Ao.barMain?Ao.barMain():/* @__PURE__ */Pn(bn,{variant:"primary",disabled:null!==Jn,onClick:()=>{Dn(nt.data)},children:St.done})]})]}),
|
|
43
|
+
/* @__PURE__ */Pn(z,{}),
|
|
44
|
+
/* @__PURE__ */Tn("div",{className:"sf-body",children:[jt?/* @__PURE__ */Tn(An,{children:[
|
|
45
|
+
/* @__PURE__ */Pn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":St.leftPanel,children:io?/* @__PURE__ */Pn($,{blocks:Xl,blocksOnly:Yl,at:co?{label:(e=>{const n=hl(e.zone);if(n)return St.add.addingTo({name:Do.rowName?$i(n,!0):Ur(n.type)});if(e.zone===le){const n=jr[e.index];return n&&!gt(n)?St.add.addingBefore({name:$i(n,!0)}):St.add.addingAtEnd}const t=yl(e.zone);return t?St.add.addingTo({name:t.parentName}):St.add.addingHere})(co),onClear:()=>po(null)}:void 0,onAdd:e=>{const n=wo,t=(e,n)=>{co&&po({zone:e,index:n})};if(n&&"block"!==e.kind&&hl(n.zone))return Ii(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===xo)return void zi(e);const n=zi(e,xo);co&&fo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===xo)return void Bi(e,n);const t=Bi(e,n,xo);co&&fo(t+1)})(e.template.name,Fr(e.template.node));if(n&&n.zone!==le){const o=yl(n.zone);if(!o)return;return o.target.spec?_i(o.parentId,o.target.slot,e.type,n.index,o.parent.type):Zi(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Hl?.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:vl,siteWide:Ao.addPanelRow?.(Oi),onClose:Oi,onHide:Ir,readOnly:Boolean(Yn)}):Qt&&Ht?
|
|
46
|
+
/* @__PURE__ */Pn(A,{panel:Ht,pick:Qt,onHide:Ir}):Zl?Zl.panel({onHide:Ir,notify:hr}):"media"===jo&&Ht?/* @__PURE__ */Pn(A,{panel:Ht,pick:null,onHide:Ir}):/* @__PURE__ */Tn(An,{children:[
|
|
47
|
+
/* @__PURE__ */Pn(P,{icon:/* @__PURE__ */Pn(Me,{}),title:St.layers,context:Ct,actions:
|
|
48
|
+
/* @__PURE__ */Pn(He,{label:al?St.expandAll:St.collapseAll,title:0===dl.length?St.nothingToFold:void 0,disabled:0===dl.length,onClick:()=>or(e=>{const n=new Set(dl);return al?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...dl])}),children:/* @__PURE__ */Pn(jn,{expand:al})}),onHide:Ir}),
|
|
49
|
+
/* @__PURE__ */Tn(Be,{className:"sf-tree sf-scroll",words:vt,children:[
|
|
50
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:"page",size:13}),name:St.pageSettings,onSelect:Ar,selected:!rt&&ko,rowProps:{onClick:Pi(Ar)}}),il&&/* @__PURE__ */Tn(An,{children:[
|
|
51
|
+
/* @__PURE__ */Pn(Ce,{children:St.header}),Vl(il)]}),!Mo&&et&&/* @__PURE__ */Tn(An,{children:[
|
|
52
|
+
/* @__PURE__ */Pn(Ce,{children:St.header}),!yt&&/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:"header",size:13}),name:St.header,onSelect:Mr,selected:go.kind===ht?.kind,rowProps:{onClick:Pi(Mr)}})]}),!Mo&&rl&&os(rl,ol,"header"),!Mo&&!ql&&/* @__PURE__ */Pn(Ce,{children:es}),ql?/* @__PURE__ */Tn(An,{children:[
|
|
53
|
+
/* @__PURE__ */Pn(be,{words:vt,icon:null,name:es,fold:{open:!ns,label:es,onToggle:()=>cr(Fn)}}),!ns&&/* @__PURE__ */Pn(ze,{children:ts})]}):ts,et&&/* @__PURE__ */Pn(Ce,{children:St.footer}),tl&&os(tl,nl,"footer"),!Mo&&!tl&&et&&/* @__PURE__ */Pn(be,{words:vt,icon:/* @__PURE__ */Pn(Go,{type:"footer",size:13}),name:St.footer,onSelect:Ti,rowProps:{onClick:Pi(Ti),title:St.editFooter}}),ll&&Vl(ll),Ao.treeFoot?.()]})]})}),
|
|
54
|
+
/* @__PURE__ */Pn(Ge,{side:"left",width:rr.left,min:Xe,max:Qe,defaultWidth:k.left,label:St.resizeLeftPanel,onResize:sr})]}):/* @__PURE__ */Pn(T,{side:"left",onShow:Ir}),
|
|
55
|
+
/* @__PURE__ */Tn("div",{ref:mr,className:"sf-center sf-scroll","data-sf-canvas-head":vr?"":void 0,style:{overflowX:Cr?"auto":"hidden",overflowY:"hidden"},children:[vr&&/* @__PURE__ */Pn("div",{ref:wr,className:"sf-canvas-head",children:/* @__PURE__ */Pn(vr,{device:Ut})}),
|
|
56
|
+
/* @__PURE__ */Pn("div",{className:"sf-frame-scaler",style:Nr,children:/* @__PURE__ */Pn("div",{className:"sf-frame "+(Ut===Vt?"":`sf-frame--${Ut}`),style:Or,children:/* @__PURE__ */Tn("div",{className:"sf-preview-host",children:[
|
|
57
|
+
/* @__PURE__ */Pn(Nt,{},qt),
|
|
58
|
+
/* @__PURE__ */Pn(qe,{canvas:oo,session:vl,model:Il,measure:Pl,canDrop:Al,onDrop:jl,choose:zl,onPick:Rl,onZoneAdd:e=>{const n=an(e),t=_r(n);t&&ei(t.node,t.slot,!1),Ni(n,0)},zoneAddLabel:St.canvasAddBlock,words:wt.canvas,readOnly:Boolean(Yn),revision:nt.data}),ho.length>0&&/* @__PURE__ */Pn("div",{className:"sf-preview-gaps","aria-hidden":"true",children:ho.map(e=>/* @__PURE__ */Tn("button",{type:"button",tabIndex:-1,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},onClick:()=>Ci(e.index),children:[
|
|
59
|
+
/* @__PURE__ */Pn("span",{className:"sf-preview-gap-line"}),
|
|
60
|
+
/* @__PURE__ */Tn("span",{className:"sf-preview-gap-pill",children:[
|
|
61
|
+
/* @__PURE__ */Pn("span",{className:"sf-preview-gap-plus",children:"+"}),
|
|
62
|
+
/* @__PURE__ */Pn("span",{className:"sf-preview-gap-label",children:St.addSection})]})]},e.index))})]})})})]}),Lt?/* @__PURE__ */Tn(An,{children:[
|
|
63
|
+
/* @__PURE__ */Pn(g,{value:{selectChild:Ki,addChild:_i,childRowName:ii,blockRowName:cl},children:/* @__PURE__ */Pn(Ot,{mode:go,onOpenWebsiteSettings:Ao.openSettings??(()=>{}),onOpenSiteStyles:Ao.openStyles,onSelectNode:Jo,onNotify:hr,onHidePanel:$r,nodeActions:rt?se(lt,rt.type):Vn})}),
|
|
64
|
+
/* @__PURE__ */Pn(Ge,{side:"right",width:rr.right,min:Xe,max:Qe,defaultWidth:k.right,label:St.resizeSettingsPanel,onResize:dr})]}):
|
|
65
|
+
/* @__PURE__ */Pn(T,{side:"right",onShow:$r})]}),fi.menu]})}))}export{Wn as ScreenChrome};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-EXCKAZKN.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-DSUMM2WF.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,isSafeLinkHref as o,toggleMark as i}from"./chunk-546BBOPE.js";var a=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),s=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function c(l,i){const c=i.rules??t,d=l.html&&""!==l.html.trim()?function(t,l,i){const c=l.createElement("template");c.innerHTML=t;const d=[[]],h=()=>d[d.length-1],f=()=>{const t=h();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&d.push([])},m=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=h();" "===t&&(0===o.length&&d.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,i=1===t.nodeType?l.localName:"";if(a.has(i))return;if("br"===i)return void d.push([]);let c=e,u=n,p=r;if("b"!==i&&"strong"!==i||(c=!0),"i"!==i&&"em"!==i||(u=!0),"a"===i){const t=(l.getAttribute("href")??"").trim();p=o(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?c=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(c=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?u=!0:"normal"===g.fontStyle&&(u=!1)}const b=s.has(i);b&&f();for(const e of[...t.childNodes])m(e,c,u,p);b&&f()};m(c.content,!1,!1,null);for(;d.length>1&&0===d[d.length-1].length;)d.pop();return d.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const a of i){const i=u(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],r(s,l)))return s}return t.map(t=>t.ch).join("")}(t,i))}(l.html,i.doc,c):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return i.multiline?d.join("\n"):1===d.length?d[0]:d.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function u(t,e,n,r){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),a=e?.[c]?a??l(++o,"bold"):null,s=n?.[c]?s??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var d="application/x-efficient-markup",h=/^([0-9]{1,3})\. $/;function f(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const a=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:h.exec(n[e]),a=t.bullet||r,s=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,f={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,f});return{lines:a,text:a.map(t=>t.text).join("\n")}}function m(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function p(t,e){const[n,r]=m(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function g(t,e){const[n,r]=m(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return p(t,e)}function b(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function k(t,e,n){return[b(t,e),b(t,n)]}function x(t,e,n){return e===n?[p(t,e),p(t,e)]:[g(t,e),p(t,n)]}function y(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function v(t,o,i,a,s){const c=f(t,o),[u,d,h]=m(c,Math.min(i,a)),[p,g,b]=m(c,Math.max(i,a)),k=y(u,d),x=y(p,g),v=u.chars.slice(0,k),D=p.chars.slice(x),w=i!==a&&u.chars[k]&&(h!==b||k<x)?u.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,k);let T=(A=c.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const M=t=>{let e;if(void 0!==s.markup){const t=T;e=r(s.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(s.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...D]}}else l.chars.push(...D);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(b+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},N=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:l(T++,"color",s.color);t&&(e=[...e,t])}return e})(w),w,[]];let S="",B="";for(const t of N){const r=M(t),l=e(r.lines).text;if(S=l,B=r.shown,n(r.lines,f(l,o).lines))break}return{text:S,caret:Math.min(i,a)+B.length}}function D(t,e,n,r){const l=f(t,e),[o,,i]=m(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?v(t,e,n,r,{text:"\n"}):w(t,e,i,!1,n)}function w(t,n,r,l,o){const i=f(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function T(t,n,r,l){const o=f(t,n),[i,a,s]=m(o,Math.min(r,l)),[c,u,d]=m(o,Math.max(r,l)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?y(i,a):0,o=r===d-s?y(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function A(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function M(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:D(e,n,i,a),range:s}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let u=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=c({html:t.html??void 0,text:u},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:v(e,n,i,a,{markup:l}),range:s}}return r||(u=u.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:v(e,n,i,a,{text:u,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(l.startsWith("delete")){const t=f(e,n),r=t.text;if(i===a){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:w(e,n,c,!1,i),range:s};if(o?0===i:i===r.length)return null;o?i=A(r,i,-1):a=A(r,a,1)}return{kind:"type",edit:v(e,n,i,a,{text:""}),range:[i,a]}}return null}var N=1e3;function S(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,a){const s="type"===i&&"type"===r&&a-l<1e3;r=i,l=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var B=/^(block|list-item|flex|grid|table|flow-root)$/;function E(t){const e=t.ownerDocument.defaultView;return!!e&&B.test(e.getComputedStyle(t).display)}function j(t){const e=[],n=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let l="",o=!1;const i=()=>{o&&(l+="\n",o=!1)},a=t=>{for(const s of Array.from(t.childNodes)){if(3===s.nodeType){s.data.length>0&&i(),n.set(s,l.length),e.push({node:s,start:l.length,length:s.data.length}),l+=s.data,r.set(s,l.length);continue}if(1!==s.nodeType)continue;const t=s;if("BR"===t.tagName){i(),n.set(t,l.length),l+="\n",r.set(t,l.length);continue}const c=E(t);c&&((o||l.length>0&&!l.endsWith("\n"))&&(l+="\n"),o=!1),n.set(t,l.length);const u=l.length;a(t),c&&l.length===u&&!o&&e.push({node:t,start:u,length:0}),r.set(t,l.length),c&&(o=!0)}};n.set(t,0),a(t),r.set(t,l.length);return{text:l,at:(t,e)=>{if(3===t.nodeType)return(n.get(t)??0)+Math.min(e,t.data.length);const o=t.childNodes;return e<o.length?n.get(o[e])??r.get(t)??0:r.get(t)??l.length},dom:n=>{for(let t=0;t<e.length;t+=1){const r=e[t],l=r.start+r.length;if(n<r.start)return[r.node,0];if(n<l||n===l&&(t===e.length-1||e[t+1].start>n))return 3===r.node.nodeType?[r.node,n-r.start]:[r.node,0]}const r=e[e.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function C(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(j(e).text!==f(n,r).text)return null;const l=t.now??(()=>Date.now()),o=S();let a=e,s=!1,u=null,h=null,m=[t.caret[0],t.caret[1]];const p={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},g=()=>a.ownerDocument,b=()=>g().defaultView?.getSelection()??null,y=()=>{if(!h)return!0;!function(){const e=t.element();if(!e||e===a)return;O(a),a=e,F(a)}();const e=j(a);if(e.text!==f(n,r).text)return!1;const[l,o]=h,[i,s]=e.dom(l),[c,u]=e.dom(o);return g().activeElement!==a&&a.focus({preventScroll:!0}),b()?.setBaseAndExtent(i,s,c,u),m=h,h=null,!0},D=()=>{y();const t=b();if(!(t&&t.anchorNode&&t.focusNode&&a.contains(t.anchorNode)&&a.contains(t.focusNode)))return m;const e=j(a),n=e.at(t.anchorNode,t.anchorOffset),r=e.at(t.focusNode,t.focusOffset);return m=n<=r?[n,r]:[r,n],m},w=(t,e)=>{h=[t,e];const n=t=>{if(s||y())return;const e=g().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},A=(e,r,i)=>{e.text!==n?(o.record({text:n,start:r[0],end:r[1]},i,l()),n=e.text,t.write(n),w(e.caret,e.caret)):w(e.caret,e.caret)},N=e=>{n=e.text,t.write(n),w(e.start,e.end)},B=e=>{s||(s=!0,O(a),t.end(e))},E=(t,e)=>{const l=D();!s&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",f(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(d,T(n,r,l[0],l[1])),e&&A(v(n,r,l[0],l[1],{text:""}),l,"edit"))},C=t=>t.preventDefault(),P=()=>{t.remount?.()},q=[["keydown",t=>{if(s||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void B("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void B("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=D(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?o.redo(r):o.undo(r);l&&N(l)}}],["beforeinput",e=>{if(s)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const c=D(),u=j(a),d="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,h=d&&!d.collapsed?[u.at(d.startContainer,d.startOffset),u.at(d.endContainer,d.endOffset)]:null,m=M({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:g(),sel:c,target:h});if(m){if("history"===m.kind){const t={text:n,start:c[0],end:c[1]},e="undo"===m.dir?o.undo(t):o.redo(t);return void(e&&N(e))}if("format"===m.kind){const e=f(n,r),[a,s]=x(e,c[0],c[1]),u=i(n,a,s,m.style,r);if(u.text===n)return;o.record({text:n,start:c[0],end:c[1]},"edit",l()),n=u.text,t.write(n);const[d,h]=k(f(n,r),u.selectionStart,u.selectionEnd);return void w(d,h)}A(m.edit,m.range,m.kind)}}],["compositionstart",()=>{u=D()}],["compositionend",e=>{const i=u;if(u=null,!s&&i)if(e.data){const a=v(n,r,i[0],i[1],{text:e.data});o.record({text:n,start:i[0],end:i[1]},"type",l()),n=a.text,t.write(n),P(),w(a.caret,a.caret)}else P(),w(i[0],i[0])}],["paste",e=>{if(s)return;e.preventDefault();const l=D(),o=e.clipboardData,i=o?.getData(d)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):c({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:g(),multiline:t.multiline,rules:r});A(v(n,r,l[0],l[1],{markup:a}),l,"edit")}],["copy",t=>E(t,!1)],["cut",t=>E(t,!0)],["drop",C],["dragstart",C],["blur",e=>{if(s||null!==u)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{s||(n.isConnected&&n===t.element()?n.ownerDocument.activeElement!==n&&B("blur"):w(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}]];function F(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of q)t.addEventListener(e,n)}function O(t){for(const[e,n]of q)t.removeEventListener(e,n);null===p.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",p.contenteditable),null===p.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",p.spellcheck),t.removeAttribute("data-es-typing")}return F(a),a.focus({preventScroll:!0}),w(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=f(t,r).text.length,[l,i]=D();n=t,o.reset(),w(Math.min(l,e),Math.min(i,e))},stop(t="stop"){B(t)}}}export{d as MARKUP_CLIPBOARD_TYPE,N as TYPING_BURST_MS,S as createHistory,v as editVisible,T as markupOfRange,D as newLine,c as pasteToMarkup,M as richInput,f as richLayout,x as selectionToSource,k as selectionToVisible,w as setBullet,C as startCanvasTyping,j as textMap,p as toSource,g as toSourceStart,b as toVisible};
|
|
@@ -0,0 +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-MCHMF32I.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 u,useCanvasEvent as d,framePointToHost as p}from"./chunk-AWJUYMX7.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,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 A,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function S(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(),j=/* @__PURE__ */new WeakMap;function D(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=j.get(n);return t||(t=c(),j.set(n,t)),t}function T(){return D(n())}function X(e,n,o){if(n===t){const{floor:n,cap:t}=e.sectionBand();return{parentId:h,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 I(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}}function E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?X(e,t.zone,t.index+1):null;for(const l of S(e,t)){const t=X(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(e){if(e.defaultPrevented||e.altKey||e.shiftKey||!e.metaKey&&!e.ctrlKey)return null;if(u(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;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function R(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=I(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;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 U(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),u=Boolean(i.props._hidden),d=n.nodeOps,p=n.isPinned(i,l),f=n.isLocked(i),m=!p&&!f&&!n.duplicateBlocked(i),h=n.permits?.(i)??{duplicate:!0,delete:!0},y=I(n,i,l),k=S(n,o),b=d.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&&h.duplicate?()=>d.duplicate(c):void 0,moveUp:g&&d.canStep(c,-1)?()=>d.step(c,-1):void 0,moveDown:g&&d.canStep(c,1)?()=>d.step(c,1):void 0,copy:y.copy?()=>d.copy(c,a):void 0,cut:g&&y.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&n.renamePropOf(i,l)?()=>n.beginRename(l,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:n.menuRows?.(i,l,r)??void 0,pinnedLine:p?Y(n).pinned:void 0})}var Y=e=>e.words?.screen??l.menu;function V(e){const n=Y(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=o?[{label:n.addSection,icon:/* @__PURE__ */M(C,{}),onClick:e.openAddSection}]:[],c=e.nodeOps.held,s=X(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__ */M(z,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[{label:e.pageSettingsLabel??l.pageSettings,icon:/* @__PURE__ */M(P,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */M(A,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function B(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=Y(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(z,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function F(e){return e.shiftKey}function N(e,n){const[t,l]=y(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=R(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]),d(n,"keydown",c);const a=k(n=>{if(F(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(n,"contextmenu",t=>{if(F(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})}),d(n,"mousedown",r),d(n,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:t?/* @__PURE__ */M(G,{host:e,target:t,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?B(e,n.el):V(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),children:/* @__PURE__ */M(r,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,S as ancestorChain,D as nodeClipboardOf,I as nodeClipboardRules,U as nodeMenuItems,L as nodeShortcut,V as pageMenuItems,E as pastePlace,R as runNodeShortcut,B as textMenuItems,T as useNodeClipboard,N as useNodeContextMenu};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as n}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as r}from"./chunk-
|
|
1
|
+
import{clientOnly as n}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as r}from"./chunk-H3WBX7FN.js";import{ScreenChrome as e}from"./chunk-HAUTMX4H.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-WZMU646D.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-MCHMF32I.js";import{documentPermissions as o}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t}from"react";import{Dialog as d,Button as l}from"efficient-shell/ui";import{jsx as m,jsxs as g,Fragment as h}from"react/jsx-runtime";var f=n(r),v=n(e);function p({saving:n,onCancel:r,onDiscard:e,onSave:i}){const a=c("screen",s).leave;/* @__PURE__ */
|
|
2
2
|
return m(d,{open:!0,role:"alertdialog",size:"sm",title:a.title,onClose:r,footer:/* @__PURE__ */g(h,{children:[
|
|
3
3
|
/* @__PURE__ */m(l,{variant:"secondary",onClick:r,children:a.cancel}),
|
|
4
4
|
/* @__PURE__ */m(l,{variant:"ghost-danger",onClick:e,children:a.discard}),
|
|
5
5
|
/* @__PURE__ */m(l,{variant:"primary",loading:n,onClick:i,children:n?a.saving:a.save})]}),children:a.body})}function u({target:n,addressing:r,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return m(i,{target:n,addressing:r,onHostMessage:e,children:a})}var
|
|
7
|
-
/* @__PURE__ */m(f,{config:n,data:i,onChange:
|
|
6
|
+
return m(i,{target:n,addressing:r,onHostMessage:e,children:a})}var k=(n,r)=>/* @__PURE__ */g(h,{children:[n,r]});function C({config:n,parts:r,wrap:e=k}){const{data:i,error:d,redirecting:l,ready:g,saveStatus:h,readOnly:u,onChange:C,pendingNav:N,cancelPendingNav:j,discardAndNavigate:H,saveAndNavigate:M}=a(),y=t(()=>o(!u),[u]),A=c("screen",s);return l?/* @__PURE__ */m("div",{className:"sf-msg",children:A.loading}):d?/* @__PURE__ */m("div",{className:"sf-msg sf-msg--error",children:d}):g?i?e(
|
|
7
|
+
/* @__PURE__ */m(f,{config:n,data:i,onChange:C,permissions:y,parts:r,children:/* @__PURE__ */m(v,{})}),N&&/* @__PURE__ */m(p,{saving:"saving"===h,onCancel:j,onDiscard:H,onSave:()=>{M()}})):/* @__PURE__ */m("div",{className:"sf-msg",children:A.loading}):/* @__PURE__ */m("div",{className:"sf-msg",children:A.waitingForAuthorization})}export{C as DocumentScreen,u as ScreenMount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as o,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as o,bindUndoKeys as t}from"./chunk-DSUMM2WF.js";import{useState as e,useEffect as u}from"react";function r(o){const t=n(),[r,c]=e(null);return u(()=>c(o.current),[o]),t.ownsDocument?"undefined"==typeof document?null:document:r}function c(e,c){const m=n(),i=o(),f=r(e);u(()=>{if(!m.ownsDocument&&f)return t(f,i,{leaveTyping:!0})},[m,i,f]);const s=c?.document??null;u(()=>{if(!m.ownsDocument&&s)return t(s,i,{leaveTyping:!0})},[m,i,s])}function m(n){return n.ownsDocument?{}:{tabIndex:-1}}export{m as editorRootFocus,r as useEaselKeyTarget,c as useEaselUndoKeys};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-I6U2G7L4.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-EXCKAZKN.js";import{useEasel as p}from"./chunk-DSUMM2WF.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 K=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(K)},[K,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:K}}export{m as usePartBridge};
|