@widgetic/canvas 0.5.35 → 0.5.36
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 +105 -36
- package/dist/canvas/DomCanvas.svelte +454 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +222 -0
- package/dist/canvas/boardFrame.d.ts +13 -0
- package/dist/canvas/boardFrame.js +13 -0
- package/dist/canvas/boardSurface.d.ts +9 -0
- package/dist/canvas/boardSurface.js +9 -0
- package/dist/canvas/chromeLayout.d.ts +76 -0
- package/dist/canvas/chromeLayout.js +121 -0
- package/dist/canvas/emptyBoardHint.d.ts +17 -0
- package/dist/canvas/emptyBoardHint.js +12 -0
- package/dist/canvas/eventScope.d.ts +1 -1
- package/dist/canvas/eventScope.js +1 -1
- package/dist/canvas/host/CanvasHost.d.ts +351 -0
- package/dist/canvas/host/CanvasHost.js +1740 -0
- package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
- package/dist/canvas/host/CanvasHostApi.js +95 -0
- package/dist/canvas/host/browserServices.d.ts +46 -0
- package/dist/canvas/host/browserServices.js +167 -0
- package/dist/canvas/host/conversion.d.ts +51 -0
- package/dist/canvas/host/conversion.js +123 -0
- package/dist/canvas/host/hostObject.d.ts +40 -0
- package/dist/canvas/host/hostObject.js +93 -0
- package/dist/canvas/host/pageEvents.d.ts +24 -0
- package/dist/canvas/host/pageEvents.js +35 -0
- package/dist/canvas/host/screenRects.d.ts +66 -0
- package/dist/canvas/host/screenRects.js +102 -0
- package/dist/canvas/host/strokeSnap.d.ts +67 -0
- package/dist/canvas/host/strokeSnap.js +165 -0
- package/dist/canvas/index.d.ts +7 -7
- package/dist/canvas/index.js +8 -8
- package/dist/canvas/openMarks.d.ts +17 -0
- package/dist/canvas/openMarks.js +26 -0
- package/dist/canvas/panZoomPosition.d.ts +15 -0
- package/dist/canvas/panZoomPosition.js +16 -0
- package/dist/canvas/preferredTextFont.d.ts +12 -0
- package/dist/canvas/preferredTextFont.js +38 -0
- package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
- package/dist/canvas/shapes/ShapeLibrary.js +13 -1
- package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
- package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
- package/dist/canvas/toolbarPosition.d.ts +11 -11
- package/dist/canvas/toolbarPosition.js +11 -24
- package/dist/canvas/types.d.ts +14 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
- package/dist/canvas/ui/CanvasHint.svelte +20 -0
- package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
- package/dist/canvas/ui/ColorField.svelte +155 -0
- package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
- package/dist/canvas/ui/LoadNotice.svelte +39 -0
- package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
- package/dist/canvas/ui/SelectionPanel.svelte +300 -0
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
- package/dist/canvas/ui/SelectorBar.svelte +82 -0
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
- package/dist/canvas/ui/ShapesMenu.svelte +185 -0
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/ToolButton.svelte +78 -0
- package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
- package/dist/canvas/ui/WidgetActions.svelte +152 -0
- package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
- package/dist/canvas/ui/ZoomControl.svelte +89 -0
- package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
- package/dist/canvas/ui/colorModel.d.ts +18 -0
- package/dist/canvas/ui/colorModel.js +85 -0
- package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
- package/dist/canvas/ui/colorPickerMessages.js +15 -0
- package/dist/canvas/ui/floatingCard.d.ts +107 -0
- package/dist/canvas/ui/floatingCard.js +107 -0
- package/dist/canvas/ui/floatingLayer.d.ts +21 -0
- package/dist/canvas/ui/floatingLayer.js +52 -0
- package/dist/canvas/ui/icons.d.ts +12 -0
- package/dist/canvas/ui/icons.js +7 -0
- package/dist/canvas/ui/keyHints.d.ts +27 -0
- package/dist/canvas/ui/keyHints.js +43 -0
- package/dist/canvas/ui/popoverSide.d.ts +5 -0
- package/dist/canvas/ui/popoverSide.js +20 -0
- package/dist/canvas/ui/selectionTraits.d.ts +61 -0
- package/dist/canvas/ui/selectionTraits.js +99 -0
- package/dist/canvas/view/CanvasStage.svelte +132 -0
- package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
- package/dist/canvas/view/EraserTrail.svelte +50 -0
- package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
- package/dist/canvas/view/ObjectView.svelte +245 -0
- package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
- package/dist/canvas/view/SelectionOverlay.svelte +487 -0
- package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
- package/dist/canvas/view/TextEditor.svelte +76 -0
- package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.js +34 -0
- package/dist/canvas/view/geometry.d.ts +169 -0
- package/dist/canvas/view/geometry.js +272 -0
- package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +2 -2
- package/dist/engine/EngineCore.d.ts +273 -0
- package/dist/engine/EngineCore.js +1051 -0
- package/dist/engine/codec/canvasDocument.d.ts +57 -0
- package/dist/engine/codec/canvasDocument.js +471 -0
- package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
- package/dist/engine/codec/hostReadableKeys.js +25 -0
- package/dist/engine/core/arrange.d.ts +20 -0
- package/dist/engine/core/arrange.js +81 -0
- package/dist/engine/core/arrow.d.ts +91 -0
- package/dist/engine/core/arrow.js +182 -0
- package/dist/engine/core/brush.d.ts +68 -0
- package/dist/engine/core/brush.js +173 -0
- package/dist/engine/core/defaults.d.ts +70 -0
- package/dist/engine/core/defaults.js +158 -0
- package/dist/engine/core/freehand.d.ts +130 -0
- package/dist/engine/core/freehand.js +430 -0
- package/dist/engine/core/geometry.d.ts +44 -0
- package/dist/engine/core/geometry.js +216 -0
- package/dist/engine/core/history.d.ts +39 -0
- package/dist/engine/core/history.js +69 -0
- package/dist/engine/core/hitTest.d.ts +54 -0
- package/dist/engine/core/hitTest.js +298 -0
- package/dist/engine/core/matrix.d.ts +47 -0
- package/dist/engine/core/matrix.js +101 -0
- package/dist/engine/core/pathData.d.ts +50 -0
- package/dist/engine/core/pathData.js +550 -0
- package/dist/engine/core/rotationReset.d.ts +10 -0
- package/dist/engine/core/rotationReset.js +17 -0
- package/dist/engine/core/scene.d.ts +99 -0
- package/dist/engine/core/scene.js +450 -0
- package/dist/engine/core/scribble.d.ts +64 -0
- package/dist/engine/core/scribble.js +121 -0
- package/dist/engine/core/shapePaths.d.ts +34 -0
- package/dist/engine/core/shapePaths.js +69 -0
- package/dist/engine/core/shapeTools.d.ts +80 -0
- package/dist/engine/core/shapeTools.js +161 -0
- package/dist/engine/core/snapping.d.ts +64 -0
- package/dist/engine/core/snapping.js +164 -0
- package/dist/engine/core/style.d.ts +40 -0
- package/dist/engine/core/style.js +151 -0
- package/dist/engine/core/transform.d.ts +79 -0
- package/dist/engine/core/transform.js +258 -0
- package/dist/engine/core/types.d.ts +238 -0
- package/dist/engine/core/types.js +31 -0
- package/dist/engine/core/viewport.d.ts +32 -0
- package/dist/engine/core/viewport.js +84 -0
- package/dist/engine/input/PointerController.d.ts +38 -0
- package/dist/engine/input/PointerController.js +545 -0
- package/dist/engine/input/arrowHandles.d.ts +38 -0
- package/dist/engine/input/arrowHandles.js +60 -0
- package/dist/engine/input/gestures.d.ts +79 -0
- package/dist/engine/input/gestures.js +769 -0
- package/dist/engine/input/hoverCursor.d.ts +29 -0
- package/dist/engine/input/hoverCursor.js +23 -0
- package/dist/engine/input/keyboard.d.ts +75 -0
- package/dist/engine/input/keyboard.js +264 -0
- package/dist/engine/input/selectionHandles.d.ts +89 -0
- package/dist/engine/input/selectionHandles.js +169 -0
- package/dist/engine/input/types.d.ts +82 -0
- package/dist/engine/input/types.js +5 -0
- package/dist/engine/render/rasterize.d.ts +74 -0
- package/dist/engine/render/rasterize.js +273 -0
- package/dist/engine/state.d.ts +124 -0
- package/dist/engine/state.js +47 -0
- package/dist/engine/text/layoutText.d.ts +53 -0
- package/dist/engine/text/layoutText.js +170 -0
- package/dist/engine/widgets.d.ts +124 -0
- package/dist/engine/widgets.js +345 -0
- package/dist/i18n/labels.d.ts +4 -15
- package/dist/i18n/labels.js +33 -53
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +51 -122
- package/dist/i18n/messages.js +58 -131
- package/dist/i18n/shortcuts.d.ts +0 -1
- package/dist/i18n/shortcuts.js +2 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13363
- package/dist/canvas/Canvas.svelte.d.ts +0 -286
- package/dist/canvas/CanvasToolbar.svelte +0 -1498
- package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
- package/dist/canvas/ContextMenu.svelte +0 -305
- package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
- package/dist/canvas/PanZoomPanel.svelte +0 -478
- package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
- package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
- package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
- package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
- package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
- package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
- package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
- package/dist/canvas/shadowRootText.d.ts +0 -5
- package/dist/canvas/shadowRootText.js +0 -43
- package/dist/canvas/shapes/FrameShape.d.ts +0 -97
- package/dist/canvas/shapes/FrameShape.js +0 -953
- package/dist/canvas/shapes/ImageShape.d.ts +0 -47
- package/dist/canvas/shapes/ImageShape.js +0 -339
- package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
- package/dist/canvas/shapes/WidgetShape.js +0 -200
- package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
- package/dist/canvas/widgetPreviewGeometry.js +0 -66
- package/dist/i18n/shapeWords.d.ts +0 -30
- package/dist/i18n/shapeWords.js +0 -36
- package/dist/i18n/slots.d.ts +0 -20
- package/dist/i18n/slots.js +0 -40
|
@@ -1,1498 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte';
|
|
3
|
-
import Tooltip from '../components/Tooltip.svelte';
|
|
4
|
-
import { eventIsForScope, getEventOrigin, getFocusedElementIn } from './eventScope';
|
|
5
|
-
import { SHAPE_LIBRARY, getShapesByCategory, type LibraryShape } from './shapes/ShapeLibrary';
|
|
6
|
-
import { useCanvasLanguage } from '../i18n/language.js';
|
|
7
|
-
import { categoryLabel, toolTitle } from '../i18n/labels.js';
|
|
8
|
-
import type { CanvasMessageKey } from '../i18n/messages.js';
|
|
9
|
-
import { TOOL_KEYS, shortcutGroups } from '../i18n/shortcuts.js';
|
|
10
|
-
import { sentenceParts } from '../i18n/slots.js';
|
|
11
|
-
|
|
12
|
-
// The words of the toolbar, in the language of the canvas it is on (English when it is used on its own)
|
|
13
|
-
const { t } = useCanvasLanguage();
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* COMPONENT PROPS
|
|
17
|
-
*/
|
|
18
|
-
// Tool type definition
|
|
19
|
-
type ToolName = 'select' | 'erase' | 'draw' | 'arrow' | 'text' | 'rect' | 'circle' | 'circle-true' | 'triangle' | 'frame' | 'pan' | 'image' | 'video' | 'library-shape';
|
|
20
|
-
// Shape tool sub-type for the shapes dropdown (Arrow is a dedicated button, not in dropdown)
|
|
21
|
-
type ShapeToolName = 'rect' | 'circle' | 'circle-true' | 'triangle' | 'arrow';
|
|
22
|
-
|
|
23
|
-
// Class
|
|
24
|
-
let className = '';
|
|
25
|
-
export { className as class };
|
|
26
|
-
// Style
|
|
27
|
-
export let style = '';
|
|
28
|
-
// component state props
|
|
29
|
-
export let activeTool: ToolName = 'select';
|
|
30
|
-
export let activeClass: string = 'wdg-tool-active';
|
|
31
|
-
export let inactiveClass: string = 'wdg-tool-inactive';
|
|
32
|
-
export let buttonClass: string = 'wdg-tool-bt';
|
|
33
|
-
|
|
34
|
-
// tools handler functions
|
|
35
|
-
export let onSelectSelectTool: () => void = () => {};
|
|
36
|
-
export let onSelectEraseTool: () => void = () => {};
|
|
37
|
-
export let onSelectDrawTool: () => void = () => {};
|
|
38
|
-
export let onSelectShapeTool: (shapeType: ShapeToolName) => void = () => {};
|
|
39
|
-
export let onSelectFrameTool: () => void = () => {};
|
|
40
|
-
export let onSelectTextTool: () => void = () => {};
|
|
41
|
-
export let onSelectPanTool: () => void = () => {};
|
|
42
|
-
export let onSelectImageTool: () => void = () => {};
|
|
43
|
-
export let onSelectVideoTool: () => void = () => {};
|
|
44
|
-
// Zoom callbacks — optional, used for Ctrl+/Ctrl- shortcuts
|
|
45
|
-
export let onZoomIn: () => void = () => {};
|
|
46
|
-
export let onZoomOut: () => void = () => {};
|
|
47
|
-
export let onZoomReset: () => void = () => {};
|
|
48
|
-
export let onZoomFit: () => void = () => {};
|
|
49
|
-
|
|
50
|
-
// actions handler functions
|
|
51
|
-
export let onGroupSelection: () => void = () => {};
|
|
52
|
-
export let onUngroupSelection: () => void = () => {};
|
|
53
|
-
export let onDuplicateSelection: () => void = () => {};
|
|
54
|
-
export let onSelectAllObjects: () => void = () => {};
|
|
55
|
-
export let onClearAllObjects: () => void = () => {};
|
|
56
|
-
|
|
57
|
-
// ── Undo / Redo ────────────────────────────────────────────────────────────
|
|
58
|
-
export let onUndo: () => void = () => {};
|
|
59
|
-
export let onRedo: () => void = () => {};
|
|
60
|
-
/** Disables the Undo button when there is no prior state to go back to. */
|
|
61
|
-
export let canUndo: boolean = false;
|
|
62
|
-
/** Disables the Redo button when there is no future state to redo to. */
|
|
63
|
-
export let canRedo: boolean = false;
|
|
64
|
-
|
|
65
|
-
// ── Sticky tool mode ────────────────────────────────────────────────────────
|
|
66
|
-
/** When true, the drawing tool stays active after placing a shape. */
|
|
67
|
-
export let stickyToolEnabled: boolean = false;
|
|
68
|
-
export let onToggleStickyTool: () => void = () => {};
|
|
69
|
-
|
|
70
|
-
/** Pencil, eraser, select, arrow and text. Off after the widget has been generated. */
|
|
71
|
-
export let showDrawingTools: boolean = true;
|
|
72
|
-
|
|
73
|
-
// ── Shape library (special shapes: media, arrows, UI) ────────────────────
|
|
74
|
-
/** Called when user clicks a library shape. Canvas inserts it as a Path. */
|
|
75
|
-
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
76
|
-
* init-set contract without the unused-reactive warning. */
|
|
77
|
-
export const onInsertLibraryShape: (shapeKey: string, pathData: string) => void = () => {};
|
|
78
|
-
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */
|
|
79
|
-
export let onSelectLibraryShapeTool: (shapeKey: string, pathData: string) => void = () => {};
|
|
80
|
-
|
|
81
|
-
/** Extra tools (undo, redo, lock, shapes). Arrow stays on the simple bar. */
|
|
82
|
-
export let advancedFeatures: boolean = false;
|
|
83
|
-
/**
|
|
84
|
-
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
85
|
-
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
86
|
-
*/
|
|
87
|
-
export let mediaBtsOnBar: boolean = true;
|
|
88
|
-
|
|
89
|
-
$: showMediaOnBar = advancedFeatures && mediaBtsOnBar;
|
|
90
|
-
$: showMediaInDropdown = !showMediaOnBar;
|
|
91
|
-
|
|
92
|
-
// Pre-group shapes for the dropdown
|
|
93
|
-
const libraryShapesByCategory = getShapesByCategory();
|
|
94
|
-
// The category the menu shows first, as a grid with the two media tools. A name the shape library saves (not a word a person reads: categoryLabel says it).
|
|
95
|
-
const GEOMETRIC_CATEGORY = 'Geometric Shapes';
|
|
96
|
-
|
|
97
|
-
// add shapes handler functions
|
|
98
|
-
export let addText: () => void = () => {};
|
|
99
|
-
export let addRect: () => void = () => {};
|
|
100
|
-
export let addTriangle: () => void = () => {};
|
|
101
|
-
export let addCircle: () => void = () => {};
|
|
102
|
-
export let addFrame: () => void = () => {};
|
|
103
|
-
export let addImage: () => void = () => {};
|
|
104
|
-
|
|
105
|
-
// ─── Shapes + Image dropdown state ───
|
|
106
|
-
// The last-selected tool within the dropdown (shapes, image, OR library shape).
|
|
107
|
-
type DropdownToolName = ShapeToolName | 'image' | 'video' | 'frame' | 'library-shape';
|
|
108
|
-
let lastSelectedDropdownTool: DropdownToolName = 'rect';
|
|
109
|
-
// When a library shape was last selected, store its info for the trigger button
|
|
110
|
-
let lastSelectedLibraryShape: LibraryShape | null = null;
|
|
111
|
-
let shapesDropdownOpen = false;
|
|
112
|
-
// The shapes menu is part of the advanced toolbar. Close it when that mode turns off.
|
|
113
|
-
$: if (!advancedFeatures) shapesDropdownOpen = false;
|
|
114
|
-
let shapesDropdownNeedsScroll = false;
|
|
115
|
-
// DEV FLAG: when true the dropdown stays open after selecting a shape so
|
|
116
|
-
// multiple shapes can be placed in a row. Set to false for production.
|
|
117
|
-
const KEEP_SHAPES_DROPDOWN_OPEN = true;
|
|
118
|
-
// Position for the dropdown (absolute within canvas-container)
|
|
119
|
-
let dropdownLeft = 0;
|
|
120
|
-
// When opening ABOVE: distance from the container's bottom edge (CSS 'bottom' property)
|
|
121
|
-
let dropdownBottomOffset = 0;
|
|
122
|
-
// When opening BELOW: distance from the container's top edge (CSS 'top' property)
|
|
123
|
-
let dropdownTopOffset = 0;
|
|
124
|
-
// Minimum width of the dropdown — at least as wide as the trigger button
|
|
125
|
-
let dropdownMinWidth = 0;
|
|
126
|
-
let dropdownMaxHeight = 400;
|
|
127
|
-
// True when the dropdown should open ABOVE the button (toolbar is at bottom of canvas)
|
|
128
|
-
let dropdownOpenAbove = false;
|
|
129
|
-
let dropdownTriggerEl: HTMLElement | null = null;
|
|
130
|
-
// The toolbar's own element: tells which tree the toolbar lives in (the page, or a shadow root on a partner's page),
|
|
131
|
-
// which decides what its keyboard shortcuts and zoom brakes may react to. See eventScope.ts.
|
|
132
|
-
let toolbarRootEl: HTMLElement | null = null;
|
|
133
|
-
|
|
134
|
-
// Map shape type to display info (Arrow is a dedicated button, not in this map).
|
|
135
|
-
const shapeInfo: Record<ShapeToolName, { icon: string; iconSvg: string; nameKey: CanvasMessageKey; key: string }> = {
|
|
136
|
-
rect: {
|
|
137
|
-
icon: '⬜',
|
|
138
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
139
|
-
nameKey: 'canvas.tool.rectangle',
|
|
140
|
-
key: TOOL_KEYS.rectangle,
|
|
141
|
-
},
|
|
142
|
-
triangle: {
|
|
143
|
-
icon: '△',
|
|
144
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polygon points="12,3 22,21 2,21" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`,
|
|
145
|
-
nameKey: 'canvas.tool.triangle',
|
|
146
|
-
key: TOOL_KEYS.triangle,
|
|
147
|
-
},
|
|
148
|
-
circle: {
|
|
149
|
-
icon: '⚪',
|
|
150
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><ellipse cx="12" cy="12" rx="10" ry="7" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
151
|
-
nameKey: 'canvas.tool.ellipse',
|
|
152
|
-
key: TOOL_KEYS.ellipse,
|
|
153
|
-
},
|
|
154
|
-
'circle-true': {
|
|
155
|
-
icon: '⚪',
|
|
156
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>`,
|
|
157
|
-
nameKey: 'canvas.tool.circle',
|
|
158
|
-
key: '',
|
|
159
|
-
},
|
|
160
|
-
arrow: {
|
|
161
|
-
icon: '↗',
|
|
162
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M6 18C6 18 6.06617 12.5162 8.00001 10.5521C10.862 7.64522 19 9 19 9M19 9L15 5M19 9L15 13" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
|
|
163
|
-
nameKey: 'canvas.tool.arrow',
|
|
164
|
-
key: TOOL_KEYS.arrow,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// Image dropdown entry — placed at the bottom of the shapes dropdown with a divider
|
|
169
|
-
const imageDropdownInfo = {
|
|
170
|
-
iconSvg: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><rect x="1" y="2" width="14" height="12" rx="1.5" fill="white" stroke="#9ca3af" stroke-width="1.5"/><polyline points="1.5,10.5 5,6.5 8,9 11,6.5 14.5,10.5" fill="none" stroke="#9ca3af" stroke-width="1.2"/><circle cx="11.5" cy="5" r="1.2" fill="#9ca3af"/></svg>`,
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// The currently displayed tool in the dropdown button (active tool if it's a dropdown tool, else last selected)
|
|
174
|
-
const mediaToolInfo: Record<'frame' | 'image' | 'video', { iconSvg: string; nameKey: CanvasMessageKey; key: string }> = {
|
|
175
|
-
frame: {
|
|
176
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 3v6"/></svg>`,
|
|
177
|
-
nameKey: 'canvas.tool.frame',
|
|
178
|
-
key: TOOL_KEYS.frame,
|
|
179
|
-
},
|
|
180
|
-
image: {
|
|
181
|
-
iconSvg: imageDropdownInfo.iconSvg,
|
|
182
|
-
nameKey: 'canvas.tool.image',
|
|
183
|
-
key: TOOL_KEYS.image,
|
|
184
|
-
},
|
|
185
|
-
video: {
|
|
186
|
-
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="14" height="12" rx="2"/><path d="M16 10l6-3v10l-6-3z"/></svg>`,
|
|
187
|
-
nameKey: 'canvas.tool.video',
|
|
188
|
-
key: '',
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const dropdownTools: DropdownToolName[] = ['rect', 'circle', 'circle-true', 'triangle', 'image', 'video', 'frame', 'library-shape'];
|
|
193
|
-
$: activeDropdownTool = dropdownTools.includes(activeTool as DropdownToolName)
|
|
194
|
-
? (activeTool as DropdownToolName)
|
|
195
|
-
: lastSelectedDropdownTool;
|
|
196
|
-
$: activeDropdownIsActive = dropdownTools.includes(activeTool as DropdownToolName);
|
|
197
|
-
|
|
198
|
-
// Backwards-compat aliases used in template
|
|
199
|
-
$: activeShapeInDropdown = activeDropdownTool as ShapeToolName;
|
|
200
|
-
$: activeShapeIsActive = activeDropdownIsActive;
|
|
201
|
-
|
|
202
|
-
function selectShape(shape: ShapeToolName) {
|
|
203
|
-
lastSelectedDropdownTool = shape;
|
|
204
|
-
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
205
|
-
onSelectShapeTool(shape);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function selectImageFromDropdown() {
|
|
209
|
-
lastSelectedDropdownTool = 'image';
|
|
210
|
-
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
211
|
-
onSelectImageTool();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function selectFrameFromDropdown() {
|
|
215
|
-
lastSelectedDropdownTool = 'frame';
|
|
216
|
-
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
217
|
-
onSelectFrameTool();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function selectVideoFromDropdown() {
|
|
221
|
-
lastSelectedDropdownTool = 'video';
|
|
222
|
-
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
223
|
-
onSelectVideoTool();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function selectLibraryShape(shape: LibraryShape) {
|
|
227
|
-
lastSelectedDropdownTool = 'library-shape';
|
|
228
|
-
lastSelectedLibraryShape = shape;
|
|
229
|
-
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
230
|
-
onSelectLibraryShapeTool(shape.key, shape.pathData);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Click action for the main dropdown button (left part)
|
|
234
|
-
function activateDropdownTool() {
|
|
235
|
-
if (activeDropdownTool === 'library-shape' && lastSelectedLibraryShape) {
|
|
236
|
-
selectLibraryShape(lastSelectedLibraryShape);
|
|
237
|
-
} else if (activeDropdownTool === 'image') {
|
|
238
|
-
selectImageFromDropdown();
|
|
239
|
-
} else if (activeDropdownTool === 'video') {
|
|
240
|
-
selectVideoFromDropdown();
|
|
241
|
-
} else if (activeDropdownTool === 'frame') {
|
|
242
|
-
selectFrameFromDropdown();
|
|
243
|
-
} else {
|
|
244
|
-
selectShape(activeDropdownTool as ShapeToolName);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
$: mediaTrigger = (activeDropdownTool === 'frame' || activeDropdownTool === 'image' || activeDropdownTool === 'video')
|
|
249
|
-
? mediaToolInfo[activeDropdownTool]
|
|
250
|
-
: null;
|
|
251
|
-
|
|
252
|
-
// The tool the main button of the shapes menu stands for: the message that names it, and the key that chooses it
|
|
253
|
-
// (a shape of the library has no key)
|
|
254
|
-
$: dropdownToolNameKey = (activeDropdownTool === 'library-shape' && lastSelectedLibraryShape)
|
|
255
|
-
? lastSelectedLibraryShape.labelKey
|
|
256
|
-
: mediaTrigger
|
|
257
|
-
? mediaTrigger.nameKey
|
|
258
|
-
: shapeInfo[activeDropdownTool as ShapeToolName]?.nameKey ?? 'canvas.tool.shapes';
|
|
259
|
-
$: dropdownToolKey = (activeDropdownTool === 'library-shape' && lastSelectedLibraryShape)
|
|
260
|
-
? ''
|
|
261
|
-
: mediaTrigger
|
|
262
|
-
? mediaTrigger.key
|
|
263
|
-
: shapeInfo[activeDropdownTool as ShapeToolName]?.key ?? '';
|
|
264
|
-
|
|
265
|
-
// Tooltip text for the main dropdown button
|
|
266
|
-
$: dropdownButtonTooltip = toolTitle(dropdownToolNameKey, dropdownToolKey, $t);
|
|
267
|
-
|
|
268
|
-
// Dropdown width — sized to fit 3 × 40px icon grid with minimal side padding
|
|
269
|
-
const DROPDOWN_WIDTH = 152;
|
|
270
|
-
|
|
271
|
-
function computeDropdownPosition() {
|
|
272
|
-
if (!dropdownTriggerEl) return;
|
|
273
|
-
const rect = dropdownTriggerEl.getBoundingClientRect();
|
|
274
|
-
const containerEl = dropdownTriggerEl.closest('.canvas-container') as HTMLElement | null;
|
|
275
|
-
const containerRect = containerEl
|
|
276
|
-
? containerEl.getBoundingClientRect()
|
|
277
|
-
: { left: 0, top: 0, bottom: window.innerHeight, height: window.innerHeight };
|
|
278
|
-
|
|
279
|
-
const estimatedDropdownHeight = 150;
|
|
280
|
-
dropdownOpenAbove = rect.top > estimatedDropdownHeight;
|
|
281
|
-
|
|
282
|
-
// Center the dropdown horizontally relative to the trigger button
|
|
283
|
-
const buttonCenterX = rect.left + rect.width / 2 - containerRect.left;
|
|
284
|
-
dropdownLeft = Math.max(4, buttonCenterX - DROPDOWN_WIDTH / 2);
|
|
285
|
-
|
|
286
|
-
if (dropdownOpenAbove) {
|
|
287
|
-
dropdownBottomOffset = containerRect.height - (rect.top - containerRect.top) + 8;
|
|
288
|
-
dropdownMaxHeight = rect.top - containerRect.top - 16;
|
|
289
|
-
} else {
|
|
290
|
-
dropdownTopOffset = rect.bottom - containerRect.top + 8;
|
|
291
|
-
dropdownMaxHeight = containerRect.bottom - rect.bottom - 16;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
dropdownMinWidth = DROPDOWN_WIDTH;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function toggleShapesDropdown(e?: MouseEvent) {
|
|
298
|
-
e?.stopPropagation();
|
|
299
|
-
e?.preventDefault();
|
|
300
|
-
if (!shapesDropdownOpen) {
|
|
301
|
-
computeDropdownPosition();
|
|
302
|
-
}
|
|
303
|
-
shapesDropdownOpen = !shapesDropdownOpen;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Close dropdown when clicking outside
|
|
307
|
-
function handleOutsideClick(e: MouseEvent) {
|
|
308
|
-
// Where the click really started: a listener on window is told the shadow root's host for a click from inside it
|
|
309
|
-
const target = getEventOrigin(e);
|
|
310
|
-
if (!target?.closest('.shapes-split-ct') && !target?.closest('.shapes-dropdown-menu-fixed')) {
|
|
311
|
-
shapesDropdownOpen = false;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// Reposition dropdown on window resize so it stays aligned with the trigger
|
|
316
|
-
function handleWindowResize() {
|
|
317
|
-
if (shapesDropdownOpen) computeDropdownPosition();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// ─── Keyboard shortcuts panel state ───
|
|
321
|
-
// Exported so Canvas.svelte can lift state and share it with PanZoomPanel's toggle button
|
|
322
|
-
export let shortcutsPanelOpen = false;
|
|
323
|
-
export let onShortcutsToggle: () => void = () => { shortcutsPanelOpen = !shortcutsPanelOpen; };
|
|
324
|
-
|
|
325
|
-
// The shortcuts are listed in i18n/shortcuts.ts: each key is a key cap, a word (a message) or the '+' between two keys.
|
|
326
|
-
// Here they are said in the language of the canvas, and said again when the page sets another language.
|
|
327
|
-
$: translatedShortcutGroups = shortcutGroups($t);
|
|
328
|
-
// The line under the list is a sentence with three parts drawn as keys: the translation says where each one goes
|
|
329
|
-
$: footerParts = sentenceParts('canvas.shortcuts.footer', ['key', 'hint', 'icon'], $t);
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Handle keyboard shortcuts
|
|
333
|
-
*/
|
|
334
|
-
function handleKeydown(event: KeyboardEvent) {
|
|
335
|
-
// Not for a key pressed elsewhere on a page that has this toolbar in a shadow root
|
|
336
|
-
if (!eventIsForScope(event, toolbarRootEl)) return;
|
|
337
|
-
// Toggle shortcuts panel with '?'
|
|
338
|
-
if (event.key === '?' && !event.ctrlKey && !event.metaKey) {
|
|
339
|
-
const activeElement = getFocusedElementIn(toolbarRootEl) as HTMLElement | null;
|
|
340
|
-
if (activeElement) {
|
|
341
|
-
const tagName = activeElement.tagName;
|
|
342
|
-
if (tagName === 'INPUT' || tagName === 'TEXTAREA' || activeElement.isContentEditable) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
event.preventDefault();
|
|
347
|
-
onShortcutsToggle();
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// Close panel / dropdown with Escape
|
|
352
|
-
if (event.key === 'Escape') {
|
|
353
|
-
shortcutsPanelOpen = false;
|
|
354
|
-
shapesDropdownOpen = false;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Ctrl / Cmd + zoom shortcuts
|
|
358
|
-
if (event.ctrlKey || event.metaKey) {
|
|
359
|
-
const key = event.key;
|
|
360
|
-
if (key === '+' || key === '=' || key === 'Add') {
|
|
361
|
-
event.preventDefault();
|
|
362
|
-
onZoomIn();
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
if (key === '-' || key === 'Subtract') {
|
|
366
|
-
event.preventDefault();
|
|
367
|
-
onZoomOut();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (key === '0') {
|
|
371
|
-
event.preventDefault();
|
|
372
|
-
onZoomReset();
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if (key === '9') {
|
|
376
|
-
event.preventDefault();
|
|
377
|
-
onZoomFit();
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
// Other Ctrl/Cmd shortcuts are handled in Canvas.svelte — skip here
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// Skip if focus is on text input
|
|
385
|
-
const activeElement = getFocusedElementIn(toolbarRootEl) as HTMLElement | null;
|
|
386
|
-
if (activeElement) {
|
|
387
|
-
const tagName = activeElement.tagName;
|
|
388
|
-
const isTextInput = tagName === 'INPUT' || tagName === 'TEXTAREA';
|
|
389
|
-
if (isTextInput || activeElement.isContentEditable) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Skip other alt combinations (handled in Canvas.svelte)
|
|
395
|
-
if (event.altKey) return;
|
|
396
|
-
|
|
397
|
-
const key = event.key.toUpperCase();
|
|
398
|
-
// Hidden tools must not answer their keys. The bar is gone; the letter would still start a pencil or a text box.
|
|
399
|
-
const drawingKey = key === 'V' || key === 'E' || key === 'D' || key === 'A' || key === 'T';
|
|
400
|
-
const shapeKey = key === 'R' || key === 'G' || key === 'O' || key === 'F' || key === 'I' || key === 'H';
|
|
401
|
-
if (drawingKey && !showDrawingTools) return;
|
|
402
|
-
if (shapeKey && !advancedFeatures) return;
|
|
403
|
-
|
|
404
|
-
// Map keys to handlers — using current prop references
|
|
405
|
-
switch (key) {
|
|
406
|
-
case 'V': event.preventDefault(); onSelectSelectTool(); break;
|
|
407
|
-
case 'E': event.preventDefault(); onSelectEraseTool(); break;
|
|
408
|
-
case 'D': event.preventDefault(); onSelectDrawTool(); break;
|
|
409
|
-
case 'H': event.preventDefault(); onSelectPanTool(); break;
|
|
410
|
-
case 'A': event.preventDefault(); selectShape('arrow'); break;
|
|
411
|
-
case 'R': event.preventDefault(); selectShape('rect'); break;
|
|
412
|
-
case 'G': event.preventDefault(); selectShape('triangle'); break;
|
|
413
|
-
case 'O': event.preventDefault(); selectShape('circle'); break;
|
|
414
|
-
case 'F': event.preventDefault(); onSelectFrameTool(); break;
|
|
415
|
-
case 'T': event.preventDefault(); onSelectTextTool(); break;
|
|
416
|
-
case 'I': event.preventDefault(); onSelectImageTool(); break;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// Capture-phase handler to prevent browser zoom (Cmd/Ctrl + = / - / 0 / 9).
|
|
421
|
-
// Must use capture:true to intercept before the browser handles it natively.
|
|
422
|
-
// We check both event.key (character-based) AND event.code (physical key-based)
|
|
423
|
-
// so this works across keyboard layouts and Numpad keys.
|
|
424
|
-
function preventBrowserZoom(event: KeyboardEvent) {
|
|
425
|
-
// Only the zoom of a visitor who is in the canvas: on a partner's page (a canvas in a shadow root) the page's own
|
|
426
|
-
// zoom keys are the visitor's, wherever else on the page they are pressed.
|
|
427
|
-
if (!eventIsForScope(event, toolbarRootEl)) return;
|
|
428
|
-
if (event.ctrlKey || event.metaKey) {
|
|
429
|
-
const key = event.key;
|
|
430
|
-
const code = event.code;
|
|
431
|
-
const isZoomKey =
|
|
432
|
-
// Character-based (varies by layout)
|
|
433
|
-
key === '=' || key === '+' || key === '-' ||
|
|
434
|
-
key === '0' || key === '9' ||
|
|
435
|
-
key === 'Add' || key === 'Subtract' ||
|
|
436
|
-
// Physical key codes (layout-independent) — covers Numpad keys too
|
|
437
|
-
code === 'Equal' || code === 'Minus' ||
|
|
438
|
-
code === 'Digit0' || code === 'Digit9' ||
|
|
439
|
-
code === 'NumpadAdd' || code === 'NumpadSubtract' || code === 'NumpadEqual';
|
|
440
|
-
if (isZoomKey) {
|
|
441
|
-
event.preventDefault();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// Prevent browser pinch-to-zoom and Ctrl+wheel zoom (trackpad gesture).
|
|
447
|
-
// passive:false is required so we can call preventDefault().
|
|
448
|
-
function preventWheelZoom(event: WheelEvent) {
|
|
449
|
-
// Only over the canvas (see preventBrowserZoom)
|
|
450
|
-
if (!eventIsForScope(event, toolbarRootEl)) return;
|
|
451
|
-
if (event.ctrlKey || event.metaKey) {
|
|
452
|
-
event.preventDefault();
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Use onMount's return function for cleanup — this only runs in browser
|
|
457
|
-
onMount(() => {
|
|
458
|
-
window.addEventListener('keydown', handleKeydown);
|
|
459
|
-
window.addEventListener('click', handleOutsideClick);
|
|
460
|
-
window.addEventListener('resize', handleWindowResize);
|
|
461
|
-
// Capture phase: intercept browser zoom keys before the browser acts on them
|
|
462
|
-
document.addEventListener('keydown', preventBrowserZoom, { capture: true });
|
|
463
|
-
// Non-passive wheel listener to block Ctrl/Cmd + scroll (trackpad pinch zoom)
|
|
464
|
-
document.addEventListener('wheel', preventWheelZoom as EventListener, { passive: false });
|
|
465
|
-
|
|
466
|
-
return () => {
|
|
467
|
-
window.removeEventListener('keydown', handleKeydown);
|
|
468
|
-
window.removeEventListener('click', handleOutsideClick);
|
|
469
|
-
window.removeEventListener('resize', handleWindowResize);
|
|
470
|
-
document.removeEventListener('keydown', preventBrowserZoom, { capture: true } as EventListenerOptions);
|
|
471
|
-
document.removeEventListener('wheel', preventWheelZoom as EventListener);
|
|
472
|
-
};
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
/** Svelte action: applies negative right margin only when scrollable,
|
|
476
|
-
* so the scrollbar overlays the parent padding zone. */
|
|
477
|
-
function overlayScrollbar(node: HTMLElement) {
|
|
478
|
-
function check() {
|
|
479
|
-
shapesDropdownNeedsScroll = node.scrollHeight > node.clientHeight;
|
|
480
|
-
}
|
|
481
|
-
const ro = new ResizeObserver(check);
|
|
482
|
-
ro.observe(node);
|
|
483
|
-
check();
|
|
484
|
-
return { destroy() { ro.disconnect(); } };
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
</script>
|
|
488
|
-
|
|
489
|
-
<div bind:this={toolbarRootEl} class="{className ? className + ' ' : ''}canvas-toolbar-el flex flex-col justify-between gap-2" style={style}>
|
|
490
|
-
<!-- Tools Bar -->
|
|
491
|
-
<div class="tools-bar-el flex flex-row gap-2 w-full">
|
|
492
|
-
<!-- Scrollable container for tools — overflow-x-auto clips absolute children,
|
|
493
|
-
so dropdowns and tooltips are rendered as siblings OUTSIDE this div -->
|
|
494
|
-
<div class="tools-ct flex flex-row">
|
|
495
|
-
{#if advancedFeatures}
|
|
496
|
-
<Tooltip text={$t('canvas.tool.undoTitle')}>
|
|
497
|
-
<div class="disabled-tooltip-wrap">
|
|
498
|
-
<button
|
|
499
|
-
class="undo-bt {buttonClass} {inactiveClass}"
|
|
500
|
-
onclick={onUndo}
|
|
501
|
-
disabled={!canUndo}
|
|
502
|
-
aria-label={$t('canvas.tool.undo')}
|
|
503
|
-
>
|
|
504
|
-
<svg class="rtl:-scale-x-100" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
505
|
-
<path d="M3 7v6h6"/>
|
|
506
|
-
<path d="M3 13C3 13 5.5 7 12 7c4.42 0 8 3.13 8 7s-3.58 7-8 7a8.23 8.23 0 0 1-5.66-2.34"/>
|
|
507
|
-
</svg>
|
|
508
|
-
</button>
|
|
509
|
-
</div>
|
|
510
|
-
</Tooltip>
|
|
511
|
-
<Tooltip text={$t('canvas.tool.redoTitle')}>
|
|
512
|
-
<div class="disabled-tooltip-wrap">
|
|
513
|
-
<button
|
|
514
|
-
class="redo-bt {buttonClass} {inactiveClass}"
|
|
515
|
-
onclick={onRedo}
|
|
516
|
-
disabled={!canRedo}
|
|
517
|
-
aria-label={$t('canvas.tool.redo')}
|
|
518
|
-
>
|
|
519
|
-
<svg class="rtl:-scale-x-100" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
520
|
-
<path d="M21 7v6h-6"/>
|
|
521
|
-
<path d="M21 13C21 13 18.5 7 12 7c-4.42 0-8 3.13-8 7s3.58 7 8 7a8.23 8.23 0 0 0 5.66-2.34"/>
|
|
522
|
-
</svg>
|
|
523
|
-
</button>
|
|
524
|
-
</div>
|
|
525
|
-
</Tooltip>
|
|
526
|
-
<!-- Hand / Pan — hidden (available in zoom panel) -->
|
|
527
|
-
<!-- <Tooltip text="Hand / Pan (H)">
|
|
528
|
-
<button class="hand-bt {buttonClass} {activeTool === 'pan' ? activeClass : inactiveClass}"
|
|
529
|
-
onclick={onSelectPanTool}
|
|
530
|
-
aria-label="Hand / Pan">
|
|
531
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
532
|
-
<path d="M18 11V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v0"/>
|
|
533
|
-
<path d="M14 10V4a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v2"/>
|
|
534
|
-
<path d="M10 10.5V6a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v8"/>
|
|
535
|
-
<path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/>
|
|
536
|
-
</svg>
|
|
537
|
-
</button>
|
|
538
|
-
</Tooltip> -->
|
|
539
|
-
<Tooltip text={$t(stickyToolEnabled ? 'canvas.tool.stickyOn' : 'canvas.tool.stickyOff')}>
|
|
540
|
-
<button class="sticky-tool-bt {buttonClass} {stickyToolEnabled ? activeClass : inactiveClass}"
|
|
541
|
-
onclick={onToggleStickyTool}
|
|
542
|
-
aria-label={$t('canvas.tool.stickyLabel')}
|
|
543
|
-
aria-pressed={stickyToolEnabled}>
|
|
544
|
-
{#if stickyToolEnabled}
|
|
545
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
546
|
-
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
547
|
-
<path d="M7 11V7a5 5 0 0 1 10 0v4"/>
|
|
548
|
-
</svg>
|
|
549
|
-
{:else}
|
|
550
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
551
|
-
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
|
|
552
|
-
<path d="M7 11V7a5 5 0 0 1 9.9-1"/>
|
|
553
|
-
</svg>
|
|
554
|
-
{/if}
|
|
555
|
-
</button>
|
|
556
|
-
</Tooltip>
|
|
557
|
-
|
|
558
|
-
<div class="toolbar-divider"></div>
|
|
559
|
-
{/if}
|
|
560
|
-
|
|
561
|
-
{#if showDrawingTools}
|
|
562
|
-
<!-- ══ Illustrated tools: Pencil & Eraser — "pulled from sheath" on select ══ -->
|
|
563
|
-
<!-- Each tool is wrapped in a mask container that clips its body at rest.
|
|
564
|
-
When active, overflow becomes visible so the tool "pops out" above the toolbar. -->
|
|
565
|
-
<div class="wdg-illustrated-mask {activeTool === 'draw' ? 'wdg-illustrated-mask-active' : ''}">
|
|
566
|
-
<Tooltip text={toolTitle('canvas.tool.draw', TOOL_KEYS.draw, $t)} offsetY={8}>
|
|
567
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
568
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
569
|
-
<div class="wdg-illustrated-bt {activeTool === 'draw' ? 'wdg-illustrated-active' : ''}"
|
|
570
|
-
onclick={onSelectDrawTool}
|
|
571
|
-
role="button"
|
|
572
|
-
tabindex="-1"
|
|
573
|
-
aria-label={$t('canvas.tool.draw')}>
|
|
574
|
-
<svg class="wdg-pencil-svg" viewBox="0 0 32 159" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
575
|
-
<path d="M20.8823 15.927L18.439 3.29447C17.3288 0.137968 14.6702 0.137967 13.5604 3.29374L11.114 15.927H20.8823Z" fill="#4A4A4C"/>
|
|
576
|
-
<path d="M32 88.8211L32 68.6342C32 66.2211 31.7486 63.9551 31.3079 61.9972L20.8785 15.927H11.1176L0.841019 61.3789L0.692138 61.9972C0.251452 63.9551 6.10352e-05 66.2211 6.10352e-05 68.6342L0.000481631 88.8221L32 88.8211Z" fill="url(#pencilBody)"/>
|
|
577
|
-
<path d="M8.00006 158.93L7.99997 69.1565C7.99997 66.1271 6.20959 61.6724 4.00002 61.6724C2.58481 61.6724 1.34125 62.6801 0.630773 64.2001L0.519114 64.4521C0.188602 65.2499 6.10352e-05 68.1732 6.10352e-05 69.1565L0.000150606 158.93H8.00006Z" fill="#A4A3A8"/>
|
|
578
|
-
<path d="M15.4888 61.6724C11.347 61.6724 7.98895 66.1279 7.98895 69.1565V158.93H22.9888L22.9888 69.1565C22.9888 66.1279 19.6306 61.6724 15.4888 61.6724Z" fill="#707477"/>
|
|
579
|
-
<path d="M32 158.93L32 68.1565C32 67.1732 31.7879 64.2499 31.4161 63.4521L31.2908 63.2006C30.4915 61.6806 29.0921 61.6724 27.5 61.6724C25.0142 61.6724 23 66.1271 23 69.1565L23 158.93H32Z" fill="#5E6064"/>
|
|
580
|
-
<defs>
|
|
581
|
-
<linearGradient id="pencilBody" x1="2.45" y1="53.89" x2="38.29" y2="57.66" gradientUnits="userSpaceOnUse">
|
|
582
|
-
<stop offset="0.145" stop-color="#EFDBCC"/><stop offset="0.185" stop-color="#FBDDCB"/>
|
|
583
|
-
<stop offset="0.25" stop-color="#E2B8A4"/><stop offset="0.44" stop-color="#C49F8F"/>
|
|
584
|
-
<stop offset="0.77" stop-color="#AF9280"/>
|
|
585
|
-
</linearGradient>
|
|
586
|
-
</defs>
|
|
587
|
-
</svg>
|
|
588
|
-
</div>
|
|
589
|
-
</Tooltip>
|
|
590
|
-
</div>
|
|
591
|
-
<div class="wdg-illustrated-mask {activeTool === 'erase' ? 'wdg-illustrated-mask-active' : ''}">
|
|
592
|
-
<Tooltip text={toolTitle('canvas.tool.erase', TOOL_KEYS.erase, $t)} offsetY={8}>
|
|
593
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
594
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
595
|
-
<div class="wdg-illustrated-bt {activeTool === 'erase' ? 'wdg-illustrated-active' : ''}"
|
|
596
|
-
onclick={onSelectEraseTool}
|
|
597
|
-
role="button"
|
|
598
|
-
tabindex="-1"
|
|
599
|
-
aria-label={$t('canvas.tool.erase')}>
|
|
600
|
-
<svg class="wdg-eraser-svg" viewBox="0 0 32 127" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
601
|
-
<path d="M31.9959 29.9282L1.3e-06 29.9282L0 36.9282L31.9959 36.9282L31.9959 29.9282Z" fill="#ABB1B4"/>
|
|
602
|
-
<path d="M4.4e-05 36.9241L0 36.5283H10.6654V36.9241L4.4e-05 36.9241Z" fill="white"/>
|
|
603
|
-
<path d="M10.6655 36.9241V36.5283L21.3307 36.5283V36.9241L10.6655 36.9241Z" fill="white"/>
|
|
604
|
-
<path d="M21.3305 36.9242L21.3305 36.5283L31.9958 36.5284L31.9958 36.9242H21.3305Z" fill="white"/>
|
|
605
|
-
<path d="M1.58716 36.5284L1.58716 29.9282H10.1257L10.1257 36.5284H1.58716Z" fill="#858E92"/>
|
|
606
|
-
<path d="M0.003 36.93L8.003 36.93V126.93H0.003V36.93Z" fill="#A4A3A8"/>
|
|
607
|
-
<path d="M8.003 36.93L23.003 36.93V126.93H8.003V36.93Z" fill="#707477"/>
|
|
608
|
-
<path d="M23.003 36.93L32 36.93V126.93H23.003V36.93Z" fill="#5E6064"/>
|
|
609
|
-
<path d="M23.362 36.5284L23.362 29.9282L30.6204 29.9283L30.6204 36.5284H23.362Z" fill="#858E92"/>
|
|
610
|
-
<path d="M20.0186 29.9282H14.8553L14.8553 36.5284L20.0186 36.5284L20.0186 29.9282Z" fill="#E4EBED"/>
|
|
611
|
-
<path d="M-2.1e-05 29.9282L31.9959 29.9283L31.9959 10.7812C31.9959 5.34073 27.7514 0.930376 22.5156 0.93042H9.48026C4.24447 0.93042 1.9e-05 5.34073 1.9e-05 10.7811L-2.1e-05 29.9282Z" fill="url(#eraserHead)"/>
|
|
612
|
-
<path opacity="0.4" d="M31.9959 29.9278L31.9959 10.7812C31.9959 10.7649 31.9959 10.7485 31.9958 10.7322C31.9948 10.5134 31.9869 10.2957 31.9723 10.0804L31.9701 10.0488L31.969 10.0331C31.601 4.94215 27.5092 0.93042 22.5156 0.93042L14.6346 0.93042C19.0593 0.978238 22.6318 4.71971 22.6318 9.32859L22.6318 29.9278L31.9959 29.9278Z" fill="#A04B5C"/>
|
|
613
|
-
<path d="M31.9959 30.324L4.3e-05 30.324L0 29.9283L31.9959 29.9282V30.324Z" fill="white"/>
|
|
614
|
-
<defs>
|
|
615
|
-
<linearGradient id="eraserHead" x1="-2.1e-05" y1="29.9283" x2="31.9959" y2="29.9283" gradientUnits="userSpaceOnUse">
|
|
616
|
-
<stop offset="0.215" stop-color="#ED95A1"/><stop offset="0.33" stop-color="#E77E8D"/>
|
|
617
|
-
<stop offset="0.667" stop-color="#BA5C6E"/><stop offset="1" stop-color="#863F4E"/>
|
|
618
|
-
</linearGradient>
|
|
619
|
-
</defs>
|
|
620
|
-
</svg>
|
|
621
|
-
</div>
|
|
622
|
-
</Tooltip>
|
|
623
|
-
</div>
|
|
624
|
-
|
|
625
|
-
<!-- ══ Standard icon-only tool buttons ══ -->
|
|
626
|
-
<Tooltip text={toolTitle('canvas.tool.select', TOOL_KEYS.select, $t)}>
|
|
627
|
-
<button class="select-bt {buttonClass} {activeTool === 'select' ? activeClass : inactiveClass}"
|
|
628
|
-
onclick={onSelectSelectTool}
|
|
629
|
-
aria-label={$t('canvas.tool.select')}>
|
|
630
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
631
|
-
<path d="M5 3L5 18.5L9.5 14L14.5 21L17 19.5L12 12.5L18 12.5L5 3Z" fill="currentColor" stroke="currentColor" stroke-width="1" stroke-linejoin="round"/>
|
|
632
|
-
</svg>
|
|
633
|
-
</button>
|
|
634
|
-
</Tooltip>
|
|
635
|
-
<Tooltip text={toolTitle('canvas.tool.arrow', TOOL_KEYS.arrow, $t)}>
|
|
636
|
-
<button class="arrow-bt {buttonClass} {activeTool === 'arrow' ? activeClass : inactiveClass}"
|
|
637
|
-
onclick={() => onSelectShapeTool('arrow')}
|
|
638
|
-
aria-label={$t('canvas.tool.arrow')}>
|
|
639
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
640
|
-
<path d="M6 18C6 18 6.06617 12.5162 8.00001 10.5521C10.862 7.64522 19 9 19 9M19 9L15 5M19 9L15 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
641
|
-
</svg>
|
|
642
|
-
</button>
|
|
643
|
-
</Tooltip>
|
|
644
|
-
<Tooltip text={toolTitle('canvas.tool.text', TOOL_KEYS.text, $t)}>
|
|
645
|
-
<button class="text-bt {buttonClass} {activeTool === 'text' ? activeClass : inactiveClass}"
|
|
646
|
-
onclick={onSelectTextTool}
|
|
647
|
-
aria-label={$t('canvas.tool.text')}>
|
|
648
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
649
|
-
<path d="M6 7V5H18V7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
650
|
-
<path d="M12 5V19" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
651
|
-
<path d="M14 19H10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
652
|
-
</svg>
|
|
653
|
-
</button>
|
|
654
|
-
</Tooltip>
|
|
655
|
-
{/if}
|
|
656
|
-
|
|
657
|
-
{#if showMediaOnBar}
|
|
658
|
-
<div class="toolbar-divider"></div>
|
|
659
|
-
|
|
660
|
-
<Tooltip text={toolTitle('canvas.tool.frame', TOOL_KEYS.frame, $t)}>
|
|
661
|
-
<button class="frame-bt {buttonClass} {activeTool === 'frame' ? activeClass : inactiveClass}"
|
|
662
|
-
onclick={onSelectFrameTool}
|
|
663
|
-
aria-label={$t('canvas.tool.frame')}>
|
|
664
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
665
|
-
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
666
|
-
<path d="M3 9h18"/>
|
|
667
|
-
<path d="M9 3v6"/>
|
|
668
|
-
</svg>
|
|
669
|
-
</button>
|
|
670
|
-
</Tooltip>
|
|
671
|
-
|
|
672
|
-
<Tooltip text={toolTitle('canvas.tool.image', TOOL_KEYS.image, $t)}>
|
|
673
|
-
<button class="image-bt {buttonClass} {activeTool === 'image' ? activeClass : inactiveClass}"
|
|
674
|
-
onclick={() => { onSelectImageTool(); }}
|
|
675
|
-
aria-label={$t('canvas.tool.image')}>
|
|
676
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
677
|
-
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
678
|
-
<circle cx="8.5" cy="8.5" r="1.5"/>
|
|
679
|
-
<path d="M21 15l-5-5L5 21"/>
|
|
680
|
-
</svg>
|
|
681
|
-
</button>
|
|
682
|
-
</Tooltip>
|
|
683
|
-
|
|
684
|
-
<Tooltip text={$t('canvas.tool.video')}>
|
|
685
|
-
<button class="video-bt {buttonClass} {activeTool === 'video' ? activeClass : inactiveClass}"
|
|
686
|
-
onclick={onSelectVideoTool}
|
|
687
|
-
aria-label={$t('canvas.tool.video')}>
|
|
688
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
689
|
-
<rect x="2" y="6" width="14" height="12" rx="2"/>
|
|
690
|
-
<path d="M16 10l6-3v10l-6-3z"/>
|
|
691
|
-
</svg>
|
|
692
|
-
</button>
|
|
693
|
-
</Tooltip>
|
|
694
|
-
{/if}
|
|
695
|
-
|
|
696
|
-
<!-- Shapes: tldraw-style split — left activates tool, right opens dropdown. Advanced only. -->
|
|
697
|
-
{#if advancedFeatures}
|
|
698
|
-
<div class="shapes-split-ct" bind:this={dropdownTriggerEl}>
|
|
699
|
-
<Tooltip text={dropdownButtonTooltip}>
|
|
700
|
-
<button
|
|
701
|
-
class="shapes-main-bt {buttonClass} {activeDropdownIsActive ? activeClass : inactiveClass}"
|
|
702
|
-
onclick={activateDropdownTool}
|
|
703
|
-
aria-label={$t(dropdownToolNameKey)}
|
|
704
|
-
>
|
|
705
|
-
{#if activeDropdownTool === 'library-shape' && lastSelectedLibraryShape}
|
|
706
|
-
{@html lastSelectedLibraryShape.iconSvg}
|
|
707
|
-
{:else if mediaTrigger}
|
|
708
|
-
{@html mediaTrigger.iconSvg}
|
|
709
|
-
{:else if shapeInfo[activeDropdownTool as ShapeToolName]}
|
|
710
|
-
{@html shapeInfo[activeDropdownTool as ShapeToolName].iconSvg}
|
|
711
|
-
{:else}
|
|
712
|
-
{@html shapeInfo['rect'].iconSvg}
|
|
713
|
-
{/if}
|
|
714
|
-
</button>
|
|
715
|
-
</Tooltip>
|
|
716
|
-
<Tooltip text={$t('canvas.tool.moreShapes')} disabled={shapesDropdownOpen}>
|
|
717
|
-
<button
|
|
718
|
-
class="shapes-caret-bt {buttonClass} {activeDropdownIsActive ? activeClass : inactiveClass}"
|
|
719
|
-
onclick={(e) => toggleShapesDropdown(e)}
|
|
720
|
-
aria-label={$t('canvas.tool.moreShapes')}
|
|
721
|
-
>
|
|
722
|
-
<svg width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
723
|
-
<path d="M2 4L5 7L8 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
724
|
-
</svg>
|
|
725
|
-
</button>
|
|
726
|
-
</Tooltip>
|
|
727
|
-
</div>
|
|
728
|
-
{/if}
|
|
729
|
-
</div>
|
|
730
|
-
</div>
|
|
731
|
-
|
|
732
|
-
<!-- Actions Bar (hidden by default, kept for future use) -->
|
|
733
|
-
<div class="actions-bar-el relative hidden flex-row gap-2 w-full">
|
|
734
|
-
<div class="actions-ct flex flex-row gap-2 overflow-x-auto rounded-xl p-2 bg-white/80 shadow-md border border-gray-100">
|
|
735
|
-
<!-- Grouping Actions -->
|
|
736
|
-
<button class="add-group-selection-bt {buttonClass}" onclick={onGroupSelection}><span class="icon">📦</span> {$t('canvas.action.group')}</button>
|
|
737
|
-
<button class="add-ungroup-selection-bt {buttonClass}" onclick={onUngroupSelection}><span class="icon">📤</span> {$t('canvas.action.ungroup')}</button>
|
|
738
|
-
<button class="add-duplicate-selection-bt {buttonClass}" onclick={onDuplicateSelection}><span class="icon">📋</span> {$t('canvas.action.duplicate')}</button>
|
|
739
|
-
<button class="add-select-all-bt {buttonClass}" onclick={onSelectAllObjects}><span class="icon">🎯</span> {$t('canvas.action.selectAll')}</button>
|
|
740
|
-
<button class="add-clear-all-bt {buttonClass}" onclick={onClearAllObjects}><span class="icon">🗑️</span> {$t('canvas.action.clearAll')}</button>
|
|
741
|
-
|
|
742
|
-
<!-- Add Objects Actions -->
|
|
743
|
-
<button class="add-text-bt {buttonClass}" onclick={addText}><span class="icon">📝</span> {$t('canvas.tool.text')}</button>
|
|
744
|
-
<button class="add-rext-bt {buttonClass}" onclick={addRect}><span class="icon">⬜</span> {$t('canvas.tool.rectangle')}</button>
|
|
745
|
-
<button class="add-triangle-bt {buttonClass}" onclick={addTriangle}><span class="icon">🔺</span> {$t('canvas.tool.triangle')}</button>
|
|
746
|
-
<button class="add-circle-bt {buttonClass}" onclick={addCircle}><span class="icon">🔴</span> {$t('canvas.tool.circle')}</button>
|
|
747
|
-
<button class="add-frame-bt {buttonClass}" onclick={addFrame}><span class="icon frame-icon">▢</span> {$t('canvas.tool.frame')}</button>
|
|
748
|
-
<button class="add-image-bt {buttonClass}" onclick={addImage}><span class="icon">🖼️</span> {$t('canvas.tool.image')}</button>
|
|
749
|
-
</div>
|
|
750
|
-
</div>
|
|
751
|
-
</div>
|
|
752
|
-
|
|
753
|
-
<!-- ═══════════════════════════════════════════════════════════════
|
|
754
|
-
Shapes Dropdown Menu — rendered as sibling (outside overflow),
|
|
755
|
-
uses position:fixed with coordinates from getBoundingClientRect.
|
|
756
|
-
dropdownOpenAbove=true: appears above the trigger (toolbar at bottom).
|
|
757
|
-
dropdownOpenAbove=false: appears below (toolbar at top).
|
|
758
|
-
═══════════════════════════════════════════════════════════════ -->
|
|
759
|
-
{#if shapesDropdownOpen}
|
|
760
|
-
<!-- position:absolute within .canvas-container (position:relative) so the dropdown
|
|
761
|
-
is correctly positioned regardless of any CSS transform on ancestors. -->
|
|
762
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
763
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
764
|
-
<div
|
|
765
|
-
class="shapes-dropdown-menu-fixed"
|
|
766
|
-
style="position:absolute; left:{dropdownLeft}px; /* rtl-ok: worked out from where the button is on the screen, in pixels from the left edge of the canvas */ {dropdownOpenAbove ? `bottom:${dropdownBottomOffset}px` : `top:${dropdownTopOffset}px`}; width:{dropdownMinWidth}px; max-height:{dropdownMaxHeight}px; z-index:9999;"
|
|
767
|
-
>
|
|
768
|
-
<div
|
|
769
|
-
class="shapes-dropdown-scroll"
|
|
770
|
-
use:overlayScrollbar
|
|
771
|
-
style={shapesDropdownNeedsScroll ? 'margin-inline-end: -6px' : ''}
|
|
772
|
-
>
|
|
773
|
-
<!-- Media Shapes — first so Frame / Image / Video are easy to reach when not on the bar -->
|
|
774
|
-
{#if showMediaInDropdown}
|
|
775
|
-
<div class="shapes-category-label">{$t('canvas.menu.mediaShapes')}</div>
|
|
776
|
-
<div class="shapes-library-grid">
|
|
777
|
-
<Tooltip text={toolTitle('canvas.tool.frame', TOOL_KEYS.frame, $t)} position="above">
|
|
778
|
-
<button class="shape-library-bt {activeTool === 'frame' ? 'active' : ''}" onclick={selectFrameFromDropdown} aria-label={$t('canvas.tool.frame')}>
|
|
779
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 3v6"/></svg>
|
|
780
|
-
</button>
|
|
781
|
-
</Tooltip>
|
|
782
|
-
<Tooltip text={toolTitle('canvas.tool.image', TOOL_KEYS.image, $t)} position="above">
|
|
783
|
-
<button class="shape-library-bt {activeTool === 'image' ? 'active' : ''}" onclick={selectImageFromDropdown} aria-label={$t('canvas.tool.image')}>
|
|
784
|
-
{@html imageDropdownInfo.iconSvg}
|
|
785
|
-
</button>
|
|
786
|
-
</Tooltip>
|
|
787
|
-
<Tooltip text={$t('canvas.tool.video')} position="above">
|
|
788
|
-
<button class="shape-library-bt {activeTool === 'video' ? 'active' : ''}" onclick={selectVideoFromDropdown} aria-label={$t('canvas.tool.video')}>
|
|
789
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="14" height="12" rx="2"/><path d="M16 10l6-3v10l-6-3z"/></svg>
|
|
790
|
-
</button>
|
|
791
|
-
</Tooltip>
|
|
792
|
-
</div>
|
|
793
|
-
<div class="shapes-dropdown-divider"></div>
|
|
794
|
-
{/if}
|
|
795
|
-
|
|
796
|
-
<!-- Geometric Shapes — 3×2 grid -->
|
|
797
|
-
<div class="shapes-category-label">{categoryLabel(GEOMETRIC_CATEGORY, $t)}</div>
|
|
798
|
-
<div class="shapes-library-grid">
|
|
799
|
-
<Tooltip text={toolTitle('canvas.tool.triangle', TOOL_KEYS.triangle, $t)} position="above">
|
|
800
|
-
<button class="shape-library-bt" onclick={() => selectShape('triangle')} aria-label={$t('canvas.tool.triangle')}>
|
|
801
|
-
{@html shapeInfo.triangle.iconSvg}
|
|
802
|
-
</button>
|
|
803
|
-
</Tooltip>
|
|
804
|
-
<Tooltip text={toolTitle('canvas.tool.rectangle', TOOL_KEYS.rectangle, $t)} position="above">
|
|
805
|
-
<button class="shape-library-bt" onclick={() => selectShape('rect')} aria-label={$t('canvas.tool.rectangle')}>
|
|
806
|
-
{@html shapeInfo.rect.iconSvg}
|
|
807
|
-
</button>
|
|
808
|
-
</Tooltip>
|
|
809
|
-
{#each (libraryShapesByCategory.get(GEOMETRIC_CATEGORY) ?? []).filter(s => s.key === 'hexagon') as shape}
|
|
810
|
-
<Tooltip text={$t(shape.labelKey)} position="above">
|
|
811
|
-
<button class="shape-library-bt" onclick={() => selectLibraryShape(shape)} aria-label={$t(shape.labelKey)}>
|
|
812
|
-
{@html shape.iconSvg}
|
|
813
|
-
</button>
|
|
814
|
-
</Tooltip>
|
|
815
|
-
{/each}
|
|
816
|
-
<Tooltip text={$t('canvas.tool.circle')} position="above">
|
|
817
|
-
<button class="shape-library-bt" onclick={() => selectShape('circle-true')} aria-label={$t('canvas.tool.circle')}>
|
|
818
|
-
{@html shapeInfo['circle-true'].iconSvg}
|
|
819
|
-
</button>
|
|
820
|
-
</Tooltip>
|
|
821
|
-
<Tooltip text={toolTitle('canvas.tool.ellipse', TOOL_KEYS.ellipse, $t)} position="above">
|
|
822
|
-
<button class="shape-library-bt" onclick={() => selectShape('circle')} aria-label={$t('canvas.tool.ellipse')}>
|
|
823
|
-
{@html shapeInfo.circle.iconSvg}
|
|
824
|
-
</button>
|
|
825
|
-
</Tooltip>
|
|
826
|
-
{#each (libraryShapesByCategory.get(GEOMETRIC_CATEGORY) ?? []).filter(s => s.key === 'oval') as shape}
|
|
827
|
-
<Tooltip text={$t(shape.labelKey)} position="above">
|
|
828
|
-
<button class="shape-library-bt" onclick={() => selectLibraryShape(shape)} aria-label={$t(shape.labelKey)}>
|
|
829
|
-
{@html shape.iconSvg}
|
|
830
|
-
</button>
|
|
831
|
-
</Tooltip>
|
|
832
|
-
{/each}
|
|
833
|
-
</div>
|
|
834
|
-
|
|
835
|
-
<!-- Library shape categories (skip Geometric, already rendered above) -->
|
|
836
|
-
{#each [...libraryShapesByCategory.entries()].filter(([cat]) => cat !== GEOMETRIC_CATEGORY) as [category, shapes]}
|
|
837
|
-
<div class="shapes-dropdown-divider"></div>
|
|
838
|
-
<div class="shapes-category-label">{categoryLabel(category, $t)}</div>
|
|
839
|
-
<div class="shapes-library-grid">
|
|
840
|
-
{#each shapes as shape}
|
|
841
|
-
<Tooltip text={$t(shape.labelKey)} position="above">
|
|
842
|
-
<button
|
|
843
|
-
class="shape-library-bt"
|
|
844
|
-
onclick={() => selectLibraryShape(shape)}
|
|
845
|
-
aria-label={$t(shape.labelKey)}
|
|
846
|
-
>
|
|
847
|
-
{@html shape.iconSvg}
|
|
848
|
-
</button>
|
|
849
|
-
</Tooltip>
|
|
850
|
-
{/each}
|
|
851
|
-
</div>
|
|
852
|
-
{/each}
|
|
853
|
-
</div><!-- end shapes-dropdown-scroll -->
|
|
854
|
-
</div><!-- end shapes-dropdown-menu-fixed -->
|
|
855
|
-
{/if}
|
|
856
|
-
|
|
857
|
-
<!-- ═══════════════════════════════════════════════════════════════
|
|
858
|
-
Keyboard Shortcuts Panel — rendered as sibling in canvas-container,
|
|
859
|
-
uses position:absolute (relative to canvas-container) so it is
|
|
860
|
-
always centered within the canvas area, not the viewport.
|
|
861
|
-
═══════════════════════════════════════════════════════════════ -->
|
|
862
|
-
{#if shortcutsPanelOpen}
|
|
863
|
-
<!-- Backdrop — covers the canvas area -->
|
|
864
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
865
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
866
|
-
<div class="shortcuts-backdrop" onclick={() => shortcutsPanelOpen = false}></div>
|
|
867
|
-
|
|
868
|
-
<!-- Shortcuts Panel Overlay -->
|
|
869
|
-
<div class="shortcuts-panel">
|
|
870
|
-
<div class="shortcuts-panel-header">
|
|
871
|
-
<div class="shortcuts-panel-title-ct">
|
|
872
|
-
<span class="shortcuts-panel-icon">⌨</span>
|
|
873
|
-
<h2 class="shortcuts-panel-title">{$t('canvas.shortcuts.title')}</h2>
|
|
874
|
-
</div>
|
|
875
|
-
<button
|
|
876
|
-
class="close-shortcuts-bt"
|
|
877
|
-
onclick={() => shortcutsPanelOpen = false}
|
|
878
|
-
aria-label={$t('canvas.shortcuts.close')}
|
|
879
|
-
>✕</button>
|
|
880
|
-
</div>
|
|
881
|
-
|
|
882
|
-
<div class="shortcuts-panel-body">
|
|
883
|
-
<div class="shortcuts-column">
|
|
884
|
-
{#each translatedShortcutGroups.filter((_, i) => i % 2 === 0) as group}
|
|
885
|
-
<div class="shortcut-group">
|
|
886
|
-
<h3 class="shortcut-group-title">{group.title}</h3>
|
|
887
|
-
<ul class="shortcut-list">
|
|
888
|
-
{#each group.shortcuts as shortcut}
|
|
889
|
-
<li class="shortcut-row">
|
|
890
|
-
<span class="shortcut-label">{shortcut.label}</span>
|
|
891
|
-
<div class="shortcut-keys">
|
|
892
|
-
{#each shortcut.keys as k}
|
|
893
|
-
{#if k === null}
|
|
894
|
-
<span class="shortcut-sep">+</span>
|
|
895
|
-
{:else}
|
|
896
|
-
<kbd class="shortcut-key">{k}</kbd>
|
|
897
|
-
{/if}
|
|
898
|
-
{/each}
|
|
899
|
-
</div>
|
|
900
|
-
</li>
|
|
901
|
-
{/each}
|
|
902
|
-
</ul>
|
|
903
|
-
</div>
|
|
904
|
-
{/each}
|
|
905
|
-
</div>
|
|
906
|
-
<div class="shortcuts-column">
|
|
907
|
-
{#each translatedShortcutGroups.filter((_, i) => i % 2 === 1) as group}
|
|
908
|
-
<div class="shortcut-group">
|
|
909
|
-
<h3 class="shortcut-group-title">{group.title}</h3>
|
|
910
|
-
<ul class="shortcut-list">
|
|
911
|
-
{#each group.shortcuts as shortcut}
|
|
912
|
-
<li class="shortcut-row">
|
|
913
|
-
<span class="shortcut-label">{shortcut.label}</span>
|
|
914
|
-
<div class="shortcut-keys">
|
|
915
|
-
{#each shortcut.keys as k}
|
|
916
|
-
{#if k === null}
|
|
917
|
-
<span class="shortcut-sep">+</span>
|
|
918
|
-
{:else}
|
|
919
|
-
<kbd class="shortcut-key">{k}</kbd>
|
|
920
|
-
{/if}
|
|
921
|
-
{/each}
|
|
922
|
-
</div>
|
|
923
|
-
</li>
|
|
924
|
-
{/each}
|
|
925
|
-
</ul>
|
|
926
|
-
</div>
|
|
927
|
-
{/each}
|
|
928
|
-
</div>
|
|
929
|
-
</div>
|
|
930
|
-
|
|
931
|
-
<div class="shortcuts-panel-footer flex items-center justify-center gap-2">
|
|
932
|
-
<!-- A sentence with three parts drawn as keys: each part goes where the translation puts it -->
|
|
933
|
-
{#each footerParts as part}
|
|
934
|
-
{#if 'text' in part}
|
|
935
|
-
{part.text}
|
|
936
|
-
{:else if part.slot === 'key'}
|
|
937
|
-
<kbd class="shortcut-key font-medium">?</kbd>
|
|
938
|
-
{:else if part.slot === 'hint'}
|
|
939
|
-
<span class="shortcuts-footer-hint">{$t('canvas.shortcuts.footerHint')}</span>
|
|
940
|
-
{:else if part.slot === 'icon'}
|
|
941
|
-
<kbd class="shortcut-key" style="font-size: 31px;">⌨</kbd>
|
|
942
|
-
{/if}
|
|
943
|
-
{/each}
|
|
944
|
-
</div>
|
|
945
|
-
</div>
|
|
946
|
-
{/if}
|
|
947
|
-
|
|
948
|
-
<style>
|
|
949
|
-
/* ══════════════════════════════════════════════════════════════
|
|
950
|
-
Widgetic Canvas Toolbar — custom design
|
|
951
|
-
• "Sheath" container: 80px height, white bg + shadow
|
|
952
|
-
• All buttons 48×48 px, icons fill proportionally
|
|
953
|
-
• Inactive: gray bg. Active: dark green. Hover: pale green.
|
|
954
|
-
• Pencil/Eraser: illustrated, extend above, pull-up on select
|
|
955
|
-
• Shapes: split button (shape + caret), dropdown centered
|
|
956
|
-
══════════════════════════════════════════════════════════════ */
|
|
957
|
-
|
|
958
|
-
/* ── Toolbar outer wrapper — transparent, no own shadow ── */
|
|
959
|
-
.canvas-toolbar-el {
|
|
960
|
-
border-radius: 1.25rem;
|
|
961
|
-
overflow: visible;
|
|
962
|
-
background: transparent !important;
|
|
963
|
-
box-shadow: none !important;
|
|
964
|
-
}
|
|
965
|
-
.canvas-toolbar-el :global(button:focus),
|
|
966
|
-
.canvas-toolbar-el :global(button:focus-visible),
|
|
967
|
-
.canvas-toolbar-el :global(a:focus),
|
|
968
|
-
.canvas-toolbar-el :global(a:focus-visible) {
|
|
969
|
-
outline: none !important;
|
|
970
|
-
box-shadow: none !important;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
/* ── "Sheath" — the white container holding all buttons ── */
|
|
974
|
-
.tools-ct {
|
|
975
|
-
background: white;
|
|
976
|
-
border-radius: 1.25rem;
|
|
977
|
-
box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
|
|
978
|
-
height: 80px;
|
|
979
|
-
padding: 0 24px;
|
|
980
|
-
gap: 4px;
|
|
981
|
-
align-items: center;
|
|
982
|
-
overflow: visible;
|
|
983
|
-
position: relative;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
/* ── Base button reset ── */
|
|
987
|
-
button {
|
|
988
|
-
cursor: pointer;
|
|
989
|
-
display: inline-flex;
|
|
990
|
-
align-items: center;
|
|
991
|
-
justify-content: center;
|
|
992
|
-
gap: 0;
|
|
993
|
-
border: none;
|
|
994
|
-
background: transparent;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
button:focus,
|
|
998
|
-
button:focus-visible {
|
|
999
|
-
outline: none !important;
|
|
1000
|
-
box-shadow: none !important;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
button:disabled {
|
|
1004
|
-
opacity: 0.35;
|
|
1005
|
-
cursor: not-allowed;
|
|
1006
|
-
pointer-events: none;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
/* ── Uniform tool button — ALL buttons 48×48, no border ── */
|
|
1010
|
-
.wdg-tool-bt {
|
|
1011
|
-
width: 48px;
|
|
1012
|
-
height: 48px;
|
|
1013
|
-
padding: 0;
|
|
1014
|
-
border-radius: 12px;
|
|
1015
|
-
border: none;
|
|
1016
|
-
background: #f0f0f0;
|
|
1017
|
-
color: #374151;
|
|
1018
|
-
transition: all 0.15s ease;
|
|
1019
|
-
flex-shrink: 0;
|
|
1020
|
-
box-shadow: none;
|
|
1021
|
-
}
|
|
1022
|
-
/* Scale icon SVGs inside tool buttons to fill them nicely */
|
|
1023
|
-
.wdg-tool-bt :global(svg) {
|
|
1024
|
-
width: 24px !important;
|
|
1025
|
-
height: 24px !important;
|
|
1026
|
-
}
|
|
1027
|
-
/* Utility buttons (undo, redo, lock) — slightly smaller icons */
|
|
1028
|
-
.undo-bt :global(svg),
|
|
1029
|
-
.redo-bt :global(svg),
|
|
1030
|
-
.sticky-tool-bt :global(svg) {
|
|
1031
|
-
width: 20px !important;
|
|
1032
|
-
height: 20px !important;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
/* Inactive state — light gray bg */
|
|
1036
|
-
.wdg-tool-inactive {
|
|
1037
|
-
background: #f0f0f0;
|
|
1038
|
-
color: #374151;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/* Hover — pale green */
|
|
1042
|
-
.wdg-tool-bt:hover {
|
|
1043
|
-
background: #e6f0eb !important;
|
|
1044
|
-
color: #1a3a2a !important;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
/* Active (selected) — dark green bg, white icon */
|
|
1048
|
-
.wdg-tool-active {
|
|
1049
|
-
background: #1a3a2a !important;
|
|
1050
|
-
color: white !important;
|
|
1051
|
-
box-shadow: 0 2px 8px rgba(26, 58, 42, 0.25);
|
|
1052
|
-
}
|
|
1053
|
-
.wdg-tool-active :global(svg),
|
|
1054
|
-
.wdg-tool-active :global(svg *) {
|
|
1055
|
-
color: white !important;
|
|
1056
|
-
stroke: currentColor !important;
|
|
1057
|
-
}
|
|
1058
|
-
.wdg-tool-active:hover {
|
|
1059
|
-
background: #244b36 !important;
|
|
1060
|
-
color: white !important;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
/* Wrapper to intercept hover events on disabled buttons for tooltip.
|
|
1064
|
-
display:inline-flex ensures the div is a visible box that receives mouseenter. */
|
|
1065
|
-
.disabled-tooltip-wrap {
|
|
1066
|
-
display: inline-flex;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/* ── Divider ── */
|
|
1070
|
-
.toolbar-divider {
|
|
1071
|
-
width: 1px;
|
|
1072
|
-
height: 32px;
|
|
1073
|
-
align-self: center;
|
|
1074
|
-
background-color: #e5e7eb;
|
|
1075
|
-
margin: 0 2px;
|
|
1076
|
-
flex-shrink: 0;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
/* ══ Illustrated tool mask container ══
|
|
1080
|
-
Clips the pencil/eraser body so only the tip peeks out at rest.
|
|
1081
|
-
When active, overflow becomes visible so the full tool is revealed above the sheath. */
|
|
1082
|
-
.wdg-illustrated-mask {
|
|
1083
|
-
width: 36px;
|
|
1084
|
-
position: relative;
|
|
1085
|
-
align-self: stretch;
|
|
1086
|
-
flex-shrink: 0;
|
|
1087
|
-
z-index: 0;
|
|
1088
|
-
/* Allow tip to extend above, clip at sides and bottom */
|
|
1089
|
-
clip-path: inset(-100px 0 0 0);
|
|
1090
|
-
}
|
|
1091
|
-
.wdg-illustrated-mask-active {
|
|
1092
|
-
/* Active: allow tall extension above (−200px top), but still clip at bottom (0) */
|
|
1093
|
-
clip-path: inset(-200px 0 0 0);
|
|
1094
|
-
z-index: 3;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
/* ══ Illustrated tool buttons (Pencil & Eraser) ══
|
|
1098
|
-
SVGs are taller than the 80px mask. At rest they are pushed down so only
|
|
1099
|
-
the tip peeks ~15px above the toolbar top edge. On active, translateY(0)
|
|
1100
|
-
reveals the full extent above the mask. */
|
|
1101
|
-
.wdg-illustrated-bt {
|
|
1102
|
-
display: flex;
|
|
1103
|
-
align-items: flex-end;
|
|
1104
|
-
justify-content: center;
|
|
1105
|
-
width: 36px;
|
|
1106
|
-
cursor: pointer;
|
|
1107
|
-
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
1108
|
-
filter 0.2s ease;
|
|
1109
|
-
flex-shrink: 0;
|
|
1110
|
-
position: absolute;
|
|
1111
|
-
bottom: 0;
|
|
1112
|
-
inset-inline-start: 0;
|
|
1113
|
-
filter: none;
|
|
1114
|
-
}
|
|
1115
|
-
/* Pencil: SVG ~149px tall, mask 48px.
|
|
1116
|
-
Rest: translateY(54px) → tip peeks ~15px above toolbar.
|
|
1117
|
-
Active: translateY(18px) → shows most of pencil without going too high.
|
|
1118
|
-
Active:hover: translateY(16px) → subtle 2px lift. */
|
|
1119
|
-
.wdg-illustrated-bt:has(.wdg-pencil-svg) {
|
|
1120
|
-
transform: translateY(54px);
|
|
1121
|
-
}
|
|
1122
|
-
.wdg-illustrated-bt:has(.wdg-pencil-svg):hover {
|
|
1123
|
-
transform: translateY(46px);
|
|
1124
|
-
}
|
|
1125
|
-
.wdg-illustrated-bt:has(.wdg-pencil-svg).wdg-illustrated-active {
|
|
1126
|
-
transform: translateY(18px);
|
|
1127
|
-
}
|
|
1128
|
-
.wdg-illustrated-bt:has(.wdg-pencil-svg).wdg-illustrated-active:hover {
|
|
1129
|
-
transform: translateY(16px);
|
|
1130
|
-
}
|
|
1131
|
-
/* Eraser: SVG ~127px tall, mask 48px.
|
|
1132
|
-
Rest: translateY(32px) → tip peeks ~15px above toolbar.
|
|
1133
|
-
Active: translateY(10px) → shows most of eraser without going too high.
|
|
1134
|
-
Active:hover: translateY(8px) → subtle 2px lift. */
|
|
1135
|
-
.wdg-illustrated-bt:has(.wdg-eraser-svg) {
|
|
1136
|
-
transform: translateY(32px);
|
|
1137
|
-
}
|
|
1138
|
-
.wdg-illustrated-bt:has(.wdg-eraser-svg):hover {
|
|
1139
|
-
transform: translateY(24px);
|
|
1140
|
-
}
|
|
1141
|
-
.wdg-illustrated-bt:has(.wdg-eraser-svg).wdg-illustrated-active {
|
|
1142
|
-
transform: translateY(10px);
|
|
1143
|
-
}
|
|
1144
|
-
.wdg-illustrated-bt:has(.wdg-eraser-svg).wdg-illustrated-active:hover {
|
|
1145
|
-
transform: translateY(8px);
|
|
1146
|
-
}
|
|
1147
|
-
/* Click feedback (both tools) */
|
|
1148
|
-
.wdg-illustrated-bt:active {
|
|
1149
|
-
transition-duration: 0.08s;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
.wdg-pencil-svg {
|
|
1153
|
-
width: 30px;
|
|
1154
|
-
height: auto;
|
|
1155
|
-
}
|
|
1156
|
-
.wdg-eraser-svg {
|
|
1157
|
-
width: 32px;
|
|
1158
|
-
height: auto;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
/* ── Shapes split button container (tldraw-style) ── */
|
|
1162
|
-
.shapes-split-ct {
|
|
1163
|
-
display: flex;
|
|
1164
|
-
flex-direction: row;
|
|
1165
|
-
align-items: center;
|
|
1166
|
-
gap: 2px;
|
|
1167
|
-
flex-shrink: 0;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
/* Left: shape icon button (.shapes-main-bt) — inherits .wdg-tool-bt 48×48 */
|
|
1171
|
-
/* When active, give all shape SVGs a semi-transparent fill for visual weight */
|
|
1172
|
-
.shapes-main-bt.wdg-tool-active :global(svg rect),
|
|
1173
|
-
.shapes-main-bt.wdg-tool-active :global(svg circle),
|
|
1174
|
-
.shapes-main-bt.wdg-tool-active :global(svg ellipse),
|
|
1175
|
-
.shapes-main-bt.wdg-tool-active :global(svg polygon),
|
|
1176
|
-
.shapes-main-bt.wdg-tool-active :global(svg path) {
|
|
1177
|
-
fill: rgba(255, 255, 255, 0.2);
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/* Right: small caret button to open dropdown */
|
|
1181
|
-
.shapes-caret-bt {
|
|
1182
|
-
width: 24px !important;
|
|
1183
|
-
height: 48px !important;
|
|
1184
|
-
border-radius: 8px !important;
|
|
1185
|
-
padding: 0 !important;
|
|
1186
|
-
}
|
|
1187
|
-
.shapes-caret-bt :global(svg) {
|
|
1188
|
-
width: 10px !important;
|
|
1189
|
-
height: 10px !important;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
/* ── Shortcuts footer hint text ── */
|
|
1193
|
-
.shortcuts-footer-hint {
|
|
1194
|
-
font-size: 0.75rem;
|
|
1195
|
-
opacity: 0.6;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
/* ── Shapes dropdown menu — centered above trigger (tldraw-style) ── */
|
|
1199
|
-
.shapes-dropdown-menu-fixed {
|
|
1200
|
-
background: white;
|
|
1201
|
-
border: 1px solid #e5e7eb;
|
|
1202
|
-
border-radius: 12px;
|
|
1203
|
-
box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
|
|
1204
|
-
padding: 6px;
|
|
1205
|
-
overflow: hidden;
|
|
1206
|
-
display: flex;
|
|
1207
|
-
flex-direction: column;
|
|
1208
|
-
}
|
|
1209
|
-
/* Inner scrollable wrapper — margin-right set dynamically when overflowing */
|
|
1210
|
-
.shapes-dropdown-scroll {
|
|
1211
|
-
overflow-y: auto;
|
|
1212
|
-
overflow-x: hidden;
|
|
1213
|
-
scrollbar-width: thin;
|
|
1214
|
-
scrollbar-color: rgba(0,0,0,0.15) transparent;
|
|
1215
|
-
}
|
|
1216
|
-
.shapes-dropdown-scroll::-webkit-scrollbar {
|
|
1217
|
-
width: 4px;
|
|
1218
|
-
}
|
|
1219
|
-
.shapes-dropdown-scroll::-webkit-scrollbar-track {
|
|
1220
|
-
background: transparent;
|
|
1221
|
-
}
|
|
1222
|
-
.shapes-dropdown-scroll::-webkit-scrollbar-thumb {
|
|
1223
|
-
background: rgba(0,0,0,0.15);
|
|
1224
|
-
border-radius: 4px;
|
|
1225
|
-
}
|
|
1226
|
-
.shapes-dropdown-scroll::-webkit-scrollbar-thumb:hover {
|
|
1227
|
-
background: rgba(0,0,0,0.25);
|
|
1228
|
-
}
|
|
1229
|
-
.shapes-dropdown-menu-fixed .shape-option-bt {
|
|
1230
|
-
width: 100%;
|
|
1231
|
-
justify-content: flex-start;
|
|
1232
|
-
padding: 8px 10px;
|
|
1233
|
-
background: transparent;
|
|
1234
|
-
border: none;
|
|
1235
|
-
border-radius: 8px;
|
|
1236
|
-
font-size: 0.875rem;
|
|
1237
|
-
color: #374151;
|
|
1238
|
-
box-shadow: none;
|
|
1239
|
-
gap: 8px;
|
|
1240
|
-
white-space: nowrap;
|
|
1241
|
-
}
|
|
1242
|
-
.shapes-dropdown-menu-fixed .shape-option-bt:hover {
|
|
1243
|
-
background: #f3f4f6;
|
|
1244
|
-
color: #111827;
|
|
1245
|
-
}
|
|
1246
|
-
.shapes-dropdown-menu-fixed .shape-option-bt.active {
|
|
1247
|
-
background: #eff6ff;
|
|
1248
|
-
color: #2563eb;
|
|
1249
|
-
font-weight: 500;
|
|
1250
|
-
}
|
|
1251
|
-
.shapes-dropdown-menu-fixed .shape-option-bt.active:hover {
|
|
1252
|
-
background: #dbeafe;
|
|
1253
|
-
color: #1d4ed8;
|
|
1254
|
-
}
|
|
1255
|
-
/* Divider between shapes and image in the dropdown */
|
|
1256
|
-
.shapes-dropdown-divider {
|
|
1257
|
-
height: 1px;
|
|
1258
|
-
background: #e5e7eb;
|
|
1259
|
-
margin: 4px 0;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
/* Category label for library shape sections */
|
|
1263
|
-
.shapes-category-label {
|
|
1264
|
-
padding: 4px 8px 2px;
|
|
1265
|
-
font-size: 9px;
|
|
1266
|
-
font-weight: 600;
|
|
1267
|
-
text-transform: uppercase;
|
|
1268
|
-
white-space: nowrap;
|
|
1269
|
-
letter-spacing: 0.05em;
|
|
1270
|
-
color: #9ca3af;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
/* Grid layout for library shapes (icon-only buttons, 3 columns) */
|
|
1274
|
-
.shapes-library-grid {
|
|
1275
|
-
display: grid;
|
|
1276
|
-
grid-template-columns: repeat(3, 1fr);
|
|
1277
|
-
gap: 2px;
|
|
1278
|
-
padding: 4px 2px;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
.shape-library-bt {
|
|
1282
|
-
display: flex;
|
|
1283
|
-
align-items: center;
|
|
1284
|
-
justify-content: center;
|
|
1285
|
-
width: 40px;
|
|
1286
|
-
height: 40px;
|
|
1287
|
-
border: none;
|
|
1288
|
-
border-radius: 8px;
|
|
1289
|
-
background: transparent;
|
|
1290
|
-
color: #374151;
|
|
1291
|
-
cursor: pointer;
|
|
1292
|
-
transition: background 0.1s;
|
|
1293
|
-
}
|
|
1294
|
-
/* Scale SVG icons inside library shape buttons */
|
|
1295
|
-
.shape-library-bt :global(svg) {
|
|
1296
|
-
width: 20px;
|
|
1297
|
-
height: 20px;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
.shape-library-bt:hover {
|
|
1301
|
-
background: #f3f4f6;
|
|
1302
|
-
color: #111827;
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
/* ── Keyboard Shortcuts Panel ── */
|
|
1306
|
-
/* position:absolute so it centers within the canvas-container (position:relative),
|
|
1307
|
-
not the viewport — avoids issues with transformed ancestors. */
|
|
1308
|
-
.shortcuts-backdrop {
|
|
1309
|
-
position: absolute;
|
|
1310
|
-
inset: 0;
|
|
1311
|
-
background: rgba(0,0,0,0.3);
|
|
1312
|
-
z-index: 40;
|
|
1313
|
-
animation: backdrop-fade 0.1s ease-out forwards;
|
|
1314
|
-
}
|
|
1315
|
-
@keyframes backdrop-fade {
|
|
1316
|
-
from { opacity: 0; }
|
|
1317
|
-
to { opacity: 1; }
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
.shortcuts-panel {
|
|
1321
|
-
position: absolute;
|
|
1322
|
-
top: 50%;
|
|
1323
|
-
left: 50%;
|
|
1324
|
-
transform: translate(-50%, -50%);
|
|
1325
|
-
background: white;
|
|
1326
|
-
border-radius: 0.75rem;
|
|
1327
|
-
box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
|
|
1328
|
-
z-index: 50;
|
|
1329
|
-
width: min(580px, 90%);
|
|
1330
|
-
/* Panel has no own scroll — only the body section scrolls */
|
|
1331
|
-
overflow: hidden;
|
|
1332
|
-
display: flex;
|
|
1333
|
-
flex-direction: column;
|
|
1334
|
-
max-height: 85%;
|
|
1335
|
-
/* Fade and slide in — starts invisible to prevent flash */
|
|
1336
|
-
opacity: 0;
|
|
1337
|
-
animation: panel-appear 0.15s ease-out 0.02s forwards;
|
|
1338
|
-
}
|
|
1339
|
-
@keyframes panel-appear {
|
|
1340
|
-
from { opacity: 0; transform: translate(-50%, -48%); }
|
|
1341
|
-
to { opacity: 1; transform: translate(-50%, -50%); }
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
.shortcuts-panel-header {
|
|
1345
|
-
display: flex;
|
|
1346
|
-
align-items: center;
|
|
1347
|
-
justify-content: space-between;
|
|
1348
|
-
padding: 14px 16px;
|
|
1349
|
-
border-bottom: 1px solid #f3f4f6;
|
|
1350
|
-
flex-shrink: 0;
|
|
1351
|
-
}
|
|
1352
|
-
.shortcuts-panel-title-ct {
|
|
1353
|
-
display: flex;
|
|
1354
|
-
align-items: center;
|
|
1355
|
-
gap: 8px;
|
|
1356
|
-
}
|
|
1357
|
-
.shortcuts-panel-title {
|
|
1358
|
-
font-size: 0.9375rem;
|
|
1359
|
-
font-weight: 600;
|
|
1360
|
-
color: #111827;
|
|
1361
|
-
margin: 0;
|
|
1362
|
-
}
|
|
1363
|
-
.close-shortcuts-bt {
|
|
1364
|
-
color: #9ca3af;
|
|
1365
|
-
width: 28px;
|
|
1366
|
-
height: 28px;
|
|
1367
|
-
border: none;
|
|
1368
|
-
border-radius: 6px;
|
|
1369
|
-
padding: 0;
|
|
1370
|
-
background: transparent;
|
|
1371
|
-
box-shadow: none;
|
|
1372
|
-
font-size: 0.875rem;
|
|
1373
|
-
justify-content: center;
|
|
1374
|
-
flex-shrink: 0;
|
|
1375
|
-
}
|
|
1376
|
-
.close-shortcuts-bt:hover {
|
|
1377
|
-
background: #f3f4f6;
|
|
1378
|
-
color: #374151;
|
|
1379
|
-
}
|
|
1380
|
-
/* Scrollable section — only this part scrolls */
|
|
1381
|
-
.shortcuts-panel-body {
|
|
1382
|
-
display: flex;
|
|
1383
|
-
gap: 20px;
|
|
1384
|
-
padding: 8px 16px;
|
|
1385
|
-
overflow-y: auto;
|
|
1386
|
-
flex: 1 1 auto;
|
|
1387
|
-
}
|
|
1388
|
-
.shortcuts-column {
|
|
1389
|
-
flex: 1;
|
|
1390
|
-
display: flex;
|
|
1391
|
-
flex-direction: column;
|
|
1392
|
-
gap: 2px;
|
|
1393
|
-
}
|
|
1394
|
-
/* Custom scrollbar inside the panel body */
|
|
1395
|
-
.shortcuts-panel-body::-webkit-scrollbar {
|
|
1396
|
-
width: 4px;
|
|
1397
|
-
}
|
|
1398
|
-
.shortcuts-panel-body::-webkit-scrollbar-track {
|
|
1399
|
-
background: transparent;
|
|
1400
|
-
}
|
|
1401
|
-
.shortcuts-panel-body::-webkit-scrollbar-thumb {
|
|
1402
|
-
background: rgba(0,0,0,0.15);
|
|
1403
|
-
border-radius: 4px;
|
|
1404
|
-
}
|
|
1405
|
-
.shortcut-group {
|
|
1406
|
-
margin-bottom: 2px;
|
|
1407
|
-
}
|
|
1408
|
-
/* Remove extra bottom margin on the last group so panel body padding handles spacing */
|
|
1409
|
-
.shortcut-group:last-child {
|
|
1410
|
-
margin-bottom: 0;
|
|
1411
|
-
}
|
|
1412
|
-
.shortcut-group-title {
|
|
1413
|
-
font-size: 0.6875rem;
|
|
1414
|
-
font-weight: 700;
|
|
1415
|
-
color: #1f2937;
|
|
1416
|
-
text-transform: uppercase;
|
|
1417
|
-
letter-spacing: 0.06em;
|
|
1418
|
-
margin-bottom: 4px;
|
|
1419
|
-
}
|
|
1420
|
-
.shortcut-list {
|
|
1421
|
-
list-style: none;
|
|
1422
|
-
padding: 0;
|
|
1423
|
-
margin: 0;
|
|
1424
|
-
}
|
|
1425
|
-
.shortcut-row {
|
|
1426
|
-
display: flex;
|
|
1427
|
-
align-items: center;
|
|
1428
|
-
justify-content: space-between;
|
|
1429
|
-
padding: 3px 0;
|
|
1430
|
-
}
|
|
1431
|
-
.shortcut-label {
|
|
1432
|
-
font-size: 0.8125rem;
|
|
1433
|
-
color: #4b5563;
|
|
1434
|
-
}
|
|
1435
|
-
.shortcut-keys {
|
|
1436
|
-
display: flex;
|
|
1437
|
-
align-items: center;
|
|
1438
|
-
gap: 3px;
|
|
1439
|
-
flex-shrink: 0;
|
|
1440
|
-
margin-inline-start: 8px;
|
|
1441
|
-
}
|
|
1442
|
-
.shortcut-sep {
|
|
1443
|
-
font-size: 0.6875rem;
|
|
1444
|
-
color: #9ca3af;
|
|
1445
|
-
font-weight: 500;
|
|
1446
|
-
padding: 0 1px;
|
|
1447
|
-
}
|
|
1448
|
-
/* Key badge — single-char keys get equal width for a square look */
|
|
1449
|
-
.shortcut-key {
|
|
1450
|
-
background: #f3f4f6;
|
|
1451
|
-
color: #374151;
|
|
1452
|
-
font-size: 0.6875rem;
|
|
1453
|
-
font-family: ui-monospace, 'SFMono-Regular', monospace;
|
|
1454
|
-
padding: 3px 6px;
|
|
1455
|
-
border-radius: 4px;
|
|
1456
|
-
border: 1px solid #d1d5db;
|
|
1457
|
-
box-shadow: 0 1px 1px rgba(0,0,0,0.08);
|
|
1458
|
-
white-space: nowrap;
|
|
1459
|
-
min-width: 22px;
|
|
1460
|
-
height: 22px;
|
|
1461
|
-
display: inline-flex;
|
|
1462
|
-
align-items: center;
|
|
1463
|
-
justify-content: center;
|
|
1464
|
-
}
|
|
1465
|
-
.shortcuts-panel-footer {
|
|
1466
|
-
padding: 10px 16px 14px;
|
|
1467
|
-
text-align: center;
|
|
1468
|
-
font-size: 0.75rem;
|
|
1469
|
-
color: #9ca3af;
|
|
1470
|
-
border-top: 1px solid #f3f4f6;
|
|
1471
|
-
flex-shrink: 0;
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
/* Custom scrollbar for tools and actions containers */
|
|
1475
|
-
.tools-ct::-webkit-scrollbar,
|
|
1476
|
-
.actions-ct::-webkit-scrollbar {
|
|
1477
|
-
height: 4px;
|
|
1478
|
-
}
|
|
1479
|
-
.tools-ct::-webkit-scrollbar-track,
|
|
1480
|
-
.actions-ct::-webkit-scrollbar-track {
|
|
1481
|
-
background: transparent;
|
|
1482
|
-
}
|
|
1483
|
-
.tools-ct::-webkit-scrollbar-thumb,
|
|
1484
|
-
.actions-ct::-webkit-scrollbar-thumb {
|
|
1485
|
-
background: rgba(0, 0, 0, 0.15);
|
|
1486
|
-
border-radius: 4px;
|
|
1487
|
-
}
|
|
1488
|
-
.tools-ct::-webkit-scrollbar-thumb:hover,
|
|
1489
|
-
.actions-ct::-webkit-scrollbar-thumb:hover {
|
|
1490
|
-
background: rgba(0, 0, 0, 0.25);
|
|
1491
|
-
}
|
|
1492
|
-
/* Firefox scrollbar */
|
|
1493
|
-
.tools-ct,
|
|
1494
|
-
.actions-ct {
|
|
1495
|
-
scrollbar-width: thin;
|
|
1496
|
-
scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
|
|
1497
|
-
}
|
|
1498
|
-
</style>
|