@widgetic/canvas 0.5.35 → 0.5.37
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 +449 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +221 -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 +348 -0
- package/dist/canvas/host/CanvasHost.js +1715 -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 +53 -0
- package/dist/canvas/host/conversion.js +125 -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 +7 -7
- package/dist/canvas/index.js +8 -8
- 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 +11 -11
- package/dist/canvas/toolbarPosition.js +11 -24
- 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 +21 -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 +156 -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 +145 -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 +52 -124
- package/dist/i18n/messages.js +59 -133
- package/dist/i18n/shortcuts.d.ts +0 -1
- package/dist/i18n/shortcuts.js +2 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13363
- package/dist/canvas/Canvas.svelte.d.ts +0 -286
- 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,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine of the canvas: the one place that owns the board.
|
|
3
|
+
*
|
|
4
|
+
* It holds an immutable snapshot of everything the board shows (the objects, the selection, the view, the tool)
|
|
5
|
+
* and replaces it on every change; a view subscribes and redraws the slices that came out different. Nothing here
|
|
6
|
+
* knows about the DOM or about Svelte, so every rule (what a delete asks, what a paste does, how undo steps) is
|
|
7
|
+
* tested in Node with a fake clock and a fake text measurer.
|
|
8
|
+
*
|
|
9
|
+
* Gestures (a drag, a resize, a stroke) change the scene *transiently* while they run and *commit* once when they
|
|
10
|
+
* end, so one gesture is one undo step. The pointer controller drives them; everything else (the menus, the
|
|
11
|
+
* keyboard, the host's own calls) uses the commands below, each of which is one step.
|
|
12
|
+
*/
|
|
13
|
+
import type { ParsedCanvas, SerializeOptions } from './codec/canvasDocument.js';
|
|
14
|
+
import type { AlignMode, DistributeAxis } from './core/arrange.js';
|
|
15
|
+
import type { ArrowHandleId } from './core/arrow.js';
|
|
16
|
+
import type { ReorderMode, Scene } from './core/scene.js';
|
|
17
|
+
import type { StylePatch } from './core/style.js';
|
|
18
|
+
import type { SelectionFrame } from './core/transform.js';
|
|
19
|
+
import type { ObjectId, Point, Rect, SceneObject, ShapeObject, Size, Viewport, WidgetObject } from './core/types.js';
|
|
20
|
+
import type { EngineOverlay, EngineState, PendingWidgetState, ToolId, WidgetRuntime } from './state.js';
|
|
21
|
+
import type { MeasureText } from './text/layoutText.js';
|
|
22
|
+
/** How many undo steps the board keeps (as the canvas it replaces did). */
|
|
23
|
+
export declare const HISTORY_LIMIT = 50;
|
|
24
|
+
/** How far a duplicate or a repeated paste lands from the original, in world units. */
|
|
25
|
+
export declare const PASTE_OFFSET = 20;
|
|
26
|
+
/** Arrow-key nudges within this time of each other are one undo step. */
|
|
27
|
+
export declare const NUDGE_MERGE_MS = 700;
|
|
28
|
+
/** Room left around the board when it is fitted to the view, in screen pixels. */
|
|
29
|
+
export declare const VIEW_FIT_PADDING = 48;
|
|
30
|
+
/** The longest a text may be, in letters. */
|
|
31
|
+
export declare const MAX_TEXT_LENGTH = 100000;
|
|
32
|
+
/** A shape turned by less than this (degrees) stands upright: there is nothing for a reset to do. */
|
|
33
|
+
export declare const UPRIGHT_TOLERANCE_DEGREES = 0.01;
|
|
34
|
+
export interface EngineServices {
|
|
35
|
+
/** Makes the id of a new object. */
|
|
36
|
+
createId?: (prefix: string) => ObjectId;
|
|
37
|
+
/** Measures a piece of text for the layout of text objects (the browser's canvas in the app, a fixed advance in tests). */
|
|
38
|
+
measureText?: MeasureText;
|
|
39
|
+
now?: () => number;
|
|
40
|
+
random?: () => number;
|
|
41
|
+
/** Schedules an animation frame; returns a function that cancels it (tests pass a manual clock). */
|
|
42
|
+
requestAnimationFrame?: (callback: (time: number) => void) => () => void;
|
|
43
|
+
}
|
|
44
|
+
/** What the engine tells the host shell. Every hook is optional and read at the moment it is needed. */
|
|
45
|
+
export interface EngineHooks {
|
|
46
|
+
/** The person changed the board: it needs saving. */
|
|
47
|
+
onDirty?: () => void;
|
|
48
|
+
/** The board was emptied by "clear all". */
|
|
49
|
+
onCleared?: () => void;
|
|
50
|
+
/** The selection changed (a selection, a deselection, after a delete or an undo). */
|
|
51
|
+
onSelectionChange?: (selectedIds: readonly ObjectId[]) => void;
|
|
52
|
+
/** Widget cards are about to be deleted: one question per widget, and one `false` cancels the whole delete. */
|
|
53
|
+
confirmWidgetDeletion?: ((widgetId: string) => Promise<boolean> | boolean) | null;
|
|
54
|
+
/** A widget card was duplicated or pasted: the host makes a copy of the widget and links it with `linkObjectToWidget`. */
|
|
55
|
+
onWidgetDuplicated?: ((sourceWidgetId: string, clone: WidgetObject) => void) | null;
|
|
56
|
+
/** Something went wrong in a hook the host supplied. */
|
|
57
|
+
onError?: (message: string, error: unknown) => void;
|
|
58
|
+
}
|
|
59
|
+
type Listener = (state: EngineState) => void;
|
|
60
|
+
/** The cursor a tool shows over the board when nothing is under the pointer. */
|
|
61
|
+
export declare function cursorForTool(tool: ToolId): string;
|
|
62
|
+
export declare class EngineCore {
|
|
63
|
+
#private;
|
|
64
|
+
/** What the host shell listens to; the shell sets its own functions here. */
|
|
65
|
+
hooks: EngineHooks;
|
|
66
|
+
/** Whether a new shape is plain white with a grey outline (true) or gets a random colour. */
|
|
67
|
+
wireframeMode: boolean;
|
|
68
|
+
/** The last place the pointer was over the board, in world units: where a paste lands. */
|
|
69
|
+
lastPointerWorld: Point | null;
|
|
70
|
+
readonly services: Required<EngineServices>;
|
|
71
|
+
constructor(services?: EngineServices);
|
|
72
|
+
get state(): EngineState;
|
|
73
|
+
/** Calls the listener after every change of the state. Returns the function that stops it. */
|
|
74
|
+
subscribe(listener: Listener): () => void;
|
|
75
|
+
/** Lets go of every listener and hook (the board was removed from the page). */
|
|
76
|
+
dispose(): void;
|
|
77
|
+
/** Stops an upright animation in progress and records the angle on screen as one undo step. */
|
|
78
|
+
cancelRotationReset(): void;
|
|
79
|
+
/** The objects of the scene by id. Built once per scene and kept while the scene is the same array. */
|
|
80
|
+
sceneIndex(scene?: Scene): Map<ObjectId, SceneObject>;
|
|
81
|
+
getObject(id: ObjectId): SceneObject | undefined;
|
|
82
|
+
/** The objects that are selected (a group counts once). */
|
|
83
|
+
selectedObjects(): SceneObject[];
|
|
84
|
+
/**
|
|
85
|
+
* The shapes the selection draws: its members when a group is selected. Found once for a scene and a selection and kept
|
|
86
|
+
* while they are the same ones: the frame, the handles and the panel each ask at every step of a drag.
|
|
87
|
+
*/
|
|
88
|
+
selectedShapes(): readonly ShapeObject[];
|
|
89
|
+
/** The box the selection handles surround, or null when nothing is selected. */
|
|
90
|
+
selectionFrame(): SelectionFrame | null;
|
|
91
|
+
isEmpty(): boolean;
|
|
92
|
+
/** Shows a canvas that was read from saved data. History starts again from it, and it is not "changed". */
|
|
93
|
+
load(parsed: ParsedCanvas, options?: {
|
|
94
|
+
fitView?: boolean;
|
|
95
|
+
}): void;
|
|
96
|
+
/** Reads saved data (text or an object) and shows it. Never throws: a bad document loads as an empty board. */
|
|
97
|
+
loadDocument(input: unknown, options?: {
|
|
98
|
+
fitView?: boolean;
|
|
99
|
+
}): ParsedCanvas;
|
|
100
|
+
/** The board as text to store. A card still waiting for its widget, and a text nobody typed in, are left out. */
|
|
101
|
+
serialize(options?: SerializeOptions): string;
|
|
102
|
+
/** Forgets what can be undone (after the host replaced the board). */
|
|
103
|
+
resetHistory(): void;
|
|
104
|
+
setLoading(loading: boolean): void;
|
|
105
|
+
setViewSize(size: Size): void;
|
|
106
|
+
/**
|
|
107
|
+
* Puts a new scene on the board. `transient` is for the frames of a gesture (nothing is recorded), `push`
|
|
108
|
+
* records one undo step and tells the host the board changed, `replace` changes the current step.
|
|
109
|
+
*/
|
|
110
|
+
applyScene(next: Scene, mode?: 'transient' | 'push' | 'replace'): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Puts a scene on the board with no undo step and without telling the host that the board changed: a repair
|
|
113
|
+
* of what was loaded (a name filled in), not an edit.
|
|
114
|
+
*/
|
|
115
|
+
applySilently(next: Scene): void;
|
|
116
|
+
/** Records the scene as it is now as one undo step (the end of a gesture). False when nothing changed since the last step. */
|
|
117
|
+
commit(): boolean;
|
|
118
|
+
/** Throws away what a gesture did and goes back to the last step (Escape in the middle of a drag). */
|
|
119
|
+
revertToCommitted(): void;
|
|
120
|
+
undo(): boolean;
|
|
121
|
+
redo(): boolean;
|
|
122
|
+
/** Adds objects on top of the board in one step. Returns their ids. */
|
|
123
|
+
addObjects(objects: readonly SceneObject[], options?: {
|
|
124
|
+
select?: boolean;
|
|
125
|
+
}): ObjectId[];
|
|
126
|
+
/** Removes objects (and what is inside them) without asking anyone. */
|
|
127
|
+
removeObjects(ids: Iterable<ObjectId>): boolean;
|
|
128
|
+
/** Deletes objects, first asking the host about each widget card among them. Resolves false when the host said no. */
|
|
129
|
+
deleteObjects(ids: Iterable<ObjectId>): Promise<boolean>;
|
|
130
|
+
deleteSelection(): Promise<boolean>;
|
|
131
|
+
/** Empties the board in one undoable step and tells the host. */
|
|
132
|
+
clearAll(): void;
|
|
133
|
+
/** Selects units (a group counts once). Everything else is deselected unless `additive`. */
|
|
134
|
+
select(ids: Iterable<ObjectId>, options?: {
|
|
135
|
+
additive?: boolean;
|
|
136
|
+
}): void;
|
|
137
|
+
/** Adds the unit to the selection, or takes it out when it is in (Shift-click). */
|
|
138
|
+
toggleSelection(id: ObjectId): void;
|
|
139
|
+
/** Deselects everything and leaves the group that was entered. */
|
|
140
|
+
clearSelection(): void;
|
|
141
|
+
selectAll(): void;
|
|
142
|
+
/** Makes the members of a group pickable one by one, and selects one of them. */
|
|
143
|
+
enterGroup(groupId: ObjectId, selectId?: ObjectId): void;
|
|
144
|
+
/** Goes back out of the entered group and selects the group itself. */
|
|
145
|
+
exitGroup(): void;
|
|
146
|
+
setHover(id: ObjectId | null): void;
|
|
147
|
+
/** The pointer is over the turning dot of the selection (or left it): the dot grows while it is. */
|
|
148
|
+
setRotationDotHover(hovered: boolean): void;
|
|
149
|
+
/** The pointer is over (or is dragging) an end or the middle of the selected arrow, or left them: that handle grows. */
|
|
150
|
+
setArrowHandleHover(handle: ArrowHandleId | null): void;
|
|
151
|
+
/** The unit under a world point. */
|
|
152
|
+
hitTest(worldPoint: Point, ignore?: ReadonlySet<ObjectId>): ObjectId | null;
|
|
153
|
+
/** Every unit under a world point, the lowest first (what an Alt-click steps through). */
|
|
154
|
+
hitTestStack(worldPoint: Point): ObjectId[];
|
|
155
|
+
/** The units a rectangle of the world takes. */
|
|
156
|
+
hitTestRect(rect: Rect, mode?: 'intersect' | 'contain', ignore?: ReadonlySet<ObjectId>): ObjectId[];
|
|
157
|
+
setOverlay(patch: Partial<EngineOverlay>): void;
|
|
158
|
+
clearOverlay(): void;
|
|
159
|
+
/** The eraser's trail begins (the pointer went past the drag threshold). The host's frame clock runs while `state.scribble` is not null. */
|
|
160
|
+
beginScribble(): void;
|
|
161
|
+
/** The pointer reached a place of the board (world units); the next step of the trail takes it in. */
|
|
162
|
+
extendScribble(world: Point): void;
|
|
163
|
+
/** The pointer let go: the trail is eaten away over the next frames. */
|
|
164
|
+
stopScribble(): void;
|
|
165
|
+
/**
|
|
166
|
+
* One frame of the trail's life, `elapsedMs` after the last one. Returns false when there is no trail any more (the
|
|
167
|
+
* host stops its clock), true while it lives.
|
|
168
|
+
*/
|
|
169
|
+
stepScribble(elapsedMs: number): boolean;
|
|
170
|
+
setCursor(cursor: string): void;
|
|
171
|
+
setTool(tool: ToolId, options?: {
|
|
172
|
+
libraryShapeKey?: string | null;
|
|
173
|
+
keepSelection?: boolean;
|
|
174
|
+
}): void;
|
|
175
|
+
/** Back to the Select tool, unless the person asked for the tool to stay. */
|
|
176
|
+
revertToSelect(options?: {
|
|
177
|
+
force?: boolean;
|
|
178
|
+
}): void;
|
|
179
|
+
setStickyTool(sticky: boolean): void;
|
|
180
|
+
setViewport(viewport: Viewport): void;
|
|
181
|
+
panBy(deltaX: number, deltaY: number): void;
|
|
182
|
+
/** Zooms and keeps the world point under `screenPoint` where it is. */
|
|
183
|
+
zoomAt(screenPoint: Point, zoom: number): void;
|
|
184
|
+
/** One step up or down the zoom ladder, about the centre of the view. */
|
|
185
|
+
zoomStep(direction: 1 | -1): void;
|
|
186
|
+
/** A zoom level (1 is 100%), about the centre of the view. */
|
|
187
|
+
zoomTo(zoom: number): void;
|
|
188
|
+
/** 100%, with the world origin where it was at the centre of the view. */
|
|
189
|
+
zoomReset(): void;
|
|
190
|
+
/** Shows everything on the board. An empty board goes back to the start. */
|
|
191
|
+
zoomToFit(): void;
|
|
192
|
+
/** Shows the selection, or everything when nothing is selected. */
|
|
193
|
+
zoomToSelection(): void;
|
|
194
|
+
/** The rectangle of the world that is on screen. */
|
|
195
|
+
visibleRect(): Rect;
|
|
196
|
+
/** The point of the world at a point of the board element. */
|
|
197
|
+
toWorld(screenPoint: Point): Point;
|
|
198
|
+
/** The middle of what is on screen, in world units (where a button puts a new object). */
|
|
199
|
+
visibleCenter(): Point;
|
|
200
|
+
/** Fonts finished loading: letters changed width, so every text is laid out again. */
|
|
201
|
+
notifyFontsChanged(): void;
|
|
202
|
+
/** Remembers the font family for the next text object the person places. */
|
|
203
|
+
setPreferredTextFontFamily(fontFamily: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Makes a text object, puts it on the board and starts editing it. A click makes a label whose width follows its
|
|
206
|
+
* text; a width makes a box whose lines wrap. Nothing is recorded until the editing ends with text in it.
|
|
207
|
+
*/
|
|
208
|
+
createText(point: Point, options?: {
|
|
209
|
+
width?: number;
|
|
210
|
+
}): ObjectId;
|
|
211
|
+
/** Starts editing the text of an existing text object. */
|
|
212
|
+
beginTextEdit(id: ObjectId): boolean;
|
|
213
|
+
/** The text the person has typed so far; the box is laid out again on every call. */
|
|
214
|
+
updateEditingText(text: string): void;
|
|
215
|
+
/**
|
|
216
|
+
* Finishes the edit. An empty text is removed (a new one leaves nothing behind, not even an undo step);
|
|
217
|
+
* otherwise creation and typing together are one undo step.
|
|
218
|
+
*/
|
|
219
|
+
endTextEdit(): ObjectId | null;
|
|
220
|
+
/** Changes how the selection looks. `commit: false` is for a slider that is still being dragged: call `commit()` when it ends. */
|
|
221
|
+
setStyle(patch: StylePatch, options?: {
|
|
222
|
+
commit?: boolean;
|
|
223
|
+
}): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Turns the one selected shape back upright, about its own middle (a double click on the turning dot). One undo step.
|
|
226
|
+
* False when the selection is not a single shape, or the shape stands upright already.
|
|
227
|
+
*/
|
|
228
|
+
resetSelectionRotation(): boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Lays the one selected text out in one line again, as it was when it was made: its width follows its letters (a
|
|
231
|
+
* double click on its side handle). One undo step. False when the selection is not a single text, or it follows its letters already.
|
|
232
|
+
*/
|
|
233
|
+
fitSelectedTextToContent(): boolean;
|
|
234
|
+
/** Moves the selection by a distance (an arrow key). Presses close together are one undo step. */
|
|
235
|
+
nudgeSelection(deltaX: number, deltaY: number): boolean;
|
|
236
|
+
alignSelection(mode: AlignMode): boolean;
|
|
237
|
+
distributeSelection(axis: DistributeAxis): boolean;
|
|
238
|
+
reorderSelection(mode: ReorderMode): boolean;
|
|
239
|
+
/** Puts the selected units in a group, which becomes the selection. */
|
|
240
|
+
groupSelection(): boolean;
|
|
241
|
+
/** Dissolves the selected groups; their members become the selection. */
|
|
242
|
+
ungroupSelection(): boolean;
|
|
243
|
+
hasClipboard(): boolean;
|
|
244
|
+
/** Remembers the selection for a paste. */
|
|
245
|
+
copySelection(): boolean;
|
|
246
|
+
/** Copies the selection and removes it, without asking about widget cards: the widget itself stays where it is stored. */
|
|
247
|
+
cutSelection(): boolean;
|
|
248
|
+
/** Puts a copy of the clipboard on the board, centred on `at` (or shifted a little from the original). Returns the new ids. */
|
|
249
|
+
paste(at?: Point | null): ObjectId[];
|
|
250
|
+
/** A copy of the selection, a little to the side and below. The copy becomes the selection. */
|
|
251
|
+
duplicateSelection(): ObjectId[];
|
|
252
|
+
/** Copies the selection in place for an Alt-drag: one undo step when the drag ends. */
|
|
253
|
+
duplicateSelectionForDrag(): ObjectId[];
|
|
254
|
+
/** Marks cards as waiting for the host (a loader is shown over them). `null` clears the mark. */
|
|
255
|
+
setPending(id: ObjectId, state: PendingWidgetState | null): void;
|
|
256
|
+
/** What the host said about a widget's card, with the defaults for what it never said. */
|
|
257
|
+
widgetRuntime(widgetId: string): WidgetRuntime;
|
|
258
|
+
/** Records what the host says about a widget's card. True when something changed. */
|
|
259
|
+
setWidgetRuntime(widgetId: string, patch: Partial<WidgetRuntime>): boolean;
|
|
260
|
+
/** The widget whose card is under the pointer, or null. */
|
|
261
|
+
setHoverWidget(widgetId: string | null): void;
|
|
262
|
+
/** The host's own bar is dragging a card. */
|
|
263
|
+
setOverlayDragActive(active: boolean): void;
|
|
264
|
+
/** Gives a card (or any object, which becomes a card) the widget it stands for. The card becomes the selection. */
|
|
265
|
+
linkObjectToWidget(target: ObjectId | {
|
|
266
|
+
id: ObjectId;
|
|
267
|
+
}, widgetId: string, name?: string | null): boolean;
|
|
268
|
+
/** Drops a card that was waiting for a widget and will never get one. */
|
|
269
|
+
discardPending(id: ObjectId): boolean;
|
|
270
|
+
/** Every widget card that is on the board for good (one still being copied does not count). */
|
|
271
|
+
widgetCards(): WidgetObject[];
|
|
272
|
+
}
|
|
273
|
+
export {};
|