@widgetic/canvas 0.5.46 → 0.5.48
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 +4 -1
- package/dist/canvas/DomCanvas.svelte +5 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +1 -0
- package/dist/canvas/eventScope.js +7 -1
- package/dist/canvas/host/CanvasHost.d.ts +5 -3
- package/dist/canvas/host/CanvasHost.js +114 -74
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/CanvasToolbar.svelte +17 -14
- 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/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +28 -8
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +10 -18
- package/dist/canvas/view/SelectionOverlay.svelte +5 -5
- package/dist/canvas/view/WidgetChromeLayer.svelte +10 -2
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/engine/EngineCore.d.ts +33 -8
- package/dist/engine/EngineCore.js +66 -30
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +145 -13
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +45 -17
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +57 -25
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +123 -48
- package/dist/engine/input/keyboard.js +14 -5
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +6 -3
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/rememberedTool.js +2 -1
- package/dist/settings/workspaceToolSettings.d.ts +17 -0
- package/dist/settings/workspaceToolSettings.js +4 -1
- package/dist/tools/hostAdapter.js +0 -1
- package/package.json +4 -4
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Left to right: the drawing group (select, draw, erase, arrow, text), a divider, the Shapes menu, a divider and the history
|
|
6
6
|
group (undo, redo). Every button is the design system's Icon Button with a tooltip, 36 px square, and the tool in use has
|
|
7
|
-
the brand tint. The page's `showDrawingTools` hides the
|
|
8
|
-
|
|
7
|
+
the brand tint. The page's `showDrawingTools` hides the sketch tools (draw, erase, arrow, text) and their letters. Select
|
|
8
|
+
stays on the bar: that is how the person turns the widget's element selector on after the first generation. The Shapes
|
|
9
|
+
menu and the history group are always on the bar: a page that wants a leaner canvas hides the bar itself (`showToolbar`). On a
|
|
9
10
|
board narrower than the whole bar and its edges (381 px, so Figma's 358 px phone) the history group leaves the bar.
|
|
10
11
|
|
|
11
12
|
The bar stands where the page's `toolbarPosition` says. On the left or the right edge it stands upright: the same groups
|
|
@@ -57,10 +58,10 @@
|
|
|
57
58
|
class="canvas-toolbar-el pointer-events-auto flex items-center gap-1 {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full'} {FLOATING_CARD_CLASSES} {TOOLBAR_ICON_STROKE_CLASSES} [&_svg]:size-4"
|
|
58
59
|
data-canvas-ui
|
|
59
60
|
>
|
|
61
|
+
<ToolButton toggle label={$t('canvas.tool.select')} shortcut={TOOL_KEYS.select} alternateShortcut={TOOL_DIGIT_KEYS.select} active={state.tool === 'select'} onclick={() => host.onSelectSelectTool()}>
|
|
62
|
+
<IconPointer />
|
|
63
|
+
</ToolButton>
|
|
60
64
|
{#if showDrawingTools}
|
|
61
|
-
<ToolButton toggle label={$t('canvas.tool.select')} shortcut={TOOL_KEYS.select} alternateShortcut={TOOL_DIGIT_KEYS.select} active={state.tool === 'select'} onclick={() => host.onSelectSelectTool()}>
|
|
62
|
-
<IconPointer />
|
|
63
|
-
</ToolButton>
|
|
64
65
|
<ToolButton toggle label={$t('canvas.tool.draw')} shortcut={TOOL_KEYS.draw} alternateShortcut={TOOL_DIGIT_KEYS.draw} active={state.tool === 'draw'} onclick={() => host.onSelectDrawTool()}>
|
|
65
66
|
<IconPencil />
|
|
66
67
|
</ToolButton>
|
|
@@ -73,18 +74,20 @@
|
|
|
73
74
|
<ToolButton toggle label={$t('canvas.tool.text')} shortcut={TOOL_KEYS.text} alternateShortcut={TOOL_DIGIT_KEYS.text} active={state.tool === 'text'} onclick={() => host.onSelectTextTool()}>
|
|
74
75
|
<IconTypography />
|
|
75
76
|
</ToolButton>
|
|
77
|
+
{/if}
|
|
76
78
|
|
|
79
|
+
{#if showDrawingTools}
|
|
77
80
|
<Separator orientation={vertical ? 'horizontal' : 'vertical'} class={vertical ? 'w-5' : 'h-5 min-h-0'} />
|
|
78
|
-
{/if}
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
<ShapesMenu
|
|
83
|
+
{host}
|
|
84
|
+
tool={state.tool}
|
|
85
|
+
libraryShapeKey={state.libraryShapeKey}
|
|
86
|
+
open={ui.shapesMenuOpen}
|
|
87
|
+
imageShortcut={TOOL_KEYS.image}
|
|
88
|
+
{showFiles}
|
|
89
|
+
/>
|
|
90
|
+
{/if}
|
|
88
91
|
|
|
89
92
|
<!-- The history group is the first thing a board too narrow for the whole bar gives up (Figma's phone): undo and redo stay on the keys. An upright bar is as long as the board is tall, so it keeps them. -->
|
|
90
93
|
<div
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
import type { Attachment } from 'svelte/attachments';
|
|
28
28
|
import { IconButton, NumberControls, Select, Slider } from '@widgetic/design-system/components';
|
|
29
29
|
import { MIN_BRUSH_WIDTH } from '../../engine/core/brush.js';
|
|
30
|
+
import { MAX_STROKE_WIDTH } from '../../engine/core/style.js';
|
|
30
31
|
import type { StylePatch } from '../../engine/core/style.js';
|
|
31
32
|
import { MIN_PEN_OPACITY } from '../../engine/state.js';
|
|
32
33
|
import type { EngineState, PenStyle } from '../../engine/state.js';
|
|
@@ -61,8 +62,6 @@
|
|
|
61
62
|
host: CanvasHost;
|
|
62
63
|
state: EngineState;
|
|
63
64
|
ui: HostUiState;
|
|
64
|
-
/** The page hides the colour fields (the wireframe mode keeps every shape white with a grey outline). */
|
|
65
|
-
wireframeMode: boolean;
|
|
66
65
|
canCapture: boolean;
|
|
67
66
|
canConvert: boolean;
|
|
68
67
|
canRename: boolean;
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
widgetCardHasNoSettings?: boolean;
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
let { host, state, ui,
|
|
81
|
+
let { host, state, ui, canCapture, canConvert, canRename, canRefresh, canOpenDetails, clearance, widgetCardHasNoSettings = false }: Props = $props();
|
|
83
82
|
|
|
84
83
|
const { t } = useCanvasLanguage();
|
|
85
84
|
const floatingLayer = useFloatingLayer();
|
|
@@ -140,7 +139,12 @@
|
|
|
140
139
|
host.changePenStyle(penPatch, { final });
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Changes how the selection looks (or the pen, while the panel is about the pen). `commit` is false while a drag is going.
|
|
144
|
+
*
|
|
145
|
+
* The engine remembers what was chosen for the next elements of this kind at every change (a drag of a slider included), and the host
|
|
146
|
+
* keeps it for the workspace: the panel has nothing more to do than change the selection.
|
|
147
|
+
*/
|
|
144
148
|
function changeStyle(patch: StylePatch, commit = true): void {
|
|
145
149
|
if (editsPen) {
|
|
146
150
|
changePen(patch, commit);
|
|
@@ -149,10 +153,7 @@
|
|
|
149
153
|
try {
|
|
150
154
|
host.engine.setStyle(patch, { commit });
|
|
151
155
|
stopCommitTimer();
|
|
152
|
-
if (commit)
|
|
153
|
-
host.engine.commit();
|
|
154
|
-
host.persistWorkspaceStyle(patch);
|
|
155
|
-
}
|
|
156
|
+
if (commit) host.engine.commit();
|
|
156
157
|
else commitTimer = setTimeout(() => host.engine.commit(), COMMIT_AFTER_MS);
|
|
157
158
|
} catch (error) {
|
|
158
159
|
console.warn('Canvas: the selection panel could not change the selection', error);
|
|
@@ -234,9 +235,10 @@
|
|
|
234
235
|
(!selectionIsAWidgetWithoutSettings &&
|
|
235
236
|
((shouldOfferSelectionPanelForTraits(traits) && hasSelection) || (canCapture && !canConvert)))
|
|
236
237
|
);
|
|
237
|
-
|
|
238
|
-
//
|
|
239
|
-
const
|
|
238
|
+
// The colour rows follow what is selected (and the pen's colour, which is the Stroke of its traits), on every board: the wireframe
|
|
239
|
+
// look only decides how a new shape starts (white with a grey outline), not which colours can be changed afterwards.
|
|
240
|
+
const showFillColor = $derived(showFillColorRow(traits));
|
|
241
|
+
const showStrokeColor = $derived(showStrokeColorRow(traits));
|
|
240
242
|
const fontSizeDisplay = $derived(traits.text ? formatFontSizeDisplay(traits.text.fontSize) : '–');
|
|
241
243
|
const panelAnchorClass = $derived(
|
|
242
244
|
`${clearance.belowTopCards ? 'top-16' : 'top-4'} ${PANEL_MAX_WIDTH_CLASSES[clearance.besideSideCard ?? 'none']}`
|
|
@@ -301,7 +303,7 @@
|
|
|
301
303
|
value={traits.strokeWidth.kind === 'same' ? Number(strokeWidthValue.toFixed(1)) : null}
|
|
302
304
|
fallbackValue={strokeWidthValue}
|
|
303
305
|
min={strokeWidthMin}
|
|
304
|
-
max={
|
|
306
|
+
max={MAX_STROKE_WIDTH}
|
|
305
307
|
step={1}
|
|
306
308
|
onChange={(next) => changeStyle({ strokeWidth: next })}
|
|
307
309
|
/>
|
|
@@ -5,8 +5,6 @@ interface Props {
|
|
|
5
5
|
host: CanvasHost;
|
|
6
6
|
state: EngineState;
|
|
7
7
|
ui: HostUiState;
|
|
8
|
-
/** The page hides the colour fields (the wireframe mode keeps every shape white with a grey outline). */
|
|
9
|
-
wireframeMode: boolean;
|
|
10
8
|
canCapture: boolean;
|
|
11
9
|
canConvert: boolean;
|
|
12
10
|
canRename: boolean;
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
import {
|
|
27
27
|
CANVAS_OVERLAY_Z_CLASS,
|
|
28
28
|
MENU_PADDING_CLASS,
|
|
29
|
-
MENU_TRIGGER_RING_CLASSES,
|
|
30
29
|
OVERLAY_REDUCED_MOTION_CLASSES,
|
|
31
30
|
SHAPE_LIBRARY_STROKE_WIDTH,
|
|
31
|
+
SUBMENU_SLIDE_UP_CLASSES,
|
|
32
32
|
TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES,
|
|
33
|
-
TOOLBAR_ICON_STROKE_CLASSES
|
|
33
|
+
TOOLBAR_ICON_STROKE_CLASSES,
|
|
34
|
+
TOOLBAR_NO_RING_CLASSES
|
|
34
35
|
} from './floatingCard.js';
|
|
35
36
|
import { canvasOverlayPortalProps, useFloatingLayer } from './floatingLayer.js';
|
|
36
37
|
import { usePopoverSide } from './popoverSide.js';
|
|
@@ -132,7 +133,7 @@
|
|
|
132
133
|
type="button"
|
|
133
134
|
aria-label={$t('canvas.tool.shapes')}
|
|
134
135
|
data-active={shapeToolInUse ? '' : undefined}
|
|
135
|
-
class="flex h-9 w-[51px] shrink-0 items-center justify-center gap-1 rounded-lg text-foreground transition-colors duration-fast hover:bg-accent focus-visible:bg-accent
|
|
136
|
+
class="flex h-9 w-[51px] shrink-0 items-center justify-center gap-1 rounded-lg text-foreground transition-colors duration-fast hover:bg-accent focus-visible:bg-accent {TOOLBAR_NO_RING_CLASSES} data-[active]:bg-brand-subtle {TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES} [&_svg]:size-4 {TOOLBAR_ICON_STROKE_CLASSES}"
|
|
136
137
|
>
|
|
137
138
|
<IconCategory />
|
|
138
139
|
<IconChevronDown class="transition-transform duration-fast motion-reduce:transition-none data-[open]:rotate-180" data-open={open ? '' : undefined} />
|
|
@@ -185,7 +186,8 @@
|
|
|
185
186
|
<DropdownMenu.Separator />
|
|
186
187
|
<DropdownMenu.Sub>
|
|
187
188
|
<DropdownMenu.SubTrigger>{$t('canvas.tool.moreShapes')}</DropdownMenu.SubTrigger>
|
|
188
|
-
|
|
189
|
+
<!-- It fades in and slides up like the Shapes menu (`SUBMENU_SLIDE_UP_CLASSES`): without it the slide it inherited came from the bottom left. -->
|
|
190
|
+
<DropdownMenu.SubContent aria-label={$t('canvas.tool.moreShapes')} class="{CANVAS_OVERLAY_Z_CLASS} max-h-[min(24rem,70vh)] w-[220px] overflow-y-auto {MENU_PADDING_CLASS} shadow-floating {SUBMENU_SLIDE_UP_CLASSES} {OVERLAY_REDUCED_MOTION_CLASSES}">
|
|
189
191
|
{#each libraryGroups as [category, shapes] (category)}
|
|
190
192
|
<DropdownMenu.Label>{categoryLabel(category, $t)}</DropdownMenu.Label>
|
|
191
193
|
<div class="grid grid-cols-5 gap-1 px-1 pb-1" role="presentation">
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import type { Snippet } from 'svelte';
|
|
10
10
|
import { IconButton } from '@widgetic/design-system/components';
|
|
11
|
-
import { TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES } from './floatingCard.js';
|
|
11
|
+
import { TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES, TOOLBAR_NO_RING_CLASSES } from './floatingCard.js';
|
|
12
12
|
import ShortcutTooltip from './ShortcutTooltip.svelte';
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
@@ -44,15 +44,16 @@
|
|
|
44
44
|
// system's `press-feedback` (which keeps still for a person who asked for less motion). The keyboard focus has no ring on it: like
|
|
45
45
|
// the design system's Icon Button it takes the look of the hover (a ring stayed on the button the pointer had clicked as soon as a
|
|
46
46
|
// shortcut key was pressed). The tool that is on keeps its brand tint, a deeper one while the keyboard holds the focus
|
|
47
|
-
// (`TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES`), so that the focus is never invisible and never a ring
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
// (`TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES`), so that the focus is never invisible and never a ring (`TOOLBAR_NO_RING_CLASSES`,
|
|
48
|
+
// added where each button is drawn below, takes the browser's own ring off every button of the chrome, for `focus` as well as
|
|
49
|
+
// for `focus-visible`). This one stays a plain string: `tests/ui/pressFeedback.test.mjs` reads it for the press cue.
|
|
50
|
+
const LEVEL_CLASSES = 'press-feedback inline-flex h-8 w-10 shrink-0 items-center justify-center rounded-lg text-xs font-medium text-muted-foreground transition-colors duration-fast motion-reduce:transition-none hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground disabled:pointer-events-none disabled:opacity-50';
|
|
50
51
|
</script>
|
|
51
52
|
|
|
52
53
|
<ShortcutTooltip {label} {shortcut}>
|
|
53
54
|
{#snippet trigger(props)}
|
|
54
55
|
{#if size === 'level'}
|
|
55
|
-
<button {...props} type="button" aria-label={label} aria-keyshortcuts={keyShortcuts} {disabled} {onclick} class="{LEVEL_CLASSES} {className}">
|
|
56
|
+
<button {...props} type="button" aria-label={label} aria-keyshortcuts={keyShortcuts} {disabled} {onclick} class="{LEVEL_CLASSES} {TOOLBAR_NO_RING_CLASSES} {className}">
|
|
56
57
|
{@render children()}
|
|
57
58
|
</button>
|
|
58
59
|
{:else}
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
aria-pressed={toggle ? active : undefined}
|
|
65
66
|
aria-keyshortcuts={keyShortcuts}
|
|
66
67
|
data-active={active ? '' : undefined}
|
|
67
|
-
class="{SQUARE_CLASSES[size]} data-[active]:bg-brand-subtle data-[active]:text-foreground {TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES} {className}"
|
|
68
|
+
class="{SQUARE_CLASSES[size]} data-[active]:bg-brand-subtle data-[active]:text-foreground {TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES} {TOOLBAR_NO_RING_CLASSES} {className}"
|
|
68
69
|
>
|
|
69
70
|
{@render children()}
|
|
70
71
|
</IconButton>
|
|
@@ -34,16 +34,36 @@ export declare const OVERLAY_REDUCED_MOTION_CLASSES = "motion-reduce:animate-non
|
|
|
34
34
|
/** Canvas-floated surfaces stay below site dialogs and toasts (design-system overlays use z-50). */
|
|
35
35
|
export declare 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 declare const
|
|
47
|
+
export declare 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 declare 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 declare 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
|
|
@@ -34,16 +34,36 @@ export const OVERLAY_REDUCED_MOTION_CLASSES = 'motion-reduce:animate-none motion
|
|
|
34
34
|
/** Canvas-floated surfaces stay below site dialogs and toasts (design-system overlays use z-50). */
|
|
35
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 const
|
|
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
|
|
@@ -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;
|
|
@@ -99,26 +99,18 @@ export function formatFontSizeDisplay(trait) {
|
|
|
99
99
|
return trait.kind === 'same' ? Math.round(trait.value) : '–';
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* 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.
|
|
103
106
|
*/
|
|
104
|
-
export function showFillColorRow(traits
|
|
105
|
-
|
|
106
|
-
return false;
|
|
107
|
-
return !wireframeMode || traits.text !== null;
|
|
107
|
+
export function showFillColorRow(traits) {
|
|
108
|
+
return traits.fill.kind !== 'none';
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
* 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.
|
|
111
113
|
*/
|
|
112
|
-
export function showStrokeColorRow(traits
|
|
113
|
-
|
|
114
|
-
return false;
|
|
115
|
-
if (!wireframeMode)
|
|
116
|
-
return true;
|
|
117
|
-
return traits.targets.some((shape) => {
|
|
118
|
-
if (shape.type === 'rect' || shape.type === 'ellipse')
|
|
119
|
-
return false;
|
|
120
|
-
if (shape.type !== 'path')
|
|
121
|
-
return false;
|
|
122
|
-
return isBrushStroke(shape) || isArrow(shape) || !paintsFillOnStroke(shape);
|
|
123
|
-
});
|
|
114
|
+
export function showStrokeColorRow(traits) {
|
|
115
|
+
return traits.stroke.kind !== 'none';
|
|
124
116
|
}
|
|
@@ -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. */
|
|
@@ -387,9 +387,9 @@
|
|
|
387
387
|
{/if}
|
|
388
388
|
{#each shownHandles as handle (handle)}
|
|
389
389
|
{#if layer === 'above-widgets'}
|
|
390
|
-
<!--
|
|
390
|
+
<!-- The drawn square stays the 8 px one. The 10 px box around it is only the hit, centred on the same corner. -->
|
|
391
391
|
<span
|
|
392
|
-
class="pointer-events-auto absolute flex size-
|
|
392
|
+
class="pointer-events-auto absolute flex size-[10px] -translate-x-1/2 -translate-y-1/2 touch-none items-center justify-center"
|
|
393
393
|
style="{handleStyle(handle)}cursor:{handleCursor(handle)};"
|
|
394
394
|
data-canvas-handle={handle}
|
|
395
395
|
role="presentation"
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
onpointerup={passReleaseToHost}
|
|
399
399
|
onpointercancel={passReleaseToHost}
|
|
400
400
|
>
|
|
401
|
-
<span class="size-2 rounded-[2px] border-[1.5px] border-ring bg-background"></span>
|
|
401
|
+
<span class="pointer-events-none size-2 rounded-[2px] border-[1.5px] border-ring bg-background"></span>
|
|
402
402
|
</span>
|
|
403
403
|
{:else}
|
|
404
404
|
<span
|
|
@@ -86,10 +86,18 @@
|
|
|
86
86
|
});
|
|
87
87
|
</script>
|
|
88
88
|
|
|
89
|
-
<Portal {target} style="z-index:
|
|
89
|
+
<Portal {target} style="z-index: 100000000; pointer-events: none;">
|
|
90
90
|
<!-- rtl-ok: physical left: 0 origin probe for getBoundingClientRect() -->
|
|
91
91
|
<span bind:this={fixedOriginEl} class="pointer-events-none fixed left-0 top-0 size-0" aria-hidden="true"></span>
|
|
92
|
-
|
|
92
|
+
<!-- data-canvas-ui: this layer is portaled above the live widgets, outside the canvas root. Without the mark, a press on a corner is an "outside" press and the selection is cleared before the resize starts. -->
|
|
93
|
+
<div class="canvas-widget-selection-layer pointer-events-none fixed overflow-visible" dir="ltr" data-canvas-widget-chrome data-canvas-ui style={layerStyle}>
|
|
93
94
|
<SelectionOverlay state={engineState} {host} {gestureKind} {advancedFeatures} layer="above-widgets" />
|
|
94
95
|
</div>
|
|
95
96
|
</Portal>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
/* The portal turns pointer events on for its direct child. This layer covers the board, so only the handles may take a press. */
|
|
100
|
+
:global(.portal-contents) > .canvas-widget-selection-layer {
|
|
101
|
+
pointer-events: none !important;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -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
|
/**
|
|
@@ -124,7 +124,7 @@ export function formatReadout(readout) {
|
|
|
124
124
|
* 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
|
|
125
125
|
* the same place and never moves off the thing it measures.
|
|
126
126
|
*/
|
|
127
|
-
export function restingSizeLabelPoint(frame
|
|
127
|
+
export function restingSizeLabelPoint(frame) {
|
|
128
128
|
return { x: frame.centerX, y: frame.centerY };
|
|
129
129
|
}
|
|
130
130
|
/** A point at `distance` pixels below the bottom edge of a turned frame, in the middle of that edge: where the turning dot goes. */
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
|
|
229
229
|
<div class="presets-container overflow-x-hidden p-2 border border-gray-300 rounded-md {presets ? 'fixed-palette' : ''}"
|
|
230
230
|
style={presets ? `grid-template-columns: repeat(${Math.min(presets.length, 8)}, 1fr); max-height: none;` : ''}>
|
|
231
|
-
{#each allPresets as color}
|
|
231
|
+
{#each allPresets as color, presetIndex (presetIndex)}
|
|
232
232
|
<div class="preset-wrapper">
|
|
233
233
|
<button
|
|
234
234
|
class="preset-btn"
|
|
@@ -16,8 +16,9 @@ import type { AlignMode, DistributeAxis } from './core/arrange.js';
|
|
|
16
16
|
import type { ArrowHandleId } from './core/arrow.js';
|
|
17
17
|
import type { ReorderMode, Scene } from './core/scene.js';
|
|
18
18
|
import type { StylePatch } from './core/style.js';
|
|
19
|
+
import type { PatchedStyleKind, RememberedStyles, StyleMemoryKind } from './core/styleMemory.js';
|
|
19
20
|
import type { SelectionFrame } from './core/transform.js';
|
|
20
|
-
import type { ObjectId, Point, Rect,
|
|
21
|
+
import type { ObjectId, Point, Rect, SceneObject, ShapeObject, Size, Viewport, WidgetObject } from './core/types.js';
|
|
21
22
|
import type { EngineOverlay, EngineState, PendingWidgetState, PenStyle, ToolId, WidgetRuntime } from './state.js';
|
|
22
23
|
import type { MeasureText } from './text/layoutText.js';
|
|
23
24
|
/** How many undo steps the board keeps (as the canvas it replaces did). */
|
|
@@ -118,6 +119,13 @@ export interface EngineHooks {
|
|
|
118
119
|
onCleared?: (cause: BoardClearCause) => void;
|
|
119
120
|
/** The selection changed (a selection, a deselection, after a delete or an undo). */
|
|
120
121
|
onSelectionChange?: (selectedIds: readonly ObjectId[]) => void;
|
|
122
|
+
/**
|
|
123
|
+
* The person restyled something and so changed what the next element of a kind starts with: the kinds that came out different (see
|
|
124
|
+
* `EngineCore.rememberedStyles`, and `EngineState.penStyle` for `'pen'`). The host keeps them for the workspace. Called for every
|
|
125
|
+
* change of the memory, a drag of a slider included, and not when an edit says what the memory holds already, nor when the memory
|
|
126
|
+
* is loaded (`setRememberedStyles`).
|
|
127
|
+
*/
|
|
128
|
+
onStyleRemembered?: (kinds: readonly StyleMemoryKind[]) => void;
|
|
121
129
|
/** Widget cards are about to be deleted: one question per widget, and one `false` cancels the whole delete. */
|
|
122
130
|
confirmWidgetDeletion?: ((widgetId: string) => Promise<boolean> | boolean) | null;
|
|
123
131
|
/** Whether widget cards may be duplicated/pasted on the board. Defaults to true. */
|
|
@@ -323,19 +331,29 @@ export declare class EngineCore {
|
|
|
323
331
|
notifyFontsChanged(): void;
|
|
324
332
|
/** Remembers the font family for the next text object the person places. */
|
|
325
333
|
setPreferredTextFontFamily(fontFamily: string): void;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
334
|
+
/**
|
|
335
|
+
* What the person last chose for each kind of element: the next shape, line icon, arrow or text starts with it, laid over the look it
|
|
336
|
+
* would start with (see `core/styleMemory.ts`). It is what the panel was used for, in this session and, when the host loaded it
|
|
337
|
+
* (`setRememberedStyles`), in the sessions before. The pen of the Draw tool is `state.penStyle`.
|
|
338
|
+
*/
|
|
339
|
+
get rememberedStyles(): RememberedStyles;
|
|
340
|
+
/**
|
|
341
|
+
* Loads what was kept for a workspace (the host does, when the board is opened in one), instead of what the engine has: a kind that
|
|
342
|
+
* the storage does not hold goes back to nothing remembered. What the storage holds is checked key by key (a value that is not one of
|
|
343
|
+
* the key is dropped, a number is brought into its range), so a damaged or an older entry cannot give a shape a look it cannot have.
|
|
344
|
+
* Not an edit of the person: nobody is told (`onStyleRemembered`) and nothing is saved because of it.
|
|
345
|
+
*/
|
|
346
|
+
setRememberedStyles(stored: {
|
|
347
|
+
readonly [kind in PatchedStyleKind]?: unknown;
|
|
348
|
+
} | null): void;
|
|
330
349
|
/**
|
|
331
350
|
* Changes how the Draw tool draws: the lines drawn from now on take the colour, the width and the opacity that are asked for. A key
|
|
332
|
-
* that is left out stays as it was; a value that cannot be a line's (a width under 1 or above
|
|
351
|
+
* that is left out stays as it was; a value that cannot be a line's (a width under 1 or above 50, an opacity out of range, a
|
|
333
352
|
* colour that is not a word, a number that is not a number) is brought to what a line can be, or ignored when it is not a value
|
|
334
353
|
* at all. Nothing on the board changes (that is `setStyle`, for the selection), and nothing is added to the history. Returns
|
|
335
354
|
* whether the pen came out different.
|
|
336
355
|
*/
|
|
337
356
|
setPenStyle(patch: Partial<PenStyle>): boolean;
|
|
338
|
-
workspacePaintForNewShape(wireframe: boolean): Partial<RectObject>;
|
|
339
357
|
/**
|
|
340
358
|
* Makes a text object, puts it on the board and starts editing it. A click makes a label whose width follows its
|
|
341
359
|
* text; a width makes a box whose lines wrap. Nothing is recorded until the editing ends with text in it.
|
|
@@ -363,7 +381,14 @@ export declare class EngineCore {
|
|
|
363
381
|
endTextEdit(options?: {
|
|
364
382
|
keepPlaceholderTool?: boolean;
|
|
365
383
|
}): ObjectId | null;
|
|
366
|
-
/**
|
|
384
|
+
/**
|
|
385
|
+
* Changes how the selection looks. `commit: false` is for a slider that is still being dragged: call `commit()` when it ends.
|
|
386
|
+
*
|
|
387
|
+
* What the person chose is also what the next element of each kind in the selection starts with, until they choose again (a
|
|
388
|
+
* rectangle's fill, stroke and width are the next rectangle's, the next ellipse's, the next star's; an arrow's colour is the next
|
|
389
|
+
* arrow's; a text's size is the next text's; the colour of a line drawn by hand is the pen's). It is kept for every change, a drag
|
|
390
|
+
* of a slider included and a value the selection has already, and the host is told (`onStyleRemembered`). See `core/styleMemory.ts`.
|
|
391
|
+
*/
|
|
367
392
|
setStyle(patch: StylePatch, options?: {
|
|
368
393
|
commit?: boolean;
|
|
369
394
|
}): boolean;
|