@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,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything a pointer can do from press to release, one small object per kind of gesture.
|
|
3
|
+
*
|
|
4
|
+
* A gesture changes the scene *transiently* on every move and the engine records one undo step when it ends,
|
|
5
|
+
* so a drag of a hundred frames is one step. `cancel` puts the board back as it was before the press.
|
|
6
|
+
*/
|
|
7
|
+
import type { ArrowHandleId, ArrowObject } from '../core/arrow.js';
|
|
8
|
+
import type { DragShapeKind } from '../core/shapeTools.js';
|
|
9
|
+
import type { ResizeHandle, SelectionFrame } from '../core/transform.js';
|
|
10
|
+
import type { ObjectId, ShapeObject } from '../core/types.js';
|
|
11
|
+
import type { RotateSource } from './selectionHandles.js';
|
|
12
|
+
import type { Gesture, GestureContext, PointerInput } from './types.js';
|
|
13
|
+
/** A press that moves less than this (screen pixels) is still a click. */
|
|
14
|
+
export declare const DRAG_THRESHOLD = 3;
|
|
15
|
+
/** How far the eraser reaches, in screen pixels. */
|
|
16
|
+
export declare const ERASER_RADIUS = 8;
|
|
17
|
+
/** The step a rotation snaps to while Shift (or Ctrl, or Meta) is held, in degrees. */
|
|
18
|
+
export declare const ROTATION_SNAP_DEGREES = 5;
|
|
19
|
+
/** When true, a text corner resize hides the pointer and draws an arrow on the corner. */
|
|
20
|
+
export declare const ENABLE_TEXT_VIRTUAL_CURSOR = false;
|
|
21
|
+
export interface MoveGestureOptions {
|
|
22
|
+
/** What a press that never became a drag does (a click on one of several selected objects selects only it). */
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
/** The press can never become a drag (a widget card a live widget covers is moved by the host's own bar). */
|
|
25
|
+
immovable?: boolean;
|
|
26
|
+
/** When the drag begins, leave the selection in place and drag a copy (Alt/Option). */
|
|
27
|
+
duplicateOnDrag?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Drags the selected units. Nothing moves until the pointer has gone `DRAG_THRESHOLD` pixels. */
|
|
30
|
+
export declare function createMoveGesture(context: GestureContext, start: PointerInput, unitIds: readonly ObjectId[], options?: MoveGestureOptions): Gesture;
|
|
31
|
+
/** Drags a handle of the selection. Nothing changes until the pointer has gone `DRAG_THRESHOLD` pixels: a press and a double press are not a stretch. */
|
|
32
|
+
export declare function createResizeGesture(context: GestureContext, start: PointerInput, handle: ResizeHandle, frame: SelectionFrame, shapes: readonly ShapeObject[]): Gesture;
|
|
33
|
+
/**
|
|
34
|
+
* Turns the selection about the middle of its frame, by the angle the pointer travels about that middle (the selection
|
|
35
|
+
* does not jump to the pointer). Shift, Ctrl or Meta holds it to steps of `ROTATION_SNAP_DEGREES`. Nothing turns until
|
|
36
|
+
* the pointer has gone `DRAG_THRESHOLD` pixels. `source` is where the press landed: the dot (the pointer is a hand that
|
|
37
|
+
* holds it) or the zone outside a corner (the turning arrow).
|
|
38
|
+
*/
|
|
39
|
+
export declare function createRotateGesture(context: GestureContext, start: PointerInput, frame: SelectionFrame, shapes: readonly ShapeObject[], source?: RotateSource): Gesture;
|
|
40
|
+
/**
|
|
41
|
+
* Drags an end or the middle of the selected arrow, the way tldraw does.
|
|
42
|
+
*
|
|
43
|
+
* An end follows the pointer by the distance the pointer has travelled since the press, so the handle does not jump to the
|
|
44
|
+
* pointer when it was taken a few pixels off its middle; Shift holds the arrow to steps of `ARROW_SNAP_DEGREES` about the other
|
|
45
|
+
* end. The middle bends the arrow: its handle is moved only across the arrow (the pointer's distance from the line between the
|
|
46
|
+
* ends), so it follows the hand without sliding along the shaft, and a bend too small to be a bend is a straight arrow. Nothing
|
|
47
|
+
* changes until the pointer has gone `DRAG_THRESHOLD` pixels, the whole drag is one undo step, and Escape puts the arrow back.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createArrowHandleGesture(context: GestureContext, start: PointerInput, arrow: ArrowObject, handle: ArrowHandleId): Gesture;
|
|
50
|
+
/**
|
|
51
|
+
* Drags a rectangle over the board. While it is dragged, what it touches is outlined the way the unit under the pointer is
|
|
52
|
+
* (the overlay's `marqueeHover`), so the person sees what the release will take; the selection is made at the release, from
|
|
53
|
+
* the same units (added to the ones that were selected when Shift was held at the press).
|
|
54
|
+
*/
|
|
55
|
+
export declare function createMarqueeGesture(context: GestureContext, start: PointerInput): Gesture;
|
|
56
|
+
/** Drags the view. `onTap` is what a press that never moved does (a finger on empty board clears the selection). */
|
|
57
|
+
export declare function createPanGesture(context: GestureContext, start: PointerInput, options?: {
|
|
58
|
+
onTap?: () => void;
|
|
59
|
+
}): Gesture;
|
|
60
|
+
/**
|
|
61
|
+
* Draws with the brush. The line is as thick as the hand presses: a pen's own pressure, or, for a mouse or a finger, the time the
|
|
62
|
+
* hand spends (a slow stroke swells, a quick one thins). Shift draws a straight line from where the pointer went down.
|
|
63
|
+
*/
|
|
64
|
+
export declare function createDrawGesture(context: GestureContext, start: PointerInput): Gesture;
|
|
65
|
+
/** Drags a shape out. A click places it at its default size. Shift constrains it; Alt draws it from the middle. */
|
|
66
|
+
export declare function createShapeGesture(context: GestureContext, start: PointerInput, kind: DragShapeKind, libraryKey: string | null): Gesture;
|
|
67
|
+
/** A click makes a label that grows with its text, a drag makes a box of that width. Then the text is edited. */
|
|
68
|
+
export declare function createTextGesture(context: GestureContext, start: PointerInput): Gesture;
|
|
69
|
+
/**
|
|
70
|
+
* Marks what the pointer passes over and removes it when the pointer is released.
|
|
71
|
+
*
|
|
72
|
+
* The marked shapes stay where they are, drawn faded, so the person sees what is about to go, and a trail follows the pointer
|
|
73
|
+
* (the way tldraw's eraser works). Released, they all go in one undo step; Escape leaves them as they were. Widget cards are
|
|
74
|
+
* never erased: they are removed with Delete.
|
|
75
|
+
*
|
|
76
|
+
* A shape in a group takes the whole group with it, unless the press began inside the group's box: then the members are taken
|
|
77
|
+
* one by one. A press that does not move marks what lies under it and removes that on release (with Ctrl or Cmd only the top shape).
|
|
78
|
+
*/
|
|
79
|
+
export declare function createEraseGesture(context: GestureContext, start: PointerInput): Gesture;
|