@widgetic/canvas 0.5.42 → 0.5.43
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 -0
- package/dist/canvas/DomCanvas.svelte +49 -20
- package/dist/canvas/DomCanvas.svelte.d.ts +13 -7
- package/dist/canvas/chromeLayout.d.ts +14 -3
- package/dist/canvas/chromeLayout.js +14 -3
- package/dist/canvas/host/CanvasHost.d.ts +47 -5
- package/dist/canvas/host/CanvasHost.js +256 -91
- package/dist/canvas/host/nearCards.d.ts +33 -0
- package/dist/canvas/host/nearCards.js +78 -0
- package/dist/canvas/host/pageEvents.d.ts +16 -4
- package/dist/canvas/host/pageEvents.js +13 -4
- package/dist/canvas/host/pictureSaves.d.ts +33 -0
- package/dist/canvas/host/pictureSaves.js +42 -0
- package/dist/canvas/host/screenRects.d.ts +5 -0
- package/dist/canvas/host/storedPictures.d.ts +88 -0
- package/dist/canvas/host/storedPictures.js +288 -0
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/shapes/shapeImageStore.d.ts +45 -2
- package/dist/canvas/shapes/shapeImageStore.js +7 -0
- package/dist/canvas/toolbarPosition.d.ts +2 -2
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/ui/SelectionPanel.svelte +28 -5
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/SelectorIndicator.svelte +81 -0
- package/dist/canvas/ui/SelectorIndicator.svelte.d.ts +11 -0
- package/dist/canvas/ui/ToolButton.svelte +8 -2
- package/dist/canvas/ui/floatingCard.d.ts +2 -2
- package/dist/canvas/ui/floatingCard.js +2 -2
- package/dist/canvas/ui/floatingLayer.d.ts +13 -2
- package/dist/canvas/ui/floatingLayer.js +14 -2
- package/dist/canvas/view/CanvasStage.svelte +101 -67
- package/dist/canvas/view/LeftToRightScope.svelte +21 -0
- package/dist/canvas/view/LeftToRightScope.svelte.d.ts +7 -0
- package/dist/canvas/view/ObjectView.svelte +15 -10
- package/dist/canvas/view/ObjectView.svelte.d.ts +1 -1
- package/dist/canvas/view/liftedScene.d.ts +31 -0
- package/dist/canvas/view/liftedScene.js +146 -0
- package/dist/canvas/view/mountedScene.d.ts +71 -0
- package/dist/canvas/view/mountedScene.js +363 -0
- package/dist/engine/EngineCore.d.ts +15 -1
- package/dist/engine/EngineCore.js +30 -4
- package/dist/engine/codec/canvasDocument.d.ts +5 -0
- package/dist/engine/codec/canvasDocument.js +31 -4
- package/dist/engine/core/history.d.ts +6 -0
- package/dist/engine/core/history.js +16 -0
- package/dist/engine/core/scene.d.ts +10 -0
- package/dist/engine/core/scene.js +24 -0
- package/dist/engine/core/types.d.ts +8 -2
- package/dist/engine/input/gestures.js +4 -2
- package/dist/engine/state.d.ts +20 -0
- package/dist/engine/state.js +1 -0
- package/dist/fonts/interFont.d.ts +10 -1
- package/dist/fonts/interFont.js +36 -13
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +8 -1
- package/dist/i18n/messages.js +9 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/canvas/ui/SelectorBar.svelte +0 -84
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +0 -12
package/README.md
CHANGED
|
@@ -217,6 +217,7 @@ ORIGIN=http://127.0.0.1:5181 node scripts/browser/conformance.mjs # the host c
|
|
|
217
217
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/interaction.mjs # a real mouse and keyboard: tools, gestures, keys
|
|
218
218
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/shadow.mjs # inside a shadow root, as the UI SDK mounts it
|
|
219
219
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/widgetCard.mjs # a live widget laid over a card
|
|
220
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/selector.mjs # the element selector: its indicator, the toolbar that stays, a card with no placeholder
|
|
220
221
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/touch.mjs # touch and pen
|
|
221
222
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/responsive.mjs # the Figma layouts at desktop, tablet and phone widths
|
|
222
223
|
ORIGIN=http://127.0.0.1:5181 node scripts/browser/a11y.mjs # the accessibility tree, focus, reduced motion
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
import { CanvasHost, DEFAULT_HOST_PROPS } from './host/CanvasHost.js';
|
|
30
30
|
import type { CanvasHostProps, SelectorGuide } from './host/CanvasHost.js';
|
|
31
31
|
import { forwardToHost } from './host/CanvasHostApi.js';
|
|
32
|
-
import { chromeSlots, panelClearanceFor, zoomVisibilityMinWidth } from './chromeLayout.js';
|
|
32
|
+
import { chromeSlots, panelClearanceFor, selectorIndicatorTopClassFor, zoomVisibilityMinWidth } from './chromeLayout.js';
|
|
33
33
|
import { DEFAULT_PAN_ZOOM_POSITION, normalizePanZoomPosition } from './panZoomPosition.js';
|
|
34
34
|
import type { PanZoomPosition } from './panZoomPosition.js';
|
|
35
35
|
import { DEFAULT_TOOLBAR_POSITION, normalizeToolbarPosition } from './toolbarPosition.js';
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
import CanvasToolbar from './ui/CanvasToolbar.svelte';
|
|
39
39
|
import { FLOATING_LAYER_CLASSES, provideFloatingLayer } from './ui/floatingLayer.js';
|
|
40
40
|
import SelectionPanel from './ui/SelectionPanel.svelte';
|
|
41
|
-
import
|
|
41
|
+
import SelectorIndicator from './ui/SelectorIndicator.svelte';
|
|
42
42
|
import ShortcutsPanel from './ui/ShortcutsPanel.svelte';
|
|
43
43
|
import ZoomControl from './ui/ZoomControl.svelte';
|
|
44
44
|
import { shouldShowEmptyBoardHint } from './emptyBoardHint.js';
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
export let panZoomPosition: PanZoomPosition = DEFAULT_PAN_ZOOM_POSITION;
|
|
69
69
|
|
|
70
70
|
// Where the drawing toolbar stands: any of the same eight places (BC, the bottom centre, is the default). On the left or
|
|
71
|
-
// the right edge it stands upright, and its menus open sideways.
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
71
|
+
// the right edge it stands upright, and its menus open sideways. A host that has something of its own at the bottom
|
|
72
|
+
// centre of the page (Shopify's Sidekick) names the place it wants; two cards named for one place stand side by side.
|
|
73
|
+
// Anything that is not one of the eight is the bottom centre. (The toolbar stays after the first generation: the
|
|
74
|
+
// selector's indicator is a card of its own at the top.)
|
|
75
75
|
export let toolbarPosition: ToolbarPosition = DEFAULT_TOOLBAR_POSITION;
|
|
76
76
|
|
|
77
77
|
// Wireframe mode: hides the colour fields of the selection panel and keeps new objects white with a dark stroke
|
|
@@ -82,13 +82,17 @@
|
|
|
82
82
|
// panel) is always there. Default off for the sketch MVP.
|
|
83
83
|
export let advancedFeatures: CanvasHostProps['advancedFeatures'] = DEFAULT_HOST_PROPS.advancedFeatures;
|
|
84
84
|
|
|
85
|
-
/** The
|
|
85
|
+
/** The selector's indicator at the top of the board: shown while the page says so (a widget stands on the board and the hint is not closed). */
|
|
86
86
|
export let showElementSelector: CanvasHostProps['showElementSelector'] = DEFAULT_HOST_PROPS.showElementSelector;
|
|
87
|
-
/**
|
|
87
|
+
/** The drawing toolbar. The page keeps it for as long as the board is drawn on, widget or not. */
|
|
88
88
|
export let showDrawingTools: CanvasHostProps['showDrawingTools'] = DEFAULT_HOST_PROPS.showDrawingTools;
|
|
89
|
+
/** The page's element selector is picking now: the indicator says "Selector on", and the arrow keys are the selector's. */
|
|
89
90
|
export let elementSelectorActive: CanvasHostProps['elementSelectorActive'] = DEFAULT_HOST_PROPS.elementSelectorActive;
|
|
91
|
+
/** Accepted for the pages that set it: the Select tool turns the selector on and off now. */
|
|
90
92
|
export let onToggleElementSelector: CanvasHostProps['onToggleElementSelector'] = DEFAULT_HOST_PROPS.onToggleElementSelector;
|
|
91
|
-
/**
|
|
93
|
+
/** The person closed the selector's indicator. The page decides when it comes back. */
|
|
94
|
+
export let onDismissElementSelectorHint: CanvasHostProps['onDismissElementSelectorHint'] = DEFAULT_HOST_PROPS.onDismissElementSelectorHint;
|
|
95
|
+
/** Words for the selector's indicator. */
|
|
92
96
|
export let selectorGuide: SelectorGuide | null = DEFAULT_HOST_PROPS.selectorGuide;
|
|
93
97
|
/** The zoom card. Off on the site when debug is off. The save control stays. */
|
|
94
98
|
export let showZoomPanel: CanvasHostProps['showZoomPanel'] = DEFAULT_HOST_PROPS.showZoomPanel;
|
|
@@ -199,6 +203,12 @@
|
|
|
199
203
|
export let userId: CanvasHostProps['userId'] = DEFAULT_HOST_PROPS.userId;
|
|
200
204
|
/** Brand-kit fonts for this workspace (B15). */
|
|
201
205
|
export let workspaceFonts: CanvasHostProps['workspaceFonts'] = DEFAULT_HOST_PROPS.workspaceFonts;
|
|
206
|
+
/**
|
|
207
|
+
* Where the canvas gets Inter from when the page does not declare it: the addresses of its WOFF2 files (URLs, or `data:`
|
|
208
|
+
* 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
|
|
209
|
+
* Inter the page declares itself.
|
|
210
|
+
*/
|
|
211
|
+
export let interFontSources: CanvasHostProps['interFontSources'] = DEFAULT_HOST_PROPS.interFontSources;
|
|
202
212
|
|
|
203
213
|
/**
|
|
204
214
|
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
@@ -237,6 +247,7 @@
|
|
|
237
247
|
showDrawingTools,
|
|
238
248
|
elementSelectorActive,
|
|
239
249
|
onToggleElementSelector,
|
|
250
|
+
onDismissElementSelectorHint,
|
|
240
251
|
selectorGuide,
|
|
241
252
|
showZoomPanel,
|
|
242
253
|
mediaBtsOnBar,
|
|
@@ -269,7 +280,8 @@
|
|
|
269
280
|
keepCenterOnResize,
|
|
270
281
|
workspaceId,
|
|
271
282
|
userId,
|
|
272
|
-
workspaceFonts
|
|
283
|
+
workspaceFonts,
|
|
284
|
+
interFontSources
|
|
273
285
|
};
|
|
274
286
|
$: host.setProps(hostProps);
|
|
275
287
|
|
|
@@ -314,15 +326,28 @@
|
|
|
314
326
|
});
|
|
315
327
|
// A live widget laid over a selected card hides the frame the board draws, so the page's own layer draws it instead.
|
|
316
328
|
$: frameElsewhere = widgetSelectionLayerTarget !== '' && onlyCardIsSelected(engineState);
|
|
317
|
-
$: showSelectorBar = !showDrawingTools && showElementSelector;
|
|
318
329
|
$: showZoomControl = showZoomPanel || showSaveButton;
|
|
319
330
|
// Where the two cards of the chrome stand. Each names one of eight anchors; two named for the same one share a slot, side by side.
|
|
320
331
|
$: toolbarAnchor = normalizeToolbarPosition(toolbarPosition);
|
|
321
332
|
$: zoomAnchor = normalizePanZoomPosition(panZoomPosition);
|
|
322
|
-
$: slots = chromeSlots(toolbarAnchor, zoomAnchor, { toolbar: showDrawingTools
|
|
333
|
+
$: slots = chromeSlots(toolbarAnchor, zoomAnchor, { toolbar: showDrawingTools, zoom: showZoomControl });
|
|
323
334
|
$: zoomVisibleMinWidth = zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor);
|
|
335
|
+
// The selector's indicator stands at the top centre, below a card the page put there. Closing it hides it at once; it shows
|
|
336
|
+
// again when the page turns `showElementSelector` off and on (the next widget), or says nothing and keeps it on.
|
|
337
|
+
let selectorHintClosed = false;
|
|
338
|
+
$: if (!showElementSelector) selectorHintClosed = false;
|
|
339
|
+
$: showSelectorIndicator = showElementSelector && !selectorHintClosed;
|
|
340
|
+
$: selectorIndicatorTopClass = selectorIndicatorTopClassFor(slots);
|
|
341
|
+
function closeSelectorHint(): void {
|
|
342
|
+
selectorHintClosed = true;
|
|
343
|
+
try {
|
|
344
|
+
onDismissElementSelectorHint?.();
|
|
345
|
+
} catch (error) {
|
|
346
|
+
console.warn('Canvas: onDismissElementSelectorHint failed', error);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
324
349
|
// The selection panel stands in the top corner at the end of the line: it keeps clear of the cards the page put there.
|
|
325
|
-
$: panelClearance = panelClearanceFor(slots);
|
|
350
|
+
$: panelClearance = panelClearanceFor(slots, { selectorIndicator: showSelectorIndicator });
|
|
326
351
|
|
|
327
352
|
/**
|
|
328
353
|
* THE FUNCTIONS THE PAGE CALLS
|
|
@@ -425,25 +450,28 @@
|
|
|
425
450
|
|
|
426
451
|
<!-- The chrome: siblings of the board, so a press on a button never reaches it. It waits while the board loads. -->
|
|
427
452
|
<div class="pointer-events-none absolute inset-0 z-10 transition-opacity duration-200 motion-reduce:transition-none {loading ? 'opacity-60' : ''}" inert={loading}>
|
|
428
|
-
<!-- One slot for each place that has a card: the toolbar
|
|
453
|
+
<!-- One slot for each place that has a card: the toolbar and the zoom control, side by side when they share a place. -->
|
|
429
454
|
{#each slots as slot (slot.anchor)}
|
|
430
455
|
<div class={slot.classes} data-canvas-slot={slot.anchor}>
|
|
431
456
|
{#each slot.cards as card (card)}
|
|
432
457
|
{#if card === 'toolbar'}
|
|
433
|
-
{
|
|
434
|
-
<CanvasToolbar {host} state={engineState} ui={uiState} {showDrawingTools} anchor={toolbarAnchor} />
|
|
435
|
-
{:else}
|
|
436
|
-
<SelectorBar active={elementSelectorActive} guide={selectorGuide} anchor={toolbarAnchor} onToggle={() => onToggleElementSelector?.()} />
|
|
437
|
-
{/if}
|
|
458
|
+
<CanvasToolbar {host} state={engineState} ui={uiState} {showDrawingTools} anchor={toolbarAnchor} />
|
|
438
459
|
{:else}
|
|
439
460
|
<ZoomControl {host} state={engineState} ui={uiState} anchor={zoomAnchor} visibleMinWidth={zoomVisibleMinWidth} showZoom={showZoomPanel} {showSaveButton} />
|
|
440
461
|
{/if}
|
|
441
462
|
{/each}
|
|
442
463
|
</div>
|
|
443
464
|
{/each}
|
|
465
|
+
|
|
466
|
+
<!-- The selector's indicator: at the top centre while a widget stands on the board, until the person closes it. -->
|
|
467
|
+
{#if showSelectorIndicator}
|
|
468
|
+
<div class="absolute inset-x-4 flex justify-center {selectorIndicatorTopClass}" data-canvas-selector-indicator-slot>
|
|
469
|
+
<SelectorIndicator active={elementSelectorActive} guide={selectorGuide} onDismiss={closeSelectorHint} />
|
|
470
|
+
</div>
|
|
471
|
+
{/if}
|
|
444
472
|
</div>
|
|
445
473
|
|
|
446
|
-
<!-- The panel that edits the selection: a selection opens it, and its close button puts it away. -->
|
|
474
|
+
<!-- The panel that edits the selection: a selection shows its settings control (it never opens the panel by itself), the control opens it, and its close button puts it away. -->
|
|
447
475
|
<SelectionPanel
|
|
448
476
|
{host}
|
|
449
477
|
state={engineState}
|
|
@@ -455,6 +483,7 @@
|
|
|
455
483
|
canRefresh={!!onRefreshScreenshot}
|
|
456
484
|
canOpenDetails={!!onWidgetImageClick}
|
|
457
485
|
clearance={panelClearance}
|
|
486
|
+
widgetCardHasNoSettings={!advancedFeatures}
|
|
458
487
|
/>
|
|
459
488
|
|
|
460
489
|
<CanvasContextMenu {host} state={engineState} ui={uiState} board={boardElement} />
|
|
@@ -26,11 +26,12 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
26
26
|
toolbarPosition?: ToolbarPosition;
|
|
27
27
|
wireframeMode?: CanvasHostProps["wireframeMode"];
|
|
28
28
|
advancedFeatures?: CanvasHostProps["advancedFeatures"];
|
|
29
|
-
/** The
|
|
30
|
-
/**
|
|
31
|
-
elementSelectorActive?: CanvasHostProps["elementSelectorActive"];
|
|
32
|
-
onToggleElementSelector?: CanvasHostProps["onToggleElementSelector"];
|
|
33
|
-
/**
|
|
29
|
+
/** The selector's indicator at the top of the board: shown while the page says so (a widget stands on the board and the hint is not closed). */ showElementSelector?: CanvasHostProps["showElementSelector"];
|
|
30
|
+
/** The drawing toolbar. The page keeps it for as long as the board is drawn on, widget or not. */ showDrawingTools?: CanvasHostProps["showDrawingTools"];
|
|
31
|
+
/** The page's element selector is picking now: the indicator says "Selector on", and the arrow keys are the selector's. */ elementSelectorActive?: CanvasHostProps["elementSelectorActive"];
|
|
32
|
+
/** Accepted for the pages that set it: the Select tool turns the selector on and off now. */ onToggleElementSelector?: CanvasHostProps["onToggleElementSelector"];
|
|
33
|
+
/** The person closed the selector's indicator. The page decides when it comes back. */ onDismissElementSelectorHint?: CanvasHostProps["onDismissElementSelectorHint"];
|
|
34
|
+
/** Words for the selector's indicator. */ selectorGuide?: SelectorGuide | null;
|
|
34
35
|
/** The zoom card. Off on the site when debug is off. The save control stays. */ showZoomPanel?: CanvasHostProps["showZoomPanel"];
|
|
35
36
|
/** Accepted for the pages that set it. The design puts Image in the Shapes menu, so it no longer changes what is drawn. */ mediaBtsOnBar?: CanvasHostProps["mediaBtsOnBar"];
|
|
36
37
|
initialData?: CanvasHostProps["initialData"];
|
|
@@ -66,6 +67,11 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
66
67
|
/** Workspace id for persisted tool settings (B16). */ workspaceId?: CanvasHostProps["workspaceId"];
|
|
67
68
|
/** Optional user id when the host distinguishes users inside one workspace embed. */ userId?: CanvasHostProps["userId"];
|
|
68
69
|
/** Brand-kit fonts for this workspace (B15). */ workspaceFonts?: CanvasHostProps["workspaceFonts"];
|
|
70
|
+
/**
|
|
71
|
+
* Where the canvas gets Inter from when the page does not declare it: the addresses of its WOFF2 files (URLs, or `data:`
|
|
72
|
+
* 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
|
+
* Inter the page declares itself.
|
|
74
|
+
*/ interFontSources?: CanvasHostProps["interFontSources"];
|
|
69
75
|
/**
|
|
70
76
|
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
71
77
|
* the page's own words are in; `messages` are the page's own words, keyed like CANVAS_MESSAGES (a key left out
|
|
@@ -91,7 +97,7 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
91
97
|
replaceObjectWithWidgetImage?: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
92
98
|
updateWidgetImage?: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
93
99
|
selectWidgetShape?: (widgetId: string) => boolean;
|
|
94
|
-
listWidgetShapeScreenRects?: () => import("./host/screenRects.js").WidgetScreenRect[];
|
|
100
|
+
listWidgetShapeScreenRects?: (options?: import("./host/screenRects.js").ListWidgetScreenRectsOptions) => import("./host/screenRects.js").WidgetScreenRect[];
|
|
95
101
|
getWidgetShapeScreenRect?: (widgetId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
96
102
|
getObjectScreenRect?: (objectId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
97
103
|
getWidgetShapeDataUrl?: (widgetId: string) => string | null;
|
|
@@ -171,7 +177,7 @@ declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
|
171
177
|
replaceObjectWithWidgetImage: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
172
178
|
updateWidgetImage: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
173
179
|
selectWidgetShape: (widgetId: string) => boolean;
|
|
174
|
-
listWidgetShapeScreenRects: () => import("./host/screenRects.js").WidgetScreenRect[];
|
|
180
|
+
listWidgetShapeScreenRects: (options?: import("./host/screenRects.js").ListWidgetScreenRectsOptions) => import("./host/screenRects.js").WidgetScreenRect[];
|
|
175
181
|
getWidgetShapeScreenRect: (widgetId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
176
182
|
getObjectScreenRect: (objectId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
177
183
|
getWidgetShapeDataUrl: (widgetId: string) => string | null;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
export declare const CHROME_ANCHORS: readonly ["TL", "TC", "TR", "CL", "CR", "BL", "BC", "BR"];
|
|
22
22
|
/** One of {@link CHROME_ANCHORS}. */
|
|
23
23
|
export type ChromeAnchor = (typeof CHROME_ANCHORS)[number];
|
|
24
|
-
/** The cards of the chrome that stand on their own anchor: the drawing toolbar
|
|
24
|
+
/** The cards of the chrome that stand on their own anchor: the drawing toolbar and the zoom control. */
|
|
25
25
|
export type ChromeCardId = 'toolbar' | 'zoom';
|
|
26
26
|
/** The side of a card its menus and tooltips open to. */
|
|
27
27
|
export type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
@@ -63,6 +63,12 @@ export declare function chromeSlots(toolbarAnchor: ChromeAnchor, zoomAnchor: Chr
|
|
|
63
63
|
export declare function zoomVisibilityClasses(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor): string;
|
|
64
64
|
/** Minimum board width (px) before the zoom card is drawn; pairs with scoped `@container` CSS in `ZoomControl.svelte`. */
|
|
65
65
|
export declare function zoomVisibilityMinWidth(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor): number;
|
|
66
|
+
/**
|
|
67
|
+
* The place of the selector's indicator: the top centre, 16 px from the edge like the other cards, and below a card that
|
|
68
|
+
* stands at the top centre itself (the toolbar or the zoom control, when a page put one there). The classes are written
|
|
69
|
+
* out in full, so that the stylesheet of a page that installs the canvas picks both up.
|
|
70
|
+
*/
|
|
71
|
+
export declare function selectorIndicatorTopClassFor(slots: readonly ChromeSlot[]): string;
|
|
66
72
|
/** What the selection panel (top right, 336 px wide) has to keep clear of. */
|
|
67
73
|
export interface PanelClearance {
|
|
68
74
|
/** A card stands on the top edge: the panel starts below it. */
|
|
@@ -74,5 +80,10 @@ export interface PanelClearance {
|
|
|
74
80
|
*/
|
|
75
81
|
besideSideCard: ChromeCardId | null;
|
|
76
82
|
}
|
|
77
|
-
/**
|
|
78
|
-
|
|
83
|
+
/**
|
|
84
|
+
* What the panel keeps clear of, for the slots that are drawn. The selector's indicator, when it is shown, stands across the
|
|
85
|
+
* top centre (it can be as wide as the board), so the panel starts below it as it does below a card of the top edge.
|
|
86
|
+
*/
|
|
87
|
+
export declare function panelClearanceFor(slots: readonly ChromeSlot[], options?: {
|
|
88
|
+
selectorIndicator?: boolean;
|
|
89
|
+
}): PanelClearance;
|
|
@@ -124,13 +124,24 @@ export function zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor) {
|
|
|
124
124
|
return ZOOM_CONTROL_MIN_WIDTHS.centredBesideCornerToolbar;
|
|
125
125
|
return ZOOM_CONTROL_MIN_WIDTHS.oppositeCorners;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The place of the selector's indicator: the top centre, 16 px from the edge like the other cards, and below a card that
|
|
129
|
+
* stands at the top centre itself (the toolbar or the zoom control, when a page put one there). The classes are written
|
|
130
|
+
* out in full, so that the stylesheet of a page that installs the canvas picks both up.
|
|
131
|
+
*/
|
|
132
|
+
export function selectorIndicatorTopClassFor(slots) {
|
|
133
|
+
return slots.some((slot) => slot.anchor === 'TC') ? 'top-16' : 'top-4';
|
|
134
|
+
}
|
|
127
135
|
const TOP_PANEL_CONFLICT_ANCHORS = new Set(['TC', 'TR']);
|
|
128
|
-
/**
|
|
129
|
-
|
|
136
|
+
/**
|
|
137
|
+
* What the panel keeps clear of, for the slots that are drawn. The selector's indicator, when it is shown, stands across the
|
|
138
|
+
* top centre (it can be as wide as the board), so the panel starts below it as it does below a card of the top edge.
|
|
139
|
+
*/
|
|
140
|
+
export function panelClearanceFor(slots, options = {}) {
|
|
130
141
|
const rightEdgeSlot = slots.find((slot) => slot.anchor === 'CR');
|
|
131
142
|
return {
|
|
132
143
|
// Top-left chrome (e.g. zoom on the creator big page) does not overlap the top-right selection panel.
|
|
133
|
-
belowTopCards: slots.some((slot) => TOP_PANEL_CONFLICT_ANCHORS.has(slot.anchor)),
|
|
144
|
+
belowTopCards: options.selectorIndicator === true || slots.some((slot) => TOP_PANEL_CONFLICT_ANCHORS.has(slot.anchor)),
|
|
134
145
|
besideSideCard: rightEdgeSlot ? (rightEdgeSlot.cards.includes('toolbar') ? 'toolbar' : 'zoom') : null
|
|
135
146
|
};
|
|
136
147
|
}
|
|
@@ -28,8 +28,8 @@ import type { CanvasMessageKey } from '../../i18n/messages.js';
|
|
|
28
28
|
import type { ObjectClickPayload, StrokeRecognizer } from '../types.js';
|
|
29
29
|
import type { LoadedImageFile } from './browserServices.js';
|
|
30
30
|
import type { HostObject } from './hostObject.js';
|
|
31
|
-
import type { ScreenRect, WidgetScreenRect } from './screenRects.js';
|
|
32
|
-
/** The words of the selector
|
|
31
|
+
import type { ListWidgetScreenRectsOptions, ScreenRect, WidgetScreenRect } from './screenRects.js';
|
|
32
|
+
/** The words of the selector's indicator at the top of the board (the line that says how to use the selector). */
|
|
33
33
|
export interface SelectorGuide {
|
|
34
34
|
click: string;
|
|
35
35
|
parentChild: string;
|
|
@@ -63,10 +63,23 @@ export interface CanvasHostProps {
|
|
|
63
63
|
toolbarPosition: ToolbarPosition;
|
|
64
64
|
wireframeMode: boolean;
|
|
65
65
|
advancedFeatures: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Shows the selector's indicator at the top of the board: the card that says whether the page's element selector is on,
|
|
68
|
+
* with the instructions of `selectorGuide`. The page turns it on while a widget stands on the board and the person has
|
|
69
|
+
* not closed it (see `onDismissElementSelectorHint`). The toolbar is not affected: it stays as `showDrawingTools` says.
|
|
70
|
+
*/
|
|
66
71
|
showElementSelector: boolean;
|
|
67
72
|
showDrawingTools: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The page's element selector is picking elements of the widget now (the Select tool is chosen and the page has not paused
|
|
75
|
+
* it). The indicator says "Selector on" while it is, and the arrow keys belong to the selector (parent and child) and not
|
|
76
|
+
* to the selection of the board, whether or not the indicator is shown.
|
|
77
|
+
*/
|
|
68
78
|
elementSelectorActive: boolean;
|
|
79
|
+
/** Accepted for the pages that set it. The Select tool turns the selector on and off now, so the canvas never calls it. */
|
|
69
80
|
onToggleElementSelector: (() => void) | null;
|
|
81
|
+
/** The person closed the indicator (its X). The page decides when the hint comes back: it sets `showElementSelector`. */
|
|
82
|
+
onDismissElementSelectorHint: (() => void) | null;
|
|
70
83
|
selectorGuide: SelectorGuide | null;
|
|
71
84
|
showZoomPanel: boolean;
|
|
72
85
|
mediaBtsOnBar: boolean;
|
|
@@ -111,6 +124,13 @@ export interface CanvasHostProps {
|
|
|
111
124
|
workspaceId: string | null;
|
|
112
125
|
userId: string | null;
|
|
113
126
|
workspaceFonts: readonly WorkspaceCanvasFont[];
|
|
127
|
+
/**
|
|
128
|
+
* Where the canvas gets Inter from when the page does not declare it itself: the addresses of its WOFF2 files (URLs, or
|
|
129
|
+
* `data:` URLs for a page with a strict `font-src`), in order of preference. The canvas registers them as the family
|
|
130
|
+
* `Inter`. Empty unless the page passes some: the canvas then asks nobody for a font file and waits for the Inter the
|
|
131
|
+
* page declares (the design system's `fonts.css` does), so it never requests a path of a page that is not ours.
|
|
132
|
+
*/
|
|
133
|
+
interFontSources: readonly string[];
|
|
114
134
|
}
|
|
115
135
|
/** What each prop is until the page sets it (the values the canvas this one replaces had, but for `panZoomPosition`). */
|
|
116
136
|
export declare const DEFAULT_HOST_PROPS: Readonly<CanvasHostProps>;
|
|
@@ -161,6 +181,12 @@ export declare const TOUCH_LONG_PRESS_DELAY_MS = 500;
|
|
|
161
181
|
export declare const TOUCH_LONG_PRESS_SLOP = 8;
|
|
162
182
|
/** How long after the finger that opened the menu lifts its release is still told apart from a choice (see `isMenuHeldByItsFinger`). */
|
|
163
183
|
export declare const TOUCH_MENU_RELEASE_GRACE_MS = 400;
|
|
184
|
+
/**
|
|
185
|
+
* How long the host waits for the pictures it was told to wait for (the ones on screen when a board is opened, or all of them
|
|
186
|
+
* when a capture needs them) before it goes on without them. A page whose store never answers must not keep the board shut for
|
|
187
|
+
* good; the pictures that come later still go on the board.
|
|
188
|
+
*/
|
|
189
|
+
export declare const PICTURE_PATIENCE_MS = 15000;
|
|
164
190
|
/** Says a message of the catalog in the language of the canvas (the host only ever asks for keys the catalog has). */
|
|
165
191
|
export type Translate = CatalogTranslate<CanvasMessageKey>;
|
|
166
192
|
/** A picture's size on the board: its own size, or the biggest one that fits `IMAGE_INSERT_MAX_SIDE`. */
|
|
@@ -241,6 +267,12 @@ export declare class CanvasHost {
|
|
|
241
267
|
* a canvas) opens as an empty board, says so, and nothing is saved until the person changes something.
|
|
242
268
|
*/
|
|
243
269
|
loadCanvas(jsonString: string): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Resolves when every picture of the board has been asked for and put on it (at once when none is on its way): what draws the
|
|
272
|
+
* whole board, a capture for instance, waits for it. It gives up after `PICTURE_PATIENCE_MS`, so a store that never answers cannot
|
|
273
|
+
* hold anything for good; what was missing is then left out, as a picture the store could not give.
|
|
274
|
+
*/
|
|
275
|
+
whenPicturesLoaded(): Promise<void>;
|
|
244
276
|
/** Empties the board (an undo step) and tells the page. */
|
|
245
277
|
onClearAllObjects(): void;
|
|
246
278
|
setTool(tool: ToolId, options?: {
|
|
@@ -248,7 +280,10 @@ export declare class CanvasHost {
|
|
|
248
280
|
}): void;
|
|
249
281
|
/** A letter of the keyboard chose a tool (or the menu did). */
|
|
250
282
|
chooseShortcutTool(tool: ToolShortcut): void;
|
|
251
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* The Select tool. The page hears `widgetic:canvas-tool` for it (the creator's element selector is on while this tool is
|
|
285
|
+
* chosen), and the older `widgetic:canvas-select-tool`, which a page that was written before the selector followed the tool still reads.
|
|
286
|
+
*/
|
|
252
287
|
onSelectSelectTool(): void;
|
|
253
288
|
onSelectDrawTool(): void;
|
|
254
289
|
onSelectEraseTool(): void;
|
|
@@ -329,8 +364,15 @@ export declare class CanvasHost {
|
|
|
329
364
|
selectWidgetShapeById(widgetId: string): boolean;
|
|
330
365
|
getSelectedWidgetShapeId(): string | null;
|
|
331
366
|
getHoveredWidgetShapeId(): string | null;
|
|
332
|
-
/**
|
|
333
|
-
|
|
367
|
+
/**
|
|
368
|
+
* The cards a live widget can be drawn over, with where each is on the page.
|
|
369
|
+
*
|
|
370
|
+
* On a board of many cards (`NEAR_CARDS_MINIMUM` or more) only the cards near the view are listed, the selected one and the one
|
|
371
|
+
* under the pointer wherever they are (see `nearCards.ts`): a page that lays a live widget over each card it is given then runs
|
|
372
|
+
* the widgets that are near, and lets the others go until the view comes back to them. `{ all: true }` lists every card, as
|
|
373
|
+
* the list did before. `getWidgetShapeScreenRect(widgetId)` answers for any card, near or not.
|
|
374
|
+
*/
|
|
375
|
+
listWidgetShapeScreenRects(options?: ListWidgetScreenRectsOptions): WidgetScreenRect[];
|
|
334
376
|
/** Where the card of a widget is on the page, with the board it is on. */
|
|
335
377
|
getWidgetShapeScreenRect(widgetId: string): ScreenRect | null;
|
|
336
378
|
/** Where any object is on the page: the id of an object, of a group, or of a selection a conversion remembered. */
|