@tangle-network/agent-app 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DesignCanvas-AOIVN3SJ.js +12 -0
- package/dist/DesignCanvasEditor-TN7CWUJW.js +13 -0
- package/dist/{TimelineEditor-JDG54OBP.js → TimelineEditor-Z7C6BFP5.js} +2 -2
- package/dist/{apply-Cp8c3K9D.d.ts → apply-Gk4raT2j.d.ts} +3 -1
- package/dist/brand-extraction/index.d.ts +212 -0
- package/dist/brand-extraction/index.js +446 -0
- package/dist/brand-extraction/index.js.map +1 -0
- package/dist/{chunk-AFDROJ64.js → chunk-2QI7XV2T.js} +1 -1
- package/dist/chunk-2QI7XV2T.js.map +1 -0
- package/dist/{chunk-LUE4HO5C.js → chunk-4IQMTTNE.js} +10 -10
- package/dist/chunk-4IQMTTNE.js.map +1 -0
- package/dist/{chunk-FSUR2752.js → chunk-7I37CO5D.js} +274 -388
- package/dist/chunk-7I37CO5D.js.map +1 -0
- package/dist/{chunk-5RT6KY4G.js → chunk-GQRL6VNU.js} +1 -1
- package/dist/chunk-GQRL6VNU.js.map +1 -0
- package/dist/{chunk-SCG5JJ4C.js → chunk-HFC4BTWJ.js} +32 -4
- package/dist/chunk-HFC4BTWJ.js.map +1 -0
- package/dist/{chunk-7QCIYDGC.js → chunk-IOREXWLM.js} +2 -2
- package/dist/chunk-J7JNV5BH.js +14 -0
- package/dist/chunk-J7JNV5BH.js.map +1 -0
- package/dist/{chunk-6UOE5CTA.js → chunk-JT6HHO5P.js} +5 -10
- package/dist/chunk-JT6HHO5P.js.map +1 -0
- package/dist/{chunk-JZAJE3JL.js → chunk-M2EBUDZ7.js} +19 -5
- package/dist/chunk-M2EBUDZ7.js.map +1 -0
- package/dist/{chunk-RJ2ZHK5D.js → chunk-S6WS2B32.js} +132 -7
- package/dist/chunk-S6WS2B32.js.map +1 -0
- package/dist/chunk-SQV7NUEM.js +136 -0
- package/dist/chunk-SQV7NUEM.js.map +1 -0
- package/dist/chunk-UAKFCMWK.js +1 -0
- package/dist/chunk-UAKFCMWK.js.map +1 -0
- package/dist/chunk-V5XZKHCL.js +296 -0
- package/dist/chunk-V5XZKHCL.js.map +1 -0
- package/dist/chunk-XWJXZ6WE.js +604 -0
- package/dist/chunk-XWJXZ6WE.js.map +1 -0
- package/dist/chunk-Y2SZVW35.js +125 -0
- package/dist/chunk-Y2SZVW35.js.map +1 -0
- package/dist/{chunk-LPAVBGVY.js → chunk-YEWTVDDT.js} +399 -860
- package/dist/chunk-YEWTVDDT.js.map +1 -0
- package/dist/{chunk-UDXMR3AD.js → chunk-YNALYIQ3.js} +56 -18
- package/dist/chunk-YNALYIQ3.js.map +1 -0
- package/dist/command-stack-CkjelfK_.d.ts +267 -0
- package/dist/design-canvas/drizzle.d.ts +2 -2
- package/dist/design-canvas/index.d.ts +7 -6
- package/dist/design-canvas/index.js +3 -2
- package/dist/design-canvas-react/engine.d.ts +349 -0
- package/dist/design-canvas-react/engine.js +86 -0
- package/dist/design-canvas-react/engine.js.map +1 -0
- package/dist/design-canvas-react/index.d.ts +80 -618
- package/dist/design-canvas-react/index.js +85 -172
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.d.ts +6 -0
- package/dist/design-canvas-react/lazy.js +9 -0
- package/dist/design-canvas-react/lazy.js.map +1 -0
- package/dist/{export-presets-Dl5Aa5xj.d.ts → export-presets-DAsU5Wal.d.ts} +2 -143
- package/dist/flow-types-Cb_AblZs.d.ts +25 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.js +21 -8
- package/dist/lazy-BHHqS8-j.d.ts +72 -0
- package/dist/missions/index.d.ts +12 -0
- package/dist/missions/index.js +1 -1
- package/dist/{model-BHLN208Z.d.ts → model-BBwyOuWG.d.ts} +3 -1
- package/dist/operations-DLIvvD00.d.ts +144 -0
- package/dist/platform/index.js +1 -1
- package/dist/runtime/index.d.ts +33 -33
- package/dist/runtime/index.js +1 -1
- package/dist/sequences/index.d.ts +1 -1
- package/dist/sequences/index.js +2 -1
- package/dist/sequences-react/index.d.ts +15 -1
- package/dist/sequences-react/index.js +2 -2
- package/dist/{store-CUStmtdH.d.ts → store-CFyxgTlD.d.ts} +1 -1
- package/dist/theme/index.d.ts +80 -0
- package/dist/theme/index.js +14 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/tailwind-preset.d.ts +65 -0
- package/dist/theme/tailwind-preset.js +33 -0
- package/dist/theme/tailwind-preset.js.map +1 -0
- package/dist/theme/tokens.css +95 -0
- package/dist/trace/index.d.ts +2 -18
- package/dist/trace/index.js +2 -2
- package/dist/web/index.d.ts +25 -2
- package/dist/web/index.js +3 -1
- package/dist/web-react/index.d.ts +71 -31
- package/dist/web-react/index.js +625 -486
- package/dist/web-react/index.js.map +1 -1
- package/package.json +33 -3
- package/dist/DesignCanvas-MA5EH324.js +0 -10
- package/dist/DesignCanvasEditor-YLCO7I5I.js +0 -9
- package/dist/chunk-5RT6KY4G.js.map +0 -1
- package/dist/chunk-6UOE5CTA.js.map +0 -1
- package/dist/chunk-AFDROJ64.js.map +0 -1
- package/dist/chunk-FSUR2752.js.map +0 -1
- package/dist/chunk-JZAJE3JL.js.map +0 -1
- package/dist/chunk-LPAVBGVY.js.map +0 -1
- package/dist/chunk-LUE4HO5C.js.map +0 -1
- package/dist/chunk-RJ2ZHK5D.js.map +0 -1
- package/dist/chunk-SCG5JJ4C.js.map +0 -1
- package/dist/chunk-UDXMR3AD.js.map +0 -1
- /package/dist/{DesignCanvas-MA5EH324.js.map → DesignCanvas-AOIVN3SJ.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-YLCO7I5I.js.map → DesignCanvasEditor-TN7CWUJW.js.map} +0 -0
- /package/dist/{TimelineEditor-JDG54OBP.js.map → TimelineEditor-Z7C6BFP5.js.map} +0 -0
- /package/dist/{chunk-7QCIYDGC.js.map → chunk-IOREXWLM.js.map} +0 -0
|
@@ -1,486 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { D as DesignCanvasProps, c as createSceneCommandStack, E as ExportTriggerOptions, a as DesignCanvasMode } from '../command-stack-CkjelfK_.js';
|
|
2
|
+
export { A as ApplySceneResult, b as EditorSceneState, S as SCENE_COMMAND_HISTORY_LIMIT, d as SceneCommand, e as SceneCommandStack, f as SceneCommandStackWithReapply, g as SnapEngine, h as SnapResult, i as SnapTarget, j as SnapTargetKind, k as SnapTargets, Z as ZoomPanMath } from '../command-stack-CkjelfK_.js';
|
|
3
|
+
import { InsertPageGeometry, InsertTemplate, MultiSetAttrsEntry } from './engine.js';
|
|
4
|
+
export { AddElementInput, AddPageInput, BindSlotInput, DEFAULT_INSERT_TEMPLATES, DUPLICATE_OFFSET, DeleteElementInput, DeletePageInput, DuplicatePageInput, ExportViewSnapshot, GroupElementsInput, MAX_INSERT_DIMENSION, MarqueeSelectOptions, NudgeDelta, ReorderElementInput, ReorderPageInput, ResolvedExportParams, SetAttrsInput, SetDocumentTitleInput, SetPageGuidesInput, SetPagePropsInput, UngroupElementInput, ZoomPanConfig, addElementCommand, addPageCommand, bindSlotCommand, buildInsertImageOp, centeredPosition, collectGridTargets, createSnapEngine, createZoomPanMath, deleteElementCommand, deletePageCommand, documentCropToStageCoords, duplicatePageCommand, fittedSize, groupElementsCommand, hitTestPoint, identifyTaintedSrc, isCrossOriginSrc, isExportHiddenNodeName, marqueeSelect, mintElementId, multiSetAttrsCommand, nudgeDelta, reorderElementCommand, reorderPageCommand, resolveExportParams, setAttrsCommand, setDocumentTitleCommand, setPageGuidesCommand, setPagePropsCommand, ungroupElementCommand } from './engine.js';
|
|
5
|
+
import { c as SceneDocument, g as ScenePage, d as SceneElement, P as PageBleed, a as PageGuides } from '../model-BBwyOuWG.js';
|
|
6
|
+
import { f as ExportPreset } from '../export-presets-DAsU5Wal.js';
|
|
7
|
+
export { d as ExportCropRect, h as bleedAwareExportBounds, s as scaleForPreset } from '../export-presets-DAsU5Wal.js';
|
|
8
|
+
export { D as DesignCanvas, a as DesignCanvasChromeLazy, b as DesignCanvasEditor, c as DesignCanvasFullProps, d as DesignCanvasLazy } from '../lazy-BHHqS8-j.js';
|
|
4
9
|
import * as react from 'react';
|
|
10
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
11
|
+
import { g as SceneOperation, f as SceneAttrsPatch } from '../operations-DLIvvD00.js';
|
|
12
|
+
import { CanvasRenderPalette } from '../theme/index.js';
|
|
5
13
|
import Konva from 'konva';
|
|
6
14
|
|
|
7
|
-
/**
|
|
8
|
-
* Seams between the design-canvas editor's engine and components, mirroring
|
|
9
|
-
* the sequences-react pattern: interface-only so layers build independently.
|
|
10
|
-
*
|
|
11
|
-
* Persistence: the command stack executes optimistically against local state
|
|
12
|
-
* and emits `SceneOperation[]` through `DesignCanvasProps.onApplyOperations`.
|
|
13
|
-
* The host's apply returns the new revision (and the server document when it
|
|
14
|
-
* re-minted ids); a rejected promise rolls the command back. Drag gestures
|
|
15
|
-
* coalesce: pointer moves mutate volatile state, ONE command (final attrs,
|
|
16
|
-
* inverse = pre-gesture attrs) executes on release — undo is per-gesture,
|
|
17
|
-
* never per-pixel.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
interface EditorSceneState {
|
|
21
|
-
document: SceneDocument;
|
|
22
|
-
activePageId: string;
|
|
23
|
-
selectedElementIds: string[];
|
|
24
|
-
/** Pixels per document px. */
|
|
25
|
-
zoom: number;
|
|
26
|
-
panX: number;
|
|
27
|
-
panY: number;
|
|
28
|
-
gridEnabled: boolean;
|
|
29
|
-
/** Document px between grid lines. */
|
|
30
|
-
gridSize: number;
|
|
31
|
-
snapEnabled: boolean;
|
|
32
|
-
showRulers: boolean;
|
|
33
|
-
showBleed: boolean;
|
|
34
|
-
}
|
|
35
|
-
interface SceneCommand {
|
|
36
|
-
label: string;
|
|
37
|
-
execute(state: EditorSceneState): EditorSceneState;
|
|
38
|
-
undo(state: EditorSceneState): EditorSceneState;
|
|
39
|
-
operations(): SceneOperation[];
|
|
40
|
-
/**
|
|
41
|
-
* The inverse operation sequence for server-side persistence of an undo.
|
|
42
|
-
* Most commands return an exact inverse (e.g. set_attrs → prior set_attrs,
|
|
43
|
-
* add_element → delete_element). deletePageCommand returns add_page +
|
|
44
|
-
* per-element add_element ops restoring the full page snapshot.
|
|
45
|
-
*/
|
|
46
|
-
inverseOperations(): SceneOperation[];
|
|
47
|
-
}
|
|
48
|
-
interface SceneCommandStack {
|
|
49
|
-
execute(command: SceneCommand): void;
|
|
50
|
-
/** Apply the top-of-done-stack inverse and return the command (callers use
|
|
51
|
-
* `command.inverseOperations()` to persist the undo to the server). */
|
|
52
|
-
undo(): SceneCommand;
|
|
53
|
-
/** Re-execute the top-of-redo-stack and return the command (callers use
|
|
54
|
-
* `command.operations()` to persist the redo to the server). */
|
|
55
|
-
redo(): SceneCommand;
|
|
56
|
-
canUndo(): boolean;
|
|
57
|
-
canRedo(): boolean;
|
|
58
|
-
subscribe(listener: () => void): () => void;
|
|
59
|
-
getState(): EditorSceneState;
|
|
60
|
-
/** Update volatile view state (zoom/pan/selection/toggles) without touching
|
|
61
|
-
* history — view changes are never undo steps. */
|
|
62
|
-
setView(patch: Partial<Omit<EditorSceneState, 'document'>>): void;
|
|
63
|
-
/** Rebase onto a server refresh WITHOUT clearing history (history holds
|
|
64
|
-
* operations, not snapshots). */
|
|
65
|
-
reset(document: SceneDocument): void;
|
|
66
|
-
/**
|
|
67
|
-
* Remove a specific command from the undo stack and apply its inverse to
|
|
68
|
-
* the current state. Called by the persistence layer when a save rejects
|
|
69
|
-
* AFTER the user may have made further edits.
|
|
70
|
-
*
|
|
71
|
-
* Invariant: for commands that operate on disjoint attributes, rollback is
|
|
72
|
-
* identity for all commands executed after the rolled-back one — their net
|
|
73
|
-
* effect is preserved. For overlapping attr edits (same element, same field)
|
|
74
|
-
* the result is defined but not guaranteed to be semantically correct; the
|
|
75
|
-
* caller should trigger an onResyncRequired fetch in that case.
|
|
76
|
-
*
|
|
77
|
-
* If `command` is not found in the undo stack (stale or double-fire
|
|
78
|
-
* rejection handler), this is a safe no-op.
|
|
79
|
-
*/
|
|
80
|
-
rollback(command: SceneCommand): void;
|
|
81
|
-
}
|
|
82
|
-
type SnapTargetKind = 'grid' | 'element-edge' | 'element-center' | 'page-edge' | 'page-center' | 'guide';
|
|
83
|
-
interface SnapTarget {
|
|
84
|
-
/** Page-coordinate position of the snap line. */
|
|
85
|
-
position: number;
|
|
86
|
-
kind: SnapTargetKind;
|
|
87
|
-
}
|
|
88
|
-
interface SnapTargets {
|
|
89
|
-
vertical: SnapTarget[];
|
|
90
|
-
horizontal: SnapTarget[];
|
|
91
|
-
}
|
|
92
|
-
interface SnapResult {
|
|
93
|
-
x: number;
|
|
94
|
-
y: number;
|
|
95
|
-
/** Lines to render while the gesture holds the snap. */
|
|
96
|
-
activeVertical: SnapTarget | null;
|
|
97
|
-
activeHorizontal: SnapTarget | null;
|
|
98
|
-
}
|
|
99
|
-
interface SnapEngine {
|
|
100
|
-
/** Collect targets for a gesture: other elements' edges/centers, page
|
|
101
|
-
* edges/center, saved guides, and grid lines when enabled. `excludeIds`
|
|
102
|
-
* removes the dragged elements' own geometry. */
|
|
103
|
-
collectTargets(state: EditorSceneState, excludeIds: string[]): SnapTargets;
|
|
104
|
-
/** Snap a moving AABB. Threshold is SCREEN pixels, divided by zoom. */
|
|
105
|
-
apply(bounds: Bounds, targets: SnapTargets, thresholdPx: number, zoom: number): SnapResult;
|
|
106
|
-
}
|
|
107
|
-
interface ZoomPanMath {
|
|
108
|
-
minZoom: number;
|
|
109
|
-
maxZoom: number;
|
|
110
|
-
/** Zoom about a screen point so the document point under the cursor stays
|
|
111
|
-
* fixed (wheel-zoom-to-cursor). Returns the clamped new view. */
|
|
112
|
-
zoomAtPoint(state: {
|
|
113
|
-
zoom: number;
|
|
114
|
-
panX: number;
|
|
115
|
-
panY: number;
|
|
116
|
-
}, factor: number, screenX: number, screenY: number): {
|
|
117
|
-
zoom: number;
|
|
118
|
-
panX: number;
|
|
119
|
-
panY: number;
|
|
120
|
-
};
|
|
121
|
-
/** Fit the active page into a viewport with padding. */
|
|
122
|
-
fitPage(page: {
|
|
123
|
-
width: number;
|
|
124
|
-
height: number;
|
|
125
|
-
}, viewport: {
|
|
126
|
-
width: number;
|
|
127
|
-
height: number;
|
|
128
|
-
}, paddingPx?: number): {
|
|
129
|
-
zoom: number;
|
|
130
|
-
panX: number;
|
|
131
|
-
panY: number;
|
|
132
|
-
};
|
|
133
|
-
documentToScreen(state: {
|
|
134
|
-
zoom: number;
|
|
135
|
-
panX: number;
|
|
136
|
-
panY: number;
|
|
137
|
-
}, x: number, y: number): {
|
|
138
|
-
x: number;
|
|
139
|
-
y: number;
|
|
140
|
-
};
|
|
141
|
-
screenToDocument(state: {
|
|
142
|
-
zoom: number;
|
|
143
|
-
panX: number;
|
|
144
|
-
panY: number;
|
|
145
|
-
}, x: number, y: number): {
|
|
146
|
-
x: number;
|
|
147
|
-
y: number;
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
interface ApplySceneResult {
|
|
151
|
-
rev: number;
|
|
152
|
-
/** Present when the server re-minted ids or normalized the document; the
|
|
153
|
-
* editor rebases onto it. */
|
|
154
|
-
document?: SceneDocument;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* What the chrome's Export control collects and hands to the workspace's
|
|
158
|
-
* export callback. The workspace (which owns the Konva stage) renders the
|
|
159
|
-
* page to a data URL with these params and forwards the full result to
|
|
160
|
-
* {@link DesignCanvasProps.onExport}. The chrome is Konva-free, so it cannot
|
|
161
|
-
* produce the data URL itself — it only chooses the format and scale.
|
|
162
|
-
*/
|
|
163
|
-
interface ExportTriggerOptions {
|
|
164
|
-
format: 'png' | 'jpeg';
|
|
165
|
-
/** Output scale multiplier (1 = page size, 2 = retina). */
|
|
166
|
-
pixelRatio: number;
|
|
167
|
-
}
|
|
168
|
-
interface DesignCanvasProps {
|
|
169
|
-
document: SceneDocument;
|
|
170
|
-
/** Revision the document was loaded at; threaded through saves. */
|
|
171
|
-
rev: number;
|
|
172
|
-
canWrite: boolean;
|
|
173
|
-
/** Persist operations. Resolve with the new revision; reject to roll back.
|
|
174
|
-
* A stale-revision failure should resolve AFTER refetch with the fresh
|
|
175
|
-
* document so the editor rebases instead of fighting. */
|
|
176
|
-
onApplyOperations(operations: SceneOperation[]): Promise<ApplySceneResult>;
|
|
177
|
-
onSelectionChange?(elements: SceneElement[]): void;
|
|
178
|
-
/** Host panels: agent chat (right), asset/template browser (left). */
|
|
179
|
-
renderAgentPanel?(ctx: {
|
|
180
|
-
selectedElements: SceneElement[];
|
|
181
|
-
activePageId: string;
|
|
182
|
-
}): React.ReactNode;
|
|
183
|
-
renderSidePanel?(): React.ReactNode;
|
|
184
|
-
/** Export hook — host persists the rendered blob (upload → asset row). */
|
|
185
|
-
onExport?(result: {
|
|
186
|
-
pageId: string;
|
|
187
|
-
format: 'png' | 'jpeg';
|
|
188
|
-
dataUrl: string;
|
|
189
|
-
pixelRatio: number;
|
|
190
|
-
}): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Optional caller-supplied default for the export popover. The chrome's
|
|
193
|
-
* Export control opens with this format/scale pre-selected. Omitted →
|
|
194
|
-
* PNG @ 1x.
|
|
195
|
-
*/
|
|
196
|
-
exportDefaults?: ExportTriggerOptions;
|
|
197
|
-
className?: string;
|
|
198
|
-
/** Fit the active page to the viewport once, on the first non-zero measurement. Default true. Set false to keep zoom:1/pan:0 (e.g. when restoring a saved viewport). */
|
|
199
|
-
fitOnMount?: boolean;
|
|
200
|
-
/** Called once after the first real (non-zero) measurement, after the initial fit is applied (or skipped when fitOnMount is false). */
|
|
201
|
-
onReady?(): void;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Undo/redo command stack over immutable `EditorSceneState`.
|
|
206
|
-
*
|
|
207
|
-
* History entries hold COMMANDS (state transforms + durable operations
|
|
208
|
-
* captured at construction), never snapshots. Rebasing the document via
|
|
209
|
-
* `reset()` therefore cannot stale the history: a later undo re-applies the
|
|
210
|
-
* inverse transform to whatever document is current. If the rebase removed an
|
|
211
|
-
* element a historical command targets, that transform throws (fail loud)
|
|
212
|
-
* rather than silently editing the wrong element.
|
|
213
|
-
*
|
|
214
|
-
* `setView` updates volatile view state (zoom/pan/selection/toggles) without
|
|
215
|
-
* touching history — view changes are never undo steps.
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
/** Oldest entries are dropped past this bound; redo stack is cleared on execute. */
|
|
219
|
-
declare const SCENE_COMMAND_HISTORY_LIMIT = 200;
|
|
220
|
-
declare function createSceneCommandStack(document: SceneDocument, activePageId: string): SceneCommandStack;
|
|
221
|
-
|
|
222
|
-
interface AddElementInput {
|
|
223
|
-
pageId: string;
|
|
224
|
-
element: SceneElement;
|
|
225
|
-
/** Insertion z-index within owner; omitted → top. */
|
|
226
|
-
index?: number;
|
|
227
|
-
/** Parent group id; omitted → page root. */
|
|
228
|
-
parentGroupId?: string;
|
|
229
|
-
}
|
|
230
|
-
declare function addElementCommand(input: AddElementInput): SceneCommand;
|
|
231
|
-
interface SetAttrsInput {
|
|
232
|
-
pageId: string;
|
|
233
|
-
elementId: string;
|
|
234
|
-
/** Final attribute values after the gesture. */
|
|
235
|
-
attrs: SceneAttrsPatch;
|
|
236
|
-
/** Attribute values BEFORE the gesture began — inverse is built from these. */
|
|
237
|
-
priorAttrs: SceneAttrsPatch;
|
|
238
|
-
}
|
|
239
|
-
declare function setAttrsCommand(input: SetAttrsInput): SceneCommand;
|
|
240
|
-
interface MultiSetAttrsEntry {
|
|
241
|
-
pageId: string;
|
|
242
|
-
elementId: string;
|
|
243
|
-
attrs: SceneAttrsPatch;
|
|
244
|
-
priorAttrs: SceneAttrsPatch;
|
|
245
|
-
}
|
|
246
|
-
declare function multiSetAttrsCommand(entries: MultiSetAttrsEntry[]): SceneCommand;
|
|
247
|
-
interface ReorderElementInput {
|
|
248
|
-
pageId: string;
|
|
249
|
-
elementId: string;
|
|
250
|
-
toIndex: number;
|
|
251
|
-
}
|
|
252
|
-
declare function reorderElementCommand(input: ReorderElementInput): SceneCommand;
|
|
253
|
-
interface DeleteElementInput {
|
|
254
|
-
document: SceneDocument;
|
|
255
|
-
pageId: string;
|
|
256
|
-
elementId: string;
|
|
257
|
-
}
|
|
258
|
-
declare function deleteElementCommand(input: DeleteElementInput): SceneCommand;
|
|
259
|
-
interface GroupElementsInput {
|
|
260
|
-
document: SceneDocument;
|
|
261
|
-
pageId: string;
|
|
262
|
-
elementIds: string[];
|
|
263
|
-
groupId: string;
|
|
264
|
-
name?: string;
|
|
265
|
-
}
|
|
266
|
-
declare function groupElementsCommand(input: GroupElementsInput): SceneCommand;
|
|
267
|
-
interface UngroupElementInput {
|
|
268
|
-
document: SceneDocument;
|
|
269
|
-
pageId: string;
|
|
270
|
-
groupId: string;
|
|
271
|
-
}
|
|
272
|
-
declare function ungroupElementCommand(input: UngroupElementInput): SceneCommand;
|
|
273
|
-
interface AddPageInput {
|
|
274
|
-
pageId: string;
|
|
275
|
-
options?: NewPageOptions;
|
|
276
|
-
index?: number;
|
|
277
|
-
}
|
|
278
|
-
declare function addPageCommand(input: AddPageInput): SceneCommand;
|
|
279
|
-
interface DuplicatePageInput {
|
|
280
|
-
document: SceneDocument;
|
|
281
|
-
sourcePageId: string;
|
|
282
|
-
/** Caller-minted id for the copy. */
|
|
283
|
-
pageId: string;
|
|
284
|
-
}
|
|
285
|
-
declare function duplicatePageCommand(input: DuplicatePageInput): SceneCommand;
|
|
286
|
-
interface DeletePageInput {
|
|
287
|
-
document: SceneDocument;
|
|
288
|
-
pageId: string;
|
|
289
|
-
}
|
|
290
|
-
declare function deletePageCommand(input: DeletePageInput): SceneCommand;
|
|
291
|
-
interface ReorderPageInput {
|
|
292
|
-
pageId: string;
|
|
293
|
-
toIndex: number;
|
|
294
|
-
}
|
|
295
|
-
declare function reorderPageCommand(input: ReorderPageInput): SceneCommand;
|
|
296
|
-
interface SetPagePropsInput {
|
|
297
|
-
document: SceneDocument;
|
|
298
|
-
pageId: string;
|
|
299
|
-
props: {
|
|
300
|
-
name?: string;
|
|
301
|
-
width?: number;
|
|
302
|
-
height?: number;
|
|
303
|
-
background?: string;
|
|
304
|
-
bleed?: PageBleed | null;
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
declare function setPagePropsCommand(input: SetPagePropsInput): SceneCommand;
|
|
308
|
-
interface SetPageGuidesInput {
|
|
309
|
-
document: SceneDocument;
|
|
310
|
-
pageId: string;
|
|
311
|
-
guides: PageGuides;
|
|
312
|
-
}
|
|
313
|
-
declare function setPageGuidesCommand(input: SetPageGuidesInput): SceneCommand;
|
|
314
|
-
interface BindSlotInput {
|
|
315
|
-
document: SceneDocument;
|
|
316
|
-
pageId: string;
|
|
317
|
-
elementId: string;
|
|
318
|
-
slot: string | null;
|
|
319
|
-
}
|
|
320
|
-
declare function bindSlotCommand(input: BindSlotInput): SceneCommand;
|
|
321
|
-
interface SetDocumentTitleInput {
|
|
322
|
-
document: SceneDocument;
|
|
323
|
-
title: string;
|
|
324
|
-
}
|
|
325
|
-
declare function setDocumentTitleCommand(input: SetDocumentTitleInput): SceneCommand;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* 2-axis snap engine for the design-canvas editor. Targets come from element
|
|
329
|
-
* AABBs (edges + centers), page edges + center, saved guides, and grid lines
|
|
330
|
-
* near the moving bounds. Grid lines are generated lazily in the neighborhood
|
|
331
|
-
* of the moving element, not the full page — avoids allocating thousands of
|
|
332
|
-
* targets on large pages with fine grids.
|
|
333
|
-
*
|
|
334
|
-
* Threshold is a SCREEN distance (pixels), divided by zoom to convert to
|
|
335
|
-
* document units — what "feels close" is a screen distance.
|
|
336
|
-
*
|
|
337
|
-
* Tie-breaking: non-grid kinds beat grid on equal distance; among equals of
|
|
338
|
-
* the same priority the first in iteration order wins.
|
|
339
|
-
*/
|
|
340
|
-
|
|
341
|
-
declare function createSnapEngine(): SnapEngine;
|
|
342
|
-
/** Generate grid line targets within a neighborhood around the moving bounds.
|
|
343
|
-
* Call this and append to `SnapTargets.vertical`/`horizontal` before
|
|
344
|
-
* passing to `apply()` when `state.gridEnabled`. */
|
|
345
|
-
declare function collectGridTargets(bounds: Bounds, gridSize: number, page: ScenePage, thresholdDocPx: number): {
|
|
346
|
-
vertical: SnapTarget[];
|
|
347
|
-
horizontal: SnapTarget[];
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Selection math for the design-canvas editor: marquee hit-tests, keyboard
|
|
352
|
-
* nudge deltas, and the duplicate offset constant. Pure functions — no DOM, no
|
|
353
|
-
* Konva, no React.
|
|
354
|
-
*
|
|
355
|
-
* Marquee inclusion: by default any element whose AABB intersects the marquee
|
|
356
|
-
* rect is included (the "touch" model). Pass `requireFullContainment: true` for
|
|
357
|
-
* the "surround" model where the marquee must fully contain the element. Locked
|
|
358
|
-
* and invisible elements are never selected regardless.
|
|
359
|
-
*/
|
|
360
|
-
|
|
361
|
-
interface MarqueeSelectOptions {
|
|
362
|
-
/** When true, the element's AABB must be fully inside the marquee; default is
|
|
363
|
-
* intersection (any overlap selects). */
|
|
364
|
-
requireFullContainment?: boolean;
|
|
365
|
-
}
|
|
366
|
-
/** Returns the ids of selectable elements on `page` whose AABB intersects (or
|
|
367
|
-
* is contained by) `rect`. Locked and invisible elements are excluded. */
|
|
368
|
-
declare function marqueeSelect(page: ScenePage, rect: Bounds, opts?: MarqueeSelectOptions): string[];
|
|
369
|
-
interface NudgeDelta {
|
|
370
|
-
dx: number;
|
|
371
|
-
dy: number;
|
|
372
|
-
}
|
|
373
|
-
/** Map an arrow key to a document-px delta. `shift` engages the 10× step.
|
|
374
|
-
* Throws on unknown keys so callers handle only real nudge keys. */
|
|
375
|
-
declare function nudgeDelta(key: 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown', shift: boolean): NudgeDelta;
|
|
376
|
-
/** Document-px offset applied to duplicated elements so the copy is visually
|
|
377
|
-
* separated from the original (matching common design-tool convention). */
|
|
378
|
-
declare const DUPLICATE_OFFSET: NudgeDelta;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Zoom + pan coordinate math for the design-canvas editor. Zoom is pixels-per-
|
|
382
|
-
* document-px (e.g. 2 = 200% magnification). The key invariant for wheel-zoom
|
|
383
|
-
* is that the document point under the cursor stays fixed in screen space:
|
|
384
|
-
*
|
|
385
|
-
* docPoint = (screenPoint - pan) / zoom
|
|
386
|
-
* newPan = screenPoint - docPoint * newZoom
|
|
387
|
-
*
|
|
388
|
-
* This module is pure math — no DOM, no Konva, no React.
|
|
389
|
-
*/
|
|
390
|
-
|
|
391
|
-
interface ZoomPanConfig {
|
|
392
|
-
minZoom: number;
|
|
393
|
-
maxZoom: number;
|
|
394
|
-
}
|
|
395
|
-
declare function createZoomPanMath(config: ZoomPanConfig): ZoomPanMath;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Pure export math for the design-canvas surface — no Konva, no DOM, no React.
|
|
399
|
-
*
|
|
400
|
-
* All stage-interaction code (save/restore, node visibility, toDataURL) lives
|
|
401
|
-
* in export.ts and delegates the decision math here so it can be tested
|
|
402
|
-
* without a canvas environment.
|
|
403
|
-
*/
|
|
404
|
-
|
|
405
|
-
/** Returns true for any Konva node that must be hidden during export. Nodes
|
|
406
|
-
* whose names start with 'overlay:' are editor-only chrome (snap lines,
|
|
407
|
-
* selection indicators, rulers, bleed guides). The transformer node is
|
|
408
|
-
* identified by its canonical name 'Transformer'. */
|
|
409
|
-
declare function isExportHiddenNodeName(name: string): boolean;
|
|
410
|
-
interface ResolvedExportParams {
|
|
411
|
-
cropRect: ExportCropRect;
|
|
412
|
-
pixelRatio: number;
|
|
413
|
-
mimeType: 'image/png' | 'image/jpeg';
|
|
414
|
-
quality: number | undefined;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Resolve the full set of toDataURL params from a page, format, pixel ratio,
|
|
418
|
-
* bleed flag, and optional preset. When a preset is supplied it overrides
|
|
419
|
-
* `pixelRatio` and `includeBleed` — the explicit args are ignored for those
|
|
420
|
-
* two values so the preset is the single source of truth.
|
|
421
|
-
*
|
|
422
|
-
* `quality` is set to 0.92 for jpeg, undefined for png (Konva ignores it).
|
|
423
|
-
*/
|
|
424
|
-
declare function resolveExportParams(page: ScenePage, opts: {
|
|
425
|
-
format: 'png' | 'jpeg';
|
|
426
|
-
pixelRatio?: number;
|
|
427
|
-
includeBleed?: boolean;
|
|
428
|
-
preset?: ExportPreset;
|
|
429
|
-
}): ResolvedExportParams;
|
|
430
|
-
/**
|
|
431
|
-
* Walk image nodes to find the src of any that may have caused a SecurityError
|
|
432
|
-
* when the stage called toDataURL. Returns the first offending src found, or
|
|
433
|
-
* null if none can be identified.
|
|
434
|
-
*
|
|
435
|
-
* `imageSrcs` is a flat list of { name, src } records collected from all image
|
|
436
|
-
* nodes on the stage before calling toDataURL — export.ts builds it before
|
|
437
|
-
* attempting the export so that if the SecurityError fires we have the data.
|
|
438
|
-
*/
|
|
439
|
-
declare function identifyTaintedSrc(imageSrcs: ReadonlyArray<{
|
|
440
|
-
name: string;
|
|
441
|
-
src: string;
|
|
442
|
-
}>): string | null;
|
|
443
|
-
/**
|
|
444
|
-
* Heuristic: a src is potentially cross-origin when it is an absolute http(s)
|
|
445
|
-
* URL. Same-origin relative paths (/api/...) and data: blobs are safe.
|
|
446
|
-
* This is intentionally conservative — the taint check runs only after a
|
|
447
|
-
* SecurityError fires, so a false positive is "blamed" without being silently
|
|
448
|
-
* ignored. NOTE: same-origin https:// assets will also match; if a
|
|
449
|
-
* SecurityError fires, the cross-origin culprit may be a different image than
|
|
450
|
-
* the one this function flags first.
|
|
451
|
-
*/
|
|
452
|
-
declare function isCrossOriginSrc(src: string): boolean;
|
|
453
|
-
/** Minimal snapshot of stage view state that export.ts saves before mutating
|
|
454
|
-
* zoom/pan/visibility and restores afterward. */
|
|
455
|
-
interface ExportViewSnapshot {
|
|
456
|
-
/** Stage scale factor before export. */
|
|
457
|
-
scaleX: number;
|
|
458
|
-
scaleY: number;
|
|
459
|
-
/** Stage translation before export. */
|
|
460
|
-
x: number;
|
|
461
|
-
y: number;
|
|
462
|
-
/** node name → prior visibility, for the nodes that were hidden. */
|
|
463
|
-
hiddenNodeNames: string[];
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Build the toDataURL crop rect translated to stage output coordinates.
|
|
467
|
-
* Konva's `stage.toDataURL({ x, y, width, height })` takes STAGE OUTPUT
|
|
468
|
-
* coordinates, not document coordinates. When the stage has been scaled to fit
|
|
469
|
-
* (zoom × stageScale), the crop rect in document px must be multiplied by the
|
|
470
|
-
* combined scale to land on the right pixels.
|
|
471
|
-
*
|
|
472
|
-
* `stageScale` is the stage's current uniform scale (scaleX == scaleY);
|
|
473
|
-
* `pixelRatio` is separate and handed directly to toDataURL — Konva multiplies
|
|
474
|
-
* it internally when rendering to the backing canvas, so we must NOT include
|
|
475
|
-
* it in the stage-coordinate rect.
|
|
476
|
-
*/
|
|
477
|
-
declare function documentCropToStageCoords(cropRect: ExportCropRect, stageScale: number, stageX: number, stageY: number): {
|
|
478
|
-
x: number;
|
|
479
|
-
y: number;
|
|
480
|
-
width: number;
|
|
481
|
-
height: number;
|
|
482
|
-
};
|
|
483
|
-
|
|
484
15
|
/**
|
|
485
16
|
* Client-side export for design-canvas pages: raster (PNG/JPEG via Konva
|
|
486
17
|
* stage.toDataURL) and JSON (document serialisation).
|
|
@@ -556,126 +87,6 @@ declare function exportDocumentJson(document: SceneDocument): string;
|
|
|
556
87
|
*/
|
|
557
88
|
declare function downloadDataUrl(dataUrl: string, filename: string): void;
|
|
558
89
|
|
|
559
|
-
/**
|
|
560
|
-
* Pure builders for the human "add element to the canvas" path — the math and
|
|
561
|
-
* `SceneOperation` construction behind {@link CanvasInsertPanel}, separated from
|
|
562
|
-
* the React/DOM layer so every insert is unit-testable without Konva or a
|
|
563
|
-
* browser. The panel calls these to produce `add_element` operations and hands
|
|
564
|
-
* them to the host's `onApplyOperations` (server-validated, undoable) — the same
|
|
565
|
-
* pipeline every other edit flows through.
|
|
566
|
-
*
|
|
567
|
-
* Media boundary: image inserts must pass {@link assertSceneMediaSrc} (remote
|
|
568
|
-
* http(s) or a rooted `/api/` path — never `data:` blobs or sandbox-local
|
|
569
|
-
* files). Builders that take a src assert it up front so a bad url fails here,
|
|
570
|
-
* not deep in the apply layer.
|
|
571
|
-
*/
|
|
572
|
-
|
|
573
|
-
/** Largest dimension (document px) a freshly inserted element is fitted to,
|
|
574
|
-
* before the page-size cap applies. Keeps a huge upload from filling the page. */
|
|
575
|
-
declare const MAX_INSERT_DIMENSION = 600;
|
|
576
|
-
/** Active page geometry an insert lands into — drives centering and fitting. */
|
|
577
|
-
interface InsertPageGeometry {
|
|
578
|
-
pageId: string;
|
|
579
|
-
width: number;
|
|
580
|
-
height: number;
|
|
581
|
-
}
|
|
582
|
-
/** Mint a DOM-safe element id. Prefers `crypto.randomUUID`; falls back to a
|
|
583
|
-
* time+random id where crypto is unavailable (older runtimes, some test envs). */
|
|
584
|
-
declare function mintElementId(): string;
|
|
585
|
-
/** Fit (naturalW, naturalH) under a max-dimension cap (further bounded by the
|
|
586
|
-
* page), preserving aspect ratio. Never upscales past natural size. */
|
|
587
|
-
declare function fittedSize(naturalW: number, naturalH: number, pageWidth: number, pageHeight: number): {
|
|
588
|
-
width: number;
|
|
589
|
-
height: number;
|
|
590
|
-
};
|
|
591
|
-
/** Top-left position that centers a (width, height) box on the page. */
|
|
592
|
-
declare function centeredPosition(width: number, height: number, pageWidth: number, pageHeight: number): {
|
|
593
|
-
x: number;
|
|
594
|
-
y: number;
|
|
595
|
-
};
|
|
596
|
-
/**
|
|
597
|
-
* Build an `add_element` op placing an image, fitted and centered on the page.
|
|
598
|
-
* `naturalSize` is the probed image dimensions (the panel reads them in the
|
|
599
|
-
* browser); pass `{ width: 0, height: 0 }` when unknown to fall back to the cap.
|
|
600
|
-
*
|
|
601
|
-
* Throws (via `assertSceneMediaSrc`) when `src` is not http(s) or a rooted
|
|
602
|
-
* `/api/` path — callers should surface the error, never insert a `data:` src.
|
|
603
|
-
*/
|
|
604
|
-
declare function buildInsertImageOp(src: string, naturalSize: {
|
|
605
|
-
width: number;
|
|
606
|
-
height: number;
|
|
607
|
-
}, page: InsertPageGeometry): SceneOperation;
|
|
608
|
-
/** A template the insert panel can drop without the agent. `build` is pure and
|
|
609
|
-
* produces the operations for the active page geometry. */
|
|
610
|
-
interface InsertTemplate {
|
|
611
|
-
id: string;
|
|
612
|
-
label: string;
|
|
613
|
-
build(page: InsertPageGeometry): SceneOperation[];
|
|
614
|
-
}
|
|
615
|
-
/** The built-in starter templates (heading, body text, rectangle, ellipse).
|
|
616
|
-
* Consumers can pass their own list to {@link CanvasInsertPanel}; this is the
|
|
617
|
-
* default so every canvas gets a usable set out of the box. */
|
|
618
|
-
declare const DEFAULT_INSERT_TEMPLATES: readonly InsertTemplate[];
|
|
619
|
-
|
|
620
|
-
/** Callers inject a workspace renderer so this chrome stays Konva-free. The
|
|
621
|
-
* workspace occupies the scrollable area between the rulers and the bottom bar. */
|
|
622
|
-
interface DesignCanvasFullProps extends DesignCanvasProps {
|
|
623
|
-
/**
|
|
624
|
-
* Render the Konva canvas workspace into the slot this shell provides.
|
|
625
|
-
* The shell passes viewport dimensions, view-state, and the shared command
|
|
626
|
-
* stack so `WorkspaceView` can commit gestures through the same stack the
|
|
627
|
-
* chrome uses for undo/redo and layers-panel selection.
|
|
628
|
-
*
|
|
629
|
-
* `onFitRef` is a ref the workspace fills with a fit-page callback; the
|
|
630
|
-
* shell calls it when the user presses F or clicks the Fit button.
|
|
631
|
-
*/
|
|
632
|
-
renderWorkspace(ctx: {
|
|
633
|
-
document: SceneDocument;
|
|
634
|
-
activePageId: string;
|
|
635
|
-
selectedElementIds: string[];
|
|
636
|
-
zoom: number;
|
|
637
|
-
panX: number;
|
|
638
|
-
panY: number;
|
|
639
|
-
gridEnabled: boolean;
|
|
640
|
-
gridSize: number;
|
|
641
|
-
snapEnabled: boolean;
|
|
642
|
-
showBleed: boolean;
|
|
643
|
-
canWrite: boolean;
|
|
644
|
-
/** The chrome's command stack. Pass to WorkspaceView so gestures, undo,
|
|
645
|
-
* and layers-panel selection share a single state machine. */
|
|
646
|
-
stack: ReturnType<typeof createSceneCommandStack>;
|
|
647
|
-
activePage: SceneDocument['pages'][number] | undefined;
|
|
648
|
-
onFitRef: React.MutableRefObject<(() => void) | null>;
|
|
649
|
-
/** A ref the workspace fills with an export callback. The chrome's Export
|
|
650
|
-
* control calls it with the chosen format/scale; the workspace renders the
|
|
651
|
-
* Konva stage to a data URL and forwards the result to `onExport`. Filled
|
|
652
|
-
* only when `onExport` is wired (the workspace skips it otherwise). */
|
|
653
|
-
onExportRef: React.MutableRefObject<((opts: ExportTriggerOptions) => void) | null>;
|
|
654
|
-
/** Forwarded from DesignCanvasProps. Default true: WorkspaceView fits the
|
|
655
|
-
* active page to the viewport once, on the first non-zero measurement. */
|
|
656
|
-
fitOnMount?: boolean;
|
|
657
|
-
/** Forwarded from DesignCanvasProps. Fires once after the first real
|
|
658
|
-
* measurement, after the initial fit is applied (or skipped). */
|
|
659
|
-
onReady?(): void;
|
|
660
|
-
onZoomChange(zoom: number): void;
|
|
661
|
-
onPanChange(panX: number, panY: number): void;
|
|
662
|
-
onSelectElements(ids: string[], additive: boolean): void;
|
|
663
|
-
}): React.ReactNode;
|
|
664
|
-
/**
|
|
665
|
-
* Generates page thumbnails for the PagesStrip. Injected by the integrator
|
|
666
|
-
* (who has Konva access) so the chrome doesn't import Konva directly.
|
|
667
|
-
*/
|
|
668
|
-
renderThumbnail(page: SceneDocument['pages'][number]): Promise<string | null>;
|
|
669
|
-
}
|
|
670
|
-
declare function DesignCanvas({ document: initialDocument, rev: initialRev, canWrite, onApplyOperations, onSelectionChange, renderAgentPanel, renderSidePanel, onExport, exportDefaults, className, fitOnMount, onReady, renderWorkspace, renderThumbnail, }: DesignCanvasFullProps): react.JSX.Element;
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* Mount this component to get the full editor: toolbar, rulers, layers panel,
|
|
674
|
-
* pages strip, zoom controls, and the Konva canvas — all sharing one command
|
|
675
|
-
* stack so undo/redo and selection are coherent across every surface.
|
|
676
|
-
*/
|
|
677
|
-
declare function DesignCanvasEditor(props: DesignCanvasProps): react.JSX.Element;
|
|
678
|
-
|
|
679
90
|
/** An already-generated image the panel can offer for one-click insertion. */
|
|
680
91
|
interface InsertGeneration {
|
|
681
92
|
id: string;
|
|
@@ -729,8 +140,10 @@ interface WorkspaceViewProps {
|
|
|
729
140
|
fitOnMount?: boolean;
|
|
730
141
|
/** Called once after the first real (non-zero) measurement, after the initial fit is applied (or skipped). */
|
|
731
142
|
onReady?(): void;
|
|
143
|
+
/** Konva render palette. Omitted → light defaults (byte-identical history). */
|
|
144
|
+
render?: CanvasRenderPalette;
|
|
732
145
|
}
|
|
733
|
-
declare function WorkspaceView({ canWrite, onApplyOperations, onSelectionChange, className, stack, activePage, onFitRef, onExport, onExportRef, fitOnMount, onReady, }: WorkspaceViewProps): react.JSX.Element;
|
|
146
|
+
declare function WorkspaceView({ canWrite, onApplyOperations, onSelectionChange, className, stack, activePage, onFitRef, onExport, onExportRef, fitOnMount, onReady, render, }: WorkspaceViewProps): react.JSX.Element;
|
|
734
147
|
/**
|
|
735
148
|
* Self-contained Konva workspace that creates its own command stack. Mount
|
|
736
149
|
* this when you want the canvas without the toolbar/rulers/pages-strip chrome.
|
|
@@ -753,8 +166,10 @@ interface SelectionLayerProps {
|
|
|
753
166
|
onTransformEnd(entries: MultiSetAttrsEntry[]): void;
|
|
754
167
|
/** Active page id — every entry in onTransformEnd carries this. */
|
|
755
168
|
pageId: string;
|
|
169
|
+
/** Theme render palette. Omitted → light defaults (byte-identical history). */
|
|
170
|
+
render?: CanvasRenderPalette;
|
|
756
171
|
}
|
|
757
|
-
declare function SelectionLayer({ stageRef, selectedIds, selectedElements, canWrite, onTransformEnd, pageId, }: SelectionLayerProps): react.JSX.Element;
|
|
172
|
+
declare function SelectionLayer({ stageRef, selectedIds, selectedElements, canWrite, onTransformEnd, pageId, render, }: SelectionLayerProps): react.JSX.Element;
|
|
758
173
|
|
|
759
174
|
interface PagesStripProps {
|
|
760
175
|
pages: ScenePage[];
|
|
@@ -771,8 +186,11 @@ interface PagesStripProps {
|
|
|
771
186
|
onDuplicatePage(pageId: string): void;
|
|
772
187
|
onDeletePage(pageId: string): void;
|
|
773
188
|
onReorderPage(pageId: string, toIndex: number): void;
|
|
189
|
+
/** Show page-management affordances (add / duplicate / delete). Default true.
|
|
190
|
+
* The review surface passes false: pages are navigated, not authored. */
|
|
191
|
+
canManagePages?: boolean;
|
|
774
192
|
}
|
|
775
|
-
declare function PagesStrip({ pages, activePageId, canWrite, renderThumbnail, onSelectPage, onAddPage, onDuplicatePage, onDeletePage, onReorderPage, }: PagesStripProps): react.JSX.Element;
|
|
193
|
+
declare function PagesStrip({ pages, activePageId, canWrite, renderThumbnail, onSelectPage, onAddPage, onDuplicatePage, onDeletePage, onReorderPage, canManagePages, }: PagesStripProps): react.JSX.Element;
|
|
776
194
|
|
|
777
195
|
interface LayersPanelProps {
|
|
778
196
|
page: ScenePage;
|
|
@@ -790,6 +208,12 @@ interface ToolbarProps {
|
|
|
790
208
|
page: ScenePage;
|
|
791
209
|
selectedElements: SceneElement[];
|
|
792
210
|
canWrite: boolean;
|
|
211
|
+
/** Capability mode. `'review'` (the lean reviewer) hides the view toggles,
|
|
212
|
+
* page-props controls, and the destructive/structural selection controls
|
|
213
|
+
* (z-order, group/ungroup, lock, slot, delete), keeping only safe direct
|
|
214
|
+
* edits: text content, image fit/replace, opacity/rotation, undo/redo.
|
|
215
|
+
* Defaults to `'edit'` (the full authoring toolbar). */
|
|
216
|
+
mode?: DesignCanvasMode;
|
|
793
217
|
canUndo: boolean;
|
|
794
218
|
canRedo: boolean;
|
|
795
219
|
gridEnabled: boolean;
|
|
@@ -821,7 +245,7 @@ interface ToolbarProps {
|
|
|
821
245
|
onDelete(elementIds: string[]): void;
|
|
822
246
|
onBindSlot(elementId: string, slot: string | null): void;
|
|
823
247
|
}
|
|
824
|
-
declare function Toolbar({ page, selectedElements, canWrite, canUndo, canRedo, gridEnabled, snapEnabled, showRulers, showBleed, onUndo, onRedo, onToggleGrid, onToggleSnap, onToggleRulers, onToggleBleed, onSetAttrs, onSetPageProps, onSetPageGuides, onReorder, onGroup, onUngroup, onDelete, onBindSlot, }: ToolbarProps): react.JSX.Element;
|
|
248
|
+
declare function Toolbar({ page, selectedElements, canWrite, mode, canUndo, canRedo, gridEnabled, snapEnabled, showRulers, showBleed, onUndo, onRedo, onToggleGrid, onToggleSnap, onToggleRulers, onToggleBleed, onSetAttrs, onSetPageProps, onSetPageGuides, onReorder, onGroup, onUngroup, onDelete, onBindSlot, }: ToolbarProps): react.JSX.Element;
|
|
825
249
|
|
|
826
250
|
/**
|
|
827
251
|
* Canvas zoom controls: fit-to-page, 100%, zoom-out/in buttons, and a percent
|
|
@@ -835,6 +259,20 @@ interface ZoomControlsProps {
|
|
|
835
259
|
}
|
|
836
260
|
declare function ZoomControls({ zoom, onZoom, onFit }: ZoomControlsProps): react.JSX.Element;
|
|
837
261
|
|
|
262
|
+
/** 28px square (h-7) — used by the main toolbar. */
|
|
263
|
+
declare const BTN = "flex h-7 w-7 items-center justify-center rounded border border-[var(--border-default)] text-[var(--text-secondary)] transition hover:text-[var(--text-primary)] focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-input)] disabled:cursor-default disabled:opacity-40";
|
|
264
|
+
declare const BTN_ACTIVE: string;
|
|
265
|
+
/** 24px square (h-6) — used by the zoom controls and pages strip. */
|
|
266
|
+
declare const BTN_SM = "flex h-6 w-6 items-center justify-center rounded border border-[var(--border-default)] text-[var(--text-secondary)] transition hover:text-[var(--text-primary)] focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-input)] disabled:cursor-default disabled:opacity-40";
|
|
267
|
+
declare const BTN_SM_ACTIVE: string;
|
|
268
|
+
interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
269
|
+
/** Render the active (brand-colored) variant. */
|
|
270
|
+
active?: boolean;
|
|
271
|
+
/** 'md' = 28px (toolbar), 'sm' = 24px (zoom/pages). */
|
|
272
|
+
size?: 'md' | 'sm';
|
|
273
|
+
}
|
|
274
|
+
declare const IconButton: react.ForwardRefExoticComponent<IconButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
275
|
+
|
|
838
276
|
interface ExportControlProps {
|
|
839
277
|
/** Pre-selected format/scale when the popover opens. Default PNG @ 1x. */
|
|
840
278
|
defaults?: ExportTriggerOptions;
|
|
@@ -848,22 +286,47 @@ interface ElementNodeProps {
|
|
|
848
286
|
element: SceneElement;
|
|
849
287
|
isSelected: boolean;
|
|
850
288
|
zoom: number;
|
|
289
|
+
/** Theme render palette. Omitted → light defaults (byte-identical history). */
|
|
290
|
+
render?: CanvasRenderPalette;
|
|
851
291
|
onClick?(elementId: string): void;
|
|
852
292
|
onDragStart?(elementId: string): void;
|
|
853
293
|
onDragMove?(elementId: string, dx: number, dy: number): void;
|
|
854
294
|
onDragEnd?(elementId: string, finalX: number, finalY: number): void;
|
|
855
295
|
onDoubleClick?(elementId: string): void;
|
|
856
296
|
}
|
|
857
|
-
declare function
|
|
297
|
+
declare function ElementNodeImpl(props: ElementNodeProps): react.JSX.Element | null;
|
|
298
|
+
/**
|
|
299
|
+
* Memoized so a `stack.notify()` (fired ~120/s during a pan/marquee) that
|
|
300
|
+
* re-renders WorkspaceView does NOT re-render every element. With stable
|
|
301
|
+
* handler identities supplied by WorkspaceView, an ElementNode re-renders only
|
|
302
|
+
* when its OWN `element` reference, `isSelected`, `zoom`, or `render` palette
|
|
303
|
+
* change — i.e. when it actually moved, was (de)selected, or the view scaled.
|
|
304
|
+
* Pan-only frames change none of these props, so the N nodes stay reconciled.
|
|
305
|
+
*/
|
|
306
|
+
declare const ElementNode: react.MemoExoticComponent<typeof ElementNodeImpl>;
|
|
858
307
|
|
|
859
308
|
/**
|
|
860
|
-
* Grid overlay rendered beneath page content.
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
*
|
|
309
|
+
* Grid overlay rendered beneath page content. The whole grid is painted by a
|
|
310
|
+
* SINGLE Konva node — a custom Shape whose `sceneFunc` strokes every grid line
|
|
311
|
+
* in one pass — rather than one Konva.Line per line. At ~hundreds of lines on a
|
|
312
|
+
* page this turns a per-pan-frame reconciliation of hundreds of React/Konva
|
|
313
|
+
* nodes into a single node whose only changing props are the transform; panning
|
|
314
|
+
* no longer churns the scene graph.
|
|
864
315
|
*
|
|
865
|
-
*
|
|
866
|
-
*
|
|
316
|
+
* Grid lines are skipped entirely when they would be closer than 4 screen
|
|
317
|
+
* pixels apart — below that density the grid becomes visual noise rather than
|
|
318
|
+
* guidance (gridVisible density-skip, unchanged).
|
|
319
|
+
*
|
|
320
|
+
* COORDINATE SYSTEM: the lines are authored in document space and wrapped in a
|
|
321
|
+
* Group carrying the SAME (panX, panY, zoom) transform the content layer uses,
|
|
322
|
+
* so the grid tracks the page exactly on pan and zoom. A Konva.Layer cannot
|
|
323
|
+
* live inside a Group, so the transform is applied to an inner Group, not the
|
|
324
|
+
* Layer. The grid is its own Layer (not merged into the content Layer) so the
|
|
325
|
+
* content draws on top without per-frame z-ordering churn.
|
|
326
|
+
*
|
|
327
|
+
* EXPORT EXCLUSION: the Layer carries the name prefix 'overlay:' and the Shape
|
|
328
|
+
* is named 'overlay:grid-shape' so export logic excludes the whole grid from
|
|
329
|
+
* rasterization.
|
|
867
330
|
*/
|
|
868
331
|
interface GridLayerProps {
|
|
869
332
|
/** Page width in document px. */
|
|
@@ -874,12 +337,16 @@ interface GridLayerProps {
|
|
|
874
337
|
gridSize: number;
|
|
875
338
|
/** Screen px per document px. */
|
|
876
339
|
zoom: number;
|
|
340
|
+
/** Horizontal pan offset in screen px (content Group x). */
|
|
341
|
+
panX: number;
|
|
342
|
+
/** Vertical pan offset in screen px (content Group y). */
|
|
343
|
+
panY: number;
|
|
877
344
|
/** Grid line color. */
|
|
878
345
|
color?: string;
|
|
879
346
|
/** Grid line opacity (0–1). */
|
|
880
347
|
opacity?: number;
|
|
881
348
|
}
|
|
882
|
-
declare function GridLayer({ pageWidth, pageHeight, gridSize, zoom, color, opacity, }: GridLayerProps): react.JSX.Element | null;
|
|
349
|
+
declare function GridLayer({ pageWidth, pageHeight, gridSize, zoom, panX, panY, color, opacity, }: GridLayerProps): react.JSX.Element | null;
|
|
883
350
|
|
|
884
351
|
interface RulersProps {
|
|
885
352
|
/** Page width in document px. */
|
|
@@ -1047,9 +514,4 @@ declare function buildRulerTicks(input: {
|
|
|
1047
514
|
* decimals are rounded to 1 place. Values ≥ 1000 are compacted to "1k" etc. */
|
|
1048
515
|
declare function formatRulerLabel(value: number): string;
|
|
1049
516
|
|
|
1050
|
-
|
|
1051
|
-
declare const DesignCanvasLazy: react.LazyExoticComponent<typeof DesignCanvasEditor>;
|
|
1052
|
-
/** Raw chrome only — use when supplying a custom renderWorkspace/renderThumbnail. */
|
|
1053
|
-
declare const DesignCanvasChromeLazy: react.LazyExoticComponent<typeof DesignCanvas>;
|
|
1054
|
-
|
|
1055
|
-
export { type AddElementInput, type AddPageInput, type ApplySceneResult, type BakedNodeAttrs, type BindSlotInput, CanvasInsertPanel, type CanvasInsertPanelProps, DEFAULT_INSERT_TEMPLATES, DUPLICATE_OFFSET, type DeleteElementInput, type DeletePageInput, DesignCanvas, DesignCanvasChromeLazy, DesignCanvasEditor, type DesignCanvasFullProps, DesignCanvasLazy, type DesignCanvasProps, type DuplicatePageInput, type EditorSceneState, ElementNode, type ElementNodeProps, ExportControl, type ExportControlProps, ExportCropRect, type ExportPageDataUrlOptions, ExportPreset, type ExportTriggerOptions, type ExportViewSnapshot, GridLayer, type GridLayerProps, type GroupElementsInput, type InsertGeneration, type InsertPageGeometry, type InsertTemplate, LAYERS_PANEL_ROW_LIMIT, type LayerRow, LayersPanel, type LayersPanelProps, MAX_INSERT_DIMENSION, type MarqueeSelectOptions, type MultiSetAttrsEntry, type NudgeDelta, PagesStrip, type PagesStripProps, type ReorderElementInput, type ReorderPageInput, type ResolvedExportParams, type RulerTick, Rulers, type RulersProps, SCENE_COMMAND_HISTORY_LIMIT, type SceneCommand, type SceneCommandStack, SelectionLayer, type SelectionLayerProps, type SetAttrsInput, type SetDocumentTitleInput, type SetPageGuidesInput, type SetPagePropsInput, type SnapEngine, type SnapResult, type SnapTarget, type SnapTargetKind, type SnapTargets, type TickStep, Toolbar, type ToolbarProps, type TransformerNode, type UngroupElementInput, Workspace, WorkspaceView, type WorkspaceViewProps, ZoomControls, type ZoomControlsProps, type ZoomPanConfig, type ZoomPanMath, addElementCommand, addPageCommand, bakeLineTransform, bakeRectTransform, bakeTextTransform, bindSlotCommand, buildInsertImageOp, buildRulerTicks, centeredPosition, collectGridTargets, createSceneCommandStack, createSnapEngine, createZoomPanMath, deleteElementCommand, deletePageCommand, documentCropToStageCoords, downloadDataUrl, duplicatePageCommand, exportDocumentJson, exportPageDataUrl, fittedSize, flattenLayerTree, formatRulerLabel, groupElementsCommand, identifyTaintedSrc, isCrossOriginSrc, isExportHiddenNodeName, marqueeSelect, mintElementId, multiSetAttrsCommand, nudgeDelta, reorderElementCommand, reorderPageCommand, resolveExportParams, selectTickStep, setAttrsCommand, setDocumentTitleCommand, setPageGuidesCommand, setPagePropsCommand, ungroupElementCommand };
|
|
517
|
+
export { BTN, BTN_ACTIVE, BTN_SM, BTN_SM_ACTIVE, type BakedNodeAttrs, CanvasInsertPanel, type CanvasInsertPanelProps, DesignCanvasMode, DesignCanvasProps, ElementNode, type ElementNodeProps, ExportControl, type ExportControlProps, type ExportPageDataUrlOptions, ExportPreset, ExportTriggerOptions, GridLayer, type GridLayerProps, IconButton, type IconButtonProps, type InsertGeneration, InsertPageGeometry, InsertTemplate, LAYERS_PANEL_ROW_LIMIT, type LayerRow, LayersPanel, type LayersPanelProps, MultiSetAttrsEntry, PagesStrip, type PagesStripProps, type RulerTick, Rulers, type RulersProps, SelectionLayer, type SelectionLayerProps, type TickStep, Toolbar, type ToolbarProps, type TransformerNode, Workspace, WorkspaceView, type WorkspaceViewProps, ZoomControls, type ZoomControlsProps, bakeLineTransform, bakeRectTransform, bakeTextTransform, buildRulerTicks, createSceneCommandStack, downloadDataUrl, exportDocumentJson, exportPageDataUrl, flattenLayerTree, formatRulerLabel, selectTickStep };
|