efficient-easel 24.1.0 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -2
- package/dist/{CanvasDragLayer-NZpaX6aq.d.ts → CanvasDragLayer-DXeQGrwJ.d.ts} +42 -3
- package/dist/canvas/index.d.ts +2 -139
- package/dist/canvas/index.js +1 -1
- package/dist/chrome/index.js +1 -1
- package/dist/{chunk-6NJHYXJM.js → chunk-3XECMGXX.js} +1 -1
- package/dist/chunk-4OMAA45Q.js +5 -0
- package/dist/{chunk-G67G63O5.js → chunk-4Y3TK65H.js} +1 -1
- package/dist/chunk-53ME3GAI.js +16 -0
- package/dist/{chunk-FRAIEWRC.js → chunk-62UGN7VM.js} +1 -1
- package/dist/{chunk-HNKB2ZYR.js → chunk-6ATIYLUL.js} +1 -1
- package/dist/{chunk-Y53EKN35.js → chunk-6EDVZBUO.js} +1 -1
- package/dist/chunk-7UFKEX72.js +1 -0
- package/dist/chunk-CEC5XLN4.js +1 -0
- package/dist/chunk-CWELHADJ.js +1 -0
- package/dist/chunk-DX3VILZ3.js +6 -0
- package/dist/chunk-ERB6FAZT.js +2 -0
- package/dist/{chunk-TGZCD6IP.js → chunk-EUFDQ4KL.js} +1 -1
- package/dist/chunk-FR7EEKFF.js +1 -0
- package/dist/{chunk-75C6WFNF.js → chunk-FYV6GZXP.js} +1 -1
- package/dist/chunk-GDO4QJ4G.js +1 -0
- package/dist/chunk-GEPSJJWW.js +1 -0
- package/dist/{chunk-GMCZXMOV.js → chunk-GR3XRILS.js} +1 -1
- package/dist/chunk-H6BER2EU.js +1 -0
- package/dist/chunk-JIP5JNRB.js +1 -0
- package/dist/{chunk-AGWKB77Q.js → chunk-K53PQAMP.js} +1 -1
- package/dist/{chunk-CLOS6SSX.js → chunk-KO47WAWR.js} +1 -1
- package/dist/chunk-KTV7ORWF.js +64 -0
- package/dist/chunk-LUG22U5L.js +1 -0
- package/dist/{chunk-DDH2DYQP.js → chunk-LUOY3A3Q.js} +1 -1
- package/dist/{chunk-OITNWE52.js → chunk-M4THI4OO.js} +1 -1
- package/dist/chunk-MBEUSPIN.js +18 -0
- package/dist/chunk-MIX7EGRG.js +2 -0
- package/dist/{chunk-2FYFAAAK.js → chunk-OXOUGEAT.js} +1 -1
- package/dist/chunk-PMRN5Z3T.js +1 -0
- package/dist/{chunk-55KKGABA.js → chunk-PVBDKBJB.js} +1 -1
- package/dist/{chunk-RPMSET77.js → chunk-QTHQPJWA.js} +1 -1
- package/dist/{chunk-ISS72IKO.js → chunk-QZJKWKGH.js} +1 -1
- package/dist/{chunk-IYHO4XQX.js → chunk-S6YOIRXQ.js} +1 -1
- package/dist/{chunk-5PXVT7JY.js → chunk-SBVIW3KJ.js} +1 -1
- package/dist/chunk-SC6E3UUS.js +13 -0
- package/dist/chunk-SSDKT4AY.js +9 -0
- package/dist/chunk-TOKMFZPB.js +1 -0
- package/dist/chunk-U3LTJSBU.js +20 -0
- package/dist/{chunk-WYTPBF3Q.js → chunk-VBEVZZTV.js} +11 -11
- package/dist/chunk-VIUES5R6.js +8 -0
- package/dist/{chunk-4ESG53BH.js → chunk-YFHKE54W.js} +1 -1
- package/dist/chunk-YYD257TD.js +1 -0
- package/dist/chunk-ZLOMH2PD.js +1 -0
- package/dist/{chunk-CE5SGCN2.js → chunk-ZYOQXBJF.js} +3 -3
- package/dist/copy/index.js +13 -13
- package/dist/copy-place-CQIemdtU.d.ts +25 -0
- package/dist/data/index.d.ts +4 -1
- package/dist/data/index.js +1 -1
- package/dist/dom-BpxMcHFP.d.ts +200 -0
- package/dist/drag/index.d.ts +2 -3
- package/dist/drag/index.js +1 -1
- package/dist/draw/index.d.ts +1 -1
- package/dist/draw/index.js +1 -1
- package/dist/easel/index.d.ts +67 -1
- package/dist/easel/index.js +1 -1
- package/dist/edit-lock/index.d.ts +0 -46
- package/dist/edit-lock/index.js +1 -1
- package/dist/fields/fields.css +6 -40
- package/dist/fields/index.d.ts +1 -6
- package/dist/fields/index.js +1 -1
- package/dist/node-ops/index.js +1 -1
- package/dist/page-copy/index.d.ts +110 -0
- package/dist/page-copy/index.js +5 -0
- package/dist/panel/index.d.ts +29 -34
- package/dist/panel/index.js +1 -1
- package/dist/panel/panel.css +0 -78
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.d.ts +37 -57
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +19 -11
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/SaveControls.d.ts +10 -11
- package/dist/screen/components/SaveControls.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.d.ts +5 -6
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +8 -9
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/SidePanelHead.js +1 -1
- package/dist/screen/components/panel-widths.js +1 -1
- package/dist/screen/components/usePartBridge.d.ts +10 -11
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +9 -10
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/document/block-set-host.d.ts +55 -0
- package/dist/screen/lib/document/block-set-host.js +1 -0
- package/dist/screen/lib/document/block-types-in.js +1 -1
- package/dist/screen/lib/document/box-fields.d.ts +70 -3
- package/dist/screen/lib/document/box-fields.js +1 -9
- package/dist/screen/lib/document/device-fields.js +1 -1
- package/dist/screen/lib/document/palette-sections.d.ts +33 -97
- package/dist/screen/lib/document/palette-sections.js +1 -1
- package/dist/screen/lib/document/preview-dom.js +1 -1
- package/dist/screen/lib/document/section-doc.js +1 -1
- package/dist/screen/lib/document/style-clipboard.d.ts +10 -11
- package/dist/screen/lib/document/style-clipboard.js +1 -1
- package/dist/screen/lib/document/use-section-ops.js +1 -1
- package/dist/screen/lib/document-switch.js +1 -1
- package/dist/screen/lib/failure.js +1 -1
- package/dist/screen/lib/host-inbound.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/media-picker.js +1 -1
- package/dist/screen/lib/page-lock.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +265 -13
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +6 -0
- package/dist/screen/words.d.ts +9 -0
- package/dist/screen/words.js +1 -1
- package/dist/strings/index.d.ts +4 -1
- package/dist/strings/index.js +2 -2
- package/dist/style-clipboard/index.d.ts +0 -32
- package/dist/style-clipboard/index.js +1 -1
- package/dist/text-styles/index.d.ts +7 -6
- package/dist/text-styles/index.js +37 -36
- package/dist/text-styles/text-styles.css +5 -53
- package/dist/tree/index.d.ts +2 -2
- package/dist/{types-DBy3L69b.d.ts → types-CoUTWUwB.d.ts} +1 -1
- package/dist/words-Dl8Qja4K.d.ts +32 -0
- package/package.json +15 -3
- package/dist/chunk-3FIS2FRS.js +0 -1
- package/dist/chunk-7RSE6KKY.js +0 -1
- package/dist/chunk-AAAZ2CQR.js +0 -1
- package/dist/chunk-CMPFUJ26.js +0 -8
- package/dist/chunk-CZAAGBVL.js +0 -7
- package/dist/chunk-DSKNJXB4.js +0 -1
- package/dist/chunk-FJTCSQWK.js +0 -16
- package/dist/chunk-H4Z2V56N.js +0 -21
- package/dist/chunk-K7MMLCTT.js +0 -2
- package/dist/chunk-KRL3IUV3.js +0 -1
- package/dist/chunk-LF3FUSCQ.js +0 -1
- package/dist/chunk-LN43DP2A.js +0 -18
- package/dist/chunk-MRWVYSU5.js +0 -64
- package/dist/chunk-QORC32JO.js +0 -5
- package/dist/chunk-THWO5YVZ.js +0 -1
- package/dist/chunk-TOHOGVAE.js +0 -15
- package/dist/chunk-V7U33NF2.js +0 -1
- package/dist/chunk-VKPOH6MK.js +0 -1
- package/dist/chunk-YU3WHLGI.js +0 -1
- package/dist/repeat-D65bJS8d.d.ts +0 -49
- package/dist/session-EsjORLQ0.d.ts +0 -43
package/README.md
CHANGED
|
@@ -715,6 +715,7 @@ const tick = useCanvasLayout(canvas); // re-m
|
|
|
715
715
|
| `isTypingTarget(target)` | Is this key pressed somewhere a person types (text inputs, textarea, select, editable regions)? A shortcut must stay out. |
|
|
716
716
|
| `nodeIdAt(target, attribute?)` | The block a pointer event landed on. |
|
|
717
717
|
| `REPEAT_ATTRIBUTE`, `REPEAT_INDEX_ATTRIBUTE`, `isRepeatCopy`, `mainCopyOf`, `queryMainCopy`, `queryAllCopies` | A template drawn once per data row: each copy is in `<div data-sf-repeat="<ownerId>:template" data-sf-repeat-index={i}>`, index 0 the main copy. The outline goes on every copy (`queryAllCopies`), a lookup by id reads the main one (`queryMainCopy`), and only the main copy's lists take drops. With no `data-sf-repeat` each answers what `querySelector` answers. |
|
|
718
|
+
| `repeatWrapperAt` | The nearest copy wrapper round an element (both attributes), as `{ wrapper, zone, index }` — the zone key as written — or null. No import: `draw` reads this file. The parsed place is `efficient-easel/easel` `repeatCopyAt`. |
|
|
718
719
|
| `watchCanvasFrame(root, onChange, options)` | The watcher the hook wraps, for code outside React. |
|
|
719
720
|
| `setCanvasNonce(document, nonce)` | The CSP nonce every `<style>` created in that canvas document carries (0.95.0). `CanvasFrame`'s `nonce` prop sets it; a host that builds its own frame calls it. |
|
|
720
721
|
|
|
@@ -1150,6 +1151,14 @@ So the frame's parts write no `style` of their own into a server's HTML:
|
|
|
1150
1151
|
reads them, and a host writes its own with `setPanelWidthVars(el, widths)`
|
|
1151
1152
|
from a ref rather than `style={panelWidthVars(widths)}`.
|
|
1152
1153
|
- **Stylesheets in the frame** take the page's nonce: `<EaselCanvas nonce>`.
|
|
1154
|
+
- **A drawn copy of a card template takes typing** (`EaselCanvas` `typing`):
|
|
1155
|
+
`onCopyText(edit: CanvasCopyText)` gets every write in a copy with
|
|
1156
|
+
`{ ownerId, slot, index, outer?, nodeId, key, text }` (return `false` for
|
|
1157
|
+
words that are the template's own: `write` takes them); `copyValue(copy:
|
|
1158
|
+
CanvasCopyPlace)` gives the row's saved string to start from;
|
|
1159
|
+
`CanvasTypingTarget.key` names the prop. `repeatCopyAt(el): RepeatCopy |
|
|
1160
|
+
null` (`{ ownerId, slot, index, count, outer? }`) is the copy an element is
|
|
1161
|
+
in, its zone key read by `data` `parseZoneKey`.
|
|
1153
1162
|
|
|
1154
1163
|
What still writes a `style`, and where it matters:
|
|
1155
1164
|
|
|
@@ -1242,7 +1251,9 @@ the Footer is drawn; `pinned.band` names the sections between the pins, folds
|
|
|
1242
1251
|
them under a row of their own and ends them with an "Add section" row; and
|
|
1243
1252
|
`useDocumentLabel` is the head's context line. A row's name, its quieter
|
|
1244
1253
|
words, its marks and buttons of the layer's own are `blockLook.rowName`,
|
|
1245
|
-
`rowPreview`, `rowMarks` and `rowActions
|
|
1254
|
+
`rowPreview`, `rowMarks` and `rowActions`; `blockLook.canvasTab` gives a
|
|
1255
|
+
block a small tab above it on the canvas while it is selected or under the
|
|
1256
|
+
pointer ("Designs shown" for a number filled from a live count). A block config's
|
|
1246
1257
|
`permissions.delete` / `duplicate` set to `false` takes the action off the
|
|
1247
1258
|
block's rows and its menu, and the inspector is handed the answer for its
|
|
1248
1259
|
head (`nodeActions`). The frame's words (the pinned labels,
|
|
@@ -1282,7 +1293,9 @@ and says why. (`add.railTarget` and `add.blocksFirst`, 0.105.0, went with the
|
|
|
1282
1293
|
rail's "+".) A category marked `visible: false` is not offered; Add's words are
|
|
1283
1294
|
`screen.add`. `styleClipboard` is Copy style / Paste style's scope and a
|
|
1284
1295
|
node's look (`scope`, `rows`, `copy`, `plan`); the bridges' `menuRows` are the
|
|
1285
|
-
layer's own rows in a node's menu
|
|
1296
|
+
layer's own rows in a node's menu, and `onCopyItem` a drawn copy's row
|
|
1297
|
+
actions there (Add item after, Move item earlier / later, Delete item,
|
|
1298
|
+
asked with `{ ownerId, slot, index, outer?, action }`; none while read-only); ⌘C / ⌘X / ⌘V copy, cut and paste the
|
|
1286
1299
|
selected block by the menu's rules (`nodeKeys`, on unless the layer says
|
|
1287
1300
|
`false`); and a host whose window closes on Escape hands
|
|
1288
1301
|
`createEaselHost({ claimEscape })`, so the menu, Add, a field's pick and a
|
|
@@ -1386,6 +1399,34 @@ only its original may hold (the campaign designer's baked picture).
|
|
|
1386
1399
|
- **Its classes keep their `sf-` names** and its strings their words: the
|
|
1387
1400
|
hosts' sheets, their guards and the website's host address them.
|
|
1388
1401
|
|
|
1402
|
+
## Duplicate page — `efficient-easel/page-copy`
|
|
1403
|
+
|
|
1404
|
+
"Duplicate page" once, for both products (B9, 2026-10-28). The rules of copying a
|
|
1405
|
+
page are pure functions; the dialog is drawn with the shell's parts. The copy
|
|
1406
|
+
itself is the backend's: the host hands in ONE call.
|
|
1407
|
+
|
|
1408
|
+
```tsx
|
|
1409
|
+
import { DuplicatePageDialog, canDuplicatePage } from 'efficient-easel/page-copy';
|
|
1410
|
+
|
|
1411
|
+
// Show the action only on a row that may be copied (`isSystem`: the host's own list).
|
|
1412
|
+
canDuplicatePage({ kind: row.kind, slug: row.slug }, isSystemPageSlug);
|
|
1413
|
+
|
|
1414
|
+
<DuplicatePageDialog
|
|
1415
|
+
source={{ title: row.label, slug: row.slug }}
|
|
1416
|
+
taken={pageSlugs} // every handle the site's pages use
|
|
1417
|
+
host="inovit.com" // the URL hint: host/handle
|
|
1418
|
+
duplicate={(input) => api.duplicate(row.id, input)} // { title, slug } → the copy
|
|
1419
|
+
onDuplicated={(copy) => reloadAndOpen(copy)}
|
|
1420
|
+
onClose={close}
|
|
1421
|
+
/>
|
|
1422
|
+
```
|
|
1423
|
+
|
|
1424
|
+
A host with a window system of its own does not use the dialog: it calls
|
|
1425
|
+
`usePageCopyForm({ source, taken, duplicate, onDuplicated })` and draws
|
|
1426
|
+
`<DuplicatePageFields form={form} host={host} />` inside its own window, with
|
|
1427
|
+
`form.submit` on its own button (efficient-admin-portal's `PopupForm`).
|
|
1428
|
+
Its words are `pageCopy` in `efficient-easel/strings`.
|
|
1429
|
+
|
|
1389
1430
|
## The engine's words — `efficient-easel/strings`
|
|
1390
1431
|
|
|
1391
1432
|
`efficient-easel/strings` (added in 0.95.0) is every word the engine itself
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { C as CanvasTarget$1 } from './watch-Unf6SfUf.js';
|
|
3
|
-
import {
|
|
4
|
-
import { D as DragSession } from './session-EsjORLQ0.js';
|
|
3
|
+
import { P as Place, S as SlotAddress } from './types-Dq180WRV.js';
|
|
5
4
|
import { D as DragWords } from './words-SD4neL0n.js';
|
|
6
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The one drag in flight, shared by every surface of an editor — the Layers
|
|
8
|
+
* tree, the canvas and the Add list (blueprint step 3.2).
|
|
9
|
+
*
|
|
10
|
+
* Native drag-and-drop does not let a drop target read what is being dragged
|
|
11
|
+
* until the drop itself (the data is sealed during `dragover`), and a tree that
|
|
12
|
+
* only knows about drags it started cannot take a block from the Add list. So
|
|
13
|
+
* the surface that starts a drag writes it here and every surface reads it: a
|
|
14
|
+
* block picked up on the canvas can land in the tree, a tile from the Add list
|
|
15
|
+
* on either.
|
|
16
|
+
*
|
|
17
|
+
* `from` is where the thing sits now — absent for something new (an Add tile),
|
|
18
|
+
* which is also why a new thing can never be a no-op drop.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
type DragHeld<I> = {
|
|
22
|
+
/** The identity `keyOf` gave it — which row or box is the one being dragged. */
|
|
23
|
+
key: string;
|
|
24
|
+
item: I;
|
|
25
|
+
/** Where it sits now. Absent: it is new, from the Add list. */
|
|
26
|
+
from?: Place;
|
|
27
|
+
};
|
|
28
|
+
type DragSession<I> = {
|
|
29
|
+
/** The drag in flight, current at once (for event handlers). */
|
|
30
|
+
get: () => DragHeld<I> | null;
|
|
31
|
+
/** The drag as last TOLD to subscribers (for rendering — see below). */
|
|
32
|
+
shown: () => DragHeld<I> | null;
|
|
33
|
+
start: (held: DragHeld<I>) => void;
|
|
34
|
+
end: () => void;
|
|
35
|
+
subscribe: (listener: () => void) => () => void;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* `get()` is current the moment a drag starts — the drop targets read it on
|
|
39
|
+
* their first `dragover`. SUBSCRIBERS hear about a start one tick later: the
|
|
40
|
+
* browser takes the drag picture when the `dragstart` handlers return, and a
|
|
41
|
+
* render in between (a row dimming, the handle hiding) would be in the picture.
|
|
42
|
+
* An end is told at once.
|
|
43
|
+
*/
|
|
44
|
+
declare function createDragSession<I>(): DragSession<I>;
|
|
45
|
+
|
|
7
46
|
/**
|
|
8
47
|
* Where a drop on the CANVAS lands — pure functions over measured boxes
|
|
9
48
|
* (blueprint step 3.2). The tree's rule (./hit) is about rows in a list; the
|
|
@@ -232,4 +271,4 @@ type CanvasDragLayerProps<I> = {
|
|
|
232
271
|
declare const HANDLE_GRACE_MS = 140;
|
|
233
272
|
declare function CanvasDragLayer<I>(props: CanvasDragLayerProps<I>): react.JSX.Element;
|
|
234
273
|
|
|
235
|
-
export { type Box as B, type CanvasDragModel as C, EMPTY_MEASURE as E, HANDLE_GRACE_MS as H, type MeasuredCanvas as M, CanvasDragLayer as a, type CanvasDragLayerProps as b, type CanvasTarget as c, type CanvasSeam as d, type CanvasSource as e, type CanvasZone as f, type
|
|
274
|
+
export { type Box as B, type CanvasDragModel as C, type DragSession as D, EMPTY_MEASURE as E, HANDLE_GRACE_MS as H, type MeasuredCanvas as M, CanvasDragLayer as a, type CanvasDragLayerProps as b, type CanvasTarget as c, type CanvasSeam as d, type CanvasSource as e, type CanvasZone as f, type DragHeld as g, type MeasuredNode as h, canvasTarget as i, contains as j, createDragSession as k, gapInZone as l, gapLine as m, insertSeams as n, measureCanvas as o, pickSource as p, sourcesAt as q, seamsBetween as s };
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -1,144 +1,7 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { C as CanvasTarget, W as WatchOptions } from '../watch-Unf6SfUf.js';
|
|
3
3
|
export { B as BLOCK_SELECTOR, a as CANVAS_SELECTOR, L as LIST_SELECTOR, i as isFrameReady, w as watchCanvasFrame } from '../watch-Unf6SfUf.js';
|
|
4
|
-
export { R as REPEAT_ATTRIBUTE, a as REPEAT_INDEX_ATTRIBUTE, i as isRepeatCopy, m as mainCopyOf, q as queryAllCopies,
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The small facts every canvas surface needs, written once — pure DOM, no
|
|
8
|
-
* React, nothing run at import.
|
|
9
|
-
*
|
|
10
|
-
* Each answers a question both editors used to answer for themselves, and
|
|
11
|
-
* sometimes differently (the blueprint's §2 rows 6–10):
|
|
12
|
-
*
|
|
13
|
-
* isTypingTarget is this keystroke someone TYPING, so a shortcut must stay out?
|
|
14
|
-
* nodeIdAt which block did this pointer event land on?
|
|
15
|
-
* frameScale how much is the canvas frame scaled (a phone view drawn small)?
|
|
16
|
-
* frameRectToHost where is a box measured INSIDE the frame, on the host page?
|
|
17
|
-
* fitCanvas how wide is the canvas, and at what scale does it fit?
|
|
18
|
-
* canvas styles a stylesheet that lives in the canvas document ONLY.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Is the event's target somewhere a person TYPES — a text field, a textarea, a
|
|
22
|
-
* native select, an editable region? A shortcut (undo, delete, copy style) must
|
|
23
|
-
* not fire there: the key belongs to the field. Duck-typed rather than
|
|
24
|
-
* `instanceof`, because a canvas element belongs to the frame's own realm and
|
|
25
|
-
* is not an instance of the host's `HTMLElement`.
|
|
26
|
-
*/
|
|
27
|
-
declare function isTypingTarget(target: EventTarget | null): boolean;
|
|
28
|
-
/** The attribute on every block the canvas draws. */
|
|
29
|
-
declare const BLOCK_ATTRIBUTE = "data-easel-block";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The id of the block a pointer event landed on: the NEAREST ancestor (or the
|
|
33
|
-
* target itself) carrying `attribute`. `null` on bare canvas.
|
|
34
|
-
*/
|
|
35
|
-
declare function nodeIdAt(target: EventTarget | null, attribute?: string): string | null;
|
|
36
|
-
/**
|
|
37
|
-
* The box a block DREW, in its frame's viewport (8.2.0). Most blocks draw inside
|
|
38
|
-
* the canvas's wrapper, and the wrapper's own box is the answer. A block whose
|
|
39
|
-
* drawing leaves the wrapper's flow (the website's header bar is
|
|
40
|
-
* `position: fixed`) leaves the wrapper with no height; then the union of what
|
|
41
|
-
* it drew is the box: each child element with a box of its own, and inside a
|
|
42
|
-
* child with none (a host's own wrapper divs round the bar), what that child
|
|
43
|
-
* drew, the same way. Never null: a wrapper with nothing drawn is its own empty
|
|
44
|
-
* box.
|
|
45
|
-
*/
|
|
46
|
-
declare function drawnBox(el: Element): Box;
|
|
47
|
-
/** Whether one element holds the other (or is it): the same words, however the host stamps them. */
|
|
48
|
-
declare function related(a: Element, b: Element): boolean;
|
|
49
|
-
/** How far the box round typed or selected words stands clear of them, in px
|
|
50
|
-
* (Lewis 2026-10-14). The one home: the canvas sets `--es-words-clear` from
|
|
51
|
-
* it (`.is-typing`, `.is-selected.is-words` read that, easel.css) and the
|
|
52
|
-
* drag layer measures the handle's corner from it. */
|
|
53
|
-
declare const WORDS_CLEAR = 4;
|
|
54
|
-
interface Box {
|
|
55
|
-
left: number;
|
|
56
|
-
top: number;
|
|
57
|
-
width: number;
|
|
58
|
-
height: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* How much the frame is drawn scaled on the host page: its on-screen width over
|
|
62
|
-
* its layout width. The storefront draws tablet and phone at their real widths
|
|
63
|
-
* and scales the frame down to fit the pane; the campaign designer does not
|
|
64
|
-
* scale. 1 when the frame has no layout width yet.
|
|
65
|
-
*/
|
|
66
|
-
declare function frameScale(frame: HTMLElement): number;
|
|
67
|
-
/**
|
|
68
|
-
* A box measured INSIDE the frame (an element's getBoundingClientRect in the
|
|
69
|
-
* frame's own viewport) as a box on the HOST page, relative to `origin` — the
|
|
70
|
-
* overlay layer the box will be drawn in — and through the frame's scale. The
|
|
71
|
-
* scale is the term both apps' own conversions left out on a scaled view.
|
|
72
|
-
*/
|
|
73
|
-
declare function frameRectToHost(frame: HTMLElement, box: Box, origin?: Element | null): Box;
|
|
74
|
-
/**
|
|
75
|
-
* How much `el` is drawn scaled on screen: its on-screen width over its layout
|
|
76
|
-
* width. 1 when it is not scaled, or has no layout width yet. An overlay that
|
|
77
|
-
* shares a scaled ancestor with the frame (the storefront scales the whole
|
|
78
|
-
* device box, frame and overlay together) is scaled too, and its own CSS pixels
|
|
79
|
-
* are then that much smaller or larger than the screen's.
|
|
80
|
-
*/
|
|
81
|
-
declare function elementScale(el: Element): number;
|
|
82
|
-
/**
|
|
83
|
-
* A box measured inside the frame as a box in `layer`'s OWN CSS coordinates —
|
|
84
|
-
* what an absolutely positioned child of `layer` is placed with. The same as
|
|
85
|
-
* `frameRectToHost` when the layer is not scaled; when it shares a scaled
|
|
86
|
-
* ancestor with the frame, every screen distance is divided back into the
|
|
87
|
-
* layer's pixels, or everything it draws lands the scale's factor away.
|
|
88
|
-
*/
|
|
89
|
-
declare function frameRectToLayer(frame: HTMLElement, box: Box, layer: Element): Box;
|
|
90
|
-
/** A pointer position on the HOST page (clientX/clientY there) in `layer`'s own CSS coordinates. */
|
|
91
|
-
declare function clientPointToLayer(layer: Element, x: number, y: number): {
|
|
92
|
-
x: number;
|
|
93
|
-
y: number;
|
|
94
|
-
};
|
|
95
|
-
/** A pointer position inside the frame (clientX/clientY there) on the host page. */
|
|
96
|
-
declare function framePointToHost(frame: HTMLElement, x: number, y: number, origin?: Element | null): {
|
|
97
|
-
x: number;
|
|
98
|
-
y: number;
|
|
99
|
-
};
|
|
100
|
-
interface CanvasFit {
|
|
101
|
-
/** The canvas's layout width — the device's, or the pane's for a fluid view. */
|
|
102
|
-
width: number;
|
|
103
|
-
/** The scale that fits `width` into the pane, capped at `maxScale`. */
|
|
104
|
-
scale: number;
|
|
105
|
-
/** What the canvas occupies on screen: `width * scale`. */
|
|
106
|
-
shownWidth: number;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* The canvas width and scale for a pane `available` px wide. A device with no
|
|
110
|
-
* width of its own (desktop, an email's inbox view) takes the pane's width at
|
|
111
|
-
* scale 1; a device width that does not fit is scaled down to fit, and one that
|
|
112
|
-
* does is scaled up no further than `maxScale` (the storefront allows 2; pass 1
|
|
113
|
-
* for "never enlarge").
|
|
114
|
-
*/
|
|
115
|
-
declare function fitCanvas({ available, width, maxScale, }: {
|
|
116
|
-
available: number;
|
|
117
|
-
width?: number | null;
|
|
118
|
-
maxScale?: number;
|
|
119
|
-
}): CanvasFit;
|
|
120
|
-
/**
|
|
121
|
-
* Say which CSP nonce the stylesheets this module puts in `doc` must carry —
|
|
122
|
-
* for a host whose policy allows inline styles by nonce (`style-src
|
|
123
|
-
* 'nonce-…'`), where a `<style>` without it is refused. Every sheet
|
|
124
|
-
* `upsertCanvasStyle` / `useCanvasStyle` creates in `doc` afterwards wears it.
|
|
125
|
-
*
|
|
126
|
-
* `CanvasFrame` (`efficient-easel/easel`) calls this with its `nonce` prop as
|
|
127
|
-
* it builds the frame, so a host says it once; a host that builds its own
|
|
128
|
-
* frame calls it itself. `undefined` (or `''`) forgets it.
|
|
129
|
-
*/
|
|
130
|
-
declare function setCanvasNonce(doc: Document, nonce: string | undefined): void;
|
|
131
|
-
/**
|
|
132
|
-
* Put `css` in the canvas document's `<head>` under `key`, replacing what that
|
|
133
|
-
* key held before. It lives in the canvas ONLY — not mirrored from the host
|
|
134
|
-
* head, so it cannot leak into the host page, and not dependent on anyone
|
|
135
|
-
* noticing a change to it. Writes nothing when the text is already current.
|
|
136
|
-
* A new sheet carries the document's nonce, when it was given one
|
|
137
|
-
* ({@link setCanvasNonce}).
|
|
138
|
-
*/
|
|
139
|
-
declare function upsertCanvasStyle(doc: Document, key: string, css: string): HTMLStyleElement;
|
|
140
|
-
/** Take `key`'s stylesheet out of the canvas document, if it is there. */
|
|
141
|
-
declare function removeCanvasStyle(doc: Document, key: string): void;
|
|
4
|
+
export { B as BLOCK_ATTRIBUTE, b as Box, C as CanvasFit, R as REPEAT_ATTRIBUTE, a as REPEAT_INDEX_ATTRIBUTE, W as WORDS_CLEAR, c as clientPointToLayer, d as drawnBox, e as elementScale, f as fitCanvas, g as framePointToHost, h as frameRectToHost, i as frameRectToLayer, j as frameScale, k as isRepeatCopy, l as isTypingTarget, m as mainCopyOf, n as nodeIdAt, q as queryAllCopies, o as queryMainCopy, r as related, p as removeCanvasStyle, s as repeatWrapperAt, t as setCanvasNonce, u as upsertCanvasStyle } from '../dom-BpxMcHFP.js';
|
|
142
5
|
|
|
143
6
|
/**
|
|
144
7
|
* efficient-easel/canvas — the one way into the editor's canvas frame.
|
|
@@ -246,4 +109,4 @@ declare function useCanvasLayout(canvas: CanvasTarget | null, { settle }?: {
|
|
|
246
109
|
settle?: readonly number[];
|
|
247
110
|
}): number;
|
|
248
111
|
|
|
249
|
-
export {
|
|
112
|
+
export { CANVAS_TYPABLE_EVENT, CANVAS_TYPING_EVENT, CanvasTarget, type CanvasTypableEvent, type CanvasTypingEvent, WatchOptions, useCanvasEvent, useCanvasFrame, useCanvasLayout, useCanvasStyle, useCanvasTyping };
|
package/dist/canvas/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{BLOCK_SELECTOR,CANVAS_SELECTOR,CANVAS_TYPABLE_EVENT,CANVAS_TYPING_EVENT,LIST_SELECTOR,isFrameReady,useCanvasEvent,useCanvasFrame,useCanvasLayout,useCanvasStyle,useCanvasTyping,watchCanvasFrame}from"../chunk-TOKMFZPB.js";export{BLOCK_ATTRIBUTE,WORDS_CLEAR,clientPointToLayer,drawnBox,elementScale,fitCanvas,framePointToHost,frameRectToHost,frameRectToLayer,frameScale,isTypingTarget,nodeIdAt,related,removeCanvasStyle,setCanvasNonce,upsertCanvasStyle}from"../chunk-FR7EEKFF.js";export{REPEAT_ATTRIBUTE,REPEAT_INDEX_ATTRIBUTE,isRepeatCopy,mainCopyOf,queryAllCopies,queryMainCopy,repeatWrapperAt}from"../chunk-7UFKEX72.js";
|
package/dist/chrome/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{DEFAULT_PANEL_W,DeviceSwitch,EaselIconButton,EaselTopBar,EditNotice,InspectorHead,InspectorIconButton,InspectorUpLevel,MAX_PANEL_W,MIN_PANEL_W,MIN_PANEL_W_BY_SIDE,PanelResizeHandle,SaveIcon,SaveState,SaveStateToggle,TopBarCluster,TopBarDivider,TopBarRail,clampPanelWidth,editNotice,headWords,panelWidthVars,saveIconTone,setPanelWidthVars}from"../chunk-
|
|
1
|
+
export{DEFAULT_PANEL_W,DeviceSwitch,EaselIconButton,EaselTopBar,EditNotice,InspectorHead,InspectorIconButton,InspectorUpLevel,MAX_PANEL_W,MIN_PANEL_W,MIN_PANEL_W_BY_SIDE,PanelResizeHandle,SaveIcon,SaveState,SaveStateToggle,TopBarCluster,TopBarDivider,TopBarRail,clampPanelWidth,editNotice,headWords,panelWidthVars,saveIconTone,setPanelWidthVars}from"../chunk-VBEVZZTV.js";import"../chunk-MJM6SFD3.js";import"../chunk-AJSDWWJW.js";import"../chunk-2OAZYSWJ.js";import"../chunk-YYD257TD.js";import"../chunk-RE4LP46F.js";import"../chunk-MFIRYGHW.js";import"../chunk-EUFDQ4KL.js";import"../chunk-KXM6YRG2.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{zoneKey as e}from"./chunk-
|
|
1
|
+
import{zoneKey as e}from"./chunk-EUFDQ4KL.js";import{useRef as t,useEffect as n,useState as r,useSyncExternalStore as o,useCallback as i}from"react";var l=56,c=16;function a(e){const t=Math.max(e,0);return t>=l?0:Math.ceil(16*(1-t/l))}function u(e,t,n){if(e<t-l||e>n+l)return 0;const r=e-t,o=n-e;return r<l&&r<=o?-a(r):o<l?a(o):0}function s(e){const t=e?.ownerDocument?.defaultView;for(let n=e?.parentElement??null;n;n=n.parentElement){const e=t?.getComputedStyle(n).overflowY;if(("auto"===e||"scroll"===e)&&n.scrollHeight>n.clientHeight)return n}return null}function f(e){const t=e?.ownerDocument?.defaultView?.getComputedStyle(e).overflowY;return e&&("auto"===t||"scroll"===t)&&e.scrollHeight>e.clientHeight?e:s(e)}function d(e){const t=e.scrollingElement??e.documentElement;return t&&t.scrollHeight>t.clientHeight?t:null}function g(e,t=e){const n=t.ownerDocument,r=n.defaultView;if(!r)return()=>{};let o=null,i=0;const l=e=>{o=e.clientY},c=()=>{if(null!==o){const n=t.getBoundingClientRect(),r=u(o,n.top,n.bottom);r&&(e.scrollTop+=r)}i=r.requestAnimationFrame(c)};return n.addEventListener("dragover",l,!0),i=r.requestAnimationFrame(c),()=>{n.removeEventListener("dragover",l,!0),r.cancelAnimationFrame(i)}}function p(e){return/move|all|uninitialized/i.test(e)?"move":"copy"}function m(){let e=null,t=null;const n=/* @__PURE__ */new Set,r=()=>{if(t!==e){t=e;for(const e of[...n])e()}};return{get:()=>e,shown:()=>t,start(t){e=t,globalThis.setTimeout(r,0)},end(){null===e&&null===t||(e=null,r())},subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function v(e,t,n,r){if(e.into)return{side:"into",to:e.into};return"first"===e.pinned||"last"!==e.pinned&&t>n+r/2?{side:"after",to:{...e.place,index:e.place.index+1}}:{side:"before",to:{...e.place,index:e.place.index}}}var D=(t,n)=>e(t)===e(n);function w(e,t){return D(e,t)&&(t.index===e.index||t.index===e.index+1)}function y(e,t){return D(e,t)&&e.index<t.index?t.index-1:t.index}function x(e,t){return{...e,index:t<0?e.index-1:e.index+2}}function h(e,t){if(!t)return e;const n={...t,...e};for(const[r,o]of Object.entries(e)){const e=t[r];"function"==typeof o&&"function"==typeof e&&(n[r]=t=>{o(t),e(t)})}return n}function T(l){const c=t(l);n(()=>{c.current=l});const[a]=r(()=>m()),u=l.session??a,d=o(u.subscribe,u.shown,u.shown),[D,y]=r(null),x=t(null),T=i(()=>{x.current?.(),x.current=null},[]),b=i(()=>{T(),u.end(),y(null)},[u,T]);n(()=>u.subscribe(()=>{u.get()||(T(),y(null))}),[u,T]),n(()=>T,[T]);const k=i((e,t)=>{y(n=>n&&n.key===e&&n.side===t?n:{key:e,side:t})},[]),E=i(e=>{y(t=>t&&t.key===e?null:t)},[]),A=(e,t,n,r)=>!("into"===n?r===e.key:void 0!==e.from&&w(e.from,t))&&c.current.canDrop(e.item,t);return{dragging:d?.item??null,row:(e,t)=>{const{keyOf:n,readOnly:r}=c.current,o=n(e.item),i=!r&&!e.pinned&&!1!==e.canDrag,l=t=>{const n=t.currentTarget.getBoundingClientRect();return v(e,t.clientY,n.top,n.height)},a={draggable:i||void 0,onDragStart:i?t=>{const n=t.currentTarget;u.start({key:o,item:e.item,from:e.place}),t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",o)}catch{}n.classList.add("is-lifting");const r=n.getBoundingClientRect();t.dataTransfer.setDragImage?.(n,t.clientX-r.left,t.clientY-r.top),n.ownerDocument.defaultView?.setTimeout(()=>n.classList.remove("is-lifting"),0);const i=s(n);T(),x.current=i?g(i):null}:void 0,onDragEnd:i?()=>b():void 0,onDragOver:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(o,n.side)):E(o)},onDrop:e=>{const t=u.get();if(!t)return;const n=l(e);A(t,n.to,n.side,o)&&(e.preventDefault(),b(),c.current.onDrop(t.item,n.to))},onKeyDown:t=>{if("ArrowUp"!==t.key&&"ArrowDown"!==t.key)return;if(!t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;if(t.preventDefault(),t.repeat||!i)return;const{onStep:n,canStep:r}=c.current,o="ArrowUp"===t.key?-1:1;n&&!1!==r?.(e.item,o)&&n(e.item,o)}};return{draggable:i,dragging:d?.key===o,drop:D?.key===o?D.side:void 0,rowProps:h(a,t)}},seam:(t,n)=>{const r=(o=t.place,`seam:${e(o)}:${o.index}`);var o;const i={onDragOver:e=>{const n=u.get();n&&(A(n,t.place,"before",r)?(e.preventDefault(),e.dataTransfer.dropEffect=p(e.dataTransfer.effectAllowed),k(r,"before")):E(r))},onDrop:e=>{const n=u.get();n&&A(n,t.place,"before",r)&&(e.preventDefault(),b(),c.current.onDrop(n.item,t.place))}};return{drop:D?.key===r,seamProps:h(i,n)}},rootProps:e=>h({onDragEnter:e=>{if(!u.get()||x.current)return;const t=f(e.currentTarget);x.current=t?g(t):null},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||y(null)}},e)}}export{l as AUTO_SCROLL_EDGE,c as AUTO_SCROLL_MAX_SPEED,u as autoScrollDelta,a as autoScrollSpeed,m as createDragSession,p as dropEffectFor,v as dropOnRow,d as frameScrollBox,y as gapToMoveIndex,w as isNoOpDrop,f as scrollBoxOf,s as scrollParent,g as startAutoScroll,x as stepGap,T as useTreeDrag};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-53ME3GAI.js";import{Inspector as i}from"./chunk-U3LTJSBU.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.every(n=>Object.is(t[n],r[n]))}function m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},O=()=>b,j=()=>"",S=()=>null,w=()=>{},C={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},B={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},I={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
|
|
2
|
+
return f(r,{height:"fill"})}function A(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
|
|
3
|
+
return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var D=l({});function G({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return f(D.Provider,{value:n,children:e})}function T(){return s(D)}function x(){return(T().useOwnerName??j)()}function F(){return(T().useDocumentLabel??S)()}function Y(n,e,t,r){return(T().useBridges??O)(n,e,t,r)}function E(n){return(T().useStandaloneBridges??O)(n)}function M(n,e){(T().useDocumentPass??w)(n,e)}function Q(){return T().blockRules??C}function R(){return T().blockLook??L}function U(){return T().devices??B}function V(){return T().leftView??I}function X(){return T().pinned??N}function H(){return T().saveSwitch??!0}function J(e){n(!0===T().pickFollowsSelection,e)}function K(){return T().storageNamespace||void 0}function W(){return T().styleClipboard??null}function Z(){return T().nodeKeys??!0}function q(){return T().notify??null}function z(){return T().Canvas??P}function $(){return T().CanvasHead??null}function _(){return T().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return T().Inspector??A}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,G as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,R as useScreenBlockLook,Q as useScreenBlockRules,Y as useScreenBridges,_ as useScreenCanvasDrag,z as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,U as useScreenDevices,F as useScreenDocumentLabel,M as useScreenDocumentPass,rn as useScreenInspectorPanel,V as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,x as useScreenOwnerName,T as useScreenParts,J as useScreenPickFollowsSelection,X as useScreenPinned,H as useScreenSaveSwitch,K as useScreenStorageNamespace,W as useScreenStyleClipboard,E as useStandaloneScreenBridges};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-4OMAA45Q.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-S6YOIRXQ.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
|
|
2
2
|
/* @__PURE__ */o("span",{children:e.group}),
|
|
3
3
|
/* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
4
4
|
return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-LUG22U5L.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}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 C,parseZoneKey as E,move as x,duplicate as I,replaceNode as D,createNode as A,insert as O,normalizeData as M,createResolveCache as $,slotsOf as P,resolveNodeData as R,ROOT_SLOT as z}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as L,fieldsFrom as N,drawnBlockCount as j,defaultsFrom as V}from"./chunk-KXM6YRG2.js";import{CANVAS_TYPABLE_EVENT as K,CANVAS_TYPING_EVENT as B}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as T,related as Z,isTypingTarget as F,upsertCanvasStyle as H,removeCanvasStyle as W,WORDS_CLEAR as q,frameRectToHost as U,drawnBox as Y}from"./chunk-FR7EEKFF.js";import{queryAllCopies as Q}from"./chunk-7UFKEX72.js";import{createContext as G,useEffect as X,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,useMemo as oe,useCallback as re,useLayoutEffect as le}from"react";import{jsx as ie,jsxs as se,Fragment as ae}from"react/jsx-runtime";import{createPortal as ce}from"react-dom";import{registerModalEscapeInterceptor as ue,FloatingBar as de,TextToolbar as pe,LinkPicker as fe}from"efficient-shell/ui";function he(e){return!["setData","setUi","set"].includes(e.type)}var me=(e,t,n,o)=>{const r=S(e,t,E(n));return r?.[o]??null},ge=(e,t,n,o,r)=>{const l=me(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ve(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 ye(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 we(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 be(e,t,n){const o=ke(e,t,n);if(o===e)return e;const r=ye(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ke(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 we(e,n,"function"==typeof t.ui?t.ui(ve(e,n)):t.ui);case"set":{const r={data:o,ui:ve(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=we(i,n,l.ui,!0)),i}case"insert":{const r={...E(t.destinationZone),index:t.destinationIndex},l=A(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:O(o,n,r,l)}}case"replace":{const r=ge(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:D(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=ge(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=I(o,n,r.props.id),i=me(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ke(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=me(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...E(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,l)}}case"remove":{const r=ge(o,n,t.zone,t.index,"remove");return{...e,data:C(o,n,r.props.id)}}default:return e}}var Se={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,xe=()=>`history-${Ee+=1}`;function Ie(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:{...Ce}};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:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:xe()}],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:xe()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},k=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},C=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&k(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},E=e=>{const n=c;if(c=be(c,e,t),c===n)return;const o=e.recordHistory??he(e);C(n,o&&c.data!==n.data)},x=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&k(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=e=>{const n=c,o=ye(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},C(n,!1))},A=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{...Se,...i,...n}};let P=O();const z=$(),L={resolveCache:z,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:z,trigger:e,metadata:n}),...l.map(o=>R(o,t,{cache:z,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=b(r,t,i)?.node;s&&s===b(o,t,i)?.node&&(r=D(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:ye(r,t,c.selection)},C(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:z,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(b(c.data,t,e)?.node!==r)return;const o=D(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:ye(o,t,c.selection)},C(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:ve(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:E,history:{back:()=>L.undo(),forward:()=>L.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ve(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&A(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:E,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=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(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:ye(e.data,t,o)},C(n,e.data!==n.data)})},load(e,n={}){const o=c,r=M(e,t);c={...c,data:r,selection:ye(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:xe()}],d=0),c!==o&&w()},undo(){d>0&&A(d-1)},redo(){d<u.length-1&&A(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 L}function De(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&&F(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var Ae=G(null),Oe=G(!0);function Me({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return X(()=>{n&&e.resolveAll()},[e,n]),X(()=>{if(t&&"undefined"!=typeof document)return De(document,e)},[e,t]),/* @__PURE__ */ie(Ae.Provider,{value:e,children:/* @__PURE__ */ie(Oe.Provider,{value:t,children:o})})}function $e(){const e=J(Ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Pe(e){const t=$e(),n=_({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 ee(t.subscribe,o,o)}function Re(){return function(e){return Pe(e)}}var ze=["--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"],Le="host-tokens";function Ne(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of ze){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?H(t,Le,n):W(t,Le)}var je="data-easel-block",Ve="data-easel-dropzone",Ke={},Be="data-es-mirror",Te="undefined"==typeof window?X:le;function Ze(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Be}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Be,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Fe({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=_(null),[p,f]=te(null);return Te(()=>{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]),Te(()=>{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),T(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Ze(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Ze(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Ne(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ne(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */ie("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?ce(e,p):null})}var He=G(null),We=G(Ke),qe=[];function Ue({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=$e(),s=Pe(n=>S(n.appState.data,i.config,{parentId:e,slot:t})??qe),a=Pe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==k),c=Pe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(He),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__ */ie("div",{className:d.join(" "),[Ve]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ie(tt,{node:e},e.props.id))})}function Ye(e,t,n,o){const r=oe(()=>{const n={};for(const o of L(N(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
|
|
2
|
+
return ie(Ue,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=j(n[e],o);return r}function Qe(e){return oe(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return ie(Ue,{parentId:e,slot:t,...n})},[e])}var Ge=["top","bottom","zIndex"];function Xe(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Je(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));Xe(e,"position",t?"sticky":"relative");for(const n of Ge)Xe(e,n,t?.[n]??"");return!!t}var _e="data-es-canvas-relative";function et(e){e.hasAttribute(_e)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(_e));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(_e,"")),!1)}function tt({node:e}){const t=$e().config,n=t.components[e.type],o=e.props.id,r=_(null),l=function(e,t){return oe(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(je),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(je,e),n.setAttribute("data-easel-dnd",e),et(n))},[e,t])}(o,r),i=_(null),s=!!n?.inline;!function(e,t){const n=_(!1),o=_(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=_(()=>{});Te(()=>o.current()),Te(()=>{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?et(e):Je(e));const a=J(We),c=Ye(n,o,e.props,t.components),u=Qe(o);if(!n?.render)return null;const d=n.render,p={...V(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */ie("div",{ref:i,[je]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ie(d,{...p,editor:f,editMode:!0})})}function nt({metadata:e}){const t=Pe(e=>e.config),n=Pe(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ye(t.root,k,n,t.components),l=Qe(k),i=/* @__PURE__ */ie(Ue,{parentId:k,slot:z}),s=o?/* @__PURE__ */ie(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
|
|
5
|
+
return ie(We.Provider,{value:e??Ke,children:s})}var ot=G(void 0),rt=G(void 0);function lt(e,t,n,o){const r=b(e,t,n);return!!r&&(P(r.node,t).length>0||!1===o.whole)}var it=G(void 0),st="data-es-chrome",at=G(void 0);function ct(e){const t=e?.closest?.(`[${st}]`)??null,n=t?.getAttribute(st);return t&&n?{id:n,element:t}:null}function ut({element:e}){const t=_(null),n=ft(t,e?()=>e:null,e);/* @__PURE__ */
|
|
6
|
+
return ie("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var dt={"--es-words-clear":`${q}px`};function pt({element:e,words:t=!1}){const n=_(null),o=ft(n,e?()=>e:null,e);/* @__PURE__ */
|
|
7
|
+
return ie("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...dt}:{display:"none"}})}function ft(e,t,n){return mt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var ht=[];function mt(e,t,n){const[o,r]=te(ht),l=_(t);return l.current=t,Te(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(ht);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=Y(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:ht;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),n.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function gt({id:e,kind:t,overlay:n}){const o=_(null),r=J(rt),l=null!==e&&!0===r?.(e),i=mt(o,e?t=>Q(t,`[${je}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=`es-canvas-outline is-${t}${l?" is-shared":""}`,u=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),d=/* @__PURE__ */se(ae,{children:[
|
|
8
|
+
/* @__PURE__ */ie("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ie("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */ie(n,{componentId:e,kind:t,children:d}):d}function vt(e,n){return Array.from(e.querySelectorAll(`[${je}]`)).find(o=>o.getAttribute(je)===n&&t(o)?.wrapper===e)??null}function yt(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 wt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",y),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=_(null),[m,g]=te(!1),[v,b]=te(null),k=m||null!==v,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},C=()=>{g(!1),b(null),e.resume()};le(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),le(()=>()=>{r.current=null},[r]);const E=_(C);E.current=C,X(()=>{if(m)return ue(e=>{const t=c.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>c.current?.querySelector(".es-copy-colors"))},[m]),X(()=>{const n=c.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;g(!1),b(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[k,e,t]),le(()=>{const e=c.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?U(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},f=o.getBoundingClientRect(),h=s?U(s,{left:f.left,top:f.top,width:f.width,height:f.height}):{left:f.left,top:f.top,width:f.width,height:f.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,h.top-6,m.top),bottom:Math.max(a.top+a.height,h.top+h.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.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:y.left,top:y.top,right:y.right,bottom:y.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 x=a?{run:f(i.color,a),open:m,onToggle:()=>{b(null),m?C():(e.hold(),g(!0))}}:void 0;/* @__PURE__ */
|
|
9
|
+
return ie(de,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?U(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__ */ie("div",{ref:c,children:/* @__PURE__ */ie(pe,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:x,linkOpen:null!==v,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */se(ae,{children:[m&&a?/* @__PURE__ */ie(h,{colors:a,current:i.color,words:l.colors??y.colors,onPick:t=>e.color(t)}):null,v?
|
|
10
|
+
/* @__PURE__ */ie(fe,{className:"es-copy-link es-copy-pop",value:v.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==v.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function bt({element:e,which:t}){const n=_(null),o=ft(n,()=>e(),t);/* @__PURE__ */
|
|
11
|
+
return ie("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,...dt}:{display:"none"}})}function kt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:k,overlay:S,children:C,typing:E,passThrough:x}){const I=$e(),D=J(ot),A=x??D,O=J(Oe),M=w("canvas",n),$=y??O,[R,z]=te(void 0),L=Pe(e=>"node"===e.selection?.kind?e.selection.id:null),[N,j]=te(null),[V,T]=te(null),F=J(it),H=J(at),[W,q]=te(null),[,U]=ne(e=>e+1,0),[,Y]=ne(e=>e+1,0),Q=e=>{F?.select(e),Y()},[G,ee]=te(null),oe=_(null),re=_(null),[,le]=te(0),ae=_(E);ae.current=E;const ce=_(null),ue=_(null),de=()=>{if(!L)return null;const e=ae.current?.atSelection?.()?.element()??null;if(!e)return null;const t=ue.current?.ownerDocument;if(F){const n=F.selected()&&t?F.selectedPart?.(t)??null:null;return n&&Z(n.element,e)?n.element:null}const n=b(I.getState().appState.data,I.config,L);return n&&0===P(n.node,I.config).length?e:null},pe=Pe(e=>e.appState.data),fe=F?.selected()??null;X(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=L&&!G&&ae.current?.atSelection?.()?L:null,o=n?de():null;e.dispatchEvent(new t(K,{detail:o?{id:n,words:o}:{id:n}}))},[L,G,pe,fe]);const he=e=>{const t=ue.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(B,{detail:{typing:e}}))},me=(e,t)=>{oe.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=I.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:yt(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>ce.current?.escape()??!1,onLinkKey:()=>ce.current?.link()??!1,end:e=>{r.close(),oe.current?.element===l&&(oe.current=null),ee(null),he(!1),ae.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${je}]`)?.getAttribute(je);return s&&I.select(s),oe.current={s:i,element:l,target:e},ee(()=>l),j(null),he(!0),ae.current?.onChange?.({typing:!0,element:n}),!0},ge=(e,n)=>{const o=e.key;if(!o||!ae.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${je}]`),i=l?.getAttribute(je);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=ae.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(v(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=ae.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};X(()=>()=>oe.current?.s.stop("stop"),[]);const ve=e=>{const t=oe.current?.element();return Boolean(t&&t.contains(e))},ye=(e,t)=>lt(I.getState().appState.data,I.config,e,t),we=e=>{const t=e.closest?.(`[${je}]`)?.getAttribute(je);if(!t)return;const n=I.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,I.config,t,r.id,o,F?.selected()??null,A);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,I.config,t,o,A)??t,part:null}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(oe.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=ke(),o=void 0===n?ae.current?.atSelection?.():n;o&&me(o,null)&&e.preventDefault()},ke=()=>{const t=ae.current,n=re.current;if(!t?.onCopyText||!n?.copy||n.node!==L)return;const o=ue.current,r=o?e(o,n.copy):null,l=r?vt(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(`[${je}]`);if(!n||n.getAttribute(je)!==t.getAttribute(je))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},Se=(e,n)=>{if(!ae.current?.onCopyText)return null;const o=t(e);return o&&vt(o.wrapper,n)?o.copy:null},Ce=ue.current?.ownerDocument??null,Ee=F?.selected()&&Ce&&L?F.selectedPart?.(Ce)??null:null,xe=Ee&&L&&ye(L,Ee)?Ee.element:null,Ie=H?.selected()??null,Ae=Ie&&Ce?Array.from(Ce.querySelectorAll(`[${st}]`)).find(e=>e.getAttribute(st)===Ie)??null:null,Me=G?null:de(),Re=/* @__PURE__ */se("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),oe.current){if(ve(t))return;oe.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?ct(t):null;if(H&&o)return H.select(o.id),q(null),void U();const r=we(t);if(re.current=void 0!==r?{node:r.node,copy:Se(t,r.node)}:null,void 0!==r)return I.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&Q(r.part?.id??null));t.hasAttribute?.(Ve)||(I.select(null),F?.selected()&&Q(null))},onDoubleClick:e=>{const t=ae.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&me(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>be(e),onMouseOver:e=>{if(oe.current)return;const t=H?ct(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==N&&j(null),void(null!==V&&T(null));const n=we(e.target),o=!!n?.part&&ye(n.node,n.part),r=n?.part&&o&&n.part.id!==F?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==N&&j(l),r?.id===V?.id&&r?.element===V?.element||T(r)},onMouseLeave:()=>{j(null),T(null),q(null)},children:[
|
|
12
|
+
/* @__PURE__ */ie(He.Provider,{value:N,children:/* @__PURE__ */ie(nt,{metadata:i})}),
|
|
13
|
+
/* @__PURE__ */se("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
14
|
+
/* @__PURE__ */ie(gt,{id:!G&&N&&N!==L?N:null,kind:"hover",overlay:S}),F?/* @__PURE__ */ie(ut,{element:G||!V||V.id===F.selected()?null:V.element}):null,Me||xe?/* @__PURE__ */ie(pt,{element:G?null:Me??xe,words:null!==Me}):null,H?/* @__PURE__ */ie(ut,{element:G||!W||W.element===Ae?null:W.element}):null,Ae?/* @__PURE__ */ie(pt,{element:G?null:Ae}):null,
|
|
15
|
+
/* @__PURE__ */ie(gt,{id:G||xe||Me||Ae?null:L,kind:"selected",overlay:S}),G?/* @__PURE__ */ie(bt,{element:()=>{const e=G?.()??null;return e?Ee&&Z(Ee.element,e)?Ee.element:e:null},which:Ee?.element??G}):null]}),C]}),ze=k?/* @__PURE__ */ie(k,{document:R,children:Re}):Re;X(()=>{if(R&&$)return De(R,I)},[R,$,I]),X(()=>{if(!R)return;const e=e=>{if("Enter"===e.key)return void be(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=I.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void Q(null);const o=s(n.appState.data,I.config,n.selection);"node"===o?.kind&&I.select(o.id)};return R.addEventListener("keydown",e),()=>R.removeEventListener("keydown",e)},[R,I,F]);/* @__PURE__ */
|
|
16
|
+
return se("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":G?"":void 0,children:[G&&oe.current?.target.toolbar?/* @__PURE__ */ie(wt,{s:oe.current.s,element:oe.current.element,toolbar:oe.current.target.toolbar,label:M.textTools,keys:ce}):null,o?/* @__PURE__ */ie(Fe,{mirrorStyles:u,onDocument:e=>{z(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:ze}):/* @__PURE__ */ie("div",{id:"preview-frame","data-easel-entry":"",children:ze})]})}function St(e={}){const t=$e(),n=Pe(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ct(){return It(Pe(e=>e.selectedItem))}function Et(){try{return Ct()}catch{return null}}function xt(){return It(null)}function It(e){const t=$e(),n=Pe(e=>e.config),r=t.resolveCache,l=Pe(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=oe(()=>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=Pe(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=re(e=>{(async()=>{const o=t.getState();if("root"!==i){const l=o.getItemById(i),s=o.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...e}},{node:c}=await R(a,n,{cache:r,trigger:"replace"}),u=t.getState().getSelectorForId(i);if(!u)return;return void t.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const l=o.appState.data.root.props??{},{node:s}=await R({type:"root",props:{...l,...e}},n,{cache:r,trigger:"replace"});t.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[t,n,r,i]),v=re((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{st as CHROME_ATTR,at as CanvasChromeContext,Fe as CanvasFrame,it as CanvasPartsContext,ot as CanvasPassThroughContext,rt as CanvasSharedContext,Ce as DEFAULT_UI,kt as EaselCanvas,Me as EaselProvider,nt as EditDocument,De as bindUndoKeys,Ie as createEasel,Re as createUseEasel,lt as partHasOwnBox,he as recordsByDefault,be as reduce,ve as uiView,Pe as useEasel,$e as useEaselApi,St as useEaselNodeOps,xt as useRootFields,Ct as useSelectedFields,Et as useSelectedHost,ye as validSelection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenDocument as n}from"./chunk-
|
|
1
|
+
import{useScreenDocument as n}from"./chunk-ERB6FAZT.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-S6YOIRXQ.js";import{EditNotice as r}from"./chunk-VBEVZZTV.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessForNewDocument as e}from"./chunk-
|
|
1
|
+
import{accessForNewDocument as e}from"./chunk-YYD257TD.js";function n(e){return e.failed?"error":e.pending?"saving":e.saved?"saved":"idle"}function t(e){return"idle"}function r(n,t){t.resetAutosave(),t.setVersion(null),t.setSaveConflict(null),t.setAccess(e(n))}export{r as resetForDocumentSwitch,t as saveStatusForNewDocument,n as saveStatusOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_PANEL_W as s,clampPanelWidth as e}from"./chunk-
|
|
1
|
+
import{DEFAULT_PANEL_W as s,clampPanelWidth as e}from"./chunk-VBEVZZTV.js";var a="sf-editor-panel-widths",l="sf-editor-collapsed-sections";function t(s){return s?{panelWidths:`${s}-panel-widths`,collapsed:`${s}-collapsed-sections`}:{panelWidths:a,collapsed:l}}var o={...s},d=(s,a)=>e(s,a);export{l as COLLAPSED_SECTIONS_KEY,o as DEFAULT_PANEL_W,a as PANEL_WIDTHS_KEY,d as clampPanelWidth,t as screenStorageKeys};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t="data-sf-repeat",e="data-sf-repeat-index",n=`[${t}][${e}]:not([${e}="0"])`;function r(t){return null!==t.closest(n)}function u(t){let e=null;for(const n of t){if(!r(n))return n;e??=n}return e}function l(t,e){return u(t.querySelectorAll(e))}function o(t,e){const n=[...t.querySelectorAll(e)],l=u(n);return l?[l,...n.filter(t=>t!==l&&r(t))]:[]}function c(n){const r=n.closest(`[${t}][${e}]`);if(!r)return null;const u=r.getAttribute(e)??"";return/^\d+$/.test(u)?{wrapper:r,zone:r.getAttribute(t)??"",index:Number(u)}:null}export{t as REPEAT_ATTRIBUTE,e as REPEAT_INDEX_ATTRIBUTE,r as isRepeatCopy,u as mainCopyOf,o as queryAllCopies,l as queryMainCopy,c as repeatWrapperAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={title:({name:e})=>`Duplicate “${e}”`,submit:"Duplicate page",titleLabel:"Title",slugLabel:"URL handle",hint:"The copy is a draft and stays hidden until you publish it. It opens in the editor.",address:({host:e,slug:t})=>`${e}/${t}`,clash:"Another page uses this URL handle.",failed:"Couldn’t duplicate the page. Try again."};export{e as DEFAULT_PAGE_COPY_WORDS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{clone as e}from"./chunk-EUFDQ4KL.js";import{CopyStyleIcon as n,PasteStyleIcon as o}from"efficient-shell/icons/efficient";import{jsx as r}from"react/jsx-runtime";var c="__styleKind";function u(t,e){return t[c]=e,t}function i(t,e){return`${t}:${e.map(t=>String(t)).sort().join("|")}`}function s(t){if(!t)return null;const e=t.indexOf(":");if(e<0)return null;const n=t.slice(0,e);return l.has(n)?{control:n,values:t.slice(e+1).split("|")}:null}var l=/* @__PURE__ */new Set(["choice","select","radio"]);function a(t){if(!t||"object"!=typeof t)return null;const e=t;return"string"==typeof e[c]?e[c]:"text"===e.type||"textarea"===e.type||"number"===e.type?e.type:"select"!==e.type&&"radio"!==e.type||!Array.isArray(e.options)?null:i(e.type,e.options.map(t=>t?.value))}function p(t){return null!=t&&""!==t}function f(t,e){let n=t;for(const t of e){if(!n||"object"!=typeof n)return;n=n[t]}return n}function d(t,e,n){const[o,...r]=e,c={...t};if(0===r.length)return void 0===n?delete c[o]:c[o]=n,c;const u=c[o],i=d(u&&"object"==typeof u?u:{},r,n);return 0===Object.keys(i).length?delete c[o]:c[o]=i,c}var y=t=>t.join("."),h="editor-shell:style-clipboard",m=null,g=!1,v=/* @__PURE__ */new Set;function b(){try{return"undefined"==typeof sessionStorage?null:sessionStorage}catch{return null}}function k(){if(!g){g=!0;try{const t=b()?.getItem(h);t&&(m=JSON.parse(t))}catch{m=null}}}function S(t){k(),m={scope:t.scope,sourceType:t.type,sourceLabel:t.label,rows:t.rows.map(n=>{const o=f(t.props,n.path);return{path:[...n.path],kind:n.kind,counted:!1!==n.counted,value:p(o)?e(o):void 0}})};try{b()?.setItem(h,JSON.stringify(m))}catch{}return v.forEach(t=>t()),m}function j(t){return k(),m&&m.scope===t?m:null}function C(t){return v.add(t),()=>{v.delete(t)}}function w(){m=null,g=!0;try{b()?.removeItem(h)}catch{}v.forEach(t=>t())}function E(t,e,n){if(t.kind===e.kind)return null!==e.kind||n;const o=s(t.kind),r=s(e.kind);return!(!o||!r||o.control!==r.control)&&(!p(t.value)||r.values.includes(String(t.value)))}function K(t,n){const o=t.sourceType===n.type,r=new Map(t.rows.map(t=>[y(t.path),t]));let c=n.props,u=0,i=!1;for(const t of n.rows){const n=r.get(y(t.path));if(!n)continue;if(!E(n,t,o))continue;const s=f(c,t.path),l=void 0===n.value?void 0:e(n.value);JSON.stringify(p(s)?s:void 0)!==JSON.stringify(l)&&(c=d(c,t.path,l),i=!0),!1!==t.counted&&(u+=1)}return{props:c,pasted:u,changed:i}}function N(e,n,o,r=t){return 0===e.pasted?r.nothing({source:n,target:o}):r.pasted({count:e.pasted,source:n})}var O="⌥⌘C",T="⌥⌘V";function x(e){const c=e.words??t,u=[];return e.canCopy&&u.push({label:c.copy,icon:/* @__PURE__ */r(n,{}),shortcut:"⌥⌘C",onClick:e.onCopy}),e.held&&u.push({label:c.paste({source:e.held.sourceLabel}),icon:/* @__PURE__ */r(o,{}),shortcut:"⌥⌘V",onClick:e.onPaste}),u}function J(t){if(!t.altKey||t.shiftKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.target;return e&&(e.isContentEditable||"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName)?null:"KeyC"===t.code?"copy":"KeyV"===t.code?"paste":null}export{O as COPY_STYLE_SHORTCUT,T as PASTE_STYLE_SHORTCUT,c as STYLE_KIND,i as choiceKind,w as clearStyle,S as copyStyle,a as fieldKind,j as heldStyle,N as pasteMessage,K as planPaste,x as styleMenuItems,J as styleShortcut,C as subscribeStyle,u as withStyleKind};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Segmented as e,Tooltip as s}from"efficient-shell/ui";import{jsx as a,jsxs as i}from"react/jsx-runtime";function l({options:l,value:n,onChange:t,ariaLabel:r,fit:d,disabled:o=!1,className:c}){const m=d&&function(e,s){return{"--es-fit-count":e,"--es-fit-labels":`${s.labelsPx}px`,"--es-fit-widest":`${s.widestLabelPx}px`}}(l.length,d),b=l.findIndex(e=>e.id===n);
|
|
2
|
+
/* @__PURE__ */
|
|
3
|
+
return a("div",{className:"es-segs-fit","data-disabled":o||void 0,style:m,children:/* @__PURE__ */a(e,{size:"sm",label:r,className:`es-segs${m?" is-measured":""}${c?` ${c}`:""}`,value:b<0?"":String(b),onChange:e=>t(l[Number(e)].id),options:l.map((e,l)=>{const n=e.title??("string"==typeof e.label?e.label:void 0),t="string"!=typeof e.label,r=i=>n&&(e.icon||t)?/* @__PURE__ */a(s,{content:n,children:i}):i;return{value:String(l),disabled:o||!0===e.disabled,icon:e.icon?r(
|
|
4
|
+
/* @__PURE__ */a("span",{className:"es-seg-icon","aria-hidden":"true",children:e.icon})):void 0,label:t?/* @__PURE__ */i("span",{className:"es-seg-word es-seg-drawn",children:[r(
|
|
5
|
+
/* @__PURE__ */a("span",{className:"es-seg-mark","aria-hidden":"true",children:e.label})),
|
|
6
|
+
/* @__PURE__ */a("span",{className:"es-vh",children:n})]}):/* @__PURE__ */a("span",{className:"es-seg-word",children:e.label})}})})})}export{l as SettingsSegmented};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-S6YOIRXQ.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as b,CLAIM_FAIL_OPEN_MS as S,holderOf as I}from"./chunk-YYD257TD.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as E,useMemo as B,useCallback as T,useEffect as A,useRef as C}from"react";import{jsx as H}from"react/jsx-runtime";var L={content:[],root:{},zones:{}};var O=j(null);function D(){const e=R(O);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function N({target:j,addressing:R=o,onHostMessage:D,children:N}){const Y=R,{homeSlug:F,entryMayBounce:M,entryBounce:W,onSwitch:K,tellsHost:U,adapterFor:V,migrateRenamedProps:X,describeMissing:G,onLoadFailed:Q}=Y,[x,Z]=E(j),z=k(),J=d(),_=B(()=>f(J),[J]),q=B(()=>t(J),[J]),$="template"===x.kind,ee="template"===x.kind?x.id:null,re="template"===x.kind?x.pageSlug??F??"":"document"===x.kind?x.slug??"":x.slug,ne="page"===x.kind?x.siteId??null:null,te=J.blocks,oe=B(()=>V(x,_,te),[V,_,te,x.kind,"template"===x.kind?x.id:"document"===x.kind?x.record:x.siteId]),ue=oe.capabilities,ae=T(e=>J.documentHooks?.stored?.(e)??e,[J]);A(()=>{m(J,ne)},[J,ne]);const se=C(x);A(()=>{se.current=x},[x]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(D?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Er(e.target)}}}),de=!J.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=E(null),[ge,pe]=E(null),[he,ye]=E(null),[we,be]=E(null),Se=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,Se):null,[Pe,je]=E(null),Re=C(null),Ee=C(null),[Be,Te]=E(!1),Ae=C(null),[Ce,He]=E(null),Le=C(null),[Oe,De]=E(null),[Ne,Ye]=E(!1),Fe=C(null);A(()=>{Fe.current=Oe},[Oe]);const[Me,We]=E(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ke=C(Me);A(()=>{Ke.current=Me},[Me]);const Ue=C(()=>Promise.resolve(!1)),Ve=T(e=>{Ee.current=e,Te(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(p(Ke.current)){if(!await Ue.current(e,r)){if(!p(Ke.current))return void Ve({id:e,data:r});throw new Error("page save did not land")}}else Ve({id:e,data:r})},onFailure:(e,r)=>{0===r&&z.send("storefront-editor:save-failed")}}),{state:Ge,push:Qe,flush:xe,pause:Ze,resume:ze,stop:Je,reset:_e,retryNow:qe,hasPending:$e}=Xe,er=C(Ge);A(()=>{er.current=Ge},[Ge]);const rr=u(Ge),nr=T(()=>{const e=Ee.current;e&&(Ee.current=null,Te(!1),Qe(e))},[Qe]),tr=C("");tr.current||(tr.current=h());const[or,ur]=E(0),ar=C(!1),[sr,ir]=E(M(j)),lr=C(!1);A(()=>{if(lr.current)return;lr.current=!0;const e=z.address.search(),r=W(j,e);r?z.address.load(r):M(j)&&ir(!1)},[j,z]);const cr=z.send;A(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=J.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void z.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:G?.(t)??null}),void Q?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Le.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:L,s=X(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},J),cause:r(o,J)}),Q?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=T(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=T(async e=>{const r=le.current;if(!r&&J.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,J)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,J]),mr=T(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=T(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ke.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Le.current,tr.current));if(t.ok)return Le.current=t.value.version??Le.current,Ye(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ke.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Le.current=n.value,Ue.current(e,r,!0)}Je(),Fe.current=u,De(u)}return Ye(i(t.error,J)?.status===c),!1},[oe,fr,Je,J]);A(()=>{Ue.current=kr},[kr]);const vr=T(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ae.current=r,p(Ke.current)?Qe({id:ke,data:r}):Ve({id:ke,data:r})},[ke,cr,Ve,Qe,ae]),gr=T(async()=>{p(Ke.current)&&nr();return await xe()&&null==Ee.current},[nr,xe]),pr=C(gr);A(()=>{pr.current=gr},[gr]);const hr=C(fr);A(()=>{hr.current=fr},[fr]);const yr=T(()=>{z.address.reload()},[z]),wr=C(()=>Promise.resolve(!1));A(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Le.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const br=null!==Pe;A(()=>{if(!fe||!ke||!de||br)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ke.current,heldWrite:()=>({pending:null!=Ee.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ke.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(b)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,br]);const Sr=T(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=T(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=T(()=>{er.current.paused?(p(Ke.current)&&nr(),ze()):Ze()},[nr,Ze,ze]),jr=T(()=>{qe()},[qe]),Rr=T(e=>{Ae.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Ee.current=null,Te(!1)},setVersion:e=>{Le.current=e},setSaveConflict:De,setAccess:We}),K(e),Z(e),Re.current=null,je(null),ve(null),pe(null),ye(null),be(null),z.address.show(e),"document"!==e.kind&&U(e)&&z.send("storefront-editor:navigated",{target:e})},[_e,z,me,K,U]),Er=T(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Ee.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?He(e):xe().then(r=>{r?Rr(e):He(e)})},[Rr,$e,xe,F]),Br=T(()=>He(null),[]),Tr=T(()=>{He(e=>(e&&Rr(e),null))},[Rr]),Ar=T(async()=>{const e=Ce;if(!e)return;await gr()&&(He(null),Rr(e))},[Ce,gr,Rr]),Cr=T(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ke.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Le.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Le.current=t.value.version??Le.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
|
|
2
|
+
return H(O.Provider,{value:{target:x,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ae.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ge,autoSaveEnabled:!Ge.paused,autoSaveStoppedByConflict:Ge.stopped,hasUnsavedEdits:Ge.pending||Be,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Cr,access:Me,readOnly:null!==I(Me)||null!==Pe||null!==Oe,readOnlyReason:Pe,takeOverEditing:Sr,viewReadOnly:Ir,saveConflict:Oe,saveUnreachable:Ne,reloadFromServer:yr,navigate:Er,pendingNav:Ce,cancelPendingNav:Br,discardAndNavigate:Tr,saveAndNavigate:Ar},children:N})}export{O as ScreenDocumentContext,N as ScreenDocumentProvider,D as useScreenDocument};
|