@widgetic/canvas 0.5.27 → 0.5.29
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/canvas/Canvas.svelte +166 -4
- package/dist/canvas/Canvas.svelte.d.ts +228 -218
- package/dist/canvas/CanvasToolbar.svelte +6 -3
- package/dist/canvas/CanvasToolbar.svelte.d.ts +66 -60
- package/dist/canvas/ContextMenu.svelte.d.ts +40 -35
- package/dist/canvas/PanZoomPanel.svelte.d.ts +35 -31
- package/dist/canvas/WidgetSelectionLayer.svelte +13 -3
- package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +10 -13
- package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +82 -78
- package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +38 -34
- package/dist/components/CanvasBoardPlaceholder.svelte +11 -9
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +19 -13
- package/dist/components/Tooltip.svelte.d.ts +30 -19
- package/dist/components/input-controls/ColorIC.svelte.d.ts +24 -20
- package/dist/components/input-controls/FontSelectorIC.svelte.d.ts +19 -15
- package/dist/components/input-controls/SliderUnitIC.svelte.d.ts +26 -22
- package/dist/components/input-controls/TextAlignIC.svelte.d.ts +19 -15
- package/dist/components/input-controls/TextStyleIC.svelte.d.ts +23 -19
- package/package.json +3 -2
|
@@ -1,174 +1,85 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Canvas } from 'fabric';
|
|
2
2
|
import type { WidgetConversionPayload, StrokeRecognizer } from './types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
initialData?: string | null;
|
|
29
|
-
onReady?: (() => void) | null;
|
|
30
|
-
isExternalDataLoading?: boolean;
|
|
31
|
-
onBeforeUnmount?: ((json: string | null) => void) | null;
|
|
32
|
-
onAutoSave?: ((json: string | null) => void) | null;
|
|
33
|
-
autosaveDelayMs?: number;
|
|
34
|
-
suspendAutosave?: boolean;
|
|
35
|
-
showSaveButton?: boolean;
|
|
36
|
-
onCanvasDirty?: (() => void) | null;
|
|
37
|
-
onCanvasCleared?: (() => void) | null;
|
|
38
|
-
onConvertToWidget?: ((data: WidgetConversionPayload) => void) | null;
|
|
39
|
-
onWidgetImageClick?: ((widgetId: string) => void) | null;
|
|
40
|
-
onRecognizeStroke?: StrokeRecognizer | null;
|
|
41
|
-
onNonWidgetSelected?: (() => void) | null;
|
|
42
|
-
onWidgetShapeDuplicated?: ((sourceWidgetId: string, clonedObject: any) => void) | null;
|
|
43
|
-
onWidgetShapeDeleting?: ((widgetId: string) => Promise<boolean>) | null;
|
|
44
|
-
onWidgetRename?: ((widgetId: string, newName: string) => void) | null;
|
|
45
|
-
onRefreshScreenshot?: ((widgetId: string) => void) | null;
|
|
46
|
-
/** Host persists canvases.primary_widget_id after Canvas paints the red stroke. */ onSetPrimaryWidget?: ((widgetId: string) => void) | null;
|
|
47
|
-
/** Throttled paint hook for HTML overlays (e.g. live WidgetShape iframes). */ onAfterRender?: (() => void) | null;
|
|
48
|
-
getWidgetName?: ((widgetId: string) => string | null) | null;
|
|
49
|
-
/** Bumped when names change so PropsPanel re-resolves getWidgetName. */ widgetNameRevision?: number;
|
|
50
|
-
/** Returns true when widgetId still exists in the host widget list. */ isWidgetKnown?: ((widgetId: string) => boolean) | null;
|
|
51
|
-
showLogs?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
54
|
-
* the page's own words are in; `messages` are the page's own words, keyed like CANVAS_MESSAGES (a key left out
|
|
55
|
-
* keeps its English text). Without them the canvas speaks English. Both can change while the canvas is open.
|
|
56
|
-
*/ locale?: string | null;
|
|
57
|
-
messages?: Readonly<Record<string, unknown>> | null;
|
|
58
|
-
shapeFillColor?: () => string;
|
|
59
|
-
deselectAll?: () => void;
|
|
60
|
-
duplicateSelectedObjects?: () => Promise<void>;
|
|
61
|
-
deleteSelectedObjects?: () => Promise<void>;
|
|
62
|
-
markSelectedAsDuplicating?: () => void;
|
|
63
|
-
linkObjectToWidget?: (fabricObject: any, widgetId: string, widgetName?: string | null) => void;
|
|
64
|
-
linkFrameToWidget?: (objectId: string, widgetId: string) => void;
|
|
65
|
-
replaceObjectWithWidgetImage?: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
66
|
-
updateWidgetImage?: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
67
|
-
selectWidgetShape?: (widgetId: string) => boolean;
|
|
68
|
-
listWidgetShapeScreenRects?: () => {
|
|
69
|
-
left: number;
|
|
70
|
-
top: number;
|
|
71
|
-
width: number;
|
|
72
|
-
height: number;
|
|
73
|
-
localWidth: number;
|
|
74
|
-
localHeight: number;
|
|
75
|
-
matrix: number[];
|
|
76
|
-
widgetId: string;
|
|
77
|
-
hovered: boolean;
|
|
78
|
-
}[];
|
|
79
|
-
getWidgetShapeScreenRect?: (widgetId: string) => {
|
|
80
|
-
left: number;
|
|
81
|
-
top: number;
|
|
82
|
-
width: number;
|
|
83
|
-
height: number;
|
|
84
|
-
viewportLeft: number;
|
|
85
|
-
viewportTop: number;
|
|
86
|
-
viewportWidth: number;
|
|
87
|
-
viewportHeight: number;
|
|
88
|
-
} | null;
|
|
89
|
-
getObjectScreenRect?: (objectId: string) => {
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const Canvas: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
/**
|
|
18
|
+
* COMPONENT PROPS
|
|
19
|
+
*/ class?: string;
|
|
20
|
+
style?: string;
|
|
21
|
+
/** Site /canvas embed sits flush under AppHeader — skip the 2px frame (double stroke). */ showContainerFrame?: boolean;
|
|
22
|
+
/** Mount native widget controls alongside host HTML previews, never over their entire body. */ widgetSelectionLayerTarget?: string;
|
|
23
|
+
onObjectClick?: ((data: {
|
|
24
|
+
screenshot: string;
|
|
25
|
+
objectType: string;
|
|
26
|
+
customType?: string;
|
|
27
|
+
bounds: {
|
|
90
28
|
left: number;
|
|
91
29
|
top: number;
|
|
92
30
|
width: number;
|
|
93
31
|
height: number;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
addText?: () => void;
|
|
146
|
-
addTriangle?: () => void;
|
|
147
|
-
addRect?: () => void;
|
|
148
|
-
addCircle?: () => void;
|
|
149
|
-
addFrame?: () => void;
|
|
150
|
-
addImage?: () => void;
|
|
151
|
-
};
|
|
152
|
-
events: {
|
|
153
|
-
[evt: string]: CustomEvent<any>;
|
|
154
|
-
};
|
|
155
|
-
slots: {};
|
|
156
|
-
};
|
|
157
|
-
export type CanvasProps = typeof __propDef.props;
|
|
158
|
-
export type CanvasEvents = typeof __propDef.events;
|
|
159
|
-
export type CanvasSlots = typeof __propDef.slots;
|
|
160
|
-
export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEvents, CanvasSlots> {
|
|
161
|
-
get shapeFillColor(): () => string;
|
|
162
|
-
get deselectAll(): () => void;
|
|
163
|
-
get duplicateSelectedObjects(): () => Promise<void>;
|
|
164
|
-
get deleteSelectedObjects(): () => Promise<void>;
|
|
165
|
-
get markSelectedAsDuplicating(): () => void;
|
|
166
|
-
get linkObjectToWidget(): (fabricObject: any, widgetId: string, widgetName?: string | null) => void;
|
|
167
|
-
get linkFrameToWidget(): (objectId: string, widgetId: string) => void;
|
|
168
|
-
get replaceObjectWithWidgetImage(): (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
169
|
-
get updateWidgetImage(): (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
170
|
-
get selectWidgetShape(): (widgetId: string) => boolean;
|
|
171
|
-
get listWidgetShapeScreenRects(): () => {
|
|
32
|
+
};
|
|
33
|
+
objectId: string;
|
|
34
|
+
metadata: Record<string, any>;
|
|
35
|
+
}) => void) | null;
|
|
36
|
+
panZoomPosition?: "TL" | "TC" | "TR" | "BL" | "BC" | "BR";
|
|
37
|
+
wireframeMode?: boolean;
|
|
38
|
+
advancedFeatures?: boolean;
|
|
39
|
+
/** When true and advanced is on, Frame/Image/Video stay on the toolbar. Default true. */ mediaBtsOnBar?: boolean;
|
|
40
|
+
initialData?: string | null;
|
|
41
|
+
onReady?: (() => void) | null;
|
|
42
|
+
isExternalDataLoading?: boolean;
|
|
43
|
+
onBeforeUnmount?: ((json: string | null) => void) | null;
|
|
44
|
+
onAutoSave?: ((json: string | null) => void) | null;
|
|
45
|
+
autosaveDelayMs?: number;
|
|
46
|
+
suspendAutosave?: boolean;
|
|
47
|
+
showSaveButton?: boolean;
|
|
48
|
+
onCanvasDirty?: (() => void) | null;
|
|
49
|
+
onCanvasCleared?: (() => void) | null;
|
|
50
|
+
onConvertToWidget?: ((data: WidgetConversionPayload) => void) | null;
|
|
51
|
+
onWidgetImageClick?: ((widgetId: string) => void) | null;
|
|
52
|
+
onRecognizeStroke?: StrokeRecognizer | null;
|
|
53
|
+
onNonWidgetSelected?: (() => void) | null;
|
|
54
|
+
onWidgetShapeDuplicated?: ((sourceWidgetId: string, clonedObject: any) => void) | null;
|
|
55
|
+
onWidgetShapeDeleting?: ((widgetId: string) => Promise<boolean>) | null;
|
|
56
|
+
onWidgetRename?: ((widgetId: string, newName: string) => void) | null;
|
|
57
|
+
onRefreshScreenshot?: ((widgetId: string) => void) | null;
|
|
58
|
+
/** Host persists canvases.primary_widget_id after Canvas paints the red stroke. */ onSetPrimaryWidget?: ((widgetId: string) => void) | null;
|
|
59
|
+
/** Throttled paint hook for HTML overlays (e.g. live WidgetShape iframes). */ onAfterRender?: (() => void) | null;
|
|
60
|
+
getWidgetName?: ((widgetId: string) => string | null) | null;
|
|
61
|
+
/** Bumped when names change so PropsPanel re-resolves getWidgetName. */ widgetNameRevision?: number;
|
|
62
|
+
/** Returns true when widgetId still exists in the host widget list. */ isWidgetKnown?: ((widgetId: string) => boolean) | null;
|
|
63
|
+
showLogs?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
66
|
+
* the page's own words are in; `messages` are the page's own words, keyed like CANVAS_MESSAGES (a key left out
|
|
67
|
+
* keeps its English text). Without them the canvas speaks English. Both can change while the canvas is open.
|
|
68
|
+
*/ locale?: string | null;
|
|
69
|
+
messages?: Readonly<Record<string, unknown>> | null;
|
|
70
|
+
shapeFillColor?: () => string;
|
|
71
|
+
captureCanvasSketch?: () => Promise<string>;
|
|
72
|
+
absorbCanvasSketchIntoWidget?: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
73
|
+
deselectAll?: () => void;
|
|
74
|
+
duplicateSelectedObjects?: () => Promise<void>;
|
|
75
|
+
deleteSelectedObjects?: () => Promise<void>;
|
|
76
|
+
markSelectedAsDuplicating?: () => void;
|
|
77
|
+
linkObjectToWidget?: (fabricObject: any, widgetId: string, widgetName?: string | null) => void;
|
|
78
|
+
linkFrameToWidget?: (objectId: string, widgetId: string) => void;
|
|
79
|
+
replaceObjectWithWidgetImage?: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
80
|
+
updateWidgetImage?: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
81
|
+
selectWidgetShape?: (widgetId: string) => boolean;
|
|
82
|
+
listWidgetShapeScreenRects?: () => {
|
|
172
83
|
left: number;
|
|
173
84
|
top: number;
|
|
174
85
|
width: number;
|
|
@@ -179,7 +90,7 @@ export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEven
|
|
|
179
90
|
widgetId: string;
|
|
180
91
|
hovered: boolean;
|
|
181
92
|
}[];
|
|
182
|
-
|
|
93
|
+
getWidgetShapeScreenRect?: (widgetId: string) => {
|
|
183
94
|
left: number;
|
|
184
95
|
top: number;
|
|
185
96
|
width: number;
|
|
@@ -189,7 +100,7 @@ export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEven
|
|
|
189
100
|
viewportWidth: number;
|
|
190
101
|
viewportHeight: number;
|
|
191
102
|
} | null;
|
|
192
|
-
|
|
103
|
+
getObjectScreenRect?: (objectId: string) => {
|
|
193
104
|
left: number;
|
|
194
105
|
top: number;
|
|
195
106
|
width: number;
|
|
@@ -199,57 +110,156 @@ export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEven
|
|
|
199
110
|
viewportWidth: number;
|
|
200
111
|
viewportHeight: number;
|
|
201
112
|
} | null;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
113
|
+
getWidgetShapeDataUrl?: (widgetId: string) => string | null;
|
|
114
|
+
setWidgetShapeLivePreviewHiddenImage?: (widgetId: string, hidden: boolean) => void;
|
|
115
|
+
addWidgetShape?: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
116
|
+
getLinkedWidgetIds?: () => Set<string>;
|
|
117
|
+
hydrateWidgetShapeMetadata?: (widgetsById: Map<string, {
|
|
207
118
|
name?: string | null;
|
|
208
119
|
thumbnailUrl?: string | null;
|
|
209
120
|
thumbnail_url?: string | null;
|
|
210
121
|
}>) => number;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
122
|
+
markOrphanedWidgetShapes?: (validWidgetIds: Set<string>) => number;
|
|
123
|
+
onSelectSelectTool?: () => void;
|
|
124
|
+
onSelectLibraryShapeTool?: (shapeKey: string, pathData: string) => void;
|
|
125
|
+
onSelectEraseTool?: () => void;
|
|
126
|
+
onSelectDrawTool?: () => void;
|
|
127
|
+
onSelectTextTool?: () => void;
|
|
128
|
+
onSelectArrowTool?: () => void;
|
|
129
|
+
onSelectShapeTool?: (shapeType: "rect" | "circle" | "circle-true" | "triangle" | "arrow") => void;
|
|
130
|
+
onSelectFrameTool?: () => void;
|
|
131
|
+
setPrimaryWidgetShape?: (widgetId: string) => boolean;
|
|
132
|
+
getPrimaryWidgetId?: () => string | null;
|
|
133
|
+
setWidgetShapeBodyDragAllowed?: (widgetId: string, allowed: boolean) => void;
|
|
134
|
+
translateWidgetShapeByScreen?: (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
135
|
+
commitWidgetShapeTranslate?: (widgetId?: string | null) => void;
|
|
136
|
+
setWidgetShapeOverlayDragActive?: (active: boolean) => void;
|
|
137
|
+
selectWidgetShapeById?: (widgetId: string) => boolean;
|
|
138
|
+
getSelectedWidgetShapeId?: () => string | null;
|
|
139
|
+
getSelectedObject?: () => any;
|
|
140
|
+
getHoveredWidgetShapeId?: () => string | null;
|
|
141
|
+
onSelectImageTool?: () => void;
|
|
142
|
+
onSelectVideoTool?: () => void;
|
|
143
|
+
onSelectPanTool?: () => void;
|
|
144
|
+
zoomIn?: () => void;
|
|
145
|
+
zoomOut?: () => void;
|
|
146
|
+
zoomTo?: (percent: number) => void;
|
|
147
|
+
zoomReset?: () => void;
|
|
148
|
+
zoomFit?: () => void;
|
|
149
|
+
onGroupSelection?: () => string | null;
|
|
150
|
+
onUngroupSelection?: () => void;
|
|
151
|
+
onSelectAllObjects?: () => void;
|
|
152
|
+
onDeselectAllObjects?: () => void;
|
|
153
|
+
saveNow?: () => void;
|
|
154
|
+
undo?: () => Promise<void>;
|
|
155
|
+
redo?: () => Promise<void>;
|
|
156
|
+
saveCanvas?: () => string | null;
|
|
157
|
+
loadCanvas?: (jsonString: string) => Promise<void>;
|
|
158
|
+
onClearAllObjects?: () => void;
|
|
159
|
+
addText?: () => void;
|
|
160
|
+
addTriangle?: () => void;
|
|
161
|
+
addRect?: () => void;
|
|
162
|
+
addCircle?: () => void;
|
|
163
|
+
addFrame?: () => void;
|
|
164
|
+
addImage?: () => void;
|
|
165
|
+
}, {
|
|
166
|
+
[evt: string]: CustomEvent<any>;
|
|
167
|
+
}, {}, {
|
|
168
|
+
shapeFillColor: () => string;
|
|
169
|
+
captureCanvasSketch: () => Promise<string>;
|
|
170
|
+
absorbCanvasSketchIntoWidget: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
171
|
+
deselectAll: () => void;
|
|
172
|
+
duplicateSelectedObjects: () => Promise<void>;
|
|
173
|
+
deleteSelectedObjects: () => Promise<void>;
|
|
174
|
+
markSelectedAsDuplicating: () => void;
|
|
175
|
+
linkObjectToWidget: (fabricObject: any, widgetId: string, widgetName?: string | null) => void;
|
|
176
|
+
linkFrameToWidget: (objectId: string, widgetId: string) => void;
|
|
177
|
+
replaceObjectWithWidgetImage: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
178
|
+
updateWidgetImage: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
179
|
+
selectWidgetShape: (widgetId: string) => boolean;
|
|
180
|
+
listWidgetShapeScreenRects: () => {
|
|
181
|
+
left: number;
|
|
182
|
+
top: number;
|
|
183
|
+
width: number;
|
|
184
|
+
height: number;
|
|
185
|
+
localWidth: number;
|
|
186
|
+
localHeight: number;
|
|
187
|
+
matrix: number[];
|
|
188
|
+
widgetId: string;
|
|
189
|
+
hovered: boolean;
|
|
190
|
+
}[];
|
|
191
|
+
getWidgetShapeScreenRect: (widgetId: string) => {
|
|
192
|
+
left: number;
|
|
193
|
+
top: number;
|
|
194
|
+
width: number;
|
|
195
|
+
height: number;
|
|
196
|
+
viewportLeft: number;
|
|
197
|
+
viewportTop: number;
|
|
198
|
+
viewportWidth: number;
|
|
199
|
+
viewportHeight: number;
|
|
200
|
+
} | null;
|
|
201
|
+
getObjectScreenRect: (objectId: string) => {
|
|
202
|
+
left: number;
|
|
203
|
+
top: number;
|
|
204
|
+
width: number;
|
|
205
|
+
height: number;
|
|
206
|
+
viewportLeft: number;
|
|
207
|
+
viewportTop: number;
|
|
208
|
+
viewportWidth: number;
|
|
209
|
+
viewportHeight: number;
|
|
210
|
+
} | null;
|
|
211
|
+
getWidgetShapeDataUrl: (widgetId: string) => string | null;
|
|
212
|
+
setWidgetShapeLivePreviewHiddenImage: (widgetId: string, hidden: boolean) => void;
|
|
213
|
+
addWidgetShape: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
214
|
+
getLinkedWidgetIds: () => Set<string>;
|
|
215
|
+
hydrateWidgetShapeMetadata: (widgetsById: Map<string, {
|
|
216
|
+
name?: string | null;
|
|
217
|
+
thumbnailUrl?: string | null;
|
|
218
|
+
thumbnail_url?: string | null;
|
|
219
|
+
}>) => number;
|
|
220
|
+
markOrphanedWidgetShapes: (validWidgetIds: Set<string>) => number;
|
|
221
|
+
onSelectSelectTool: () => void;
|
|
222
|
+
onSelectLibraryShapeTool: (shapeKey: string, pathData: string) => void;
|
|
223
|
+
onSelectEraseTool: () => void;
|
|
224
|
+
onSelectDrawTool: () => void;
|
|
225
|
+
onSelectTextTool: () => void;
|
|
226
|
+
onSelectArrowTool: () => void;
|
|
227
|
+
onSelectShapeTool: (shapeType: "rect" | "circle" | "circle-true" | "triangle" | "arrow") => void;
|
|
228
|
+
onSelectFrameTool: () => void;
|
|
229
|
+
setPrimaryWidgetShape: (widgetId: string) => boolean;
|
|
230
|
+
getPrimaryWidgetId: () => string | null;
|
|
231
|
+
setWidgetShapeBodyDragAllowed: (widgetId: string, allowed: boolean) => void;
|
|
232
|
+
translateWidgetShapeByScreen: (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
233
|
+
commitWidgetShapeTranslate: (widgetId?: string | null) => void;
|
|
234
|
+
setWidgetShapeOverlayDragActive: (active: boolean) => void;
|
|
235
|
+
selectWidgetShapeById: (widgetId: string) => boolean;
|
|
236
|
+
getSelectedWidgetShapeId: () => string | null;
|
|
237
|
+
getSelectedObject: () => any;
|
|
238
|
+
getHoveredWidgetShapeId: () => string | null;
|
|
239
|
+
onSelectImageTool: () => void;
|
|
240
|
+
onSelectVideoTool: () => void;
|
|
241
|
+
onSelectPanTool: () => void;
|
|
242
|
+
zoomIn: () => void;
|
|
243
|
+
zoomOut: () => void;
|
|
244
|
+
zoomTo: (percent: number) => void;
|
|
245
|
+
zoomReset: () => void;
|
|
246
|
+
zoomFit: () => void;
|
|
247
|
+
onGroupSelection: () => string | null;
|
|
248
|
+
onUngroupSelection: () => void;
|
|
249
|
+
onSelectAllObjects: () => void;
|
|
250
|
+
onDeselectAllObjects: () => void;
|
|
251
|
+
saveNow: () => void;
|
|
252
|
+
undo: () => Promise<void>;
|
|
253
|
+
redo: () => Promise<void>;
|
|
254
|
+
saveCanvas: () => string | null;
|
|
255
|
+
loadCanvas: (jsonString: string) => Promise<void>;
|
|
256
|
+
onClearAllObjects: () => void;
|
|
257
|
+
addText: () => void;
|
|
258
|
+
addTriangle: () => void;
|
|
259
|
+
addRect: () => void;
|
|
260
|
+
addCircle: () => void;
|
|
261
|
+
addFrame: () => void;
|
|
262
|
+
addImage: () => void;
|
|
263
|
+
}, string>;
|
|
264
|
+
type Canvas = InstanceType<typeof Canvas>;
|
|
265
|
+
export default Canvas;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */
|
|
76
76
|
export let onSelectLibraryShapeTool: (shapeKey: string, pathData: string) => void = () => {};
|
|
77
77
|
|
|
78
|
-
/** Extra tools (undo
|
|
78
|
+
/** Extra tools (undo, redo, lock, shapes). Arrow stays on the simple bar. */
|
|
79
79
|
export let advancedFeatures: boolean = false;
|
|
80
80
|
/**
|
|
81
81
|
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
@@ -106,6 +106,8 @@
|
|
|
106
106
|
// When a library shape was last selected, store its info for the trigger button
|
|
107
107
|
let lastSelectedLibraryShape: LibraryShape | null = null;
|
|
108
108
|
let shapesDropdownOpen = false;
|
|
109
|
+
// The shapes menu is part of the advanced toolbar. Close it when that mode turns off.
|
|
110
|
+
$: if (!advancedFeatures) shapesDropdownOpen = false;
|
|
109
111
|
let shapesDropdownNeedsScroll = false;
|
|
110
112
|
// DEV FLAG: when true the dropdown stays open after selecting a shape so
|
|
111
113
|
// multiple shapes can be placed in a row. Set to false for production.
|
|
@@ -483,7 +485,6 @@
|
|
|
483
485
|
so dropdowns and tooltips are rendered as siblings OUTSIDE this div -->
|
|
484
486
|
<div class="tools-ct flex flex-row">
|
|
485
487
|
{#if advancedFeatures}
|
|
486
|
-
<!-- ── Utility cluster: Undo, Redo, Hand, Lock | Divider ── -->
|
|
487
488
|
<Tooltip text={$t('canvas.tool.undoTitle')}>
|
|
488
489
|
<div class="disabled-tooltip-wrap">
|
|
489
490
|
<button
|
|
@@ -682,7 +683,8 @@
|
|
|
682
683
|
</Tooltip>
|
|
683
684
|
{/if}
|
|
684
685
|
|
|
685
|
-
<!-- Shapes: tldraw-style split — left activates tool, right opens dropdown.
|
|
686
|
+
<!-- Shapes: tldraw-style split — left activates tool, right opens dropdown. Advanced only. -->
|
|
687
|
+
{#if advancedFeatures}
|
|
686
688
|
<div class="shapes-split-ct" bind:this={dropdownTriggerEl}>
|
|
687
689
|
<Tooltip text={dropdownButtonTooltip}>
|
|
688
690
|
<button
|
|
@@ -713,6 +715,7 @@
|
|
|
713
715
|
</button>
|
|
714
716
|
</Tooltip>
|
|
715
717
|
</div>
|
|
718
|
+
{/if}
|
|
716
719
|
</div>
|
|
717
720
|
</div>
|
|
718
721
|
|
|
@@ -1,62 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onSelectEraseTool?: () => void;
|
|
12
|
-
onSelectDrawTool?: () => void;
|
|
13
|
-
onSelectShapeTool?: (shapeType: "rect" | "circle" | "triangle" | "arrow" | "circle-true") => void;
|
|
14
|
-
onSelectFrameTool?: () => void;
|
|
15
|
-
onSelectTextTool?: () => void;
|
|
16
|
-
onSelectPanTool?: () => void;
|
|
17
|
-
onSelectImageTool?: () => void;
|
|
18
|
-
onSelectVideoTool?: () => void;
|
|
19
|
-
onZoomIn?: () => void;
|
|
20
|
-
onZoomOut?: () => void;
|
|
21
|
-
onZoomReset?: () => void;
|
|
22
|
-
onZoomFit?: () => void;
|
|
23
|
-
onGroupSelection?: () => void;
|
|
24
|
-
onUngroupSelection?: () => void;
|
|
25
|
-
onDuplicateSelection?: () => void;
|
|
26
|
-
onSelectAllObjects?: () => void;
|
|
27
|
-
onClearAllObjects?: () => void;
|
|
28
|
-
onUndo?: () => void;
|
|
29
|
-
onRedo?: () => void;
|
|
30
|
-
/** Disables the Undo button when there is no prior state to go back to. */ canUndo?: boolean;
|
|
31
|
-
/** Disables the Redo button when there is no future state to redo to. */ canRedo?: boolean;
|
|
32
|
-
/** When true, the drawing tool stays active after placing a shape. */ stickyToolEnabled?: boolean;
|
|
33
|
-
onToggleStickyTool?: () => void;
|
|
34
|
-
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
35
|
-
* init-set contract without the unused-reactive warning. */ onInsertLibraryShape?: (shapeKey: string, pathData: string) => void;
|
|
36
|
-
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */ onSelectLibraryShapeTool?: (shapeKey: string, pathData: string) => void;
|
|
37
|
-
/** Extra tools (undo/redo/lock). Code stays; UI is gated. */ advancedFeatures?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
40
|
-
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
41
|
-
*/ mediaBtsOnBar?: boolean;
|
|
42
|
-
addText?: () => void;
|
|
43
|
-
addRect?: () => void;
|
|
44
|
-
addTriangle?: () => void;
|
|
45
|
-
addCircle?: () => void;
|
|
46
|
-
addFrame?: () => void;
|
|
47
|
-
addImage?: () => void;
|
|
48
|
-
shortcutsPanelOpen?: boolean;
|
|
49
|
-
onShortcutsToggle?: () => void;
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
50
11
|
};
|
|
51
|
-
|
|
52
|
-
[evt: string]: CustomEvent<any>;
|
|
53
|
-
};
|
|
54
|
-
slots: {};
|
|
55
|
-
};
|
|
56
|
-
export type CanvasToolbarProps = typeof __propDef.props;
|
|
57
|
-
export type CanvasToolbarEvents = typeof __propDef.events;
|
|
58
|
-
export type CanvasToolbarSlots = typeof __propDef.slots;
|
|
59
|
-
export default class CanvasToolbar extends SvelteComponentTyped<CanvasToolbarProps, CanvasToolbarEvents, CanvasToolbarSlots> {
|
|
60
|
-
get onInsertLibraryShape(): (shapeKey: string, pathData: string) => void;
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
61
13
|
}
|
|
62
|
-
|
|
14
|
+
declare const CanvasToolbar: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
class?: string;
|
|
16
|
+
style?: string;
|
|
17
|
+
activeTool?: "select" | "video" | "text" | "rect" | "circle" | "triangle" | "frame" | "arrow" | "image" | "erase" | "draw" | "circle-true" | "pan" | "library-shape";
|
|
18
|
+
activeClass?: string;
|
|
19
|
+
inactiveClass?: string;
|
|
20
|
+
buttonClass?: string;
|
|
21
|
+
onSelectSelectTool?: () => void;
|
|
22
|
+
onSelectEraseTool?: () => void;
|
|
23
|
+
onSelectDrawTool?: () => void;
|
|
24
|
+
onSelectShapeTool?: (shapeType: "rect" | "circle" | "triangle" | "arrow" | "circle-true") => void;
|
|
25
|
+
onSelectFrameTool?: () => void;
|
|
26
|
+
onSelectTextTool?: () => void;
|
|
27
|
+
onSelectPanTool?: () => void;
|
|
28
|
+
onSelectImageTool?: () => void;
|
|
29
|
+
onSelectVideoTool?: () => void;
|
|
30
|
+
onZoomIn?: () => void;
|
|
31
|
+
onZoomOut?: () => void;
|
|
32
|
+
onZoomReset?: () => void;
|
|
33
|
+
onZoomFit?: () => void;
|
|
34
|
+
onGroupSelection?: () => void;
|
|
35
|
+
onUngroupSelection?: () => void;
|
|
36
|
+
onDuplicateSelection?: () => void;
|
|
37
|
+
onSelectAllObjects?: () => void;
|
|
38
|
+
onClearAllObjects?: () => void;
|
|
39
|
+
onUndo?: () => void;
|
|
40
|
+
onRedo?: () => void;
|
|
41
|
+
/** Disables the Undo button when there is no prior state to go back to. */ canUndo?: boolean;
|
|
42
|
+
/** Disables the Redo button when there is no future state to redo to. */ canRedo?: boolean;
|
|
43
|
+
/** When true, the drawing tool stays active after placing a shape. */ stickyToolEnabled?: boolean;
|
|
44
|
+
onToggleStickyTool?: () => void;
|
|
45
|
+
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
46
|
+
* init-set contract without the unused-reactive warning. */ onInsertLibraryShape?: (shapeKey: string, pathData: string) => void;
|
|
47
|
+
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */ onSelectLibraryShapeTool?: (shapeKey: string, pathData: string) => void;
|
|
48
|
+
/** Extra tools (undo, redo, lock, shapes). Arrow stays on the simple bar. */ advancedFeatures?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
51
|
+
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
52
|
+
*/ mediaBtsOnBar?: boolean;
|
|
53
|
+
addText?: () => void;
|
|
54
|
+
addRect?: () => void;
|
|
55
|
+
addTriangle?: () => void;
|
|
56
|
+
addCircle?: () => void;
|
|
57
|
+
addFrame?: () => void;
|
|
58
|
+
addImage?: () => void;
|
|
59
|
+
shortcutsPanelOpen?: boolean;
|
|
60
|
+
onShortcutsToggle?: () => void;
|
|
61
|
+
}, {
|
|
62
|
+
[evt: string]: CustomEvent<any>;
|
|
63
|
+
}, {}, {
|
|
64
|
+
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
65
|
+
* init-set contract without the unused-reactive warning. */ onInsertLibraryShape: (shapeKey: string, pathData: string) => void;
|
|
66
|
+
}, string>;
|
|
67
|
+
type CanvasToolbar = InstanceType<typeof CanvasToolbar>;
|
|
68
|
+
export default CanvasToolbar;
|