@widgetic/canvas 0.5.34 → 0.5.36
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 +105 -36
- package/dist/canvas/DomCanvas.svelte +454 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +222 -0
- package/dist/canvas/autosaveScheduler.d.ts +58 -0
- package/dist/canvas/autosaveScheduler.js +157 -0
- package/dist/canvas/boardFrame.d.ts +13 -0
- package/dist/canvas/boardFrame.js +13 -0
- package/dist/canvas/boardSurface.d.ts +9 -0
- package/dist/canvas/boardSurface.js +9 -0
- package/dist/canvas/chromeLayout.d.ts +76 -0
- package/dist/canvas/chromeLayout.js +121 -0
- package/dist/canvas/emptyBoardHint.d.ts +17 -0
- package/dist/canvas/emptyBoardHint.js +12 -0
- package/dist/canvas/eventScope.d.ts +1 -1
- package/dist/canvas/eventScope.js +1 -1
- package/dist/canvas/host/CanvasHost.d.ts +351 -0
- package/dist/canvas/host/CanvasHost.js +1740 -0
- package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
- package/dist/canvas/host/CanvasHostApi.js +95 -0
- package/dist/canvas/host/browserServices.d.ts +46 -0
- package/dist/canvas/host/browserServices.js +167 -0
- package/dist/canvas/host/conversion.d.ts +51 -0
- package/dist/canvas/host/conversion.js +123 -0
- package/dist/canvas/host/hostObject.d.ts +40 -0
- package/dist/canvas/host/hostObject.js +93 -0
- package/dist/canvas/host/pageEvents.d.ts +24 -0
- package/dist/canvas/host/pageEvents.js +35 -0
- package/dist/canvas/host/screenRects.d.ts +66 -0
- package/dist/canvas/host/screenRects.js +102 -0
- package/dist/canvas/host/strokeSnap.d.ts +67 -0
- package/dist/canvas/host/strokeSnap.js +165 -0
- package/dist/canvas/index.d.ts +9 -7
- package/dist/canvas/index.js +9 -7
- package/dist/canvas/openMarks.d.ts +17 -0
- package/dist/canvas/openMarks.js +26 -0
- package/dist/canvas/panZoomPosition.d.ts +15 -0
- package/dist/canvas/panZoomPosition.js +16 -0
- package/dist/canvas/preferredTextFont.d.ts +12 -0
- package/dist/canvas/preferredTextFont.js +38 -0
- package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
- package/dist/canvas/shapes/ShapeLibrary.js +13 -1
- package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
- package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
- package/dist/canvas/toolbarPosition.d.ts +24 -0
- package/dist/canvas/toolbarPosition.js +24 -0
- package/dist/canvas/types.d.ts +14 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
- package/dist/canvas/ui/CanvasHint.svelte +20 -0
- package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
- package/dist/canvas/ui/ColorField.svelte +155 -0
- package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
- package/dist/canvas/ui/LoadNotice.svelte +39 -0
- package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
- package/dist/canvas/ui/SelectionPanel.svelte +300 -0
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
- package/dist/canvas/ui/SelectorBar.svelte +82 -0
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
- package/dist/canvas/ui/ShapesMenu.svelte +185 -0
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/ToolButton.svelte +78 -0
- package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
- package/dist/canvas/ui/WidgetActions.svelte +152 -0
- package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
- package/dist/canvas/ui/ZoomControl.svelte +89 -0
- package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
- package/dist/canvas/ui/colorModel.d.ts +18 -0
- package/dist/canvas/ui/colorModel.js +85 -0
- package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
- package/dist/canvas/ui/colorPickerMessages.js +15 -0
- package/dist/canvas/ui/floatingCard.d.ts +107 -0
- package/dist/canvas/ui/floatingCard.js +107 -0
- package/dist/canvas/ui/floatingLayer.d.ts +21 -0
- package/dist/canvas/ui/floatingLayer.js +52 -0
- package/dist/canvas/ui/icons.d.ts +12 -0
- package/dist/canvas/ui/icons.js +7 -0
- package/dist/canvas/ui/keyHints.d.ts +27 -0
- package/dist/canvas/ui/keyHints.js +43 -0
- package/dist/canvas/ui/popoverSide.d.ts +5 -0
- package/dist/canvas/ui/popoverSide.js +20 -0
- package/dist/canvas/ui/selectionTraits.d.ts +61 -0
- package/dist/canvas/ui/selectionTraits.js +99 -0
- package/dist/canvas/view/CanvasStage.svelte +132 -0
- package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
- package/dist/canvas/view/EraserTrail.svelte +50 -0
- package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
- package/dist/canvas/view/ObjectView.svelte +245 -0
- package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
- package/dist/canvas/view/SelectionOverlay.svelte +487 -0
- package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
- package/dist/canvas/view/TextEditor.svelte +76 -0
- package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.js +34 -0
- package/dist/canvas/view/geometry.d.ts +169 -0
- package/dist/canvas/view/geometry.js +272 -0
- package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +2 -2
- package/dist/engine/EngineCore.d.ts +273 -0
- package/dist/engine/EngineCore.js +1051 -0
- package/dist/engine/codec/canvasDocument.d.ts +57 -0
- package/dist/engine/codec/canvasDocument.js +471 -0
- package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
- package/dist/engine/codec/hostReadableKeys.js +25 -0
- package/dist/engine/core/arrange.d.ts +20 -0
- package/dist/engine/core/arrange.js +81 -0
- package/dist/engine/core/arrow.d.ts +91 -0
- package/dist/engine/core/arrow.js +182 -0
- package/dist/engine/core/brush.d.ts +68 -0
- package/dist/engine/core/brush.js +173 -0
- package/dist/engine/core/defaults.d.ts +70 -0
- package/dist/engine/core/defaults.js +158 -0
- package/dist/engine/core/freehand.d.ts +130 -0
- package/dist/engine/core/freehand.js +430 -0
- package/dist/engine/core/geometry.d.ts +44 -0
- package/dist/engine/core/geometry.js +216 -0
- package/dist/engine/core/history.d.ts +39 -0
- package/dist/engine/core/history.js +69 -0
- package/dist/engine/core/hitTest.d.ts +54 -0
- package/dist/engine/core/hitTest.js +298 -0
- package/dist/engine/core/matrix.d.ts +47 -0
- package/dist/engine/core/matrix.js +101 -0
- package/dist/engine/core/pathData.d.ts +50 -0
- package/dist/engine/core/pathData.js +550 -0
- package/dist/engine/core/rotationReset.d.ts +10 -0
- package/dist/engine/core/rotationReset.js +17 -0
- package/dist/engine/core/scene.d.ts +99 -0
- package/dist/engine/core/scene.js +450 -0
- package/dist/engine/core/scribble.d.ts +64 -0
- package/dist/engine/core/scribble.js +121 -0
- package/dist/engine/core/shapePaths.d.ts +34 -0
- package/dist/engine/core/shapePaths.js +69 -0
- package/dist/engine/core/shapeTools.d.ts +80 -0
- package/dist/engine/core/shapeTools.js +161 -0
- package/dist/engine/core/snapping.d.ts +64 -0
- package/dist/engine/core/snapping.js +164 -0
- package/dist/engine/core/style.d.ts +40 -0
- package/dist/engine/core/style.js +151 -0
- package/dist/engine/core/transform.d.ts +79 -0
- package/dist/engine/core/transform.js +258 -0
- package/dist/engine/core/types.d.ts +238 -0
- package/dist/engine/core/types.js +31 -0
- package/dist/engine/core/viewport.d.ts +32 -0
- package/dist/engine/core/viewport.js +84 -0
- package/dist/engine/input/PointerController.d.ts +38 -0
- package/dist/engine/input/PointerController.js +545 -0
- package/dist/engine/input/arrowHandles.d.ts +38 -0
- package/dist/engine/input/arrowHandles.js +60 -0
- package/dist/engine/input/gestures.d.ts +79 -0
- package/dist/engine/input/gestures.js +769 -0
- package/dist/engine/input/hoverCursor.d.ts +29 -0
- package/dist/engine/input/hoverCursor.js +23 -0
- package/dist/engine/input/keyboard.d.ts +75 -0
- package/dist/engine/input/keyboard.js +264 -0
- package/dist/engine/input/selectionHandles.d.ts +89 -0
- package/dist/engine/input/selectionHandles.js +169 -0
- package/dist/engine/input/types.d.ts +82 -0
- package/dist/engine/input/types.js +5 -0
- package/dist/engine/render/rasterize.d.ts +74 -0
- package/dist/engine/render/rasterize.js +273 -0
- package/dist/engine/state.d.ts +124 -0
- package/dist/engine/state.js +47 -0
- package/dist/engine/text/layoutText.d.ts +53 -0
- package/dist/engine/text/layoutText.js +170 -0
- package/dist/engine/widgets.d.ts +124 -0
- package/dist/engine/widgets.js +345 -0
- package/dist/i18n/labels.d.ts +4 -15
- package/dist/i18n/labels.js +33 -53
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +51 -122
- package/dist/i18n/messages.js +58 -131
- package/dist/i18n/shortcuts.d.ts +0 -1
- package/dist/i18n/shortcuts.js +2 -11
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13299
- package/dist/canvas/Canvas.svelte.d.ts +0 -281
- package/dist/canvas/CanvasToolbar.svelte +0 -1498
- package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
- package/dist/canvas/ContextMenu.svelte +0 -305
- package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
- package/dist/canvas/PanZoomPanel.svelte +0 -478
- package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
- package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
- package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
- package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
- package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
- package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
- package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
- package/dist/canvas/shadowRootText.d.ts +0 -5
- package/dist/canvas/shadowRootText.js +0 -43
- package/dist/canvas/shapes/FrameShape.d.ts +0 -97
- package/dist/canvas/shapes/FrameShape.js +0 -953
- package/dist/canvas/shapes/ImageShape.d.ts +0 -47
- package/dist/canvas/shapes/ImageShape.js +0 -339
- package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
- package/dist/canvas/shapes/WidgetShape.js +0 -200
- package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
- package/dist/canvas/widgetPreviewGeometry.js +0 -66
- package/dist/i18n/shapeWords.d.ts +0 -30
- package/dist/i18n/shapeWords.js +0 -36
- package/dist/i18n/slots.d.ts +0 -20
- package/dist/i18n/slots.js +0 -40
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the floating cards of the chrome (the toolbar and the zoom control) stand on the board, and how they share the
|
|
3
|
+
* board when a page puts both in the same place.
|
|
4
|
+
*
|
|
5
|
+
* A page names a place for each card (`toolbarPosition`, `panZoomPosition`): one of eight anchors, written the way the
|
|
6
|
+
* design names its frames, a row letter and a column letter.
|
|
7
|
+
*
|
|
8
|
+
* TL TC TR the top edge: left, centre, right
|
|
9
|
+
* CL CR the middle of the left edge and of the right edge
|
|
10
|
+
* BL BC BR the bottom edge: left, centre, right
|
|
11
|
+
*
|
|
12
|
+
* The middle of the board is not a place: a card there would sit on the drawing. A card on a side edge (CL, CR) stands
|
|
13
|
+
* upright, its buttons one under the other, and its menus and tooltips open sideways, into the board.
|
|
14
|
+
*
|
|
15
|
+
* Two cards named for the same anchor are put in one row (one column on a side edge) with a gap between them instead of
|
|
16
|
+
* lying on top of each other, so a host can ask for "everything at the bottom left" and get it.
|
|
17
|
+
*
|
|
18
|
+
* Kept free of Svelte and of the DOM so that Node can test it.
|
|
19
|
+
*/
|
|
20
|
+
import { ZOOM_CONTROL_VISIBLE_FROM } from './ui/floatingCard.js';
|
|
21
|
+
/** The eight places a card can stand. */
|
|
22
|
+
export const CHROME_ANCHORS = ['TL', 'TC', 'TR', 'CL', 'CR', 'BL', 'BC', 'BR'];
|
|
23
|
+
/**
|
|
24
|
+
* The classes that put an anchor in place, 16 px from the edges as the Figma design has it. Written out in full, so that
|
|
25
|
+
* the stylesheet of a page that installs the canvas picks every one of them up when it reads this file.
|
|
26
|
+
*/
|
|
27
|
+
const ANCHOR_CLASSES = {
|
|
28
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
29
|
+
TL: 'absolute top-4 left-4',
|
|
30
|
+
TC: 'absolute top-4 left-1/2 -translate-x-1/2',
|
|
31
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
32
|
+
TR: 'absolute top-4 right-4',
|
|
33
|
+
// rtl-ok: the page names a side of the screen, as it is drawn
|
|
34
|
+
CL: 'absolute top-1/2 left-4 -translate-y-1/2',
|
|
35
|
+
// rtl-ok: the page names a side of the screen, as it is drawn
|
|
36
|
+
CR: 'absolute top-1/2 right-4 -translate-y-1/2',
|
|
37
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
38
|
+
BL: 'absolute bottom-4 left-4',
|
|
39
|
+
BC: 'absolute bottom-4 left-1/2 -translate-x-1/2',
|
|
40
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
41
|
+
BR: 'absolute bottom-4 right-4'
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* How the cards of a slot are laid out: a row on the top and the bottom edge (the cards stand on the line of the edge they
|
|
45
|
+
* are against), a column on a side edge (centred on each other, so the layout does not depend on the direction of the
|
|
46
|
+
* page). A slot never grows larger than the board minus its 16 px edges.
|
|
47
|
+
*/
|
|
48
|
+
const SLOT_TOP_ROW_CLASSES = 'flex flex-row items-start gap-2 max-w-[calc(100%-2rem)]';
|
|
49
|
+
const SLOT_BOTTOM_ROW_CLASSES = 'flex flex-row items-end gap-2 max-w-[calc(100%-2rem)]';
|
|
50
|
+
const SLOT_COLUMN_CLASSES = 'flex flex-col items-center gap-2 max-h-[calc(100%-2rem)]';
|
|
51
|
+
/** The anchor to use for what a page passed: anything that is not one of the eight is the fallback, so a mistyped option never takes a card off the board. */
|
|
52
|
+
export function normalizeAnchor(value, fallback) {
|
|
53
|
+
return CHROME_ANCHORS.includes(value) ? value : fallback;
|
|
54
|
+
}
|
|
55
|
+
/** Whether a card at this anchor stands upright, against the left or the right edge. */
|
|
56
|
+
export function isSideAnchor(anchor) {
|
|
57
|
+
return anchor === 'CL' || anchor === 'CR';
|
|
58
|
+
}
|
|
59
|
+
/** Whether a card at this anchor stands against the top edge. */
|
|
60
|
+
export function isTopAnchor(anchor) {
|
|
61
|
+
return anchor.startsWith('T');
|
|
62
|
+
}
|
|
63
|
+
/** The side of a card at this anchor that its menus and tooltips open to: away from the edge the card stands on. */
|
|
64
|
+
export function popoverSideFor(anchor) {
|
|
65
|
+
if (anchor === 'CL')
|
|
66
|
+
return 'right';
|
|
67
|
+
if (anchor === 'CR')
|
|
68
|
+
return 'left';
|
|
69
|
+
return isTopAnchor(anchor) ? 'bottom' : 'top';
|
|
70
|
+
}
|
|
71
|
+
/** The classes of the anchor alone (its place on the board, no layout of what is inside). */
|
|
72
|
+
export function anchorClasses(anchor) {
|
|
73
|
+
return ANCHOR_CLASSES[anchor];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The slots to draw for the anchors a page named: one per anchor that has a card, in a fixed order, so a card that moves
|
|
77
|
+
* from one anchor to another does not make the other one start again.
|
|
78
|
+
*/
|
|
79
|
+
export function chromeSlots(toolbarAnchor, zoomAnchor, shown) {
|
|
80
|
+
const slots = [];
|
|
81
|
+
for (const anchor of CHROME_ANCHORS) {
|
|
82
|
+
const cards = [];
|
|
83
|
+
if (shown.toolbar && toolbarAnchor === anchor)
|
|
84
|
+
cards.push('toolbar');
|
|
85
|
+
if (shown.zoom && zoomAnchor === anchor)
|
|
86
|
+
cards.push('zoom');
|
|
87
|
+
if (cards.length === 0)
|
|
88
|
+
continue;
|
|
89
|
+
const vertical = isSideAnchor(anchor);
|
|
90
|
+
const layout = vertical ? SLOT_COLUMN_CLASSES : isTopAnchor(anchor) ? SLOT_TOP_ROW_CLASSES : SLOT_BOTTOM_ROW_CLASSES;
|
|
91
|
+
slots.push({ anchor, cards, vertical, classes: `${ANCHOR_CLASSES[anchor]} ${layout}` });
|
|
92
|
+
}
|
|
93
|
+
return slots;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The classes that show the zoom card from the width of board it needs, and hide it below. A zoom card on the same edge as
|
|
97
|
+
* the toolbar shares the line with it, so how much room it needs depends on where each stands: the widths and the sums
|
|
98
|
+
* behind them are in `ZOOM_CONTROL_MIN_WIDTHS`.
|
|
99
|
+
*/
|
|
100
|
+
export function zoomVisibilityClasses(toolbarAnchor, zoomAnchor) {
|
|
101
|
+
// A card on a side edge shares no line with a card on the top or the bottom edge, and neither do two cards on different edges.
|
|
102
|
+
if (isSideAnchor(toolbarAnchor) || isSideAnchor(zoomAnchor) || toolbarAnchor[0] !== zoomAnchor[0])
|
|
103
|
+
return ZOOM_CONTROL_VISIBLE_FROM.alone;
|
|
104
|
+
const toolbarColumn = toolbarAnchor[1];
|
|
105
|
+
const zoomColumn = zoomAnchor[1];
|
|
106
|
+
if (toolbarColumn === zoomColumn)
|
|
107
|
+
return ZOOM_CONTROL_VISIBLE_FROM.sameSlot;
|
|
108
|
+
if (toolbarColumn === 'C')
|
|
109
|
+
return ZOOM_CONTROL_VISIBLE_FROM.besideCentredToolbar;
|
|
110
|
+
if (zoomColumn === 'C')
|
|
111
|
+
return ZOOM_CONTROL_VISIBLE_FROM.centredBesideCornerToolbar;
|
|
112
|
+
return ZOOM_CONTROL_VISIBLE_FROM.oppositeCorners;
|
|
113
|
+
}
|
|
114
|
+
/** What the panel keeps clear of, for the slots that are drawn. */
|
|
115
|
+
export function panelClearanceFor(slots) {
|
|
116
|
+
const rightEdgeSlot = slots.find((slot) => slot.anchor === 'CR');
|
|
117
|
+
return {
|
|
118
|
+
belowTopCards: slots.some((slot) => isTopAnchor(slot.anchor)),
|
|
119
|
+
besideSideCard: rightEdgeSlot ? (rightEdgeSlot.cards.includes('toolbar') ? 'toolbar' : 'zoom') : null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the empty-board hint ("Draw or type…") may show. The hint is only for a board that finished loading and stayed
|
|
3
|
+
* empty; never a flash before saved shapes arrive (item 22).
|
|
4
|
+
*/
|
|
5
|
+
export interface EmptyBoardHintInput {
|
|
6
|
+
/** The page wants the sketch hint (drawing tools visible). */
|
|
7
|
+
showDrawingHint: boolean;
|
|
8
|
+
/** The host has opened the gate after onReady / the first load (see CanvasHost). */
|
|
9
|
+
emptyHintGateOpen: boolean;
|
|
10
|
+
/** The board or the page is still loading saved content. */
|
|
11
|
+
loading: boolean;
|
|
12
|
+
sceneObjectCount: number;
|
|
13
|
+
hasPreviewOverlay: boolean;
|
|
14
|
+
editingText: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** True when the centered empty-board hint should render. */
|
|
17
|
+
export declare function shouldShowEmptyBoardHint(input: EmptyBoardHintInput): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the empty-board hint ("Draw or type…") may show. The hint is only for a board that finished loading and stayed
|
|
3
|
+
* empty; never a flash before saved shapes arrive (item 22).
|
|
4
|
+
*/
|
|
5
|
+
/** True when the centered empty-board hint should render. */
|
|
6
|
+
export function shouldShowEmptyBoardHint(input) {
|
|
7
|
+
if (!input.showDrawingHint || !input.emptyHintGateOpen)
|
|
8
|
+
return false;
|
|
9
|
+
if (input.loading || input.editingText)
|
|
10
|
+
return false;
|
|
11
|
+
return input.sceneObjectCount === 0 && !input.hasPreviewOverlay;
|
|
12
|
+
}
|
|
@@ -46,7 +46,7 @@ export declare function eventWentThrough(event: Event, element: Element | null |
|
|
|
46
46
|
export declare function getTransientHostFor(scopeNode: Node | null | undefined): Node;
|
|
47
47
|
/**
|
|
48
48
|
* Whether the canvas whose element is `scopeNode` should take the keyboard back after the element that held it went away
|
|
49
|
-
* (
|
|
49
|
+
* (the text editor of the board, which is taken out of the page when text editing ends, and leaves the focus on nothing).
|
|
50
50
|
*
|
|
51
51
|
* Inside a shadow root the canvas's shortcuts follow the focus, so a focus that fell to nothing (the page's `<body>`, or
|
|
52
52
|
* the shadow root's host alone) has to come back to the canvas. A focus that went to something else is not ours to take:
|
|
@@ -68,7 +68,7 @@ export function getTransientHostFor(scopeNode) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Whether the canvas whose element is `scopeNode` should take the keyboard back after the element that held it went away
|
|
71
|
-
* (
|
|
71
|
+
* (the text editor of the board, which is taken out of the page when text editing ends, and leaves the focus on nothing).
|
|
72
72
|
*
|
|
73
73
|
* Inside a shadow root the canvas's shortcuts follow the focus, so a focus that fell to nothing (the page's `<body>`, or
|
|
74
74
|
* the shadow root's host alone) has to come back to the canvas. A focus that went to something else is not ours to take:
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host of one canvas: the object the Svelte shell talks to, and the only place where the engine meets the page.
|
|
3
|
+
*
|
|
4
|
+
* It owns the engine, the pointer controller, the autosave buffer and the registry of conversions in flight, and it
|
|
5
|
+
* keeps every promise the canvas this one replaces made to the widget creator and the other modules that mount it:
|
|
6
|
+
* the props they set (read at the moment they are needed, so a change takes effect without a remount), the functions
|
|
7
|
+
* they call (the shell re-exports them one by one), the callbacks they are given, and the order in which these happen.
|
|
8
|
+
*
|
|
9
|
+
* Plain TypeScript with no Svelte and no DOM at construction, so a page that is rendered on the server can make one;
|
|
10
|
+
* the shell calls `attach` from `onMount` and `destroy` from `onDestroy`. The engine's state and the host's own UI state
|
|
11
|
+
* are offered as stores (`engineStore`, `uiStore`), so legacy and runes components read them the same way.
|
|
12
|
+
*/
|
|
13
|
+
import { createRectObject } from '../../engine/core/defaults.js';
|
|
14
|
+
import type { ObjectId, Point, TextObject, WidgetObject } from '../../engine/core/types.js';
|
|
15
|
+
import { EngineCore } from '../../engine/EngineCore.js';
|
|
16
|
+
import type { ToolShortcut } from '../../engine/input/keyboard.js';
|
|
17
|
+
import { PointerController } from '../../engine/input/PointerController.js';
|
|
18
|
+
import type { TextLayout } from '../../engine/text/layoutText.js';
|
|
19
|
+
import type { EngineState, ToolId } from '../../engine/state.js';
|
|
20
|
+
import { ConversionRegistry } from '../../engine/widgets.js';
|
|
21
|
+
import type { WidgetMetadata } from '../../engine/widgets.js';
|
|
22
|
+
import type { PanZoomPosition } from '../panZoomPosition.js';
|
|
23
|
+
import type { ToolbarPosition } from '../toolbarPosition.js';
|
|
24
|
+
import type { Translate as CatalogTranslate } from '@widgetic/design-system/i18n';
|
|
25
|
+
import type { CanvasMessageKey } from '../../i18n/messages.js';
|
|
26
|
+
import type { ObjectClickPayload, StrokeRecognizer, WidgetConversionPayload } from '../types.js';
|
|
27
|
+
import type { LoadedImageFile } from './browserServices.js';
|
|
28
|
+
import type { HostObject } from './hostObject.js';
|
|
29
|
+
import type { ScreenRect, WidgetScreenRect } from './screenRects.js';
|
|
30
|
+
/** The words of the selector bar that replaces the drawing tools. */
|
|
31
|
+
export interface SelectorGuide {
|
|
32
|
+
click: string;
|
|
33
|
+
parentChild: string;
|
|
34
|
+
hold: string;
|
|
35
|
+
cmd: string;
|
|
36
|
+
interact: string;
|
|
37
|
+
esc: string;
|
|
38
|
+
done: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every prop of the canvas that the host reads. `class`, `style`, `locale` and `messages` belong to the shell (they
|
|
42
|
+
* are about the element and the words), the rest are here. Each is read when it is needed, never copied.
|
|
43
|
+
*/
|
|
44
|
+
export interface CanvasHostProps {
|
|
45
|
+
showContainerFrame: boolean;
|
|
46
|
+
widgetSelectionLayerTarget: string;
|
|
47
|
+
onObjectClick: ((data: ObjectClickPayload) => void) | null;
|
|
48
|
+
panZoomPosition: PanZoomPosition;
|
|
49
|
+
toolbarPosition: ToolbarPosition;
|
|
50
|
+
wireframeMode: boolean;
|
|
51
|
+
advancedFeatures: boolean;
|
|
52
|
+
showElementSelector: boolean;
|
|
53
|
+
showDrawingTools: boolean;
|
|
54
|
+
elementSelectorActive: boolean;
|
|
55
|
+
onToggleElementSelector: (() => void) | null;
|
|
56
|
+
selectorGuide: SelectorGuide | null;
|
|
57
|
+
showZoomPanel: boolean;
|
|
58
|
+
mediaBtsOnBar: boolean;
|
|
59
|
+
initialData: string | null;
|
|
60
|
+
onReady: (() => void) | null;
|
|
61
|
+
isExternalDataLoading: boolean;
|
|
62
|
+
onBeforeUnmount: ((json: string | null) => void) | null;
|
|
63
|
+
onAutoSave: ((json: string | null) => void | Promise<unknown>) | null;
|
|
64
|
+
autosaveDelayMs: number;
|
|
65
|
+
autosaveMaxWaitMs: number;
|
|
66
|
+
suspendAutosave: boolean;
|
|
67
|
+
showSaveButton: boolean;
|
|
68
|
+
onCanvasDirty: (() => void) | null;
|
|
69
|
+
onCanvasCleared: (() => void) | null;
|
|
70
|
+
onConvertToWidget: ((data: WidgetConversionPayload) => void) | null;
|
|
71
|
+
onWidgetImageClick: ((widgetId: string) => void) | null;
|
|
72
|
+
onRecognizeStroke: StrokeRecognizer | null;
|
|
73
|
+
onNonWidgetSelected: (() => void) | null;
|
|
74
|
+
onWidgetShapeDuplicated: ((sourceWidgetId: string, clonedObject: any) => void) | null;
|
|
75
|
+
onWidgetShapeDeleting: ((widgetId: string) => Promise<boolean>) | null;
|
|
76
|
+
onWidgetRename: ((widgetId: string, newName: string) => void) | null;
|
|
77
|
+
onRefreshScreenshot: ((widgetId: string) => void) | null;
|
|
78
|
+
onSetPrimaryWidget: ((widgetId: string) => void) | null;
|
|
79
|
+
onAfterRender: (() => void) | null;
|
|
80
|
+
getWidgetName: ((widgetId: string) => string | null) | null;
|
|
81
|
+
widgetNameRevision: number;
|
|
82
|
+
isWidgetKnown: ((widgetId: string) => boolean) | null;
|
|
83
|
+
showLogs: boolean;
|
|
84
|
+
/** Whether a freehand stroke that is a clean shape becomes that shape. Off unless the page passes true. */
|
|
85
|
+
shapeSnap: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** What each prop is until the page sets it (the values the canvas this one replaces had, but for `panZoomPosition`). */
|
|
88
|
+
export declare const DEFAULT_HOST_PROPS: Readonly<CanvasHostProps>;
|
|
89
|
+
export type SaveState = 'saved' | 'dirty' | 'saving';
|
|
90
|
+
export type LoadPhase = 'initializing' | 'loading' | 'ready' | 'error';
|
|
91
|
+
export type LoadStatus = 'ok' | 'empty' | 'unsupported' | 'invalid';
|
|
92
|
+
/** What the host shows that is not the board: the open menus, the loading phase, the state of the save. */
|
|
93
|
+
export interface HostUiState {
|
|
94
|
+
loadPhase: LoadPhase;
|
|
95
|
+
/** How the last document read went (`unsupported` is an older canvas the board does not open). */
|
|
96
|
+
loadStatus: LoadStatus | null;
|
|
97
|
+
saveState: SaveState;
|
|
98
|
+
/** Where the context menu is open, in pixels of the board. */
|
|
99
|
+
/** The point of the board the menu opens at; `byTouch` when a long press opened it (the menu then stands clear of the finger). */
|
|
100
|
+
contextMenu: {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
byTouch?: boolean;
|
|
104
|
+
} | null;
|
|
105
|
+
shapesMenuOpen: boolean;
|
|
106
|
+
shortcutsOpen: boolean;
|
|
107
|
+
/** The selection panel is collapsed to the settings control (true) or expanded (false). */
|
|
108
|
+
selectionPanelDismissed: boolean;
|
|
109
|
+
/** Space is held: a press pans. */
|
|
110
|
+
spacePan: boolean;
|
|
111
|
+
/** The gesture that is running (`draw`, `move`, `pinch` ...) or null. */
|
|
112
|
+
gestureKind: string | null;
|
|
113
|
+
/** Counts the times the host said that the names of the widgets changed. */
|
|
114
|
+
nameRevision: number;
|
|
115
|
+
/** False until onReady and the first load have had a turn, so the empty-board hint does not flash before saved shapes. */
|
|
116
|
+
emptyHintGateOpen: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface Readable<T> {
|
|
119
|
+
subscribe(run: (value: T) => void): () => void;
|
|
120
|
+
}
|
|
121
|
+
/** Text put on the system clipboard by a copy on the board, so that a picture copied earlier does not win the next paste. */
|
|
122
|
+
export declare const CLIPBOARD_MARKER = "widgetic-canvas-selection";
|
|
123
|
+
/** The longest side a picture gets when it is put on the board (the picture itself keeps its size). */
|
|
124
|
+
export declare const IMAGE_INSERT_MAX_SIDE = 480;
|
|
125
|
+
/** The smallest side of a picture put on the board. */
|
|
126
|
+
export declare const IMAGE_INSERT_MIN_SIDE = 24;
|
|
127
|
+
/**
|
|
128
|
+
* How long a finger rests on the board before the press is a long press (it opens the menu a right click opens), and how
|
|
129
|
+
* far the finger may wander meanwhile, in board pixels. The host times it itself: a browser that sends a `contextmenu`
|
|
130
|
+
* for a long press (Android) is not needed, and one that does not (an iPad) is served the same.
|
|
131
|
+
*/
|
|
132
|
+
export declare const TOUCH_LONG_PRESS_DELAY_MS = 500;
|
|
133
|
+
export declare const TOUCH_LONG_PRESS_SLOP = 8;
|
|
134
|
+
/** How long after the finger that opened the menu lifts its release is still told apart from a choice (see `isMenuHeldByItsFinger`). */
|
|
135
|
+
export declare const TOUCH_MENU_RELEASE_GRACE_MS = 400;
|
|
136
|
+
/** Says a message of the catalog in the language of the canvas (the host only ever asks for keys the catalog has). */
|
|
137
|
+
export type Translate = CatalogTranslate<CanvasMessageKey>;
|
|
138
|
+
/** A picture's size on the board: its own size, or the biggest one that fits `IMAGE_INSERT_MAX_SIDE`. */
|
|
139
|
+
export declare function fitImageSize(naturalWidth: number, naturalHeight: number): {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
/** The tools the shell lets people pick, by the name the shortcuts and menus use. */
|
|
144
|
+
export type ShapeToolName = 'rect' | 'rounded-rect' | 'circle' | 'circle-true' | 'triangle' | 'arrow';
|
|
145
|
+
export declare class CanvasHost {
|
|
146
|
+
#private;
|
|
147
|
+
readonly engine: EngineCore;
|
|
148
|
+
readonly controller: PointerController;
|
|
149
|
+
readonly conversions: ConversionRegistry;
|
|
150
|
+
/** The engine's state as a store. */
|
|
151
|
+
readonly engineStore: Readable<EngineState>;
|
|
152
|
+
/** The host's own state as a store. */
|
|
153
|
+
readonly uiStore: Readable<HostUiState>;
|
|
154
|
+
props: CanvasHostProps;
|
|
155
|
+
/** The words the host draws or says (the shell gives it the language of the page). */
|
|
156
|
+
translate: Translate;
|
|
157
|
+
constructor(initialProps?: Partial<CanvasHostProps>);
|
|
158
|
+
/** The page changed some props. */
|
|
159
|
+
setProps(patch: Partial<CanvasHostProps>): void;
|
|
160
|
+
/** The shell gives the host the words of the page's language. */
|
|
161
|
+
setTranslator(translate: Translate): void;
|
|
162
|
+
get ui(): HostUiState;
|
|
163
|
+
updateUi(patch: Partial<HostUiState>): void;
|
|
164
|
+
/** True while the board is loading or the page says it is (the loader shows, input waits). */
|
|
165
|
+
get isLoading(): boolean;
|
|
166
|
+
/** The tools the page lets people use: the drawing group is the page's to hide, the shapes are always there. */
|
|
167
|
+
get tools(): {
|
|
168
|
+
drawing: boolean;
|
|
169
|
+
};
|
|
170
|
+
/** The shell mounted: the board element exists and has a size. Starts listening and loads the data the page gave. */
|
|
171
|
+
attach(root: HTMLElement, board: HTMLElement): void;
|
|
172
|
+
/** The shell is going away: hands the page its last chance to keep the board, then lets go of everything. */
|
|
173
|
+
destroy(): void;
|
|
174
|
+
/** The element the board's pointer events come from. */
|
|
175
|
+
get boardElement(): HTMLElement | null;
|
|
176
|
+
get rootElement(): HTMLElement | null;
|
|
177
|
+
/**
|
|
178
|
+
* Gives the board the keyboard.
|
|
179
|
+
*
|
|
180
|
+
* A press of the pointer passes `focusVisible: false`: the browser draws the focus ring for a focus that a script moves
|
|
181
|
+
* when the last thing the person did was a key, and a press on the board is not asking for a ring (the keyboard still
|
|
182
|
+
* has the focus, and a Tab or an arrow shows it). Browsers that do not know the option ignore it.
|
|
183
|
+
*/
|
|
184
|
+
focusBoard(options?: {
|
|
185
|
+
focusVisible?: boolean;
|
|
186
|
+
}): void;
|
|
187
|
+
handlePointerDown(event: PointerEvent): void;
|
|
188
|
+
/**
|
|
189
|
+
* Is the menu still held by the finger that opened it? True while that finger is down, and for a moment after it lifts:
|
|
190
|
+
* the browser sends the finger's `click` a moment after `pointerup`, to whatever is under it, and that is not a choice.
|
|
191
|
+
* The menu asks before it acts on an item, so a long press never picks the entry that opened under the finger.
|
|
192
|
+
*/
|
|
193
|
+
isMenuHeldByItsFinger(): boolean;
|
|
194
|
+
handlePointerMove(event: PointerEvent): void;
|
|
195
|
+
handlePointerUp(event: PointerEvent): void;
|
|
196
|
+
handlePointerCancel(event: PointerEvent): void;
|
|
197
|
+
handlePointerLeave(event: PointerEvent): void;
|
|
198
|
+
handleContextMenu(event: MouseEvent): void;
|
|
199
|
+
/** A picture is being dragged over the board: say that it can be dropped. */
|
|
200
|
+
handleDragOver(event: DragEvent): void;
|
|
201
|
+
/** Pictures were dropped on the board: they land where the pointer is. */
|
|
202
|
+
handleDrop(event: DragEvent): void;
|
|
203
|
+
/** Saves whatever the buffer still holds, now. Resolves once the page's save is done. */
|
|
204
|
+
flushAutosave(): Promise<void>;
|
|
205
|
+
/** An immediate save (Cmd+S, the save button, the page's own flushes). */
|
|
206
|
+
saveNow(): void;
|
|
207
|
+
/** The board as the text the page keeps. Null while the board is loading. */
|
|
208
|
+
saveCanvas(): string | null;
|
|
209
|
+
/**
|
|
210
|
+
* Shows saved data. Never throws: text the board cannot read (a canvas of the older engine, or something that is not
|
|
211
|
+
* a canvas) opens as an empty board, says so, and nothing is saved until the person changes something.
|
|
212
|
+
*/
|
|
213
|
+
loadCanvas(jsonString: string): Promise<void>;
|
|
214
|
+
/** Empties the board (an undo step) and tells the page. */
|
|
215
|
+
onClearAllObjects(): void;
|
|
216
|
+
setTool(tool: ToolId, options?: {
|
|
217
|
+
libraryShapeKey?: string | null;
|
|
218
|
+
}): void;
|
|
219
|
+
/** A letter of the keyboard chose a tool (or the menu did). */
|
|
220
|
+
chooseShortcutTool(tool: ToolShortcut): void;
|
|
221
|
+
/** The Select tool: the creator closes the element selector of its widgets when it hears of it. */
|
|
222
|
+
onSelectSelectTool(): void;
|
|
223
|
+
onSelectDrawTool(): void;
|
|
224
|
+
onSelectEraseTool(): void;
|
|
225
|
+
onSelectTextTool(): void;
|
|
226
|
+
onSelectArrowTool(): void;
|
|
227
|
+
onSelectPanTool(): void;
|
|
228
|
+
/** The names are the old ones: `circle` is the oval, `circle-true` the circle. */
|
|
229
|
+
onSelectShapeTool(shapeType: ShapeToolName): void;
|
|
230
|
+
/** The second argument of the old call (the path of the shape) is still accepted, and not needed: the library knows the shape by its key. */
|
|
231
|
+
onSelectLibraryShapeTool(shapeKey: string, _pathData?: string): void;
|
|
232
|
+
/** The image tool opens the file chooser (it needs the click that called it, which is how the toolbar and the key call it). */
|
|
233
|
+
onSelectImageTool(): void;
|
|
234
|
+
/** There are no frames on this board: kept so a page that still calls it keeps working. */
|
|
235
|
+
onSelectFrameTool(): void;
|
|
236
|
+
/** There is no video on this board: kept so a page that still calls it keeps working. */
|
|
237
|
+
onSelectVideoTool(): void;
|
|
238
|
+
zoomIn(): void;
|
|
239
|
+
zoomOut(): void;
|
|
240
|
+
zoomTo(percent: number): void;
|
|
241
|
+
zoomReset(): void;
|
|
242
|
+
zoomFit(): void;
|
|
243
|
+
deselectAll(): void;
|
|
244
|
+
onSelectAllObjects(): void;
|
|
245
|
+
onDeselectAllObjects(): void;
|
|
246
|
+
/** The same as the keys and the menu: copies the selection. Widget cards are made into new widgets by the page. */
|
|
247
|
+
duplicateSelectedObjects(): ObjectId[];
|
|
248
|
+
deleteSelectedObjects(): Promise<boolean>;
|
|
249
|
+
/** The same as the Copy key: remembers the selection for a paste and marks the system clipboard as the board's. */
|
|
250
|
+
copySelection(): boolean;
|
|
251
|
+
/** The same as the Cut key. */
|
|
252
|
+
cutSelection(): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Paste from the menu, centred on a point of the board (in pixels of the board). A copy made on the board wins; without
|
|
255
|
+
* one, a picture on the system clipboard is put on the board when the browser lets the page read it.
|
|
256
|
+
*/
|
|
257
|
+
pasteAt(boardPoint: Point | null): Promise<void>;
|
|
258
|
+
/** A colour for a new shape: a random hue, so that shapes drawn in a row can be told apart. */
|
|
259
|
+
shapeFillColor(): string;
|
|
260
|
+
onGroupSelection(): string | null;
|
|
261
|
+
onUngroupSelection(): void;
|
|
262
|
+
undo(): Promise<void>;
|
|
263
|
+
redo(): Promise<void>;
|
|
264
|
+
/** What the page reads of the selection: a view of the one object, or of the several. */
|
|
265
|
+
getSelectedObject(): HostObject | null;
|
|
266
|
+
addRect(): ObjectId | null;
|
|
267
|
+
addCircle(): ObjectId | null;
|
|
268
|
+
addTriangle(): ObjectId | null;
|
|
269
|
+
/** A label in the middle of the view, ready to be typed in. */
|
|
270
|
+
addText(): ObjectId;
|
|
271
|
+
/** There are no frames on this board: kept so a page that still calls it keeps working. */
|
|
272
|
+
addFrame(): null;
|
|
273
|
+
/** Opens the file chooser and puts the pictures that are chosen on the board. */
|
|
274
|
+
addImage(): Promise<void>;
|
|
275
|
+
/** The SVG entry of the shapes menu: the same as `addImage`, but the chooser only offers vector files. */
|
|
276
|
+
addSvg(): Promise<void>;
|
|
277
|
+
/** Reads picture files and puts them on the board, side by side from `at` (the middle of the view by default), as one step. */
|
|
278
|
+
insertImageFiles(files: readonly (File | Blob)[], at?: Point): Promise<ObjectId[]>;
|
|
279
|
+
insertLoadedImages(pictures: readonly LoadedImageFile[], at?: Point): ObjectId[];
|
|
280
|
+
/** A PNG of everything on the board, cropped to it; an empty string for an empty board. */
|
|
281
|
+
captureCanvasSketch(): Promise<string>;
|
|
282
|
+
/** The selection panel's "convert": hands the page what it needs to make a widget of the selection. */
|
|
283
|
+
convertObjectToWidget(): Promise<void>;
|
|
284
|
+
/** The selection panel's "capture": hands the page a screenshot of the selection. */
|
|
285
|
+
captureSelection(): Promise<void>;
|
|
286
|
+
/** The whole board becomes one card of the widget. Resolves to the id of the card. */
|
|
287
|
+
absorbCanvasSketchIntoWidget(widgetId: string, screenshotDataUrl: string): Promise<string | null>;
|
|
288
|
+
/** Gives a card (or any object, which becomes one) the widget it stands for. */
|
|
289
|
+
linkObjectToWidget(target: ObjectId | {
|
|
290
|
+
id?: ObjectId;
|
|
291
|
+
_objectId?: ObjectId;
|
|
292
|
+
} | null | undefined, widgetId: string, widgetName?: string | null): void;
|
|
293
|
+
/** Gives the card with that id its widget (the page learned the id of the widget it made). */
|
|
294
|
+
linkFrameToWidget(objectId: string, widgetId: string): void;
|
|
295
|
+
/** Marks the selected cards as being copied: a loader shows over them until the page links them. */
|
|
296
|
+
markSelectedAsDuplicating(): void;
|
|
297
|
+
/** Replaces an object, or the selection a conversion remembered under that id, by a card of the widget. */
|
|
298
|
+
replaceObjectWithWidgetImage(objectId: string, widgetId: string, screenshotDataUrl: string): Promise<string | null>;
|
|
299
|
+
updateWidgetImage(widgetId: string, newScreenshotDataUrl: string): void;
|
|
300
|
+
selectWidgetShape(widgetId: string): boolean;
|
|
301
|
+
selectWidgetShapeById(widgetId: string): boolean;
|
|
302
|
+
getSelectedWidgetShapeId(): string | null;
|
|
303
|
+
getHoveredWidgetShapeId(): string | null;
|
|
304
|
+
/** The cards a live widget can be drawn over, with where each is on the page. */
|
|
305
|
+
listWidgetShapeScreenRects(): WidgetScreenRect[];
|
|
306
|
+
/** Where the card of a widget is on the page, with the board it is on. */
|
|
307
|
+
getWidgetShapeScreenRect(widgetId: string): ScreenRect | null;
|
|
308
|
+
/** Where any object is on the page: the id of an object, of a group, or of a selection a conversion remembered. */
|
|
309
|
+
getObjectScreenRect(objectId: string): ScreenRect | null;
|
|
310
|
+
/**
|
|
311
|
+
* The picture of a card as a data address, or null. A card shows its last screenshot; the answer is that one when it
|
|
312
|
+
* is inline (the page asks for it at a moment it cannot wait, so the board does not draw anything new here).
|
|
313
|
+
*/
|
|
314
|
+
getWidgetShapeDataUrl(widgetId: string): string | null;
|
|
315
|
+
/** Hides the screenshot of a card while a live widget covers it (so it does not show through the padding). */
|
|
316
|
+
setWidgetShapeLivePreviewHiddenImage(widgetId: string, hidden: boolean): void;
|
|
317
|
+
/** Puts a card for a widget in the middle of the view (rows of up to four for a batch). */
|
|
318
|
+
addWidgetShape(widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null): string | null;
|
|
319
|
+
getLinkedWidgetIds(): Set<string>;
|
|
320
|
+
keepOnlyWidgetShape(widgetId: string): number;
|
|
321
|
+
/** Takes everything but the card of one widget off the board. Returns how many objects went. */
|
|
322
|
+
removeSketchObjectsKeepingWidget(widgetId: string): number;
|
|
323
|
+
hydrateWidgetShapeMetadata(widgetsById: Map<string, WidgetMetadata>): number;
|
|
324
|
+
markOrphanedWidgetShapes(validWidgetIds: Set<string>): number;
|
|
325
|
+
setPrimaryWidgetShape(widgetId: string): boolean;
|
|
326
|
+
/** The selection chrome's "set as primary": marks the card, then tells the page so it can keep it. */
|
|
327
|
+
handleSetPrimaryFromPanel(widgetId: string): void;
|
|
328
|
+
getPrimaryWidgetId(): string | null;
|
|
329
|
+
/** A live widget covers the card: its own bar moves it, so the body does not. */
|
|
330
|
+
setWidgetShapeBodyDragAllowed(widgetId: string, allowed: boolean): void;
|
|
331
|
+
/** The page's bar drags a card by a distance in page pixels (the zoom, and a board the page scales, are accounted for). */
|
|
332
|
+
translateWidgetShapeByScreen(widgetId: string, dxScreen: number, dyScreen: number): boolean;
|
|
333
|
+
/** The page's bar let go: the move is one step and the board is marked as changed. */
|
|
334
|
+
/** The id the old call carries (the creator still passes it) is not needed: only one card is carried at a time, and the engine knows which. */
|
|
335
|
+
commitWidgetShapeTranslate(_widgetId?: string | null): void;
|
|
336
|
+
setWidgetShapeOverlayDragActive(active: boolean): void;
|
|
337
|
+
/**
|
|
338
|
+
* The lines a text is drawn on. The board draws exactly these (never letting the browser wrap), and the sketch handed to
|
|
339
|
+
* the AI is drawn from the same lines, so what is on the screen is what is sent. Kept per record: a text that did not
|
|
340
|
+
* change is not laid out again on the next frame, and all of them are when the fonts finished loading.
|
|
341
|
+
*/
|
|
342
|
+
textLayoutOf(text: TextObject): TextLayout;
|
|
343
|
+
/** The name drawn on a card: what the page calls the widget, what the card was saved with, or the generic word. */
|
|
344
|
+
widgetLabel(card: WidgetObject): string;
|
|
345
|
+
/** Whether the widget behind a card is gone (the card is kept, with a label that says so). */
|
|
346
|
+
isCardOrphaned(card: WidgetObject): boolean;
|
|
347
|
+
/** A new id for something the shell makes. */
|
|
348
|
+
createId(prefix?: string): ObjectId;
|
|
349
|
+
/** A plain rectangle in the middle of the view (used by the stress page). */
|
|
350
|
+
makeRect(fields?: Partial<Parameters<typeof createRectObject>[0]>): ObjectId;
|
|
351
|
+
}
|