@tangle-network/agent-app 0.27.2 → 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/{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-HABVCJJT.js → chunk-7I37CO5D.js} +271 -404
- 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-27LQXQSS.js → chunk-YEWTVDDT.js} +224 -767
- 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 +69 -649
- package/dist/design-canvas-react/index.js +84 -173
- 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 +28 -3
- package/dist/DesignCanvas-73IUJJUP.js +0 -10
- package/dist/DesignCanvasEditor-6F2UTOSW.js +0 -9
- package/dist/chunk-27LQXQSS.js.map +0 -1
- 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-HABVCJJT.js.map +0 -1
- package/dist/chunk-JZAJE3JL.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-73IUJJUP.js.map → DesignCanvas-AOIVN3SJ.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-6F2UTOSW.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,519 +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
|
-
/**
|
|
169
|
-
* Editor capability mode.
|
|
170
|
-
* - `'edit'` (default): the full authoring editor — insert panel, page
|
|
171
|
-
* add/duplicate/delete, layers, grid/snap/ruler/bleed toggles, group/ungroup,
|
|
172
|
-
* z-order. This is the designer surface.
|
|
173
|
-
* - `'review'`: a lean review/tweak surface for agent-authored output. The
|
|
174
|
-
* minimal toolbar exposes only safe direct edits (undo/redo, fit/zoom). The
|
|
175
|
-
* insert panel, blank-page-create, and authoring controls are hidden. Drag,
|
|
176
|
-
* select, double-click-to-edit-text, image swap, the agent panel, and
|
|
177
|
-
* gallery/thumbnail/export all stay. Additive and backward-compatible.
|
|
178
|
-
*/
|
|
179
|
-
type DesignCanvasMode = 'edit' | 'review';
|
|
180
|
-
interface DesignCanvasProps {
|
|
181
|
-
document: SceneDocument;
|
|
182
|
-
/** Revision the document was loaded at; threaded through saves. */
|
|
183
|
-
rev: number;
|
|
184
|
-
canWrite: boolean;
|
|
185
|
-
/** Editor capability mode. Default `'edit'` (full authoring editor). Set
|
|
186
|
-
* `'review'` for a lean reviewer that hides authoring controls but keeps
|
|
187
|
-
* drag/select/text-edit/image-swap and the agent panel. */
|
|
188
|
-
mode?: DesignCanvasMode;
|
|
189
|
-
/** Persist operations. Resolve with the new revision; reject to roll back.
|
|
190
|
-
* A stale-revision failure should resolve AFTER refetch with the fresh
|
|
191
|
-
* document so the editor rebases instead of fighting. */
|
|
192
|
-
onApplyOperations(operations: SceneOperation[]): Promise<ApplySceneResult>;
|
|
193
|
-
onSelectionChange?(elements: SceneElement[]): void;
|
|
194
|
-
/** Host panels: agent chat (right), asset/template browser (left). */
|
|
195
|
-
renderAgentPanel?(ctx: {
|
|
196
|
-
selectedElements: SceneElement[];
|
|
197
|
-
activePageId: string;
|
|
198
|
-
}): React.ReactNode;
|
|
199
|
-
renderSidePanel?(): React.ReactNode;
|
|
200
|
-
/** Export hook — host persists the rendered blob (upload → asset row). */
|
|
201
|
-
onExport?(result: {
|
|
202
|
-
pageId: string;
|
|
203
|
-
format: 'png' | 'jpeg';
|
|
204
|
-
dataUrl: string;
|
|
205
|
-
pixelRatio: number;
|
|
206
|
-
}): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* Optional caller-supplied default for the export popover. The chrome's
|
|
209
|
-
* Export control opens with this format/scale pre-selected. Omitted →
|
|
210
|
-
* PNG @ 1x.
|
|
211
|
-
*/
|
|
212
|
-
exportDefaults?: ExportTriggerOptions;
|
|
213
|
-
className?: string;
|
|
214
|
-
/** 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). */
|
|
215
|
-
fitOnMount?: boolean;
|
|
216
|
-
/** Called once after the first real (non-zero) measurement, after the initial fit is applied (or skipped when fitOnMount is false). */
|
|
217
|
-
onReady?(): void;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Undo/redo command stack over immutable `EditorSceneState`.
|
|
222
|
-
*
|
|
223
|
-
* History entries hold COMMANDS (state transforms + durable operations
|
|
224
|
-
* captured at construction), never snapshots. Rebasing the document via
|
|
225
|
-
* `reset()` therefore cannot stale the history: a later undo re-applies the
|
|
226
|
-
* inverse transform to whatever document is current. If the rebase removed an
|
|
227
|
-
* element a historical command targets, that transform throws (fail loud)
|
|
228
|
-
* rather than silently editing the wrong element.
|
|
229
|
-
*
|
|
230
|
-
* `setView` updates volatile view state (zoom/pan/selection/toggles) without
|
|
231
|
-
* touching history — view changes are never undo steps.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
/** Oldest entries are dropped past this bound; redo stack is cleared on execute. */
|
|
235
|
-
declare const SCENE_COMMAND_HISTORY_LIMIT = 200;
|
|
236
|
-
declare function createSceneCommandStack(document: SceneDocument, activePageId: string): SceneCommandStack;
|
|
237
|
-
|
|
238
|
-
interface AddElementInput {
|
|
239
|
-
pageId: string;
|
|
240
|
-
element: SceneElement;
|
|
241
|
-
/** Insertion z-index within owner; omitted → top. */
|
|
242
|
-
index?: number;
|
|
243
|
-
/** Parent group id; omitted → page root. */
|
|
244
|
-
parentGroupId?: string;
|
|
245
|
-
}
|
|
246
|
-
declare function addElementCommand(input: AddElementInput): SceneCommand;
|
|
247
|
-
interface SetAttrsInput {
|
|
248
|
-
pageId: string;
|
|
249
|
-
elementId: string;
|
|
250
|
-
/** Final attribute values after the gesture. */
|
|
251
|
-
attrs: SceneAttrsPatch;
|
|
252
|
-
/** Attribute values BEFORE the gesture began — inverse is built from these. */
|
|
253
|
-
priorAttrs: SceneAttrsPatch;
|
|
254
|
-
}
|
|
255
|
-
declare function setAttrsCommand(input: SetAttrsInput): SceneCommand;
|
|
256
|
-
interface MultiSetAttrsEntry {
|
|
257
|
-
pageId: string;
|
|
258
|
-
elementId: string;
|
|
259
|
-
attrs: SceneAttrsPatch;
|
|
260
|
-
priorAttrs: SceneAttrsPatch;
|
|
261
|
-
}
|
|
262
|
-
declare function multiSetAttrsCommand(entries: MultiSetAttrsEntry[]): SceneCommand;
|
|
263
|
-
interface ReorderElementInput {
|
|
264
|
-
pageId: string;
|
|
265
|
-
elementId: string;
|
|
266
|
-
toIndex: number;
|
|
267
|
-
}
|
|
268
|
-
declare function reorderElementCommand(input: ReorderElementInput): SceneCommand;
|
|
269
|
-
interface DeleteElementInput {
|
|
270
|
-
document: SceneDocument;
|
|
271
|
-
pageId: string;
|
|
272
|
-
elementId: string;
|
|
273
|
-
}
|
|
274
|
-
declare function deleteElementCommand(input: DeleteElementInput): SceneCommand;
|
|
275
|
-
interface GroupElementsInput {
|
|
276
|
-
document: SceneDocument;
|
|
277
|
-
pageId: string;
|
|
278
|
-
elementIds: string[];
|
|
279
|
-
groupId: string;
|
|
280
|
-
name?: string;
|
|
281
|
-
}
|
|
282
|
-
declare function groupElementsCommand(input: GroupElementsInput): SceneCommand;
|
|
283
|
-
interface UngroupElementInput {
|
|
284
|
-
document: SceneDocument;
|
|
285
|
-
pageId: string;
|
|
286
|
-
groupId: string;
|
|
287
|
-
}
|
|
288
|
-
declare function ungroupElementCommand(input: UngroupElementInput): SceneCommand;
|
|
289
|
-
interface AddPageInput {
|
|
290
|
-
pageId: string;
|
|
291
|
-
options?: NewPageOptions;
|
|
292
|
-
index?: number;
|
|
293
|
-
}
|
|
294
|
-
declare function addPageCommand(input: AddPageInput): SceneCommand;
|
|
295
|
-
interface DuplicatePageInput {
|
|
296
|
-
document: SceneDocument;
|
|
297
|
-
sourcePageId: string;
|
|
298
|
-
/** Caller-minted id for the copy. */
|
|
299
|
-
pageId: string;
|
|
300
|
-
}
|
|
301
|
-
declare function duplicatePageCommand(input: DuplicatePageInput): SceneCommand;
|
|
302
|
-
interface DeletePageInput {
|
|
303
|
-
document: SceneDocument;
|
|
304
|
-
pageId: string;
|
|
305
|
-
}
|
|
306
|
-
declare function deletePageCommand(input: DeletePageInput): SceneCommand;
|
|
307
|
-
interface ReorderPageInput {
|
|
308
|
-
pageId: string;
|
|
309
|
-
toIndex: number;
|
|
310
|
-
}
|
|
311
|
-
declare function reorderPageCommand(input: ReorderPageInput): SceneCommand;
|
|
312
|
-
interface SetPagePropsInput {
|
|
313
|
-
document: SceneDocument;
|
|
314
|
-
pageId: string;
|
|
315
|
-
props: {
|
|
316
|
-
name?: string;
|
|
317
|
-
width?: number;
|
|
318
|
-
height?: number;
|
|
319
|
-
background?: string;
|
|
320
|
-
bleed?: PageBleed | null;
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
declare function setPagePropsCommand(input: SetPagePropsInput): SceneCommand;
|
|
324
|
-
interface SetPageGuidesInput {
|
|
325
|
-
document: SceneDocument;
|
|
326
|
-
pageId: string;
|
|
327
|
-
guides: PageGuides;
|
|
328
|
-
}
|
|
329
|
-
declare function setPageGuidesCommand(input: SetPageGuidesInput): SceneCommand;
|
|
330
|
-
interface BindSlotInput {
|
|
331
|
-
document: SceneDocument;
|
|
332
|
-
pageId: string;
|
|
333
|
-
elementId: string;
|
|
334
|
-
slot: string | null;
|
|
335
|
-
}
|
|
336
|
-
declare function bindSlotCommand(input: BindSlotInput): SceneCommand;
|
|
337
|
-
interface SetDocumentTitleInput {
|
|
338
|
-
document: SceneDocument;
|
|
339
|
-
title: string;
|
|
340
|
-
}
|
|
341
|
-
declare function setDocumentTitleCommand(input: SetDocumentTitleInput): SceneCommand;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* 2-axis snap engine for the design-canvas editor. Targets come from element
|
|
345
|
-
* AABBs (edges + centers), page edges + center, saved guides, and grid lines
|
|
346
|
-
* near the moving bounds. Grid lines are generated lazily in the neighborhood
|
|
347
|
-
* of the moving element, not the full page — avoids allocating thousands of
|
|
348
|
-
* targets on large pages with fine grids.
|
|
349
|
-
*
|
|
350
|
-
* Threshold is a SCREEN distance (pixels), divided by zoom to convert to
|
|
351
|
-
* document units — what "feels close" is a screen distance.
|
|
352
|
-
*
|
|
353
|
-
* Tie-breaking: non-grid kinds beat grid on equal distance; among equals of
|
|
354
|
-
* the same priority the first in iteration order wins.
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
declare function createSnapEngine(): SnapEngine;
|
|
358
|
-
/** Generate grid line targets within a neighborhood around the moving bounds.
|
|
359
|
-
* Call this and append to `SnapTargets.vertical`/`horizontal` before
|
|
360
|
-
* passing to `apply()` when `state.gridEnabled`. */
|
|
361
|
-
declare function collectGridTargets(bounds: Bounds, gridSize: number, page: ScenePage, thresholdDocPx: number): {
|
|
362
|
-
vertical: SnapTarget[];
|
|
363
|
-
horizontal: SnapTarget[];
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Selection math for the design-canvas editor: marquee hit-tests, keyboard
|
|
368
|
-
* nudge deltas, and the duplicate offset constant. Pure functions — no DOM, no
|
|
369
|
-
* Konva, no React.
|
|
370
|
-
*
|
|
371
|
-
* Marquee inclusion: by default any element whose AABB intersects the marquee
|
|
372
|
-
* rect is included (the "touch" model). Pass `requireFullContainment: true` for
|
|
373
|
-
* the "surround" model where the marquee must fully contain the element. Locked
|
|
374
|
-
* and invisible elements are never selected regardless.
|
|
375
|
-
*/
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Top-most selectable element whose AABB contains the document-space point, or
|
|
379
|
-
* null when the point is over empty space.
|
|
380
|
-
*
|
|
381
|
-
* This is the authoritative "is the pointer over an element?" test for the
|
|
382
|
-
* pointer-down gesture router. It runs against the scene model in document
|
|
383
|
-
* coordinates rather than Konva's hit-graph canvas, so it is independent of
|
|
384
|
-
* clip groups, listening flags, and hit-canvas redraw timing — all of which
|
|
385
|
-
* could make `stage.getIntersection` misclassify a press as empty space and
|
|
386
|
-
* silently start a marquee instead of an element drag.
|
|
387
|
-
*
|
|
388
|
-
* Z-order: later elements paint on top, so we scan the array in reverse and
|
|
389
|
-
* return the first hit. Groups descend into children (top child wins); a hit on
|
|
390
|
-
* a group child resolves to the group itself, matching drag/selection which
|
|
391
|
-
* operate on the group as a unit. Locked and invisible elements never hit.
|
|
392
|
-
*/
|
|
393
|
-
declare function hitTestPoint(page: ScenePage, x: number, y: number): string | null;
|
|
394
|
-
interface MarqueeSelectOptions {
|
|
395
|
-
/** When true, the element's AABB must be fully inside the marquee; default is
|
|
396
|
-
* intersection (any overlap selects). */
|
|
397
|
-
requireFullContainment?: boolean;
|
|
398
|
-
}
|
|
399
|
-
/** Returns the ids of selectable elements on `page` whose AABB intersects (or
|
|
400
|
-
* is contained by) `rect`. Locked and invisible elements are excluded. */
|
|
401
|
-
declare function marqueeSelect(page: ScenePage, rect: Bounds, opts?: MarqueeSelectOptions): string[];
|
|
402
|
-
interface NudgeDelta {
|
|
403
|
-
dx: number;
|
|
404
|
-
dy: number;
|
|
405
|
-
}
|
|
406
|
-
/** Map an arrow key to a document-px delta. `shift` engages the 10× step.
|
|
407
|
-
* Throws on unknown keys so callers handle only real nudge keys. */
|
|
408
|
-
declare function nudgeDelta(key: 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown', shift: boolean): NudgeDelta;
|
|
409
|
-
/** Document-px offset applied to duplicated elements so the copy is visually
|
|
410
|
-
* separated from the original (matching common design-tool convention). */
|
|
411
|
-
declare const DUPLICATE_OFFSET: NudgeDelta;
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Zoom + pan coordinate math for the design-canvas editor. Zoom is pixels-per-
|
|
415
|
-
* document-px (e.g. 2 = 200% magnification). The key invariant for wheel-zoom
|
|
416
|
-
* is that the document point under the cursor stays fixed in screen space:
|
|
417
|
-
*
|
|
418
|
-
* docPoint = (screenPoint - pan) / zoom
|
|
419
|
-
* newPan = screenPoint - docPoint * newZoom
|
|
420
|
-
*
|
|
421
|
-
* This module is pure math — no DOM, no Konva, no React.
|
|
422
|
-
*/
|
|
423
|
-
|
|
424
|
-
interface ZoomPanConfig {
|
|
425
|
-
minZoom: number;
|
|
426
|
-
maxZoom: number;
|
|
427
|
-
}
|
|
428
|
-
declare function createZoomPanMath(config: ZoomPanConfig): ZoomPanMath;
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Pure export math for the design-canvas surface — no Konva, no DOM, no React.
|
|
432
|
-
*
|
|
433
|
-
* All stage-interaction code (save/restore, node visibility, toDataURL) lives
|
|
434
|
-
* in export.ts and delegates the decision math here so it can be tested
|
|
435
|
-
* without a canvas environment.
|
|
436
|
-
*/
|
|
437
|
-
|
|
438
|
-
/** Returns true for any Konva node that must be hidden during export. Nodes
|
|
439
|
-
* whose names start with 'overlay:' are editor-only chrome (snap lines,
|
|
440
|
-
* selection indicators, rulers, bleed guides). The transformer node is
|
|
441
|
-
* identified by its canonical name 'Transformer'. */
|
|
442
|
-
declare function isExportHiddenNodeName(name: string): boolean;
|
|
443
|
-
interface ResolvedExportParams {
|
|
444
|
-
cropRect: ExportCropRect;
|
|
445
|
-
pixelRatio: number;
|
|
446
|
-
mimeType: 'image/png' | 'image/jpeg';
|
|
447
|
-
quality: number | undefined;
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Resolve the full set of toDataURL params from a page, format, pixel ratio,
|
|
451
|
-
* bleed flag, and optional preset. When a preset is supplied it overrides
|
|
452
|
-
* `pixelRatio` and `includeBleed` — the explicit args are ignored for those
|
|
453
|
-
* two values so the preset is the single source of truth.
|
|
454
|
-
*
|
|
455
|
-
* `quality` is set to 0.92 for jpeg, undefined for png (Konva ignores it).
|
|
456
|
-
*/
|
|
457
|
-
declare function resolveExportParams(page: ScenePage, opts: {
|
|
458
|
-
format: 'png' | 'jpeg';
|
|
459
|
-
pixelRatio?: number;
|
|
460
|
-
includeBleed?: boolean;
|
|
461
|
-
preset?: ExportPreset;
|
|
462
|
-
}): ResolvedExportParams;
|
|
463
|
-
/**
|
|
464
|
-
* Walk image nodes to find the src of any that may have caused a SecurityError
|
|
465
|
-
* when the stage called toDataURL. Returns the first offending src found, or
|
|
466
|
-
* null if none can be identified.
|
|
467
|
-
*
|
|
468
|
-
* `imageSrcs` is a flat list of { name, src } records collected from all image
|
|
469
|
-
* nodes on the stage before calling toDataURL — export.ts builds it before
|
|
470
|
-
* attempting the export so that if the SecurityError fires we have the data.
|
|
471
|
-
*/
|
|
472
|
-
declare function identifyTaintedSrc(imageSrcs: ReadonlyArray<{
|
|
473
|
-
name: string;
|
|
474
|
-
src: string;
|
|
475
|
-
}>): string | null;
|
|
476
|
-
/**
|
|
477
|
-
* Heuristic: a src is potentially cross-origin when it is an absolute http(s)
|
|
478
|
-
* URL. Same-origin relative paths (/api/...) and data: blobs are safe.
|
|
479
|
-
* This is intentionally conservative — the taint check runs only after a
|
|
480
|
-
* SecurityError fires, so a false positive is "blamed" without being silently
|
|
481
|
-
* ignored. NOTE: same-origin https:// assets will also match; if a
|
|
482
|
-
* SecurityError fires, the cross-origin culprit may be a different image than
|
|
483
|
-
* the one this function flags first.
|
|
484
|
-
*/
|
|
485
|
-
declare function isCrossOriginSrc(src: string): boolean;
|
|
486
|
-
/** Minimal snapshot of stage view state that export.ts saves before mutating
|
|
487
|
-
* zoom/pan/visibility and restores afterward. */
|
|
488
|
-
interface ExportViewSnapshot {
|
|
489
|
-
/** Stage scale factor before export. */
|
|
490
|
-
scaleX: number;
|
|
491
|
-
scaleY: number;
|
|
492
|
-
/** Stage translation before export. */
|
|
493
|
-
x: number;
|
|
494
|
-
y: number;
|
|
495
|
-
/** node name → prior visibility, for the nodes that were hidden. */
|
|
496
|
-
hiddenNodeNames: string[];
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Build the toDataURL crop rect translated to stage output coordinates.
|
|
500
|
-
* Konva's `stage.toDataURL({ x, y, width, height })` takes STAGE OUTPUT
|
|
501
|
-
* coordinates, not document coordinates. When the stage has been scaled to fit
|
|
502
|
-
* (zoom × stageScale), the crop rect in document px must be multiplied by the
|
|
503
|
-
* combined scale to land on the right pixels.
|
|
504
|
-
*
|
|
505
|
-
* `stageScale` is the stage's current uniform scale (scaleX == scaleY);
|
|
506
|
-
* `pixelRatio` is separate and handed directly to toDataURL — Konva multiplies
|
|
507
|
-
* it internally when rendering to the backing canvas, so we must NOT include
|
|
508
|
-
* it in the stage-coordinate rect.
|
|
509
|
-
*/
|
|
510
|
-
declare function documentCropToStageCoords(cropRect: ExportCropRect, stageScale: number, stageX: number, stageY: number): {
|
|
511
|
-
x: number;
|
|
512
|
-
y: number;
|
|
513
|
-
width: number;
|
|
514
|
-
height: number;
|
|
515
|
-
};
|
|
516
|
-
|
|
517
15
|
/**
|
|
518
16
|
* Client-side export for design-canvas pages: raster (PNG/JPEG via Konva
|
|
519
17
|
* stage.toDataURL) and JSON (document serialisation).
|
|
@@ -589,126 +87,6 @@ declare function exportDocumentJson(document: SceneDocument): string;
|
|
|
589
87
|
*/
|
|
590
88
|
declare function downloadDataUrl(dataUrl: string, filename: string): void;
|
|
591
89
|
|
|
592
|
-
/**
|
|
593
|
-
* Pure builders for the human "add element to the canvas" path — the math and
|
|
594
|
-
* `SceneOperation` construction behind {@link CanvasInsertPanel}, separated from
|
|
595
|
-
* the React/DOM layer so every insert is unit-testable without Konva or a
|
|
596
|
-
* browser. The panel calls these to produce `add_element` operations and hands
|
|
597
|
-
* them to the host's `onApplyOperations` (server-validated, undoable) — the same
|
|
598
|
-
* pipeline every other edit flows through.
|
|
599
|
-
*
|
|
600
|
-
* Media boundary: image inserts must pass {@link assertSceneMediaSrc} (remote
|
|
601
|
-
* http(s) or a rooted `/api/` path — never `data:` blobs or sandbox-local
|
|
602
|
-
* files). Builders that take a src assert it up front so a bad url fails here,
|
|
603
|
-
* not deep in the apply layer.
|
|
604
|
-
*/
|
|
605
|
-
|
|
606
|
-
/** Largest dimension (document px) a freshly inserted element is fitted to,
|
|
607
|
-
* before the page-size cap applies. Keeps a huge upload from filling the page. */
|
|
608
|
-
declare const MAX_INSERT_DIMENSION = 600;
|
|
609
|
-
/** Active page geometry an insert lands into — drives centering and fitting. */
|
|
610
|
-
interface InsertPageGeometry {
|
|
611
|
-
pageId: string;
|
|
612
|
-
width: number;
|
|
613
|
-
height: number;
|
|
614
|
-
}
|
|
615
|
-
/** Mint a DOM-safe element id. Prefers `crypto.randomUUID`; falls back to a
|
|
616
|
-
* time+random id where crypto is unavailable (older runtimes, some test envs). */
|
|
617
|
-
declare function mintElementId(): string;
|
|
618
|
-
/** Fit (naturalW, naturalH) under a max-dimension cap (further bounded by the
|
|
619
|
-
* page), preserving aspect ratio. Never upscales past natural size. */
|
|
620
|
-
declare function fittedSize(naturalW: number, naturalH: number, pageWidth: number, pageHeight: number): {
|
|
621
|
-
width: number;
|
|
622
|
-
height: number;
|
|
623
|
-
};
|
|
624
|
-
/** Top-left position that centers a (width, height) box on the page. */
|
|
625
|
-
declare function centeredPosition(width: number, height: number, pageWidth: number, pageHeight: number): {
|
|
626
|
-
x: number;
|
|
627
|
-
y: number;
|
|
628
|
-
};
|
|
629
|
-
/**
|
|
630
|
-
* Build an `add_element` op placing an image, fitted and centered on the page.
|
|
631
|
-
* `naturalSize` is the probed image dimensions (the panel reads them in the
|
|
632
|
-
* browser); pass `{ width: 0, height: 0 }` when unknown to fall back to the cap.
|
|
633
|
-
*
|
|
634
|
-
* Throws (via `assertSceneMediaSrc`) when `src` is not http(s) or a rooted
|
|
635
|
-
* `/api/` path — callers should surface the error, never insert a `data:` src.
|
|
636
|
-
*/
|
|
637
|
-
declare function buildInsertImageOp(src: string, naturalSize: {
|
|
638
|
-
width: number;
|
|
639
|
-
height: number;
|
|
640
|
-
}, page: InsertPageGeometry): SceneOperation;
|
|
641
|
-
/** A template the insert panel can drop without the agent. `build` is pure and
|
|
642
|
-
* produces the operations for the active page geometry. */
|
|
643
|
-
interface InsertTemplate {
|
|
644
|
-
id: string;
|
|
645
|
-
label: string;
|
|
646
|
-
build(page: InsertPageGeometry): SceneOperation[];
|
|
647
|
-
}
|
|
648
|
-
/** The built-in starter templates (heading, body text, rectangle, ellipse).
|
|
649
|
-
* Consumers can pass their own list to {@link CanvasInsertPanel}; this is the
|
|
650
|
-
* default so every canvas gets a usable set out of the box. */
|
|
651
|
-
declare const DEFAULT_INSERT_TEMPLATES: readonly InsertTemplate[];
|
|
652
|
-
|
|
653
|
-
/** Callers inject a workspace renderer so this chrome stays Konva-free. The
|
|
654
|
-
* workspace occupies the scrollable area between the rulers and the bottom bar. */
|
|
655
|
-
interface DesignCanvasFullProps extends DesignCanvasProps {
|
|
656
|
-
/**
|
|
657
|
-
* Render the Konva canvas workspace into the slot this shell provides.
|
|
658
|
-
* The shell passes viewport dimensions, view-state, and the shared command
|
|
659
|
-
* stack so `WorkspaceView` can commit gestures through the same stack the
|
|
660
|
-
* chrome uses for undo/redo and layers-panel selection.
|
|
661
|
-
*
|
|
662
|
-
* `onFitRef` is a ref the workspace fills with a fit-page callback; the
|
|
663
|
-
* shell calls it when the user presses F or clicks the Fit button.
|
|
664
|
-
*/
|
|
665
|
-
renderWorkspace(ctx: {
|
|
666
|
-
document: SceneDocument;
|
|
667
|
-
activePageId: string;
|
|
668
|
-
selectedElementIds: string[];
|
|
669
|
-
zoom: number;
|
|
670
|
-
panX: number;
|
|
671
|
-
panY: number;
|
|
672
|
-
gridEnabled: boolean;
|
|
673
|
-
gridSize: number;
|
|
674
|
-
snapEnabled: boolean;
|
|
675
|
-
showBleed: boolean;
|
|
676
|
-
canWrite: boolean;
|
|
677
|
-
/** The chrome's command stack. Pass to WorkspaceView so gestures, undo,
|
|
678
|
-
* and layers-panel selection share a single state machine. */
|
|
679
|
-
stack: ReturnType<typeof createSceneCommandStack>;
|
|
680
|
-
activePage: SceneDocument['pages'][number] | undefined;
|
|
681
|
-
onFitRef: React.MutableRefObject<(() => void) | null>;
|
|
682
|
-
/** A ref the workspace fills with an export callback. The chrome's Export
|
|
683
|
-
* control calls it with the chosen format/scale; the workspace renders the
|
|
684
|
-
* Konva stage to a data URL and forwards the result to `onExport`. Filled
|
|
685
|
-
* only when `onExport` is wired (the workspace skips it otherwise). */
|
|
686
|
-
onExportRef: React.MutableRefObject<((opts: ExportTriggerOptions) => void) | null>;
|
|
687
|
-
/** Forwarded from DesignCanvasProps. Default true: WorkspaceView fits the
|
|
688
|
-
* active page to the viewport once, on the first non-zero measurement. */
|
|
689
|
-
fitOnMount?: boolean;
|
|
690
|
-
/** Forwarded from DesignCanvasProps. Fires once after the first real
|
|
691
|
-
* measurement, after the initial fit is applied (or skipped). */
|
|
692
|
-
onReady?(): void;
|
|
693
|
-
onZoomChange(zoom: number): void;
|
|
694
|
-
onPanChange(panX: number, panY: number): void;
|
|
695
|
-
onSelectElements(ids: string[], additive: boolean): void;
|
|
696
|
-
}): React.ReactNode;
|
|
697
|
-
/**
|
|
698
|
-
* Generates page thumbnails for the PagesStrip. Injected by the integrator
|
|
699
|
-
* (who has Konva access) so the chrome doesn't import Konva directly.
|
|
700
|
-
*/
|
|
701
|
-
renderThumbnail(page: SceneDocument['pages'][number]): Promise<string | null>;
|
|
702
|
-
}
|
|
703
|
-
declare function DesignCanvas({ document: initialDocument, rev: initialRev, canWrite, mode, onApplyOperations, onSelectionChange, renderAgentPanel, renderSidePanel, onExport, exportDefaults, className, fitOnMount, onReady, renderWorkspace, renderThumbnail, }: DesignCanvasFullProps): react.JSX.Element;
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Mount this component to get the full editor: toolbar, rulers, layers panel,
|
|
707
|
-
* pages strip, zoom controls, and the Konva canvas — all sharing one command
|
|
708
|
-
* stack so undo/redo and selection are coherent across every surface.
|
|
709
|
-
*/
|
|
710
|
-
declare function DesignCanvasEditor(props: DesignCanvasProps): react.JSX.Element;
|
|
711
|
-
|
|
712
90
|
/** An already-generated image the panel can offer for one-click insertion. */
|
|
713
91
|
interface InsertGeneration {
|
|
714
92
|
id: string;
|
|
@@ -762,8 +140,10 @@ interface WorkspaceViewProps {
|
|
|
762
140
|
fitOnMount?: boolean;
|
|
763
141
|
/** Called once after the first real (non-zero) measurement, after the initial fit is applied (or skipped). */
|
|
764
142
|
onReady?(): void;
|
|
143
|
+
/** Konva render palette. Omitted → light defaults (byte-identical history). */
|
|
144
|
+
render?: CanvasRenderPalette;
|
|
765
145
|
}
|
|
766
|
-
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;
|
|
767
147
|
/**
|
|
768
148
|
* Self-contained Konva workspace that creates its own command stack. Mount
|
|
769
149
|
* this when you want the canvas without the toolbar/rulers/pages-strip chrome.
|
|
@@ -786,8 +166,10 @@ interface SelectionLayerProps {
|
|
|
786
166
|
onTransformEnd(entries: MultiSetAttrsEntry[]): void;
|
|
787
167
|
/** Active page id — every entry in onTransformEnd carries this. */
|
|
788
168
|
pageId: string;
|
|
169
|
+
/** Theme render palette. Omitted → light defaults (byte-identical history). */
|
|
170
|
+
render?: CanvasRenderPalette;
|
|
789
171
|
}
|
|
790
|
-
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;
|
|
791
173
|
|
|
792
174
|
interface PagesStripProps {
|
|
793
175
|
pages: ScenePage[];
|
|
@@ -877,6 +259,20 @@ interface ZoomControlsProps {
|
|
|
877
259
|
}
|
|
878
260
|
declare function ZoomControls({ zoom, onZoom, onFit }: ZoomControlsProps): react.JSX.Element;
|
|
879
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
|
+
|
|
880
276
|
interface ExportControlProps {
|
|
881
277
|
/** Pre-selected format/scale when the popover opens. Default PNG @ 1x. */
|
|
882
278
|
defaults?: ExportTriggerOptions;
|
|
@@ -890,22 +286,47 @@ interface ElementNodeProps {
|
|
|
890
286
|
element: SceneElement;
|
|
891
287
|
isSelected: boolean;
|
|
892
288
|
zoom: number;
|
|
289
|
+
/** Theme render palette. Omitted → light defaults (byte-identical history). */
|
|
290
|
+
render?: CanvasRenderPalette;
|
|
893
291
|
onClick?(elementId: string): void;
|
|
894
292
|
onDragStart?(elementId: string): void;
|
|
895
293
|
onDragMove?(elementId: string, dx: number, dy: number): void;
|
|
896
294
|
onDragEnd?(elementId: string, finalX: number, finalY: number): void;
|
|
897
295
|
onDoubleClick?(elementId: string): void;
|
|
898
296
|
}
|
|
899
|
-
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>;
|
|
900
307
|
|
|
901
308
|
/**
|
|
902
|
-
* Grid overlay rendered beneath page content.
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
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.
|
|
315
|
+
*
|
|
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.
|
|
906
326
|
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
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.
|
|
909
330
|
*/
|
|
910
331
|
interface GridLayerProps {
|
|
911
332
|
/** Page width in document px. */
|
|
@@ -916,12 +337,16 @@ interface GridLayerProps {
|
|
|
916
337
|
gridSize: number;
|
|
917
338
|
/** Screen px per document px. */
|
|
918
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;
|
|
919
344
|
/** Grid line color. */
|
|
920
345
|
color?: string;
|
|
921
346
|
/** Grid line opacity (0–1). */
|
|
922
347
|
opacity?: number;
|
|
923
348
|
}
|
|
924
|
-
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;
|
|
925
350
|
|
|
926
351
|
interface RulersProps {
|
|
927
352
|
/** Page width in document px. */
|
|
@@ -1089,9 +514,4 @@ declare function buildRulerTicks(input: {
|
|
|
1089
514
|
* decimals are rounded to 1 place. Values ≥ 1000 are compacted to "1k" etc. */
|
|
1090
515
|
declare function formatRulerLabel(value: number): string;
|
|
1091
516
|
|
|
1092
|
-
|
|
1093
|
-
declare const DesignCanvasLazy: react.LazyExoticComponent<typeof DesignCanvasEditor>;
|
|
1094
|
-
/** Raw chrome only — use when supplying a custom renderWorkspace/renderThumbnail. */
|
|
1095
|
-
declare const DesignCanvasChromeLazy: react.LazyExoticComponent<typeof DesignCanvas>;
|
|
1096
|
-
|
|
1097
|
-
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 DesignCanvasMode, 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, hitTestPoint, 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 };
|