@widgetic/canvas 0.5.7 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/Canvas.svelte +461 -134
- package/dist/canvas/Canvas.svelte.d.ts +5 -0
- package/dist/canvas/CanvasToolbar.svelte +115 -35
- package/dist/canvas/CanvasToolbar.svelte.d.ts +7 -2
- package/dist/canvas/PanZoomPanel.svelte +75 -19
- package/dist/canvas/props-panel/PropsPanel.svelte +21 -5
- package/dist/canvas/shapes/ImageShape.d.ts +9 -0
- package/dist/canvas/shapes/ImageShape.js +115 -24
- package/dist/components/Tooltip.svelte +10 -2
- package/package.json +1 -1
|
@@ -23,6 +23,8 @@ declare const __propDef: {
|
|
|
23
23
|
panZoomPosition?: "TL" | "TC" | "TR" | "BL" | "BC" | "BR";
|
|
24
24
|
wireframeMode?: boolean;
|
|
25
25
|
advancedFeatures?: boolean;
|
|
26
|
+
/** When true and advanced is on, Frame/Image/Video stay on the toolbar. Default true. */ mediaBtsOnBar?: boolean;
|
|
27
|
+
initialData?: string | null;
|
|
26
28
|
onReady?: (() => void) | null;
|
|
27
29
|
isExternalDataLoading?: boolean;
|
|
28
30
|
onBeforeUnmount?: ((json: string | null) => void) | null;
|
|
@@ -30,6 +32,7 @@ declare const __propDef: {
|
|
|
30
32
|
autosaveDelayMs?: number;
|
|
31
33
|
showSaveButton?: boolean;
|
|
32
34
|
onCanvasDirty?: (() => void) | null;
|
|
35
|
+
onCanvasCleared?: (() => void) | null;
|
|
33
36
|
onConvertToWidget?: ((data: WidgetConversionPayload) => void) | null;
|
|
34
37
|
onWidgetImageClick?: ((widgetId: string) => void) | null;
|
|
35
38
|
onNonWidgetSelected?: (() => void) | null;
|
|
@@ -91,6 +94,7 @@ declare const __propDef: {
|
|
|
91
94
|
setPrimaryWidgetShape?: (widgetId: string) => boolean;
|
|
92
95
|
getPrimaryWidgetId?: () => string | null;
|
|
93
96
|
onSelectImageTool?: () => void;
|
|
97
|
+
onSelectVideoTool?: () => void;
|
|
94
98
|
onSelectPanTool?: () => void;
|
|
95
99
|
zoomIn?: () => void;
|
|
96
100
|
zoomOut?: () => void;
|
|
@@ -173,6 +177,7 @@ export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEven
|
|
|
173
177
|
get setPrimaryWidgetShape(): (widgetId: string) => boolean;
|
|
174
178
|
get getPrimaryWidgetId(): () => string | null;
|
|
175
179
|
get onSelectImageTool(): () => void;
|
|
180
|
+
get onSelectVideoTool(): () => void;
|
|
176
181
|
get onSelectPanTool(): () => void;
|
|
177
182
|
get zoomIn(): () => void;
|
|
178
183
|
get zoomOut(): () => void;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* COMPONENT PROPS
|
|
8
8
|
*/
|
|
9
9
|
// Tool type definition
|
|
10
|
-
type ToolName = 'select' | 'erase' | 'draw' | 'arrow' | 'text' | 'rect' | 'circle' | 'circle-true' | 'triangle' | 'frame' | 'pan' | 'image' | 'library-shape';
|
|
10
|
+
type ToolName = 'select' | 'erase' | 'draw' | 'arrow' | 'text' | 'rect' | 'circle' | 'circle-true' | 'triangle' | 'frame' | 'pan' | 'image' | 'video' | 'library-shape';
|
|
11
11
|
// Shape tool sub-type for the shapes dropdown (Arrow is a dedicated button, not in dropdown)
|
|
12
12
|
type ShapeToolName = 'rect' | 'circle' | 'circle-true' | 'triangle';
|
|
13
13
|
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
export let onSelectTextTool: () => void = () => {};
|
|
32
32
|
export let onSelectPanTool: () => void = () => {};
|
|
33
33
|
export let onSelectImageTool: () => void = () => {};
|
|
34
|
+
export let onSelectVideoTool: () => void = () => {};
|
|
34
35
|
// Zoom callbacks — optional, used for Ctrl+/Ctrl- shortcuts
|
|
35
36
|
export let onZoomIn: () => void = () => {};
|
|
36
37
|
export let onZoomOut: () => void = () => {};
|
|
@@ -63,8 +64,16 @@
|
|
|
63
64
|
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */
|
|
64
65
|
export let onSelectLibraryShapeTool: (shapeKey: string, pathData: string) => void = () => {};
|
|
65
66
|
|
|
66
|
-
/** Extra tools (undo/redo/lock
|
|
67
|
+
/** Extra tools (undo/redo/lock). Code stays; UI is gated. */
|
|
67
68
|
export let advancedFeatures: boolean = false;
|
|
69
|
+
/**
|
|
70
|
+
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
71
|
+
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
72
|
+
*/
|
|
73
|
+
export let mediaBtsOnBar: boolean = true;
|
|
74
|
+
|
|
75
|
+
$: showMediaOnBar = advancedFeatures && mediaBtsOnBar;
|
|
76
|
+
$: showMediaInDropdown = !showMediaOnBar;
|
|
68
77
|
|
|
69
78
|
// Pre-group shapes for the dropdown
|
|
70
79
|
const libraryShapesByCategory = getShapesByCategory();
|
|
@@ -79,7 +88,7 @@
|
|
|
79
88
|
|
|
80
89
|
// ─── Shapes + Image dropdown state ───
|
|
81
90
|
// The last-selected tool within the dropdown (shapes, image, OR library shape).
|
|
82
|
-
type DropdownToolName = ShapeToolName | 'image' | 'library-shape';
|
|
91
|
+
type DropdownToolName = ShapeToolName | 'image' | 'video' | 'frame' | 'library-shape';
|
|
83
92
|
let lastSelectedDropdownTool: DropdownToolName = 'rect';
|
|
84
93
|
// When a library shape was last selected, store its info for the trigger button
|
|
85
94
|
let lastSelectedLibraryShape: LibraryShape | null = null;
|
|
@@ -137,12 +146,29 @@
|
|
|
137
146
|
};
|
|
138
147
|
|
|
139
148
|
// The currently displayed tool in the dropdown button (active tool if it's a dropdown tool, else last selected)
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
const mediaToolInfo: Record<'frame' | 'image' | 'video', { iconSvg: string; label: string; key: string }> = {
|
|
150
|
+
frame: {
|
|
151
|
+
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>`,
|
|
152
|
+
label: 'Frame',
|
|
153
|
+
key: 'F',
|
|
154
|
+
},
|
|
155
|
+
image: {
|
|
156
|
+
iconSvg: imageDropdownInfo.iconSvg,
|
|
157
|
+
label: 'Image',
|
|
158
|
+
key: 'I',
|
|
159
|
+
},
|
|
160
|
+
video: {
|
|
161
|
+
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>`,
|
|
162
|
+
label: 'Video',
|
|
163
|
+
key: '',
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const dropdownTools: DropdownToolName[] = ['rect', 'circle', 'circle-true', 'triangle', 'image', 'video', 'frame', 'library-shape'];
|
|
168
|
+
$: activeDropdownTool = dropdownTools.includes(activeTool as DropdownToolName)
|
|
143
169
|
? (activeTool as DropdownToolName)
|
|
144
170
|
: lastSelectedDropdownTool;
|
|
145
|
-
$: activeDropdownIsActive =
|
|
171
|
+
$: activeDropdownIsActive = dropdownTools.includes(activeTool as DropdownToolName);
|
|
146
172
|
|
|
147
173
|
// Backwards-compat aliases used in template
|
|
148
174
|
$: activeShapeInDropdown = activeDropdownTool as ShapeToolName;
|
|
@@ -155,10 +181,23 @@
|
|
|
155
181
|
}
|
|
156
182
|
|
|
157
183
|
function selectImageFromDropdown() {
|
|
184
|
+
lastSelectedDropdownTool = 'image';
|
|
158
185
|
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
159
186
|
onSelectImageTool();
|
|
160
187
|
}
|
|
161
188
|
|
|
189
|
+
function selectFrameFromDropdown() {
|
|
190
|
+
lastSelectedDropdownTool = 'frame';
|
|
191
|
+
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
192
|
+
onSelectFrameTool();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function selectVideoFromDropdown() {
|
|
196
|
+
lastSelectedDropdownTool = 'video';
|
|
197
|
+
if (!KEEP_SHAPES_DROPDOWN_OPEN) shapesDropdownOpen = false;
|
|
198
|
+
onSelectVideoTool();
|
|
199
|
+
}
|
|
200
|
+
|
|
162
201
|
function selectLibraryShape(shape: LibraryShape) {
|
|
163
202
|
lastSelectedDropdownTool = 'library-shape';
|
|
164
203
|
lastSelectedLibraryShape = shape;
|
|
@@ -170,14 +209,26 @@
|
|
|
170
209
|
function activateDropdownTool() {
|
|
171
210
|
if (activeDropdownTool === 'library-shape' && lastSelectedLibraryShape) {
|
|
172
211
|
selectLibraryShape(lastSelectedLibraryShape);
|
|
212
|
+
} else if (activeDropdownTool === 'image') {
|
|
213
|
+
selectImageFromDropdown();
|
|
214
|
+
} else if (activeDropdownTool === 'video') {
|
|
215
|
+
selectVideoFromDropdown();
|
|
216
|
+
} else if (activeDropdownTool === 'frame') {
|
|
217
|
+
selectFrameFromDropdown();
|
|
173
218
|
} else {
|
|
174
219
|
selectShape(activeDropdownTool as ShapeToolName);
|
|
175
220
|
}
|
|
176
221
|
}
|
|
177
222
|
|
|
223
|
+
$: mediaTrigger = (activeDropdownTool === 'frame' || activeDropdownTool === 'image' || activeDropdownTool === 'video')
|
|
224
|
+
? mediaToolInfo[activeDropdownTool]
|
|
225
|
+
: null;
|
|
226
|
+
|
|
178
227
|
// Tooltip text for the main dropdown button
|
|
179
228
|
$: dropdownButtonTooltip = activeDropdownTool === 'library-shape' && lastSelectedLibraryShape
|
|
180
229
|
? lastSelectedLibraryShape.label
|
|
230
|
+
: mediaTrigger
|
|
231
|
+
? (mediaTrigger.key ? `${mediaTrigger.label} (${mediaTrigger.key})` : mediaTrigger.label)
|
|
181
232
|
: shapeInfo[activeDropdownTool as ShapeToolName]?.label
|
|
182
233
|
? (shapeInfo[activeDropdownTool as ShapeToolName].key
|
|
183
234
|
? `${shapeInfo[activeDropdownTool as ShapeToolName].label} (${shapeInfo[activeDropdownTool as ShapeToolName].key})`
|
|
@@ -388,12 +439,12 @@
|
|
|
388
439
|
case 'D': event.preventDefault(); onSelectDrawTool(); break;
|
|
389
440
|
case 'H': event.preventDefault(); onSelectPanTool(); break;
|
|
390
441
|
case 'A': event.preventDefault(); selectShape('arrow'); break;
|
|
391
|
-
case 'R':
|
|
392
|
-
case 'G':
|
|
393
|
-
case 'O':
|
|
394
|
-
case 'F':
|
|
442
|
+
case 'R': event.preventDefault(); selectShape('rect'); break;
|
|
443
|
+
case 'G': event.preventDefault(); selectShape('triangle'); break;
|
|
444
|
+
case 'O': event.preventDefault(); selectShape('circle'); break;
|
|
445
|
+
case 'F': event.preventDefault(); onSelectFrameTool(); break;
|
|
395
446
|
case 'T': event.preventDefault(); onSelectTextTool(); break;
|
|
396
|
-
case 'I':
|
|
447
|
+
case 'I': event.preventDefault(); onSelectImageTool(); break;
|
|
397
448
|
}
|
|
398
449
|
}
|
|
399
450
|
|
|
@@ -628,7 +679,7 @@
|
|
|
628
679
|
</button>
|
|
629
680
|
</Tooltip>
|
|
630
681
|
|
|
631
|
-
{#if
|
|
682
|
+
{#if showMediaOnBar}
|
|
632
683
|
<div class="toolbar-divider"></div>
|
|
633
684
|
|
|
634
685
|
<Tooltip text="Frame (F)">
|
|
@@ -655,7 +706,19 @@
|
|
|
655
706
|
</button>
|
|
656
707
|
</Tooltip>
|
|
657
708
|
|
|
658
|
-
|
|
709
|
+
<Tooltip text="Video">
|
|
710
|
+
<button class="video-bt {buttonClass} {activeTool === 'video' ? activeClass : inactiveClass}"
|
|
711
|
+
onclick={onSelectVideoTool}
|
|
712
|
+
aria-label="Video">
|
|
713
|
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
714
|
+
<rect x="2" y="6" width="14" height="12" rx="2"/>
|
|
715
|
+
<path d="M16 10l6-3v10l-6-3z"/>
|
|
716
|
+
</svg>
|
|
717
|
+
</button>
|
|
718
|
+
</Tooltip>
|
|
719
|
+
{/if}
|
|
720
|
+
|
|
721
|
+
<!-- Shapes: tldraw-style split — left activates tool, right opens dropdown. Always available. -->
|
|
659
722
|
<div class="shapes-split-ct" bind:this={dropdownTriggerEl}>
|
|
660
723
|
<Tooltip text={dropdownButtonTooltip}>
|
|
661
724
|
<button
|
|
@@ -665,6 +728,8 @@
|
|
|
665
728
|
>
|
|
666
729
|
{#if activeDropdownTool === 'library-shape' && lastSelectedLibraryShape}
|
|
667
730
|
{@html lastSelectedLibraryShape.iconSvg}
|
|
731
|
+
{:else if mediaTrigger}
|
|
732
|
+
{@html mediaTrigger.iconSvg}
|
|
668
733
|
{:else if shapeInfo[activeDropdownTool as ShapeToolName]}
|
|
669
734
|
{@html shapeInfo[activeDropdownTool as ShapeToolName].iconSvg}
|
|
670
735
|
{:else}
|
|
@@ -684,7 +749,6 @@
|
|
|
684
749
|
</button>
|
|
685
750
|
</Tooltip>
|
|
686
751
|
</div>
|
|
687
|
-
{/if}
|
|
688
752
|
</div>
|
|
689
753
|
</div>
|
|
690
754
|
|
|
@@ -715,7 +779,7 @@
|
|
|
715
779
|
dropdownOpenAbove=true: appears above the trigger (toolbar at bottom).
|
|
716
780
|
dropdownOpenAbove=false: appears below (toolbar at top).
|
|
717
781
|
═══════════════════════════════════════════════════════════════ -->
|
|
718
|
-
{#if shapesDropdownOpen
|
|
782
|
+
{#if shapesDropdownOpen}
|
|
719
783
|
<!-- position:absolute within .canvas-container (position:relative) so the dropdown
|
|
720
784
|
is correctly positioned regardless of any CSS transform on ancestors. -->
|
|
721
785
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
@@ -729,6 +793,29 @@
|
|
|
729
793
|
use:overlayScrollbar
|
|
730
794
|
style={shapesDropdownNeedsScroll ? 'margin-right: -6px' : ''}
|
|
731
795
|
>
|
|
796
|
+
<!-- Media Shapes — first so Frame / Image / Video are easy to reach when not on the bar -->
|
|
797
|
+
{#if showMediaInDropdown}
|
|
798
|
+
<div class="shapes-category-label">Media Shapes</div>
|
|
799
|
+
<div class="shapes-library-grid">
|
|
800
|
+
<Tooltip text="Frame (F)" position="above">
|
|
801
|
+
<button class="shape-library-bt {activeTool === 'frame' ? 'active' : ''}" onclick={selectFrameFromDropdown} aria-label="Frame">
|
|
802
|
+
<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>
|
|
803
|
+
</button>
|
|
804
|
+
</Tooltip>
|
|
805
|
+
<Tooltip text="Image (I)" position="above">
|
|
806
|
+
<button class="shape-library-bt {activeTool === 'image' ? 'active' : ''}" onclick={selectImageFromDropdown} aria-label="Image">
|
|
807
|
+
{@html imageDropdownInfo.iconSvg}
|
|
808
|
+
</button>
|
|
809
|
+
</Tooltip>
|
|
810
|
+
<Tooltip text="Video" position="above">
|
|
811
|
+
<button class="shape-library-bt {activeTool === 'video' ? 'active' : ''}" onclick={selectVideoFromDropdown} aria-label="Video">
|
|
812
|
+
<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>
|
|
813
|
+
</button>
|
|
814
|
+
</Tooltip>
|
|
815
|
+
</div>
|
|
816
|
+
<div class="shapes-dropdown-divider"></div>
|
|
817
|
+
{/if}
|
|
818
|
+
|
|
732
819
|
<!-- Geometric Shapes — 3×2 grid -->
|
|
733
820
|
<div class="shapes-category-label">Geometric Shapes</div>
|
|
734
821
|
<div class="shapes-library-grid">
|
|
@@ -768,21 +855,6 @@
|
|
|
768
855
|
{/each}
|
|
769
856
|
</div>
|
|
770
857
|
|
|
771
|
-
<!-- Media (hidden — Image tool moved to main toolbar) -->
|
|
772
|
-
{#if false}
|
|
773
|
-
<div class="shapes-dropdown-divider"></div>
|
|
774
|
-
<div class="shapes-category-label">Media</div>
|
|
775
|
-
<Tooltip text="Image (I)" position="above">
|
|
776
|
-
<button
|
|
777
|
-
class="shape-option-bt {activeTool === 'image' ? 'active' : ''}"
|
|
778
|
-
onclick={selectImageFromDropdown}
|
|
779
|
-
>
|
|
780
|
-
{@html imageDropdownInfo.iconSvg}
|
|
781
|
-
{imageDropdownInfo.label}
|
|
782
|
-
</button>
|
|
783
|
-
</Tooltip>
|
|
784
|
-
{/if}
|
|
785
|
-
|
|
786
858
|
<!-- Library shape categories (skip Geometric, already rendered above) -->
|
|
787
859
|
{#each [...libraryShapesByCategory.entries()].filter(([cat]) => cat !== 'Geometric Shapes') as [category, shapes]}
|
|
788
860
|
<div class="shapes-dropdown-divider"></div>
|
|
@@ -901,6 +973,13 @@
|
|
|
901
973
|
background: transparent !important;
|
|
902
974
|
box-shadow: none !important;
|
|
903
975
|
}
|
|
976
|
+
.canvas-toolbar-el :global(button:focus),
|
|
977
|
+
.canvas-toolbar-el :global(button:focus-visible),
|
|
978
|
+
.canvas-toolbar-el :global(a:focus),
|
|
979
|
+
.canvas-toolbar-el :global(a:focus-visible) {
|
|
980
|
+
outline: none !important;
|
|
981
|
+
box-shadow: none !important;
|
|
982
|
+
}
|
|
904
983
|
|
|
905
984
|
/* ── "Sheath" — the white container holding all buttons ── */
|
|
906
985
|
.tools-ct {
|
|
@@ -908,7 +987,7 @@
|
|
|
908
987
|
border-radius: 1.25rem;
|
|
909
988
|
box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
|
|
910
989
|
height: 80px;
|
|
911
|
-
padding: 0
|
|
990
|
+
padding: 0 24px;
|
|
912
991
|
gap: 4px;
|
|
913
992
|
align-items: center;
|
|
914
993
|
overflow: visible;
|
|
@@ -926,9 +1005,10 @@ button {
|
|
|
926
1005
|
background: transparent;
|
|
927
1006
|
}
|
|
928
1007
|
|
|
929
|
-
button:focus
|
|
930
|
-
|
|
931
|
-
|
|
1008
|
+
button:focus,
|
|
1009
|
+
button:focus-visible {
|
|
1010
|
+
outline: none !important;
|
|
1011
|
+
box-shadow: none !important;
|
|
932
1012
|
}
|
|
933
1013
|
|
|
934
1014
|
button:disabled {
|
|
@@ -3,7 +3,7 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
class?: string;
|
|
5
5
|
style?: string;
|
|
6
|
-
activeTool?: "select" | "rect" | "erase" | "draw" | "arrow" | "text" | "circle" | "circle-true" | "triangle" | "frame" | "pan" | "image" | "library-shape";
|
|
6
|
+
activeTool?: "select" | "video" | "rect" | "erase" | "draw" | "arrow" | "text" | "circle" | "circle-true" | "triangle" | "frame" | "pan" | "image" | "library-shape";
|
|
7
7
|
activeClass?: string;
|
|
8
8
|
inactiveClass?: string;
|
|
9
9
|
buttonClass?: string;
|
|
@@ -15,6 +15,7 @@ declare const __propDef: {
|
|
|
15
15
|
onSelectTextTool?: () => void;
|
|
16
16
|
onSelectPanTool?: () => void;
|
|
17
17
|
onSelectImageTool?: () => void;
|
|
18
|
+
onSelectVideoTool?: () => void;
|
|
18
19
|
onZoomIn?: () => void;
|
|
19
20
|
onZoomOut?: () => void;
|
|
20
21
|
onZoomReset?: () => void;
|
|
@@ -32,7 +33,11 @@ declare const __propDef: {
|
|
|
32
33
|
onToggleStickyTool?: () => void;
|
|
33
34
|
/** Called when user clicks a library shape. Canvas inserts it as a Path. */ onInsertLibraryShape?: (shapeKey: string, pathData: string) => void;
|
|
34
35
|
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */ onSelectLibraryShapeTool?: (shapeKey: string, pathData: string) => void;
|
|
35
|
-
/** Extra tools (undo/redo/lock
|
|
36
|
+
/** Extra tools (undo/redo/lock). Code stays; UI is gated. */ advancedFeatures?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
39
|
+
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
40
|
+
*/ mediaBtsOnBar?: boolean;
|
|
36
41
|
addText?: () => void;
|
|
37
42
|
addRect?: () => void;
|
|
38
43
|
addTriangle?: () => void;
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
|
|
65
65
|
function toggleMinimized() {
|
|
66
66
|
isMinimized = !isMinimized;
|
|
67
|
-
console.log('[PanZoomPanel] minimized:', isMinimized);
|
|
67
|
+
// console.log('[PanZoomPanel] minimized:', isMinimized);
|
|
68
68
|
}
|
|
69
69
|
</script>
|
|
70
70
|
|
|
@@ -134,6 +134,19 @@
|
|
|
134
134
|
|
|
135
135
|
<!-- Zoom Level Input -->
|
|
136
136
|
<div class="zoom-level">
|
|
137
|
+
<Tooltip text="Reset zoom to 100% [Ctrl/Cmd] + [0]" position="above">
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
class="zoom-reset-in-input"
|
|
141
|
+
onclick={onZoomReset}
|
|
142
|
+
aria-label="Reset zoom to 100%"
|
|
143
|
+
>
|
|
144
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
145
|
+
<polyline points="1 4 1 10 7 10"/>
|
|
146
|
+
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>
|
|
147
|
+
</svg>
|
|
148
|
+
</button>
|
|
149
|
+
</Tooltip>
|
|
137
150
|
<input
|
|
138
151
|
type="text"
|
|
139
152
|
class="zoom-input"
|
|
@@ -208,7 +221,7 @@
|
|
|
208
221
|
</Tooltip>
|
|
209
222
|
{/if}
|
|
210
223
|
|
|
211
|
-
|
|
224
|
+
{#if showSaveButton && advancedFeatures}
|
|
212
225
|
<div class="divider"></div>
|
|
213
226
|
<Tooltip text={hasUnsavedChanges ? 'Unsaved changes — click to save [Cmd+S]' : 'All changes saved [Cmd+S]'} position="above">
|
|
214
227
|
<button
|
|
@@ -229,18 +242,15 @@
|
|
|
229
242
|
{/if}
|
|
230
243
|
|
|
231
244
|
<div class="pan-zoom-minimize-anchor">
|
|
232
|
-
<Tooltip text="Minimize
|
|
245
|
+
<Tooltip text="Minimize Zoom Panel" position="above">
|
|
233
246
|
<button
|
|
234
247
|
type="button"
|
|
235
|
-
class="
|
|
248
|
+
class="pan-zoom-minimize-btn"
|
|
236
249
|
onclick={toggleMinimized}
|
|
237
|
-
aria-label="Minimize
|
|
250
|
+
aria-label="Minimize Zoom Panel"
|
|
238
251
|
>
|
|
239
|
-
<svg width="
|
|
240
|
-
<
|
|
241
|
-
<polyline points="20 10 14 10 14 4"/>
|
|
242
|
-
<line x1="14" y1="10" x2="21" y2="3"/>
|
|
243
|
-
<line x1="3" y1="21" x2="10" y2="14"/>
|
|
252
|
+
<svg width="8" height="8" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
253
|
+
<rect x="2" y="5.25" width="8" height="1.5" rx="0.25" fill="currentColor"/>
|
|
244
254
|
</svg>
|
|
245
255
|
</button>
|
|
246
256
|
</Tooltip>
|
|
@@ -272,11 +282,25 @@
|
|
|
272
282
|
}
|
|
273
283
|
|
|
274
284
|
.pan-zoom-minimize-btn {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
justify-content: center;
|
|
288
|
+
width: 14px;
|
|
289
|
+
height: 14px;
|
|
290
|
+
padding: 0;
|
|
291
|
+
border-radius: 9999px;
|
|
292
|
+
background: #ffffff;
|
|
293
|
+
border: 1px solid #9ca3af;
|
|
294
|
+
color: #9ca3af;
|
|
295
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
|
|
296
|
+
cursor: pointer;
|
|
297
|
+
transition: color 0.15s ease, border-color 0.15s ease;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.pan-zoom-minimize-btn:hover:not(:disabled) {
|
|
301
|
+
background: #ffffff;
|
|
302
|
+
border-color: #111827;
|
|
303
|
+
color: #111827;
|
|
280
304
|
}
|
|
281
305
|
|
|
282
306
|
.pan-zoom-panel-minimized {
|
|
@@ -342,6 +366,14 @@
|
|
|
342
366
|
cursor: not-allowed;
|
|
343
367
|
}
|
|
344
368
|
|
|
369
|
+
.pan-zoom-panel button:focus,
|
|
370
|
+
.pan-zoom-panel button:focus-visible,
|
|
371
|
+
.pan-zoom-panel input:focus,
|
|
372
|
+
.pan-zoom-panel input:focus-visible {
|
|
373
|
+
outline: none;
|
|
374
|
+
box-shadow: none;
|
|
375
|
+
}
|
|
376
|
+
|
|
345
377
|
/* Keyboard shortcuts button — slightly bigger to ensure the icon is clearly readable */
|
|
346
378
|
.shortcuts-btn {
|
|
347
379
|
width: 36px;
|
|
@@ -370,14 +402,34 @@
|
|
|
370
402
|
background: #f9fafb;
|
|
371
403
|
}
|
|
372
404
|
|
|
405
|
+
.zoom-reset-in-input {
|
|
406
|
+
display: flex;
|
|
407
|
+
align-items: center;
|
|
408
|
+
justify-content: center;
|
|
409
|
+
width: 18px;
|
|
410
|
+
height: 24px;
|
|
411
|
+
padding: 0;
|
|
412
|
+
margin: 0 0 0 2px;
|
|
413
|
+
border: none;
|
|
414
|
+
background: transparent;
|
|
415
|
+
color: #6b7280;
|
|
416
|
+
cursor: pointer;
|
|
417
|
+
flex-shrink: 0;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.zoom-reset-in-input:hover {
|
|
421
|
+
color: #111827;
|
|
422
|
+
background: #f3f4f6;
|
|
423
|
+
}
|
|
424
|
+
|
|
373
425
|
.zoom-input {
|
|
374
|
-
width:
|
|
375
|
-
padding: 4px
|
|
426
|
+
width: 28px;
|
|
427
|
+
padding: 4px 0;
|
|
376
428
|
border: none;
|
|
377
429
|
background: transparent;
|
|
378
430
|
font-size: 12px;
|
|
379
431
|
font-weight: 500;
|
|
380
|
-
text-align:
|
|
432
|
+
text-align: center;
|
|
381
433
|
outline: none;
|
|
382
434
|
}
|
|
383
435
|
|
|
@@ -386,9 +438,13 @@
|
|
|
386
438
|
}
|
|
387
439
|
|
|
388
440
|
.zoom-unit {
|
|
389
|
-
|
|
441
|
+
width: 18px;
|
|
442
|
+
padding: 4px 0;
|
|
443
|
+
margin: 0 2px 0 0;
|
|
390
444
|
font-size: 11px;
|
|
391
445
|
color: #6b7280;
|
|
446
|
+
text-align: center;
|
|
447
|
+
flex-shrink: 0;
|
|
392
448
|
}
|
|
393
449
|
|
|
394
450
|
.save-btn--dirty {
|
|
@@ -122,9 +122,8 @@
|
|
|
122
122
|
$: isFrame = customType === 'frame' || objectType === 'frame';
|
|
123
123
|
// WidgetShape is a Rect subclass with _customType === 'image'
|
|
124
124
|
// isImagePlaceholder: when no image loaded yet (_hasImage is false)
|
|
125
|
-
$: isImagePlaceholder = customType === 'image' && !selectedObject?._hasImage;
|
|
126
|
-
|
|
127
|
-
$: isRect = objectType === 'rect' && !isFrame && customType !== 'image';
|
|
125
|
+
$: isImagePlaceholder = (customType === 'image' || customType === 'video') && !selectedObject?._hasImage;
|
|
126
|
+
$: isRect = objectType === 'rect' && !isFrame && customType !== 'image' && customType !== 'video';
|
|
128
127
|
$: isTextbox = objectType === 'textbox';
|
|
129
128
|
$: isPath = objectType === 'path' && !customType;
|
|
130
129
|
$: isArrow = objectType === 'path' && customType === 'arrow';
|
|
@@ -141,7 +140,7 @@
|
|
|
141
140
|
$: isMultiSelect = (isGroup && !isFrame) || isActiveSelection;
|
|
142
141
|
$: isPlainGroup = isGroup && !isFrame;
|
|
143
142
|
$: isLine = objectType === 'line';
|
|
144
|
-
$: isImage = objectType === 'image' || customType === 'image';
|
|
143
|
+
$: isImage = objectType === 'image' || customType === 'image' || customType === 'video';
|
|
145
144
|
// Widget link: true when the selected object has already been converted to a widget
|
|
146
145
|
$: hasWidgetId = !!selectedObject?._widgetId;
|
|
147
146
|
$: widgetId = selectedObject?._widgetId ?? null;
|
|
@@ -195,6 +194,7 @@
|
|
|
195
194
|
if (obj._customType === 'frame') return 'Frame';
|
|
196
195
|
if (obj._customType === 'arrow') return 'Arrow';
|
|
197
196
|
if (obj._customType === 'triangle') return 'Triangle';
|
|
197
|
+
if (obj._customType === 'video') return 'Video';
|
|
198
198
|
if (obj._customType === 'image' || obj.type === 'image') return 'Image';
|
|
199
199
|
// Library shapes: derive a readable name from _shapeKey (e.g. 'arrow-right' → 'Arrow Right')
|
|
200
200
|
// Fall back to 'Custom Shape (Drawing)' if _shapeKey is missing (old saves).
|
|
@@ -226,7 +226,13 @@
|
|
|
226
226
|
// Get current values from selected object
|
|
227
227
|
// For Frames (Group-based), read fill/stroke from custom properties (_frameFill, _frameStroke)
|
|
228
228
|
// because the actual fill/stroke is on the background Rect child, not the Group itself
|
|
229
|
-
$:
|
|
229
|
+
$: usesPathBackgroundFill = selectedObject?._cornerRadiusMode === 'strokeRound'
|
|
230
|
+
|| ['cross', 'plus', 'minus', 'check'].includes(selectedObject?._shapeKey);
|
|
231
|
+
$: currentFill = isFrame
|
|
232
|
+
? (selectedObject?._frameFill ?? '#FFFFFF')
|
|
233
|
+
: (usesPathBackgroundFill
|
|
234
|
+
? (selectedObject?._iconFill || selectedObject?.backgroundColor || '#FFFFFF')
|
|
235
|
+
: (selectedObject?.fill ?? '#FFFFFF'));
|
|
230
236
|
$: currentFillOpacity = Math.round((selectedObject?._fillOpacity ?? 1) * 100);
|
|
231
237
|
$: currentStroke = isFrame ? (selectedObject?._frameStroke ?? '#000000') : (selectedObject?.stroke ?? '#000000');
|
|
232
238
|
$: currentStrokeWidth = isFrame ? (selectedObject?._frameStrokeWidth ?? 1) : (selectedObject?.strokeWidth ?? 1);
|
|
@@ -1305,6 +1311,16 @@
|
|
|
1305
1311
|
border-radius: 8px;
|
|
1306
1312
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
1307
1313
|
}
|
|
1314
|
+
|
|
1315
|
+
.props-panel-el :global(button:focus),
|
|
1316
|
+
.props-panel-el :global(button:focus-visible),
|
|
1317
|
+
.props-panel-el :global(a:focus),
|
|
1318
|
+
.props-panel-el :global(a:focus-visible),
|
|
1319
|
+
.props-panel-el :global(input:focus),
|
|
1320
|
+
.props-panel-el :global(input:focus-visible) {
|
|
1321
|
+
outline: none !important;
|
|
1322
|
+
box-shadow: none !important;
|
|
1323
|
+
}
|
|
1308
1324
|
|
|
1309
1325
|
/* Sticky header: stays at top, never scrolls */
|
|
1310
1326
|
.props-panel-sticky-header {
|
|
@@ -24,8 +24,17 @@ export declare class ImageShape extends Rect {
|
|
|
24
24
|
_cornerRoundness: number;
|
|
25
25
|
_cornerRoundnessPixels: number;
|
|
26
26
|
_objectId: string | null;
|
|
27
|
+
_videoElement: HTMLVideoElement | null;
|
|
28
|
+
_videoObjectUrl: string | null;
|
|
27
29
|
_render(ctx: CanvasRenderingContext2D): void;
|
|
28
30
|
private _renderImage;
|
|
31
|
+
getVideoPlayBadgeRadius(): number;
|
|
32
|
+
isVideoPlayBadgeHit(scenePoint: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}): boolean;
|
|
36
|
+
toggleVideoPlayback(): Promise<boolean>;
|
|
37
|
+
private _renderVideoChrome;
|
|
29
38
|
private _renderPlaceholderOverlay;
|
|
30
39
|
toObject(propertiesToInclude?: any[]): any;
|
|
31
40
|
static fromObject(object: Record<string, unknown>, options?: Record<string, unknown>): Promise<ImageShape>;
|