efficient-easel 10.0.0 → 10.2.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.
Files changed (44) hide show
  1. package/README.md +6 -0
  2. package/dist/canvas-typing-CJodefPO.d.ts +478 -0
  3. package/dist/{chunk-OWW44DVK.js → chunk-74ZFATLG.js} +1 -1
  4. package/dist/{chunk-LGDQLTJW.js → chunk-7O6MDCDU.js} +3 -3
  5. package/dist/{chunk-U5RF4USK.js → chunk-A5OEGP7B.js} +4 -4
  6. package/dist/{chunk-K2YSFVOJ.js → chunk-ERA3XM2U.js} +1 -1
  7. package/dist/{chunk-BPLCMQ6S.js → chunk-FJ3ZJJ5Z.js} +45 -45
  8. package/dist/chunk-ICN6COBK.js +5 -0
  9. package/dist/{chunk-WQASXLXS.js → chunk-IL6QCPO6.js} +1 -1
  10. package/dist/{chunk-GKGBKSZ7.js → chunk-IZ2QRXSE.js} +1 -1
  11. package/dist/{chunk-XF2AIO46.js → chunk-JSPZU7X2.js} +1 -1
  12. package/dist/{chunk-K5744MTM.js → chunk-M32O2WRM.js} +10 -10
  13. package/dist/{chunk-M6F6LS3H.js → chunk-OGH6CC3E.js} +1 -1
  14. package/dist/{chunk-XO7OUCZV.js → chunk-OWK7DGWG.js} +1 -1
  15. package/dist/{chunk-4CE7XFCE.js → chunk-TROOTMAD.js} +1 -1
  16. package/dist/{chunk-2AKW6UXX.js → chunk-YMEN4KVE.js} +1 -1
  17. package/dist/copy/index.d.ts +20 -399
  18. package/dist/copy/index.js +17 -15
  19. package/dist/easel/index.d.ts +19 -2
  20. package/dist/easel/index.js +1 -1
  21. package/dist/fields/index.d.ts +2 -2
  22. package/dist/screen/components/AddBlockRow.js +1 -1
  23. package/dist/screen/components/AddSidePanel.js +1 -1
  24. package/dist/screen/components/MediaSidePanel.js +1 -1
  25. package/dist/screen/components/ScreenChrome.js +1 -1
  26. package/dist/screen/components/ScreenMount.js +1 -1
  27. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  28. package/dist/screen/components/SectionScreenShell.js +15 -15
  29. package/dist/screen/components/usePartBridge.js +1 -1
  30. package/dist/screen/index.js +1 -1
  31. package/dist/screen/lib/key-scope.js +1 -1
  32. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  33. package/dist/screen/lib/screen-parts.js +1 -1
  34. package/dist/strings/catalogue.d.ts +1 -1
  35. package/dist/strings/catalogue.js +1 -1
  36. package/dist/strings/index.d.ts +1 -1
  37. package/dist/strings/index.js +1 -1
  38. package/dist/text-styles/index.d.ts +3 -3
  39. package/dist/text-styles/index.js +33 -33
  40. package/dist/{types-C97TAUKi.d.ts → types-Dkx1VAIQ.d.ts} +1 -1
  41. package/dist/{words-CRYvAiHX.d.ts → words-gIDCeRv3.d.ts} +1 -0
  42. package/package.json +1 -1
  43. package/dist/canvas-typing-Cnvlsh_V.d.ts +0 -69
  44. package/dist/chunk-XTDBTCVO.js +0 -5
package/README.md CHANGED
@@ -453,6 +453,12 @@ import 'efficient-easel/copy.css';
453
453
  An empty value (`''`, or `undefined` for Italic) follows the style. Pressing
454
454
  the answer that is already pressed goes back to the style.
455
455
 
456
+ Since 10.2.0: `readOnly` shows every row disabled and writes nothing;
457
+ `keptHint` is one line under the kept box; and with no `font`, `italic` is a
458
+ row of its own named Italic, where the Font row stands (a phone view, which has
459
+ no font of its own). Capitalization's Capitalized is also a text style's
460
+ `letterCase: 'capitalize'` in `efficient-easel/text-styles`.
461
+
456
462
  ## Copy style, paste style — one rule for both editors
457
463
 
458
464
  `efficient-easel/style-clipboard` (added in 0.50.0) is the right-click menu's
