@widgetic/canvas 0.5.43 → 0.5.45
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/dist/canvas/DomCanvas.svelte +56 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +59 -28
- 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 +21 -19
- package/dist/canvas/eventScope.js +14 -10
- package/dist/canvas/host/CanvasHost.d.ts +87 -2
- package/dist/canvas/host/CanvasHost.js +1948 -1394
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +32 -5
- package/dist/canvas/host/boardFiles.d.ts +90 -0
- package/dist/canvas/host/boardFiles.js +155 -0
- package/dist/canvas/host/browserServices.d.ts +17 -0
- package/dist/canvas/host/browserServices.js +211 -65
- package/dist/canvas/host/conversion.js +170 -82
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +21 -18
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pictureSaves.js +11 -9
- package/dist/canvas/host/screenRects.js +31 -28
- package/dist/canvas/host/storedPictures.js +243 -149
- package/dist/canvas/host/strokeSnap.js +143 -88
- package/dist/canvas/index.d.ts +2 -0
- 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 +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +17 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/canvas/ui/ColorField.svelte +7 -2
- package/dist/canvas/ui/SelectionPanel.svelte +105 -42
- package/dist/canvas/ui/ShapesMenu.svelte +65 -31
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
- package/dist/canvas/ui/ToolButton.svelte +35 -54
- package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
- package/dist/canvas/ui/colorModel.js +32 -21
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +26 -4
- package/dist/canvas/ui/floatingCard.js +43 -21
- package/dist/canvas/ui/floatingLayer.js +6 -5
- package/dist/canvas/ui/icons.d.ts +1 -1
- package/dist/canvas/ui/icons.js +1 -1
- package/dist/canvas/ui/keyHints.js +11 -9
- package/dist/canvas/ui/popoverSide.js +3 -2
- package/dist/canvas/ui/selectionTraits.d.ts +12 -0
- package/dist/canvas/ui/selectionTraits.js +66 -35
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
- package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
- package/dist/canvas/view/CanvasStage.svelte +7 -2
- package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
- package/dist/canvas/view/SelectionOverlay.svelte +17 -10
- package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +90 -71
- package/dist/canvas/view/liftedScene.js +36 -24
- package/dist/canvas/view/mountedScene.js +79 -76
- package/dist/components/CanvasBoardPoster.svelte +206 -0
- package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +8 -0
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +111 -2
- package/dist/engine/EngineCore.js +1013 -707
- package/dist/engine/codec/canvasDocument.d.ts +7 -0
- package/dist/engine/codec/canvasDocument.js +172 -186
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +38 -26
- package/dist/engine/core/arrow.d.ts +18 -8
- package/dist/engine/core/arrow.js +109 -84
- package/dist/engine/core/arrowBinding.d.ts +1 -1
- package/dist/engine/core/arrowBinding.js +126 -101
- package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
- package/dist/engine/core/arrowBindingRecords.js +48 -29
- package/dist/engine/core/brush.d.ts +8 -0
- package/dist/engine/core/brush.js +98 -78
- package/dist/engine/core/cameraMove.d.ts +73 -0
- package/dist/engine/core/cameraMove.js +172 -0
- 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 +55 -38
- package/dist/engine/core/hitTest.js +81 -68
- 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 +22 -0
- package/dist/engine/core/scene.js +288 -139
- 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.d.ts +10 -0
- package/dist/engine/core/style.js +82 -33
- package/dist/engine/core/transform.d.ts +6 -0
- package/dist/engine/core/transform.js +103 -83
- package/dist/engine/core/types.d.ts +7 -0
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +36 -23
- package/dist/engine/input/PointerController.d.ts +15 -1
- package/dist/engine/input/PointerController.js +549 -466
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +3 -1
- package/dist/engine/input/gestures.js +340 -266
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.d.ts +22 -3
- package/dist/engine/input/keyboard.js +131 -32
- package/dist/engine/input/selectionHandles.js +50 -45
- package/dist/engine/input/types.d.ts +7 -0
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +158 -86
- package/dist/engine/state.d.ts +18 -0
- package/dist/engine/state.js +25 -4
- 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 +83 -30
- package/dist/fonts/workspaceFonts.d.ts +6 -0
- package/dist/fonts/workspaceFonts.js +108 -34
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.js +7 -1
- package/dist/i18n/shortcuts.d.ts +6 -4
- package/dist/i18n/shortcuts.js +30 -26
- package/dist/index.d.ts +2 -1
- package/dist/poster/boardPlacement.d.ts +80 -0
- package/dist/poster/boardPlacement.js +140 -0
- package/dist/poster/boardPoster.d.ts +80 -0
- package/dist/poster/boardPoster.js +251 -0
- package/dist/poster/paintBoardPoster.d.ts +49 -0
- package/dist/poster/paintBoardPoster.js +112 -0
- package/dist/poster/posterPictures.d.ts +32 -0
- package/dist/poster/posterPictures.js +138 -0
- package/dist/settings/workspaceToolSettings.d.ts +6 -0
- package/dist/settings/workspaceToolSettings.js +58 -34
- package/dist/tools/components/catalog.js +74 -64
- package/dist/tools/components/grouping.js +28 -6
- package/dist/tools/definitions.js +31 -9
- package/dist/tools/executors.js +214 -106
- package/dist/tools/hostAdapter.d.ts +5 -1
- package/dist/tools/hostAdapter.js +15 -11
- package/dist/tools/sceneSummary.js +57 -43
- package/dist/tools/sketchIntent.js +21 -13
- package/dist/tools/styleArguments.d.ts +35 -0
- package/dist/tools/styleArguments.js +93 -0
- package/dist/tools/types.d.ts +26 -1
- package/dist/tools/types.js +2 -1
- package/package.json +1 -1
|
@@ -5,17 +5,26 @@
|
|
|
5
5
|
* of shape has is the engine's own rule (`style.ts` says which keys of a style patch a shape takes), so the panel never
|
|
6
6
|
* offers a control that would change nothing.
|
|
7
7
|
*/
|
|
8
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
9
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10
|
+
if (ar || !(i in from)) {
|
|
11
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
12
|
+
ar[i] = from[i];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
16
|
+
};
|
|
8
17
|
import { isArrow } from '../../engine/core/arrow.js';
|
|
9
18
|
import { isBrushStroke } from '../../engine/core/brush.js';
|
|
10
19
|
import { leafShapesOf, normalizeSelection } from '../../engine/core/scene.js';
|
|
11
|
-
import { lineColorOf, paintsFillOnStroke, pathSupportsRoundness } from '../../engine/core/style.js';
|
|
12
|
-
|
|
20
|
+
import { lineColorOf, minimumStrokeWidthOf, paintsFillOnStroke, pathSupportsRoundness } from '../../engine/core/style.js';
|
|
21
|
+
var NONE = { kind: 'none' };
|
|
13
22
|
/** One value out of many: the value they all have, `mixed` when they differ, `none` when there is nothing to compare. */
|
|
14
23
|
export function unify(values) {
|
|
15
24
|
if (values.length === 0)
|
|
16
25
|
return NONE;
|
|
17
|
-
|
|
18
|
-
return values.every((value)
|
|
26
|
+
var first = values[0];
|
|
27
|
+
return values.every(function (value) { return Object.is(value, first); }) ? { kind: 'same', value: first } : { kind: 'mixed' };
|
|
19
28
|
}
|
|
20
29
|
/** Whether a shape has a fill and a stroke of its own: the three kinds of vector shape. */
|
|
21
30
|
function isVector(shape) {
|
|
@@ -23,52 +32,74 @@ function isVector(shape) {
|
|
|
23
32
|
}
|
|
24
33
|
/** Describes the selection for the panel. */
|
|
25
34
|
export function describeSelection(scene, selectedIds) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
var unitIds = normalizeSelection(scene, selectedIds);
|
|
36
|
+
var unitIdSet = new Set(unitIds);
|
|
37
|
+
var units = scene.filter(function (object) { return unitIdSet.has(object.id); });
|
|
38
|
+
var shapes = leafShapesOf(scene, unitIds);
|
|
39
|
+
var only = units.length === 1 ? units[0] : undefined;
|
|
40
|
+
var widgetCard = only && only.type === 'widget' ? only : null;
|
|
32
41
|
// The card of a widget is the page's to style (it shows the widget): the panel does not paint it.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
var targets = shapes.filter(function (shape) { return shape.type !== 'widget'; });
|
|
43
|
+
var vectors = targets.filter(isVector);
|
|
44
|
+
var texts = targets.filter(function (shape) { return shape.type === 'text'; });
|
|
36
45
|
// A brush stroke is a filled outline, but to a person it is a line: its colour is the Stroke, and it has no Fill. An arrow is a line too.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const roundnessValues = vectors
|
|
45
|
-
.filter((shape) => shape.type === 'rect' || (shape.type === 'path' && pathSupportsRoundness(shape.shape)))
|
|
46
|
-
.map((shape) => (shape.type === 'rect' || shape.type === 'path' ? shape.roundness : 0));
|
|
46
|
+
var fillValues = __spreadArray(__spreadArray([], vectors
|
|
47
|
+
.filter(function (shape) { return !isBrushStroke(shape) && !isArrow(shape); })
|
|
48
|
+
.map(function (shape) { return (paintsFillOnStroke(shape) ? shape.stroke : shape.fill); }), true), texts.map(function (shape) { return shape.color; }), true);
|
|
49
|
+
var strokeValues = vectors.filter(function (shape) { return !paintsFillOnStroke(shape); }).map(lineColorOf);
|
|
50
|
+
var roundnessValues = vectors
|
|
51
|
+
.filter(function (shape) { return shape.type === 'rect' || (shape.type === 'path' && pathSupportsRoundness(shape.shape)); })
|
|
52
|
+
.map(function (shape) { return (shape.type === 'rect' || shape.type === 'path' ? shape.roundness : 0); });
|
|
47
53
|
return {
|
|
48
|
-
targets,
|
|
49
|
-
units,
|
|
54
|
+
targets: targets,
|
|
55
|
+
units: units,
|
|
50
56
|
fill: unify(fillValues),
|
|
51
57
|
stroke: unify(strokeValues),
|
|
52
|
-
strokeWidth: unify(vectors.map((shape)
|
|
58
|
+
strokeWidth: unify(vectors.map(function (shape) { return shape.strokeWidth; })),
|
|
53
59
|
roundness: unify(roundnessValues),
|
|
54
|
-
opacity: unify(targets.map((shape)
|
|
60
|
+
opacity: unify(targets.map(function (shape) { return shape.opacity; })),
|
|
55
61
|
text: texts.length === 0
|
|
56
62
|
? null
|
|
57
63
|
: {
|
|
58
|
-
fontSize: unify(texts.map((shape)
|
|
59
|
-
fontFamily: unify(texts.map((shape)
|
|
60
|
-
bold: unify(texts.map((shape)
|
|
61
|
-
italic: unify(texts.map((shape)
|
|
62
|
-
underline: unify(texts.map((shape)
|
|
63
|
-
align: unify(texts.map((shape)
|
|
64
|
+
fontSize: unify(texts.map(function (shape) { return shape.fontSize; })),
|
|
65
|
+
fontFamily: unify(texts.map(function (shape) { return shape.fontFamily; })),
|
|
66
|
+
bold: unify(texts.map(function (shape) { return shape.fontWeight === 'bold'; })),
|
|
67
|
+
italic: unify(texts.map(function (shape) { return shape.fontStyle === 'italic'; })),
|
|
68
|
+
underline: unify(texts.map(function (shape) { return shape.underline; })),
|
|
69
|
+
align: unify(texts.map(function (shape) { return shape.align; }))
|
|
64
70
|
},
|
|
65
|
-
widgetCard
|
|
71
|
+
widgetCard: widgetCard
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What the panel shows for the pen of the Draw tool, when the tool is chosen and nothing is selected: the controls a line drawn by
|
|
76
|
+
* hand has (its colour as the Stroke, its width, its opacity), each with the one value the pen has. The pen has no inside, no
|
|
77
|
+
* corners and no text, and nothing of it is on the board yet: there is nothing to select, so there are no targets and no units.
|
|
78
|
+
*/
|
|
79
|
+
export function describePenStyle(pen) {
|
|
80
|
+
return {
|
|
81
|
+
targets: [],
|
|
82
|
+
units: [],
|
|
83
|
+
fill: NONE,
|
|
84
|
+
stroke: { kind: 'same', value: pen.color },
|
|
85
|
+
strokeWidth: { kind: 'same', value: pen.width },
|
|
86
|
+
roundness: NONE,
|
|
87
|
+
opacity: { kind: 'same', value: pen.opacity },
|
|
88
|
+
text: null,
|
|
89
|
+
widgetCard: null
|
|
66
90
|
};
|
|
67
91
|
}
|
|
68
92
|
/** The number of a trait for a control, or a fallback when the shapes differ or the control does not apply. */
|
|
69
93
|
export function traitNumber(trait, fallback) {
|
|
70
94
|
return trait.kind === 'same' ? trait.value : fallback;
|
|
71
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* The least the Width control offers for the selection. One number is written to every shape, so it is the highest minimum among
|
|
98
|
+
* the shapes: an arrow, a line-only icon or a brush stroke cannot go to 0 (there would be nothing left of it), a rectangle can.
|
|
99
|
+
*/
|
|
100
|
+
export function minimumStrokeWidth(traits) {
|
|
101
|
+
return Math.max.apply(Math, __spreadArray([0], traits.targets.filter(isVector).map(minimumStrokeWidthOf), false));
|
|
102
|
+
}
|
|
72
103
|
/** What the font size stepper shows: a whole number, never a long float from resizing. */
|
|
73
104
|
export function formatFontSizeDisplay(trait) {
|
|
74
105
|
return trait.kind === 'same' ? Math.round(trait.value) : '–';
|
|
@@ -89,7 +120,7 @@ export function showStrokeColorRow(traits, wireframeMode) {
|
|
|
89
120
|
return false;
|
|
90
121
|
if (!wireframeMode)
|
|
91
122
|
return true;
|
|
92
|
-
return traits.targets.some((shape)
|
|
123
|
+
return traits.targets.some(function (shape) {
|
|
93
124
|
if (shape.type === 'rect' || shape.type === 'ellipse')
|
|
94
125
|
return false;
|
|
95
126
|
if (shape.type !== 'path')
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
import type { SelectionDrag } from '../../engine/state.js';
|
|
5
5
|
export interface SizeLabelVisibilityInput {
|
|
6
6
|
hasFrame: boolean;
|
|
7
|
-
/** Any gesture is active (press on body, handle, dot, …). */
|
|
8
|
-
gestureKind: string | null;
|
|
9
7
|
/** Non-null only after the pointer crossed the drag threshold. */
|
|
10
8
|
overlayDragging: SelectionDrag | null;
|
|
11
9
|
}
|
|
12
10
|
/**
|
|
13
11
|
* True only while the selection is being resized (Figma "Selection Box" keeps the size chip hidden at rest;
|
|
14
12
|
* see 515:623 `hidden` on the component board).
|
|
13
|
+
*
|
|
14
|
+
* The size is shown once the pointer has started to drag the handle, and not at the press: the engine only reports a drag
|
|
15
|
+
* (`overlayDragging`) after the pointer went the drag threshold, so a plain click on a handle changes nothing on the board.
|
|
16
|
+
* The kind of gesture is not read here: a resize gesture exists from the press on, before anything is being stretched.
|
|
15
17
|
*/
|
|
16
18
|
export declare function shouldShowRestingSizeLabel(input: SizeLabelVisibilityInput): boolean;
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* True only while the selection is being resized (Figma "Selection Box" keeps the size chip hidden at rest;
|
|
6
6
|
* see 515:623 `hidden` on the component board).
|
|
7
|
+
*
|
|
8
|
+
* The size is shown once the pointer has started to drag the handle, and not at the press: the engine only reports a drag
|
|
9
|
+
* (`overlayDragging`) after the pointer went the drag threshold, so a plain click on a handle changes nothing on the board.
|
|
10
|
+
* The kind of gesture is not read here: a resize gesture exists from the press on, before anything is being stretched.
|
|
7
11
|
*/
|
|
8
12
|
export function shouldShowRestingSizeLabel(input) {
|
|
9
13
|
if (!input.hasFrame)
|
|
10
14
|
return false;
|
|
11
|
-
|
|
12
|
-
return true;
|
|
13
|
-
if (input.gestureKind === 'resize')
|
|
14
|
-
return true;
|
|
15
|
-
return false;
|
|
15
|
+
return input.overlayDragging === 'resize';
|
|
16
16
|
}
|
|
@@ -42,11 +42,13 @@
|
|
|
42
42
|
showEmptyBoardHint: boolean;
|
|
43
43
|
/** True when the frame of a selected live widget card is drawn in the page's own layer above it. */
|
|
44
44
|
frameElsewhere: boolean;
|
|
45
|
+
/** The poster of the board is on the screen: the objects are there to look at, so the loader draws no spinner over them (its layer stays). */
|
|
46
|
+
posterVisible?: boolean;
|
|
45
47
|
/** The element the pointer events come from, handed to the shell (it is what the host is attached to). */
|
|
46
48
|
board?: HTMLElement | null;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
let { host, state, ui, advancedFeatures, loading, showEmptyBoardHint, frameElsewhere, board = $bindable(null) }: Props = $props();
|
|
51
|
+
let { host, state, ui, advancedFeatures, loading, showEmptyBoardHint, frameElsewhere, posterVisible = false, board = $bindable(null) }: Props = $props();
|
|
50
52
|
|
|
51
53
|
const { t } = useCanvasLanguage();
|
|
52
54
|
// The shapes the eraser has marked, as a set: each object asks whether it is one of them. A store of its own, told only
|
|
@@ -159,7 +161,10 @@
|
|
|
159
161
|
{#if loading}
|
|
160
162
|
<!-- The board stays visible while its content loads. Input waits, so a late load cannot replace what was just drawn. -->
|
|
161
163
|
<div class="absolute inset-0 z-30 cursor-progress" data-canvas-loader>
|
|
162
|
-
|
|
164
|
+
<!-- No spinner over the poster: the placeholders before the canvas drew none, and a spinner that came back now would blink for the moment the board reads its saved text. The layer stays, so input still waits. -->
|
|
165
|
+
{#if !posterVisible}
|
|
166
|
+
<CanvasBoardPlaceholder showSurface={false} />
|
|
167
|
+
{/if}
|
|
163
168
|
</div>
|
|
164
169
|
{/if}
|
|
165
170
|
</div>
|
|
@@ -13,6 +13,8 @@ interface Props {
|
|
|
13
13
|
showEmptyBoardHint: boolean;
|
|
14
14
|
/** True when the frame of a selected live widget card is drawn in the page's own layer above it. */
|
|
15
15
|
frameElsewhere: boolean;
|
|
16
|
+
/** The poster of the board is on the screen: the objects are there to look at, so the loader draws no spinner over them (its layer stays). */
|
|
17
|
+
posterVisible?: boolean;
|
|
16
18
|
/** The element the pointer events come from, handed to the shell (it is what the host is attached to). */
|
|
17
19
|
board?: HTMLElement | null;
|
|
18
20
|
}
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
nothing here takes the pointer.
|
|
11
11
|
|
|
12
12
|
The frame follows what is done with the selection, the way the Memoreco canvas does: while it is carried the handles step
|
|
13
|
-
aside
|
|
14
|
-
while it is
|
|
13
|
+
aside and so does the line of the frame (the line along a selected arrow too), so that only the objects are seen, and no
|
|
14
|
+
outline of anything is drawn while it is carried; while it is stretched the outline is dashed, the turning dot is gone and its
|
|
15
|
+
size is the figure in the middle; while it is turned the dot stays, grown, and the angle is the figure. The dot is 8 px at
|
|
16
|
+
rest, 24 px under the pointer.
|
|
15
17
|
|
|
16
18
|
One selected arrow has no frame at all (the way tldraw shows one): its own thin outline, a round handle on each end and one in
|
|
17
19
|
the middle that bends it. No corners, no turning dot, no size: an arrow is a line from here to there, and it points where its
|
|
@@ -127,8 +129,11 @@
|
|
|
127
129
|
|
|
128
130
|
// What is being done with the selection since the press became a drag, and what the frame shows for it.
|
|
129
131
|
const dragging = $derived(state.overlay.dragging);
|
|
130
|
-
// The handles step aside while the selection is carried
|
|
131
|
-
|
|
132
|
+
// The handles step aside while the selection is carried, and so does every line the board draws round it (the frame, the line
|
|
133
|
+
// along a selected arrow): what is carried is all that is to be seen, and a thin outline over the shapes it passes would be one
|
|
134
|
+
// more stroke on them.
|
|
135
|
+
const carried = $derived(dragging === 'move');
|
|
136
|
+
const shownHandles = $derived(!carried && availability ? availability.handles : []);
|
|
132
137
|
const showDot = $derived(!!availability?.canRotate && (dragging === null || dragging === 'rotate'));
|
|
133
138
|
const dotActive = $derived(state.rotationDotHovered || dragging === 'rotate');
|
|
134
139
|
const dotCenter = $derived(frame && showDot ? pointBelowFrame(frame.screen, ROTATION_DOT_OFFSET) : null);
|
|
@@ -141,11 +146,12 @@
|
|
|
141
146
|
return only.length === 1 && only[0].type === 'widget' && only[0].isPrimary;
|
|
142
147
|
});
|
|
143
148
|
|
|
144
|
-
// The unit under the pointer, unless it is already selected
|
|
149
|
+
// The unit under the pointer, unless it is already selected, and never while the selection is carried, stretched or turned (the
|
|
150
|
+
// engine drops its hover when a drag begins, and the outline is kept from coming back for one that is still on its way).
|
|
145
151
|
const hoveredId = $derived.by(() => {
|
|
146
152
|
if (!onBoard) return null;
|
|
147
153
|
const id = state.hoverId;
|
|
148
|
-
if (!id || state.selectedIds.includes(id) || state.tool !== 'select' || gestureKind !== null) return null;
|
|
154
|
+
if (!id || state.selectedIds.includes(id) || state.tool !== 'select' || gestureKind !== null || dragging !== null) return null;
|
|
149
155
|
return id;
|
|
150
156
|
});
|
|
151
157
|
|
|
@@ -212,7 +218,6 @@
|
|
|
212
218
|
if (
|
|
213
219
|
!shouldShowRestingSizeLabel({
|
|
214
220
|
hasFrame: !!frame,
|
|
215
|
-
gestureKind,
|
|
216
221
|
overlayDragging: state.overlay.dragging
|
|
217
222
|
})
|
|
218
223
|
) {
|
|
@@ -324,8 +329,10 @@
|
|
|
324
329
|
{/each}
|
|
325
330
|
|
|
326
331
|
{#if arrowSelection}
|
|
327
|
-
{
|
|
328
|
-
|
|
332
|
+
{#if !carried}
|
|
333
|
+
{@render arrowOutline(arrowSelection.arrow, false)}
|
|
334
|
+
{/if}
|
|
335
|
+
{#each carried ? [] : arrowSelection.handles as handle (handle.id)}
|
|
329
336
|
{@const active = state.arrowHandleHovered === handle.id}
|
|
330
337
|
<!-- A round handle: 10 px on an end, 8 px on the middle, 14 px under the pointer and while it is dragged. -->
|
|
331
338
|
<span
|
|
@@ -353,7 +360,7 @@
|
|
|
353
360
|
<div class="absolute box-border border-2" style="{screenFrameStyle(frame.screen)}border-color:{PRIMARY_RING_COLOR};"></div>
|
|
354
361
|
{/if}
|
|
355
362
|
<div
|
|
356
|
-
class="absolute box-border border-[1.5px] {dragging === 'resize' ? 'border-transparent' : 'border-ring'}"
|
|
363
|
+
class="absolute box-border border-[1.5px] {dragging === 'resize' || carried ? 'border-transparent' : 'border-ring'}"
|
|
357
364
|
style={screenFrameStyle(frame.screen)}
|
|
358
365
|
data-canvas-frame
|
|
359
366
|
data-canvas-selection-frame
|
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
// `state` is a prop name of the canvas; here it is renamed, because a local `state` would turn `$state` into a store.
|
|
28
28
|
let { host, state: engineState, gestureKind, advancedFeatures, target }: Props = $props();
|
|
29
29
|
|
|
30
|
-
// Where the board is on the screen, in pixels from
|
|
30
|
+
// Where the board is on the screen, in pixels from its `position: fixed` containing block (the window on a normal page,
|
|
31
|
+
// or `:host` inside a shadow root with `contain: layout`).
|
|
31
32
|
let boardRect = $state({ left: 0, top: 0, width: 0, height: 0 });
|
|
33
|
+
let fixedOriginEl = $state<HTMLSpanElement | null>(null);
|
|
32
34
|
let measureFrame = 0;
|
|
33
35
|
|
|
34
36
|
function measure(): void {
|
|
@@ -36,8 +38,16 @@
|
|
|
36
38
|
const board = host.boardElement;
|
|
37
39
|
if (!board) return;
|
|
38
40
|
const bounds = board.getBoundingClientRect();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const root = board.getRootNode();
|
|
42
|
+
const origin = fixedOriginEl
|
|
43
|
+
? fixedOriginEl.getBoundingClientRect()
|
|
44
|
+
: root instanceof ShadowRoot
|
|
45
|
+
? root.host.getBoundingClientRect()
|
|
46
|
+
: { left: 0, top: 0 };
|
|
47
|
+
const left = bounds.left - origin.left;
|
|
48
|
+
const top = bounds.top - origin.top;
|
|
49
|
+
if (left !== boardRect.left || top !== boardRect.top || bounds.width !== boardRect.width || bounds.height !== boardRect.height) {
|
|
50
|
+
boardRect = { left, top, width: bounds.width, height: bounds.height };
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
|
|
@@ -77,6 +87,8 @@
|
|
|
77
87
|
</script>
|
|
78
88
|
|
|
79
89
|
<Portal {target} style="z-index: 70; pointer-events: none;">
|
|
90
|
+
<!-- rtl-ok: physical left: 0 origin probe for getBoundingClientRect() -->
|
|
91
|
+
<span bind:this={fixedOriginEl} class="pointer-events-none fixed left-0 top-0 size-0" aria-hidden="true"></span>
|
|
80
92
|
<div class="canvas-widget-selection-layer pointer-events-none fixed overflow-hidden" dir="ltr" data-canvas-widget-chrome style={layerStyle}>
|
|
81
93
|
<SelectionOverlay state={engineState} {host} {gestureKind} {advancedFeatures} layer="above-widgets" />
|
|
82
94
|
</div>
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { writable } from 'svelte/store';
|
|
14
14
|
/** The set while nothing is marked: one shared set, so that "nothing marked" is the same value every time. */
|
|
15
|
-
export
|
|
15
|
+
export var NOTHING_ERASED = new Set();
|
|
16
16
|
export function createErasingMarks() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
var _a = writable(NOTHING_ERASED), subscribe = _a.subscribe, set = _a.set;
|
|
18
|
+
var listSeen = null;
|
|
19
|
+
var current = NOTHING_ERASED;
|
|
20
20
|
return {
|
|
21
|
-
subscribe,
|
|
22
|
-
take(marked) {
|
|
21
|
+
subscribe: subscribe,
|
|
22
|
+
take: function (marked) {
|
|
23
23
|
if (marked === listSeen)
|
|
24
24
|
return;
|
|
25
25
|
listSeen = marked;
|
|
26
|
-
|
|
26
|
+
var next = marked.length === 0 ? NOTHING_ERASED : new Set(marked);
|
|
27
27
|
// A store tells its subscribers of every `set` of an object, equal or not: nothing marked before and nothing now is no news.
|
|
28
28
|
if (next === current)
|
|
29
29
|
return;
|
|
@@ -171,7 +171,7 @@ export declare const DOT_GRID_STEP = 24;
|
|
|
171
171
|
* One dot in the middle of a cell, as a gradient: it takes its colour from the page's `foreground` token (a data URL
|
|
172
172
|
* cannot), stays two pixels across at every zoom, and costs one background layer however large the board is.
|
|
173
173
|
*/
|
|
174
|
-
export declare const DOT_GRID_IMAGE = "radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--foreground, #0f172a) 30%, transparent) 0, color-mix(in srgb, var(--foreground, #0f172a) 30%, transparent) 1px, transparent 1.5px)";
|
|
174
|
+
export declare const DOT_GRID_IMAGE = "radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--canvas-ink, var(--foreground, #0f172a)) 30%, transparent) 0, color-mix(in srgb, var(--canvas-ink, var(--foreground, #0f172a)) 30%, transparent) 1px, transparent 1.5px)";
|
|
175
175
|
export declare function dotGridStyle(viewport: Viewport): string;
|
|
176
176
|
/** The CSS `cursor` for what the engine asked the board to show. */
|
|
177
177
|
export declare function cssCursor(cursor: string): string;
|