@widgetic/canvas 0.5.44 → 0.5.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/canvas/DomCanvas.svelte +52 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +59 -34
- package/dist/canvas/host/CanvasHost.d.ts +74 -3
- package/dist/canvas/host/CanvasHost.js +278 -16
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +9 -1
- package/dist/canvas/host/boardFiles.d.ts +90 -0
- package/dist/canvas/host/boardFiles.js +139 -0
- package/dist/canvas/host/browserServices.d.ts +17 -0
- package/dist/canvas/host/browserServices.js +58 -0
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/canvas/ui/SelectionPanel.svelte +78 -17
- package/dist/canvas/ui/ShapesMenu.svelte +65 -31
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
- package/dist/canvas/ui/ToolButton.svelte +34 -55
- package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
- package/dist/canvas/ui/floatingCard.d.ts +26 -4
- package/dist/canvas/ui/floatingCard.js +26 -4
- package/dist/canvas/ui/icons.d.ts +1 -1
- package/dist/canvas/ui/icons.js +1 -1
- package/dist/canvas/ui/selectionTraits.d.ts +12 -0
- package/dist/canvas/ui/selectionTraits.js +26 -1
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
- package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
- package/dist/canvas/view/CanvasStage.svelte +7 -2
- package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
- package/dist/canvas/view/SelectionOverlay.svelte +17 -10
- package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +1 -1
- package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
- package/dist/components/CanvasBoardPoster.svelte +206 -0
- package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte +129 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +15 -0
- package/dist/components/boardLoaderDelay.d.ts +39 -0
- package/dist/components/boardLoaderDelay.js +71 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +8 -0
- package/dist/engine/EngineCore.d.ts +46 -4
- package/dist/engine/EngineCore.js +85 -16
- package/dist/engine/codec/canvasDocument.d.ts +7 -0
- package/dist/engine/codec/canvasDocument.js +25 -2
- package/dist/engine/core/arrow.d.ts +18 -8
- package/dist/engine/core/arrow.js +24 -12
- package/dist/engine/core/arrowBinding.d.ts +1 -1
- package/dist/engine/core/arrowBinding.js +10 -3
- package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
- package/dist/engine/core/arrowBindingRecords.js +10 -6
- package/dist/engine/core/brush.d.ts +8 -0
- package/dist/engine/core/brush.js +10 -2
- package/dist/engine/core/cameraMove.d.ts +6 -0
- package/dist/engine/core/cameraMove.js +6 -0
- package/dist/engine/core/defaults.js +2 -0
- package/dist/engine/core/scene.d.ts +22 -0
- package/dist/engine/core/scene.js +86 -1
- package/dist/engine/core/style.d.ts +10 -0
- package/dist/engine/core/style.js +19 -3
- package/dist/engine/core/transform.d.ts +6 -0
- package/dist/engine/core/transform.js +9 -0
- package/dist/engine/core/types.d.ts +7 -0
- package/dist/engine/input/PointerController.d.ts +15 -1
- package/dist/engine/input/PointerController.js +70 -12
- package/dist/engine/input/gestures.d.ts +3 -1
- package/dist/engine/input/gestures.js +41 -10
- package/dist/engine/input/keyboard.d.ts +22 -3
- package/dist/engine/input/keyboard.js +100 -5
- package/dist/engine/input/types.d.ts +7 -0
- package/dist/engine/state.d.ts +18 -0
- package/dist/engine/state.js +10 -0
- package/dist/fonts/workspaceFonts.d.ts +6 -0
- package/dist/fonts/workspaceFonts.js +44 -29
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.js +6 -0
- package/dist/i18n/shortcuts.d.ts +6 -4
- package/dist/i18n/shortcuts.js +16 -12
- package/dist/index.d.ts +2 -1
- package/dist/poster/boardPlacement.d.ts +80 -0
- package/dist/poster/boardPlacement.js +138 -0
- package/dist/poster/boardPoster.d.ts +80 -0
- package/dist/poster/boardPoster.js +226 -0
- package/dist/poster/paintBoardPoster.d.ts +49 -0
- package/dist/poster/paintBoardPoster.js +89 -0
- package/dist/poster/posterPictures.d.ts +32 -0
- package/dist/poster/posterPictures.js +122 -0
- package/dist/settings/rememberedTool.d.ts +50 -0
- package/dist/settings/rememberedTool.js +68 -0
- package/dist/settings/workspaceToolSettings.d.ts +14 -0
- package/dist/settings/workspaceToolSettings.js +21 -10
- package/dist/tools/definitions.js +26 -4
- package/dist/tools/executors.js +81 -5
- package/dist/tools/hostAdapter.d.ts +5 -1
- package/dist/tools/hostAdapter.js +2 -0
- package/dist/tools/styleArguments.d.ts +35 -0
- package/dist/tools/styleArguments.js +91 -0
- package/dist/tools/types.d.ts +26 -1
- package/dist/tools/types.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ the canvas itself.
|
|
|
77
77
|
|
|
78
78
|
| Keys start with | The words of |
|
|
79
79
|
| --- | --- |
|
|
80
|
-
| `canvas.state.` | "Loading canvas…", the line when the canvas could not start, the name of the board for a screen reader, and the notice when a saved canvas cannot be opened |
|
|
80
|
+
| `canvas.state.` | "Loading canvas…" (the name of the loader for a screen reader: the loader draws no words), the line when the canvas could not start, the name of the board for a screen reader, and the notice when a saved canvas cannot be opened |
|
|
81
81
|
| `canvas.hint.` | the hint on an empty board |
|
|
82
82
|
| `canvas.defaults.`, `canvas.draw.` | what new things start with ("Type here", "Untitled Shape"), and the words a widget card draws (its name when it has none, "Widget preview") |
|
|
83
83
|
| `canvas.toolbar.`, `canvas.tool.`, `canvas.menu.`, `canvas.category.`, `canvas.shape.` | the toolbar: the tools and their hints, the menu of shapes, its groups, and the name of every shape in it |
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
import { onDestroy } from 'svelte';
|
|
23
23
|
import { writable } from 'svelte/store';
|
|
24
24
|
import { Tooltip } from '@widgetic/design-system/components';
|
|
25
|
+
import CanvasBoardPoster from '../components/CanvasBoardPoster.svelte';
|
|
26
|
+
import type { BoardPoster } from '../poster/boardPoster.js';
|
|
27
|
+
import type { PosterPictureResolver } from '../poster/posterPictures.js';
|
|
25
28
|
import { onlyCardIsSelected } from '../engine/widgets.js';
|
|
26
29
|
import { provideCanvasLanguage } from '../i18n/language.js';
|
|
27
30
|
import { BOARD_FRAME_CLASSES } from './boardFrame.js';
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
import type { ToolbarPosition } from './toolbarPosition.js';
|
|
37
40
|
import CanvasContextMenu from './ui/CanvasContextMenu.svelte';
|
|
38
41
|
import CanvasToolbar from './ui/CanvasToolbar.svelte';
|
|
42
|
+
import { CANVAS_TOOLTIP_DELAY_MS, CANVAS_TOOLTIP_SKIP_DELAY_MS } from './ui/floatingCard.js';
|
|
39
43
|
import { FLOATING_LAYER_CLASSES, provideFloatingLayer } from './ui/floatingLayer.js';
|
|
40
44
|
import SelectionPanel from './ui/SelectionPanel.svelte';
|
|
41
45
|
import SelectorIndicator from './ui/SelectorIndicator.svelte';
|
|
@@ -110,6 +114,18 @@
|
|
|
110
114
|
// Use this to keep the loader visible while the host fetches data from API before calling loadCanvas().
|
|
111
115
|
export let isExternalDataLoading: CanvasHostProps['isExternalDataLoading'] = DEFAULT_HOST_PROPS.isExternalDataLoading;
|
|
112
116
|
|
|
117
|
+
// The poster of the board: a small copy of the objects that were in the saved view (`createBoardPoster`), drawn from the first
|
|
118
|
+
// frame and held while the board loads, so a refresh shows the objects at once and not an empty board first. Nothing changes
|
|
119
|
+
// for a page that does not give one. It is a picture of the shell and not a behaviour of the host, so it is not a host prop.
|
|
120
|
+
export let boardPoster: BoardPoster | null = null;
|
|
121
|
+
// The host's image store for the poster: answers the reference of a picture the board keeps there (a photo, the screenshot of a
|
|
122
|
+
// widget card) with its bytes or an address, so the poster draws the card with its picture. Null: those pictures come with the board.
|
|
123
|
+
export let resolveBoardPosterPicture: PosterPictureResolver | null = null;
|
|
124
|
+
// Whether the poster is on the screen now (the poster says it, `bind:visible`). The board draws no spinner over the objects of a
|
|
125
|
+
// poster that is up: the placeholders before the canvas drew none, and one that came back for the moment the board reads its saved
|
|
126
|
+
// text would blink at the hand-over. The layer of the loader stays: input waits and the cursor shows it.
|
|
127
|
+
let boardPosterVisible = false;
|
|
128
|
+
|
|
113
129
|
// Callback fired at the very start of component teardown.
|
|
114
130
|
// Use this in the host page to save canvas state when Vite HMR or navigation destroys this component
|
|
115
131
|
// before the auto-save timer fires.
|
|
@@ -161,6 +177,7 @@
|
|
|
161
177
|
// Callback: fires when a widget card is duplicated/pasted.
|
|
162
178
|
// Receives the source widgetId and the cloned card so the host can duplicate the widget in DB and re-link the clone.
|
|
163
179
|
export let onWidgetShapeDuplicated: CanvasHostProps['onWidgetShapeDuplicated'] = DEFAULT_HOST_PROPS.onWidgetShapeDuplicated;
|
|
180
|
+
export let allowWidgetDuplication: CanvasHostProps['allowWidgetDuplication'] = DEFAULT_HOST_PROPS.allowWidgetDuplication;
|
|
164
181
|
|
|
165
182
|
// Callback: fires when a widget card is about to be deleted.
|
|
166
183
|
// Returns a Promise<boolean>: if true, proceed with deletion; if false, cancel.
|
|
@@ -209,6 +226,18 @@
|
|
|
209
226
|
* Inter the page declares itself.
|
|
210
227
|
*/
|
|
211
228
|
export let interFontSources: CanvasHostProps['interFontSources'] = DEFAULT_HOST_PROPS.interFontSources;
|
|
229
|
+
/**
|
|
230
|
+
* Shows the person's file library (the File Browser of their workspace) in the Shapes menu, before the Image entry. Off by
|
|
231
|
+
* default; it needs `pickFiles`, the page's File Browser (see `BoardFilePicker`), which opens in select state for pictures and
|
|
232
|
+
* vector files. The board puts the files that are chosen down, and never deletes a library file.
|
|
233
|
+
*/
|
|
234
|
+
export let showFileBrowser: CanvasHostProps['showFileBrowser'] = DEFAULT_HOST_PROPS.showFileBrowser;
|
|
235
|
+
export let pickFiles: CanvasHostProps['pickFiles'] = DEFAULT_HOST_PROPS.pickFiles;
|
|
236
|
+
/**
|
|
237
|
+
* Pictures the sketch assistant may put on the board by their id (`add_asset`): the icons of the brand kit and the files of the
|
|
238
|
+
* library. The page builds the list; the board draws what the assistant names.
|
|
239
|
+
*/
|
|
240
|
+
export let sketchAssets: CanvasHostProps['sketchAssets'] = DEFAULT_HOST_PROPS.sketchAssets;
|
|
212
241
|
|
|
213
242
|
/**
|
|
214
243
|
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
@@ -267,6 +296,7 @@
|
|
|
267
296
|
onRecognizeStroke,
|
|
268
297
|
onNonWidgetSelected,
|
|
269
298
|
onWidgetShapeDuplicated,
|
|
299
|
+
allowWidgetDuplication,
|
|
270
300
|
onWidgetShapeDeleting,
|
|
271
301
|
onWidgetRename,
|
|
272
302
|
onRefreshScreenshot,
|
|
@@ -281,9 +311,14 @@
|
|
|
281
311
|
workspaceId,
|
|
282
312
|
userId,
|
|
283
313
|
workspaceFonts,
|
|
284
|
-
interFontSources
|
|
314
|
+
interFontSources,
|
|
315
|
+
showFileBrowser,
|
|
316
|
+
pickFiles,
|
|
317
|
+
sketchAssets
|
|
285
318
|
};
|
|
286
319
|
$: host.setProps(hostProps);
|
|
320
|
+
// The Shapes menu offers the library only when the page asked for it and gave the browser that opens it.
|
|
321
|
+
$: fileBrowserAvailable = showFileBrowser && typeof pickFiles === 'function';
|
|
287
322
|
|
|
288
323
|
/**
|
|
289
324
|
* THE DOM
|
|
@@ -426,13 +461,21 @@
|
|
|
426
461
|
export const executeSketchTool = forwardToHost(host, 'executeSketchTool');
|
|
427
462
|
export const beginSketchToolBatch = forwardToHost(host, 'beginSketchToolBatch');
|
|
428
463
|
export const endSketchToolBatch = forwardToHost(host, 'endSketchToolBatch');
|
|
464
|
+
// The person's file library on the board: the Shapes menu's Files entry, and the calls the page uses to put the pictures that are
|
|
465
|
+
// only on the board into its library (`getBoardPictures`, then `setPictureLibraryFile` for each one it uploaded;
|
|
466
|
+
// `getLoadedBoardPictures` is the same list at once, for the moment the board is about to change).
|
|
467
|
+
export const openFileBrowser = forwardToHost(host, 'openFileBrowser');
|
|
468
|
+
export const insertPickedFiles = forwardToHost(host, 'insertPickedFiles');
|
|
469
|
+
export const getBoardPictures = forwardToHost(host, 'getBoardPictures');
|
|
470
|
+
export const getLoadedBoardPictures = forwardToHost(host, 'getLoadedBoardPictures');
|
|
471
|
+
export const setPictureLibraryFile = forwardToHost(host, 'setPictureLibraryFile');
|
|
429
472
|
// The camera: the view eases to some objects, to a point, or back to 100% on everything drawn (position and zoom together).
|
|
430
473
|
export const flyToObjects = forwardToHost(host, 'flyToObjects');
|
|
431
474
|
export const flyToPoint = forwardToHost(host, 'flyToPoint');
|
|
432
475
|
export const flyToContent = forwardToHost(host, 'flyToContent');
|
|
433
476
|
</script>
|
|
434
477
|
|
|
435
|
-
<Tooltip.Provider delayDuration={
|
|
478
|
+
<Tooltip.Provider delayDuration={CANVAS_TOOLTIP_DELAY_MS} skipDelayDuration={CANVAS_TOOLTIP_SKIP_DELAY_MS}>
|
|
436
479
|
<div
|
|
437
480
|
bind:this={rootElement}
|
|
438
481
|
class="{className ? className + ' ' : ''}canvas-container @container relative isolate h-full w-full overflow-visible text-foreground outline-hidden {showContainerFrame ? BOARD_FRAME_CLASSES : ''}"
|
|
@@ -449,9 +492,15 @@
|
|
|
449
492
|
{loading}
|
|
450
493
|
{showEmptyBoardHint}
|
|
451
494
|
{frameElsewhere}
|
|
495
|
+
posterVisible={boardPosterVisible}
|
|
452
496
|
bind:board={boardElement}
|
|
453
497
|
/>
|
|
454
498
|
|
|
499
|
+
<!-- The poster: the objects of the saved view, drawn before the board has them. Over the board, under the chrome; it fades when the board has painted its own. While it is up the loader draws no spinner over it (`posterVisible`), and the layer of the loader still holds the pointer. -->
|
|
500
|
+
{#if boardPoster}
|
|
501
|
+
<CanvasBoardPoster bind:visible={boardPosterVisible} poster={boardPoster} hold={loading} resolvePicture={resolveBoardPosterPicture} class="z-[1]" />
|
|
502
|
+
{/if}
|
|
503
|
+
|
|
455
504
|
<!-- The chrome: siblings of the board, so a press on a button never reaches it. It waits while the board loads. -->
|
|
456
505
|
<div class="pointer-events-none absolute inset-0 z-10 transition-opacity duration-200 motion-reduce:transition-none {loading ? 'opacity-60' : ''}" inert={loading}>
|
|
457
506
|
<!-- One slot for each place that has a card: the toolbar and the zoom control, side by side when they share a place. -->
|
|
@@ -459,7 +508,7 @@
|
|
|
459
508
|
<div class={slot.classes} data-canvas-slot={slot.anchor}>
|
|
460
509
|
{#each slot.cards as card (card)}
|
|
461
510
|
{#if card === 'toolbar'}
|
|
462
|
-
<CanvasToolbar {host} state={engineState} ui={uiState} {showDrawingTools} anchor={toolbarAnchor} />
|
|
511
|
+
<CanvasToolbar {host} state={engineState} ui={uiState} {showDrawingTools} showFiles={fileBrowserAvailable} anchor={toolbarAnchor} />
|
|
463
512
|
{:else}
|
|
464
513
|
<ZoomControl {host} state={engineState} ui={uiState} anchor={zoomAnchor} visibleMinWidth={zoomVisibleMinWidth} showZoom={showZoomPanel} {showSaveButton} />
|
|
465
514
|
{/if}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BoardPoster } from '../poster/boardPoster.js';
|
|
2
|
+
import type { PosterPictureResolver } from '../poster/posterPictures.js';
|
|
1
3
|
import type { CanvasHostProps, SelectorGuide } from './host/CanvasHost.js';
|
|
2
4
|
import type { PanZoomPosition } from './panZoomPosition.js';
|
|
3
5
|
import type { ToolbarPosition } from './toolbarPosition.js';
|
|
@@ -37,6 +39,8 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
37
39
|
initialData?: CanvasHostProps["initialData"];
|
|
38
40
|
onReady?: CanvasHostProps["onReady"];
|
|
39
41
|
isExternalDataLoading?: CanvasHostProps["isExternalDataLoading"];
|
|
42
|
+
boardPoster?: BoardPoster | null;
|
|
43
|
+
resolveBoardPosterPicture?: PosterPictureResolver | null;
|
|
40
44
|
onBeforeUnmount?: CanvasHostProps["onBeforeUnmount"];
|
|
41
45
|
onAutoSave?: CanvasHostProps["onAutoSave"];
|
|
42
46
|
autosaveDelayMs?: CanvasHostProps["autosaveDelayMs"];
|
|
@@ -50,6 +54,7 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
50
54
|
onRecognizeStroke?: CanvasHostProps["onRecognizeStroke"];
|
|
51
55
|
onNonWidgetSelected?: CanvasHostProps["onNonWidgetSelected"];
|
|
52
56
|
onWidgetShapeDuplicated?: CanvasHostProps["onWidgetShapeDuplicated"];
|
|
57
|
+
allowWidgetDuplication?: CanvasHostProps["allowWidgetDuplication"];
|
|
53
58
|
onWidgetShapeDeleting?: CanvasHostProps["onWidgetShapeDeleting"];
|
|
54
59
|
onWidgetRename?: CanvasHostProps["onWidgetRename"];
|
|
55
60
|
onRefreshScreenshot?: CanvasHostProps["onRefreshScreenshot"];
|
|
@@ -72,6 +77,16 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
72
77
|
* URLs for a page with a strict `font-src`). None by default, so the canvas asks no one for a file and waits for the
|
|
73
78
|
* Inter the page declares itself.
|
|
74
79
|
*/ interFontSources?: CanvasHostProps["interFontSources"];
|
|
80
|
+
/**
|
|
81
|
+
* Shows the person's file library (the File Browser of their workspace) in the Shapes menu, before the Image entry. Off by
|
|
82
|
+
* default; it needs `pickFiles`, the page's File Browser (see `BoardFilePicker`), which opens in select state for pictures and
|
|
83
|
+
* vector files. The board puts the files that are chosen down, and never deletes a library file.
|
|
84
|
+
*/ showFileBrowser?: CanvasHostProps["showFileBrowser"];
|
|
85
|
+
pickFiles?: CanvasHostProps["pickFiles"];
|
|
86
|
+
/**
|
|
87
|
+
* Pictures the sketch assistant may put on the board by their id (`add_asset`): the icons of the brand kit and the files of the
|
|
88
|
+
* library. The page builds the list; the board draws what the assistant names.
|
|
89
|
+
*/ sketchAssets?: CanvasHostProps["sketchAssets"];
|
|
75
90
|
/**
|
|
76
91
|
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
77
92
|
* the page's own words are in; `messages` are the page's own words, keyed like CANVAS_MESSAGES (a key left out
|
|
@@ -86,20 +101,20 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
86
101
|
captureCanvasSketch?: () => Promise<string>;
|
|
87
102
|
absorbCanvasSketchIntoWidget?: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
88
103
|
deselectAll?: () => void;
|
|
89
|
-
duplicateSelectedObjects?: () => import("../engine/core/types
|
|
104
|
+
duplicateSelectedObjects?: () => import("../engine/core/types").ObjectId[];
|
|
90
105
|
deleteSelectedObjects?: () => Promise<boolean>;
|
|
91
106
|
markSelectedAsDuplicating?: () => void;
|
|
92
|
-
linkObjectToWidget?: (target: import("../engine/core/types
|
|
93
|
-
id?: import("../engine/core/types
|
|
94
|
-
_objectId?: import("../engine/core/types
|
|
107
|
+
linkObjectToWidget?: (target: import("../engine/core/types").ObjectId | {
|
|
108
|
+
id?: import("../engine/core/types").ObjectId;
|
|
109
|
+
_objectId?: import("../engine/core/types").ObjectId;
|
|
95
110
|
} | null | undefined, widgetId: string, widgetName?: string | null) => void;
|
|
96
111
|
linkFrameToWidget?: (objectId: string, widgetId: string) => void;
|
|
97
112
|
replaceObjectWithWidgetImage?: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
98
113
|
updateWidgetImage?: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
99
114
|
selectWidgetShape?: (widgetId: string) => boolean;
|
|
100
|
-
listWidgetShapeScreenRects?: (options?: import("./host/screenRects
|
|
101
|
-
getWidgetShapeScreenRect?: (widgetId: string) => import("./host/screenRects
|
|
102
|
-
getObjectScreenRect?: (objectId: string) => import("./host/screenRects
|
|
115
|
+
listWidgetShapeScreenRects?: (options?: import("./host/screenRects").ListWidgetScreenRectsOptions) => import("./host/screenRects").WidgetScreenRect[];
|
|
116
|
+
getWidgetShapeScreenRect?: (widgetId: string) => import("./host/screenRects").ScreenRect | null;
|
|
117
|
+
getObjectScreenRect?: (objectId: string) => import("./host/screenRects").ScreenRect | null;
|
|
103
118
|
getWidgetShapeDataUrl?: (widgetId: string) => string | null;
|
|
104
119
|
setWidgetShapeLivePreviewHiddenImage?: (widgetId: string, hidden: boolean) => void;
|
|
105
120
|
addWidgetShape?: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
@@ -123,7 +138,7 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
123
138
|
setWidgetShapeOverlayDragActive?: (active: boolean) => void;
|
|
124
139
|
selectWidgetShapeById?: (widgetId: string) => boolean;
|
|
125
140
|
getSelectedWidgetShapeId?: () => string | null;
|
|
126
|
-
getSelectedObject?: () => import("./host/hostObject
|
|
141
|
+
getSelectedObject?: () => import("./host/hostObject").HostObject | null;
|
|
127
142
|
getHoveredWidgetShapeId?: () => string | null;
|
|
128
143
|
onSelectImageTool?: () => void;
|
|
129
144
|
onSelectVideoTool?: () => void;
|
|
@@ -144,20 +159,25 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
144
159
|
saveCanvas?: () => string | null;
|
|
145
160
|
loadCanvas?: (jsonString: string) => Promise<void>;
|
|
146
161
|
onClearAllObjects?: () => void;
|
|
147
|
-
addText?: () => import("../engine/core/types
|
|
148
|
-
addTriangle?: () => import("../engine/core/types
|
|
149
|
-
addRect?: () => import("../engine/core/types
|
|
150
|
-
addCircle?: () => import("../engine/core/types
|
|
162
|
+
addText?: () => import("../engine/core/types").ObjectId;
|
|
163
|
+
addTriangle?: () => import("../engine/core/types").ObjectId | null;
|
|
164
|
+
addRect?: () => import("../engine/core/types").ObjectId | null;
|
|
165
|
+
addCircle?: () => import("../engine/core/types").ObjectId | null;
|
|
151
166
|
addFrame?: () => null;
|
|
152
167
|
addImage?: () => Promise<void>;
|
|
153
168
|
removeSketchObjectsKeepingWidget?: (widgetId: string) => number;
|
|
154
|
-
getSketchSceneSummary?: () => import("../tools
|
|
155
|
-
executeSketchTool?: (name: string, args: Record<string, unknown>) => import("../tools
|
|
169
|
+
getSketchSceneSummary?: () => import("../tools").SceneSummary;
|
|
170
|
+
executeSketchTool?: (name: string, args: Record<string, unknown>) => import("../tools").ToolResult;
|
|
156
171
|
beginSketchToolBatch?: () => void;
|
|
157
172
|
endSketchToolBatch?: () => void;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
openFileBrowser?: () => Promise<void>;
|
|
174
|
+
insertPickedFiles?: (files: readonly import(".").BoardLibraryFile[], at?: import("../engine/core/types").Point) => Promise<import("../engine/core/types").ObjectId[]>;
|
|
175
|
+
getBoardPictures?: () => Promise<import(".").BoardPicture[]>;
|
|
176
|
+
getLoadedBoardPictures?: () => import(".").BoardPicture[];
|
|
177
|
+
setPictureLibraryFile?: (objectId: import("../engine/core/types").ObjectId, file: import(".").BoardPictureLibraryFile) => boolean;
|
|
178
|
+
flyToObjects?: (objectIds: readonly string[], options?: import("./types").CanvasFlyOptions) => boolean;
|
|
179
|
+
flyToPoint?: (point: import("../engine/core/types").Point, options?: import("./types").CanvasFlyOptions) => boolean;
|
|
180
|
+
flyToContent?: (options?: import("./types").CanvasMoveOptions) => boolean;
|
|
161
181
|
}, {
|
|
162
182
|
[evt: string]: CustomEvent<any>;
|
|
163
183
|
}, {}, {
|
|
@@ -169,20 +189,20 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
169
189
|
captureCanvasSketch: () => Promise<string>;
|
|
170
190
|
absorbCanvasSketchIntoWidget: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
171
191
|
deselectAll: () => void;
|
|
172
|
-
duplicateSelectedObjects: () => import("../engine/core/types
|
|
192
|
+
duplicateSelectedObjects: () => import("../engine/core/types").ObjectId[];
|
|
173
193
|
deleteSelectedObjects: () => Promise<boolean>;
|
|
174
194
|
markSelectedAsDuplicating: () => void;
|
|
175
|
-
linkObjectToWidget: (target: import("../engine/core/types
|
|
176
|
-
id?: import("../engine/core/types
|
|
177
|
-
_objectId?: import("../engine/core/types
|
|
195
|
+
linkObjectToWidget: (target: import("../engine/core/types").ObjectId | {
|
|
196
|
+
id?: import("../engine/core/types").ObjectId;
|
|
197
|
+
_objectId?: import("../engine/core/types").ObjectId;
|
|
178
198
|
} | null | undefined, widgetId: string, widgetName?: string | null) => void;
|
|
179
199
|
linkFrameToWidget: (objectId: string, widgetId: string) => void;
|
|
180
200
|
replaceObjectWithWidgetImage: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
181
201
|
updateWidgetImage: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
182
202
|
selectWidgetShape: (widgetId: string) => boolean;
|
|
183
|
-
listWidgetShapeScreenRects: (options?: import("./host/screenRects
|
|
184
|
-
getWidgetShapeScreenRect: (widgetId: string) => import("./host/screenRects
|
|
185
|
-
getObjectScreenRect: (objectId: string) => import("./host/screenRects
|
|
203
|
+
listWidgetShapeScreenRects: (options?: import("./host/screenRects").ListWidgetScreenRectsOptions) => import("./host/screenRects").WidgetScreenRect[];
|
|
204
|
+
getWidgetShapeScreenRect: (widgetId: string) => import("./host/screenRects").ScreenRect | null;
|
|
205
|
+
getObjectScreenRect: (objectId: string) => import("./host/screenRects").ScreenRect | null;
|
|
186
206
|
getWidgetShapeDataUrl: (widgetId: string) => string | null;
|
|
187
207
|
setWidgetShapeLivePreviewHiddenImage: (widgetId: string, hidden: boolean) => void;
|
|
188
208
|
addWidgetShape: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
@@ -206,7 +226,7 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
206
226
|
setWidgetShapeOverlayDragActive: (active: boolean) => void;
|
|
207
227
|
selectWidgetShapeById: (widgetId: string) => boolean;
|
|
208
228
|
getSelectedWidgetShapeId: () => string | null;
|
|
209
|
-
getSelectedObject: () => import("./host/hostObject
|
|
229
|
+
getSelectedObject: () => import("./host/hostObject").HostObject | null;
|
|
210
230
|
getHoveredWidgetShapeId: () => string | null;
|
|
211
231
|
onSelectImageTool: () => void;
|
|
212
232
|
onSelectVideoTool: () => void;
|
|
@@ -227,20 +247,25 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
227
247
|
saveCanvas: () => string | null;
|
|
228
248
|
loadCanvas: (jsonString: string) => Promise<void>;
|
|
229
249
|
onClearAllObjects: () => void;
|
|
230
|
-
addText: () => import("../engine/core/types
|
|
231
|
-
addTriangle: () => import("../engine/core/types
|
|
232
|
-
addRect: () => import("../engine/core/types
|
|
233
|
-
addCircle: () => import("../engine/core/types
|
|
250
|
+
addText: () => import("../engine/core/types").ObjectId;
|
|
251
|
+
addTriangle: () => import("../engine/core/types").ObjectId | null;
|
|
252
|
+
addRect: () => import("../engine/core/types").ObjectId | null;
|
|
253
|
+
addCircle: () => import("../engine/core/types").ObjectId | null;
|
|
234
254
|
addFrame: () => null;
|
|
235
255
|
addImage: () => Promise<void>;
|
|
236
256
|
removeSketchObjectsKeepingWidget: (widgetId: string) => number;
|
|
237
|
-
getSketchSceneSummary: () => import("../tools
|
|
238
|
-
executeSketchTool: (name: string, args: Record<string, unknown>) => import("../tools
|
|
257
|
+
getSketchSceneSummary: () => import("../tools").SceneSummary;
|
|
258
|
+
executeSketchTool: (name: string, args: Record<string, unknown>) => import("../tools").ToolResult;
|
|
239
259
|
beginSketchToolBatch: () => void;
|
|
240
260
|
endSketchToolBatch: () => void;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
261
|
+
openFileBrowser: () => Promise<void>;
|
|
262
|
+
insertPickedFiles: (files: readonly import(".").BoardLibraryFile[], at?: import("../engine/core/types").Point) => Promise<import("../engine/core/types").ObjectId[]>;
|
|
263
|
+
getBoardPictures: () => Promise<import(".").BoardPicture[]>;
|
|
264
|
+
getLoadedBoardPictures: () => import(".").BoardPicture[];
|
|
265
|
+
setPictureLibraryFile: (objectId: import("../engine/core/types").ObjectId, file: import(".").BoardPictureLibraryFile) => boolean;
|
|
266
|
+
flyToObjects: (objectIds: readonly string[], options?: import("./types").CanvasFlyOptions) => boolean;
|
|
267
|
+
flyToPoint: (point: import("../engine/core/types").Point, options?: import("./types").CanvasFlyOptions) => boolean;
|
|
268
|
+
flyToContent: (options?: import("./types").CanvasMoveOptions) => boolean;
|
|
244
269
|
}, string>;
|
|
245
270
|
type DomCanvas = InstanceType<typeof DomCanvas>;
|
|
246
271
|
export default DomCanvas;
|
|
@@ -16,7 +16,7 @@ import { EngineCore } from '../../engine/EngineCore.js';
|
|
|
16
16
|
import type { ToolShortcut } from '../../engine/input/keyboard.js';
|
|
17
17
|
import { PointerController } from '../../engine/input/PointerController.js';
|
|
18
18
|
import type { TextLayout } from '../../engine/text/layoutText.js';
|
|
19
|
-
import type { EngineState, ToolId } from '../../engine/state.js';
|
|
19
|
+
import type { EngineState, PenStyle, ToolId } from '../../engine/state.js';
|
|
20
20
|
import { ConversionRegistry } from '../../engine/widgets.js';
|
|
21
21
|
import type { WidgetMetadata } from '../../engine/widgets.js';
|
|
22
22
|
import { type WorkspaceCanvasFont } from '../../fonts/workspaceFonts.js';
|
|
@@ -25,10 +25,12 @@ import type { PanZoomPosition } from '../panZoomPosition.js';
|
|
|
25
25
|
import type { ToolbarPosition } from '../toolbarPosition.js';
|
|
26
26
|
import type { Translate as CatalogTranslate } from '@widgetic/design-system/i18n';
|
|
27
27
|
import type { CanvasMessageKey } from '../../i18n/messages.js';
|
|
28
|
-
import type { CanvasFlyOptions, CanvasMoveOptions, ObjectClickPayload, StrokeRecognizer } from '../types.js';
|
|
28
|
+
import type { CanvasClearCause, CanvasFlyOptions, CanvasMoveOptions, ObjectClickPayload, StrokeRecognizer } from '../types.js';
|
|
29
|
+
import type { BoardFilePicker, BoardLibraryFile, BoardPicture, BoardPictureLibraryFile } from './boardFiles.js';
|
|
29
30
|
import type { LoadedImageFile } from './browserServices.js';
|
|
30
31
|
import type { HostObject } from './hostObject.js';
|
|
31
32
|
import type { ListWidgetScreenRectsOptions, ScreenRect, WidgetScreenRect } from './screenRects.js';
|
|
33
|
+
import type { CanvasToolAsset } from '../../tools/types.js';
|
|
32
34
|
/** The words of the selector's indicator at the top of the board (the line that says how to use the selector). */
|
|
33
35
|
export interface SelectorGuide {
|
|
34
36
|
click: string;
|
|
@@ -99,11 +101,17 @@ export interface CanvasHostProps {
|
|
|
99
101
|
suspendAutosave: boolean;
|
|
100
102
|
showSaveButton: boolean;
|
|
101
103
|
onCanvasDirty: (() => void) | null;
|
|
102
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The board was emptied. `cause` says by whom: the page (`onClearAllObjects()`: `'clear-all'`) or the person (their delete or cut took
|
|
106
|
+
* the last object: `'deleted'`). A handler that takes no argument hears both. Called after `onCanvasDirty` of the same change.
|
|
107
|
+
*/
|
|
108
|
+
onCanvasCleared: ((cause: CanvasClearCause) => void) | null;
|
|
103
109
|
onWidgetImageClick: ((widgetId: string) => void) | null;
|
|
104
110
|
onRecognizeStroke: StrokeRecognizer | null;
|
|
105
111
|
onNonWidgetSelected: (() => void) | null;
|
|
106
112
|
onWidgetShapeDuplicated: ((sourceWidgetId: string, clonedObject: any) => void) | null;
|
|
113
|
+
/** Whether widget cards can be duplicated/pasted on the board. Off in single-widget sketch canvases. */
|
|
114
|
+
allowWidgetDuplication: boolean;
|
|
107
115
|
onWidgetShapeDeleting: ((widgetId: string) => Promise<boolean>) | null;
|
|
108
116
|
onWidgetRename: ((widgetId: string, newName: string) => void) | null;
|
|
109
117
|
onRefreshScreenshot: ((widgetId: string) => void) | null;
|
|
@@ -131,6 +139,21 @@ export interface CanvasHostProps {
|
|
|
131
139
|
* page declares (the design system's `fonts.css` does), so it never requests a path of a page that is not ours.
|
|
132
140
|
*/
|
|
133
141
|
interFontSources: readonly string[];
|
|
142
|
+
/**
|
|
143
|
+
* Whether the Shapes menu offers the person's file library (the File Browser of their workspace) before the Image entry. Off unless
|
|
144
|
+
* the page passes true. It needs `pickFiles`: with no picker there is nothing to open, and the entry is not shown.
|
|
145
|
+
*/
|
|
146
|
+
showFileBrowser: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* The page's File Browser (see `BoardFilePicker`). It opens in select state for pictures and vector files and answers with the
|
|
149
|
+
* files the person chose, which the board puts down. The page owns the browser, the workspace and a partner's media library.
|
|
150
|
+
*/
|
|
151
|
+
pickFiles: BoardFilePicker | null;
|
|
152
|
+
/**
|
|
153
|
+
* Pictures the sketch assistant may put on the board by their id with the `add_asset` tool: the icons of the brand kit, the files
|
|
154
|
+
* of the person's library. The page decides the list (it knows the brand kit and the library); the board only draws what is named.
|
|
155
|
+
*/
|
|
156
|
+
sketchAssets: readonly CanvasToolAsset[];
|
|
134
157
|
}
|
|
135
158
|
/** What each prop is until the page sets it (the values the canvas this one replaces had, but for `panZoomPosition`). */
|
|
136
159
|
export declare const DEFAULT_HOST_PROPS: Readonly<CanvasHostProps>;
|
|
@@ -213,6 +236,18 @@ export declare class CanvasHost {
|
|
|
213
236
|
setProps(patch: Partial<CanvasHostProps>): void;
|
|
214
237
|
/** Persists tool style changes for this workspace (called from the selection panel). */
|
|
215
238
|
persistWorkspaceStyle(patch: StylePatch): void;
|
|
239
|
+
/**
|
|
240
|
+
* Sets the pen, the line the Draw tool draws next (its colour, its width, how much of the board shows through it), and keeps it
|
|
241
|
+
* for this workspace, so the pen is the same when the page is opened again. The settings panel calls it while the Draw tool is
|
|
242
|
+
* chosen and nothing is selected, which is how the pen is set before a line is drawn. The pen is not on the board: nothing that
|
|
243
|
+
* is drawn already changes, and no step of the history is taken.
|
|
244
|
+
*
|
|
245
|
+
* `final` is false while a slider or a colour picker is still being dragged: the pen changes (the next line is drawn with it)
|
|
246
|
+
* and is kept, but the console has one line for the whole drag, written when it ends (`final`, with no patch for the pen).
|
|
247
|
+
*/
|
|
248
|
+
changePenStyle(patch: Partial<PenStyle>, options?: {
|
|
249
|
+
final?: boolean;
|
|
250
|
+
}): void;
|
|
216
251
|
/** The shell gives the host the words of the page's language. */
|
|
217
252
|
setTranslator(translate: Translate): void;
|
|
218
253
|
get ui(): HostUiState;
|
|
@@ -287,6 +322,12 @@ export declare class CanvasHost {
|
|
|
287
322
|
onSelectSelectTool(): void;
|
|
288
323
|
onSelectDrawTool(): void;
|
|
289
324
|
onSelectEraseTool(): void;
|
|
325
|
+
/**
|
|
326
|
+
* The Text tool. The text is on the board the moment the tool is chosen: an empty text, shown as the placeholder prompt, in the
|
|
327
|
+
* middle of the view and ready to be typed in (its field has the focus, so the letters go straight into it). Escape takes it away
|
|
328
|
+
* and the tool with it; a press elsewhere on the board, while nothing is typed, places the text there instead (a drag gives it a
|
|
329
|
+
* width); a press on a text that is already there edits that one.
|
|
330
|
+
*/
|
|
290
331
|
onSelectTextTool(): void;
|
|
291
332
|
onSelectArrowTool(): void;
|
|
292
333
|
onSelectPanTool(): void;
|
|
@@ -357,6 +398,36 @@ export declare class CanvasHost {
|
|
|
357
398
|
addImage(): Promise<void>;
|
|
358
399
|
/** The SVG entry of the shapes menu: the same as `addImage`, but the chooser only offers vector files. */
|
|
359
400
|
addSvg(): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* The Files entry of the Shapes menu: asks the page's File Browser (`pickFiles`) for pictures and vector files of the person's
|
|
403
|
+
* library, in the workspace they are in, and puts the chosen ones on the board as one step. Nothing happens when the page did not
|
|
404
|
+
* turn the entry on (`showFileBrowser`) or gave no picker, when the browser is open already, or when the person closes it without
|
|
405
|
+
* choosing. The picker's answer comes from the page, so it is checked before anything is read (see `normalizeLibraryFiles`).
|
|
406
|
+
*/
|
|
407
|
+
openFileBrowser(): Promise<void>;
|
|
408
|
+
/**
|
|
409
|
+
* Puts files of the person's library on the board, side by side from `at` (the middle of the view by default), as one step. Each
|
|
410
|
+
* picture remembers the library file it is (`libraryFileId`, `libraryFileUrl`), so the page knows it is in the library already. A
|
|
411
|
+
* file that cannot be shown is left out (and said in the console).
|
|
412
|
+
*/
|
|
413
|
+
insertPickedFiles(files: readonly BoardLibraryFile[], at?: Point): Promise<ObjectId[]>;
|
|
414
|
+
/**
|
|
415
|
+
* The pictures that are on the board and where each one comes from: what the page needs to put the ones its library does not have
|
|
416
|
+
* into it (see `setPictureLibraryFile`). Waits for the pictures that are still on their way from the page's store.
|
|
417
|
+
*/
|
|
418
|
+
getBoardPictures(): Promise<BoardPicture[]>;
|
|
419
|
+
/**
|
|
420
|
+
* The same list as `getBoardPictures`, at once and without waiting: the pictures that are on the board now. A picture whose bytes
|
|
421
|
+
* are still on their way from the page's store has `src: null` for the moment. It is for the moment the board is about to change
|
|
422
|
+
* (the sketch becoming the widget's card) and the page has no time to wait, only to take note of what is there: it keeps each
|
|
423
|
+
* picture's `src` and puts the ones its library lacks into it afterwards, when the pictures are no longer on the board.
|
|
424
|
+
*/
|
|
425
|
+
getLoadedBoardPictures(): BoardPicture[];
|
|
426
|
+
/**
|
|
427
|
+
* Remembers that the page's library has the picture of an object now (the page put it there). The picture itself, the history and
|
|
428
|
+
* the selection are left as they are; the board is saved with the new ids. True when something was written.
|
|
429
|
+
*/
|
|
430
|
+
setPictureLibraryFile(objectId: ObjectId, file: BoardPictureLibraryFile): boolean;
|
|
360
431
|
/** Reads picture files and puts them on the board, side by side from `at` (the middle of the view by default), as one step. */
|
|
361
432
|
insertImageFiles(files: readonly (File | Blob)[], at?: Point): Promise<ObjectId[]>;
|
|
362
433
|
insertLoadedImages(pictures: readonly LoadedImageFile[], at?: Point): ObjectId[];
|