@@ -0,0 +1,478 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { MarkStyle, MarkupTool, WrapResult, InlineRule } from './markup/index.js';
4
+ import { C as CopyWords, a as CopyAlign } from './words-dsex49Jh.js';
5
+ import { TextToolbarCase, TextToolbarMark } from 'efficient-shell/ui';
6
+
7
+ type CellWords = NonNullable<CopyWords['cells']>;
8
+ interface CopyCell {
9
+ /** Which cell this is — a stable key for the grid. */
10
+ key: string;
11
+ /** The cell's name, from the copy words (the four the design draws)… */
12
+ nameKey?: Exclude<keyof CellWords, 'tip'>;
13
+ /** …or the host's own (a cell the package does not know). */
14
+ name?: string;
15
+ icon?: ReactNode;
16
+ unit?: string;
17
+ /** What an arrow or ↑↓ moves by, in SHOWN units. */
18
+ step?: number;
19
+ /** What Shift moves by. Default ten steps. */
20
+ shiftStep?: number;
21
+ /** Bounds, in SHOWN units. */
22
+ min?: number;
23
+ max?: number;
24
+ /** Shown = stored × scale (100 for a multiple shown in %). Default 1. */
25
+ scale?: number;
26
+ /** The STORED value, or `undefined` while the cell follows the style. */
27
+ value: number | undefined;
28
+ /** The style's STORED value, shown grey while the cell is empty. */
29
+ styleValue?: number;
30
+ /** A STORED value, or `undefined` when the cell is emptied. */
31
+ onChange: (value: number | undefined) => void;
32
+ }
33
+ /** A cell's preset: everything but its value and its write. */
34
+ type CopyCellPreset = Omit<CopyCell, 'value' | 'styleValue' | 'onChange'>;
35
+ /** The four cells the final design draws, with its steps and ranges
36
+ * (the campaign page's "三个框的规则" table, read 2026-10-06). */
37
+ declare const COPY_CELLS: {
38
+ fontSize: CopyCellPreset;
39
+ lineHeight: CopyCellPreset;
40
+ letterSpacing: CopyCellPreset;
41
+ paragraphSpacing: CopyCellPreset;
42
+ };
43
+ declare function CopyCells({ cells, words, readOnly }: {
44
+ cells: readonly CopyCell[];
45
+ words?: CellWords;
46
+ readOnly?: boolean;
47
+ }): react.JSX.Element;
48
+
49
+ interface CopyThemeColor {
50
+ name: string;
51
+ label: string;
52
+ value: string;
53
+ }
54
+ declare function ColorWindow({ colors, current, words, onPick, }: {
55
+ colors: readonly CopyThemeColor[];
56
+ /** The colour the selection wears — a theme name or a hex — or null. */
57
+ current: string | null;
58
+ words: NonNullable<CopyWords['colors']>;
59
+ /** A theme name, a lowercase `#rrggbb`, or null to take the colour off. */
60
+ onPick: (color: string | null) => void;
61
+ }): react.JSX.Element;
62
+
63
+ /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
64
+ * shortcut. Meta is what the tooltips promise (⌘); Ctrl works too. */
65
+ declare function ariaShortcut(shortcut: string | undefined): string | undefined;
66
+ interface MarkBarProps {
67
+ /**
68
+ * Which buttons to show.
69
+ *
70
+ * TWO FORMS, and the second is not a convenience — it is the only way a
71
+ * product with marks of its OWN can use this bar at all.
72
+ *
73
+ * `MarkStyle[]` resolved against the shared grammar's `MARKUP_TOOLS`, in
74
+ * that order. What the campaign designer passes.
75
+ * `MarkupTool[]` used verbatim. What `efficient-storefront` passes.
76
+ *
77
+ * ⚠️ WHY VERBATIM DESCRIPTORS HAD TO EXIST. The storefront offered SEVEN
78
+ * marks: the grammar's four, plus its three word styles (`@@`, `++`, `^^`),
79
+ * which then lived only in the shop because the grammar was
80
+ * `efficient-shell/markup`. Resolving through `markupTools` can only ever
81
+ * return marks the grammar knows, so it silently DROPPED all three — the bar
82
+ * rendered four buttons where the panel had seven, and nothing failed to
83
+ * compile. Since 2026-09-28 the grammar is ours and holds Quiet (`^^`) and
84
+ * reads `@@` / `++` as Emphasis and Strong, but a host may still hand in
85
+ * marks of its own.
86
+ *
87
+ * So a host that has its own marks builds its own descriptors (the shop
88
+ * already did: `shopMarkupTools()`) and hands them over whole. The bar's job
89
+ * is the ROW — the buttons, the focus guard, the naming, the group — and that
90
+ * job does not depend on who defined the mark.
91
+ */
92
+ tools: readonly MarkStyle[] | readonly MarkupTool[];
93
+ onApply: (style: MarkStyle) => void;
94
+ disabled?: boolean;
95
+ /** Buttons that write no mark, after a divider — see `CopyBoxProps.actions`. */
96
+ actions?: ReactNode;
97
+ /** The alignment strip, already built by the control. */
98
+ align?: ReactNode;
99
+ /**
100
+ * WHAT A BUTTON IS DRAWN AS, per style. Default: the grammar's own letter —
101
+ * `B`, `I`, `S`, `◆` — which is what the campaign designer has always shown.
102
+ *
103
+ * ⚠️ THIS IS NOT A THEME KNOB, AND IT IS NOT OPTIONAL POLISH. This package
104
+ * already says that WHICH buttons and WHAT they write are the grammar's, while
105
+ * how they LOOK is the host's, "because this bar has to belong to the
106
+ * storefront inspector's chrome and the campaign designer's bar has to belong
107
+ * to the portal's". Colour was delegated by tokens on day one; the DRAWING was
108
+ * not, and a letter is a drawing. `efficient-storefront` renders each mark as a 14px
109
+ * stroked SVG at the weight of its other inspector glyphs, on the stated
110
+ * ground that the row should read "as part of the field rather than as
111
+ * pasted-in icons" — so without this it could not adopt the bar without losing
112
+ * that, which is a regression dressed as a refactor.
113
+ *
114
+ * The set now HAS a glyph for every mark (0.94.0: bold, italic, strike,
115
+ * emphasis, quiet, clear-marks — the owner's call, made 2026-10-02), and they
116
+ * are the default. This map stays so a host can still draw its own.
117
+ *
118
+ * A style the map does not name falls back to the icon set's glyph for it
119
+ * (`SET_GLYPH`, 0.94.0, when the owner added the mark glyphs to the set) and
120
+ * then to the letter, so a host may override one button and leave the rest.
121
+ */
122
+ glyphs?: Partial<Record<MarkStyle, ReactNode>>;
123
+ /**
124
+ * What the group is CALLED. Defaults to "Formatting" (`EaselStrings.copy.formatting`).
125
+ *
126
+ * A bar bound to one box needs nothing more. A bar SHARED by several rows has
127
+ * to say which row it is aimed at, because the visible cue — the marked row —
128
+ * is not readable. `efficient-storefront` has that case today.
129
+ */
130
+ ariaLabel?: string;
131
+ /**
132
+ * The marks the selection already wears — a button drawn pressed is one
133
+ * whose press takes the mark OFF (`markedAt`, the same test `applyMark`
134
+ * unwraps by), so the two cannot disagree. A style not named is not pressed;
135
+ * with no map at all no button says either way (`aria-pressed` is left off),
136
+ * which is what every host that does not track the selection still gets.
137
+ */
138
+ pressed?: Partial<Record<MarkStyle, boolean>>;
139
+ /** The style whose own window is open — the link button while its "Link
140
+ * to" window is showing. Drawn pressed, and named as expanded. */
141
+ open?: MarkStyle | null;
142
+ }
143
+ declare function MarkBar({ tools, onApply, disabled, actions, align, glyphs, ariaLabel, pressed, open, }: MarkBarProps): react.JSX.Element | null;
144
+
145
+ /**
146
+ * Just enough of a text control to read a selection off it. Narrowed to these
147
+ * two fields so a caller may hand in a plain object in a test.
148
+ *
149
+ * A `<textarea>` OR an `<input>` (blueprint 4.9). An input's selection is
150
+ * `number | null` where a textarea's is `number`, so the type had to be the
151
+ * wider of the two: typed to the textarea, every one-line row in the website
152
+ * editor needed a cast or a copy of this file, and the shop kept a copy.
153
+ */
154
+ type SelectionSource = {
155
+ readonly selectionStart: number | null;
156
+ readonly selectionEnd: number | null;
157
+ } | null;
158
+ /**
159
+ * How a mark is written. Defaults to the shared grammar's own `applyMark`.
160
+ *
161
+ * INJECTED RATHER THAN ASSUMED, because the storefront legitimately writes marks
162
+ * the shell's grammar does not know: its three word styles (`@@`, `++`, `^^`)
163
+ * go through `applyShopMark`, which delegates here for everything else. Making
164
+ * the writer a parameter is what lets one control serve both products without
165
+ * this package learning a vocabulary that belongs to one of them.
166
+ */
167
+ type MarkWriter = (text: string, start: number, end: number, style: MarkStyle) => WrapResult;
168
+ /** Apply a style to whatever the field has selected. */
169
+ declare function markSelection(value: string, style: MarkStyle, el: SelectionSource, write?: MarkWriter): WrapResult;
170
+ /**
171
+ * Put a literal string where the caret is.
172
+ *
173
+ * The caret lands AFTER the inserted text and selects nothing, because the thing
174
+ * inserted is finished — a merge tag is not a placeholder to type over, and
175
+ * leaving it selected invites the next keystroke to delete it.
176
+ */
177
+ declare function insertSelection(value: string, text: string, el: SelectionSource): WrapResult;
178
+
179
+ /** A letter case the toolbar sets on the host's field: the shell toolbar's. */
180
+ type CopyCase = TextToolbarCase;
181
+ /** The marks row 1 of the toolbar carries: the shell toolbar's. */
182
+ type ToolbarMark = TextToolbarMark;
183
+ /**
184
+ * A handle on the box's textarea.
185
+ *
186
+ * DECLARED STRUCTURALLY rather than as React's `RefObject`, and the reason is
187
+ * the package's `react >=18` peer range. React 18 types read `RefObject<T>` as
188
+ * `{ readonly current: T | null }`, React 19's `useRef<T>(null)` produces
189
+ * `RefObject<T | null>`, and the interface is covariant in `T` — so the two
190
+ * spellings of the same object do not assign to each other, and a package that
191
+ * has to compile against both cannot name either one. The shape is the whole
192
+ * contract; naming it here costs one line and no version branch.
193
+ */
194
+ type TextAreaHandle = {
195
+ current: HTMLTextAreaElement | null;
196
+ };
197
+ /**
198
+ * A handle on ANY text control the caret machinery can drive — a `<textarea>`
199
+ * or a one-line `<input>` (blueprint 4.9). `useCaretEdit` takes this, so a host
200
+ * with its own input rows (the website editor's list lines) uses the same
201
+ * twelve lines instead of a copy of them. A {@link TextAreaHandle} is one.
202
+ */
203
+ type TextBoxHandle = {
204
+ current: HTMLInputElement | HTMLTextAreaElement | null;
205
+ };
206
+ /**
207
+ * What a host may put UNDER the box, and what it needs to draw it.
208
+ *
209
+ * A render prop rather than a plain node, for one reason that is not style: the
210
+ * campaign's merge-tag chips have to insert at the caret, and only this control
211
+ * knows where the caret is. Handing the host `insert` is what lets the chips
212
+ * live in the app — where the tag list, the audience call and the product's
213
+ * vocabulary belong — while the caret machinery stays here, written once.
214
+ *
215
+ * `focused` is passed for the same reason the portal tracked it locally: the row
216
+ * appears while the merchant is typing in THIS box and not in its neighbour.
217
+ */
218
+ interface CopyBoxFooter {
219
+ focused: boolean;
220
+ /** Put a literal string where the caret is, replacing any selection. */
221
+ insert: (text: string) => void;
222
+ }
223
+ /**
224
+ * What a host needs to draw its OWN control in row 1's 9th cell of the final
225
+ * toolbar ({@link CopyBoxProps.lastTool}) — the campaign designer's Insert
226
+ * (merge tags), owner ruling 2026-10-07. The website editor passes nothing.
227
+ *
228
+ * `className` makes it a cell that looks like its neighbours; `keepCaret` on
229
+ * its mousedown keeps the caret and the selection in the box; `insert` writes
230
+ * at the caret, as {@link CopyBoxFooter.insert} does.
231
+ */
232
+ interface CopyBoxLastTool {
233
+ className: string;
234
+ /** The box is read-only. */
235
+ disabled: boolean;
236
+ /** Words are selected (not just a caret). */
237
+ selected: boolean;
238
+ keepCaret: (e: {
239
+ preventDefault(): void;
240
+ }) => void;
241
+ /** Put a literal string where the caret is, replacing any selection. */
242
+ insert: (text: string) => void;
243
+ }
244
+ /**
245
+ * The alignment strip, when the host has an alignment to offer.
246
+ *
247
+ * GENERIC IN THE DIRECTIONS IT ALLOWS, so `onChange` RECEIVES only what the
248
+ * host said it could honour. Before this it received the whole union, and a
249
+ * host allowing three directions had to narrow a `justify` it had just
250
+ * declared impossible before storing. Raised by the strip's first consumer,
251
+ * which did write that narrowing; the next one might not.
252
+ *
253
+ * `A` is inferred from `allow`, so nothing has to be spelled at the call site.
254
+ *
255
+ * ⚠️ IT DOES NOT FORBID A WIDER HANDLER, and cannot: a function taking the
256
+ * whole `CopyAlign` is assignable where one taking three is wanted, because
257
+ * parameters are contravariant — and that direction is SAFE, since only the
258
+ * three can ever arrive. What this buys is that the narrow handler now
259
+ * type-checks without a cast, which is what makes writing the safe one the
260
+ * path of least resistance.
261
+ */
262
+ interface CopyBoxAlign<A extends CopyAlign = CopyAlign> {
263
+ value: A | '';
264
+ onChange: (next: A) => void;
265
+ /**
266
+ * Which directions this host can honour. Required and with no default: a
267
+ * renderer that cannot justify must not be given a Justify button because a
268
+ * default handed it one, which is the shape of mistake this whole card exists
269
+ * to stop. It is also what `A` above is inferred from.
270
+ */
271
+ allow: readonly A[];
272
+ /** The strip exists but cannot apply right now. Distinct from the whole
273
+ * control being read-only. */
274
+ disabled?: boolean;
275
+ }
276
+ interface CopyBoxProps {
277
+ /** The authored string, delimiters and all. The single source of truth. */
278
+ value: string;
279
+ /** Every keystroke, and every button press. */
280
+ onChange: (value: string) => void;
281
+ /** The edit is finished and may be written: on blur, and on Enter when
282
+ * {@link multiline} is false. */
283
+ onCommit?: (value: string) => void;
284
+ /** Escape. The argument is the value the box was given when it gained focus;
285
+ * the HOST puts it back, because the host owns the string. */
286
+ onCancel?: (restored: string) => void;
287
+ /** What Enter means — NOT how the text wraps. Both modes soft-wrap. */
288
+ multiline?: boolean;
289
+ placeholder?: string;
290
+ /** Accessible name for the box. */
291
+ ariaLabel?: string;
292
+ className?: string;
293
+ /** Nothing may be typed or pressed. */
294
+ readOnly?: boolean;
295
+ /**
296
+ * The grammar's rule set — `CAMPAIGN_MARKUP` in the designer,
297
+ * `STOREFRONT_MARKUP` in the shop, both from `efficient-easel/markup`. It
298
+ * decides what the LAYER paints; {@link tools} decides what the BAR offers,
299
+ * and a host that lets those two disagree gets a button whose mark draws as
300
+ * plain text.
301
+ */
302
+ rules?: readonly InlineRule[];
303
+ /**
304
+ * Which mark buttons to show — styles resolved against the shared grammar, or
305
+ * the host's own descriptors used verbatim. See `MarkBarProps.tools`. Empty
306
+ * draws no bar.
307
+ */
308
+ tools?: MarkBarProps['tools'];
309
+ /**
310
+ * How a mark is written. Defaults to the shared grammar's `applyMark`; the
311
+ * storefront passes its own so its three word styles reach the same bar.
312
+ */
313
+ writeMark?: MarkWriter;
314
+ /**
315
+ * Buttons that are NOT marks, drawn after a divider at the end of the bar.
316
+ *
317
+ * The storefront's "Clear formatting" is the one that exists: it writes no
318
+ * mark at all, so it is not in the grammar's tool list and must not be added
319
+ * to it. Drawing it here keeps `MARKUP_TOOLS` meaning "what a mark MEANS".
320
+ */
321
+ actions?: ReactNode;
322
+ /** The alignment strip. Omitted = no strip. */
323
+ align?: CopyBoxAlign<CopyAlign>;
324
+ /** What each mark button is DRAWN as — see `MarkBarProps.glyphs`. Default is
325
+ * the grammar's own letter. */
326
+ glyphs?: MarkBarProps['glyphs'];
327
+ /** What the formatting group is CALLED — see `MarkBarProps.ariaLabel`. */
328
+ barLabel?: string;
329
+ /** What goes under the box — see {@link CopyBoxFooter}. */
330
+ renderFooter?: (ctx: CopyBoxFooter) => ReactNode;
331
+ /**
332
+ * When the bar is drawn. `'always'` (the default) keeps it over the box at
333
+ * rest. `'focus'` draws it only while this box is being typed in — the text
334
+ * box design for 4.9: a column of text settings at rest is a column of
335
+ * words, not a column of toolbars.
336
+ */
337
+ barShows?: 'always' | 'focus';
338
+ /**
339
+ * Show the EFFECT, not the marks (0.95.0, rulings B + C — the default). A
340
+ * many-line box gets a "Show marks" switch under it that flips to the raw
341
+ * text with its marks and back; a one-line box is always the effect.
342
+ * `false` keeps the 0.94 box (the raw text, painted) with no switch.
343
+ *
344
+ * ⚠️ In the rich view there is no textarea, so {@link inputRef} holds null.
345
+ * Insert at the caret through `renderFooter`'s `insert`, which works in both.
346
+ */
347
+ richText?: boolean;
348
+ /** A many-line box opens with its marks shown. Default false. */
349
+ defaultShowMarks?: boolean;
350
+ /**
351
+ * Which toolbar (E5b). `'final'` — the default — is the design made final
352
+ * on 2026-10-06: two rows on one 9-column grid, B · I · U · S · Color ·
353
+ * Link · Superscript · Subscript · the host's {@link lastTool} (Undo until
354
+ * 2026-10-07) over Left · Center · Right · Justify
355
+ * · Bulleted · Numbered · Aa · AA · aa, with the number {@link cells}
356
+ * between it and the box. `'classic'` is the bar before it (`MarkBar` and
357
+ * the alignment strip), for a host not moved over yet.
358
+ */
359
+ toolbar?: 'final' | 'classic';
360
+ /**
361
+ * The theme colours the colour window offers (final toolbar): the NAME
362
+ * saved in `[words]{color=name}`, what it is called, and its value. The box
363
+ * paints a coloured word with the value (`--es-color-<name>`). The window
364
+ * also offers Any color, saved as a hex (`[words]{color=#rrggbb}`). No colours:
365
+ * no colour button, and no blank where it was (Lewis 2026-10-13).
366
+ */
367
+ colors?: readonly CopyThemeColor[];
368
+ /** The number cells between the toolbar and the box (final toolbar), each
369
+ * the host's value — see `COPY_CELLS`. None: no cells. */
370
+ cells?: readonly CopyCell[];
371
+ /**
372
+ * The host's letter-case field, set by Aa · AA · aa (final toolbar). The
373
+ * lit one pressed again writes `''`: no case of its own, the style decides.
374
+ * Left out: no case buttons, and no blanks where they were (Lewis
375
+ * 2026-10-13). A row with no tool at all is not drawn.
376
+ */
377
+ letterCase?: {
378
+ value: CopyCase | '';
379
+ onChange: (next: CopyCase | '') => void;
380
+ disabled?: boolean;
381
+ };
382
+ /**
383
+ * Row 1's 9th cell of the final toolbar, drawn by the host (owner ruling
384
+ * 2026-10-07: Undo left that cell). Return one control; it is placed in the
385
+ * cell as given; one that draws nothing (`null`) leaves no blank. Left
386
+ * out, row 1 is eight buttons spread over the row. See
387
+ * {@link CopyBoxLastTool}.
388
+ */
389
+ lastTool?: (slot: CopyBoxLastTool) => ReactNode;
390
+ /** A handle on the textarea, for a host that needs one — and the SAME object
391
+ * the control uses, so there is never a second ref to reconcile. A plain prop
392
+ * rather than `ref`, for the reason `GoldLayer.layerRef` gives. */
393
+ inputRef?: TextAreaHandle;
394
+ }
395
+
396
+ interface TextMap {
397
+ /** The words as drawn: text in order, a `<br>` or a new block line as `\n`. */
398
+ text: string;
399
+ /** The visible offset of a DOM point inside the root. */
400
+ at: (node: Node, offset: number) => number;
401
+ /** The DOM point of a visible offset. */
402
+ dom: (v: number) => [Node, number];
403
+ }
404
+ /**
405
+ * Read the words a renderer drew, whatever its markup: text nodes in order;
406
+ * a `<br>` is a line break, and so is the start of a block-level child after
407
+ * some words (a line the renderer drew as its own block). An element matching
408
+ * `skip` is drawn among the words but is not words (the email's paragraph
409
+ * gap): it adds nothing, and a caret inside it reads as the place it stands.
410
+ */
411
+ declare function textMap(root: HTMLElement, skip?: string): TextMap;
412
+ /** Why typing ended. */
413
+ type CanvasTypingEnd = 'escape' | 'enter' | 'blur' | 'outside' | 'stop';
414
+ interface CanvasTypingOptions {
415
+ /** The element the page drew the words in. Read again after every redraw:
416
+ * a host that draws them afresh may hand back a new one. */
417
+ element: () => HTMLElement | null;
418
+ /** The saved string. */
419
+ value: string;
420
+ rules: readonly InlineRule[];
421
+ /** The field has lines: Shift+Enter makes one. */
422
+ multiline: boolean;
423
+ /** A selector for elements drawn among the words that are not words (a
424
+ * paragraph's gap): {@link textMap} leaves them out. */
425
+ skip?: string;
426
+ /** The visible selection to start with. */
427
+ caret: [number, number];
428
+ /** The host's ONE writer — the same the panel's text box writes through. */
429
+ write: (next: string) => void;
430
+ /** Typing ended; the words are what was last written. */
431
+ end: (why: CanvasTypingEnd) => void;
432
+ /** The browser wrote into the words (a composition): draw them afresh. */
433
+ remount?: () => void;
434
+ /** What the toolbar shows may have changed (the selection moved, a press, a
435
+ * write): a host draws its buttons again from `pressed()`. */
436
+ onSelect?: () => void;
437
+ now?: () => number;
438
+ }
439
+ interface CanvasTypingSession {
440
+ /** The string as the session last wrote or was told. */
441
+ readonly value: string;
442
+ /** The host wrote the string from elsewhere (the panel's text box). */
443
+ update: (next: string) => void;
444
+ /** End typing. Once: a second call does nothing. */
445
+ stop: (why?: CanvasTypingEnd) => void;
446
+ /** What the selection wears, for the toolbar's pressed buttons (a pending
447
+ * press included), the list its lines are in, and whether words (not just
448
+ * a caret) are selected. */
449
+ pressed: () => {
450
+ marks: Partial<Record<string, boolean>>;
451
+ list: 'bullet' | 'number' | null;
452
+ selected: boolean;
453
+ };
454
+ /** A mark button pressed (B, I, U, S, superscript, subscript): on the
455
+ * selected words, or for the words typed next — `markPress`, as the panel
456
+ * box presses. */
457
+ press: (style: MarkStyle) => void;
458
+ /** A list button pressed: the selection's lines become that list, or stop being one. */
459
+ list: (kind: 'bullet' | 'number') => void;
460
+ /**
461
+ * Put a literal string where the caret is, replacing the selected words —
462
+ * the host tool's write (the email's merge-tag Insert), as `CopyBox`'s
463
+ * `lastTool` slot does in the panel's box. One edit step; the caret lands
464
+ * after the words; typing goes on.
465
+ */
466
+ insert: (text: string) => void;
467
+ /**
468
+ * A host tool on the toolbar is taking focus (its menu opens): the words
469
+ * losing focus to it is not leaving them. Held until the words have focus
470
+ * again or the tool writes (`insert`); a click outside the words still ends
471
+ * typing (the canvas's `stop('outside')`).
472
+ */
473
+ hold: () => void;
474
+ }
475
+ /** Start typing in the words `element()` drew, or `null` where they are not the string's. */
476
+ declare function startCanvasTyping(o: CanvasTypingOptions): CanvasTypingSession | null;
477
+
478
+ export { type CopyBoxLastTool as C, MarkBar as M, type SelectionSource as S, type TextBoxHandle as T, type CanvasTypingEnd as a, type CopyBoxProps as b, type CopyCell as c, COPY_CELLS as d, type CanvasTypingOptions as e, type CanvasTypingSession as f, ColorWindow as g, type CopyBoxAlign as h, type CopyBoxFooter as i, type CopyCase as j, type CopyCellPreset as k, CopyCells as l, type CopyThemeColor as m, type MarkBarProps as n, type MarkWriter as o, type TextAreaHandle as p, type TextMap as q, type ToolbarMark as r, ariaShortcut as s, insertSelection as t, markSelection as u, startCanvasTyping as v, textMap as w };
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-K5744MTM.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
1
+ import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-M32O2WRM.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
@@ -1,5 +1,5 @@
1
- import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-K5744MTM.js";import{Inspector as i}from"./chunk-26GHWMNN.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},L={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
1
+ import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-M32O2WRM.js";import{Inspector as i}from"./chunk-26GHWMNN.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},L={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
2
2
  return s(t,{height:"fill"})}function C(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
3
3
  return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var G=o({});function P({parts:n,children:e}){/* @__PURE__ */
4
- return s(G.Provider,{value:n,children:e})}function D(){return u(G)}function T(){return(D().useOwnerName??g)()}function x(){return(D().useDocumentLabel??y)()}function B(n,e,t,r){return(D().useBridges??v)(n,e,t,r)}function I(n){return(D().useStandaloneBridges??v)(n)}function A(n,e){(D().useDocumentPass??b)(n,e)}function F(){return D().blockRules??O}function K(){return D().blockLook??j}function M(){return D().devices??w}function R(){return D().leftView??L}function W(){return D().pinned??N}function H(){return D().saveSwitch??!0}function V(n){e(!0===D().pickFollowsSelection,n)}function E(){return D().add??h}function Q(){return D().storageNamespace||void 0}function Y(){return D().styleClipboard??null}function Z(){return D().nodeKeys??!0}function q(){return D().notify??null}function z(){return D().Canvas??S}function J(){return D().CanvasHead??null}function U(){return D().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
5
- return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return D().Inspector??C}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,P as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,E as useScreenAdd,K as useScreenBlockLook,F as useScreenBlockRules,B as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,J as useScreenCanvasHead,_ as useScreenCanvasTarget,M as useScreenDevices,x as useScreenDocumentLabel,A as useScreenDocumentPass,nn as useScreenInspectorPanel,R as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,T as useScreenOwnerName,D as useScreenParts,V as useScreenPickFollowsSelection,W as useScreenPinned,H as useScreenSaveSwitch,Q as useScreenStorageNamespace,Y as useScreenStyleClipboard,I as useStandaloneScreenBridges};
4
+ return s(G.Provider,{value:n,children:e})}function D(){return u(G)}function x(){return(D().useOwnerName??g)()}function B(){return(D().useDocumentLabel??y)()}function I(n,e,t,r){return(D().useBridges??v)(n,e,t,r)}function R(n){return(D().useStandaloneBridges??v)(n)}function T(n,e){(D().useDocumentPass??b)(n,e)}function W(){return D().blockRules??O}function A(){return D().blockLook??j}function F(){return D().devices??w}function M(){return D().leftView??L}function H(){return D().pinned??N}function K(){return D().saveSwitch??!0}function V(n){e(!0===D().pickFollowsSelection,n)}function E(){return D().add??h}function Q(){return D().storageNamespace||void 0}function Y(){return D().styleClipboard??null}function Z(){return D().nodeKeys??!0}function q(){return D().notify??null}function z(){return D().Canvas??S}function J(){return D().CanvasHead??null}function U(){return D().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
5
+ return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return D().Inspector??C}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,P as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,E as useScreenAdd,A as useScreenBlockLook,W as useScreenBlockRules,I as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,J as useScreenCanvasHead,_ as useScreenCanvasTarget,F as useScreenDevices,B as useScreenDocumentLabel,T as useScreenDocumentPass,nn as useScreenInspectorPanel,M as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,x as useScreenOwnerName,D as useScreenParts,V as useScreenPickFollowsSelection,H as useScreenPinned,K as useScreenSaveSwitch,Q as useScreenStorageNamespace,Y as useScreenStyleClipboard,R as useStandaloneScreenBridges};
@@ -1,7 +1,7 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-GKGBKSZ7.js";import{ScreenChrome as e}from"./chunk-BPLCMQ6S.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-THZ46DC5.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-JTUUIVBZ.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
1
+ import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-IZ2QRXSE.js";import{ScreenChrome as e}from"./chunk-FJ3ZJJ5Z.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-THZ46DC5.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-JTUUIVBZ.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.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 k=r(n),C=r(e);function j({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 k=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:()=>{C()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
- return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),H=t(()=>s(!g),[g]),Z=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:Z.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
- /* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:H,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:Z.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:Z.waitingForAuthorization})}export{H as DocumentScreen,y as ScreenMount};
5
+ /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
+ return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function Z({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),Z=t(()=>s(!g),[g]),H=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
+ /* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:Z,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:H.waitingForAuthorization})}export{Z as DocumentScreen,y as ScreenMount};
@@ -1 +1 @@
1
- import{useScreenBlockRules as e}from"./chunk-LGDQLTJW.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-K5744MTM.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
1
+ import{useScreenBlockRules as e}from"./chunk-7O6MDCDU.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-M32O2WRM.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};