@widgetic/canvas 0.5.44 → 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 +52 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +59 -34
- 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 +68 -1
- package/dist/canvas/host/CanvasHost.js +1901 -1407
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +28 -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 +1 -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/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/SelectionPanel.svelte +78 -17
- 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 +34 -55
- 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 +37 -2
- package/dist/engine/EngineCore.js +946 -768
- 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 +6 -0
- package/dist/engine/core/cameraMove.js +56 -38
- 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 +547 -476
- 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 +1 -0
- 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
|
@@ -7,17 +7,19 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import type { Snippet } from 'svelte';
|
|
10
|
-
import { IconButton
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import { usePopoverSide } from './popoverSide.js';
|
|
10
|
+
import { IconButton } from '@widgetic/design-system/components';
|
|
11
|
+
import { TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES } from './floatingCard.js';
|
|
12
|
+
import ShortcutTooltip from './ShortcutTooltip.svelte';
|
|
14
13
|
|
|
15
14
|
interface Props {
|
|
16
15
|
/** What the button does. It is the accessible name and the first line of the tooltip. */
|
|
17
16
|
label: string;
|
|
18
17
|
/** The key that does the same, as it is printed on a key cap ("V"), or nothing. It is also the button's `aria-keyshortcuts`. */
|
|
19
18
|
shortcut?: string | undefined;
|
|
20
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* A second key that does the same ("1", the number of the tool): a second entry of `aria-keyshortcuts`. The tooltip does not
|
|
21
|
+
* draw it (the letter is the one the person is shown); the key still works.
|
|
22
|
+
*/
|
|
21
23
|
alternateShortcut?: string | undefined;
|
|
22
24
|
/** The tool this button chooses is the one in use. */
|
|
23
25
|
active?: boolean;
|
|
@@ -36,59 +38,36 @@
|
|
|
36
38
|
// `aria-keyshortcuts` lists the keys that do the same, separated by a space ("V 1").
|
|
37
39
|
const keyShortcuts = $derived([shortcut, alternateShortcut].filter(Boolean).join(' ') || undefined);
|
|
38
40
|
|
|
39
|
-
// The tooltip is drawn into the canvas's floating layer, not in place: see floatingLayer.ts.
|
|
40
|
-
const floatingLayer = useFloatingLayer();
|
|
41
|
-
// Until the canvas has made its layer nothing is mounted (the tooltip is closed then anyway), so the page's body is not written to.
|
|
42
|
-
const overlayPortal = $derived(canvasOverlayPortalProps($floatingLayer));
|
|
43
|
-
// It opens away from the edge the card stands on: upward from the bottom, downward from the top, sideways from a side.
|
|
44
|
-
const popoverSide = usePopoverSide();
|
|
45
|
-
|
|
46
41
|
// Written out in full, so that the stylesheet of a page that installs the canvas picks every class up.
|
|
47
42
|
const SQUARE_CLASSES = { toolbar: 'size-9', compact: 'size-8' } as const;
|
|
48
43
|
// The zoom level is a real button, so it shrinks a little while it is pressed like the zoom buttons beside it, through the design
|
|
49
|
-
// system's `press-feedback` (which keeps still for a person who asked for less motion).
|
|
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
|
+
// 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
|
+
// 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.
|
|
50
48
|
const LEVEL_CLASSES =
|
|
51
|
-
'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:
|
|
52
|
-
// The design system's Icon Button shows the keyboard focus by a tint of its background, and the brand tint of the tool that is on
|
|
53
|
-
// is a background too, that wins over it: the tool in use, which is where the keyboard begins, showed no focus at all (found with
|
|
54
|
-
// the accessibility check). It gets the ring that the zoom level and the Shapes button show, and only when the keyboard has the focus.
|
|
55
|
-
const ACTIVE_FOCUS_CLASSES = 'data-[active]:focus-visible:ring-2 data-[active]:focus-visible:ring-ring';
|
|
49
|
+
'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 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50';
|
|
56
50
|
</script>
|
|
57
51
|
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
{#
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</Tooltip.Trigger>
|
|
81
|
-
<Tooltip.Portal to={overlayPortal.to} disabled={overlayPortal.disabled}>
|
|
82
|
-
<Tooltip.Content side={popoverSide()} sideOffset={8} class="{CANVAS_OVERLAY_Z_CLASS} {OVERLAY_REDUCED_MOTION_CLASSES}">
|
|
83
|
-
<span class="flex items-center gap-2">
|
|
84
|
-
<span>{label}</span>
|
|
85
|
-
{#if shortcut}
|
|
86
|
-
<kbd class="rounded-sm bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{shortcut}</kbd>
|
|
87
|
-
{/if}
|
|
88
|
-
{#if alternateShortcut}
|
|
89
|
-
<kbd class="rounded-sm bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{alternateShortcut}</kbd>
|
|
90
|
-
{/if}
|
|
91
|
-
</span>
|
|
92
|
-
</Tooltip.Content>
|
|
93
|
-
</Tooltip.Portal>
|
|
94
|
-
</Tooltip.Root>
|
|
52
|
+
<ShortcutTooltip {label} {shortcut}>
|
|
53
|
+
{#snippet trigger(props)}
|
|
54
|
+
{#if size === 'level'}
|
|
55
|
+
<button {...props} type="button" aria-label={label} aria-keyshortcuts={keyShortcuts} {disabled} {onclick} class="{LEVEL_CLASSES} {className}">
|
|
56
|
+
{@render children()}
|
|
57
|
+
</button>
|
|
58
|
+
{:else}
|
|
59
|
+
<IconButton
|
|
60
|
+
{...props}
|
|
61
|
+
{label}
|
|
62
|
+
{disabled}
|
|
63
|
+
{onclick}
|
|
64
|
+
aria-pressed={toggle ? active : undefined}
|
|
65
|
+
aria-keyshortcuts={keyShortcuts}
|
|
66
|
+
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
|
+
>
|
|
69
|
+
{@render children()}
|
|
70
|
+
</IconButton>
|
|
71
|
+
{/if}
|
|
72
|
+
{/snippet}
|
|
73
|
+
</ShortcutTooltip>
|
|
@@ -4,7 +4,10 @@ interface Props {
|
|
|
4
4
|
label: string;
|
|
5
5
|
/** The key that does the same, as it is printed on a key cap ("V"), or nothing. It is also the button's `aria-keyshortcuts`. */
|
|
6
6
|
shortcut?: string | undefined;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A second key that does the same ("1", the number of the tool): a second entry of `aria-keyshortcuts`. The tooltip does not
|
|
9
|
+
* draw it (the letter is the one the person is shown); the key still works.
|
|
10
|
+
*/
|
|
8
11
|
alternateShortcut?: string | undefined;
|
|
9
12
|
/** The tool this button chooses is the one in use. */
|
|
10
13
|
active?: boolean;
|
|
@@ -5,8 +5,17 @@
|
|
|
5
5
|
* and the panel has to show it and to take what a person types. Plain functions, free of Svelte and of the DOM, so Node
|
|
6
6
|
* can test them.
|
|
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
|
/** The colours the panel offers first, one click each. The first two are the board's own ink and paper. */
|
|
9
|
-
export
|
|
18
|
+
export var COLOR_PRESETS = [
|
|
10
19
|
'#0F172A',
|
|
11
20
|
'#FFFFFF',
|
|
12
21
|
'#EF4444',
|
|
@@ -18,59 +27,61 @@ export const COLOR_PRESETS = [
|
|
|
18
27
|
'#EC4899',
|
|
19
28
|
'#6B7280'
|
|
20
29
|
];
|
|
21
|
-
|
|
30
|
+
var HEX_PATTERN = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
22
31
|
/** True for a colour that paints nothing: `transparent`, or a colour that is fully see-through. */
|
|
23
32
|
export function isNoColor(color) {
|
|
24
33
|
if (!color)
|
|
25
34
|
return true;
|
|
26
|
-
|
|
35
|
+
var text = color.trim().toLowerCase();
|
|
27
36
|
if (text === 'transparent' || text === 'none')
|
|
28
37
|
return true;
|
|
29
|
-
|
|
38
|
+
var rgba = text.match(/^rgba\(\s*[^,]+,\s*[^,]+,\s*[^,]+,\s*([\d.]+)\s*\)$/);
|
|
30
39
|
return rgba ? Number.parseFloat(rgba[1]) === 0 : false;
|
|
31
40
|
}
|
|
32
41
|
/** What a person typed (`f80`, `#FF8800`, `ff8800`) as `#RRGGBB`, or null when it is not a colour. */
|
|
33
42
|
export function parseHexInput(text) {
|
|
34
|
-
|
|
43
|
+
var match = text.trim().match(HEX_PATTERN);
|
|
35
44
|
if (!match)
|
|
36
45
|
return null;
|
|
37
|
-
|
|
38
|
-
return
|
|
46
|
+
var digits = match[1].length === 3 ? __spreadArray([], match[1], true).map(function (digit) { return digit + digit; }).join('') : match[1];
|
|
47
|
+
return "#".concat(digits.toUpperCase());
|
|
39
48
|
}
|
|
40
49
|
function toHexByte(value) {
|
|
41
50
|
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, '0');
|
|
42
51
|
}
|
|
43
52
|
function hslToHex(hue, saturation, lightness) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
var s = saturation / 100;
|
|
54
|
+
var l = lightness / 100;
|
|
55
|
+
var a = s * Math.min(l, 1 - l);
|
|
56
|
+
var channel = function (n) {
|
|
57
|
+
var k = (n + hue / 30) % 12;
|
|
49
58
|
return toHexByte(255 * (l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)));
|
|
50
59
|
};
|
|
51
|
-
return
|
|
60
|
+
return "#".concat(channel(0)).concat(channel(8)).concat(channel(4)).toUpperCase();
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
63
|
* A stored colour as `#RRGGBB`: a hex, an `rgb()` or `hsl()` an older canvas may hold, or the nearest the browser can
|
|
55
64
|
* say for a colour name. `fallback` is what is answered for a colour that cannot be read.
|
|
56
65
|
*/
|
|
57
|
-
export function colorToHex(color, fallback
|
|
66
|
+
export function colorToHex(color, fallback) {
|
|
67
|
+
var _a;
|
|
68
|
+
if (fallback === void 0) { fallback = '#000000'; }
|
|
58
69
|
if (!color)
|
|
59
70
|
return fallback;
|
|
60
|
-
|
|
71
|
+
var hex = parseHexInput(color);
|
|
61
72
|
if (hex)
|
|
62
73
|
return hex;
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
var text = color.trim();
|
|
75
|
+
var rgb = text.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
|
|
65
76
|
if (rgb)
|
|
66
|
-
return
|
|
67
|
-
|
|
77
|
+
return "#".concat(toHexByte(Number(rgb[1]))).concat(toHexByte(Number(rgb[2]))).concat(toHexByte(Number(rgb[3]))).toUpperCase();
|
|
78
|
+
var hsl = text.match(/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/i);
|
|
68
79
|
if (hsl)
|
|
69
80
|
return hslToHex(Number(hsl[1]), Number(hsl[2]), Number(hsl[3]));
|
|
70
|
-
return NAMED_COLORS[text.toLowerCase()]
|
|
81
|
+
return (_a = NAMED_COLORS[text.toLowerCase()]) !== null && _a !== void 0 ? _a : fallback;
|
|
71
82
|
}
|
|
72
83
|
/** The few colour names an older canvas may hold. A name that is not here reads as the fallback. */
|
|
73
|
-
|
|
84
|
+
var NAMED_COLORS = Object.freeze({
|
|
74
85
|
black: '#000000',
|
|
75
86
|
white: '#FFFFFF',
|
|
76
87
|
red: '#FF0000',
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** Names the colour picker fills in at runtime (`{s}`, `{v}`, `{hex}`), built without literals the word scan would read. */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var s = "{".concat('s', "}");
|
|
3
|
+
var v = "{".concat('v', "}");
|
|
4
|
+
var hex = "{".concat('hex', "}");
|
|
5
5
|
/** Words the design-system colour picker speaks; templates keep their placeholders for the picker to replace. */
|
|
6
6
|
export function colorPickerMessages(t) {
|
|
7
7
|
return {
|
|
8
8
|
area: t('canvas.colorPicker.area'),
|
|
9
|
-
areaValue: t('canvas.colorPicker.areaValue', { s, v }),
|
|
9
|
+
areaValue: t('canvas.colorPicker.areaValue', { s: s, v: v }),
|
|
10
10
|
hue: t('canvas.colorPicker.hue'),
|
|
11
11
|
hex: t('canvas.panel.hex'),
|
|
12
12
|
add: t('canvas.colorPicker.add'),
|
|
13
|
-
swatch: t('canvas.colorPicker.swatch', { hex })
|
|
13
|
+
swatch: t('canvas.colorPicker.swatch', { hex: hex })
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -34,15 +34,37 @@ 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
|
-
* The ring of a menu's button while its menu is open
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* The ring of a menu's button while its menu is open: 2 px of ring standing 2 px off the button, with the board's colour in the
|
|
38
|
+
* gap, as the design system draws its focus ring. Figma draws the open "Shapes" button that way (the ring makes it 59 x 44, the
|
|
39
|
+
* height of the toolbar). The keyboard focus has no ring on the buttons of the chrome: it takes the look of the hover, as it does
|
|
40
|
+
* on the design system's Icon Button (a ring stayed on the button the pointer had clicked as soon as a shortcut key was pressed).
|
|
40
41
|
*
|
|
41
42
|
* It is two plain shadows, not Tailwind's `ring-2 ring-offset-2`: the design system's global stylesheet zeroes
|
|
42
43
|
* `--tw-ring-offset-width` with `!important` on every element that has `aria-expanded` (a menu's button always has), so the
|
|
43
44
|
* offset of a ring on such a button is lost, whatever class asks for it.
|
|
44
45
|
*/
|
|
45
|
-
export declare const MENU_TRIGGER_RING_CLASSES = "
|
|
46
|
+
export declare const MENU_TRIGGER_RING_CLASSES = "data-[state=open]:shadow-[0_0_0_2px_var(--color-background),0_0_0_4px_var(--color-ring)]";
|
|
47
|
+
/**
|
|
48
|
+
* 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
|
+
* 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
|
|
50
|
+
* design system's own rule for its buttons. A button that is on has no look of the hover to take (the tint is already there), and
|
|
51
|
+
* with nothing at all the person who works by keyboard could not see where the focus is (the accessibility check of the browser
|
|
52
|
+
* scripts reads exactly that).
|
|
53
|
+
*
|
|
54
|
+
* The `data-[active]` and `focus-visible` variants are stacked so that this beats both `data-[active]:bg-brand-subtle` and the
|
|
55
|
+
* design system's `focus-visible:bg-accent`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES = "data-[active]:focus-visible:bg-brand/40";
|
|
58
|
+
/**
|
|
59
|
+
* How long the pointer rests on a button of the chrome before its tooltip (the name and the key) opens, in milliseconds. The
|
|
60
|
+
* tooltips were quicker and opened on the way across the toolbar; this is the delay of the design system's own tooltips.
|
|
61
|
+
*/
|
|
62
|
+
export declare const CANVAS_TOOLTIP_DELAY_MS = 700;
|
|
63
|
+
/**
|
|
64
|
+
* After one tooltip has closed, the time within which the next button the pointer rests on opens its tooltip at once, so that
|
|
65
|
+
* moving along the toolbar to the next tool reads as one hover.
|
|
66
|
+
*/
|
|
67
|
+
export declare const CANVAS_TOOLTIP_SKIP_DELAY_MS = 200;
|
|
46
68
|
/**
|
|
47
69
|
* Tabler toolbar icons are 16 px (`size-4`) with stroke 2 in a 24 px viewBox: 2 × 16 / 24 = 1.333 px on screen.
|
|
48
70
|
* 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
|
|
@@ -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 var 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 var MENU_PADDING_CLASS = 'p-[3px]';
|
|
23
23
|
/** Figma "Layer Menu" (519:*): 4 px inset, 220 × 136 with 32 px rows. */
|
|
24
|
-
export
|
|
24
|
+
export var 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,35 +30,57 @@ export const 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 var 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 var CANVAS_OVERLAY_Z_CLASS = 'z-40';
|
|
36
36
|
/**
|
|
37
|
-
* The ring of a menu's button while its menu is open
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* The ring of a menu's button while its menu is open: 2 px of ring standing 2 px off the button, with the board's colour in the
|
|
38
|
+
* gap, as the design system draws its focus ring. Figma draws the open "Shapes" button that way (the ring makes it 59 x 44, the
|
|
39
|
+
* height of the toolbar). The keyboard focus has no ring on the buttons of the chrome: it takes the look of the hover, as it does
|
|
40
|
+
* on the design system's Icon Button (a ring stayed on the button the pointer had clicked as soon as a shortcut key was pressed).
|
|
40
41
|
*
|
|
41
42
|
* It is two plain shadows, not Tailwind's `ring-2 ring-offset-2`: the design system's global stylesheet zeroes
|
|
42
43
|
* `--tw-ring-offset-width` with `!important` on every element that has `aria-expanded` (a menu's button always has), so the
|
|
43
44
|
* offset of a ring on such a button is lost, whatever class asks for it.
|
|
44
45
|
*/
|
|
45
|
-
export
|
|
46
|
+
export var MENU_TRIGGER_RING_CLASSES = 'data-[state=open]:shadow-[0_0_0_2px_var(--color-background),0_0_0_4px_var(--color-ring)]';
|
|
47
|
+
/**
|
|
48
|
+
* 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
|
+
* 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
|
|
50
|
+
* design system's own rule for its buttons. A button that is on has no look of the hover to take (the tint is already there), and
|
|
51
|
+
* with nothing at all the person who works by keyboard could not see where the focus is (the accessibility check of the browser
|
|
52
|
+
* scripts reads exactly that).
|
|
53
|
+
*
|
|
54
|
+
* The `data-[active]` and `focus-visible` variants are stacked so that this beats both `data-[active]:bg-brand-subtle` and the
|
|
55
|
+
* design system's `focus-visible:bg-accent`.
|
|
56
|
+
*/
|
|
57
|
+
export var TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES = 'data-[active]:focus-visible:bg-brand/40';
|
|
58
|
+
/**
|
|
59
|
+
* How long the pointer rests on a button of the chrome before its tooltip (the name and the key) opens, in milliseconds. The
|
|
60
|
+
* tooltips were quicker and opened on the way across the toolbar; this is the delay of the design system's own tooltips.
|
|
61
|
+
*/
|
|
62
|
+
export var CANVAS_TOOLTIP_DELAY_MS = 700;
|
|
63
|
+
/**
|
|
64
|
+
* After one tooltip has closed, the time within which the next button the pointer rests on opens its tooltip at once, so that
|
|
65
|
+
* moving along the toolbar to the next tool reads as one hover.
|
|
66
|
+
*/
|
|
67
|
+
export var CANVAS_TOOLTIP_SKIP_DELAY_MS = 200;
|
|
46
68
|
/**
|
|
47
69
|
* Tabler toolbar icons are 16 px (`size-4`) with stroke 2 in a 24 px viewBox: 2 × 16 / 24 = 1.333 px on screen.
|
|
48
70
|
* 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
|
|
49
71
|
* look as thick. The design system's menu item forces `size-4` and `stroke-2` on every svg inside it through CSS, which beats
|
|
50
72
|
* the `stroke-width` attribute (the glyphs were 0.32 px thick), so the width is set inline on the glyph.
|
|
51
73
|
*/
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
74
|
+
export var TOOLBAR_ICON_STROKE_CLASSES = '[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:stroke-2';
|
|
75
|
+
export var TOOLBAR_ICON_SIZE_PX = 16;
|
|
76
|
+
export var TOOLBAR_ICON_VIEWBOX = 24;
|
|
77
|
+
export var TOOLBAR_ICON_STROKE_UNITS = 2;
|
|
78
|
+
export var TOOLBAR_ICON_STROKE_PX = (TOOLBAR_ICON_STROKE_UNITS * TOOLBAR_ICON_SIZE_PX) / TOOLBAR_ICON_VIEWBOX;
|
|
79
|
+
export var SHAPE_LIBRARY_ICON_SIZE_PX = TOOLBAR_ICON_SIZE_PX;
|
|
80
|
+
export var SHAPE_LIBRARY_VIEWBOX = 100;
|
|
81
|
+
export var SHAPE_LIBRARY_STROKE_WIDTH = (TOOLBAR_ICON_STROKE_PX * SHAPE_LIBRARY_VIEWBOX) / SHAPE_LIBRARY_ICON_SIZE_PX;
|
|
60
82
|
/** Figma's measures of the cards, in px (a Figma frame counts an inside stroke as part of the card). */
|
|
61
|
-
export
|
|
83
|
+
export var FLOATING_CARD_METRICS = {
|
|
62
84
|
/** The whole toolbar: five tools, the Shapes menu and the history group, with their dividers. */
|
|
63
85
|
toolbarWidth: 349,
|
|
64
86
|
toolbarHeight: 44,
|
|
@@ -76,7 +98,7 @@ export const FLOATING_CARD_METRICS = {
|
|
|
76
98
|
* 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
|
|
77
99
|
* picks it up.
|
|
78
100
|
*/
|
|
79
|
-
export
|
|
101
|
+
export var TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @[384px]:flex';
|
|
80
102
|
/**
|
|
81
103
|
* The width of board from which the zoom card is drawn, by the way it stands beside the toolbar (see `chromeLayout.ts`, which
|
|
82
104
|
* 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
|
|
@@ -92,7 +114,7 @@ export const TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @[384px]:flex';
|
|
|
92
114
|
* - `centredBesideCornerToolbar`: the toolbar at a corner and the zoom card centred: the card's left edge has to clear the
|
|
93
115
|
* toolbar's right edge, which is 365 px from the board's left edge.
|
|
94
116
|
*/
|
|
95
|
-
export
|
|
117
|
+
export var ZOOM_CONTROL_MIN_WIDTHS = {
|
|
96
118
|
alone: 512,
|
|
97
119
|
sameSlot: 560,
|
|
98
120
|
oppositeCorners: 560,
|
|
@@ -100,7 +122,7 @@ export const ZOOM_CONTROL_MIN_WIDTHS = {
|
|
|
100
122
|
centredBesideCornerToolbar: 912
|
|
101
123
|
};
|
|
102
124
|
/** 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. */
|
|
103
|
-
export
|
|
125
|
+
export var ZOOM_CONTROL_VISIBLE_FROM = {
|
|
104
126
|
alone: 'hidden @lg:flex',
|
|
105
127
|
sameSlot: 'hidden @[560px]:flex',
|
|
106
128
|
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
|
+
var 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 var 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,10 +27,11 @@ 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
|
-
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = getContext(FLOATING_LAYER_CONTEXT_KEY)) !== null && _a !== void 0 ? _a : readable(undefined);
|
|
31
32
|
}
|
|
32
33
|
/** Below design-system dialogs, dropdowns and toasts (`z-50`); still above normal page content so a compact card does not cover menus. */
|
|
33
|
-
export
|
|
34
|
+
export var CANVAS_OVERLAY_PORTAL_Z_CLASS = 'z-40';
|
|
34
35
|
/**
|
|
35
36
|
* Portal target for a menu, popover or tooltip: `document.body` in the light DOM, else the in-canvas floating layer.
|
|
36
37
|
* Floating UI still measures from the trigger; only the mount node changes.
|
|
@@ -50,7 +51,7 @@ export function canvasOverlayPortalProps(floatingLayer) {
|
|
|
50
51
|
? { to: document.body, class: CANVAS_OVERLAY_PORTAL_Z_CLASS }
|
|
51
52
|
: { class: CANVAS_OVERLAY_PORTAL_Z_CLASS };
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
var root = floatingLayer.getRootNode();
|
|
54
55
|
if (typeof Document !== 'undefined' && root instanceof Document) {
|
|
55
56
|
return { to: document.body, class: CANVAS_OVERLAY_PORTAL_Z_CLASS };
|
|
56
57
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* of what the chrome uses is visible at a glance and no component reaches for an icon library of its own.
|
|
4
4
|
*/
|
|
5
5
|
import type { IconSquare as SquareIcon } from '@widgetic/design-system/icons';
|
|
6
|
-
export { IconAlertTriangle, IconAlignCenter, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowBarToDown, IconArrowBarToUp, IconArrowForwardUp, IconArrowsMaximize, IconArrowUpRight, IconBold, IconBrowser, IconCamera, IconCategory, IconCheck, IconChevronDown, IconCircle, IconClipboard, IconCopy, IconDeviceFloppy, IconDiamond, IconEraser, IconHexagon, IconItalic, IconLink, IconLoader2, IconPencil, IconPentagon, IconPhoto, IconPointer, IconRefresh, IconReplace, IconScissors, IconSelectAll, IconSettings, IconSquare, IconSquareRounded, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconStar, IconTrash, IconTriangle, IconTypography, IconUnderline, IconX, IconZoomIn, IconZoomOut } from '@widgetic/design-system/icons';
|
|
6
|
+
export { IconAlertTriangle, IconAlignCenter, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowBarToDown, IconArrowBarToUp, IconArrowForwardUp, IconArrowsMaximize, IconArrowUpRight, IconBold, IconBrowser, IconCamera, IconCategory, IconCheck, IconChevronDown, IconCircle, IconClipboard, IconCopy, IconDeviceFloppy, IconDiamond, IconEraser, IconFolder, IconHexagon, IconItalic, IconLink, IconLoader2, IconPencil, IconPentagon, IconPhoto, IconPointer, IconRefresh, IconReplace, IconScissors, IconSelectAll, IconSettings, IconSquare, IconSquareRounded, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconStar, IconTrash, IconTriangle, IconTypography, IconUnderline, IconX, IconZoomIn, IconZoomOut } from '@widgetic/design-system/icons';
|
|
7
7
|
export { SquareDashedMousePointer as IconSelectElement } from '@widgetic/design-system/icons';
|
|
8
8
|
/**
|
|
9
9
|
* What a Tabler icon is: a component class that every icon of the set shares the shape of. A row of a menu keeps its icon
|
package/dist/canvas/ui/icons.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Every icon the canvas draws, imported from the Widgetic design system's own set (Tabler) in this one place, so the list
|
|
3
3
|
* of what the chrome uses is visible at a glance and no component reaches for an icon library of its own.
|
|
4
4
|
*/
|
|
5
|
-
export { IconAlertTriangle, IconAlignCenter, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowBarToDown, IconArrowBarToUp, IconArrowForwardUp, IconArrowsMaximize, IconArrowUpRight, IconBold, IconBrowser, IconCamera, IconCategory, IconCheck, IconChevronDown, IconCircle, IconClipboard, IconCopy, IconDeviceFloppy, IconDiamond, IconEraser, IconHexagon, IconItalic, IconLink, IconLoader2, IconPencil, IconPentagon, IconPhoto, IconPointer, IconRefresh, IconReplace, IconScissors, IconSelectAll, IconSettings, IconSquare, IconSquareRounded, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconStar, IconTrash, IconTriangle, IconTypography, IconUnderline, IconX, IconZoomIn, IconZoomOut } from '@widgetic/design-system/icons';
|
|
5
|
+
export { IconAlertTriangle, IconAlignCenter, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowBarToDown, IconArrowBarToUp, IconArrowForwardUp, IconArrowsMaximize, IconArrowUpRight, IconBold, IconBrowser, IconCamera, IconCategory, IconCheck, IconChevronDown, IconCircle, IconClipboard, IconCopy, IconDeviceFloppy, IconDiamond, IconEraser, IconFolder, IconHexagon, IconItalic, IconLink, IconLoader2, IconPencil, IconPentagon, IconPhoto, IconPointer, IconRefresh, IconReplace, IconScissors, IconSelectAll, IconSettings, IconSquare, IconSquareRounded, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconStar, IconTrash, IconTriangle, IconTypography, IconUnderline, IconX, IconZoomIn, IconZoomOut } from '@widgetic/design-system/icons';
|
|
6
6
|
// The element selector's own icon exists only in the Lucide set of the design system's barrel.
|
|
7
7
|
export { SquareDashedMousePointer as IconSelectElement } from '@widgetic/design-system/icons';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** The platform name of a browser, from the newer API when there is one. */
|
|
2
2
|
function platformName(nav) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var _a, _b, _c;
|
|
4
|
+
var withData = nav;
|
|
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 : '';
|
|
5
6
|
}
|
|
6
7
|
/** True on a Mac, an iPhone or an iPad, where the shortcut key is Command and the menus print it as a symbol. */
|
|
7
|
-
export function isApplePlatform(nav
|
|
8
|
+
export function isApplePlatform(nav) {
|
|
9
|
+
if (nav === void 0) { nav = typeof navigator === 'undefined' ? undefined : navigator; }
|
|
8
10
|
if (!nav)
|
|
9
11
|
return false;
|
|
10
12
|
return /mac|iphone|ipad|ipod/i.test(platformName(nav));
|
|
@@ -17,7 +19,7 @@ export function isApplePlatform(nav = typeof navigator === 'undefined' ? undefin
|
|
|
17
19
|
export function ariaKeyShortcut(chord, apple) {
|
|
18
20
|
if (typeof chord.key !== 'string')
|
|
19
21
|
return undefined;
|
|
20
|
-
|
|
22
|
+
var parts = [];
|
|
21
23
|
if (chord.mod)
|
|
22
24
|
parts.push(apple ? 'Meta' : 'Control');
|
|
23
25
|
if (chord.shift)
|
|
@@ -30,10 +32,10 @@ export function ariaKeyShortcut(chord, apple) {
|
|
|
30
32
|
* the same in every language; the words of the others come from the page's language.
|
|
31
33
|
*/
|
|
32
34
|
export function chordText(chord, apple, t) {
|
|
33
|
-
|
|
35
|
+
var key = typeof chord.key === 'string' ? chord.key : t(chord.key.name);
|
|
34
36
|
if (apple)
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
+
return "".concat(chord.shift ? '⇧' : '').concat(chord.mod ? '⌘' : '').concat(key);
|
|
38
|
+
var parts = [];
|
|
37
39
|
if (chord.mod)
|
|
38
40
|
parts.push(t('canvas.key.ctrl'));
|
|
39
41
|
if (chord.shift)
|
|
@@ -46,8 +48,8 @@ export function chordText(chord, apple, t) {
|
|
|
46
48
|
* elsewhere. The toolbar and zoom control keep `chordText` (symbols on Apple).
|
|
47
49
|
*/
|
|
48
50
|
export function menuChordText(chord, apple, t) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
var key = typeof chord.key === 'string' ? chord.key : t(chord.key.name);
|
|
52
|
+
var parts = [];
|
|
51
53
|
if (chord.shift)
|
|
52
54
|
parts.push(t('canvas.key.shift'));
|
|
53
55
|
if (chord.mod)
|
|
@@ -9,12 +9,13 @@
|
|
|
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
|
+
var 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
|
-
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = getContext(POPOVER_SIDE_CONTEXT_KEY)) !== null && _a !== void 0 ? _a : (function () { return 'top'; });
|
|
20
21
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Scene } from '../../engine/core/scene.js';
|
|
9
9
|
import type { ObjectId, SceneObject, ShapeObject, TextAlign, WidgetObject } from '../../engine/core/types.js';
|
|
10
|
+
import type { PenStyle } from '../../engine/state.js';
|
|
10
11
|
/** A value the selected shapes share, differ in, or do not have at all. */
|
|
11
12
|
export type Trait<T> = {
|
|
12
13
|
kind: 'none';
|
|
@@ -47,8 +48,19 @@ export interface SelectionTraits {
|
|
|
47
48
|
}
|
|
48
49
|
/** Describes the selection for the panel. */
|
|
49
50
|
export declare function describeSelection(scene: Scene, selectedIds: readonly ObjectId[]): SelectionTraits;
|
|
51
|
+
/**
|
|
52
|
+
* 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
|
|
53
|
+
* 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
|
|
54
|
+
* 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.
|
|
55
|
+
*/
|
|
56
|
+
export declare function describePenStyle(pen: PenStyle): SelectionTraits;
|
|
50
57
|
/** The number of a trait for a control, or a fallback when the shapes differ or the control does not apply. */
|
|
51
58
|
export declare function traitNumber(trait: Trait<number>, fallback: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* The least the Width control offers for the selection. One number is written to every shape, so it is the highest minimum among
|
|
61
|
+
* 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.
|
|
62
|
+
*/
|
|
63
|
+
export declare function minimumStrokeWidth(traits: SelectionTraits): number;
|
|
52
64
|
/** What the font size stepper shows: a whole number, never a long float from resizing. */
|
|
53
65
|
export declare function formatFontSizeDisplay(trait: Trait<number>): number | '–';
|
|
54
66
|
/**
|