@widgetic/canvas 0.5.40 → 0.5.41
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 +7 -3
- package/dist/canvas/DomCanvas.svelte +4 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +8 -0
- package/dist/canvas/autosaveScheduler.js +89 -37
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +19 -7
- package/dist/canvas/chromeLayout.js +18 -17
- package/dist/canvas/eventScope.js +14 -10
- package/dist/canvas/host/CanvasHost.d.ts +6 -0
- package/dist/canvas/host/CanvasHost.js +1556 -1267
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +25 -4
- package/dist/canvas/host/browserServices.js +116 -65
- package/dist/canvas/host/conversion.js +170 -82
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/pageEvents.js +4 -4
- package/dist/canvas/host/screenRects.js +31 -28
- package/dist/canvas/host/strokeSnap.js +143 -88
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +7 -6
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +25 -13
- package/dist/canvas/shapes/ShapeLibrary.js +148 -138
- package/dist/canvas/shapes/shapeImageStore.js +3 -3
- package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/ui/CanvasHint.svelte +16 -3
- package/dist/canvas/ui/CanvasHint.svelte.d.ts +2 -17
- package/dist/canvas/ui/CanvasToolbar.svelte +7 -7
- package/dist/canvas/ui/ToolButton.svelte +11 -3
- package/dist/canvas/ui/ToolButton.svelte.d.ts +2 -0
- package/dist/canvas/ui/colorModel.js +32 -21
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.js +18 -18
- package/dist/canvas/ui/floatingLayer.js +6 -5
- package/dist/canvas/ui/keyHints.js +11 -9
- package/dist/canvas/ui/popoverSide.js +3 -2
- package/dist/canvas/ui/selectionTraits.js +40 -34
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +1 -1
- package/dist/canvas/ui/sizeLabelVisibility.js +1 -1
- package/dist/canvas/view/SelectionOverlay.svelte +33 -14
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +14 -4
- package/dist/canvas/view/geometry.js +103 -77
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +4 -1
- package/dist/engine/EngineCore.js +801 -695
- package/dist/engine/codec/canvasDocument.js +173 -173
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +38 -26
- package/dist/engine/core/arrow.d.ts +10 -3
- package/dist/engine/core/arrow.js +96 -75
- package/dist/engine/core/arrowBinding.d.ts +69 -0
- package/dist/engine/core/arrowBinding.js +344 -0
- package/dist/engine/core/arrowBindingRecords.d.ts +43 -0
- package/dist/engine/core/arrowBindingRecords.js +141 -0
- package/dist/engine/core/brush.js +94 -67
- package/dist/engine/core/defaults.js +51 -90
- package/dist/engine/core/freehand.js +163 -147
- package/dist/engine/core/geometry.js +54 -47
- package/dist/engine/core/history.js +50 -33
- package/dist/engine/core/hitTest.d.ts +3 -0
- package/dist/engine/core/hitTest.js +83 -69
- package/dist/engine/core/matrix.js +20 -18
- package/dist/engine/core/pathData.js +210 -183
- package/dist/engine/core/rotationReset.js +6 -5
- package/dist/engine/core/scene.d.ts +3 -0
- package/dist/engine/core/scene.js +192 -129
- package/dist/engine/core/scribble.js +84 -59
- package/dist/engine/core/shapePaths.js +15 -12
- package/dist/engine/core/shapeTools.js +63 -72
- package/dist/engine/core/snapping.js +117 -65
- package/dist/engine/core/style.js +64 -31
- package/dist/engine/core/transform.js +94 -83
- package/dist/engine/core/types.d.ts +29 -0
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +36 -23
- package/dist/engine/input/PointerController.js +476 -447
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +12 -1
- package/dist/engine/input/gestures.js +342 -251
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.d.ts +9 -1
- package/dist/engine/input/keyboard.js +46 -27
- package/dist/engine/input/selectionHandles.js +50 -45
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +158 -86
- package/dist/engine/state.d.ts +6 -1
- package/dist/engine/state.js +17 -5
- package/dist/engine/text/layoutText.js +62 -43
- package/dist/engine/text/textMetrics.js +10 -8
- package/dist/engine/widgets.js +137 -101
- package/dist/fonts/interFont.js +68 -17
- package/dist/fonts/workspaceFonts.js +90 -32
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.js +1 -1
- package/dist/i18n/shortcuts.d.ts +12 -0
- package/dist/i18n/shortcuts.js +32 -18
- package/dist/settings/workspaceToolSettings.js +48 -32
- package/dist/tools/components/catalog.d.ts +11 -0
- package/dist/tools/components/catalog.js +270 -0
- package/dist/tools/components/grouping.d.ts +9 -0
- package/dist/tools/components/grouping.js +33 -0
- package/dist/tools/definitions.d.ts +19 -0
- package/dist/tools/definitions.js +147 -0
- package/dist/tools/executors.d.ts +7 -0
- package/dist/tools/executors.js +324 -0
- package/dist/tools/hostAdapter.d.ts +14 -0
- package/dist/tools/hostAdapter.js +40 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/sceneSummary.d.ts +24 -0
- package/dist/tools/sceneSummary.js +170 -0
- package/dist/tools/sketchIntent.d.ts +17 -0
- package/dist/tools/sketchIntent.js +166 -0
- package/dist/tools/types.d.ts +54 -0
- package/dist/tools/types.js +11 -0
- package/package.json +7 -2
|
@@ -9,27 +9,27 @@
|
|
|
9
9
|
import { arrowPointsInWorld, isArrow } from '../core/arrow.js';
|
|
10
10
|
import { distanceBetween } from '../core/geometry.js';
|
|
11
11
|
import { worldToScreen } from '../core/viewport.js';
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var MOUSE_ARROW_METRICS = { endReach: 12, bendReach: 10 };
|
|
13
|
+
var TOUCH_ARROW_METRICS = { endReach: 24, bendReach: 22 };
|
|
14
14
|
export function arrowHandleMetricsFor(pointerType) {
|
|
15
15
|
return pointerType === 'touch' ? TOUCH_ARROW_METRICS : MOUSE_ARROW_METRICS;
|
|
16
16
|
}
|
|
17
17
|
/** An end of the arrow while nobody is near it: a round handle of this diameter (screen pixels). */
|
|
18
|
-
export
|
|
18
|
+
export var ARROW_END_HANDLE_SIZE = 10;
|
|
19
19
|
/** The bend handle at rest: a little smaller, so the ends read as the ends. */
|
|
20
|
-
export
|
|
20
|
+
export var ARROW_BEND_HANDLE_SIZE = 8;
|
|
21
21
|
/** Any arrow handle under the pointer, and while it is dragged. */
|
|
22
|
-
export
|
|
22
|
+
export var ARROW_HANDLE_ACTIVE_SIZE = 14;
|
|
23
23
|
/** The arrow that is selected, when the selection is that arrow and nothing else: the one selection that has handles of its own. */
|
|
24
24
|
export function singleArrowOf(shapes, selectedIds) {
|
|
25
25
|
if (shapes.length !== 1 || selectedIds.length !== 1)
|
|
26
26
|
return null;
|
|
27
|
-
|
|
27
|
+
var only = shapes[0];
|
|
28
28
|
return isArrow(only) && only.id === selectedIds[0] ? only : null;
|
|
29
29
|
}
|
|
30
30
|
/** The places of the three handles on the screen, in pixels of the board. */
|
|
31
31
|
export function arrowHandlePositions(arrow, viewport) {
|
|
32
|
-
|
|
32
|
+
var points = arrowPointsInWorld(arrow);
|
|
33
33
|
return {
|
|
34
34
|
start: worldToScreen(viewport, points.start),
|
|
35
35
|
end: worldToScreen(viewport, points.end),
|
|
@@ -41,17 +41,17 @@ export function arrowHandlePositions(arrow, viewport) {
|
|
|
41
41
|
* reach on both (`TOUCH_ARROW_METRICS`), so that on no kind of pointer does its area sit on an end and cover it. A shorter arrow
|
|
42
42
|
* has its two ends only, and the same arrow shows the same handles whoever holds the pointer.
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
44
|
+
export var BEND_HANDLE_CLEARANCE = 46;
|
|
45
45
|
/** Whether the bend handle is offered for an arrow whose handles are at these places. */
|
|
46
46
|
export function bendHandleAvailable(positions) {
|
|
47
47
|
return distanceBetween(positions.start, positions.bend) > BEND_HANDLE_CLEARANCE && distanceBetween(positions.end, positions.bend) > BEND_HANDLE_CLEARANCE;
|
|
48
48
|
}
|
|
49
49
|
/** The handle of an arrow under a pixel of the board, or null. An end wins over the middle where their areas meet. */
|
|
50
50
|
export function hitArrowHandle(arrow, viewport, screenPoint, metrics) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
var positions = arrowHandlePositions(arrow, viewport);
|
|
52
|
+
var startDistance = distanceBetween(positions.start, screenPoint);
|
|
53
|
+
var endDistance = distanceBetween(positions.end, screenPoint);
|
|
54
|
+
var nearestEnd = startDistance <= endDistance ? 'start' : 'end';
|
|
55
55
|
if (Math.min(startDistance, endDistance) <= metrics.endReach)
|
|
56
56
|
return nearestEnd;
|
|
57
57
|
if (bendHandleAvailable(positions) && distanceBetween(positions.bend, screenPoint) <= metrics.bendReach)
|
|
@@ -45,6 +45,10 @@ export declare function createRotateGesture(context: GestureContext, start: Poin
|
|
|
45
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
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
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
|
+
* An end that is dragged over a shape is tied to it (to a point of its outline near the edge, to its middle further in), and the board
|
|
50
|
+
* shows which shape and where; dragged off the shape it is free again. Alt, or Shift (the end is held to the steps of 15 degrees then),
|
|
51
|
+
* ties it to nothing. The shape the other end is tied to is passed over: the two ends of an arrow are never tied to the same shape.
|
|
48
52
|
*/
|
|
49
53
|
export declare function createArrowHandleGesture(context: GestureContext, start: PointerInput, arrow: ArrowObject, handle: ArrowHandleId): Gesture;
|
|
50
54
|
/**
|
|
@@ -62,7 +66,14 @@ export declare function createPanGesture(context: GestureContext, start: Pointer
|
|
|
62
66
|
* hand spends (a slow stroke swells, a quick one thins). Shift draws a straight line from where the pointer went down.
|
|
63
67
|
*/
|
|
64
68
|
export declare function createDrawGesture(context: GestureContext, start: PointerInput): Gesture;
|
|
65
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Drags a shape out. A click places it at its default size. Shift constrains it; Alt draws it from the middle.
|
|
71
|
+
*
|
|
72
|
+
* An arrow drawn by a drag is tied to the shapes it is drawn between: its tail to the shape the press was on, its head to the shape the
|
|
73
|
+
* pointer is over (a point of the outline near the edge, the middle further in; the board shows which and where while the pointer is
|
|
74
|
+
* over it). Alt ties it to nothing; Shift holds the head to the steps of 15 degrees, so the head is not tied; a click places the
|
|
75
|
+
* default arrow, tied to nothing; the two ends are never tied to the same shape.
|
|
76
|
+
*/
|
|
66
77
|
export declare function createShapeGesture(context: GestureContext, start: PointerInput, kind: DragShapeKind, libraryKey: string | null): Gesture;
|
|
67
78
|
/** A click makes a label that grows with its text, a drag makes a box of that width. Then the text is edited. */
|
|
68
79
|
export declare function createTextGesture(context: GestureContext, start: PointerInput): Gesture;
|