@widgetic/canvas 0.5.34 → 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/autosaveScheduler.d.ts +58 -0
- package/dist/canvas/autosaveScheduler.js +157 -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 +9 -7
- package/dist/canvas/index.js +9 -7
- 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 +24 -0
- package/dist/canvas/toolbarPosition.js +24 -0
- 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 +6 -2
- package/dist/index.js +6 -2
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13299
- package/dist/canvas/Canvas.svelte.d.ts +0 -281
- 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,69 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const CanvasToolbar: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
class?: string;
|
|
16
|
-
style?: string;
|
|
17
|
-
activeTool?: "select" | "video" | "text" | "rect" | "circle" | "triangle" | "frame" | "arrow" | "image" | "erase" | "draw" | "circle-true" | "pan" | "library-shape";
|
|
18
|
-
activeClass?: string;
|
|
19
|
-
inactiveClass?: string;
|
|
20
|
-
buttonClass?: string;
|
|
21
|
-
onSelectSelectTool?: () => void;
|
|
22
|
-
onSelectEraseTool?: () => void;
|
|
23
|
-
onSelectDrawTool?: () => void;
|
|
24
|
-
onSelectShapeTool?: (shapeType: "rect" | "circle" | "triangle" | "arrow" | "circle-true") => void;
|
|
25
|
-
onSelectFrameTool?: () => void;
|
|
26
|
-
onSelectTextTool?: () => void;
|
|
27
|
-
onSelectPanTool?: () => void;
|
|
28
|
-
onSelectImageTool?: () => void;
|
|
29
|
-
onSelectVideoTool?: () => void;
|
|
30
|
-
onZoomIn?: () => void;
|
|
31
|
-
onZoomOut?: () => void;
|
|
32
|
-
onZoomReset?: () => void;
|
|
33
|
-
onZoomFit?: () => void;
|
|
34
|
-
onGroupSelection?: () => void;
|
|
35
|
-
onUngroupSelection?: () => void;
|
|
36
|
-
onDuplicateSelection?: () => void;
|
|
37
|
-
onSelectAllObjects?: () => void;
|
|
38
|
-
onClearAllObjects?: () => void;
|
|
39
|
-
onUndo?: () => void;
|
|
40
|
-
onRedo?: () => void;
|
|
41
|
-
/** Disables the Undo button when there is no prior state to go back to. */ canUndo?: boolean;
|
|
42
|
-
/** Disables the Redo button when there is no future state to redo to. */ canRedo?: boolean;
|
|
43
|
-
/** When true, the drawing tool stays active after placing a shape. */ stickyToolEnabled?: boolean;
|
|
44
|
-
onToggleStickyTool?: () => void;
|
|
45
|
-
/** Pencil, eraser, select, arrow and text. Off after the widget has been generated. */ showDrawingTools?: boolean;
|
|
46
|
-
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
47
|
-
* init-set contract without the unused-reactive warning. */ onInsertLibraryShape?: (shapeKey: string, pathData: string) => void;
|
|
48
|
-
/** Draw-to-place: activates library shape tool so user clicks-and-drags to size it. */ onSelectLibraryShapeTool?: (shapeKey: string, pathData: string) => void;
|
|
49
|
-
/** Extra tools (undo, redo, lock, shapes). Arrow stays on the simple bar. */ advancedFeatures?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* When true (default) and advancedFeatures is on, Frame / Image / Video sit on the toolbar.
|
|
52
|
-
* When false, they leave the bar and appear under More Shapes → Media Shapes.
|
|
53
|
-
*/ mediaBtsOnBar?: boolean;
|
|
54
|
-
addText?: () => void;
|
|
55
|
-
addRect?: () => void;
|
|
56
|
-
addTriangle?: () => void;
|
|
57
|
-
addCircle?: () => void;
|
|
58
|
-
addFrame?: () => void;
|
|
59
|
-
addImage?: () => void;
|
|
60
|
-
shortcutsPanelOpen?: boolean;
|
|
61
|
-
onShortcutsToggle?: () => void;
|
|
62
|
-
}, {
|
|
63
|
-
[evt: string]: CustomEvent<any>;
|
|
64
|
-
}, {}, {
|
|
65
|
-
/** Passed by Canvas.svelte but never read here — export const keeps the
|
|
66
|
-
* init-set contract without the unused-reactive warning. */ onInsertLibraryShape: (shapeKey: string, pathData: string) => void;
|
|
67
|
-
}, string>;
|
|
68
|
-
type CanvasToolbar = InstanceType<typeof CanvasToolbar>;
|
|
69
|
-
export default CanvasToolbar;
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte';
|
|
3
|
-
import { eventWentThrough } from './eventScope';
|
|
4
|
-
import { useCanvasLanguage } from '../i18n/language.js';
|
|
5
|
-
|
|
6
|
-
// The words of the menu, in the language of the canvas it is on (English when it is used on its own)
|
|
7
|
-
const { t } = useCanvasLanguage();
|
|
8
|
-
|
|
9
|
-
// The key that does the same as each item, as the Mac writes it (⌘ is its Command key, ⇧ its Shift key). These are
|
|
10
|
-
// key caps, not words, so they are the same in every language.
|
|
11
|
-
const menuKeys = {
|
|
12
|
-
cut: '⌘X',
|
|
13
|
-
copy: '⌘C',
|
|
14
|
-
paste: '⌘V',
|
|
15
|
-
duplicate: '⌘D',
|
|
16
|
-
group: '⌘G',
|
|
17
|
-
ungroup: '⌘⇧G',
|
|
18
|
-
bringToFront: '⌘]',
|
|
19
|
-
bringForward: ']',
|
|
20
|
-
sendBackward: '[',
|
|
21
|
-
sendToBack: '⌘[',
|
|
22
|
-
delete: '⌫',
|
|
23
|
-
selectAll: '⌘A'
|
|
24
|
-
} as const;
|
|
25
|
-
|
|
26
|
-
// ── Position & visibility ──────────────────────────────────────────────────
|
|
27
|
-
export let x: number = 0;
|
|
28
|
-
export let y: number = 0;
|
|
29
|
-
export let visible: boolean = false;
|
|
30
|
-
|
|
31
|
-
// ── Context: what was right-clicked ───────────────────────────────────────
|
|
32
|
-
export let hasSelection: boolean = false;
|
|
33
|
-
// Passed by Canvas.svelte but never read here — export const keeps the
|
|
34
|
-
// init-set contract without the unused-reactive warning.
|
|
35
|
-
export const selectionCount: number = 0;
|
|
36
|
-
export let canGroup: boolean = false;
|
|
37
|
-
export let canUngroup: boolean = false;
|
|
38
|
-
export let canPaste: boolean = false;
|
|
39
|
-
|
|
40
|
-
// ── Action callbacks ──────────────────────────────────────────────────────
|
|
41
|
-
export let onCut: () => void = () => {};
|
|
42
|
-
export let onCopy: () => void = () => {};
|
|
43
|
-
export let onPaste: () => void = () => {};
|
|
44
|
-
export let onDuplicate: () => void = () => {};
|
|
45
|
-
export let onDelete: () => void = () => {};
|
|
46
|
-
export let onGroup: () => void = () => {};
|
|
47
|
-
export let onUngroup: () => void = () => {};
|
|
48
|
-
export let onBringToFront: () => void = () => {};
|
|
49
|
-
export let onSendToBack: () => void = () => {};
|
|
50
|
-
export let onBringForward: () => void = () => {};
|
|
51
|
-
export let onSendBackward: () => void = () => {};
|
|
52
|
-
export let onSelectAll: () => void = () => {};
|
|
53
|
-
export let onClose: () => void = () => {};
|
|
54
|
-
|
|
55
|
-
let menuEl: HTMLDivElement;
|
|
56
|
-
|
|
57
|
-
// Close on click outside or Escape
|
|
58
|
-
function handleKeydown(e: KeyboardEvent) {
|
|
59
|
-
if (e.key === 'Escape' && visible) {
|
|
60
|
-
onClose();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function handlePointerDown(e: PointerEvent) {
|
|
65
|
-
// Did the press go through the menu? (Asked of the event's path: in a shadow root a listener on window is told the
|
|
66
|
-
// host element as the target, which is never inside the menu, and the menu would close before its item is clicked.)
|
|
67
|
-
if (visible && menuEl && !eventWentThrough(e, menuEl)) {
|
|
68
|
-
onClose();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Use onMount's return function for cleanup — both the setup and teardown are
|
|
73
|
-
// browser-only. onDestroy runs during SSR where window is not defined.
|
|
74
|
-
onMount(() => {
|
|
75
|
-
window.addEventListener('keydown', handleKeydown);
|
|
76
|
-
window.addEventListener('pointerdown', handlePointerDown, { capture: true });
|
|
77
|
-
|
|
78
|
-
return () => {
|
|
79
|
-
window.removeEventListener('keydown', handleKeydown);
|
|
80
|
-
window.removeEventListener('pointerdown', handlePointerDown, true);
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Keep menu inside viewport
|
|
85
|
-
$: safeX = x;
|
|
86
|
-
$: safeY = y;
|
|
87
|
-
|
|
88
|
-
function adjustPosition(el: HTMLDivElement) {
|
|
89
|
-
if (!el) return;
|
|
90
|
-
const rect = el.getBoundingClientRect();
|
|
91
|
-
const vw = window.innerWidth;
|
|
92
|
-
const vh = window.innerHeight;
|
|
93
|
-
if (rect.right > vw) safeX = Math.max(0, x - rect.width);
|
|
94
|
-
if (rect.bottom > vh) safeY = Math.max(0, y - rect.height);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
$: if (visible && menuEl) {
|
|
98
|
-
// Run after DOM update so getBoundingClientRect is accurate
|
|
99
|
-
requestAnimationFrame(() => adjustPosition(menuEl));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function handleAction(fn: () => void) {
|
|
103
|
-
fn();
|
|
104
|
-
onClose();
|
|
105
|
-
}
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
{#if visible}
|
|
109
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
110
|
-
<div
|
|
111
|
-
bind:this={menuEl}
|
|
112
|
-
class="context-menu-el"
|
|
113
|
-
style="left: {safeX}px; top: {safeY}px; /* rtl-ok: put where the pointer is, measured from the left edge of the canvas */"
|
|
114
|
-
oncontextmenu={(e) => e.preventDefault()}
|
|
115
|
-
>
|
|
116
|
-
<!-- Selection actions -->
|
|
117
|
-
{#if hasSelection}
|
|
118
|
-
<button class="item" onclick={() => handleAction(onCut)}>
|
|
119
|
-
<span class="icon">✂️</span>
|
|
120
|
-
<span class="label">{$t('canvas.action.cut')}</span>
|
|
121
|
-
<span class="shortcut">{menuKeys.cut}</span>
|
|
122
|
-
</button>
|
|
123
|
-
<button class="item" onclick={() => handleAction(onCopy)}>
|
|
124
|
-
<span class="icon">📋</span>
|
|
125
|
-
<span class="label">{$t('canvas.action.copy')}</span>
|
|
126
|
-
<span class="shortcut">{menuKeys.copy}</span>
|
|
127
|
-
</button>
|
|
128
|
-
{/if}
|
|
129
|
-
|
|
130
|
-
<button class="item" class:disabled={!canPaste} onclick={() => canPaste && handleAction(onPaste)}>
|
|
131
|
-
<span class="icon">📌</span>
|
|
132
|
-
<span class="label">{$t('canvas.action.paste')}</span>
|
|
133
|
-
<span class="shortcut">{menuKeys.paste}</span>
|
|
134
|
-
</button>
|
|
135
|
-
|
|
136
|
-
{#if hasSelection}
|
|
137
|
-
<button class="item" onclick={() => handleAction(onDuplicate)}>
|
|
138
|
-
<span class="icon">⧉</span>
|
|
139
|
-
<span class="label">{$t('canvas.action.duplicate')}</span>
|
|
140
|
-
<span class="shortcut">{menuKeys.duplicate}</span>
|
|
141
|
-
</button>
|
|
142
|
-
|
|
143
|
-
<div class="divider"></div>
|
|
144
|
-
|
|
145
|
-
<!-- Grouping -->
|
|
146
|
-
{#if canGroup}
|
|
147
|
-
<button class="item" onclick={() => handleAction(onGroup)}>
|
|
148
|
-
<span class="icon">
|
|
149
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
150
|
-
<rect x="2" y="2" width="8" height="8" rx="1"/><rect x="14" y="2" width="8" height="8" rx="1"/>
|
|
151
|
-
<rect x="2" y="14" width="8" height="8" rx="1"/><rect x="14" y="14" width="8" height="8" rx="1"/>
|
|
152
|
-
</svg>
|
|
153
|
-
</span>
|
|
154
|
-
<span class="label">{$t('canvas.action.group')}</span>
|
|
155
|
-
<span class="shortcut">{menuKeys.group}</span>
|
|
156
|
-
</button>
|
|
157
|
-
{/if}
|
|
158
|
-
{#if canUngroup}
|
|
159
|
-
<button class="item" onclick={() => handleAction(onUngroup)}>
|
|
160
|
-
<span class="icon">
|
|
161
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
162
|
-
<rect x="2" y="2" width="8" height="8" rx="1" stroke-dasharray="3 2"/><rect x="14" y="2" width="8" height="8" rx="1" stroke-dasharray="3 2"/>
|
|
163
|
-
<rect x="2" y="14" width="8" height="8" rx="1" stroke-dasharray="3 2"/><rect x="14" y="14" width="8" height="8" rx="1" stroke-dasharray="3 2"/>
|
|
164
|
-
</svg>
|
|
165
|
-
</span>
|
|
166
|
-
<span class="label">{$t('canvas.action.ungroup')}</span>
|
|
167
|
-
<span class="shortcut">{menuKeys.ungroup}</span>
|
|
168
|
-
</button>
|
|
169
|
-
{/if}
|
|
170
|
-
|
|
171
|
-
<div class="divider"></div>
|
|
172
|
-
|
|
173
|
-
<!-- Layer order -->
|
|
174
|
-
<button class="item" onclick={() => handleAction(onBringToFront)}>
|
|
175
|
-
<span class="icon">
|
|
176
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
177
|
-
<rect x="3" y="3" width="13" height="13"/><rect x="8" y="8" width="13" height="13" fill="white"/>
|
|
178
|
-
<path d="M12 4v4M14 6l-2-2-2 2"/>
|
|
179
|
-
</svg>
|
|
180
|
-
</span>
|
|
181
|
-
<span class="label">{$t('canvas.layer.front')}</span>
|
|
182
|
-
<span class="shortcut">{menuKeys.bringToFront}</span>
|
|
183
|
-
</button>
|
|
184
|
-
<button class="item" onclick={() => handleAction(onBringForward)}>
|
|
185
|
-
<span class="icon">
|
|
186
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
187
|
-
<rect x="3" y="8" width="13" height="13"/><rect x="8" y="3" width="13" height="13" fill="white" stroke="currentColor"/>
|
|
188
|
-
<path d="M12 5v3M14 6l-2-2-2 2"/>
|
|
189
|
-
</svg>
|
|
190
|
-
</span>
|
|
191
|
-
<span class="label">{$t('canvas.layer.forward')}</span>
|
|
192
|
-
<span class="shortcut">{menuKeys.bringForward}</span>
|
|
193
|
-
</button>
|
|
194
|
-
<button class="item" onclick={() => handleAction(onSendBackward)}>
|
|
195
|
-
<span class="icon">
|
|
196
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
197
|
-
<rect x="8" y="3" width="13" height="13"/><rect x="3" y="8" width="13" height="13" fill="white" stroke="currentColor"/>
|
|
198
|
-
<path d="M12 16v3M10 18l2 2 2-2"/>
|
|
199
|
-
</svg>
|
|
200
|
-
</span>
|
|
201
|
-
<span class="label">{$t('canvas.layer.backward')}</span>
|
|
202
|
-
<span class="shortcut">{menuKeys.sendBackward}</span>
|
|
203
|
-
</button>
|
|
204
|
-
<button class="item" onclick={() => handleAction(onSendToBack)}>
|
|
205
|
-
<span class="icon">
|
|
206
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
207
|
-
<rect x="8" y="8" width="13" height="13"/><rect x="3" y="3" width="13" height="13" fill="white"/>
|
|
208
|
-
<path d="M12 17v3M10 19l2 2 2-2"/>
|
|
209
|
-
</svg>
|
|
210
|
-
</span>
|
|
211
|
-
<span class="label">{$t('canvas.layer.back')}</span>
|
|
212
|
-
<span class="shortcut">{menuKeys.sendToBack}</span>
|
|
213
|
-
</button>
|
|
214
|
-
|
|
215
|
-
<div class="divider"></div>
|
|
216
|
-
|
|
217
|
-
<button class="item danger" onclick={() => handleAction(onDelete)}>
|
|
218
|
-
<span class="icon">🗑</span>
|
|
219
|
-
<span class="label">{$t('canvas.action.delete')}</span>
|
|
220
|
-
<span class="shortcut">{menuKeys.delete}</span>
|
|
221
|
-
</button>
|
|
222
|
-
{:else}
|
|
223
|
-
<!-- No selection: only canvas-level actions -->
|
|
224
|
-
<div class="divider"></div>
|
|
225
|
-
<button class="item" onclick={() => handleAction(onSelectAll)}>
|
|
226
|
-
<span class="icon">⊹</span>
|
|
227
|
-
<span class="label">{$t('canvas.action.selectAll')}</span>
|
|
228
|
-
<span class="shortcut">{menuKeys.selectAll}</span>
|
|
229
|
-
</button>
|
|
230
|
-
{/if}
|
|
231
|
-
</div>
|
|
232
|
-
{/if}
|
|
233
|
-
|
|
234
|
-
<style>
|
|
235
|
-
.context-menu-el {
|
|
236
|
-
position: fixed;
|
|
237
|
-
z-index: 9999;
|
|
238
|
-
background: white;
|
|
239
|
-
border: 1px solid #e5e7eb;
|
|
240
|
-
border-radius: 8px;
|
|
241
|
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
|
|
242
|
-
padding: 4px;
|
|
243
|
-
min-width: 180px;
|
|
244
|
-
font-size: 13px;
|
|
245
|
-
user-select: none;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.item {
|
|
249
|
-
display: flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: 8px;
|
|
252
|
-
width: 100%;
|
|
253
|
-
padding: 6px 10px;
|
|
254
|
-
border: none;
|
|
255
|
-
background: transparent;
|
|
256
|
-
border-radius: 5px;
|
|
257
|
-
cursor: pointer;
|
|
258
|
-
color: #111827;
|
|
259
|
-
text-align: start;
|
|
260
|
-
transition: background 0.1s;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.item:hover:not(.disabled) {
|
|
264
|
-
background: #f3f4f6;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.item.disabled {
|
|
268
|
-
opacity: 0.4;
|
|
269
|
-
cursor: default;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
.item.danger {
|
|
273
|
-
color: #dc2626;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.item.danger:hover {
|
|
277
|
-
background: #fef2f2;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
.icon {
|
|
281
|
-
width: 16px;
|
|
282
|
-
display: flex;
|
|
283
|
-
align-items: center;
|
|
284
|
-
justify-content: center;
|
|
285
|
-
flex-shrink: 0;
|
|
286
|
-
font-size: 12px;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.label {
|
|
290
|
-
flex: 1;
|
|
291
|
-
font-weight: 400;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.shortcut {
|
|
295
|
-
color: #9ca3af;
|
|
296
|
-
font-size: 11px;
|
|
297
|
-
margin-inline-start: auto;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.divider {
|
|
301
|
-
height: 1px;
|
|
302
|
-
background: #e5e7eb;
|
|
303
|
-
margin: 3px 0;
|
|
304
|
-
}
|
|
305
|
-
</style>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const ContextMenu: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
x?: number;
|
|
16
|
-
y?: number;
|
|
17
|
-
visible?: boolean;
|
|
18
|
-
hasSelection?: boolean;
|
|
19
|
-
selectionCount?: number;
|
|
20
|
-
canGroup?: boolean;
|
|
21
|
-
canUngroup?: boolean;
|
|
22
|
-
canPaste?: boolean;
|
|
23
|
-
onCut?: () => void;
|
|
24
|
-
onCopy?: () => void;
|
|
25
|
-
onPaste?: () => void;
|
|
26
|
-
onDuplicate?: () => void;
|
|
27
|
-
onDelete?: () => void;
|
|
28
|
-
onGroup?: () => void;
|
|
29
|
-
onUngroup?: () => void;
|
|
30
|
-
onBringToFront?: () => void;
|
|
31
|
-
onSendToBack?: () => void;
|
|
32
|
-
onBringForward?: () => void;
|
|
33
|
-
onSendBackward?: () => void;
|
|
34
|
-
onSelectAll?: () => void;
|
|
35
|
-
onClose?: () => void;
|
|
36
|
-
}, {
|
|
37
|
-
[evt: string]: CustomEvent<any>;
|
|
38
|
-
}, {}, {
|
|
39
|
-
selectionCount: number;
|
|
40
|
-
}, string>;
|
|
41
|
-
type ContextMenu = InstanceType<typeof ContextMenu>;
|
|
42
|
-
export default ContextMenu;
|