@widgetic/canvas 0.5.38 → 0.5.40
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 +5 -0
- package/dist/canvas/DomCanvas.svelte +29 -8
- package/dist/canvas/DomCanvas.svelte.d.ts +5 -0
- package/dist/canvas/autosaveScheduler.d.ts +10 -2
- package/dist/canvas/autosaveScheduler.js +31 -5
- package/dist/canvas/boardSurface.d.ts +5 -1
- package/dist/canvas/boardSurface.js +5 -1
- package/dist/canvas/chromeLayout.d.ts +2 -0
- package/dist/canvas/chromeLayout.js +17 -2
- package/dist/canvas/host/CanvasHost.d.ts +32 -1
- package/dist/canvas/host/CanvasHost.js +138 -12
- package/dist/canvas/outsideClickDeselect.d.ts +5 -0
- package/dist/canvas/outsideClickDeselect.js +25 -0
- package/dist/canvas/preferredTextFont.d.ts +7 -1
- package/dist/canvas/preferredTextFont.js +26 -2
- package/dist/canvas/ui/CanvasContextMenu.svelte +69 -39
- package/dist/canvas/ui/CanvasHint.svelte +4 -4
- package/dist/canvas/ui/CanvasToolbar.svelte +21 -3
- package/dist/canvas/ui/ColorField.svelte +2 -1
- package/dist/canvas/ui/SelectionPanel.svelte +82 -43
- package/dist/canvas/ui/SelectorBar.svelte +5 -3
- package/dist/canvas/ui/ShapesMenu.svelte +0 -2
- package/dist/canvas/ui/WidgetActions.svelte +1 -1
- package/dist/canvas/ui/ZoomControl.svelte +39 -4
- package/dist/canvas/ui/ZoomControl.svelte.d.ts +2 -2
- package/dist/canvas/ui/floatingCard.d.ts +7 -5
- package/dist/canvas/ui/floatingCard.js +7 -5
- package/dist/canvas/ui/keyHints.d.ts +5 -0
- package/dist/canvas/ui/keyHints.js +14 -0
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +16 -0
- package/dist/canvas/ui/sizeLabelVisibility.js +16 -0
- package/dist/canvas/ui/widgetSelectionPanel.d.ts +6 -0
- package/dist/canvas/ui/widgetSelectionPanel.js +9 -0
- package/dist/canvas/view/ObjectView.svelte +2 -1
- package/dist/canvas/view/SelectionOverlay.svelte +12 -1
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +1 -1
- package/dist/engine/EngineCore.d.ts +19 -2
- package/dist/engine/EngineCore.js +51 -7
- package/dist/engine/core/defaults.d.ts +1 -1
- package/dist/engine/core/defaults.js +1 -1
- package/dist/engine/core/shapeTools.d.ts +16 -6
- package/dist/engine/core/shapeTools.js +8 -6
- package/dist/engine/input/gestures.js +3 -2
- package/dist/engine/text/layoutText.d.ts +1 -2
- package/dist/engine/text/layoutText.js +2 -4
- package/dist/engine/text/textMetrics.d.ts +19 -0
- package/dist/engine/text/textMetrics.js +24 -0
- package/dist/fonts/interFont.d.ts +5 -0
- package/dist/fonts/interFont.js +31 -0
- package/dist/fonts/workspaceFonts.d.ts +12 -0
- package/dist/fonts/workspaceFonts.js +51 -0
- package/dist/i18n/labels.js +2 -1
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +9 -6
- package/dist/i18n/messages.js +9 -6
- package/dist/settings/workspaceToolSettings.d.ts +45 -0
- package/dist/settings/workspaceToolSettings.js +90 -0
- package/package.json +3 -3
|
@@ -66,6 +66,8 @@ export class EngineCore {
|
|
|
66
66
|
#textSession = null;
|
|
67
67
|
/** The last font family chosen in the panel; new text objects start with this instead of the catalog default. */
|
|
68
68
|
#preferredTextFontFamily = null;
|
|
69
|
+
#workspaceTextDefaults = null;
|
|
70
|
+
#workspacePaintDefaults = null;
|
|
69
71
|
// The eraser's trail while it lives; what the views draw of it is `state.scribble`.
|
|
70
72
|
#scribble = null;
|
|
71
73
|
#indexes = new WeakMap();
|
|
@@ -240,11 +242,25 @@ export class EngineCore {
|
|
|
240
242
|
setLoading(loading) {
|
|
241
243
|
this.#set({ loading });
|
|
242
244
|
}
|
|
243
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Tells the engine how big the board element is. With `keepCentre` the view stays on the same point of the world: when
|
|
247
|
+
* the board grows or shrinks, the pan moves by half of the change, so what was in the middle stays in the middle (a board
|
|
248
|
+
* that its page resizes by dragging its edges). The first measure (from 0 by 0) never moves the pan, whatever `keepCentre` says.
|
|
249
|
+
*/
|
|
250
|
+
setViewSize(size, keepCentre = false) {
|
|
244
251
|
const current = this.#state.viewSize;
|
|
245
252
|
if (current.width === size.width && current.height === size.height)
|
|
246
253
|
return;
|
|
247
|
-
|
|
254
|
+
const patch = { viewSize: { width: size.width, height: size.height } };
|
|
255
|
+
if (keepCentre && current.width > 0 && current.height > 0 && size.width > 0 && size.height > 0) {
|
|
256
|
+
const viewport = this.#state.viewport;
|
|
257
|
+
patch.viewport = {
|
|
258
|
+
...viewport,
|
|
259
|
+
x: viewport.x + (size.width - current.width) / 2,
|
|
260
|
+
y: viewport.y + (size.height - current.height) / 2
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
this.#set(patch);
|
|
248
264
|
}
|
|
249
265
|
// ──────────────────────────────────────────────────────── scene changes
|
|
250
266
|
/**
|
|
@@ -672,6 +688,26 @@ export class EngineCore {
|
|
|
672
688
|
setPreferredTextFontFamily(fontFamily) {
|
|
673
689
|
this.#preferredTextFontFamily = fontFamily;
|
|
674
690
|
}
|
|
691
|
+
setWorkspaceToolDefaults(settings) {
|
|
692
|
+
this.#workspaceTextDefaults = settings.text ?? null;
|
|
693
|
+
this.#workspacePaintDefaults = settings.paint ?? null;
|
|
694
|
+
if (settings.text?.fontFamily)
|
|
695
|
+
this.#preferredTextFontFamily = settings.text.fontFamily;
|
|
696
|
+
}
|
|
697
|
+
workspacePaintForNewShape(wireframe) {
|
|
698
|
+
if (!this.#workspacePaintDefaults)
|
|
699
|
+
return {};
|
|
700
|
+
if (wireframe) {
|
|
701
|
+
const { stroke, strokeWidth, strokeStyle, opacity } = this.#workspacePaintDefaults;
|
|
702
|
+
return {
|
|
703
|
+
...(stroke !== undefined ? { stroke } : {}),
|
|
704
|
+
...(strokeWidth !== undefined ? { strokeWidth } : {}),
|
|
705
|
+
...(strokeStyle !== undefined ? { strokeStyle } : {}),
|
|
706
|
+
...(opacity !== undefined ? { opacity } : {})
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
return { ...this.#workspacePaintDefaults };
|
|
710
|
+
}
|
|
675
711
|
/**
|
|
676
712
|
* Makes a text object, puts it on the board and starts editing it. A click makes a label whose width follows its
|
|
677
713
|
* text; a width makes a box whose lines wrap. Nothing is recorded until the editing ends with text in it.
|
|
@@ -685,12 +721,13 @@ export class EngineCore {
|
|
|
685
721
|
y: point.y,
|
|
686
722
|
width: fixedWidth ? options.width : TEXT_DEFAULTS.minimumWidth,
|
|
687
723
|
autoWidth: !fixedWidth,
|
|
688
|
-
fontFamily: this.#preferredTextFontFamily ?? TEXT_DEFAULTS.fontFamily
|
|
724
|
+
fontFamily: this.#preferredTextFontFamily ?? this.#workspaceTextDefaults?.fontFamily ?? TEXT_DEFAULTS.fontFamily,
|
|
725
|
+
...this.#workspaceTextDefaults
|
|
689
726
|
});
|
|
690
727
|
const text = this.#fitText(base);
|
|
691
728
|
const sceneBefore = this.#state.scene;
|
|
692
729
|
this.applyScene([...sceneBefore, text], 'transient');
|
|
693
|
-
this.#textSession = { id: text.id, isNew: true, sceneBefore };
|
|
730
|
+
this.#textSession = { id: text.id, isNew: true, sceneBefore, typed: false };
|
|
694
731
|
this.#set({ editingTextId: text.id, selectedIds: [text.id], enteredGroupId: null });
|
|
695
732
|
return text.id;
|
|
696
733
|
}
|
|
@@ -702,7 +739,7 @@ export class EngineCore {
|
|
|
702
739
|
if (this.#textSession?.id === id)
|
|
703
740
|
return true;
|
|
704
741
|
this.endTextEdit();
|
|
705
|
-
this.#textSession = { id, isNew: false, sceneBefore: this.#state.scene };
|
|
742
|
+
this.#textSession = { id, isNew: false, sceneBefore: this.#state.scene, typed: false };
|
|
706
743
|
this.#set({ editingTextId: id, selectedIds: [id] });
|
|
707
744
|
return true;
|
|
708
745
|
}
|
|
@@ -717,8 +754,12 @@ export class EngineCore {
|
|
|
717
754
|
? fitTextObject({ ...object, text: clipped }, this.services.measureText)
|
|
718
755
|
: object);
|
|
719
756
|
const changed = next.some((object, position) => object !== scene[position]);
|
|
720
|
-
if (changed)
|
|
721
|
-
|
|
757
|
+
if (!changed)
|
|
758
|
+
return;
|
|
759
|
+
this.applyScene(next, 'transient');
|
|
760
|
+
session.typed = true;
|
|
761
|
+
// The board is not recorded until the typing ends, but the letters are on it: the host's next save takes them.
|
|
762
|
+
this.#callHook(() => this.hooks.onDraftChange?.(), 'draft change hook');
|
|
722
763
|
}
|
|
723
764
|
/**
|
|
724
765
|
* Finishes the edit. An empty text is removed (a new one leaves nothing behind, not even an undo step);
|
|
@@ -737,6 +778,9 @@ export class EngineCore {
|
|
|
737
778
|
if (session.isNew) {
|
|
738
779
|
this.applyScene(session.sceneBefore, 'transient');
|
|
739
780
|
this.#set({ selectedIds: [] });
|
|
781
|
+
// A save may have taken the letters that were typed before they were all deleted: it has to be told they are gone.
|
|
782
|
+
if (session.typed)
|
|
783
|
+
this.#callHook(() => this.hooks.onDraftChange?.(), 'draft change hook');
|
|
740
784
|
}
|
|
741
785
|
else {
|
|
742
786
|
this.applyScene(removeFromScene(this.#state.scene, [session.id]), 'push');
|
|
@@ -18,7 +18,7 @@ export declare const SHAPE_STYLE_DEFAULTS: {
|
|
|
18
18
|
};
|
|
19
19
|
export declare const TEXT_DEFAULTS: {
|
|
20
20
|
readonly fontSize: 20;
|
|
21
|
-
readonly fontFamily: "
|
|
21
|
+
readonly fontFamily: "Inter";
|
|
22
22
|
readonly color: "#111827";
|
|
23
23
|
/** The colour of the "Type something" prompt shown in an empty text box. */
|
|
24
24
|
readonly placeholderColor: "#9ca3af";
|
|
@@ -17,7 +17,7 @@ export const SHAPE_STYLE_DEFAULTS = {
|
|
|
17
17
|
};
|
|
18
18
|
export const TEXT_DEFAULTS = {
|
|
19
19
|
fontSize: 20,
|
|
20
|
-
fontFamily: '
|
|
20
|
+
fontFamily: 'Inter',
|
|
21
21
|
color: '#111827',
|
|
22
22
|
/** The colour of the "Type something" prompt shown in an empty text box. */
|
|
23
23
|
placeholderColor: '#9ca3af',
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* once more on release for the shape that is kept.
|
|
5
5
|
*/
|
|
6
6
|
import type { EllipseObject, ObjectId, PathObject, Point, Rect, RectObject } from './types.js';
|
|
7
|
+
type WorkspaceShapePaint = Partial<Pick<RectObject, 'fill' | 'stroke' | 'strokeWidth' | 'strokeStyle' | 'opacity' | 'roundness'>>;
|
|
7
8
|
/** A drag shorter than this (in screen pixels) is a click: the shape is placed at its default size. */
|
|
8
9
|
export declare const MIN_DRAW_DISTANCE = 4;
|
|
9
10
|
/** The size of a library shape placed by a click. */
|
|
@@ -39,16 +40,24 @@ export interface ShapeDraftOptions {
|
|
|
39
40
|
wireframe: boolean;
|
|
40
41
|
createId?: (prefix: string) => ObjectId;
|
|
41
42
|
random?: () => number;
|
|
43
|
+
/** Remembered workspace paint for new shapes (B16). */
|
|
44
|
+
workspacePaint?: WorkspaceShapePaint;
|
|
42
45
|
}
|
|
43
46
|
/** The paint of a new shape of the tools, by the look the board is in. */
|
|
44
|
-
export declare function newShapePaint(wireframe: boolean, random?: () => number): {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
export declare function newShapePaint(wireframe: boolean, random?: () => number, workspacePaint?: WorkspaceShapePaint): {
|
|
48
|
+
roundness?: number | undefined;
|
|
49
|
+
opacity?: number | undefined;
|
|
50
|
+
fill: string;
|
|
51
|
+
stroke: string;
|
|
52
|
+
strokeWidth: number;
|
|
53
|
+
strokeStyle?: import("./types.js").StrokeStyle | undefined;
|
|
48
54
|
} | {
|
|
55
|
+
roundness?: number | undefined;
|
|
56
|
+
opacity?: number | undefined;
|
|
49
57
|
fill: string;
|
|
50
|
-
stroke:
|
|
51
|
-
strokeWidth:
|
|
58
|
+
stroke: string;
|
|
59
|
+
strokeWidth: number;
|
|
60
|
+
strokeStyle?: import("./types.js").StrokeStyle | undefined;
|
|
52
61
|
};
|
|
53
62
|
/** The look of a library shape, and of an arrow. */
|
|
54
63
|
export declare const LIBRARY_SHAPE_PAINT: {
|
|
@@ -78,3 +87,4 @@ export declare function buildLibraryShape(fields: {
|
|
|
78
87
|
height: number;
|
|
79
88
|
key: string | null;
|
|
80
89
|
}): RectObject | PathObject;
|
|
90
|
+
export {};
|
|
@@ -43,14 +43,15 @@ function centeredBox(center, width, height) {
|
|
|
43
43
|
return { x: center.x - width / 2, y: center.y - height / 2, width, height };
|
|
44
44
|
}
|
|
45
45
|
/** The paint of a new shape of the tools, by the look the board is in. */
|
|
46
|
-
export function newShapePaint(wireframe, random = Math.random) {
|
|
47
|
-
|
|
46
|
+
export function newShapePaint(wireframe, random = Math.random, workspacePaint = {}) {
|
|
47
|
+
const base = wireframe
|
|
48
48
|
? {
|
|
49
49
|
fill: SHAPE_STYLE_DEFAULTS.wireframeFill,
|
|
50
50
|
stroke: SHAPE_STYLE_DEFAULTS.wireframeStroke,
|
|
51
51
|
strokeWidth: SHAPE_STYLE_DEFAULTS.wireframeStrokeWidth
|
|
52
52
|
}
|
|
53
53
|
: { fill: randomShapeFill(random), stroke: SHAPE_STYLE_DEFAULTS.stroke, strokeWidth: SHAPE_STYLE_DEFAULTS.strokeWidth };
|
|
54
|
+
return { ...base, ...workspacePaint };
|
|
54
55
|
}
|
|
55
56
|
/** The look of a library shape, and of an arrow. */
|
|
56
57
|
export const LIBRARY_SHAPE_PAINT = { fill: '#ffffff', stroke: '#374151', strokeWidth: 3 };
|
|
@@ -119,19 +120,20 @@ export function buildDraggedShape(options) {
|
|
|
119
120
|
const width = Math.max(box.width, MIN_OBJECT_SIZE);
|
|
120
121
|
const height = Math.max(box.height, MIN_OBJECT_SIZE);
|
|
121
122
|
const frame = { id, x: box.x, y: box.y, width, height };
|
|
123
|
+
const paint = newShapePaint(wireframe, options.random, options.workspacePaint);
|
|
122
124
|
if (kind === 'rect')
|
|
123
|
-
return createRectObject({ ...frame, ...
|
|
125
|
+
return createRectObject({ ...frame, ...paint });
|
|
124
126
|
// The rounded square of the shapes menu: a rectangle that starts with soft corners (its Roundness control still moves them).
|
|
125
127
|
if (kind === 'rounded-rect') {
|
|
126
|
-
return createRectObject({ ...frame, ...
|
|
128
|
+
return createRectObject({ ...frame, ...paint, roundness: ROUNDED_RECT_ROUNDNESS });
|
|
127
129
|
}
|
|
128
130
|
if (kind === 'ellipse' || kind === 'circle') {
|
|
129
|
-
return createEllipseObject({ ...frame, ...
|
|
131
|
+
return createEllipseObject({ ...frame, ...paint, aspectLocked: kind === 'circle' });
|
|
130
132
|
}
|
|
131
133
|
if (kind === 'triangle') {
|
|
132
134
|
return createPathObject({
|
|
133
135
|
...frame,
|
|
134
|
-
...
|
|
136
|
+
...paint,
|
|
135
137
|
d: serializePathData(trianglePathCommands(width, height, 0)),
|
|
136
138
|
shape: TRIANGLE_SHAPE_KEY,
|
|
137
139
|
lineJoin: 'miter'
|
|
@@ -134,7 +134,7 @@ export function createMoveGesture(context, start, unitIds, options = {}) {
|
|
|
134
134
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
135
135
|
return;
|
|
136
136
|
started = true;
|
|
137
|
-
engine.setCursor('
|
|
137
|
+
engine.setCursor('grabbing');
|
|
138
138
|
if (options.duplicateOnDrag && !duplicated) {
|
|
139
139
|
duplicated = true;
|
|
140
140
|
if (engine.state.selectedIds.length === 0 && unitIds.length > 0)
|
|
@@ -573,7 +573,8 @@ export function createShapeGesture(context, start, kind, libraryKey) {
|
|
|
573
573
|
libraryKey,
|
|
574
574
|
wireframe: engine.wireframeMode,
|
|
575
575
|
createId: () => id,
|
|
576
|
-
random: () => colorSeed
|
|
576
|
+
random: () => colorSeed,
|
|
577
|
+
workspacePaint: engine.workspacePaintForNewShape(engine.wireframeMode)
|
|
577
578
|
});
|
|
578
579
|
};
|
|
579
580
|
return {
|
|
@@ -27,8 +27,7 @@ export interface TextLayout {
|
|
|
27
27
|
export declare function fontShorthand(style: Pick<TextStyleFields, 'fontSize' | 'fontFamily' | 'fontWeight' | 'fontStyle'>): string;
|
|
28
28
|
/** The height of one line, in world units. */
|
|
29
29
|
export declare function lineBoxHeight(style: Pick<TextStyleFields, 'fontSize' | 'lineHeight'>): number;
|
|
30
|
-
|
|
31
|
-
export declare function textLineExtent(style: Pick<TextStyleFields, 'fontSize' | 'lineHeight'>): number;
|
|
30
|
+
export { textLineExtent } from './textMetrics.js';
|
|
32
31
|
/** The way a text is written across a line. */
|
|
33
32
|
export type TextDirection = 'ltr' | 'rtl';
|
|
34
33
|
/**
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* browser), and the sketch the AI is shown is drawn from the same lines, so what is on the screen is what is sent.
|
|
8
8
|
*/
|
|
9
9
|
import { TEXT_DEFAULTS } from '../core/defaults.js';
|
|
10
|
+
import { textLineExtent } from './textMetrics.js';
|
|
10
11
|
/** Room so the last letter and the caret stay on the line; more than this reads as padding. */
|
|
11
12
|
export const TEXT_FIT_SLACK = 4;
|
|
12
13
|
/** Extra width for italic slant and serif overhang beyond what `measureText` returns. */
|
|
@@ -30,10 +31,7 @@ export function fontShorthand(style) {
|
|
|
30
31
|
export function lineBoxHeight(style) {
|
|
31
32
|
return style.fontSize * style.lineHeight;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
export function textLineExtent(style) {
|
|
35
|
-
return Math.max(lineBoxHeight(style), style.fontSize * 1.45);
|
|
36
|
-
}
|
|
34
|
+
export { textLineExtent } from './textMetrics.js';
|
|
37
35
|
/** A letter of a script that is written from right to left. Digits, signs and marks have no direction of their own. */
|
|
38
36
|
const RIGHT_TO_LEFT_LETTER = /(?=\p{L})[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Adlam}]/u;
|
|
39
37
|
/** A letter of any script. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertical metrics for text layout: symmetric line boxes from font ascent/descent when available.
|
|
3
|
+
*/
|
|
4
|
+
import type { TextStyleFields } from '../text/layoutText.js';
|
|
5
|
+
export interface FontVerticalMetrics {
|
|
6
|
+
ascent: number;
|
|
7
|
+
descent: number;
|
|
8
|
+
}
|
|
9
|
+
/** Fallback when the platform cannot report font bounding boxes (tests, Node). */
|
|
10
|
+
export declare function estimateFontVerticalMetrics(fontSize: number): FontVerticalMetrics;
|
|
11
|
+
/**
|
|
12
|
+
* The height of one line in world units: glyph ascent+descent plus balanced leading inside the CSS line-height box.
|
|
13
|
+
*/
|
|
14
|
+
export declare function textLineExtent(style: Pick<TextStyleFields, 'fontSize' | 'lineHeight'>, metrics?: FontVerticalMetrics): number;
|
|
15
|
+
/** Splits leading evenly above and below the glyph box inside one line. */
|
|
16
|
+
export declare function lineVerticalInsets(style: Pick<TextStyleFields, 'fontSize' | 'lineHeight'>, metrics?: FontVerticalMetrics): {
|
|
17
|
+
top: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertical metrics for text layout: symmetric line boxes from font ascent/descent when available.
|
|
3
|
+
*/
|
|
4
|
+
import { lineBoxHeight } from '../text/layoutText.js';
|
|
5
|
+
/** Fallback when the platform cannot report font bounding boxes (tests, Node). */
|
|
6
|
+
export function estimateFontVerticalMetrics(fontSize) {
|
|
7
|
+
return { ascent: fontSize * 0.8, descent: fontSize * 0.2 };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The height of one line in world units: glyph ascent+descent plus balanced leading inside the CSS line-height box.
|
|
11
|
+
*/
|
|
12
|
+
export function textLineExtent(style, metrics = estimateFontVerticalMetrics(style.fontSize)) {
|
|
13
|
+
const glyphHeight = metrics.ascent + metrics.descent;
|
|
14
|
+
const lineHeight = lineBoxHeight(style);
|
|
15
|
+
const leading = Math.max(0, lineHeight - glyphHeight);
|
|
16
|
+
return glyphHeight + leading;
|
|
17
|
+
}
|
|
18
|
+
/** Splits leading evenly above and below the glyph box inside one line. */
|
|
19
|
+
export function lineVerticalInsets(style, metrics = estimateFontVerticalMetrics(style.fontSize)) {
|
|
20
|
+
const extent = textLineExtent(style, metrics);
|
|
21
|
+
const glyphHeight = metrics.ascent + metrics.descent;
|
|
22
|
+
const slack = Math.max(0, extent - glyphHeight);
|
|
23
|
+
return { top: slack / 2, bottom: slack / 2 };
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures Inter is loaded before text is measured (item B14). Host pages usually ship Inter via the design system.
|
|
3
|
+
*/
|
|
4
|
+
export const INTER_FONT_FAMILY = 'Inter';
|
|
5
|
+
const INTER_SOURCES = [
|
|
6
|
+
"url('/fonts/Inter/InterVariable.woff2') format('woff2')",
|
|
7
|
+
"url('/fonts/Inter/Inter-Regular.woff2') format('woff2')"
|
|
8
|
+
];
|
|
9
|
+
let interLoad = null;
|
|
10
|
+
export function ensureInterFontLoaded() {
|
|
11
|
+
if (typeof document === 'undefined')
|
|
12
|
+
return Promise.resolve();
|
|
13
|
+
if (interLoad)
|
|
14
|
+
return interLoad;
|
|
15
|
+
interLoad = (async () => {
|
|
16
|
+
try {
|
|
17
|
+
if (typeof FontFace !== 'undefined') {
|
|
18
|
+
const face = new FontFace(INTER_FONT_FAMILY, INTER_SOURCES.join(', '), { weight: '100 900', style: 'normal', display: 'swap' });
|
|
19
|
+
const loaded = await face.load();
|
|
20
|
+
document.fonts.add(loaded);
|
|
21
|
+
}
|
|
22
|
+
if (document.fonts?.load) {
|
|
23
|
+
await document.fonts.load('16px Inter');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.warn('Canvas: Inter could not be preloaded, fallback fonts will be used', error);
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
return interLoad;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace brand-kit fonts registered for the canvas font picker (item B15).
|
|
3
|
+
*/
|
|
4
|
+
export interface WorkspaceCanvasFont {
|
|
5
|
+
family: string;
|
|
6
|
+
url: string;
|
|
7
|
+
weight?: string | number;
|
|
8
|
+
style?: 'normal' | 'italic';
|
|
9
|
+
format?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function listWorkspaceFontFamilies(fonts: readonly WorkspaceCanvasFont[]): string[];
|
|
12
|
+
export declare function registerWorkspaceFonts(fonts: readonly WorkspaceCanvasFont[]): Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace brand-kit fonts registered for the canvas font picker (item B15).
|
|
3
|
+
*/
|
|
4
|
+
const registered = new Set();
|
|
5
|
+
let registerPass = null;
|
|
6
|
+
function familyKey(font) {
|
|
7
|
+
return `${font.family}|${font.weight ?? '400'}|${font.style ?? 'normal'}`;
|
|
8
|
+
}
|
|
9
|
+
export function listWorkspaceFontFamilies(fonts) {
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
const out = [];
|
|
12
|
+
for (const font of fonts) {
|
|
13
|
+
if (!font.family || seen.has(font.family))
|
|
14
|
+
continue;
|
|
15
|
+
seen.add(font.family);
|
|
16
|
+
out.push(font.family);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
export function registerWorkspaceFonts(fonts) {
|
|
21
|
+
if (typeof document === 'undefined' || typeof FontFace === 'undefined')
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
registerPass ??= (async () => {
|
|
24
|
+
for (const font of fonts) {
|
|
25
|
+
const key = familyKey(font);
|
|
26
|
+
if (registered.has(key) || !font.url)
|
|
27
|
+
continue;
|
|
28
|
+
try {
|
|
29
|
+
const format = font.format ? ` format('${font.format}')` : '';
|
|
30
|
+
const source = `url(${JSON.stringify(font.url)})${format}`;
|
|
31
|
+
const face = new FontFace(font.family, source, {
|
|
32
|
+
weight: String(font.weight ?? '400'),
|
|
33
|
+
style: font.style ?? 'normal',
|
|
34
|
+
display: 'swap'
|
|
35
|
+
});
|
|
36
|
+
const loaded = await Promise.race([
|
|
37
|
+
face.load(),
|
|
38
|
+
new Promise((_, reject) => {
|
|
39
|
+
setTimeout(() => reject(new Error('font load timeout')), 12_000);
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
document.fonts.add(loaded);
|
|
43
|
+
registered.add(key);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn(`Canvas: workspace font "${font.family}" could not load`, error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
return registerPass;
|
|
51
|
+
}
|
package/dist/i18n/labels.js
CHANGED
|
@@ -32,7 +32,8 @@ export function objectName(object, t) {
|
|
|
32
32
|
case 'widget':
|
|
33
33
|
return t('canvas.type.widget');
|
|
34
34
|
case 'rect':
|
|
35
|
-
|
|
35
|
+
// Figma names every rectangle "Rectangle" in the selection panel, including soft corners.
|
|
36
|
+
return t('canvas.tool.rectangle');
|
|
36
37
|
case 'ellipse':
|
|
37
38
|
return t(object.aspectLocked ? 'canvas.tool.circle' : 'canvas.tool.ellipse');
|
|
38
39
|
case 'text':
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -3,18 +3,18 @@ import { type MessageOverrides, type MessageProblem } from '@widgetic/design-sys
|
|
|
3
3
|
* Called by the root component of a canvas while it is created, so everything inside it speaks the page's language.
|
|
4
4
|
* It gives back the words as stores and `update(settings)` for when the page sets the language again.
|
|
5
5
|
*/
|
|
6
|
-
export declare const provideCanvasLanguage: (initial: import("@widgetic/design-system/i18n").I18nSettings) => import("@widgetic/design-system/i18n").I18nHandle<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
6
|
+
export declare const provideCanvasLanguage: (initial: import("@widgetic/design-system/i18n").I18nSettings) => import("@widgetic/design-system/i18n").I18nHandle<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.panel.fontGroupDefault" | "canvas.panel.fontGroupMore" | "canvas.panel.fontGroupWorkspace" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
7
7
|
/**
|
|
8
8
|
* Called by a part of the canvas while it is created. Gives its words as stores, so a part that is already on the screen
|
|
9
9
|
* changes when the page sets the language again. Outside a canvas (a part used on its own, such as the colour control)
|
|
10
10
|
* it speaks English.
|
|
11
11
|
*/
|
|
12
|
-
export declare const useCanvasLanguage: () => import("@widgetic/design-system/i18n").I18nContext<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
12
|
+
export declare const useCanvasLanguage: () => import("@widgetic/design-system/i18n").I18nContext<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.panel.fontGroupDefault" | "canvas.panel.fontGroupMore" | "canvas.panel.fontGroupWorkspace" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
13
13
|
/**
|
|
14
14
|
* The English `t` of the canvas, for code that has no component around it. The screens of the canvas get their words, in
|
|
15
15
|
* the page's language, from `useCanvasLanguage`.
|
|
16
16
|
*/
|
|
17
|
-
export declare const translateEnglish: import("@widgetic/design-system/i18n").Translate<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
17
|
+
export declare const translateEnglish: import("@widgetic/design-system/i18n").Translate<"canvas.state.loading" | "canvas.state.initFailed" | "canvas.state.boardLabel" | "canvas.state.unsupported" | "canvas.state.invalid" | "canvas.state.dismiss" | "canvas.hint.title" | "canvas.hint.description" | "canvas.defaults.textBox" | "canvas.defaults.untitledShape" | "canvas.draw.widgetName" | "canvas.draw.widgetPreview" | "canvas.toolbar.label" | "canvas.tool.select" | "canvas.tool.hand" | "canvas.tool.erase" | "canvas.tool.draw" | "canvas.tool.arrow" | "canvas.tool.rectangle" | "canvas.tool.roundedRectangle" | "canvas.tool.triangle" | "canvas.tool.ellipse" | "canvas.tool.circle" | "canvas.tool.text" | "canvas.tool.selector" | "canvas.tool.image" | "canvas.tool.svg" | "canvas.tool.shapes" | "canvas.tool.moreShapes" | "canvas.tool.undo" | "canvas.tool.redo" | "canvas.menu.media" | "canvas.category.geometric" | "canvas.category.arrows" | "canvas.category.media" | "canvas.category.ui" | "canvas.category.symbols" | "canvas.shape.hexagon" | "canvas.shape.pentagon" | "canvas.shape.oval" | "canvas.shape.play" | "canvas.shape.pause" | "canvas.shape.stop" | "canvas.shape.rewind" | "canvas.shape.fastForward" | "canvas.shape.record" | "canvas.shape.arrowRight" | "canvas.shape.arrowLeft" | "canvas.shape.arrowUp" | "canvas.shape.arrowDown" | "canvas.shape.doubleArrow" | "canvas.shape.curvedArrow" | "canvas.shape.checkMark" | "canvas.shape.cross" | "canvas.shape.plus" | "canvas.shape.minus" | "canvas.shape.info" | "canvas.shape.warning" | "canvas.shape.star" | "canvas.shape.heart" | "canvas.shape.speechBubble" | "canvas.shape.rhombus" | "canvas.shape.lightning" | "canvas.shape.shield" | "canvas.action.cut" | "canvas.action.copy" | "canvas.action.paste" | "canvas.action.duplicate" | "canvas.action.delete" | "canvas.action.group" | "canvas.action.ungroup" | "canvas.action.selectAll" | "canvas.layer.title" | "canvas.layer.front" | "canvas.layer.forward" | "canvas.layer.backward" | "canvas.layer.back" | "canvas.shortcuts.title" | "canvas.shortcuts.close" | "canvas.shortcuts.groupTools" | "canvas.shortcuts.groupSelection" | "canvas.shortcuts.groupHistory" | "canvas.shortcuts.groupZoom" | "canvas.shortcuts.drillThrough" | "canvas.shortcuts.redoAlt" | "canvas.shortcuts.save" | "canvas.shortcuts.zoomIn" | "canvas.shortcuts.zoomOut" | "canvas.shortcuts.zoomReset" | "canvas.shortcuts.fit" | "canvas.shortcuts.pan" | "canvas.shortcuts.move1" | "canvas.shortcuts.move10" | "canvas.key.ctrl" | "canvas.key.ctrlCmd" | "canvas.key.alt" | "canvas.key.shift" | "canvas.key.delete" | "canvas.key.space" | "canvas.key.click" | "canvas.key.drag" | "canvas.zoom.groupLabel" | "canvas.zoom.outLabel" | "canvas.zoom.inLabel" | "canvas.zoom.resetLabel" | "canvas.zoom.fitLabel" | "canvas.zoom.unsavedTitle" | "canvas.zoom.savedTitle" | "canvas.panel.label" | "canvas.panel.close" | "canvas.panel.open" | "canvas.panel.actions" | "canvas.panel.fill" | "canvas.panel.stroke" | "canvas.panel.strokeWidth" | "canvas.panel.roundness" | "canvas.panel.opacity" | "canvas.panel.fontSize" | "canvas.panel.decrease" | "canvas.panel.increase" | "canvas.panel.mixed" | "canvas.panel.none" | "canvas.panel.noColor" | "canvas.panel.pickColor" | "canvas.panel.hex" | "canvas.colorPicker.area" | "canvas.colorPicker.areaValue" | "canvas.colorPicker.hue" | "canvas.colorPicker.add" | "canvas.colorPicker.swatch" | "canvas.type.none" | "canvas.type.widget" | "canvas.type.drawing" | "canvas.type.group" | "canvas.type.selection" | "canvas.type.drawingOf" | "canvas.widget.createPreview" | "canvas.widget.capture" | "canvas.widget.linked" | "canvas.widget.converting" | "canvas.widget.duplicating" | "canvas.widget.linking" | "canvas.widget.unlinkedTitle" | "canvas.widget.orphanNotice" | "canvas.widget.removeFromCanvas" | "canvas.widget.namePlaceholder" | "canvas.widget.openDetails" | "canvas.widget.refreshPreview" | "canvas.widget.primary" | "canvas.widget.primaryTitle" | "canvas.widget.setPrimary" | "canvas.widget.unlinkedName" | "canvas.control.color" | "canvas.control.value" | "canvas.control.openPicker" | "canvas.control.removeColor" | "canvas.control.fontFamily" | "canvas.panel.fontGroupDefault" | "canvas.panel.fontGroupMore" | "canvas.panel.fontGroupWorkspace" | "canvas.control.textStyle" | "canvas.control.bold" | "canvas.control.boldMark" | "canvas.control.italic" | "canvas.control.italicMark" | "canvas.control.underline" | "canvas.control.underlineMark" | "canvas.control.textAlign" | "canvas.control.alignLeft" | "canvas.control.alignCenter" | "canvas.control.alignRight">;
|
|
18
18
|
/**
|
|
19
19
|
* Checks a page's `messages` against the canvas's catalog without showing anything: a key that does not exist (with the
|
|
20
20
|
* nearest real one), a value that is not text, a template that does not parse, or one that asks for a value the message
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -94,12 +94,12 @@ export declare const CANVAS_MESSAGES: {
|
|
|
94
94
|
readonly 'canvas.action.delete': "Delete";
|
|
95
95
|
readonly 'canvas.action.group': "Group";
|
|
96
96
|
readonly 'canvas.action.ungroup': "Ungroup";
|
|
97
|
-
readonly 'canvas.action.selectAll': "Select
|
|
98
|
-
readonly 'canvas.layer.title': "Layer
|
|
99
|
-
readonly 'canvas.layer.front': "Bring to
|
|
100
|
-
readonly 'canvas.layer.forward': "Bring
|
|
101
|
-
readonly 'canvas.layer.backward': "Send
|
|
102
|
-
readonly 'canvas.layer.back': "Send to
|
|
97
|
+
readonly 'canvas.action.selectAll': "Select all";
|
|
98
|
+
readonly 'canvas.layer.title': "Layer order";
|
|
99
|
+
readonly 'canvas.layer.front': "Bring to front";
|
|
100
|
+
readonly 'canvas.layer.forward': "Bring forward";
|
|
101
|
+
readonly 'canvas.layer.backward': "Send backward";
|
|
102
|
+
readonly 'canvas.layer.back': "Send to back";
|
|
103
103
|
readonly 'canvas.shortcuts.title': "Keyboard Shortcuts";
|
|
104
104
|
readonly 'canvas.shortcuts.close': "Close keyboard shortcuts";
|
|
105
105
|
readonly 'canvas.shortcuts.groupTools': "Tools";
|
|
@@ -190,6 +190,9 @@ export declare const CANVAS_MESSAGES: {
|
|
|
190
190
|
readonly 'canvas.control.openPicker': "Open color picker";
|
|
191
191
|
readonly 'canvas.control.removeColor': "Remove color";
|
|
192
192
|
readonly 'canvas.control.fontFamily': "Font family";
|
|
193
|
+
readonly 'canvas.panel.fontGroupDefault': "Default fonts";
|
|
194
|
+
readonly 'canvas.panel.fontGroupMore': "More fonts";
|
|
195
|
+
readonly 'canvas.panel.fontGroupWorkspace': "Workspace fonts";
|
|
193
196
|
readonly 'canvas.control.textStyle': "Text Style";
|
|
194
197
|
readonly 'canvas.control.bold': "Bold";
|
|
195
198
|
/** The letters on the buttons for bold, italic and underline. */
|
package/dist/i18n/messages.js
CHANGED
|
@@ -102,13 +102,13 @@ export const CANVAS_MESSAGES = {
|
|
|
102
102
|
'canvas.action.delete': 'Delete',
|
|
103
103
|
'canvas.action.group': 'Group',
|
|
104
104
|
'canvas.action.ungroup': 'Ungroup',
|
|
105
|
-
'canvas.action.selectAll': 'Select
|
|
105
|
+
'canvas.action.selectAll': 'Select all',
|
|
106
106
|
// ===== The order of the layers =====
|
|
107
|
-
'canvas.layer.title': 'Layer
|
|
108
|
-
'canvas.layer.front': 'Bring to
|
|
109
|
-
'canvas.layer.forward': 'Bring
|
|
110
|
-
'canvas.layer.backward': 'Send
|
|
111
|
-
'canvas.layer.back': 'Send to
|
|
107
|
+
'canvas.layer.title': 'Layer order',
|
|
108
|
+
'canvas.layer.front': 'Bring to front',
|
|
109
|
+
'canvas.layer.forward': 'Bring forward',
|
|
110
|
+
'canvas.layer.backward': 'Send backward',
|
|
111
|
+
'canvas.layer.back': 'Send to back',
|
|
112
112
|
// ===== The list of keyboard shortcuts =====
|
|
113
113
|
'canvas.shortcuts.title': 'Keyboard Shortcuts',
|
|
114
114
|
'canvas.shortcuts.close': 'Close keyboard shortcuts',
|
|
@@ -205,6 +205,9 @@ export const CANVAS_MESSAGES = {
|
|
|
205
205
|
'canvas.control.openPicker': 'Open color picker',
|
|
206
206
|
'canvas.control.removeColor': 'Remove color',
|
|
207
207
|
'canvas.control.fontFamily': 'Font family',
|
|
208
|
+
'canvas.panel.fontGroupDefault': 'Default fonts',
|
|
209
|
+
'canvas.panel.fontGroupMore': 'More fonts',
|
|
210
|
+
'canvas.panel.fontGroupWorkspace': 'Workspace fonts',
|
|
208
211
|
'canvas.control.textStyle': 'Text Style',
|
|
209
212
|
'canvas.control.bold': 'Bold',
|
|
210
213
|
/** The letters on the buttons for bold, italic and underline. */
|