efficient-easel 27.2.0 → 27.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/{AddSidePanel-DoCx-ZrM.d.ts → AddSidePanel-DwfZOS5C.d.ts} +11 -3
- package/dist/blocks/index.d.ts +1 -1
- package/dist/{canvas-typing-CD1aeYnk.d.ts → canvas-typing-B33ssbpU.d.ts} +22 -3
- package/dist/chunk-2DFSODES.js +1 -0
- package/dist/{chunk-I4Z75MCX.js → chunk-2ODVRWRM.js} +1 -1
- package/dist/{chunk-SR2535CN.js → chunk-36AWYQLN.js} +17 -17
- package/dist/{chunk-JI7GUM3C.js → chunk-4JPAVKV6.js} +1 -1
- package/dist/{chunk-ZSP4ZAQ2.js → chunk-7WONGRN3.js} +40 -40
- package/dist/chunk-AI5IQV4A.js +2 -0
- package/dist/chunk-BDYS3UAD.js +5 -0
- package/dist/{chunk-3RGHXL5V.js → chunk-DFLPDOZF.js} +1 -1
- package/dist/chunk-IHYRYSP2.js +7 -0
- package/dist/chunk-JEKFHCKS.js +8 -0
- package/dist/{chunk-XGTO4LHI.js → chunk-JNNBGI6Y.js} +1 -1
- package/dist/chunk-KRONK73U.js +1 -0
- package/dist/{chunk-HGTDDSFJ.js → chunk-NMLAW6FI.js} +17 -17
- package/dist/chunk-OHHODU7N.js +26 -0
- package/dist/{chunk-MMHYTIUY.js → chunk-PMDIDRDB.js} +4 -4
- package/dist/{chunk-DQSRGKSM.js → chunk-SEC6NV6Y.js} +4 -4
- package/dist/{chunk-2Y4CAWZQ.js → chunk-TWXA55SR.js} +3 -3
- package/dist/chunk-WW24O7HT.js +1 -0
- package/dist/chunk-XT75WETI.js +1 -0
- package/dist/copy/index.d.ts +3 -3
- package/dist/copy/index.js +29 -29
- package/dist/data/index.d.ts +1 -1
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.d.ts +10 -2
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/panel/index.d.ts +5 -0
- package/dist/panel/index.js +1 -1
- package/dist/{phone-order-CRKvsTsz.d.ts → phone-order-BCM_f8A1.d.ts} +7 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.d.ts +2 -2
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +2 -2
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/SaveControls.d.ts +2 -2
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
- package/dist/screen/components/ScreenMount.d.ts +2 -2
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +2 -2
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +16 -16
- package/dist/screen/components/usePartBridge.d.ts +2 -2
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +2 -2
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/admin-bridge.d.ts +1 -1
- package/dist/screen/lib/document/add-target-types.d.ts +2 -2
- package/dist/screen/lib/document/block-set-host.js +1 -1
- package/dist/screen/lib/document/block-size-fields.d.ts +1 -1
- package/dist/screen/lib/document/block-size-fields.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +1 -1
- package/dist/screen/lib/document/box-fields.js +1 -1
- package/dist/screen/lib/document/button-fields.d.ts +1 -1
- package/dist/screen/lib/document/button-fields.js +1 -1
- package/dist/screen/lib/document/image-fields.d.ts +1 -1
- package/dist/screen/lib/document/image-fields.js +4 -4
- package/dist/screen/lib/document/new-child.d.ts +2 -2
- package/dist/screen/lib/document/palette-sections.d.ts +2 -2
- package/dist/screen/lib/document/section-doc.d.ts +1 -1
- package/dist/screen/lib/document/shadow-fields.d.ts +1 -1
- package/dist/screen/lib/document/shadow-fields.js +2 -2
- package/dist/screen/lib/document/slot-section-spec.d.ts +2 -2
- package/dist/screen/lib/document/style-clipboard.d.ts +2 -2
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/style-fields.d.ts +1 -1
- package/dist/screen/lib/document/style-fields.js +1 -1
- package/dist/screen/lib/document/use-section-ops.d.ts +37 -3
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/document-addressing.d.ts +1 -1
- package/dist/screen/lib/document-hooks.d.ts +1 -1
- package/dist/screen/lib/host.d.ts +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/media-panel.d.ts +1 -1
- package/dist/screen/lib/media-picker.d.ts +1 -1
- package/dist/screen/lib/page-lock.d.ts +1 -1
- package/dist/screen/lib/screen-parts.d.ts +2 -2
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/lib/section-templates.d.ts +1 -1
- package/dist/screen/lib/session-context.d.ts +1 -1
- package/dist/screen/lib/session.d.ts +1 -1
- package/dist/screen/lib/shared-sections.d.ts +1 -1
- package/dist/text-styles/index.js +11 -11
- package/package.json +4 -4
- package/dist/chunk-D4TH4QQR.js +0 -2
- package/dist/chunk-DCBUJ36Q.js +0 -5
- package/dist/chunk-LK56FUFT.js +0 -1
- package/dist/chunk-M5UCPD66.js +0 -1
- package/dist/chunk-MNQDOSAX.js +0 -7
- package/dist/chunk-OSF2H3LO.js +0 -1
- package/dist/chunk-PTTQWCD7.js +0 -1
- package/dist/chunk-SDSBXW3V.js +0 -26
- package/dist/chunk-YCYGY54I.js +0 -8
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-LK56FUFT.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-LDHUPZBK.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-TF6NAIV7.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as y}from"./chunk-MNQDOSAX.js";import{DEFAULT_COPY_WORDS as v}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CANVAS_TYPABLE_EVENT as b,onMotionEnd as k,CANVAS_TYPING_EVENT as S}from"./chunk-6GJEOER4.js";import{setCanvasNonce as x,related as C,isTypingTarget as I,upsertCanvasStyle as E,removeCanvasStyle as A,WORDS_CLEAR as D,frameRectToHost as M,drawnBox as O}from"./chunk-FR7EEKFF.js";import{queryAllCopies as $}from"./chunk-7UFKEX72.js";import{find as P,ROOT_ID as j,getList as z,remove as R,parseZoneKey as L,move as N,duplicate as V,replaceNode as B,createNode as T,insert as K,normalizeData as F,createResolveCache as Z,slotsOf as H,deepEqual as W,ROOT_SLOT as q,resolveNodeData as Y}from"./chunk-YDTEYXQW.js";import{topLevelSlotKeys as U,fieldsFrom as X,drawnBlockCount as G,defaultsFrom as Q}from"./chunk-KXM6YRG2.js";import{createContext as J,useEffect as _,useContext as ee,useRef as te,useSyncExternalStore as ne,useState as oe,useReducer as re,useCallback as le,createElement as ie,useMemo as se,useLayoutEffect as ae}from"react";import{jsx as ce,jsxs as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as pe}from"react-dom";import{registerModalEscapeInterceptor as fe,FloatingBar as he,TextToolbar as me,LinkPicker as ge}from"efficient-shell/ui";function ye(e){return!["setData","setUi","set"].includes(e.type)}var ve=(e,t,n,o)=>{const r=z(e,t,L(n));return r?.[o]??null},we=(e,t,n,o,r)=>{const l=ve(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function be(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ke(e,t,n){return n?"node"===n.kind?P(e,t,n.id)?n:null:n.parentId===j?z(e,t,n)?n:null:P(e,t,n.parentId)&&z(e,t,n)?n:null:null}function Se(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function xe(e,t,n){const o=Ce(e,t,n);if(o===e)return e;const r=ke(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function Ce(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Se(e,n,"function"==typeof t.ui?t.ui(be(e,n)):t.ui);case"set":{const r={data:o,ui:be(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=Se(i,n,l.ui,!0)),i}case"insert":{const r={...L(t.destinationZone),index:t.destinationIndex},l=T(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=we(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:B(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=we(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=V(o,n,r.props.id),i=ve(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return Ce(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ve(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...L(t.destinationZone),index:t.destinationIndex};return{...e,data:N(o,n,r.props.id,l)}}case"remove":{const r=we(o,n,t.zone,t.index,"remove");return{...e,data:R(o,n,r.props.id)}}default:return e}}var Ie={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ae=0,De=()=>`history-${Ae+=1}`;function Me(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=F(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ee}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ee,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:De()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,v=!1;const w=()=>{for(const e of[...f])e()},b=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},k=(t,n)=>{g>0?v=v||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=xe(c,e,t),c===n)return;const o=e.recordHistory??ye(e);k(n,o&&c.data!==n.data)},x=t=>{0===g&&(y=c,v=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,v&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},C=e=>{const n=c,o=ke(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},k(n,!1))},I=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Ie,...i,...n}};let A=E();const D=Z(),M={resolveCache:D,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([Y(r,t,{cache:D,trigger:e,metadata:n}),...l.map(o=>Y(o,t,{cache:D,trigger:e,metadata:n}))]);x(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=P(r,t,i)?.node;s&&s===P(o,t,i)?.node&&(r=B(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ke(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=P(c.data,t,e)?.node;if(!r)return!1;const l=await Y(r,t,{cache:D,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(P(c.data,t,e)?.node!==r)return;const o=B(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ke(o,t,c.selection)},k(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:be(e,t)},o="node"===e.selection?.kind?P(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>M.undo(),forward:()=>M.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:be(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&I(e)}},getPermissions:A,getItemById:n=>P(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return z(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:x,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>C(e?{kind:"node",id:e}:null),selectSlot:e=>C(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){x(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ke(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=F(e,t);c={...c,data:r,selection:ke(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0),c!==o&&w()},undo(){d>0&&I(d-1)},redo(){d<u.length-1&&I(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,i)||(i=e,A=E(),h=null,w())},setConfig(e){e!==t&&(t=e,A=E(),h=null,w())}};return M}function Oe(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&I(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var $e=J(null),Pe=J(!0);function je({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return _(()=>{n&&e.resolveAll()},[e,n]),_(()=>{if(t&&"undefined"!=typeof document)return Oe(document,e)},[e,t]),/* @__PURE__ */ce($e.Provider,{value:e,children:/* @__PURE__ */ce(Pe.Provider,{value:t,children:o})})}function ze(){const e=ee($e);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Re(e){const t=ze(),n=te({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ne(t.subscribe,o,o)}function Le(){return function(e){return Re(e)}}var Ne=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Ve="host-tokens";function Be(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Ne){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?E(t,Ve,n):A(t,Ve)}var Te="data-easel-block",Ke="data-easel-dropzone",Fe={},Ze="data-es-mirror",He="undefined"==typeof window?_:ae;function We(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ze}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ze,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function qe({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=te(null),[p,f]=oe(null);return He(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),He(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),x(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){We(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>We(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Be(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Be(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ce("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?pe(e,p):null})}var Ye=J(null),Ue=J(Fe),Xe=[];function Ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=ze(),s=Re(n=>z(n.appState.data,i.config,{parentId:e,slot:t})??Xe),a=Re(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==j),c=Re(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=ee(Ye),d=["es-zone"];return s.length&&d.push("has-children"),e===j&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==j&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ce("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ce(rt,{node:e},e.props.id))})}function Qe(e,t,n,o){const r=se(()=>{const n={};for(const o of U(X(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
-
return ce(Ge,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=
|
|
3
|
-
return ce(Ge,{parentId:e,slot:t,...n})},[e])}var _e=["top","bottom","zIndex"];function et(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function tt(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));et(e,"position",t?"sticky":"relative");for(const n of _e)et(e,n,t?.[n]??"");return!!t}var nt="data-es-canvas-relative";function ot(e){e.hasAttribute(nt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(nt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(nt,"")),!1)}function rt({node:e}){const t=ze().config,n=t.components[e.type],o=e.props.id,r=te(null),l=function(e,t){return se(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Te),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Te,e),n.setAttribute("data-easel-dnd",e),ot(n))},[e,t])}(o,r),i=te(null),s=!!n?.inline;!function(e,t){const n=te(!1),o=te(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=te(()=>{});He(()=>o.current()),He(()=>{const t=e(),l=t?.ownerDocument.defaultView;if(!t||!l)return;const i=()=>o.current();l.addEventListener("resize",i);const s=l.ResizeObserver,a=s?new s(i):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&l.MutationObserver&&(c=new l.MutationObserver(i),c.observe(e,{attributes:!0}))},r.current(),()=>{l.removeEventListener("resize",i),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:i.current,e=>s?ot(e):tt(e));const a=ee(Ue),c=
|
|
4
|
-
/* @__PURE__ */ce("div",{ref:i,[Te]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0})})}function lt({metadata:e}){const t=Re(e=>e.config),n=Re(e=>e.appState.data.root).props??{},o=t.root?.render,r=
|
|
5
|
-
return ce(Ue.Provider,{value:e??
|
|
6
|
-
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:t?St(o,r):void 0}:{display:"none"}})}var ht={"--es-words-clear":`${
|
|
7
|
-
return ce("div",{ref:o,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height,clipPath:n?St(r,l):void 0,...ht}:{display:"none"}})}function gt(e,t,n){return vt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var yt=[];function vt(e,t,n){const[o,r]=oe(yt),l=te(t);return l.current=t,He(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(yt);let o=0;const i=()=>{o=0;const n=e.current?.parentElement??null,i=(l.current?l.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-XT75WETI.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-LDHUPZBK.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-TF6NAIV7.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as y}from"./chunk-IHYRYSP2.js";import{DEFAULT_COPY_WORDS as v}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{find as b,ROOT_ID as k,getList as S,remove as x,parseZoneKey as I,move as C,duplicate as E,replaceNode as A,createNode as D,insert as O,normalizeData as M,createResolveCache as $,slotsOf as P,deepEqual as j,ROOT_SLOT as z,resolveNodeData as R}from"./chunk-YDTEYXQW.js";import{topLevelSlotKeys as N,fieldsFrom as L,drawnBlockCount as V,defaultsFrom as B}from"./chunk-KXM6YRG2.js";import{CANVAS_TYPABLE_EVENT as T,onMotionEnd as K,CANVAS_TYPING_EVENT as Z}from"./chunk-6GJEOER4.js";import{setCanvasNonce as F,related as H,isTypingTarget as W,upsertCanvasStyle as Y,removeCanvasStyle as q,WORDS_CLEAR as U,frameRectToHost as X,drawnBox as G}from"./chunk-FR7EEKFF.js";import{queryAllCopies as J}from"./chunk-7UFKEX72.js";import{createContext as Q,useEffect as _,useContext as ee,useRef as te,useSyncExternalStore as ne,useState as oe,useReducer as re,useCallback as le,createElement as ie,useMemo as se,useLayoutEffect as ae}from"react";import{jsx as ce,jsxs as ue,Fragment as de}from"react/jsx-runtime";import{createPortal as pe}from"react-dom";import{registerModalEscapeInterceptor as fe,FloatingBar as he,TextToolbar as me,LinkPicker as ge}from"efficient-shell/ui";function ye(e){return!["setData","setUi","set"].includes(e.type)}var ve=(e,t,n,o)=>{const r=S(e,t,I(n));return r?.[o]??null},we=(e,t,n,o,r)=>{const l=ve(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function be(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function ke(e,t,n){return n?"node"===n.kind?b(e,t,n.id)?n:null:n.parentId===k?S(e,t,n)?n:null:b(e,t,n.parentId)&&S(e,t,n)?n:null:null}function Se(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function xe(e,t,n){const o=Ie(e,t,n);if(o===e)return e;const r=ke(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function Ie(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Se(e,n,"function"==typeof t.ui?t.ui(be(e,n)):t.ui);case"set":{const r={data:o,ui:be(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=Se(i,n,l.ui,!0)),i}case"insert":{const r={...I(t.destinationZone),index:t.destinationIndex},l=D(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:O(o,n,r,l)}}case"replace":{const r=we(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:A(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=we(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=E(o,n,r.props.id),i=ve(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return Ie(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ve(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...I(t.destinationZone),index:t.destinationIndex};return{...e,data:C(o,n,r.props.id,l)}}case"remove":{const r=we(o,n,t.zone,t.index,"remove");return{...e,data:x(o,n,r.props.id)}}default:return e}}var Ce={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ae=0,De=()=>`history-${Ae+=1}`;function Oe(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=M(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ee}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ee,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:De()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,v=!1;const w=()=>{for(const e of[...f])e()},k=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},x=(t,n)=>{g>0?v=v||n:(n?p(!1):c!==t&&k(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},I=e=>{const n=c;if(c=xe(c,e,t),c===n)return;const o=e.recordHistory??ye(e);x(n,o&&c.data!==n.data)},C=t=>{0===g&&(y=c,v=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,v&&c.data!==n.data?p(!0):c!==n&&k(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=e=>{const n=c,o=ke(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},x(n,!1))},D=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},O=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...Ce,...i,...n}};let P=O();const j=$(),z={resolveCache:j,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([R(r,t,{cache:j,trigger:e,metadata:n}),...l.map(o=>R(o,t,{cache:j,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=b(r,t,i)?.node;s&&s===b(o,t,i)?.node&&(r=A(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ke(r,t,c.selection)},x(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=b(c.data,t,e)?.node;if(!r)return!1;const l=await R(r,t,{cache:j,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return C(()=>{const n=c;if(b(c.data,t,e)?.node!==r)return;const o=A(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ke(o,t,c.selection)},x(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:be(e,t)},o="node"===e.selection?.kind?b(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:I,history:{back:()=>z.undo(),forward:()=>z.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:be(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&D(e)}},getPermissions:P,getItemById:n=>b(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return S(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:I,batch:C,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ke(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=c,r=M(e,t);c={...c,data:r,selection:ke(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:De()}],d=0),c!==o&&w()},undo(){d>0&&D(d-1)},redo(){d<u.length-1&&D(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,i)||(i=e,P=O(),h=null,w())},setConfig(e){e!==t&&(t=e,P=O(),h=null,w())}};return z}function Me(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&W(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var $e=Q(null),Pe=Q(!0);function je({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return _(()=>{n&&e.resolveAll()},[e,n]),_(()=>{if(t&&"undefined"!=typeof document)return Me(document,e)},[e,t]),/* @__PURE__ */ce($e.Provider,{value:e,children:/* @__PURE__ */ce(Pe.Provider,{value:t,children:o})})}function ze(){const e=ee($e);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Re(e){const t=ze(),n=te({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ne(t.subscribe,o,o)}function Ne(){return function(e){return Re(e)}}var Le=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Ve="host-tokens";function Be(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Le){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?Y(t,Ve,n):q(t,Ve)}var Te="data-easel-block",Ke="data-easel-dropzone",Ze={},Fe="data-es-mirror",He="undefined"==typeof window?_:ae;function We(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Fe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Fe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Ye({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=te(null),[p,f]=oe(null);return He(()=>{const e=d.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),He(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),F(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){We(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>We(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Be(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Be(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ce("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?pe(e,p):null})}var qe=Q(null),Ue=Q(Ze),Xe=[];function Ge({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=ze(),s=Re(n=>S(n.appState.data,i.config,{parentId:e,slot:t})??Xe),a=Re(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==k),c=Re(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=ee(qe),d=["es-zone"];return s.length&&d.push("has-children"),e===k&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==k&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */ce("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ce(rt,{node:e},e.props.id))})}function Je(e,t,n,o){const r=se(()=>{const n={};for(const o of N(L(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ce(Ge,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=V(n[e],o);return r}function Qe(e){return se(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ce(Ge,{parentId:e,slot:t,...n})},[e])}var _e=["top","bottom","zIndex"];function et(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function tt(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));et(e,"position",t?"sticky":"relative");for(const n of _e)et(e,n,t?.[n]??"");return!!t}var nt="data-es-canvas-relative";function ot(e){e.hasAttribute(nt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(nt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(nt,"")),!1)}function rt({node:e}){const t=ze().config,n=t.components[e.type],o=e.props.id,r=te(null),l=function(e,t){return se(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Te),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Te,e),n.setAttribute("data-easel-dnd",e),ot(n))},[e,t])}(o,r),i=te(null),s=!!n?.inline;!function(e,t){const n=te(!1),o=te(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=te(()=>{});He(()=>o.current()),He(()=>{const t=e(),l=t?.ownerDocument.defaultView;if(!t||!l)return;const i=()=>o.current();l.addEventListener("resize",i);const s=l.ResizeObserver,a=s?new s(i):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&l.MutationObserver&&(c=new l.MutationObserver(i),c.observe(e,{attributes:!0}))},r.current(),()=>{l.removeEventListener("resize",i),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:i.current,e=>s?ot(e):tt(e));const a=ee(Ue),c=Je(n,o,e.props,t.components),u=Qe(o);if(!n?.render)return null;const d=n.render,p={...B(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ce("div",{ref:i,[Te]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ce(d,{...p,editor:f,editMode:!0})})}function lt({metadata:e}){const t=Re(e=>e.config),n=Re(e=>e.appState.data.root).props??{},o=t.root?.render,r=Je(t.root,k,n,t.components),l=Qe(k),i=/* @__PURE__ */ce(Ge,{parentId:k,slot:z}),s=o?/* @__PURE__ */ce(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ce(Ue.Provider,{value:e??Ze,children:s})}var it=Q(void 0),st=Q(void 0);function at(e,t,n,o){const r=b(e,t,n);return!!r&&(P(r.node,t).length>0||!1===o.whole)}var ct=Q(void 0),ut="data-es-chrome",dt=Q(void 0);function pt(e){const t=e?.closest?.(`[${ut}]`)??null,n=t?.getAttribute(ut);return t&&n?{id:n,element:t}:null}function ft({element:e,clip:t=!1}){const n=te(null),o=gt(n,e?()=>e:null,e),r=ee(xt);/* @__PURE__ */
|
|
6
|
+
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:t?St(o,r):void 0}:{display:"none"}})}var ht={"--es-words-clear":`${U}px`};function mt({element:e,words:t=!1,clip:n=!1}){const o=te(null),r=gt(o,e?()=>e:null,e),l=ee(xt);/* @__PURE__ */
|
|
7
|
+
return ce("div",{ref:o,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height,clipPath:n?St(r,l):void 0,...ht}:{display:"none"}})}function gt(e,t,n){return vt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var yt=[];function vt(e,t,n){const[o,r]=oe(yt),l=te(t);return l.current=t,He(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(yt);let o=0;const i=()=>{o=0;const n=e.current?.parentElement??null,i=(l.current?l.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=G(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=i)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:i.length?i:yt;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;c?.observe(t.documentElement),n.addEventListener("resize",s),n.addEventListener("scroll",s,{capture:!0,passive:!0});const u=K(n,s);return()=>{u(),a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}var wt=U+2,bt=wt+2,kt=1;function St(e,t){const n=e.left+e.width,o=e.top+e.height,r=t.map(t=>{const r=t.left+t.width,l=t.top+t.height;if(!(r>e.left-wt&&t.left<n+wt&&l>e.top-wt&&t.top<o+wt))return null;const i=Math.max(t.left<=e.left&&r>e.left?Math.min(t.left,e.left-kt):t.left,e.left-bt)-e.left,s=Math.max(t.top<=e.top&&l>e.top?Math.min(t.top,e.top-kt):t.top,e.top-bt)-e.top,a=Math.min(r>=n&&t.left<n?Math.max(r,n+kt):r,n+bt)-e.left,c=Math.min(l>=o&&t.top<o?Math.max(l,o+kt):l,o+bt)-e.top;return a>i&&c>s?{x:i,y:s,w:a-i,h:c-s}:null}).filter(e=>null!==e);if(!r.length)return;const l=function(e){if(e.length<2)return e;const t=Array.from(new Set(e.flatMap(e=>[e.x,e.x+e.w]))).sort((e,t)=>e-t),n=Array.from(new Set(e.flatMap(e=>[e.y,e.y+e.h]))).sort((e,t)=>e-t),o=[];for(let r=0;r<n.length-1;r++){const l=o=>e.some(e=>e.x<=t[o]&&t[o+1]<=e.x+e.w&&e.y<=n[r]&&n[r+1]<=e.y+e.h);for(let e=0;e<t.length-1;e++){if(!l(e))continue;let i=e+1;for(;i<t.length-1&&l(i);)i++;const s={x:t[e],y:n[r],w:t[i]-t[e],h:n[r+1]-n[r]},a=o.find(e=>e.x===s.x&&e.w===s.w&&e.y+e.h===s.y);a?a.h+=s.h:o.push(s),e=i-1}}return o}(r);return`path(evenodd, "${`M${-bt} ${-bt}h${e.width+2*bt}v${e.height+2*bt}h${-(e.width+2*bt)}z`}${l.map(e=>`M${e.x} ${e.y}h${e.w}v${e.h}h${-e.w}z`).join("")}")`}var xt=Q([]);function It({children:e}){const t=te(null),n=ee(dt),o=vt(t,n?e=>Array.from(e.querySelectorAll(`[${ut}]`)):null,n?1:0);/* @__PURE__ */
|
|
8
8
|
return ue("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
9
|
/* @__PURE__ */ce("span",{ref:t,hidden:!0,"aria-hidden":"true"}),
|
|
10
|
-
/* @__PURE__ */ce(xt.Provider,{value:o,children:e})]})}function
|
|
11
|
-
/* @__PURE__ */ce("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ce("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ce(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Te}]`)).find(o=>o.getAttribute(Te)===n&&t(o)?.wrapper===e)??null}function At(e,t,n){const o=g(e,n),r=o.text.length,l=e.ownerDocument;if(!t)return[r,r];let i=null;const s=l.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))i=o.at(s.offsetNode,s.offset);else{const n=l.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(i=o.at(n.startContainer,n.startOffset))}if(null===i)return[r,r];const a=o.text;let c=i,u=i;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;u<a.length&&!/\s/.test(a[u]);)u+=1;return[c,u]}function Dt(e,t){const n=t?.closest?.(`[${Te}]`)?.getAttribute(Te)??null;return!1===e.getPermissions(n?{item:e.getItemById(n)}:{root:!0}).edit}function
|
|
12
|
-
return ce(he,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
13
|
-
/* @__PURE__ */ce(ge,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:
|
|
14
|
-
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:St(o,r),...ht}:{display:"none"}})}function $t({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:k,overlay:
|
|
15
|
-
/* @__PURE__ */ce(
|
|
16
|
-
/* @__PURE__ */ue(
|
|
17
|
-
/* @__PURE__ */ce(
|
|
18
|
-
/* @__PURE__ */ce(
|
|
19
|
-
return ue("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&
|
|
10
|
+
/* @__PURE__ */ce(xt.Provider,{value:o,children:e})]})}function Ct({id:e,kind:t,overlay:n}){const o=te(null),r=ee(st),l=null!==e&&!0===r?.(e),i=vt(o,e?t=>J(t,`[${Te}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=ee(xt),u=`es-canvas-outline is-${t}${l?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height,clipPath:St(e,c)}),p=/* @__PURE__ */ue(de,{children:[
|
|
11
|
+
/* @__PURE__ */ce("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ce("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ce(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Te}]`)).find(o=>o.getAttribute(Te)===n&&t(o)?.wrapper===e)??null}function At(e,t,n){const o=g(e,n),r=o.text.length,l=e.ownerDocument;if(!t)return[r,r];let i=null;const s=l.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))i=o.at(s.offsetNode,s.offset);else{const n=l.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(i=o.at(n.startContainer,n.startOffset))}if(null===i)return[r,r];const a=o.text;let c=i,u=i;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;u<a.length&&!/\s/.test(a[u]);)u+=1;return[c,u]}function Dt(e,t){const n=t?.closest?.(`[${Te}]`)?.getAttribute(Te)??null;return!1===e.getPermissions(n?{item:e.getItemById(n)}:{root:!0}).edit}function Ot({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",v),i=Re(e=>Dt(e,t())),s=e.pressed(),a=new Set(n.offered),c=n.colors&&n.colors.length>0?n.colors:null,m=te(null),[g,y]=oe(!1),[b,k]=oe(null),S=g||null!==b,x=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};ae(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!a.has("link")&&(x(),!0)}}),ae(()=>()=>{r.current=null},[r]);const C=te(I);C.current=I,_(()=>{if(g)return fe(e=>{const t=m.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(C.current(),!0)},()=>m.current?.querySelector(".es-copy-colors"))},[g]),_(()=>{const n=m.current;if(!S||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),k(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[S,e,t]),ae(()=>{const e=m.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?X(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},c=o.getBoundingClientRect(),f=s?X(s,{left:c.left,top:c.top,width:c.width,height:c.height}):{left:c.left,top:c.top,width:c.width,height:c.height},h=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,f.top-6,h.top),bottom:Math.max(a.top+a.height,f.top+f.height+6,h.bottom)},y=e.ownerDocument.documentElement,v=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,v.left),top:Math.max(0,v.top),right:Math.min(y.clientWidth||v.right,v.right),bottom:Math.min(y.clientHeight||v.bottom,v.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=d({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:v.left,top:v.top,right:v.right,bottom:v.bottom},clip:w,parent:p(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const E=c?{run:f(s.color,c,n.colorNameOf),open:g,onToggle:()=>{k(null),g?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
|
|
12
|
+
return ce(he,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?X(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */ce("div",{ref:m,children:/* @__PURE__ */ce(me,{layout:"row",offered:a,pressed:s.marks,onMark:t=>{"link"===t?x():e.press(t)},color:E,linkOpen:null!==b,list:{pressed:s.list,onList:t=>e.list(t)},clear:s.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:i,selected:s.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t),style:s.style,applyStyle:t=>e.textStyle(t)}),windows:/* @__PURE__ */ue(de,{children:[g&&c?/* @__PURE__ */ce(h,{colors:c,current:s.color,nameOf:n.colorNameOf,words:l.colors??v.colors,onPick:t=>e.color(t)}):null,b?
|
|
13
|
+
/* @__PURE__ */ce(ge,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Mt({element:e,which:t}){const n=te(null),o=gt(n,()=>e(),t),r=ee(xt);/* @__PURE__ */
|
|
14
|
+
return ce("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:St(o,r),...ht}:{display:"none"}})}function $t({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:k,overlay:S,children:x,typing:I,passThrough:C}){const E=ze(),A=ee(it),D=C??A,O=ee(Pe),M=w("canvas",n),$=v??O,[j,z]=oe(void 0),R=Re(e=>"node"===e.selection?.kind?e.selection.id:null),[N,L]=oe(null),[V,B]=oe(null),K=ee(ct),F=ee(dt),[W,Y]=oe(null),[,q]=re(e=>e+1,0),[,U]=re(e=>e+1,0),X=e=>{K?.select(e),U()},[G,J]=oe(null),Q=te(null),ne=Re(e=>!!G&&Dt(e,G()));_(()=>{ne&&Q.current?.s.stop("stop")},[ne]);const le=te(null),[,ie]=oe(0),se=te(I);se.current=I;const ae=te(null),de=te(null),pe=()=>{if(!R)return null;const e=se.current?.atSelection?.()?.element()??null;if(!e)return null;const t=de.current?.ownerDocument;if(K){const n=K.selected()&&t?K.selectedPart?.(t)??null:null;return n&&H(n.element,e)?n.element:null}const n=b(E.getState().appState.data,E.config,R);return n&&0===P(n.node,E.config).length?e:null},fe=Re(e=>e.appState.data),he=K?.selected()??null;_(()=>{const e=de.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=R&&!G&&se.current?.atSelection?.()?R:null,o=n?pe():null;e.dispatchEvent(new t(T,{detail:o?{id:n,words:o}:{id:n}}))},[R,G,fe,he]);const me=e=>{const t=de.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(Z,{detail:{typing:e}}))},ge=(e,t)=>{Q.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=e.element,r=()=>Dt(E.getState(),o());if(r())return!1;const l=ye(e,n),i=l?.write??e.write,s=E.group(),a=m({element:o,value:l?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:At(n,t,e.skip),editable:()=>!r(),write:e=>{r()?queueMicrotask(()=>Q.current?.s.stop("stop")):i(e)},remount:e.remount,onSelect:()=>ie(e=>e+1),onEscape:()=>ae.current?.escape()??!1,onLinkKey:()=>ae.current?.link()??!1,end:e=>{s.close(),Q.current?.element===o&&(Q.current=null),J(null),me(!1),se.current?.onChange?.({typing:!1,why:e})}});if(!a)return s.close(),!1;const c=n.closest?.(`[${Te}]`)?.getAttribute(Te);return c&&E.select(c),Q.current={s:a,element:o,target:e},J(()=>o),L(null),me(!0),se.current?.onChange?.({typing:!0,element:n}),!0},ye=(e,n)=>{const o=e.key;if(!o||!se.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${Te}]`),i=l?.getAttribute(Te);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=se.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(y(e.value,e.rules).text===c?e.value:c),d={ownerId:s.ownerId,slot:s.slot,index:s.index,...s.outer?{outer:s.outer}:{},nodeId:i,key:o};return{value:u,write:t=>{const n=se.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};_(()=>()=>Q.current?.s.stop("stop"),[]);const ve=e=>{const t=Q.current?.element();return Boolean(t&&t.contains(e))},we=(e,t)=>at(E.getState().appState.data,E.config,e,t),be=e=>{const t=e.closest?.(`[${Te}]`)?.getAttribute(Te);if(!t)return;const n=E.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=K?.partAt(e,t)??null;if(r){const e=a(n.appState.data,E.config,t,r.id,o,K?.selected()??null,D);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,E.config,t,o,D)??t,part:null}},ke=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(Q.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Se(),o=void 0===n?se.current?.atSelection?.():n;o&&ge(o,null)&&e.preventDefault()},Se=()=>{const t=se.current,n=le.current;if(!t?.onCopyText||!n?.copy||n.node!==R)return;const o=de.current,r=o?e(o,n.copy):null,l=r?Et(r,n.node):null;if(!l)return null;const i=t.atSelection?.()??null,s=i?.element()??null;if(!i||!s)return null;if(l.contains(s))return i;const a=function(e,t){const n=e.closest(`[${Te}]`);if(!n||n.getAttribute(Te)!==t.getAttribute(Te))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},xe=(e,n)=>{if(!se.current?.onCopyText)return null;const o=t(e);return o&&Et(o.wrapper,n)?o.copy:null},Ie=de.current?.ownerDocument??null,Ce=K?.selected()&&Ie&&R?K.selectedPart?.(Ie)??null:null,Ee=Ce&&R&&we(R,Ce)?Ce.element:null,Ae=F?.selected()??null,De=Ae&&Ie?Array.from(Ie.querySelectorAll(`[${ut}]`)).find(e=>e.getAttribute(ut)===Ae)??null:null,Oe=G?null:pe(),$e=/* @__PURE__ */ue("div",{ref:de,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),Q.current){if(ve(t))return;Q.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=F?pt(t):null;if(F&&o)return F.select(o.id),Y(null),void q();const r=be(t);if(le.current=void 0!==r?{node:r.node,copy:xe(t,r.node)}:null,void 0!==r)return E.select(r.node),void(K&&(r.part?.id??null)!==K.selected()&&X(r.part?.id??null));t.hasAttribute?.(Ke)||(E.select(null),K?.selected()&&X(null))},onDoubleClick:e=>{const t=se.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&ge(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>ke(e),onMouseOver:e=>{if(Q.current)return;const t=F?pt(e.target):null;if(t?.element!==W?.element&&Y(t),t)return null!==N&&L(null),void(null!==V&&B(null));const n=be(e.target),o=!!n?.part&&we(n.node,n.part),r=n?.part&&o&&n.part.id!==K?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==N&&L(l),r?.id===V?.id&&r?.element===V?.element||B(r)},onMouseLeave:()=>{L(null),B(null),Y(null)},children:[
|
|
15
|
+
/* @__PURE__ */ce(qe.Provider,{value:N,children:/* @__PURE__ */ce(lt,{metadata:i})}),
|
|
16
|
+
/* @__PURE__ */ue(It,{children:[
|
|
17
|
+
/* @__PURE__ */ce(Ct,{id:!G&&N&&N!==R?N:null,kind:"hover",overlay:S}),K?/* @__PURE__ */ce(ft,{clip:!0,element:G||!V||V.id===K.selected()?null:V.element}):null,Oe||Ee?/* @__PURE__ */ce(mt,{clip:!0,element:G?null:Oe??Ee,words:null!==Oe}):null,F?/* @__PURE__ */ce(ft,{element:G||!W||W.element===De?null:W.element}):null,De?/* @__PURE__ */ce(mt,{element:G?null:De}):null,
|
|
18
|
+
/* @__PURE__ */ce(Ct,{id:G||Ee||Oe||De?null:R,kind:"selected",overlay:S}),G?/* @__PURE__ */ce(Mt,{element:()=>{const e=G?.()??null;return e?Ce&&H(Ce.element,e)?Ce.element:e:null},which:Ce?.element??G}):null]}),x]}),je=k?/* @__PURE__ */ce(k,{document:j,children:$e}):$e;_(()=>{if(j&&$)return Me(j,E)},[j,$,E]),_(()=>{if(!j)return;const e=e=>{if("Enter"===e.key)return void ke(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=E.getState();if("node"!==n.selection?.kind)return;if(K?.selected())return void X(null);const o=s(n.appState.data,E.config,n.selection);"node"===o?.kind&&E.select(o.id)};return j.addEventListener("keydown",e),()=>j.removeEventListener("keydown",e)},[j,E,K]);/* @__PURE__ */
|
|
19
|
+
return ue("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&Q.current?.target.toolbar?/* @__PURE__ */ce(Ot,{s:Q.current.s,element:Q.current.element,toolbar:Q.current.target.toolbar,label:M.textTools,keys:ae}):null,o?/* @__PURE__ */ce(Ye,{mirrorStyles:u,onDocument:e=>{z(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:je}):/* @__PURE__ */ce("div",{id:"preview-frame","data-easel-entry":"",children:je})]})}function Pt(e={}){const t=ze(),n=Re(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}var jt=/* @__PURE__ */new WeakMap,zt=[];function Rt(e){let t=jt.get(e);return t||(t={nodes:/* @__PURE__ */new Map,shown:/* @__PURE__ */new Map,listeners:/* @__PURE__ */new Set,lateListeners:/* @__PURE__ */new Set,settled:[]},jt.set(e,t)),t}function Nt(e,t){const n=e.nodes.get(t),o=n?[...n.running,...n.next]:zt;o.length?e.shown.set(t,o):e.shown.delete(t),e.listeners.forEach(e=>e())}function Lt(e,t,n,o){const r=Rt(e),l=r.nodes.get(t);l?l.next=[...l.next,n]:r.nodes.set(t,{running:zt,next:[n]}),Nt(r,t),l||Promise.resolve().then(()=>Vt(r,t,o))}function Vt(e,t,n){const o=e.nodes.get(t);if(!o)return;if(!o.next.length)return e.nodes.delete(t),Nt(e,t),void(e.nodes.size||e.settled.splice(0).forEach(e=>e()));const r=o.next;o.running=r,o.next=zt;let l=!0;const i=()=>{l=!1,clearTimeout(a),o.running=zt,Nt(e,t)};let s=!1;const a=setTimeout(()=>{s=!0,i();try{n.landWithoutAnswer(r)&&(e.lateListeners.forEach(e=>e()),Promise.reject(new Error(`A write to ${t} landed without its resolver's answer after 60000 ms.`)))}catch(e){Promise.reject(e)}Vt(e,t,n)},6e4);n.run(r,{live:()=>l,landing:i}).catch(e=>{if(!s)throw e}).finally(()=>{s||(l&&i(),Vt(e,t,n))})}function Bt(e){const t=Rt(e);return t.nodes.size?new Promise(e=>t.settled.push(e)):Promise.resolve()}function Tt(){const e=ze(),t=te([]),n=te(!1),[o,r]=oe(!1),[,l]=re(e=>e+1,0);_(()=>{t.current.splice(0).forEach(e=>e())});return{run:le(o=>{n.current||(n.current=!0,r(!0),Bt(e).then(()=>new Promise(e=>{t.current.push(e),l()})).then(()=>{n.current=!1,r(!1),o()}))},[e]),waiting:o}}function Kt(e){const t=Tt(),n=te(e);return n.current=e,{...e,busy:!0===e.busy||t.waiting,onPress:()=>t.run(()=>n.current.onPress())}}function Zt(e,t){const{lateListeners:n}=Rt(e);return n.add(t),()=>{n.delete(t)}}var Ft=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype;function Ht(e,t,n){if(t===e)return n;if(Array.isArray(e)&&Array.isArray(t)&&Array.isArray(n)){if(e.length!==n.length||e.some((e,t)=>n.includes(e)&&n[t]!==e))return t;const o=e.length===t.length&&1===t.filter((t,n)=>t!==e[n]).length;return t.map((t,r)=>{if(t===e[r])return n[r];const l=Ft(t)?e.indexOf(t):-1;return l>=0?n[l]:o?Ht(e[r],t,n[r]):t})}if(Ft(e)&&Ft(t)&&Ft(n)){const o={...n};for(const n of Object.keys(e))n in t||delete o[n];for(const r of Object.keys(t))o[r]=Ht(e[r],t[r],n[r]);return o}return t}function Wt(e,t){let n=null;for(const o of e){const e="function"==typeof o?o({...t,...n}):o;e&&(n={...n,...e})}return n}function Yt(e,t){if(!e.length)return t;try{return{...t,...Wt(e,t)}}catch{return t}}function qt(){return Qt(Re(e=>e.selectedItem))}function Ut(){const e=ee(Xt);try{return function(e){const t=Re(e=>e.selectedItem);return Qt("root"===e?null:t)}(e)}catch{return null}}var Xt=Q("selected");function Gt({children:e}){return ie(Xt.Provider,{value:"root"},e)}function Jt(){return Qt(null)}function Qt(e){const t=ze(),n=Re(e=>e.config),r=t.resolveCache,l=Re(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=se(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?b(u.appState.data,n,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=o({id:i,node:a,block:c,parent:f,appState:u.appState}),m=Re(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=le(e=>{Lt(t,i,e,{landWithoutAnswer:e=>{const n=t.getState();if("root"===i){const o=n.appState.data.root.props??{},r=Wt(e,o);return!!r&&(t.dispatch({type:"replaceRoot",root:{props:{...o,...r},readOnly:n.appState.data.root.readOnly},recordHistory:!0}),!0)}const o=n.getItemById(i),r=n.getSelectorForId(i);if(!o||!r)return!1;const l=Wt(e,o.props);return!!l&&(t.dispatch({type:"replace",destinationZone:r.zone??"root:default-zone",destinationIndex:r.index,data:{...o,props:{...o.props,...l}}}),!0)},run:async(e,{live:n,landing:o})=>{for(let l=1;;l+=1){const s=t.getState(),a={...r,lastChange:Object.create(r.lastChange)},c=()=>{o(),Object.assign(r.lastChange,a.lastChange)};if("root"!==i){const o=s.getItemById(i);if(!o)return;const r=Wt(e,o.props);if(!r)return;const u={...o,props:{...o.props,...r}},{node:d}=await R(u,t.config,{cache:a,trigger:"replace"});if(!n())return;const p=t.getState(),f=p.getSelectorForId(i);if(!f)return;if(p.getItemById(i)!==o&&l<5)continue;return c(),void t.dispatch({type:"replace",destinationZone:f.zone??"root:default-zone",destinationIndex:f.index,data:d})}const u=s.appState.data.root.props??{},d=Wt(e,u);if(!d)return;const{node:p}=await R({type:"root",props:{...u,...d}},t.config,{cache:a,trigger:"replace"});if(!n())return;if(!(t.getState().appState.data.root.props!==s.appState.data.root.props&&l<5))return c(),void t.dispatch({type:"replaceRoot",root:{props:p.props,readOnly:p.readOnly},recordHistory:!0})}}})},[t,r,i]),y=le(e=>{const{listeners:n}=Rt(t);return n.add(e),()=>{n.delete(e)}},[t]),v=le(()=>Rt(t).shown.get(i)??zt,[t,i]),w=ne(y,v,v),k=se(()=>Yt(w,a.props),[w,a.props]),S=te({id:i,values:k});S.current={id:i,values:k};const x=le((e,n)=>{const o=t.getState(),r=("root"===i?o.appState.data.root.props:o.getItemById(i)?.props)??{},l=Yt(Rt(t).shown.get(i)??zt,r),s=S.current,a=(s.id===i?s.values:l)[e];j(n,a)&&!j(l[e],a)?g({[e]:n}):g(t=>({[e]:Ht(a,n,t[e])}))},[t,i,g]);return{id:i,node:a,fields:h,values:k,readOnly:m,onChange:x,onChangeMany:g}}export{ut as CHROME_ATTR,dt as CanvasChromeContext,Ye as CanvasFrame,ct as CanvasPartsContext,it as CanvasPassThroughContext,st as CanvasSharedContext,Ee as DEFAULT_UI,$t as EaselCanvas,je as EaselProvider,lt as EditDocument,Gt as RootHostScope,Me as bindUndoKeys,Oe as createEasel,Ne as createUseEasel,at as partHasOwnBox,ye as recordsByDefault,xe as reduce,Zt as subscribeLateWrites,be as uiView,Re as useEasel,ze as useEaselApi,Pt as useEaselNodeOps,Jt as useRootFields,qt as useSelectedFields,Ut as useSelectedHost,Kt as useSettledAction,Tt as useSettledPress,ke as validSelection,Bt as writesSettled};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{deviceMetaOf as t,noControlMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{SETTINGS_BUCKETS as o,SettingsGroup as a}from"./chunk-AI5IQV4A.js";import{DEFAULT_TREE_WORDS as i}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as s}from"./chunk-56ID6FKZ.js";import{easelMenuEntries as c}from"./chunk-FIVU2COQ.js";import{FieldNumber as d}from"./chunk-ANBPE45L.js";import{FieldSelect as u}from"./chunk-C63IB4VW.js";import{SettingsSegmented as m}from"./chunk-DX3VILZ3.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{DEFAULT_FIELDS_WORDS as p}from"./chunk-UMTUKSE6.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{useTreeDrag as b,gapToMoveIndex as v}from"./chunk-QEEW4X64.js";import{withTip as g}from"./chunk-P2VEMZH5.js";import{normalizePhoneOrder as y,isCustomPhoneOrder as k,settlePhoneOrder as w,clone as x}from"./chunk-YDTEYXQW.js";import{Textarea as C,Input as O,ItemCount as N,SortableList as j,ListRow as D,IconButton as I,ContextMenu as $,tabPanelId as S,Tabs as P,SliderGroup as L,tabButtonId as E,Button as F}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as T,useState as M,useLayoutEffect as z,useId as A}from"react";import{jsx as R,jsxs as W,Fragment as B}from"react/jsx-runtime";import{LockIcon as Y,CloseIcon as H,ListIcon as K,MoveUpIcon as V,MoveDownIcon as Q,DuplicateIcon as X,TrashIcon as Z}from"efficient-shell/icons/efficient";function U({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:o=3,readOnly:a=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */R(C,{id:e,size:"sm",className:"es-fin",value:c,rows:o,placeholder:l,readOnly:a,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */R(O,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:a,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function G(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function q(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function _(e,n){return e.filter((e,t)=>t!==n)}var J='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',ee={parentId:"list",slot:"items"};function ne({label:e,icon:n,noun:t,items:l,onChange:o,newItem:a,summary:s,itemName:d,thumb:u,min:m=0,max:h,readOnly:y=!1,open:k,onOpen:w,renderItem:C,renderRow:O,canRemove:S,lockedReason:P,fixed:L=!1,removeOnRow:E=!0,canDuplicate:F,above:A,head:K=!0}){const U=f("fields",p).list,ne=f("tree",i),te=t??U.item,le=!y&&!L&&("number"!=typeof h||l.length<h),re=l.length<=m,oe=e=>!!S&&!S(l[e],e),ae=e=>!y&&!L&&E&&!re&&!oe(e),ie=e=>le&&(!F||F(l[e],e)),se=(e,n)=>d?d(e,n):U.itemName({noun:te,n:n+1}),ce=T([]),de=T(null),[ue,me]=M(null),he=T(null),[pe,fe]=M(null),[be,ve]=M("");z(()=>{const e=de.current;if(!e)return;de.current=null;const n=ce.current[e.index]?.querySelectorAll(J)[e.nth]??ce.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const ge=(e,n)=>{if(n<0||n>=l.length||n===e)return;const t=ce.current[e],r=t?.ownerDocument.activeElement;if(t&&r&&t.contains(r)){const e=[...t.querySelectorAll(J)].indexOf(r),l=r;de.current={index:n,nth:e,start:"number"==typeof l.selectionStart?l.selectionStart:null,end:"number"==typeof l.selectionEnd?l.selectionEnd:null}}o(q(l,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(k,e,n);a!==k&&w(a),ve(U.moved({n:n+1,total:l.length}))},ye=e=>{le&&(o(G(l,e,a())),O?(de.current={index:e,nth:0,start:null,end:null},null!==k&&k>=e&&w(k+1)):w(e))},ke=e=>{ae(e)&&(o(_(l,e)),k===e?w(null):null!==k&&k>e&&w(k-1))},we=b({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===ee.parentId&&n.slot===ee.slot,onDrop:(e,n)=>{const t=v({...ee,index:e},n);t!==e&&ge(e,t)},onStep:(e,n)=>ge(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<l.length,readOnly:y}),xe=e=>{const n=[];return e>0&&n.push({label:U.moveUp,icon:/* @__PURE__ */R(V,{size:14}),shortcut:"⌥↑",onClick:()=>ge(e,e-1)}),e<l.length-1&&n.push({label:U.moveDown,icon:/* @__PURE__ */R(Q,{size:14}),shortcut:"⌥↓",onClick:()=>ge(e,e+1)}),ie(e)&&n.push({label:U.duplicate,icon:/* @__PURE__ */R(X,{size:14}),onClick:()=>(e=>{ie(e)&&(o(G(l,e+1,x(l[e]))),null!==k&&k>e&&w(k+1))})(e)}),ae(e)&&n.push({label:U.delete,icon:/* @__PURE__ */R(Z,{size:14}),danger:!0,onClick:()=>ke(e)}),n},Ce=(e,n,t,l)=>{y||0===xe(e).length||fe({index:e,x:n,y:t,owner:l})},Oe=e=>n=>{const t=l.slice();t[e]=n,o(t)};/* @__PURE__ */
|
|
2
|
+
return W("div",{className:"es-list",children:[K?/* @__PURE__ */W("div",{className:"es-list-head",children:[
|
|
3
|
+
/* @__PURE__ */W("span",{className:"es-list-label",children:[n?/* @__PURE__ */R("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
|
|
4
|
+
/* @__PURE__ */R(N,{count:l.length,label:U.count({noun:te,n:l.length}),showZero:!0})]}):null,A?/* @__PURE__ */R("div",{className:"es-list-above",children:A}):null,l.length?/* @__PURE__ */W(j,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:we.rootProps(),children:[l.map((e,n)=>{const t=we.row({item:n,place:{...ee,index:n}}),l=t.draggable&&ue!==n,o=!O&&k===n,a=!y&&!L&&E&&oe(n),i=["es-list-row",O?"is-inline":"is-item",o?"is-open":"",l?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */R(r,{...we.seam({place:{...ee,index:n}}),onAdd:le?()=>ye(n):void 0,label:U.addHere({noun:te})},`seam-${n}`):null,
|
|
5
|
+
/* @__PURE__ */R(D,{className:i,flat:!!O,active:o,title:O?void 0:/* @__PURE__ */W(B,{children:[
|
|
6
|
+
/* @__PURE__ */R("span",{className:"es-list-row-name",children:se(e,n)}),s?/* @__PURE__ */R("span",{className:"es-list-row-summary",children:s(e,n)}):null]}),thumb:!O&&u?u(e,n):void 0,expanded:O?void 0:o,onToggle:O?void 0:()=>w(o?null:n),draggable:t.draggable,dragHint:ne.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>ge(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{ce.current[n]=e},rowProps:{...t.rowProps,draggable:l||void 0,onPointerDown:e=>{const l=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!l&&l===l.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!r,he.current=l&&!r?l:null,me(r?n:null)},onDragStart:e=>{const n=he.current;he.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{y||(e.preventDefault(),e.stopPropagation(),Ce(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void Ce(n,r.left+24,r.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:y||L||!E?void 0:a?g(P?P(e,n):U.locked,/* @__PURE__ */R("span",{className:"es-list-lock",role:"img","aria-label":P?P(e,n):U.locked,children:/* @__PURE__ */R(Y,{size:13})})):g(U.deleteItem({noun:te}),/* @__PURE__ */R(I,{size:"sm",className:"es-list-x","aria-label":U.deleteItem({noun:te}),disabled:!ae(n),onClick:()=>ke(n),children:/* @__PURE__ */R(H,{size:14,"aria-hidden":"true"})})),below:o?/* @__PURE__ */R("div",{className:"es-list-item",children:C(e,n,Oe(n))}):void 0,children:O?/* @__PURE__ */R("div",{className:"es-list-row-main",children:O(e,n,Oe(n))}):null},n)]}),
|
|
7
|
+
/* @__PURE__ */R(r,{...we.seam({place:{...ee,index:l.length}})})]}):null,y||L?null:/* @__PURE__ */R("button",{type:"button",className:"es-list-add",disabled:!le,onClick:()=>ye(l.length),children:U.add({noun:te})}),
|
|
8
|
+
/* @__PURE__ */R("span",{className:"es-list-said","aria-live":"polite",children:be}),pe&&pe.index<l.length?
|
|
9
|
+
/* @__PURE__ */R($,{at:{x:pe.x,y:pe.y},owner:pe.owner,onClose:()=>fe(null),items:c(xe(pe.index))}):null]})}var te=e=>e<6?e+1:6,le=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function re({field:e,name:t,id:l,value:r,onChange:o,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=M(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
|
|
10
|
+
return R(a,{id:`${l}-group`,title:le(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */R(ae,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>o({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:te(u)},e))})}function oe({field:e,name:t,id:l,value:r,onChange:o,readOnly:a,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=M(null),f=u?d??null:h,b=u??p,v=Array.isArray(r)?r:[],g=e.getItemSummary;/* @__PURE__ */
|
|
11
|
+
return R(ne,{label:le(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:v,onChange:o,newItem:()=>x({...e.defaultItemProps??{}}),summary:g?(e,n)=>g(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:f,onOpen:b,renderItem:(r,o,d)=>Object.entries(n(e.arrayFields,{values:r,context:s})).map(([e,n])=>/* @__PURE__ */R(ae,{field:n,name:`${t}[${o}].${e}`,id:`${l}-${o}-${e}`,value:r?.[e],onChange:n=>d({...r,[e]:n}),readOnly:a,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function ae(e){const{field:n,name:t,id:l,value:r,onChange:o,readOnly:a,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const c=s?.[n.type];if(c)return c({field:n,name:t,id:l,value:r,onChange:o,readOnly:a});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:r,onChange:o,readOnly:a};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
12
|
+
return R(h,{label:le(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */R(U,{id:l,value:"string"==typeof r?r:null==r?"":String(r),onChange:o,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:a})});case"number":/* @__PURE__ */
|
|
13
|
+
return R(h,{label:le(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */R(d,{id:l,value:"number"==typeof r?r:void 0,onChange:o,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:a})});case"select":{const e=`${l}-label`;/* @__PURE__ */
|
|
14
|
+
return R(h,{label:le(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */R(u,{id:l,value:r,options:n.options,onChange:o,readOnly:a,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
|
|
15
|
+
return R(h,{label:le(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */R(m,{ariaLabel:le(n,t),value:r,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||a})),onChange:e=>{a||o(e)}})});case"object":/* @__PURE__ */
|
|
16
|
+
return R(re,{...e,field:n});case"array":/* @__PURE__ */
|
|
17
|
+
return R(oe,{...e,field:n});case"slot":return null}}function ie(e,n,r){if("mobile"!==n&&"tablet"!==n)return!0;const o=e;if(o&&"string"==typeof o.reachedBy){const t=r?.[o.reachedBy];return void 0!==t&&t!==e&&ie(t,n)}if(!o||o.marker||"slot"===o.type)return!0;const a=t(e)?.tier;return a?a===n||"each"===a:"always"===l(e)}var se={},ce=e=>o.includes(e);function de(n,t){let l,r=o[0];const a=[],i=/* @__PURE__ */new Set;for(const[o,s]of Object.entries(n))s&&(ce(s.bucket)&&((s.marker||s.bucket!==r)&&(l=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?l={key:o,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||t&&!me(s,n,t)||t&&!ie(s,t.context?.device,n)||(a.push(l?{name:o,field:s,bucket:r,fold:l}:{name:o,field:s,bucket:r}),"slot"!==s.type&&i.add(r)));return{rows:a,buckets:o.filter(e=>i.has(e))}}function ue(e){return new Map(de(e).rows.map(e=>[e.name,e.bucket]))}function me(n,t,l){const r=n.reachedBy;if("string"!=typeof r)return!0;const o=t[r];return!!o&&!1!==o.visible&&e(o,l)}function he(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function pe({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:i,tab:c,onTab:d,tabs:u=!0,allTabs:m=!1,tabIcons:h,renderers:p,idPrefix:b,ariaLabel:v,lead:g,children:y,leadFold:k,closedFolds:w,onFold:x,headingLevel:C=3}){const O=f("panel",s),N=A(),j=b??`es-insp${N.replace(/:/g,"")}`,D=de(e,{values:n,context:i}),[I,$]=M(void 0),F=I&&(I.panel===j||D.buckets.includes(I.tab))?I.tab:void 0,T=c??F,z=m?o:D.buckets,B=T&&z.includes(T)?T:D.buckets[0]??z[0],[Y,H]=M(null),K=Y&&Y.panel===j&&D.rows.some(e=>e.name===Y.name)?Y:null,V=u&&z.length>1,Q=V&&B?S(j,B):`${j}-rows`,[X,Z]=M(()=>/* @__PURE__ */new Set),U=w??X,G=(e,n)=>{/* @__PURE__ */return R(a,{title:e.title,open:!U.has(e.key),onToggle:n=>((e,n)=>{void 0===w&&Z(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),x?.(e,n)})(e.key,n),id:`${j}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:C,children:n});var t},q=e=>V&&e!==B,_=({name:e,field:o,bucket:a,fold:s})=>/* @__PURE__ */R("div",{className:"es-insp-row","data-field":e,"data-bucket":a,hidden:!!q(a)||void 0,children:/* @__PURE__ */R(ae,{field:o,name:e,id:`${j}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:i,renderers:p,openItem:K&&K.name===e?K.index:null,onOpenItem:n=>H(null===n?null:{panel:j,name:e,index:n}),headingLevel:s?te(C):C})},e);/* @__PURE__ */
|
|
18
|
+
return W("div",{className:"es-insp",children:[V?/* @__PURE__ */R("div",{className:"es-insp-tabs",children:/* @__PURE__ */R(P,{variant:"underline",block:!0,"aria-label":v??O.settings,idPrefix:j,value:B,onChange:e=>{const n=e;void 0===c&&$({panel:j,tab:n}),d?.(n)},items:z.map(e=>{const n=O.buckets[e],t=h?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */R("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
|
|
19
|
+
/* @__PURE__ */W("div",{className:"es-insp-rows",id:Q,role:V?"tabpanel":void 0,"aria-labelledby":V&&B?E(j,B):void 0,children:[g&&ie(se,i?.device)?k?/* @__PURE__ */R("div",{className:"es-insp-band","data-fold":k.key,children:G(k,g)}):/* @__PURE__ */R(L,{children:g}):null,he(D.rows).map((e,n)=>{if(!e.fold){if(!V)/* @__PURE__ */return R(L,{children:e.rows.map(_)},`loose-${n}`);const t=[];for(const n of e.rows){const e=t[t.length-1];e&&e[0].bucket===n.bucket?e.push(n):t.push([n])}return t.map((e,t)=>/* @__PURE__ */R(L,{children:e.map(_)},`loose-${n}-${t}`))}const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
|
|
20
|
+
return R("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!q(t)&&!l)||void 0,children:G(e.fold,e.rows.map(_))},`fold-${e.fold.key}-${n}`)}),y]})]})}function fe(e,n,l=ie){const r=t(e)?.tier,o=t=>l(e,t,n)&&r!==t&&"each"!==r?1:0;return{phoneShared:o("mobile"),tabletShared:o("tablet")}}function be(e){const{arrayFields:n,objectFields:t}=e;return Object.values(n??t??{}).reduce((e,n)=>e+1+be(n),0)}var ve=/\buse(?:PreviewDevice\(\)|(?:Context)?\(PreviewDeviceContext\))|\b(?:previewD|d)evice\s*(?:[!=]==?|\?)|(?:[!=]==?)\s*(?:previewD|d)evice\b|switch\s*\(\s*(?:previewD|d)evice\b|shownTier\(\w+\)\s*[!=]==|\btier\s*[!=]==\s*"(?:mobile|tablet|desktop|each)"|context:\s*"device"/g;function ge(e){return e.match(ve)??[]}function ye({value:e,count:n,onChange:t,readOnly:l,noun:r,itemLabel:o,hint:a,children:i}){const s=f("fields",p).phoneOrder??p.phoneOrder;if(!(n>=2))return null;const c=y(e,n),d=k(c);/* @__PURE__ */
|
|
21
|
+
return R(h,{label:s.label,icon:/* @__PURE__ */R(K,{}),hint:a??s.hint({noun:r}),value:n,children:/* @__PURE__ */W("div",{className:"es-phone-order",children:[
|
|
22
|
+
/* @__PURE__ */R(ne,{label:s.label,head:!1,noun:r,items:c,onChange:e=>t(w(e,n)),newItem:()=>0,fixed:!0,readOnly:l,open:null,onOpen:()=>{},renderItem:()=>null,itemName:e=>o(e),renderRow:(e,n)=>/* @__PURE__ */W("span",{className:"es-phone-order-row",children:[
|
|
23
|
+
/* @__PURE__ */R("span",{className:"es-phone-order-pos","aria-hidden":"true",children:n+1}),
|
|
24
|
+
/* @__PURE__ */R("span",{className:"es-phone-order-name",children:o(e)})]})}),
|
|
25
|
+
/* @__PURE__ */R("p",{className:"es-phone-order-note",children:d?s.desktopKept:s.followsDesktop({noun:r})}),d&&i,d&&!l&&
|
|
26
|
+
/* @__PURE__ */R(F,{variant:"secondary",size:"md",block:!0,onClick:()=>t(void 0),children:s.matchDesktop})]})})}export{U as FieldText,pe as Inspector,ae as InspectorField,ne as ListField,ye as PhoneOrderField,ue as bucketsOf,ie as fieldShownInView,be as innerRowCount,G as insertAt,le as labelOf,q as moveTo,de as planFields,_ as removeAt,fe as rowViewState,ge as viewReadsIn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as s}from"./chunk-
|
|
2
|
-
return g(n,{label:l(s.label),icon:s.icon,hint:s.hint,value:O,onChange:e=>m(""===e?x:e),inherited:
|
|
3
|
-
return g(h,{label:o("Border"),icon:/* @__PURE__ */g(b,{}),action:d?/* @__PURE__ */g(i,{label:o("Border"),changed:f,detail:r(o,`${y}px`,s.followsView),disabled:s.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */g(t,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:y,right:y,bottom:y,left:y},style:u.style??"solid",color:p},presets:[p],words:w,styles:e.styles??!1,max:20,readOnly:s.readOnly})})}var
|
|
4
|
-
return g(h,{label:t("Corners"),icon:/* @__PURE__ */g(m,{}),changed:null!==
|
|
1
|
+
import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as s}from"./chunk-36AWYQLN.js";import{CornersInput as l,BorderInput as t,SettingsColour as n}from"./chunk-XWTQTANN.js";import{SettingsDefaultReset as i}from"./chunk-2T22IY3J.js";import{noControlField as c,NoControlMark as a}from"./chunk-22I55W37.js";import{normalizeCornerSides as d,CORNER_SIDES as u}from"./chunk-PLTTPHK5.js";import{DEFAULT_PANEL_WORDS as y,DEFAULT_COLOUR_ROW_WORDS as p}from"./chunk-56ID6FKZ.js";import{viewFollows as f}from"./chunk-DIOTWSCO.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CornerIcon as m,BorderAllIcon as b}from"efficient-shell/icons/efficient";import{jsx as g}from"react/jsx-runtime";var v=e=>e;function k(e,o){const r=o.twinAccess;return r?{key:e.key,access:r,ownField:r.ownField}:e}function j(e,r){const l=!e.access||e.ownField?{value:r.value,onChange:r.onChange}:void 0;return s(e.access??o,e.key,l)}function F(e,r){return s(e.access??o,r??"")}function C(e){return{...c({type:"custom",render:()=>/* @__PURE__ */g(a,{})},"always"),reachedBy:e}}function O({o:s,say:l,props:t}){const i=w("colourRow",p),c=w("panel",y),a=s.useFollows(),d=s.usePresets?.(),u=s.opacity?.useUnset?.()??100,f=k(s,t),[h,m]=j(f,t),[b,v]=F(f,s.opacity?.key),C=e(f.access??o),O="string"==typeof h?h:"",B="number"==typeof b,A="follows"in t,T=(A&&"string"==typeof t.follows&&""!==t.follows?t.follows:void 0)??a,x=s.access||A?void 0:"";/* @__PURE__ */
|
|
2
|
+
return g(n,{label:l(s.label),icon:s.icon,hint:s.hint,value:O,onChange:e=>m(""===e?x:e),inherited:T,presets:d,changed:""!==O||B,onReset:()=>{B&&s.opacity?C([[s.key,x],[s.opacity.key,void 0]]):m(x)},resetTo:A?r(l,T.toUpperCase(),t.followsView):s.resetTo?s.resetTo(a.toUpperCase()):a.toUpperCase(),...s.opacity?{opacity:B?b:u,onOpacityChange:e=>v(e)}:{},readOnly:t.readOnly,words:i,resetWords:c})}var B=20;function A({o:e,say:o,props:s}){const l=e.useFollows(),[n,c]=j(k(e,s),s),a=n&&"object"==typeof n?n:{},d="follows"in s,u=d&&s.follows&&"object"==typeof s.follows?s.follows:{},y="number"==typeof u.width?u.width:l.width,p="string"==typeof u.color&&""!==u.color?u.color:l.color,f=Object.keys(a).length>0,w={width:o("Border width"),sides:{top:o("Border top"),right:o("Border right"),bottom:o("Border bottom"),left:o("Border left")},style:o("Border style"),styles:{solid:o("Solid"),dashed:o("Dashed"),dotted:o("Dotted")},color:o("Border color"),unit:"px"};/* @__PURE__ */
|
|
3
|
+
return g(h,{label:o("Border"),icon:/* @__PURE__ */g(b,{}),action:d?/* @__PURE__ */g(i,{label:o("Border"),changed:f,detail:r(o,`${y}px`,s.followsView),disabled:s.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */g(t,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:y,right:y,bottom:y,left:y},style:u.style??"solid",color:p},presets:[p],words:w,styles:e.styles??!1,max:20,readOnly:s.readOnly})})}var T=40,x=()=>null;function R({o:s,say:t,props:n}){const c=w("panel",y),a=s.useFollows(),p=(s.useFollowsSides??x)(),b=k(s,n),[v,C]=j(b,n),[O,B]=F(b,s.sidesKey),[A]=F(s,s.sidesKey),[T]=F({key:s.key,access:n.widerAccess},n.widerAccess?s.sidesKey:void 0),R=e(b.access??o),I="follows"in n,K=s.access||I?void 0:null,W=I&&"number"==typeof n.follows?n.follows:a,S="number"==typeof v&&Number.isFinite(v)?v:null,D=(I?f(d(A),d(T)):null)??d(p)??[...u],M=d(O)??D,N=[{value:"tl",label:t("Top left")},{value:"tr",label:t("Top right")},{value:"bl",label:t("Bottom left")},{value:"br",label:t("Bottom right")}];/* @__PURE__ */
|
|
4
|
+
return g(h,{label:t("Corners"),icon:/* @__PURE__ */g(m,{}),changed:null!==S||Array.isArray(O),action:/* @__PURE__ */g(i,{label:t("Corners"),changed:null!==S||Array.isArray(O),detail:I?r(t,`${W}px`,n.followsView):`${W}px`,disabled:n.readOnly,onReset:()=>Array.isArray(O)?R([[s.key,K],[s.sidesKey,K]]):C(K),words:c}),children:/* @__PURE__ */g(l,{label:t("Corners"),value:M,corners:N,onChange:e=>{const o=u.filter(o=>e.includes(o)),r=o.length===D.length&&o.every(e=>D.includes(e));B(r?K:o)},radius:S,onRadiusChange:e=>C(e??K),radiusMin:0,radiusMax:40,radiusStep:s.step??1,radiusPlaceholder:String(W),disabled:n.readOnly})})}function I(e=v){return{colourField:o=>({type:"custom",render:r=>/* @__PURE__ */g(O,{o:o,say:e,props:r})}),borderField:o=>({type:"custom",render:r=>/* @__PURE__ */g(A,{o:o,say:e,props:r})}),cornersField:o=>({type:"custom",render:r=>/* @__PURE__ */g(R,{o:o,say:e,props:r})})}}var{colourField:K,borderField:W,cornersField:S}=I();export{B as BORDER_WIDTH_MAX,T as CORNER_RADIUS_MAX,W as borderField,K as colourField,S as cornersField,C as keptByRow,I as styleFieldBuilders};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-QEEW4X64.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-QEEW4X64.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{parseZoneKey as o,ROOT_ID as i}from"./chunk-YDTEYXQW.js";import{useCanvasLayout as c,useCanvasTyping as d,useCanvasEvent as u,CANVAS_TYPABLE_EVENT as h}from"./chunk-6GJEOER4.js";import{framePointToHost as f,elementScale as p,related as m,WORDS_CLEAR as g,frameRectToLayer as b,clientPointToLayer as y}from"./chunk-FR7EEKFF.js";import{isRepeatCopy as x}from"./chunk-7UFKEX72.js";import{useRef as v,useEffect as w,useState as k,useCallback as N,useMemo as D,useSyncExternalStore as A,useId as E,useLayoutEffect as T}from"react";import{Tooltip as z,IconButton as M,solidSurfaceStyle as C,Input as $,ItemCount as S}from"efficient-shell/ui";import{AddIcon as j,CloseIcon as L,SearchIcon as O}from"efficient-shell/icons/efficient";import{jsxs as B,jsx as X}from"react/jsx-runtime";function K({label:e,onInsert:t,style:n,axis:l="y",className:r,index:a}){const s=["es-canvas-insert","x"===l?"is-x":"",r??""].filter(Boolean).join(" ");/* @__PURE__ */
|
|
2
2
|
return B("div",{className:s,style:n,"data-index":a,children:[
|
|
3
3
|
/* @__PURE__ */X("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */X("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */X(z,{content:e,children:/* @__PURE__ */X(M,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */X(j,{})})})})]})}var Y=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,I=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>Y(e.box,t,n)).sort((e,t)=>I(t.s.box)-I(e.s.box)||e.at-t.at).map(({s:e})=>e)}function F(e,t,n){return q(e,t,n).at(-1)??null}function R(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function P(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function Q(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>Y(e.box,t,n)).sort((e,t)=>I(e.box)-I(t.box));for(const e of s){const s=R(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:P(e,s)};if(!a(o))return null}return null}function W(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function Z(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var H={nodes:[],zones:[]},V="data-easel-dropzone",G="data-easel-block";function J(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function U(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return
|
|
5
|
-
/* @__PURE__ */X(K,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??E.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */X("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",J?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===
|
|
6
|
-
/* @__PURE__ */X("div",{className:"es-canvas-handle-spot",style:Ce?{"--es-handle-x":`${ae(Ce).left}px`,"--es-handle-y":`${ae(Ce).top}px`}:void 0,children:/* @__PURE__ */X(z,{className:"es-canvas-handle-tip",side:"top",content:!V||
|
|
4
|
+
/* @__PURE__ */X("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */X(z,{content:e,children:/* @__PURE__ */X(M,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */X(j,{})})})})]})}var Y=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,I=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>Y(e.box,t,n)).sort((e,t)=>I(t.s.box)-I(e.s.box)||e.at-t.at).map(({s:e})=>e)}function F(e,t,n){return q(e,t,n).at(-1)??null}function R(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function P(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function Q(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>Y(e.box,t,n)).sort((e,t)=>I(e.box)-I(t.box));for(const e of s){const s=R(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:P(e,s)};if(!a(o))return null}return null}function W(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function Z(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var H={nodes:[],zones:[]},V="data-easel-dropzone",G="data-easel-block";function J(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function U(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return b(e.frame,J(n),t)}function ee(e,t){const{frame:n,document:l}=e,r=e=>b(n,J(e),t),a=[],s=[];for(const e of l.querySelectorAll(`[${V}]`)){if(x(e))continue;const t=e.getAttribute(V)??"";let n;try{n=o(t)}catch{continue}const l=[...e.querySelectorAll(`[${G}]`)].filter(t=>t.parentElement?.closest(`[${V}]`)===e&&!x(t)),i=l.map(r);s.push({key:t,list:n,box:r(e),axis:U(i,e),children:i}),l.forEach((e,t)=>{const l=e.getAttribute(G);l&&a.push({id:l,place:{...n,index:t},box:i[t]})})}return{nodes:a,zones:s}}var te="data-es-empty-cell",ne="data-easel-dropzone",le=140;var re=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),ae=e=>({left:e.left+2,top:Math.max(e.top-11,0)});function se(s){const{canvas:o,session:b,readOnly:x,words:E=e.canvas}=s,M=v(s);w(()=>{M.current=s});const $=v(null),S=c(o),[j,L]=k(0),O=N(()=>L(e=>e+1),[]),[Y,I]=k(H);w(()=>{const e=$.current;o&&e&&I((M.current.measure??ee)(o,e))},[o,S,s.revision,j]);const F=s.model,R=D(()=>F(Y),[F,Y]),P=A(b.subscribe,b.shown,b.shown),W=s.choose,Z=(e,t)=>{const n=q(R.sources,e,t);return 0===n.length?null:W?W(n):n[n.length-1]},[V,G]=k(null),[J,U]=k(null),[le,se]=k(null),oe=v(null),ie=()=>{oe.current&&clearTimeout(oe.current),oe.current=null},ce=()=>{ie(),oe.current=setTimeout(()=>{b.get()||G(null)},140)};w(()=>ie,[]);const de=v(null),ue=d(o),he=v(!1);he.current=ue;const[fe,pe]=k(null),me=v(null),ge=v(V);ge.current=V,w(()=>{ue?(pe(ge.current?.key??me.current?.id??null),ie(),G(null)):pe(null)},[ue]);const[be,ye]=k(null);u(o,h,e=>{const t=e.detail?.id??null,n=t?{id:t,words:e.detail?.words??null}:null;ye(n),n&&(me.current=n)});const xe=e=>{if(!(e&&e.isConnected&&o&&$.current))return null;const t=_(o,$.current,e);return{left:t.left-g,top:t.top-g,width:t.width+2*g,height:t.height+2*g}},ve=!be||ue||x||P?null:xe(be.words)??Y.nodes.find(e=>e.id===be.id)?.box??null;u(o,"mousemove",e=>{const t=$.current;if(!o||!t)return;const n=f(o.frame,e.clientX,e.clientY,t),l=p(t),r={x:n.x/l,y:n.y/l};if(de.current=r,M.current.readOnly||b.get()||he.current)return;ie();const a=Z(r.x,r.y);G(e=>e?.key===a?.key&&e?.box===a?.box?e:a)}),u(o,"mouseout",e=>{e.relatedTarget||(de.current=null,ce())}),u(o,"mouseover",e=>{e.relatedTarget||O()});const we=v(null),ke=N(()=>{we.current?.(),we.current=null,U(null),se(null)},[]);w(()=>b.subscribe(()=>{b.get()?O():ke()}),[b,ke,O]),w(()=>ke,[ke]),("undefined"==typeof document?w:T)(()=>{if(b.get())return;const e=de.current;G(t=>x||he.current?null:e?Z(e.x,e.y):t?R.sources.find(e=>e.key===t.key)??null:null)},[R,P,b,x,W]);const Ne=e=>{const t=b.get(),n=$.current,l=M.current.dropOn;if(!t||!n||!l)return null;const r=y(n,e.clientX,e.clientY);de.current=r;const a=q(R.sources,r.x,r.y);for(let e=a.length-1;e>=0;e-=1)if(l.accepts(t.item,a[e]))return{h:t,source:a[e]};return null},De=e=>{const t=b.get(),n=$.current;if(!t||!n)return null;const l=y(n,e.clientX,e.clientY);de.current=l;const r=Q(R.zones,l.x,l.y,e=>M.current.canDrop(t.item,e),e=>!!t.from&&a(t.from,e),e=>M.current.fallThrough?.(t.item,e,t.from)??!0);return r?{h:t,t:r}:null},Ae={onDragEnter:e=>{if(we.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),a=o?l(o.document):null,s=[];t&&s.push(r(t)),a&&o&&s.push(r(a,o.frame)),we.current=s.length?()=>s.forEach(e=>e()):null},onDragOver:e=>{const n=Ne(e);if(n)return e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed),U(null),void se(e=>e&&e.key===n.source.key&&e.box===n.source.box?e:n.source);se(null);const l=De(e);if(!l)return void U(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const r={zoneKey:l.t.zone.key,line:l.t.line,axis:l.t.zone.axis};U(e=>e&&e.zoneKey===r.zoneKey&&e.line.left===r.line.left&&e.line.top===r.line.top?e:r)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(de.current=null,U(null),se(null))},onDrop:e=>{const t=Ne(e);if(t)return e.preventDefault(),b.end(),ke(),void M.current.dropOn.onDrop(t.h.item,t.source);const n=De(e);n&&(e.preventDefault(),b.end(),ke(),M.current.onDrop(n.h.item,n.t.to))}},Ee={draggable:!x&&!!V,onMouseEnter:ie,onMouseLeave:()=>!b.get()&&ce(),onDragStart:e=>{if(V&&!x){b.start({key:V.key,item:V.item,from:V.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",V.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{b.end(),ke()},onClick:()=>{V&&!x&&M.current.onPick?.(V.item)}},{seams:Te=[]}=R,ze=be?.words??(ue?me.current?.words??null:null),Me=s.tag&&o&&$.current&&!P?(ze&&m(s.tag.element,ze)?xe(ze):null)??_(o,$.current,s.tag.element):null,Ce=V?(be&&be.id===V.key?xe(be.words):null)??V.box:null,$e=ue&&fe&&!s.tag?R.sources.find(e=>e.key===fe)??null:null,Se=$e?xe(ze)??$e.box:null,je=R.zones.filter(e=>0===e.children.length),Le=!s.onZoneAdd||x||ue?[]:je,Oe=Le.map(e=>e.key).join("\n");return w(()=>{const e=o?.document;if(!e)return;const t=new Set(Oe?Oe.split("\n"):[]);for(const n of e.querySelectorAll(`[${ne}]`))n.toggleAttribute(te,t.has(n.getAttribute(ne)??""));return()=>{for(const t of e.querySelectorAll(`[${te}]`))t.removeAttribute(te)}},[o,Oe,Y,S,j]),/* @__PURE__ */B("div",{ref:$,className:"es-canvas-layer",children:[P||!s.onSeamAdd||x||ue?null:Te.map(e=>
|
|
5
|
+
/* @__PURE__ */X(K,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??E.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */X("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",J?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===i?void 0:e.list.parentId,onClick:()=>s.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */X("span",{className:"es-canvas-empty-add",children:E.addButton({label:e.addLabel??s.zoneAddLabel??E.addBlock})})},e.key)):null,P?/* @__PURE__ */X("div",{className:"es-canvas-catch",...Ae}):null,le&&P?/* @__PURE__ */X("div",{className:"es-canvas-target",style:re(le.box),children:s.dropOn?.label?/* @__PURE__ */X("span",{className:"es-canvas-target-label",style:C(),children:s.dropOn.label(P.item,le)}):null}):null,J&&!je.some(e=>e.key===J.zoneKey)?/* @__PURE__ */X("div",{className:`es-canvas-line is-${J.axis}`,style:re(J.line)}):null,ve?/* @__PURE__ */X("span",{className:"es-canvas-hint"+(ve.width<200?" is-below":""),style:{...C(),left:ve.left+ve.width,top:ve.width<200?ve.top+ve.height:ve.top},children:E.typeHint}):null,Me&&s.tag?/* @__PURE__ */X("span",{className:"es-canvas-tag",style:ae(Me),children:s.tag.label}):$e&&Se?/* @__PURE__ */X("span",{className:"es-canvas-tag",style:ae(Se),children:$e.label}):null,
|
|
6
|
+
/* @__PURE__ */X("div",{className:"es-canvas-handle-spot",style:Ce?{"--es-handle-x":`${ae(Ce).left}px`,"--es-handle-y":`${ae(Ce).top}px`}:void 0,children:/* @__PURE__ */X(z,{className:"es-canvas-handle-tip",side:"top",content:!V||x||P?null:V.title??E.handle({label:V.label}),children:/* @__PURE__ */B("div",{className:["es-canvas-handle",V&&!x?"is-shown":"",P?"is-dragging":""].filter(Boolean).join(" "),...Ee,children:[
|
|
7
7
|
/* @__PURE__ */X("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),V?.label]})})})]})}var oe=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function ie({groups:t,session:n,itemFor:l,onInsert:r,onTileMenu:a,at:o,hint:i,searchLabel:c,readOnly:d,words:u=e.add}){const h=i??u.hint,f=c??u.search,[p,m]=k(""),g=E(),b=p.trim().toLowerCase(),y=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),x=t.map((e,t)=>({...e,key:y[t],tiles:b?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,b)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>r=>{if(t)r.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),r.dataTransfer.effectAllowed="copy";try{r.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
|
|
8
8
|
return B("div",{className:"es-add",children:[o?/* @__PURE__ */B("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */X("span",{children:o.label}),s(u.stop,/* @__PURE__ */X("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:o.onClear,children:/* @__PURE__ */X(L,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-4JPAVKV6.js";import{ScreenChrome as e}from"./chunk-7WONGRN3.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-OB4KI2AN.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-G2VZ4DET.js";import{documentPermissions as s}from"./chunk-G7J6SGMF.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var N=r(n),k=r(e);function C({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const N=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
|
-
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{
|
|
5
|
+
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{N()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
6
|
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function G({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),G=t(()=>s(!g),[g]),A=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
-
/* @__PURE__ */u(
|
|
7
|
+
/* @__PURE__ */u(N,{config:r,data:i,onChange:h,permissions:G,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(C,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:A.waitingForAuthorization})}export{G as DocumentScreen,j as ScreenMount};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-G2VZ4DET.js";import{styleMenuItems as o}from"./chunk-3OOYGEJY.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-XT75WETI.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{zoneKey as d,ROOT_SLOT as p,ROOT_ID as f}from"./chunk-YDTEYXQW.js";import{useCanvasEvent as m}from"./chunk-6GJEOER4.js";import{isTypingTarget as y,framePointToHost as h}from"./chunk-FR7EEKFF.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as w,AddIcon as C,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as P,RedoIcon as A,PasteIcon as E,StylesIcon as T,LayersIcon as j,CopyIcon as Y}from"efficient-shell/icons/efficient";import{jsx as D}from"react/jsx-runtime";function M(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var I=s(),K=/* @__PURE__ */new WeakMap;function X(e){if(e.claimsPage)return I;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=K.get(n);return t||(t=s(),K.set(n,t)),t}function L(){return X(e())}function S(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:f,slot:p,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function R(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function V(e,n,t){const o=e.canPasteAt;if(!o)return d(n.from)===t.zone?S(e,t.zone,t.index+1):null;for(const l of M(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function B(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(y(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function F(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=R(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:V(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function G(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=R(e,i,t),k=M(e,n),b=d.held,v=b&&!p?V(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...N(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:W(x?U(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?Q(e).pinned:void 0})}function U(e,n){const o=e.copyItem;if(!o||!n)return null;const l=Q(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */D(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */D(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */D(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */D(w,{}),danger:!0,onClick:s("delete")}]}}function W(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function N(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var Q=e=>e.words?.screen??t.menu;function Z(e){const n=Q(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */D(P,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */D(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=S(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):d(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */D(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */D(T,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */D(j,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),p={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[p,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=Q(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */D(Y,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */D(Y,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */D(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function $(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=B(e);if(!o)return;const l=t.selected();if(!l)return;const r=F(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),m(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);m(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=h(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),m(t,"mousedown",i),m(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */D(q,{host:e,target:o,onClose:i}):null,closeMenu:i}}function q({host:e,target:n,onClose:t}){const o="node"===n.kind?G(e,n):"input"===n.kind?J(e,n.el):Z(e);return 0===o.length?null:/* @__PURE__ */D(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{I as EASEL_NODE_CLIPBOARD,M as ancestorChain,X as nodeClipboardOf,R as nodeClipboardRules,G as nodeMenuItems,B as nodeShortcut,Z as pageMenuItems,V as pastePlace,F as runNodeShortcut,J as textMenuItems,L as useNodeClipboard,$ as useNodeContextMenu};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseZoneKey as t}from"./chunk-YDTEYXQW.js";import{repeatWrapperAt as e,REPEAT_ATTRIBUTE as r,REPEAT_INDEX_ATTRIBUTE as n}from"./chunk-7UFKEX72.js";var o=`[${r}][${n}]`;function l(l){const c=e(l);if(!c)return null;let i;try{i=t(c.zone)}catch{return null}if(!i.parentId||!i.slot)return null;const{wrapper:a,zone:p,index:f}=c;let s=a.parentElement;for(let t=a.parentElement;t;t=t.parentElement)if(t.getAttribute("data-easel-block")===i.parentId){s=t;break}const d=/* @__PURE__ */new Set;for(const t of Array.from(s?.querySelectorAll(o)??[]))t.getAttribute(r)===p&&d.add(t.getAttribute(n)??"");const m={ownerId:i.parentId,slot:i.slot,index:f,count:Math.max(d.size,f+1)},y=a.parentElement?u(a.parentElement):null;return y&&(m.outer=y),{copy:m,wrapper:a}}function u(t){return l(t)?.copy??null}function c(t,e){return t&&e?t.ownerId===e.ownerId&&t.slot===e.slot&&t.index===e.index&&c(t.outer,e.outer):t===e}function i(t,e){for(const r of Array.from(t.querySelectorAll(o))){if(r.getAttribute(n)!==String(e.index))continue;const t=l(r);if(t?.wrapper===r&&c(t.copy,e))return r}return null}export{i as findCopy,u as repeatCopyAt,l as repeatCopyWithWrapper};
|
package/dist/copy/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { d as CopyBoxProps, e as CopyCell, T as TextBoxHandle } from '../canvas-typing-B33ssbpU.js';
|
|
3
|
+
export { f as COPY_CELLS, c as CanvasTypingEnd, g as CanvasTypingOptions, h as CanvasTypingSession, b as ColorNameOf, i as ColorWindow, j as CopyBoxAlign, k as CopyBoxFooter, C as CopyBoxLastTool, l as CopyCase, m as CopyCellPreset, n as CopyCells, a as CopyThemeColor, M as MarkWriter, S as SelectionSource, o as TextAreaHandle, p as TextMap, q as ToolbarMark, r as colorRunOf, s as insertSelection, t as markSelection, u as startCanvasTyping, v as textMap } from '../canvas-typing-B33ssbpU.js';
|
|
4
4
|
import { TextAlign } from 'efficient-shell/ui';
|
|
5
5
|
export { TextToolbar, TextToolbarProps } from 'efficient-shell/ui';
|
|
6
6
|
import { F as FieldOption } from '../types-DcyH17ij.js';
|
|
@@ -10,7 +10,7 @@ export { C as CopyWords } from '../words-Cf5VT2Ic.js';
|
|
|
10
10
|
import '../buckets-BYQBBVgO.js';
|
|
11
11
|
import '../words-B5Gb7KFq.js';
|
|
12
12
|
|
|
13
|
-
declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, align, actions, toolbar, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
|
|
13
|
+
declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, align, actions, toolbar, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, colors, colorNameOf, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The range Clear formatting acts on, in one place: the selected words, or —
|