@widgetic/canvas 0.5.45 → 0.5.47
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 +3 -2
- package/dist/canvas/DomCanvas.svelte +1 -2
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.js +19 -21
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +6 -5
- package/dist/canvas/host/CanvasHost.js +1664 -1861
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/boardFiles.js +35 -51
- package/dist/canvas/host/browserServices.js +108 -196
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +18 -21
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/host/pictureSaves.js +9 -11
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.js +149 -243
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/SelectionPanel.svelte +14 -12
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
- package/dist/canvas/ui/ShapesMenu.svelte +6 -4
- package/dist/canvas/ui/ToolButton.svelte +7 -6
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +48 -28
- package/dist/canvas/ui/floatingLayer.js +5 -6
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +44 -58
- package/dist/canvas/view/CanvasStage.svelte +1 -1
- package/dist/canvas/view/SelectionOverlay.svelte +2 -2
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +72 -91
- package/dist/canvas/view/liftedScene.js +24 -36
- package/dist/canvas/view/mountedScene.js +76 -79
- package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
- package/dist/components/CanvasToolbarPlaceholder.svelte +25 -11
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +6 -0
- package/dist/components/boardLoaderDelay.d.ts +39 -0
- package/dist/components/boardLoaderDelay.js +71 -0
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +42 -10
- package/dist/engine/EngineCore.js +843 -916
- package/dist/engine/codec/canvasDocument.js +192 -155
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +79 -92
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +223 -103
- package/dist/engine/core/cameraMove.js +39 -51
- package/dist/engine/core/defaults.js +92 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.js +38 -55
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.js +160 -224
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +104 -67
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +79 -80
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/core/transform.js +84 -95
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +513 -526
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +378 -346
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +42 -41
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.js +6 -17
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.js +30 -83
- package/dist/fonts/workspaceFonts.js +33 -92
- 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.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +34 -33
- package/dist/poster/boardPoster.js +58 -83
- package/dist/poster/paintBoardPoster.js +16 -39
- package/dist/poster/posterPictures.js +27 -43
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/rememberedTool.d.ts +50 -0
- package/dist/settings/rememberedTool.js +68 -0
- package/dist/settings/workspaceToolSettings.d.ts +25 -0
- package/dist/settings/workspaceToolSettings.js +38 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +137 -169
- package/dist/tools/hostAdapter.js +10 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/styleArguments.js +19 -21
- package/dist/tools/types.js +1 -1
- package/package.json +5 -5
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
* when it reads this file. Kept free of Svelte and of the DOM so that Node can test it.
|
|
13
13
|
*/
|
|
14
14
|
/** The card itself: its corners, border, fill, padding and shadow. */
|
|
15
|
-
export
|
|
15
|
+
export const FLOATING_CARD_CLASSES = 'rounded-xl border border-border bg-background p-[3px] shadow-floating';
|
|
16
16
|
/**
|
|
17
17
|
* The padding of the canvas's menus (the Shapes menu, the right-click menu and their submenus). They are the design system's
|
|
18
18
|
* Dropdown Menu, drawn in Figma the same way as the cards above: the first row stands 4 px from the outer edge, the 1 px
|
|
19
19
|
* border inside that. The component's own padding (4 px, beside the border) makes a menu 2 px larger each way than Figma's:
|
|
20
20
|
* the Shape Menu is 196 x 246 there, and measures 246 only with 3 px.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export const MENU_PADDING_CLASS = 'p-[3px]';
|
|
23
23
|
/** Figma "Layer Menu" (519:*): 4 px inset, 220 × 136 with 32 px rows. */
|
|
24
|
-
export
|
|
24
|
+
export const LAYER_MENU_PADDING_CLASS = 'p-1';
|
|
25
25
|
/**
|
|
26
26
|
* A menu, a popover or a tooltip of the design system slides and fades in, and its classes do not ask whether the system wants
|
|
27
27
|
* less motion. The canvas adds this to each one it draws: with `prefers-reduced-motion: reduce` the card appears and goes
|
|
@@ -30,20 +30,40 @@ export var LAYER_MENU_PADDING_CLASS = 'p-1';
|
|
|
30
30
|
* The states are those of the three components: a menu and a popover are `open` and `closed`, a tooltip `delayed-open`,
|
|
31
31
|
* `instant-open` and `closed`.
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
33
|
+
export const OVERLAY_REDUCED_MOTION_CLASSES = 'motion-reduce:animate-none motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none motion-reduce:data-[state=delayed-open]:animate-none motion-reduce:data-[state=instant-open]:animate-none';
|
|
34
34
|
/** Canvas-floated surfaces stay below site dialogs and toasts (design-system overlays use z-50). */
|
|
35
|
-
export
|
|
35
|
+
export const CANVAS_OVERLAY_Z_CLASS = 'z-40';
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* No ring on any control of the chrome (the buttons of the toolbar, the Shapes button, the zoom buttons), however the focus got
|
|
38
|
+
* there. The keyboard focus takes the look of the hover on the buttons that are not on, and a deeper brand tint on the one that is
|
|
39
|
+
* (`TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES`), so it is never invisible and never a ring. The Shapes button used to have a ring while
|
|
40
|
+
* its menu was open (Figma draws it so); it was taken off at the owner's request (19 Nov 2026) and the open menu is shown by the
|
|
41
|
+
* menu itself and the chevron that turns.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* `outline-hidden` hides the browser's own ring (it stays in the forced-colours mode of the system, which a person who asked for
|
|
44
|
+
* it needs); it is given for `focus` as well as for `focus-visible`, so that a page whose stylesheet rings every focused button is
|
|
45
|
+
* not heard either. Written out in full, so that a page's stylesheet picks both classes up.
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
+
export const TOOLBAR_NO_RING_CLASSES = 'focus:outline-hidden focus-visible:outline-hidden';
|
|
48
|
+
/**
|
|
49
|
+
* How a sub-menu (the Shapes menu's "More shapes", the right-click menu's "Layer order") opens: it fades in while it slides up by
|
|
50
|
+
* `--floating-slide` (8 px), as the Shapes menu does when it opens.
|
|
51
|
+
*
|
|
52
|
+
* The design system's `floating-motion` writes `--floating-slide-x` for a menu that opens to the side (`data-side='right'` or
|
|
53
|
+
* `'left'`), and `--floating-slide-y` only for one that opens above or below. A sub-menu opens to the side, so it set the first and
|
|
54
|
+
* took the second from the menu it stands in (a custom property is inherited): the Shapes menu opens upward and lent it its slide
|
|
55
|
+
* up, so "More shapes" came in from the bottom left, and the right-click menu opens downward and lent "Layer order" its slide
|
|
56
|
+
* down, so it came in from the top left. Both axes are set here, with `!` because the design system's own rule (a `data-side`
|
|
57
|
+
* selector) is more specific than a utility: no slide sideways, and the slide up.
|
|
58
|
+
*/
|
|
59
|
+
export const SUBMENU_SLIDE_UP_CLASSES = '[--floating-slide-x:0px]! [--floating-slide-y:var(--floating-slide)]!';
|
|
60
|
+
/**
|
|
61
|
+
* Where the right-click menu's "Layer order" submenu stands against its row: the first row of the submenu level with "Layer order".
|
|
62
|
+
* The submenu is a card with a 1 px border and `LAYER_MENU_PADDING_CLASS` (4 px) of padding before its first row, so the card
|
|
63
|
+
* itself starts 5 px above the row it opens from (the offset runs down from the row's top, so a negative one lifts it). It was 12:
|
|
64
|
+
* the card then stood 13 px below the row.
|
|
65
|
+
*/
|
|
66
|
+
export const LAYER_MENU_ALIGN_OFFSET_PX = -5;
|
|
47
67
|
/**
|
|
48
68
|
* How the keyboard focus shows on a button of the chrome that has its brand tint on (the tool in use, the Shapes button while a
|
|
49
69
|
* shape is the tool): no ring, a deeper tint of the same colour. A button that is not on takes the look of the hover, which is the
|
|
@@ -54,33 +74,33 @@ export var MENU_TRIGGER_RING_CLASSES = 'data-[state=open]:shadow-[0_0_0_2px_var(
|
|
|
54
74
|
* The `data-[active]` and `focus-visible` variants are stacked so that this beats both `data-[active]:bg-brand-subtle` and the
|
|
55
75
|
* design system's `focus-visible:bg-accent`.
|
|
56
76
|
*/
|
|
57
|
-
export
|
|
77
|
+
export const TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES = 'data-[active]:focus-visible:bg-brand/40';
|
|
58
78
|
/**
|
|
59
79
|
* How long the pointer rests on a button of the chrome before its tooltip (the name and the key) opens, in milliseconds. The
|
|
60
80
|
* tooltips were quicker and opened on the way across the toolbar; this is the delay of the design system's own tooltips.
|
|
61
81
|
*/
|
|
62
|
-
export
|
|
82
|
+
export const CANVAS_TOOLTIP_DELAY_MS = 700;
|
|
63
83
|
/**
|
|
64
84
|
* After one tooltip has closed, the time within which the next button the pointer rests on opens its tooltip at once, so that
|
|
65
85
|
* moving along the toolbar to the next tool reads as one hover.
|
|
66
86
|
*/
|
|
67
|
-
export
|
|
87
|
+
export const CANVAS_TOOLTIP_SKIP_DELAY_MS = 200;
|
|
68
88
|
/**
|
|
69
89
|
* Tabler toolbar icons are 16 px (`size-4`) with stroke 2 in a 24 px viewBox: 2 × 16 / 24 = 1.333 px on screen.
|
|
70
90
|
* A library shape glyph is drawn in a 100 px viewBox, so it needs a stroke of 1.333 × 100 / 16 = 8.33 in its own units to
|
|
71
91
|
* look as thick. The design system's menu item forces `size-4` and `stroke-2` on every svg inside it through CSS, which beats
|
|
72
92
|
* the `stroke-width` attribute (the glyphs were 0.32 px thick), so the width is set inline on the glyph.
|
|
73
93
|
*/
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
79
|
-
export
|
|
80
|
-
export
|
|
81
|
-
export
|
|
94
|
+
export const TOOLBAR_ICON_STROKE_CLASSES = '[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:stroke-2';
|
|
95
|
+
export const TOOLBAR_ICON_SIZE_PX = 16;
|
|
96
|
+
export const TOOLBAR_ICON_VIEWBOX = 24;
|
|
97
|
+
export const TOOLBAR_ICON_STROKE_UNITS = 2;
|
|
98
|
+
export const TOOLBAR_ICON_STROKE_PX = (TOOLBAR_ICON_STROKE_UNITS * TOOLBAR_ICON_SIZE_PX) / TOOLBAR_ICON_VIEWBOX;
|
|
99
|
+
export const SHAPE_LIBRARY_ICON_SIZE_PX = TOOLBAR_ICON_SIZE_PX;
|
|
100
|
+
export const SHAPE_LIBRARY_VIEWBOX = 100;
|
|
101
|
+
export const SHAPE_LIBRARY_STROKE_WIDTH = (TOOLBAR_ICON_STROKE_PX * SHAPE_LIBRARY_VIEWBOX) / SHAPE_LIBRARY_ICON_SIZE_PX;
|
|
82
102
|
/** Figma's measures of the cards, in px (a Figma frame counts an inside stroke as part of the card). */
|
|
83
|
-
export
|
|
103
|
+
export const FLOATING_CARD_METRICS = {
|
|
84
104
|
/** The whole toolbar: five tools, the Shapes menu and the history group, with their dividers. */
|
|
85
105
|
toolbarWidth: 349,
|
|
86
106
|
toolbarHeight: 44,
|
|
@@ -98,7 +118,7 @@ export var FLOATING_CARD_METRICS = {
|
|
|
98
118
|
* with. (An upright bar is as long as the board is tall, so it always has them.) Written out in full, so a page's stylesheet
|
|
99
119
|
* picks it up.
|
|
100
120
|
*/
|
|
101
|
-
export
|
|
121
|
+
export const TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @[384px]:flex';
|
|
102
122
|
/**
|
|
103
123
|
* The width of board from which the zoom card is drawn, by the way it stands beside the toolbar (see `chromeLayout.ts`, which
|
|
104
124
|
* picks the case from the two anchors a page named). Narrower than that the zoom card is not drawn, as in Figma's phone: a
|
|
@@ -114,7 +134,7 @@ export var TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @[384px]:flex';
|
|
|
114
134
|
* - `centredBesideCornerToolbar`: the toolbar at a corner and the zoom card centred: the card's left edge has to clear the
|
|
115
135
|
* toolbar's right edge, which is 365 px from the board's left edge.
|
|
116
136
|
*/
|
|
117
|
-
export
|
|
137
|
+
export const ZOOM_CONTROL_MIN_WIDTHS = {
|
|
118
138
|
alone: 512,
|
|
119
139
|
sameSlot: 560,
|
|
120
140
|
oppositeCorners: 560,
|
|
@@ -122,7 +142,7 @@ export var ZOOM_CONTROL_MIN_WIDTHS = {
|
|
|
122
142
|
centredBesideCornerToolbar: 912
|
|
123
143
|
};
|
|
124
144
|
/** The classes that show the zoom card from each of those widths. Written out in full, so a page's stylesheet picks every one up. */
|
|
125
|
-
export
|
|
145
|
+
export const ZOOM_CONTROL_VISIBLE_FROM = {
|
|
126
146
|
alone: 'hidden @lg:flex',
|
|
127
147
|
sameSlot: 'hidden @[560px]:flex',
|
|
128
148
|
oppositeCorners: 'hidden @[560px]:flex',
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { getContext, setContext } from 'svelte';
|
|
14
14
|
import { readable } from 'svelte/store';
|
|
15
|
-
|
|
15
|
+
const FLOATING_LAYER_CONTEXT_KEY = Symbol('widgetic-canvas-floating-layer');
|
|
16
16
|
/**
|
|
17
17
|
* The classes of the layer's element: no size (so it catches no press, and no `pointer-events: none` is needed, which the
|
|
18
18
|
* menus inside would inherit), above the chrome, and a containing block for what is fixed inside it.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export const FLOATING_LAYER_CLASSES = 'absolute inset-0 z-50 h-0 w-0 [contain:layout]';
|
|
21
21
|
/** Called by the canvas that owns the layer, before its children are made. */
|
|
22
22
|
export function provideFloatingLayer(layer) {
|
|
23
23
|
setContext(FLOATING_LAYER_CONTEXT_KEY, layer);
|
|
@@ -27,11 +27,10 @@ export function provideFloatingLayer(layer) {
|
|
|
27
27
|
* default applies. Inside a canvas the value is `null` until the canvas has made its layer, a moment after its first render.
|
|
28
28
|
*/
|
|
29
29
|
export function useFloatingLayer() {
|
|
30
|
-
|
|
31
|
-
return (_a = getContext(FLOATING_LAYER_CONTEXT_KEY)) !== null && _a !== void 0 ? _a : readable(undefined);
|
|
30
|
+
return getContext(FLOATING_LAYER_CONTEXT_KEY) ?? readable(undefined);
|
|
32
31
|
}
|
|
33
32
|
/** Below design-system dialogs, dropdowns and toasts (`z-50`); still above normal page content so a compact card does not cover menus. */
|
|
34
|
-
export
|
|
33
|
+
export const CANVAS_OVERLAY_PORTAL_Z_CLASS = 'z-40';
|
|
35
34
|
/**
|
|
36
35
|
* Portal target for a menu, popover or tooltip: `document.body` in the light DOM, else the in-canvas floating layer.
|
|
37
36
|
* Floating UI still measures from the trigger; only the mount node changes.
|
|
@@ -51,7 +50,7 @@ export function canvasOverlayPortalProps(floatingLayer) {
|
|
|
51
50
|
? { to: document.body, class: CANVAS_OVERLAY_PORTAL_Z_CLASS }
|
|
52
51
|
: { class: CANVAS_OVERLAY_PORTAL_Z_CLASS };
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
const root = floatingLayer.getRootNode();
|
|
55
54
|
if (typeof Document !== 'undefined' && root instanceof Document) {
|
|
56
55
|
return { to: document.body, class: CANVAS_OVERLAY_PORTAL_Z_CLASS };
|
|
57
56
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** The platform name of a browser, from the newer API when there is one. */
|
|
2
2
|
function platformName(nav) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return (_c = (_b = (_a = withData.userAgentData) === null || _a === void 0 ? void 0 : _a.platform) !== null && _b !== void 0 ? _b : nav.platform) !== null && _c !== void 0 ? _c : '';
|
|
3
|
+
const withData = nav;
|
|
4
|
+
return withData.userAgentData?.platform ?? nav.platform ?? '';
|
|
6
5
|
}
|
|
7
6
|
/** True on a Mac, an iPhone or an iPad, where the shortcut key is Command and the menus print it as a symbol. */
|
|
8
|
-
export function isApplePlatform(nav) {
|
|
9
|
-
if (nav === void 0) { nav = typeof navigator === 'undefined' ? undefined : navigator; }
|
|
7
|
+
export function isApplePlatform(nav = typeof navigator === 'undefined' ? undefined : navigator) {
|
|
10
8
|
if (!nav)
|
|
11
9
|
return false;
|
|
12
10
|
return /mac|iphone|ipad|ipod/i.test(platformName(nav));
|
|
@@ -19,7 +17,7 @@ export function isApplePlatform(nav) {
|
|
|
19
17
|
export function ariaKeyShortcut(chord, apple) {
|
|
20
18
|
if (typeof chord.key !== 'string')
|
|
21
19
|
return undefined;
|
|
22
|
-
|
|
20
|
+
const parts = [];
|
|
23
21
|
if (chord.mod)
|
|
24
22
|
parts.push(apple ? 'Meta' : 'Control');
|
|
25
23
|
if (chord.shift)
|
|
@@ -32,10 +30,10 @@ export function ariaKeyShortcut(chord, apple) {
|
|
|
32
30
|
* the same in every language; the words of the others come from the page's language.
|
|
33
31
|
*/
|
|
34
32
|
export function chordText(chord, apple, t) {
|
|
35
|
-
|
|
33
|
+
const key = typeof chord.key === 'string' ? chord.key : t(chord.key.name);
|
|
36
34
|
if (apple)
|
|
37
|
-
return
|
|
38
|
-
|
|
35
|
+
return `${chord.shift ? '⇧' : ''}${chord.mod ? '⌘' : ''}${key}`;
|
|
36
|
+
const parts = [];
|
|
39
37
|
if (chord.mod)
|
|
40
38
|
parts.push(t('canvas.key.ctrl'));
|
|
41
39
|
if (chord.shift)
|
|
@@ -48,8 +46,8 @@ export function chordText(chord, apple, t) {
|
|
|
48
46
|
* elsewhere. The toolbar and zoom control keep `chordText` (symbols on Apple).
|
|
49
47
|
*/
|
|
50
48
|
export function menuChordText(chord, apple, t) {
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const key = typeof chord.key === 'string' ? chord.key : t(chord.key.name);
|
|
50
|
+
const parts = [];
|
|
53
51
|
if (chord.shift)
|
|
54
52
|
parts.push(t('canvas.key.shift'));
|
|
55
53
|
if (chord.mod)
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
* The side is given as a function, so a card that the page moves while the canvas is open takes its tooltips with it.
|
|
10
10
|
*/
|
|
11
11
|
import { getContext, setContext } from 'svelte';
|
|
12
|
-
|
|
12
|
+
const POPOVER_SIDE_CONTEXT_KEY = Symbol('widgetic-canvas-popover-side');
|
|
13
13
|
/** Called by a card of the chrome, before its children are made. */
|
|
14
14
|
export function providePopoverSide(getSide) {
|
|
15
15
|
setContext(POPOVER_SIDE_CONTEXT_KEY, getSide);
|
|
16
16
|
}
|
|
17
17
|
/** The side to open a tooltip or a menu to. A button used outside a card of the chrome opens upward, as the bottom toolbar always did. */
|
|
18
18
|
export function usePopoverSide() {
|
|
19
|
-
|
|
20
|
-
return (_a = getContext(POPOVER_SIDE_CONTEXT_KEY)) !== null && _a !== void 0 ? _a : (function () { return 'top'; });
|
|
19
|
+
return getContext(POPOVER_SIDE_CONTEXT_KEY) ?? (() => 'top');
|
|
21
20
|
}
|
|
@@ -64,10 +64,14 @@ export declare function minimumStrokeWidth(traits: SelectionTraits): number;
|
|
|
64
64
|
/** What the font size stepper shows: a whole number, never a long float from resizing. */
|
|
65
65
|
export declare function formatFontSizeDisplay(trait: Trait<number>): number | '–';
|
|
66
66
|
/**
|
|
67
|
-
* Whether the
|
|
67
|
+
* Whether the Fill colour row shows: when something selected has a colour to fill, which is a shape's inside, the letters of a text or
|
|
68
|
+
* the line of a line-only icon. The look of the board (the wireframe look, which starts a new shape white with a grey outline) decides
|
|
69
|
+
* how a shape begins, not whether its colours can be changed afterwards: "The shapes are lacking the stroke and the fill color" (19 Nov
|
|
70
|
+
* 2026) was the row being hidden for every shape in that look.
|
|
68
71
|
*/
|
|
69
|
-
export declare function showFillColorRow(traits: SelectionTraits
|
|
72
|
+
export declare function showFillColorRow(traits: SelectionTraits): boolean;
|
|
70
73
|
/**
|
|
71
|
-
* Whether the
|
|
74
|
+
* Whether the Stroke colour row shows: when something selected has an outline or a line of its own to colour (a shape's outline, an
|
|
75
|
+
* arrow, a line drawn by hand, and the pen of the Draw tool). Like the Fill row, whatever the look of the board is.
|
|
72
76
|
*/
|
|
73
|
-
export declare function showStrokeColorRow(traits: SelectionTraits
|
|
77
|
+
export declare function showStrokeColorRow(traits: SelectionTraits): boolean;
|
|
@@ -5,26 +5,17 @@
|
|
|
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
|
-
};
|
|
17
8
|
import { isArrow } from '../../engine/core/arrow.js';
|
|
18
9
|
import { isBrushStroke } from '../../engine/core/brush.js';
|
|
19
10
|
import { leafShapesOf, normalizeSelection } from '../../engine/core/scene.js';
|
|
20
11
|
import { lineColorOf, minimumStrokeWidthOf, paintsFillOnStroke, pathSupportsRoundness } from '../../engine/core/style.js';
|
|
21
|
-
|
|
12
|
+
const NONE = { kind: 'none' };
|
|
22
13
|
/** One value out of many: the value they all have, `mixed` when they differ, `none` when there is nothing to compare. */
|
|
23
14
|
export function unify(values) {
|
|
24
15
|
if (values.length === 0)
|
|
25
16
|
return NONE;
|
|
26
|
-
|
|
27
|
-
return values.every(
|
|
17
|
+
const first = values[0];
|
|
18
|
+
return values.every((value) => Object.is(value, first)) ? { kind: 'same', value: first } : { kind: 'mixed' };
|
|
28
19
|
}
|
|
29
20
|
/** Whether a shape has a fill and a stroke of its own: the three kinds of vector shape. */
|
|
30
21
|
function isVector(shape) {
|
|
@@ -32,43 +23,46 @@ function isVector(shape) {
|
|
|
32
23
|
}
|
|
33
24
|
/** Describes the selection for the panel. */
|
|
34
25
|
export function describeSelection(scene, selectedIds) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
const unitIds = normalizeSelection(scene, selectedIds);
|
|
27
|
+
const unitIdSet = new Set(unitIds);
|
|
28
|
+
const units = scene.filter((object) => unitIdSet.has(object.id));
|
|
29
|
+
const shapes = leafShapesOf(scene, unitIds);
|
|
30
|
+
const only = units.length === 1 ? units[0] : undefined;
|
|
31
|
+
const widgetCard = only && only.type === 'widget' ? only : null;
|
|
41
32
|
// The card of a widget is the page's to style (it shows the widget): the panel does not paint it.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
const targets = shapes.filter((shape) => shape.type !== 'widget');
|
|
34
|
+
const vectors = targets.filter(isVector);
|
|
35
|
+
const texts = targets.filter((shape) => shape.type === 'text');
|
|
45
36
|
// 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.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
const fillValues = [
|
|
38
|
+
...vectors
|
|
39
|
+
.filter((shape) => !isBrushStroke(shape) && !isArrow(shape))
|
|
40
|
+
.map((shape) => (paintsFillOnStroke(shape) ? shape.stroke : shape.fill)),
|
|
41
|
+
...texts.map((shape) => shape.color)
|
|
42
|
+
];
|
|
43
|
+
const strokeValues = vectors.filter((shape) => !paintsFillOnStroke(shape)).map(lineColorOf);
|
|
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));
|
|
53
47
|
return {
|
|
54
|
-
targets
|
|
55
|
-
units
|
|
48
|
+
targets,
|
|
49
|
+
units,
|
|
56
50
|
fill: unify(fillValues),
|
|
57
51
|
stroke: unify(strokeValues),
|
|
58
|
-
strokeWidth: unify(vectors.map(
|
|
52
|
+
strokeWidth: unify(vectors.map((shape) => shape.strokeWidth)),
|
|
59
53
|
roundness: unify(roundnessValues),
|
|
60
|
-
opacity: unify(targets.map(
|
|
54
|
+
opacity: unify(targets.map((shape) => shape.opacity)),
|
|
61
55
|
text: texts.length === 0
|
|
62
56
|
? null
|
|
63
57
|
: {
|
|
64
|
-
fontSize: unify(texts.map(
|
|
65
|
-
fontFamily: unify(texts.map(
|
|
66
|
-
bold: unify(texts.map(
|
|
67
|
-
italic: unify(texts.map(
|
|
68
|
-
underline: unify(texts.map(
|
|
69
|
-
align: unify(texts.map(
|
|
58
|
+
fontSize: unify(texts.map((shape) => shape.fontSize)),
|
|
59
|
+
fontFamily: unify(texts.map((shape) => shape.fontFamily)),
|
|
60
|
+
bold: unify(texts.map((shape) => shape.fontWeight === 'bold')),
|
|
61
|
+
italic: unify(texts.map((shape) => shape.fontStyle === 'italic')),
|
|
62
|
+
underline: unify(texts.map((shape) => shape.underline)),
|
|
63
|
+
align: unify(texts.map((shape) => shape.align))
|
|
70
64
|
},
|
|
71
|
-
widgetCard
|
|
65
|
+
widgetCard
|
|
72
66
|
};
|
|
73
67
|
}
|
|
74
68
|
/**
|
|
@@ -98,33 +92,25 @@ export function traitNumber(trait, fallback) {
|
|
|
98
92
|
* 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
93
|
*/
|
|
100
94
|
export function minimumStrokeWidth(traits) {
|
|
101
|
-
return Math.max
|
|
95
|
+
return Math.max(0, ...traits.targets.filter(isVector).map(minimumStrokeWidthOf));
|
|
102
96
|
}
|
|
103
97
|
/** What the font size stepper shows: a whole number, never a long float from resizing. */
|
|
104
98
|
export function formatFontSizeDisplay(trait) {
|
|
105
99
|
return trait.kind === 'same' ? Math.round(trait.value) : '–';
|
|
106
100
|
}
|
|
107
101
|
/**
|
|
108
|
-
* Whether the
|
|
102
|
+
* Whether the Fill colour row shows: when something selected has a colour to fill, which is a shape's inside, the letters of a text or
|
|
103
|
+
* the line of a line-only icon. The look of the board (the wireframe look, which starts a new shape white with a grey outline) decides
|
|
104
|
+
* how a shape begins, not whether its colours can be changed afterwards: "The shapes are lacking the stroke and the fill color" (19 Nov
|
|
105
|
+
* 2026) was the row being hidden for every shape in that look.
|
|
109
106
|
*/
|
|
110
|
-
export function showFillColorRow(traits
|
|
111
|
-
|
|
112
|
-
return false;
|
|
113
|
-
return !wireframeMode || traits.text !== null;
|
|
107
|
+
export function showFillColorRow(traits) {
|
|
108
|
+
return traits.fill.kind !== 'none';
|
|
114
109
|
}
|
|
115
110
|
/**
|
|
116
|
-
* Whether the
|
|
111
|
+
* Whether the Stroke colour row shows: when something selected has an outline or a line of its own to colour (a shape's outline, an
|
|
112
|
+
* arrow, a line drawn by hand, and the pen of the Draw tool). Like the Fill row, whatever the look of the board is.
|
|
117
113
|
*/
|
|
118
|
-
export function showStrokeColorRow(traits
|
|
119
|
-
|
|
120
|
-
return false;
|
|
121
|
-
if (!wireframeMode)
|
|
122
|
-
return true;
|
|
123
|
-
return traits.targets.some(function (shape) {
|
|
124
|
-
if (shape.type === 'rect' || shape.type === 'ellipse')
|
|
125
|
-
return false;
|
|
126
|
-
if (shape.type !== 'path')
|
|
127
|
-
return false;
|
|
128
|
-
return isBrushStroke(shape) || isArrow(shape) || !paintsFillOnStroke(shape);
|
|
129
|
-
});
|
|
114
|
+
export function showStrokeColorRow(traits) {
|
|
115
|
+
return traits.stroke.kind !== 'none';
|
|
130
116
|
}
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
{#if loading}
|
|
162
162
|
<!-- The board stays visible while its content loads. Input waits, so a late load cannot replace what was just drawn. -->
|
|
163
163
|
<div class="absolute inset-0 z-30 cursor-progress" data-canvas-loader>
|
|
164
|
-
<!-- No spinner over the poster: the placeholders before the canvas drew none, and a spinner
|
|
164
|
+
<!-- No spinner over the poster: the placeholders before the canvas drew none, and a spinner made now, when the opening is older than its delay, would show at once and blink for the moment the board reads its saved text. The layer stays, so input still waits. -->
|
|
165
165
|
{#if !posterVisible}
|
|
166
166
|
<CanvasBoardPlaceholder showSurface={false} />
|
|
167
167
|
{/if}
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
}
|
|
226
226
|
if (!frame || state.overlay.readout) return null;
|
|
227
227
|
const text = formatReadout({ kind: 'size', width: Math.round(frame.world.width), height: Math.round(frame.world.height) });
|
|
228
|
-
const at = restingSizeLabelPoint(frame.screen
|
|
228
|
+
const at = restingSizeLabelPoint(frame.screen);
|
|
229
229
|
if (!at) return null;
|
|
230
230
|
return { x: at.x, y: at.y, text };
|
|
231
231
|
});
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
// The figure of a stretch (the size) or of a turn (the angle) stands in the middle of the frame, in both cases.
|
|
234
234
|
const readoutPoint = $derived.by(() => {
|
|
235
235
|
if (!frame || !state.overlay.readout) return null;
|
|
236
|
-
return restingSizeLabelPoint(frame.screen
|
|
236
|
+
return restingSizeLabelPoint(frame.screen);
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
/** Where one handle sits on the frame, as the percentages of its width and height. */
|
|
@@ -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 const NOTHING_ERASED = new Set();
|
|
16
16
|
export function createErasingMarks() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const { subscribe, set } = writable(NOTHING_ERASED);
|
|
18
|
+
let listSeen = null;
|
|
19
|
+
let current = NOTHING_ERASED;
|
|
20
20
|
return {
|
|
21
|
-
subscribe
|
|
22
|
-
take
|
|
21
|
+
subscribe,
|
|
22
|
+
take(marked) {
|
|
23
23
|
if (marked === listSeen)
|
|
24
24
|
return;
|
|
25
25
|
listSeen = marked;
|
|
26
|
-
|
|
26
|
+
const 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;
|
|
@@ -97,7 +97,7 @@ export declare function formatReadout(readout: Readout): string;
|
|
|
97
97
|
* all of it when several things are selected), where the figure of a stretch or a turn sits too, so the number is always at
|
|
98
98
|
* the same place and never moves off the thing it measures.
|
|
99
99
|
*/
|
|
100
|
-
export declare function restingSizeLabelPoint(frame: ScreenFrame
|
|
100
|
+
export declare function restingSizeLabelPoint(frame: ScreenFrame): Point | null;
|
|
101
101
|
/** A point at `distance` pixels below the bottom edge of a turned frame, in the middle of that edge: where the turning dot goes. */
|
|
102
102
|
export declare function pointBelowFrame(frame: ScreenFrame, distance: number): Point;
|
|
103
103
|
/**
|