@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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* the shell calls `attach` from `onMount` and `destroy` from `onDestroy`. The engine's state and the host's own UI state
|
|
11
11
|
* are offered as stores (`engineStore`, `uiStore`), so legacy and runes components read them the same way.
|
|
12
12
|
*/
|
|
13
|
-
import { createObjectId, createImageObject, createRectObject } from '../../engine/core/defaults.js';
|
|
13
|
+
import { createObjectId, createImageObject, createRectObject, TEXT_DEFAULTS } from '../../engine/core/defaults.js';
|
|
14
14
|
import { boundsOfObjects, shapeBounds } from '../../engine/core/scene.js';
|
|
15
15
|
import { buildDraggedShape } from '../../engine/core/shapeTools.js';
|
|
16
16
|
import { EngineCore } from '../../engine/EngineCore.js';
|
|
@@ -20,7 +20,11 @@ import { renderShapesToDataUrl } from '../../engine/render/rasterize.js';
|
|
|
20
20
|
import { layoutTextObject } from '../../engine/text/layoutText.js';
|
|
21
21
|
import { ConversionRegistry, absorbSketchIntoWidget, addWidgetCard, commitWidgetCardMove, findWidgetCard, hydrateWidgetMetadata, keepOnlyWidgetCard, linkedWidgetIds, markOrphanedWidgetCards, moveWidgetCardByScreen, primaryWidgetId, removeSketchObjectsKeeping, replaceObjectWithWidgetCard, selectWidgetCard, selectedWidgetId, setPrimaryWidgetCard, updateWidgetThumbnail } from '../../engine/widgets.js';
|
|
22
22
|
import { createAutosaveScheduler } from '../autosaveScheduler.js';
|
|
23
|
-
import { readPreferredTextFontFamily } from '../preferredTextFont.js';
|
|
23
|
+
import { readPreferredTextFontFamily, setWorkspaceFontFamilies, writePreferredTextFontFamily } from '../preferredTextFont.js';
|
|
24
|
+
import { ensureInterFontLoaded } from '../../fonts/interFont.js';
|
|
25
|
+
import { registerWorkspaceFonts } from '../../fonts/workspaceFonts.js';
|
|
26
|
+
import { isCanvasOwnedTarget } from '../outsideClickDeselect.js';
|
|
27
|
+
import { flushWorkspaceToolSettingsPending, loadWorkspaceToolSettings, saveWorkspaceToolSettingsDebounced } from '../../settings/workspaceToolSettings.js';
|
|
24
28
|
import { canvasLog, canvasWarn, setCanvasLogsEnabled } from '../canvasLogger.js';
|
|
25
29
|
import { CANVAS_OPEN_MARKS, markCanvasOpenStep } from '../openMarks.js';
|
|
26
30
|
import { eventIsForScope, getEventOrigin, shouldTakeFocusBack } from '../eventScope.js';
|
|
@@ -54,6 +58,7 @@ export const DEFAULT_HOST_PROPS = Object.freeze({
|
|
|
54
58
|
onAutoSave: null,
|
|
55
59
|
autosaveDelayMs: 3000,
|
|
56
60
|
autosaveMaxWaitMs: 10000,
|
|
61
|
+
autosaveRetryDelaysMs: Object.freeze([5000, 10000, 20000, 40000, 60000]),
|
|
57
62
|
suspendAutosave: false,
|
|
58
63
|
showSaveButton: false,
|
|
59
64
|
onCanvasDirty: null,
|
|
@@ -71,7 +76,11 @@ export const DEFAULT_HOST_PROPS = Object.freeze({
|
|
|
71
76
|
widgetNameRevision: 0,
|
|
72
77
|
isWidgetKnown: null,
|
|
73
78
|
showLogs: false,
|
|
74
|
-
shapeSnap: false
|
|
79
|
+
shapeSnap: false,
|
|
80
|
+
keepCenterOnResize: false,
|
|
81
|
+
workspaceId: null,
|
|
82
|
+
userId: null,
|
|
83
|
+
workspaceFonts: Object.freeze([])
|
|
75
84
|
});
|
|
76
85
|
/** A store the way Svelte reads one (`$store` and `fromStore` both work on it). */
|
|
77
86
|
class ValueStore {
|
|
@@ -217,10 +226,13 @@ export class CanvasHost {
|
|
|
217
226
|
#unsubscribeEngine = null;
|
|
218
227
|
/** The last payload handed to `onAutoSave`, so a timer that fires with no real change does not serialize again. */
|
|
219
228
|
#lastAutosavedJson = null;
|
|
229
|
+
/** The browser said `pagehide` and the page has not come back (`pageshow`): the saves made now are the page's last ones. */
|
|
230
|
+
#pageIsLeaving = false;
|
|
220
231
|
/** A text was being typed at the last change of the engine (its field is on the page). */
|
|
221
232
|
#wasEditingText = false;
|
|
222
233
|
/** The board is about to take the keyboard back from a text field that left the page (asked for the next frame). */
|
|
223
234
|
#keyboardReturnQueued = false;
|
|
235
|
+
#loadedWorkspaceSettings = null;
|
|
224
236
|
/** The animation frame that steps the eraser's trail (null: none asked for), and when the trail was last stepped (null: the clock is idle). */
|
|
225
237
|
#scribbleFrame = null;
|
|
226
238
|
#scribbleClockLast = null;
|
|
@@ -254,9 +266,10 @@ export class CanvasHost {
|
|
|
254
266
|
getMaxWaitMs: () => this.props.autosaveMaxWaitMs,
|
|
255
267
|
isSuspended: () => this.props.suspendAutosave,
|
|
256
268
|
save: () => this.#runAutosave(),
|
|
269
|
+
getRetryDelayMs: (failuresInARow) => this.props.autosaveRetryDelaysMs[failuresInARow - 1] ?? 0,
|
|
257
270
|
onSaveFailed: (error) => {
|
|
258
271
|
this.#updateUi({ saveState: 'dirty' });
|
|
259
|
-
canvasWarn('Canvas: autosave failed, the changes stay unsaved
|
|
272
|
+
canvasWarn('Canvas: autosave failed, the changes stay unsaved and the save is tried again', error);
|
|
260
273
|
}
|
|
261
274
|
});
|
|
262
275
|
this.#wireEngineHooks();
|
|
@@ -282,6 +295,79 @@ export class CanvasHost {
|
|
|
282
295
|
if (this.props.isExternalDataLoading !== previous.isExternalDataLoading) {
|
|
283
296
|
queueMicrotask(() => this.#syncEmptyHintGate());
|
|
284
297
|
}
|
|
298
|
+
if (this.props.workspaceId !== previous.workspaceId ||
|
|
299
|
+
this.props.userId !== previous.userId ||
|
|
300
|
+
this.props.workspaceFonts !== previous.workspaceFonts) {
|
|
301
|
+
void this.#syncWorkspaceContext();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
#compactStylePatch(fields) {
|
|
305
|
+
const compact = Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
306
|
+
return Object.keys(compact).length > 0 ? compact : undefined;
|
|
307
|
+
}
|
|
308
|
+
/** Persists tool style changes for this workspace (called from the selection panel). */
|
|
309
|
+
persistWorkspaceStyle(patch) {
|
|
310
|
+
const workspaceId = this.props.workspaceId;
|
|
311
|
+
if (!workspaceId)
|
|
312
|
+
return;
|
|
313
|
+
const textPatch = patch.fontFamily !== undefined ||
|
|
314
|
+
patch.fontSize !== undefined ||
|
|
315
|
+
patch.fontWeight !== undefined ||
|
|
316
|
+
patch.fontStyle !== undefined ||
|
|
317
|
+
patch.color !== undefined ||
|
|
318
|
+
patch.align !== undefined ||
|
|
319
|
+
patch.underline !== undefined
|
|
320
|
+
? this.#compactStylePatch({
|
|
321
|
+
fontFamily: patch.fontFamily,
|
|
322
|
+
fontSize: patch.fontSize,
|
|
323
|
+
fontWeight: patch.fontWeight,
|
|
324
|
+
fontStyle: patch.fontStyle,
|
|
325
|
+
color: patch.color,
|
|
326
|
+
align: patch.align,
|
|
327
|
+
underline: patch.underline
|
|
328
|
+
})
|
|
329
|
+
: undefined;
|
|
330
|
+
const paintPatch = patch.fill !== undefined ||
|
|
331
|
+
patch.stroke !== undefined ||
|
|
332
|
+
patch.strokeWidth !== undefined ||
|
|
333
|
+
patch.strokeStyle !== undefined ||
|
|
334
|
+
patch.opacity !== undefined ||
|
|
335
|
+
patch.roundness !== undefined
|
|
336
|
+
? this.#compactStylePatch({
|
|
337
|
+
fill: patch.fill,
|
|
338
|
+
stroke: patch.stroke,
|
|
339
|
+
strokeWidth: patch.strokeWidth,
|
|
340
|
+
strokeStyle: patch.strokeStyle,
|
|
341
|
+
opacity: patch.opacity,
|
|
342
|
+
roundness: patch.roundness
|
|
343
|
+
})
|
|
344
|
+
: undefined;
|
|
345
|
+
if (!textPatch && !paintPatch)
|
|
346
|
+
return;
|
|
347
|
+
saveWorkspaceToolSettingsDebounced({ workspaceId, userId: this.props.userId }, { text: textPatch, paint: paintPatch });
|
|
348
|
+
}
|
|
349
|
+
async #syncWorkspaceContext() {
|
|
350
|
+
await ensureInterFontLoaded();
|
|
351
|
+
const fonts = this.props.workspaceFonts ?? [];
|
|
352
|
+
setWorkspaceFontFamilies(fonts.map((font) => font.family));
|
|
353
|
+
await registerWorkspaceFonts(fonts);
|
|
354
|
+
this.engine.notifyFontsChanged();
|
|
355
|
+
const workspaceId = this.props.workspaceId;
|
|
356
|
+
if (!workspaceId)
|
|
357
|
+
return;
|
|
358
|
+
this.#loadedWorkspaceSettings = loadWorkspaceToolSettings({ workspaceId, userId: this.props.userId });
|
|
359
|
+
const textFamily = this.#loadedWorkspaceSettings?.text?.fontFamily;
|
|
360
|
+
if (textFamily) {
|
|
361
|
+
this.engine.setPreferredTextFontFamily(textFamily);
|
|
362
|
+
writePreferredTextFontFamily(textFamily);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
this.engine.setPreferredTextFontFamily(TEXT_DEFAULTS.fontFamily);
|
|
366
|
+
}
|
|
367
|
+
this.engine.setWorkspaceToolDefaults({
|
|
368
|
+
text: this.#loadedWorkspaceSettings?.text ?? null,
|
|
369
|
+
paint: this.#loadedWorkspaceSettings?.paint ?? null
|
|
370
|
+
});
|
|
285
371
|
}
|
|
286
372
|
/**
|
|
287
373
|
* A tool whose button the page hides must not stay armed: once the page takes the drawing tools off (after the first
|
|
@@ -365,7 +451,29 @@ export class CanvasHost {
|
|
|
365
451
|
this.#listen(window, 'keyup', (event) => this.#onKeyUp(event));
|
|
366
452
|
this.#listen(window, 'blur', () => this.#onWindowBlur());
|
|
367
453
|
this.#listen(window, 'paste', (event) => this.#onPaste(event));
|
|
368
|
-
this.#listen(window, 'pagehide', () =>
|
|
454
|
+
this.#listen(window, 'pagehide', () => {
|
|
455
|
+
flushWorkspaceToolSettingsPending();
|
|
456
|
+
// Said before the flush, and kept until the page comes back: a save that waits behind another one (the buffer runs one
|
|
457
|
+
// at a time) is made after this handler returns, and it too is a save of a page that is going away.
|
|
458
|
+
this.#pageIsLeaving = true;
|
|
459
|
+
void this.#scheduler.flush();
|
|
460
|
+
});
|
|
461
|
+
// A page that went into the browser's back-forward cache and is shown again is not leaving any more.
|
|
462
|
+
this.#listen(window, 'pageshow', () => {
|
|
463
|
+
this.#pageIsLeaving = false;
|
|
464
|
+
});
|
|
465
|
+
this.#listen(document, 'pointerdown', (event) => {
|
|
466
|
+
const pointer = event;
|
|
467
|
+
if (pointer.button !== 0)
|
|
468
|
+
return;
|
|
469
|
+
if (this.engine.state.selectedIds.length === 0)
|
|
470
|
+
return;
|
|
471
|
+
if (isCanvasOwnedTarget(pointer, this.#root))
|
|
472
|
+
return;
|
|
473
|
+
if (this.engine.state.editingTextId !== null)
|
|
474
|
+
this.engine.endTextEdit();
|
|
475
|
+
this.engine.clearSelection();
|
|
476
|
+
}, true);
|
|
369
477
|
this.#listen(document, 'visibilitychange', () => {
|
|
370
478
|
if (document.visibilityState === 'hidden')
|
|
371
479
|
void this.#scheduler.flush();
|
|
@@ -374,7 +482,10 @@ export class CanvasHost {
|
|
|
374
482
|
if (typeof document !== 'undefined' && document.fonts && typeof document.fonts.addEventListener === 'function') {
|
|
375
483
|
this.#listen(document.fonts, 'loadingdone', () => this.engine.notifyFontsChanged());
|
|
376
484
|
}
|
|
377
|
-
|
|
485
|
+
void ensureInterFontLoaded().then(() => {
|
|
486
|
+
this.engine.notifyFontsChanged();
|
|
487
|
+
void this.#syncWorkspaceContext();
|
|
488
|
+
});
|
|
378
489
|
void this.#start();
|
|
379
490
|
}
|
|
380
491
|
async #start() {
|
|
@@ -493,7 +604,7 @@ export class CanvasHost {
|
|
|
493
604
|
const board = this.#board;
|
|
494
605
|
if (!board)
|
|
495
606
|
return;
|
|
496
|
-
this.engine.setViewSize({ width: board.clientWidth, height: board.clientHeight });
|
|
607
|
+
this.engine.setViewSize({ width: board.clientWidth, height: board.clientHeight }, this.props.keepCenterOnResize);
|
|
497
608
|
}
|
|
498
609
|
/** The board on the page (its rectangle and its layout size), for everything the page lays over it. */
|
|
499
610
|
#frame() {
|
|
@@ -588,7 +699,7 @@ export class CanvasHost {
|
|
|
588
699
|
this.controller.pointerCancel({ pointerId: pending.pointerId });
|
|
589
700
|
this.controller.prepareContextMenu({ x: pending.x, y: pending.y });
|
|
590
701
|
this.#menuFinger = { pointerId: pending.pointerId, liftedAt: null };
|
|
591
|
-
this.#updateUi({ contextMenu: { x: pending.x, y: pending.y, byTouch: true }, shapesMenuOpen: false });
|
|
702
|
+
this.#updateUi({ contextMenu: { x: pending.x, y: pending.y, byTouch: true }, shapesMenuOpen: false, selectionPanelDismissed: true });
|
|
592
703
|
}
|
|
593
704
|
/**
|
|
594
705
|
* Is the menu still held by the finger that opened it? True while that finger is down, and for a moment after it lifts:
|
|
@@ -683,7 +794,7 @@ export class CanvasHost {
|
|
|
683
794
|
this.focusBoard({ focusVisible: false });
|
|
684
795
|
this.#menuFinger = null;
|
|
685
796
|
this.controller.prepareContextMenu({ x: input.x, y: input.y });
|
|
686
|
-
this.#updateUi({ contextMenu: { x: input.x, y: input.y }, shapesMenuOpen: false });
|
|
797
|
+
this.#updateUi({ contextMenu: { x: input.x, y: input.y }, shapesMenuOpen: false, selectionPanelDismissed: true });
|
|
687
798
|
}
|
|
688
799
|
/** A picture is being dragged over the board: say that it can be dropped. */
|
|
689
800
|
handleDragOver(event) {
|
|
@@ -847,6 +958,8 @@ export class CanvasHost {
|
|
|
847
958
|
#wireEngineHooks() {
|
|
848
959
|
const hooks = {
|
|
849
960
|
onDirty: () => this.#markDirty(),
|
|
961
|
+
// Typing is a change too: the letters are saved with the next save, before the typing ends and makes its undo step.
|
|
962
|
+
onDraftChange: () => this.#markDirty(),
|
|
850
963
|
onCleared: () => this.#safely(() => this.props.onCanvasCleared?.(), 'onCanvasCleared'),
|
|
851
964
|
onSelectionChange: (ids) => this.#onSelectionChange(ids),
|
|
852
965
|
confirmWidgetDeletion: (widgetId) => {
|
|
@@ -916,6 +1029,18 @@ export class CanvasHost {
|
|
|
916
1029
|
last.hoverWidgetId !== state.hoverWidgetId ||
|
|
917
1030
|
last.selectedIds !== state.selectedIds ||
|
|
918
1031
|
last.overlayDragActive !== state.overlayDragActive) {
|
|
1032
|
+
if (last && last.selectedIds !== state.selectedIds) {
|
|
1033
|
+
if (state.selectedIds.length === 0) {
|
|
1034
|
+
// Leave dismissal as the user left it.
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
const selected = state.selectedIds
|
|
1038
|
+
.map((id) => state.scene.find((object) => object.id === id))
|
|
1039
|
+
.filter((object) => object !== undefined);
|
|
1040
|
+
const widgetOnly = selected.length === 1 && selected[0].type === 'widget';
|
|
1041
|
+
this.#updateUi({ selectionPanelDismissed: widgetOnly });
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
919
1044
|
this.#lastOverlayState = {
|
|
920
1045
|
scene: state.scene,
|
|
921
1046
|
viewport: state.viewport,
|
|
@@ -1032,7 +1157,7 @@ export class CanvasHost {
|
|
|
1032
1157
|
this.#updateUi({ saveState: 'saving' });
|
|
1033
1158
|
let outcome;
|
|
1034
1159
|
try {
|
|
1035
|
-
outcome = this.props.onAutoSave?.(json);
|
|
1160
|
+
outcome = this.props.onAutoSave?.(json, { leaving: this.#pageIsLeaving });
|
|
1036
1161
|
}
|
|
1037
1162
|
catch (error) {
|
|
1038
1163
|
this.#updateUi({ saveState: 'dirty' });
|
|
@@ -1066,7 +1191,7 @@ export class CanvasHost {
|
|
|
1066
1191
|
this.#updateUi({ saveState: 'saving' });
|
|
1067
1192
|
let outcome;
|
|
1068
1193
|
try {
|
|
1069
|
-
outcome = this.props.onAutoSave?.(json);
|
|
1194
|
+
outcome = this.props.onAutoSave?.(json, { leaving: this.#pageIsLeaving });
|
|
1070
1195
|
}
|
|
1071
1196
|
catch (error) {
|
|
1072
1197
|
canvasWarn('Canvas: the save failed', error);
|
|
@@ -1373,7 +1498,8 @@ export class CanvasHost {
|
|
|
1373
1498
|
dragged: false,
|
|
1374
1499
|
wireframe: this.engine.wireframeMode,
|
|
1375
1500
|
createId: this.engine.services.createId,
|
|
1376
|
-
random: this.engine.services.random
|
|
1501
|
+
random: this.engine.services.random,
|
|
1502
|
+
workspacePaint: this.engine.workspacePaintForNewShape(this.engine.wireframeMode)
|
|
1377
1503
|
});
|
|
1378
1504
|
}
|
|
1379
1505
|
addRect() {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document-level outside press: deselect when the press is outside the canvas root and its portaled UI (item B18).
|
|
3
|
+
*/
|
|
4
|
+
export declare const CANVAS_UI_ATTRIBUTE = "data-canvas-ui";
|
|
5
|
+
export declare function isCanvasOwnedTarget(event: Event, canvasRoot: HTMLElement | null): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document-level outside press: deselect when the press is outside the canvas root and its portaled UI (item B18).
|
|
3
|
+
*/
|
|
4
|
+
export const CANVAS_UI_ATTRIBUTE = 'data-canvas-ui';
|
|
5
|
+
export function isCanvasOwnedTarget(event, canvasRoot) {
|
|
6
|
+
if (!canvasRoot)
|
|
7
|
+
return false;
|
|
8
|
+
const path = typeof event.composedPath === 'function' ? event.composedPath() : [];
|
|
9
|
+
if (path.length > 0) {
|
|
10
|
+
for (const node of path) {
|
|
11
|
+
if (!(node instanceof Node))
|
|
12
|
+
continue;
|
|
13
|
+
if (node === canvasRoot || canvasRoot.contains(node))
|
|
14
|
+
return true;
|
|
15
|
+
if (node instanceof Element && node.closest(`[${CANVAS_UI_ATTRIBUTE}]`))
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const target = event.target;
|
|
21
|
+
if (target instanceof Node && (canvasRoot.contains(target) || (target instanceof Element && target.closest(`[${CANVAS_UI_ATTRIBUTE}]`)))) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* store a partner page installed with `setCanvasPreferenceStorage`), so that the next text they place starts with it.
|
|
4
4
|
*/
|
|
5
5
|
/** The font families the selection panel offers for a text, in the order of its list. */
|
|
6
|
-
export declare const TEXT_FONT_FAMILIES: readonly ["Arial", "Helvetica", "Times New Roman", "Georgia", "Verdana", "
|
|
6
|
+
export declare const TEXT_FONT_FAMILIES: readonly ["Inter", "Comic Sans MS", "Arial", "Helvetica", "Times New Roman", "Georgia", "Verdana", "Courier New", "Impact"];
|
|
7
|
+
export declare function setWorkspaceFontFamilies(families: readonly string[]): void;
|
|
8
|
+
export declare function fontFamiliesForPicker(): string[];
|
|
9
|
+
/** Inter + Comic Sans for the picker’s “Default fonts” group. */
|
|
10
|
+
export declare const PRIMARY_CANVAS_FONT_FAMILIES: readonly ["Inter", "Comic Sans MS"];
|
|
11
|
+
export declare function builtInFontFamiliesForPicker(): string[];
|
|
12
|
+
export declare function workspaceFontFamiliesForPicker(): string[];
|
|
7
13
|
/** The key the choice is kept under. */
|
|
8
14
|
export declare const PREFERRED_TEXT_FONT_STORAGE_KEY = "widgetic-canvas:preferred-text-font";
|
|
9
15
|
/** The font family kept from an earlier choice, or null when none was made (or the store refuses, or the name is no longer offered). */
|
|
@@ -5,22 +5,44 @@
|
|
|
5
5
|
import { getCanvasPreferenceStorage } from '../components/preferenceStorage.js';
|
|
6
6
|
/** The font families the selection panel offers for a text, in the order of its list. */
|
|
7
7
|
export const TEXT_FONT_FAMILIES = [
|
|
8
|
+
'Inter',
|
|
9
|
+
'Comic Sans MS',
|
|
8
10
|
'Arial',
|
|
9
11
|
'Helvetica',
|
|
10
12
|
'Times New Roman',
|
|
11
13
|
'Georgia',
|
|
12
14
|
'Verdana',
|
|
13
|
-
'Comic Sans MS',
|
|
14
15
|
'Courier New',
|
|
15
16
|
'Impact'
|
|
16
17
|
];
|
|
18
|
+
/** Families added from the workspace brand kit (not persisted in this list; merged in the panel). */
|
|
19
|
+
let workspaceFontFamilies = [];
|
|
20
|
+
export function setWorkspaceFontFamilies(families) {
|
|
21
|
+
workspaceFontFamilies = [...new Set(families.filter(Boolean))];
|
|
22
|
+
}
|
|
23
|
+
export function fontFamiliesForPicker() {
|
|
24
|
+
const merged = [...TEXT_FONT_FAMILIES];
|
|
25
|
+
for (const family of workspaceFontFamilies) {
|
|
26
|
+
if (!merged.includes(family))
|
|
27
|
+
merged.push(family);
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
}
|
|
31
|
+
/** Inter + Comic Sans for the picker’s “Default fonts” group. */
|
|
32
|
+
export const PRIMARY_CANVAS_FONT_FAMILIES = ['Inter', 'Comic Sans MS'];
|
|
33
|
+
export function builtInFontFamiliesForPicker() {
|
|
34
|
+
return TEXT_FONT_FAMILIES.filter((family) => !PRIMARY_CANVAS_FONT_FAMILIES.includes(family));
|
|
35
|
+
}
|
|
36
|
+
export function workspaceFontFamiliesForPicker() {
|
|
37
|
+
return [...workspaceFontFamilies];
|
|
38
|
+
}
|
|
17
39
|
/** The key the choice is kept under. */
|
|
18
40
|
export const PREFERRED_TEXT_FONT_STORAGE_KEY = 'widgetic-canvas:preferred-text-font';
|
|
19
41
|
/** The font family kept from an earlier choice, or null when none was made (or the store refuses, or the name is no longer offered). */
|
|
20
42
|
export function readPreferredTextFontFamily() {
|
|
21
43
|
try {
|
|
22
44
|
const stored = getCanvasPreferenceStorage()?.getItem(PREFERRED_TEXT_FONT_STORAGE_KEY);
|
|
23
|
-
return stored &&
|
|
45
|
+
return stored && fontFamiliesForPicker().includes(stored) ? stored : null;
|
|
24
46
|
}
|
|
25
47
|
catch {
|
|
26
48
|
// A store that blocks reading is the same as a store with nothing in it.
|
|
@@ -29,6 +51,8 @@ export function readPreferredTextFontFamily() {
|
|
|
29
51
|
}
|
|
30
52
|
/** Keeps the choice for the next text. A store that refuses the write is not an error: the choice then lasts until the page closes. */
|
|
31
53
|
export function writePreferredTextFontFamily(fontFamily) {
|
|
54
|
+
if (!fontFamiliesForPicker().includes(fontFamily))
|
|
55
|
+
return;
|
|
32
56
|
try {
|
|
33
57
|
getCanvasPreferenceStorage()?.setItem(PREFERRED_TEXT_FONT_STORAGE_KEY, fontFamily);
|
|
34
58
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Figma "Canvas Menu" and its "Layer order" submenu: the menu a right click (or a long press) opens on the board.
|
|
3
3
|
|
|
4
4
|
Cut, Copy, Paste and Duplicate; Group and Ungroup; Layer order (a submenu of four) and Select all; Delete in the colour of a
|
|
5
|
-
destructive action.
|
|
6
|
-
|
|
5
|
+
destructive action. No leading icons; sentence-case labels; shortcuts as words ("Cmd X", "Shift Cmd G" on a Mac). A row that
|
|
6
|
+
cannot act on what is selected is dimmed. Opening the menu dismisses the selection panel (Figma shows no panel behind it).
|
|
7
7
|
|
|
8
8
|
The menu is the design system's Dropdown Menu, anchored to the point of the board that was pressed, and drawn into the
|
|
9
9
|
canvas's floating layer. The host decides when it opens (`ui.contextMenu`): a press on an object selects it first.
|
|
@@ -15,12 +15,10 @@
|
|
|
15
15
|
import { useCanvasLanguage } from '../../i18n/language.js';
|
|
16
16
|
import type { CanvasMessageKey } from '../../i18n/messages.js';
|
|
17
17
|
import type { CanvasHost, HostUiState } from '../host/CanvasHost.js';
|
|
18
|
-
import { ariaKeyShortcut,
|
|
18
|
+
import { ariaKeyShortcut, isApplePlatform, menuChordText } from './keyHints.js';
|
|
19
19
|
import type { Chord } from './keyHints.js';
|
|
20
|
-
import
|
|
21
|
-
import { CANVAS_OVERLAY_Z_CLASS, MENU_PADDING_CLASS, OVERLAY_REDUCED_MOTION_CLASSES } from './floatingCard.js';
|
|
20
|
+
import { CANVAS_OVERLAY_Z_CLASS, LAYER_MENU_PADDING_CLASS, MENU_PADDING_CLASS, OVERLAY_REDUCED_MOTION_CLASSES } from './floatingCard.js';
|
|
22
21
|
import { canvasOverlayPortalProps, useFloatingLayer } from './floatingLayer.js';
|
|
23
|
-
import { IconArrowBarToDown, IconArrowBarToUp, IconClipboard, IconCopy, IconReplace, IconScissors, IconSelectAll, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconTrash } from './icons.js';
|
|
24
22
|
|
|
25
23
|
interface Props {
|
|
26
24
|
host: CanvasHost;
|
|
@@ -38,10 +36,9 @@
|
|
|
38
36
|
const { t } = useCanvasLanguage();
|
|
39
37
|
const apple = isApplePlatform();
|
|
40
38
|
|
|
41
|
-
/** A row of the menu: what it is called,
|
|
39
|
+
/** A row of the menu: what it is called, the keys, whether it can act, and what it does. */
|
|
42
40
|
interface Row {
|
|
43
41
|
label: CanvasMessageKey;
|
|
44
|
-
icon: CanvasIcon;
|
|
45
42
|
chord?: Chord;
|
|
46
43
|
disabled: boolean;
|
|
47
44
|
run: () => void;
|
|
@@ -60,22 +57,22 @@
|
|
|
60
57
|
const point = $derived(ui.contextMenu);
|
|
61
58
|
|
|
62
59
|
const clipboardRows = $derived<Row[]>([
|
|
63
|
-
{ label: 'canvas.action.cut',
|
|
64
|
-
{ label: 'canvas.action.copy',
|
|
65
|
-
{ label: 'canvas.action.paste',
|
|
66
|
-
{ label: 'canvas.action.duplicate',
|
|
60
|
+
{ label: 'canvas.action.cut', chord: { mod: true, key: 'X' }, disabled: !hasSelection, run: () => void host.cutSelection() },
|
|
61
|
+
{ label: 'canvas.action.copy', chord: { mod: true, key: 'C' }, disabled: !hasSelection, run: () => void host.copySelection() },
|
|
62
|
+
{ label: 'canvas.action.paste', chord: { mod: true, key: 'V' }, disabled: false, run: () => void host.pasteAt(point) },
|
|
63
|
+
{ label: 'canvas.action.duplicate', chord: { mod: true, key: 'D' }, disabled: !hasSelection, run: () => void host.duplicateSelectedObjects() }
|
|
67
64
|
]);
|
|
68
65
|
|
|
69
66
|
const groupRows = $derived<Row[]>([
|
|
70
|
-
{ label: 'canvas.action.group',
|
|
71
|
-
{ label: 'canvas.action.ungroup',
|
|
67
|
+
{ label: 'canvas.action.group', chord: { mod: true, key: 'G' }, disabled: !canGroup, run: () => void host.onGroupSelection() },
|
|
68
|
+
{ label: 'canvas.action.ungroup', chord: { mod: true, shift: true, key: 'G' }, disabled: !canUngroup, run: () => host.onUngroupSelection() }
|
|
72
69
|
]);
|
|
73
70
|
|
|
74
71
|
const layerRows = $derived<(Row & { mode: ReorderMode })[]>([
|
|
75
|
-
{ mode: 'front', label: 'canvas.layer.front',
|
|
76
|
-
{ mode: 'forward', label: 'canvas.layer.forward',
|
|
77
|
-
{ mode: 'backward', label: 'canvas.layer.backward',
|
|
78
|
-
{ mode: 'back', label: 'canvas.layer.back',
|
|
72
|
+
{ mode: 'front', label: 'canvas.layer.front', chord: { mod: true, shift: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('front') },
|
|
73
|
+
{ mode: 'forward', label: 'canvas.layer.forward', chord: { mod: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('forward') },
|
|
74
|
+
{ mode: 'backward', label: 'canvas.layer.backward', chord: { mod: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('backward') },
|
|
75
|
+
{ mode: 'back', label: 'canvas.layer.back', chord: { mod: true, shift: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('back') }
|
|
79
76
|
]);
|
|
80
77
|
|
|
81
78
|
/** Where the menu opens on the page: the pressed point of the board, which is only known once the board is. */
|
|
@@ -116,11 +113,30 @@
|
|
|
116
113
|
|
|
117
114
|
<!-- The keys are written beside the name for the eye (hidden from the name a screen reader reads) and given as `aria-keyshortcuts`. -->
|
|
118
115
|
{#snippet rowView(row: Row)}
|
|
119
|
-
<DropdownMenu.Item
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
<DropdownMenu.Item
|
|
117
|
+
class="h-8 min-h-8 gap-2 px-2 py-1.5"
|
|
118
|
+
disabled={row.disabled}
|
|
119
|
+
aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined}
|
|
120
|
+
onSelect={(event) => choose(event, row.run)}
|
|
121
|
+
>
|
|
122
|
+
<span class="flex-1 text-body">{$t(row.label)}</span>
|
|
122
123
|
{#if row.chord}
|
|
123
|
-
<DropdownMenu.Shortcut aria-hidden="true">{
|
|
124
|
+
<DropdownMenu.Shortcut aria-hidden="true">{menuChordText(row.chord, apple, $t)}</DropdownMenu.Shortcut>
|
|
125
|
+
{/if}
|
|
126
|
+
</DropdownMenu.Item>
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
129
|
+
<!-- Figma layer submenu rows (519:477): label + shortcut only, 32 px tall, no leading icon. -->
|
|
130
|
+
{#snippet layerMenuRowView(row: Row)}
|
|
131
|
+
<DropdownMenu.Item
|
|
132
|
+
class="h-8 min-h-8 gap-2 px-2 py-1.5 [&_svg]:hidden"
|
|
133
|
+
disabled={row.disabled}
|
|
134
|
+
aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined}
|
|
135
|
+
onSelect={(event) => choose(event, row.run)}
|
|
136
|
+
>
|
|
137
|
+
<span class="flex-1 text-body">{$t(row.label)}</span>
|
|
138
|
+
{#if row.chord}
|
|
139
|
+
<DropdownMenu.Shortcut class="text-caption text-muted-foreground" aria-hidden="true">{menuChordText(row.chord, apple, $t)}</DropdownMenu.Shortcut>
|
|
124
140
|
{/if}
|
|
125
141
|
</DropdownMenu.Item>
|
|
126
142
|
{/snippet}
|
|
@@ -136,37 +152,51 @@
|
|
|
136
152
|
onCloseAutoFocus={returnFocusToBoard}
|
|
137
153
|
aria-label={$t('canvas.panel.actions')}
|
|
138
154
|
data-canvas-context-menu
|
|
139
|
-
class="{CANVAS_OVERLAY_Z_CLASS} w-[240px] {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}"
|
|
155
|
+
class="{CANVAS_OVERLAY_Z_CLASS} w-[240px] py-1 {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}"
|
|
140
156
|
>
|
|
141
157
|
{#each clipboardRows as row (row.label)}
|
|
142
158
|
{@render rowView(row)}
|
|
143
159
|
{/each}
|
|
144
|
-
<DropdownMenu.Separator />
|
|
160
|
+
<DropdownMenu.Separator class="my-0 h-px min-h-px" />
|
|
145
161
|
{#each groupRows as row (row.label)}
|
|
146
162
|
{@render rowView(row)}
|
|
147
163
|
{/each}
|
|
148
|
-
<DropdownMenu.Separator />
|
|
164
|
+
<DropdownMenu.Separator class="my-0 h-px min-h-px" />
|
|
149
165
|
<DropdownMenu.Sub>
|
|
150
|
-
<DropdownMenu.SubTrigger disabled={!hasSelection}>
|
|
151
|
-
<
|
|
152
|
-
<span class="flex-1">{$t('canvas.layer.title')}</span>
|
|
166
|
+
<DropdownMenu.SubTrigger class="h-8 min-h-8 gap-2 px-2 py-1.5" disabled={!hasSelection}>
|
|
167
|
+
<span class="flex-1 text-body">{$t('canvas.layer.title')}</span>
|
|
153
168
|
</DropdownMenu.SubTrigger>
|
|
154
|
-
<DropdownMenu.SubContent
|
|
169
|
+
<DropdownMenu.SubContent
|
|
170
|
+
align="start"
|
|
171
|
+
alignOffset={12}
|
|
172
|
+
sideOffset={13}
|
|
173
|
+
aria-label={$t('canvas.layer.title')}
|
|
174
|
+
data-canvas-layer-menu
|
|
175
|
+
class="{CANVAS_OVERLAY_Z_CLASS} w-[220px] rounded-xl border border-border bg-popover {LAYER_MENU_PADDING_CLASS} shadow-floating {OVERLAY_REDUCED_MOTION_CLASSES}"
|
|
176
|
+
>
|
|
155
177
|
{#each layerRows as row (row.mode)}
|
|
156
|
-
{@render
|
|
178
|
+
{@render layerMenuRowView(row)}
|
|
157
179
|
{/each}
|
|
158
180
|
</DropdownMenu.SubContent>
|
|
159
181
|
</DropdownMenu.Sub>
|
|
160
|
-
<DropdownMenu.Item
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
182
|
+
<DropdownMenu.Item
|
|
183
|
+
class="h-8 min-h-8 gap-2 px-2 py-1.5"
|
|
184
|
+
disabled={boardIsEmpty}
|
|
185
|
+
aria-keyshortcuts={ariaKeyShortcut({ mod: true, key: 'A' }, apple)}
|
|
186
|
+
onSelect={(event) => choose(event, () => host.onSelectAllObjects())}
|
|
187
|
+
>
|
|
188
|
+
<span class="flex-1 text-body">{$t('canvas.action.selectAll')}</span>
|
|
189
|
+
<DropdownMenu.Shortcut aria-hidden="true">{menuChordText({ mod: true, key: 'A' }, apple, $t)}</DropdownMenu.Shortcut>
|
|
164
190
|
</DropdownMenu.Item>
|
|
165
|
-
<DropdownMenu.Separator />
|
|
166
|
-
<DropdownMenu.Item
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
191
|
+
<DropdownMenu.Separator class="my-0 h-px min-h-px" />
|
|
192
|
+
<DropdownMenu.Item
|
|
193
|
+
class="h-8 min-h-8 gap-2 px-2 py-1.5"
|
|
194
|
+
data-variant="destructive"
|
|
195
|
+
disabled={!hasSelection}
|
|
196
|
+
aria-keyshortcuts="Delete"
|
|
197
|
+
onSelect={(event) => choose(event, () => void host.deleteSelectedObjects())}
|
|
198
|
+
>
|
|
199
|
+
<span class="flex-1 text-body">{$t('canvas.action.delete')}</span>
|
|
170
200
|
</DropdownMenu.Item>
|
|
171
201
|
</DropdownMenu.Content>
|
|
172
202
|
{/if}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
const { t } = useCanvasLanguage();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<div class="pointer-events-none absolute inset-0 flex
|
|
14
|
-
<div class="flex w-80 max-w-full flex-col items-center gap-
|
|
15
|
-
<div class="flex size-
|
|
16
|
-
<IconPencil class="size-
|
|
13
|
+
<div class="pointer-events-none absolute inset-x-0 top-0 flex justify-center pt-[312px] max-md:inset-0 max-md:items-center max-md:pt-0 max-md:p-6" data-canvas-hint>
|
|
14
|
+
<div class="flex w-80 max-w-full flex-col items-center gap-2.5 text-center">
|
|
15
|
+
<div class="flex size-9 items-center justify-center rounded-lg border border-border bg-background text-foreground">
|
|
16
|
+
<IconPencil class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
17
17
|
</div>
|
|
18
18
|
<p class="text-body-medium text-foreground">{$t('canvas.hint.title')}</p>
|
|
19
19
|
<p class="text-body text-muted-foreground">{$t('canvas.hint.description')}</p>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { isSideAnchor, popoverSideFor } from '../chromeLayout.js';
|
|
23
23
|
import type { ChromeAnchor } from '../chromeLayout.js';
|
|
24
24
|
import type { CanvasHost, HostUiState } from '../host/CanvasHost.js';
|
|
25
|
-
import { FLOATING_CARD_CLASSES,
|
|
25
|
+
import { FLOATING_CARD_CLASSES, TOOLBAR_ICON_STROKE_CLASSES } from './floatingCard.js';
|
|
26
26
|
import { providePopoverSide } from './popoverSide.js';
|
|
27
27
|
import ShapesMenu from './ShapesMenu.svelte';
|
|
28
28
|
import ToolButton from './ToolButton.svelte';
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
aria-label={$t('canvas.toolbar.label')}
|
|
53
53
|
data-canvas-toolbar
|
|
54
54
|
data-anchor={anchor}
|
|
55
|
-
class="canvas-toolbar-el pointer-events-auto flex items-center gap-1 {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full'} {FLOATING_CARD_CLASSES}"
|
|
55
|
+
class="canvas-toolbar-el pointer-events-auto flex items-center gap-1 {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full'} {FLOATING_CARD_CLASSES} {TOOLBAR_ICON_STROKE_CLASSES} [&_svg]:size-4"
|
|
56
|
+
data-canvas-ui
|
|
56
57
|
>
|
|
57
58
|
{#if showDrawingTools}
|
|
58
59
|
<ToolButton toggle label={$t('canvas.tool.select')} shortcut={TOOL_KEYS.select} active={state.tool === 'select'} onclick={() => host.onSelectSelectTool()}>
|
|
@@ -83,7 +84,9 @@
|
|
|
83
84
|
/>
|
|
84
85
|
|
|
85
86
|
<!-- The history group is the first thing a board too narrow for the whole bar gives up (Figma's phone): undo and redo stay on the keys. An upright bar is as long as the board is tall, so it keeps them. -->
|
|
86
|
-
<div
|
|
87
|
+
<div
|
|
88
|
+
class="canvas-toolbar-history items-center gap-1 {vertical ? 'flex flex-col is-upright' : ''}"
|
|
89
|
+
>
|
|
87
90
|
<Separator orientation={vertical ? 'horizontal' : 'vertical'} class={vertical ? 'w-5' : 'h-5 min-h-0'} />
|
|
88
91
|
<ToolButton label={$t('canvas.tool.undo')} disabled={!state.canUndo} onclick={() => void host.undo()}>
|
|
89
92
|
<IconArrowBackUp class="rtl:-scale-x-100" />
|
|
@@ -93,3 +96,18 @@
|
|
|
93
96
|
</ToolButton>
|
|
94
97
|
</div>
|
|
95
98
|
</div>
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
/* Tailwind container variants from `floatingCard.ts` are not emitted in the site dev bundle; keep Figma's 384px cutoff on the board container. */
|
|
102
|
+
.canvas-toolbar-history {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
.canvas-toolbar-history.is-upright {
|
|
106
|
+
display: flex;
|
|
107
|
+
}
|
|
108
|
+
@container (min-width: 384px) {
|
|
109
|
+
.canvas-toolbar-history:not(.is-upright) {
|
|
110
|
+
display: flex;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
</style>
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
data-canvas-color-picker-trigger
|
|
105
105
|
aria-label="{label}: {fieldText}"
|
|
106
106
|
title={$t('canvas.panel.pickColor')}
|
|
107
|
-
class="flex h-9 w-[185px] items-center justify-between gap-2 rounded-lg bg-accent
|
|
107
|
+
class="flex h-9 w-[185px] min-h-9 items-center justify-between gap-2 rounded-lg bg-accent py-0 ps-3 pe-2 text-body text-foreground transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring"
|
|
108
108
|
>
|
|
109
109
|
<span class="truncate tabular-nums">{fieldText}</span>
|
|
110
110
|
<span class="size-5 shrink-0 rounded-md border border-border" style:background={swatchBackground}></span>
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
onInteractOutside={remember}
|
|
121
121
|
onCloseAutoFocus={returnFocusToField}
|
|
122
122
|
class="{CANVAS_OVERLAY_Z_CLASS} w-64 p-0 shadow-floating data-[state=open]:!animate-none data-[state=closed]:!animate-none data-[state=open]:!fade-in-0 data-[state=closed]:!fade-out-0 data-[state=open]:!duration-0 data-[state=closed]:!duration-0 {OVERLAY_REDUCED_MOTION_CLASSES}"
|
|
123
|
+
data-canvas-ui
|
|
123
124
|
data-canvas-color-picker
|
|
124
125
|
>
|
|
125
126
|
{#if allowNone}
|