@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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { CanvasHostProps, SelectorGuide } from './host/CanvasHost.js';
|
|
2
|
+
import type { PanZoomPosition } from './panZoomPosition.js';
|
|
3
|
+
import type { ToolbarPosition } from './toolbarPosition.js';
|
|
4
|
+
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> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
14
|
+
};
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
16
|
+
}
|
|
17
|
+
declare const DomCanvas: $$__sveltets_2_IsomorphicComponent<{
|
|
18
|
+
/**
|
|
19
|
+
* COMPONENT PROPS
|
|
20
|
+
*/ class?: string;
|
|
21
|
+
style?: string;
|
|
22
|
+
/** Site /canvas embed sits flush under AppHeader: skip the frame (double stroke). */ showContainerFrame?: CanvasHostProps["showContainerFrame"];
|
|
23
|
+
/** The id or class of an element of the page that stands above its live widgets: the frame of a selected widget card is drawn there. */ widgetSelectionLayerTarget?: CanvasHostProps["widgetSelectionLayerTarget"];
|
|
24
|
+
onObjectClick?: CanvasHostProps["onObjectClick"];
|
|
25
|
+
panZoomPosition?: PanZoomPosition;
|
|
26
|
+
toolbarPosition?: ToolbarPosition;
|
|
27
|
+
wireframeMode?: CanvasHostProps["wireframeMode"];
|
|
28
|
+
advancedFeatures?: CanvasHostProps["advancedFeatures"];
|
|
29
|
+
/** The element selector on the toolbar. The host owns whether it is on. */ showElementSelector?: CanvasHostProps["showElementSelector"];
|
|
30
|
+
/** Drawing tools stay until the first generation. After that, only the selector remains. */ showDrawingTools?: CanvasHostProps["showDrawingTools"];
|
|
31
|
+
elementSelectorActive?: CanvasHostProps["elementSelectorActive"];
|
|
32
|
+
onToggleElementSelector?: CanvasHostProps["onToggleElementSelector"];
|
|
33
|
+
/** Words for the selector bar that replaces the drawing tools. */ selectorGuide?: SelectorGuide | null;
|
|
34
|
+
/** The zoom card. Off on the site when debug is off. The save control stays. */ showZoomPanel?: CanvasHostProps["showZoomPanel"];
|
|
35
|
+
/** Accepted for the pages that set it. The design puts Image in the Shapes menu, so it no longer changes what is drawn. */ mediaBtsOnBar?: CanvasHostProps["mediaBtsOnBar"];
|
|
36
|
+
initialData?: CanvasHostProps["initialData"];
|
|
37
|
+
onReady?: CanvasHostProps["onReady"];
|
|
38
|
+
isExternalDataLoading?: CanvasHostProps["isExternalDataLoading"];
|
|
39
|
+
onBeforeUnmount?: CanvasHostProps["onBeforeUnmount"];
|
|
40
|
+
onAutoSave?: CanvasHostProps["onAutoSave"];
|
|
41
|
+
autosaveDelayMs?: CanvasHostProps["autosaveDelayMs"];
|
|
42
|
+
autosaveMaxWaitMs?: CanvasHostProps["autosaveMaxWaitMs"];
|
|
43
|
+
suspendAutosave?: CanvasHostProps["suspendAutosave"];
|
|
44
|
+
showSaveButton?: CanvasHostProps["showSaveButton"];
|
|
45
|
+
onCanvasDirty?: CanvasHostProps["onCanvasDirty"];
|
|
46
|
+
onCanvasCleared?: CanvasHostProps["onCanvasCleared"];
|
|
47
|
+
onConvertToWidget?: CanvasHostProps["onConvertToWidget"];
|
|
48
|
+
onWidgetImageClick?: CanvasHostProps["onWidgetImageClick"];
|
|
49
|
+
onRecognizeStroke?: CanvasHostProps["onRecognizeStroke"];
|
|
50
|
+
onNonWidgetSelected?: CanvasHostProps["onNonWidgetSelected"];
|
|
51
|
+
onWidgetShapeDuplicated?: CanvasHostProps["onWidgetShapeDuplicated"];
|
|
52
|
+
onWidgetShapeDeleting?: CanvasHostProps["onWidgetShapeDeleting"];
|
|
53
|
+
onWidgetRename?: CanvasHostProps["onWidgetRename"];
|
|
54
|
+
onRefreshScreenshot?: CanvasHostProps["onRefreshScreenshot"];
|
|
55
|
+
/** Host persists canvases.primary_widget_id after the canvas marks the primary widget. */ onSetPrimaryWidget?: CanvasHostProps["onSetPrimaryWidget"];
|
|
56
|
+
/** Throttled paint hook for HTML overlays (e.g. the live widgets laid over the cards). */ onAfterRender?: CanvasHostProps["onAfterRender"];
|
|
57
|
+
getWidgetName?: CanvasHostProps["getWidgetName"];
|
|
58
|
+
/** Bumped when names change so the names are resolved again. */ widgetNameRevision?: CanvasHostProps["widgetNameRevision"];
|
|
59
|
+
/** Returns true when widgetId still exists in the host widget list. */ isWidgetKnown?: CanvasHostProps["isWidgetKnown"];
|
|
60
|
+
showLogs?: CanvasHostProps["showLogs"];
|
|
61
|
+
/**
|
|
62
|
+
* Whether a freehand stroke that is a clean shape (a circle, an oval, a rectangle, a triangle, a diamond, a hexagon)
|
|
63
|
+
* becomes that shape. Off unless a page passes true: the package's own flag turns it on for every page.
|
|
64
|
+
*/ shapeSnap?: CanvasHostProps["shapeSnap"];
|
|
65
|
+
/**
|
|
66
|
+
* The language of the canvas: `locale` ("de", "pt-BR") picks the plural rules, the number format and the language
|
|
67
|
+
* the page's own words are in; `messages` are the page's own words, keyed like CANVAS_MESSAGES (a key left out
|
|
68
|
+
* keeps its English text). Without them the canvas speaks English. Both can change while the canvas is open.
|
|
69
|
+
*/ locale?: string | null;
|
|
70
|
+
messages?: Readonly<Record<string, unknown>> | null;
|
|
71
|
+
/**
|
|
72
|
+
* THE FUNCTIONS THE PAGE CALLS
|
|
73
|
+
*
|
|
74
|
+
* Each one is the host's method of the same name, with its type. The list is `CANVAS_EXPORTED_FUNCTION_NAMES`.
|
|
75
|
+
*/ shapeFillColor?: () => string;
|
|
76
|
+
captureCanvasSketch?: () => Promise<string>;
|
|
77
|
+
absorbCanvasSketchIntoWidget?: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
78
|
+
deselectAll?: () => void;
|
|
79
|
+
duplicateSelectedObjects?: () => import("../engine/core/types.js").ObjectId[];
|
|
80
|
+
deleteSelectedObjects?: () => Promise<boolean>;
|
|
81
|
+
markSelectedAsDuplicating?: () => void;
|
|
82
|
+
linkObjectToWidget?: (target: import("../engine/core/types.js").ObjectId | {
|
|
83
|
+
id?: import("../engine/core/types.js").ObjectId;
|
|
84
|
+
_objectId?: import("../engine/core/types.js").ObjectId;
|
|
85
|
+
} | null | undefined, widgetId: string, widgetName?: string | null) => void;
|
|
86
|
+
linkFrameToWidget?: (objectId: string, widgetId: string) => void;
|
|
87
|
+
replaceObjectWithWidgetImage?: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
88
|
+
updateWidgetImage?: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
89
|
+
selectWidgetShape?: (widgetId: string) => boolean;
|
|
90
|
+
listWidgetShapeScreenRects?: () => import("./host/screenRects.js").WidgetScreenRect[];
|
|
91
|
+
getWidgetShapeScreenRect?: (widgetId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
92
|
+
getObjectScreenRect?: (objectId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
93
|
+
getWidgetShapeDataUrl?: (widgetId: string) => string | null;
|
|
94
|
+
setWidgetShapeLivePreviewHiddenImage?: (widgetId: string, hidden: boolean) => void;
|
|
95
|
+
addWidgetShape?: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
96
|
+
getLinkedWidgetIds?: () => Set<string>;
|
|
97
|
+
keepOnlyWidgetShape?: (widgetId: string) => number;
|
|
98
|
+
hydrateWidgetShapeMetadata?: (widgetsById: Map<string, import("../engine/widgets.js").WidgetMetadata>) => number;
|
|
99
|
+
markOrphanedWidgetShapes?: (validWidgetIds: Set<string>) => number;
|
|
100
|
+
onSelectSelectTool?: () => void;
|
|
101
|
+
onSelectLibraryShapeTool?: (shapeKey: string, _pathData?: string) => void;
|
|
102
|
+
onSelectEraseTool?: () => void;
|
|
103
|
+
onSelectDrawTool?: () => void;
|
|
104
|
+
onSelectTextTool?: () => void;
|
|
105
|
+
onSelectArrowTool?: () => void;
|
|
106
|
+
onSelectShapeTool?: (shapeType: import("./host/CanvasHost.js").ShapeToolName) => void;
|
|
107
|
+
onSelectFrameTool?: () => void;
|
|
108
|
+
setPrimaryWidgetShape?: (widgetId: string) => boolean;
|
|
109
|
+
getPrimaryWidgetId?: () => string | null;
|
|
110
|
+
setWidgetShapeBodyDragAllowed?: (widgetId: string, allowed: boolean) => void;
|
|
111
|
+
translateWidgetShapeByScreen?: (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
112
|
+
commitWidgetShapeTranslate?: (_widgetId?: string | null) => void;
|
|
113
|
+
setWidgetShapeOverlayDragActive?: (active: boolean) => void;
|
|
114
|
+
selectWidgetShapeById?: (widgetId: string) => boolean;
|
|
115
|
+
getSelectedWidgetShapeId?: () => string | null;
|
|
116
|
+
getSelectedObject?: () => import("./host/hostObject.js").HostObject | null;
|
|
117
|
+
getHoveredWidgetShapeId?: () => string | null;
|
|
118
|
+
onSelectImageTool?: () => void;
|
|
119
|
+
onSelectVideoTool?: () => void;
|
|
120
|
+
onSelectPanTool?: () => void;
|
|
121
|
+
zoomIn?: () => void;
|
|
122
|
+
zoomOut?: () => void;
|
|
123
|
+
zoomTo?: (percent: number) => void;
|
|
124
|
+
zoomReset?: () => void;
|
|
125
|
+
zoomFit?: () => void;
|
|
126
|
+
onGroupSelection?: () => string | null;
|
|
127
|
+
onUngroupSelection?: () => void;
|
|
128
|
+
onSelectAllObjects?: () => void;
|
|
129
|
+
onDeselectAllObjects?: () => void;
|
|
130
|
+
flushAutosave?: () => Promise<void>;
|
|
131
|
+
saveNow?: () => void;
|
|
132
|
+
undo?: () => Promise<void>;
|
|
133
|
+
redo?: () => Promise<void>;
|
|
134
|
+
saveCanvas?: () => string | null;
|
|
135
|
+
loadCanvas?: (jsonString: string) => Promise<void>;
|
|
136
|
+
onClearAllObjects?: () => void;
|
|
137
|
+
addText?: () => import("../engine/core/types.js").ObjectId;
|
|
138
|
+
addTriangle?: () => import("../engine/core/types.js").ObjectId | null;
|
|
139
|
+
addRect?: () => import("../engine/core/types.js").ObjectId | null;
|
|
140
|
+
addCircle?: () => import("../engine/core/types.js").ObjectId | null;
|
|
141
|
+
addFrame?: () => null;
|
|
142
|
+
addImage?: () => Promise<void>;
|
|
143
|
+
removeSketchObjectsKeepingWidget?: (widgetId: string) => number;
|
|
144
|
+
}, {
|
|
145
|
+
[evt: string]: CustomEvent<any>;
|
|
146
|
+
}, {}, {
|
|
147
|
+
/**
|
|
148
|
+
* THE FUNCTIONS THE PAGE CALLS
|
|
149
|
+
*
|
|
150
|
+
* Each one is the host's method of the same name, with its type. The list is `CANVAS_EXPORTED_FUNCTION_NAMES`.
|
|
151
|
+
*/ shapeFillColor: () => string;
|
|
152
|
+
captureCanvasSketch: () => Promise<string>;
|
|
153
|
+
absorbCanvasSketchIntoWidget: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
154
|
+
deselectAll: () => void;
|
|
155
|
+
duplicateSelectedObjects: () => import("../engine/core/types.js").ObjectId[];
|
|
156
|
+
deleteSelectedObjects: () => Promise<boolean>;
|
|
157
|
+
markSelectedAsDuplicating: () => void;
|
|
158
|
+
linkObjectToWidget: (target: import("../engine/core/types.js").ObjectId | {
|
|
159
|
+
id?: import("../engine/core/types.js").ObjectId;
|
|
160
|
+
_objectId?: import("../engine/core/types.js").ObjectId;
|
|
161
|
+
} | null | undefined, widgetId: string, widgetName?: string | null) => void;
|
|
162
|
+
linkFrameToWidget: (objectId: string, widgetId: string) => void;
|
|
163
|
+
replaceObjectWithWidgetImage: (objectId: string, widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
164
|
+
updateWidgetImage: (widgetId: string, newScreenshotDataUrl: string) => void;
|
|
165
|
+
selectWidgetShape: (widgetId: string) => boolean;
|
|
166
|
+
listWidgetShapeScreenRects: () => import("./host/screenRects.js").WidgetScreenRect[];
|
|
167
|
+
getWidgetShapeScreenRect: (widgetId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
168
|
+
getObjectScreenRect: (objectId: string) => import("./host/screenRects.js").ScreenRect | null;
|
|
169
|
+
getWidgetShapeDataUrl: (widgetId: string) => string | null;
|
|
170
|
+
setWidgetShapeLivePreviewHiddenImage: (widgetId: string, hidden: boolean) => void;
|
|
171
|
+
addWidgetShape: (widgetId: string, widgetName?: string, gridIndex?: number, totalCount?: number, previewImageUrl?: string | null) => string | null;
|
|
172
|
+
getLinkedWidgetIds: () => Set<string>;
|
|
173
|
+
keepOnlyWidgetShape: (widgetId: string) => number;
|
|
174
|
+
hydrateWidgetShapeMetadata: (widgetsById: Map<string, import("../engine/widgets.js").WidgetMetadata>) => number;
|
|
175
|
+
markOrphanedWidgetShapes: (validWidgetIds: Set<string>) => number;
|
|
176
|
+
onSelectSelectTool: () => void;
|
|
177
|
+
onSelectLibraryShapeTool: (shapeKey: string, _pathData?: string) => void;
|
|
178
|
+
onSelectEraseTool: () => void;
|
|
179
|
+
onSelectDrawTool: () => void;
|
|
180
|
+
onSelectTextTool: () => void;
|
|
181
|
+
onSelectArrowTool: () => void;
|
|
182
|
+
onSelectShapeTool: (shapeType: import("./host/CanvasHost.js").ShapeToolName) => void;
|
|
183
|
+
onSelectFrameTool: () => void;
|
|
184
|
+
setPrimaryWidgetShape: (widgetId: string) => boolean;
|
|
185
|
+
getPrimaryWidgetId: () => string | null;
|
|
186
|
+
setWidgetShapeBodyDragAllowed: (widgetId: string, allowed: boolean) => void;
|
|
187
|
+
translateWidgetShapeByScreen: (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
188
|
+
commitWidgetShapeTranslate: (_widgetId?: string | null) => void;
|
|
189
|
+
setWidgetShapeOverlayDragActive: (active: boolean) => void;
|
|
190
|
+
selectWidgetShapeById: (widgetId: string) => boolean;
|
|
191
|
+
getSelectedWidgetShapeId: () => string | null;
|
|
192
|
+
getSelectedObject: () => import("./host/hostObject.js").HostObject | null;
|
|
193
|
+
getHoveredWidgetShapeId: () => string | null;
|
|
194
|
+
onSelectImageTool: () => void;
|
|
195
|
+
onSelectVideoTool: () => void;
|
|
196
|
+
onSelectPanTool: () => void;
|
|
197
|
+
zoomIn: () => void;
|
|
198
|
+
zoomOut: () => void;
|
|
199
|
+
zoomTo: (percent: number) => void;
|
|
200
|
+
zoomReset: () => void;
|
|
201
|
+
zoomFit: () => void;
|
|
202
|
+
onGroupSelection: () => string | null;
|
|
203
|
+
onUngroupSelection: () => void;
|
|
204
|
+
onSelectAllObjects: () => void;
|
|
205
|
+
onDeselectAllObjects: () => void;
|
|
206
|
+
flushAutosave: () => Promise<void>;
|
|
207
|
+
saveNow: () => void;
|
|
208
|
+
undo: () => Promise<void>;
|
|
209
|
+
redo: () => Promise<void>;
|
|
210
|
+
saveCanvas: () => string | null;
|
|
211
|
+
loadCanvas: (jsonString: string) => Promise<void>;
|
|
212
|
+
onClearAllObjects: () => void;
|
|
213
|
+
addText: () => import("../engine/core/types.js").ObjectId;
|
|
214
|
+
addTriangle: () => import("../engine/core/types.js").ObjectId | null;
|
|
215
|
+
addRect: () => import("../engine/core/types.js").ObjectId | null;
|
|
216
|
+
addCircle: () => import("../engine/core/types.js").ObjectId | null;
|
|
217
|
+
addFrame: () => null;
|
|
218
|
+
addImage: () => Promise<void>;
|
|
219
|
+
removeSketchObjectsKeepingWidget: (widgetId: string) => number;
|
|
220
|
+
}, string>;
|
|
221
|
+
type DomCanvas = InstanceType<typeof DomCanvas>;
|
|
222
|
+
export default DomCanvas;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame the board draws around itself when the page asks for it (`showContainerFrame`): rounded corners and a 1 px
|
|
3
|
+
* border, as the Figma design has them.
|
|
4
|
+
*
|
|
5
|
+
* The border is drawn by a pseudo-element laid over the edge of the board and not by a CSS border. A real border takes room
|
|
6
|
+
* of its own, and everything that is placed "16 px from the edge" (the toolbar, the zoom control, the selection panel, the
|
|
7
|
+
* notices) is placed from the inside of it, so it would stand 17 px from the outer edge, a pixel off Figma's measures. The
|
|
8
|
+
* ring has no pointer events, so a press on the 1 px under it still reaches the board.
|
|
9
|
+
*
|
|
10
|
+
* Written out in full, so that the stylesheet of a page that installs the canvas picks every class up when it reads this
|
|
11
|
+
* file. Kept free of Svelte and of the DOM so that Node can test it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const BOARD_FRAME_CLASSES = "rounded-card after:pointer-events-none after:absolute after:inset-0 after:z-50 after:rounded-[inherit] after:border after:border-border";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame the board draws around itself when the page asks for it (`showContainerFrame`): rounded corners and a 1 px
|
|
3
|
+
* border, as the Figma design has them.
|
|
4
|
+
*
|
|
5
|
+
* The border is drawn by a pseudo-element laid over the edge of the board and not by a CSS border. A real border takes room
|
|
6
|
+
* of its own, and everything that is placed "16 px from the edge" (the toolbar, the zoom control, the selection panel, the
|
|
7
|
+
* notices) is placed from the inside of it, so it would stand 17 px from the outer edge, a pixel off Figma's measures. The
|
|
8
|
+
* ring has no pointer events, so a press on the 1 px under it still reaches the board.
|
|
9
|
+
*
|
|
10
|
+
* Written out in full, so that the stylesheet of a page that installs the canvas picks every class up when it reads this
|
|
11
|
+
* file. Kept free of Svelte and of the DOM so that Node can test it.
|
|
12
|
+
*/
|
|
13
|
+
export const BOARD_FRAME_CLASSES = 'rounded-card after:pointer-events-none after:absolute after:inset-0 after:z-50 after:rounded-[inherit] after:border after:border-border';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour of the board's surface, under the dots of its grid and under an empty board that has not been drawn yet.
|
|
3
|
+
*
|
|
4
|
+
* It is the design system's own `muted` token (Figma: the canvas surface is `bg-muted`), so the board follows the page's theme.
|
|
5
|
+
* The fallback is the token's value in the light theme, for a page that does not load the design system's styles. One
|
|
6
|
+
* constant, read by the board and by the placeholder a page shows while the canvas is still downloading, so the swap
|
|
7
|
+
* from one to the other cannot change colour.
|
|
8
|
+
*/
|
|
9
|
+
export declare const BOARD_SURFACE_COLOR = "var(--muted, #f5f5f5)";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour of the board's surface, under the dots of its grid and under an empty board that has not been drawn yet.
|
|
3
|
+
*
|
|
4
|
+
* It is the design system's own `muted` token (Figma: the canvas surface is `bg-muted`), so the board follows the page's theme.
|
|
5
|
+
* The fallback is the token's value in the light theme, for a page that does not load the design system's styles. One
|
|
6
|
+
* constant, read by the board and by the placeholder a page shows while the canvas is still downloading, so the swap
|
|
7
|
+
* from one to the other cannot change colour.
|
|
8
|
+
*/
|
|
9
|
+
export const BOARD_SURFACE_COLOR = 'var(--muted, #f5f5f5)';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the floating cards of the chrome (the toolbar and the zoom control) stand on the board, and how they share the
|
|
3
|
+
* board when a page puts both in the same place.
|
|
4
|
+
*
|
|
5
|
+
* A page names a place for each card (`toolbarPosition`, `panZoomPosition`): one of eight anchors, written the way the
|
|
6
|
+
* design names its frames, a row letter and a column letter.
|
|
7
|
+
*
|
|
8
|
+
* TL TC TR the top edge: left, centre, right
|
|
9
|
+
* CL CR the middle of the left edge and of the right edge
|
|
10
|
+
* BL BC BR the bottom edge: left, centre, right
|
|
11
|
+
*
|
|
12
|
+
* The middle of the board is not a place: a card there would sit on the drawing. A card on a side edge (CL, CR) stands
|
|
13
|
+
* upright, its buttons one under the other, and its menus and tooltips open sideways, into the board.
|
|
14
|
+
*
|
|
15
|
+
* Two cards named for the same anchor are put in one row (one column on a side edge) with a gap between them instead of
|
|
16
|
+
* lying on top of each other, so a host can ask for "everything at the bottom left" and get it.
|
|
17
|
+
*
|
|
18
|
+
* Kept free of Svelte and of the DOM so that Node can test it.
|
|
19
|
+
*/
|
|
20
|
+
/** The eight places a card can stand. */
|
|
21
|
+
export declare const CHROME_ANCHORS: readonly ["TL", "TC", "TR", "CL", "CR", "BL", "BC", "BR"];
|
|
22
|
+
/** One of {@link CHROME_ANCHORS}. */
|
|
23
|
+
export type ChromeAnchor = (typeof CHROME_ANCHORS)[number];
|
|
24
|
+
/** The cards of the chrome that stand on their own anchor: the drawing toolbar (or the selector bar) and the zoom control. */
|
|
25
|
+
export type ChromeCardId = 'toolbar' | 'zoom';
|
|
26
|
+
/** The side of a card its menus and tooltips open to. */
|
|
27
|
+
export type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
28
|
+
/** The anchor to use for what a page passed: anything that is not one of the eight is the fallback, so a mistyped option never takes a card off the board. */
|
|
29
|
+
export declare function normalizeAnchor(value: unknown, fallback: ChromeAnchor): ChromeAnchor;
|
|
30
|
+
/** Whether a card at this anchor stands upright, against the left or the right edge. */
|
|
31
|
+
export declare function isSideAnchor(anchor: ChromeAnchor): boolean;
|
|
32
|
+
/** Whether a card at this anchor stands against the top edge. */
|
|
33
|
+
export declare function isTopAnchor(anchor: ChromeAnchor): boolean;
|
|
34
|
+
/** The side of a card at this anchor that its menus and tooltips open to: away from the edge the card stands on. */
|
|
35
|
+
export declare function popoverSideFor(anchor: ChromeAnchor): PopoverSide;
|
|
36
|
+
/** The classes of the anchor alone (its place on the board, no layout of what is inside). */
|
|
37
|
+
export declare function anchorClasses(anchor: ChromeAnchor): string;
|
|
38
|
+
/** One place on the board that holds one or two cards. */
|
|
39
|
+
export interface ChromeSlot {
|
|
40
|
+
anchor: ChromeAnchor;
|
|
41
|
+
/** The cards that stand here, in the order they are drawn (the toolbar first). */
|
|
42
|
+
cards: readonly ChromeCardId[];
|
|
43
|
+
/** The slot stands against a side edge: what is inside is laid out in a column. */
|
|
44
|
+
vertical: boolean;
|
|
45
|
+
/** The classes of the slot's element: its place on the board and the layout of what is inside. */
|
|
46
|
+
classes: string;
|
|
47
|
+
}
|
|
48
|
+
/** Which cards the page shows. */
|
|
49
|
+
export interface ShownCards {
|
|
50
|
+
toolbar: boolean;
|
|
51
|
+
zoom: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The slots to draw for the anchors a page named: one per anchor that has a card, in a fixed order, so a card that moves
|
|
55
|
+
* from one anchor to another does not make the other one start again.
|
|
56
|
+
*/
|
|
57
|
+
export declare function chromeSlots(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor, shown: ShownCards): ChromeSlot[];
|
|
58
|
+
/**
|
|
59
|
+
* The classes that show the zoom card from the width of board it needs, and hide it below. A zoom card on the same edge as
|
|
60
|
+
* the toolbar shares the line with it, so how much room it needs depends on where each stands: the widths and the sums
|
|
61
|
+
* behind them are in `ZOOM_CONTROL_MIN_WIDTHS`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function zoomVisibilityClasses(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor): string;
|
|
64
|
+
/** What the selection panel (top right, 336 px wide) has to keep clear of. */
|
|
65
|
+
export interface PanelClearance {
|
|
66
|
+
/** A card stands on the top edge: the panel starts below it. */
|
|
67
|
+
belowTopCards: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The card that stands upright against the right edge, when one does: the panel stands beside it, not over it. Which card
|
|
70
|
+
* it is says how wide it is (the toolbar's 59 px: the shape button's 51 and 4 px of padding on each side; the zoom control's
|
|
71
|
+
* 40 px), and the toolbar wins where the two share the slot.
|
|
72
|
+
*/
|
|
73
|
+
besideSideCard: ChromeCardId | null;
|
|
74
|
+
}
|
|
75
|
+
/** What the panel keeps clear of, for the slots that are drawn. */
|
|
76
|
+
export declare function panelClearanceFor(slots: readonly ChromeSlot[]): PanelClearance;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the floating cards of the chrome (the toolbar and the zoom control) stand on the board, and how they share the
|
|
3
|
+
* board when a page puts both in the same place.
|
|
4
|
+
*
|
|
5
|
+
* A page names a place for each card (`toolbarPosition`, `panZoomPosition`): one of eight anchors, written the way the
|
|
6
|
+
* design names its frames, a row letter and a column letter.
|
|
7
|
+
*
|
|
8
|
+
* TL TC TR the top edge: left, centre, right
|
|
9
|
+
* CL CR the middle of the left edge and of the right edge
|
|
10
|
+
* BL BC BR the bottom edge: left, centre, right
|
|
11
|
+
*
|
|
12
|
+
* The middle of the board is not a place: a card there would sit on the drawing. A card on a side edge (CL, CR) stands
|
|
13
|
+
* upright, its buttons one under the other, and its menus and tooltips open sideways, into the board.
|
|
14
|
+
*
|
|
15
|
+
* Two cards named for the same anchor are put in one row (one column on a side edge) with a gap between them instead of
|
|
16
|
+
* lying on top of each other, so a host can ask for "everything at the bottom left" and get it.
|
|
17
|
+
*
|
|
18
|
+
* Kept free of Svelte and of the DOM so that Node can test it.
|
|
19
|
+
*/
|
|
20
|
+
import { ZOOM_CONTROL_VISIBLE_FROM } from './ui/floatingCard.js';
|
|
21
|
+
/** The eight places a card can stand. */
|
|
22
|
+
export const CHROME_ANCHORS = ['TL', 'TC', 'TR', 'CL', 'CR', 'BL', 'BC', 'BR'];
|
|
23
|
+
/**
|
|
24
|
+
* The classes that put an anchor in place, 16 px from the edges as the Figma design has it. Written out in full, so that
|
|
25
|
+
* the stylesheet of a page that installs the canvas picks every one of them up when it reads this file.
|
|
26
|
+
*/
|
|
27
|
+
const ANCHOR_CLASSES = {
|
|
28
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
29
|
+
TL: 'absolute top-4 left-4',
|
|
30
|
+
TC: 'absolute top-4 left-1/2 -translate-x-1/2',
|
|
31
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
32
|
+
TR: 'absolute top-4 right-4',
|
|
33
|
+
// rtl-ok: the page names a side of the screen, as it is drawn
|
|
34
|
+
CL: 'absolute top-1/2 left-4 -translate-y-1/2',
|
|
35
|
+
// rtl-ok: the page names a side of the screen, as it is drawn
|
|
36
|
+
CR: 'absolute top-1/2 right-4 -translate-y-1/2',
|
|
37
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
38
|
+
BL: 'absolute bottom-4 left-4',
|
|
39
|
+
BC: 'absolute bottom-4 left-1/2 -translate-x-1/2',
|
|
40
|
+
// rtl-ok: the page names a corner of the screen, as it is drawn
|
|
41
|
+
BR: 'absolute bottom-4 right-4'
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* How the cards of a slot are laid out: a row on the top and the bottom edge (the cards stand on the line of the edge they
|
|
45
|
+
* are against), a column on a side edge (centred on each other, so the layout does not depend on the direction of the
|
|
46
|
+
* page). A slot never grows larger than the board minus its 16 px edges.
|
|
47
|
+
*/
|
|
48
|
+
const SLOT_TOP_ROW_CLASSES = 'flex flex-row items-start gap-2 max-w-[calc(100%-2rem)]';
|
|
49
|
+
const SLOT_BOTTOM_ROW_CLASSES = 'flex flex-row items-end gap-2 max-w-[calc(100%-2rem)]';
|
|
50
|
+
const SLOT_COLUMN_CLASSES = 'flex flex-col items-center gap-2 max-h-[calc(100%-2rem)]';
|
|
51
|
+
/** The anchor to use for what a page passed: anything that is not one of the eight is the fallback, so a mistyped option never takes a card off the board. */
|
|
52
|
+
export function normalizeAnchor(value, fallback) {
|
|
53
|
+
return CHROME_ANCHORS.includes(value) ? value : fallback;
|
|
54
|
+
}
|
|
55
|
+
/** Whether a card at this anchor stands upright, against the left or the right edge. */
|
|
56
|
+
export function isSideAnchor(anchor) {
|
|
57
|
+
return anchor === 'CL' || anchor === 'CR';
|
|
58
|
+
}
|
|
59
|
+
/** Whether a card at this anchor stands against the top edge. */
|
|
60
|
+
export function isTopAnchor(anchor) {
|
|
61
|
+
return anchor.startsWith('T');
|
|
62
|
+
}
|
|
63
|
+
/** The side of a card at this anchor that its menus and tooltips open to: away from the edge the card stands on. */
|
|
64
|
+
export function popoverSideFor(anchor) {
|
|
65
|
+
if (anchor === 'CL')
|
|
66
|
+
return 'right';
|
|
67
|
+
if (anchor === 'CR')
|
|
68
|
+
return 'left';
|
|
69
|
+
return isTopAnchor(anchor) ? 'bottom' : 'top';
|
|
70
|
+
}
|
|
71
|
+
/** The classes of the anchor alone (its place on the board, no layout of what is inside). */
|
|
72
|
+
export function anchorClasses(anchor) {
|
|
73
|
+
return ANCHOR_CLASSES[anchor];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The slots to draw for the anchors a page named: one per anchor that has a card, in a fixed order, so a card that moves
|
|
77
|
+
* from one anchor to another does not make the other one start again.
|
|
78
|
+
*/
|
|
79
|
+
export function chromeSlots(toolbarAnchor, zoomAnchor, shown) {
|
|
80
|
+
const slots = [];
|
|
81
|
+
for (const anchor of CHROME_ANCHORS) {
|
|
82
|
+
const cards = [];
|
|
83
|
+
if (shown.toolbar && toolbarAnchor === anchor)
|
|
84
|
+
cards.push('toolbar');
|
|
85
|
+
if (shown.zoom && zoomAnchor === anchor)
|
|
86
|
+
cards.push('zoom');
|
|
87
|
+
if (cards.length === 0)
|
|
88
|
+
continue;
|
|
89
|
+
const vertical = isSideAnchor(anchor);
|
|
90
|
+
const layout = vertical ? SLOT_COLUMN_CLASSES : isTopAnchor(anchor) ? SLOT_TOP_ROW_CLASSES : SLOT_BOTTOM_ROW_CLASSES;
|
|
91
|
+
slots.push({ anchor, cards, vertical, classes: `${ANCHOR_CLASSES[anchor]} ${layout}` });
|
|
92
|
+
}
|
|
93
|
+
return slots;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The classes that show the zoom card from the width of board it needs, and hide it below. A zoom card on the same edge as
|
|
97
|
+
* the toolbar shares the line with it, so how much room it needs depends on where each stands: the widths and the sums
|
|
98
|
+
* behind them are in `ZOOM_CONTROL_MIN_WIDTHS`.
|
|
99
|
+
*/
|
|
100
|
+
export function zoomVisibilityClasses(toolbarAnchor, zoomAnchor) {
|
|
101
|
+
// A card on a side edge shares no line with a card on the top or the bottom edge, and neither do two cards on different edges.
|
|
102
|
+
if (isSideAnchor(toolbarAnchor) || isSideAnchor(zoomAnchor) || toolbarAnchor[0] !== zoomAnchor[0])
|
|
103
|
+
return ZOOM_CONTROL_VISIBLE_FROM.alone;
|
|
104
|
+
const toolbarColumn = toolbarAnchor[1];
|
|
105
|
+
const zoomColumn = zoomAnchor[1];
|
|
106
|
+
if (toolbarColumn === zoomColumn)
|
|
107
|
+
return ZOOM_CONTROL_VISIBLE_FROM.sameSlot;
|
|
108
|
+
if (toolbarColumn === 'C')
|
|
109
|
+
return ZOOM_CONTROL_VISIBLE_FROM.besideCentredToolbar;
|
|
110
|
+
if (zoomColumn === 'C')
|
|
111
|
+
return ZOOM_CONTROL_VISIBLE_FROM.centredBesideCornerToolbar;
|
|
112
|
+
return ZOOM_CONTROL_VISIBLE_FROM.oppositeCorners;
|
|
113
|
+
}
|
|
114
|
+
/** What the panel keeps clear of, for the slots that are drawn. */
|
|
115
|
+
export function panelClearanceFor(slots) {
|
|
116
|
+
const rightEdgeSlot = slots.find((slot) => slot.anchor === 'CR');
|
|
117
|
+
return {
|
|
118
|
+
belowTopCards: slots.some((slot) => isTopAnchor(slot.anchor)),
|
|
119
|
+
besideSideCard: rightEdgeSlot ? (rightEdgeSlot.cards.includes('toolbar') ? 'toolbar' : 'zoom') : null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the empty-board hint ("Draw or type…") may show. The hint is only for a board that finished loading and stayed
|
|
3
|
+
* empty; never a flash before saved shapes arrive (item 22).
|
|
4
|
+
*/
|
|
5
|
+
export interface EmptyBoardHintInput {
|
|
6
|
+
/** The page wants the sketch hint (drawing tools visible). */
|
|
7
|
+
showDrawingHint: boolean;
|
|
8
|
+
/** The host has opened the gate after onReady / the first load (see CanvasHost). */
|
|
9
|
+
emptyHintGateOpen: boolean;
|
|
10
|
+
/** The board or the page is still loading saved content. */
|
|
11
|
+
loading: boolean;
|
|
12
|
+
sceneObjectCount: number;
|
|
13
|
+
hasPreviewOverlay: boolean;
|
|
14
|
+
editingText: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** True when the centered empty-board hint should render. */
|
|
17
|
+
export declare function shouldShowEmptyBoardHint(input: EmptyBoardHintInput): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the empty-board hint ("Draw or type…") may show. The hint is only for a board that finished loading and stayed
|
|
3
|
+
* empty; never a flash before saved shapes arrive (item 22).
|
|
4
|
+
*/
|
|
5
|
+
/** True when the centered empty-board hint should render. */
|
|
6
|
+
export function shouldShowEmptyBoardHint(input) {
|
|
7
|
+
if (!input.showDrawingHint || !input.emptyHintGateOpen)
|
|
8
|
+
return false;
|
|
9
|
+
if (input.loading || input.editingText)
|
|
10
|
+
return false;
|
|
11
|
+
return input.sceneObjectCount === 0 && !input.hasPreviewOverlay;
|
|
12
|
+
}
|
|
@@ -46,7 +46,7 @@ export declare function eventWentThrough(event: Event, element: Element | null |
|
|
|
46
46
|
export declare function getTransientHostFor(scopeNode: Node | null | undefined): Node;
|
|
47
47
|
/**
|
|
48
48
|
* Whether the canvas whose element is `scopeNode` should take the keyboard back after the element that held it went away
|
|
49
|
-
* (
|
|
49
|
+
* (the text editor of the board, which is taken out of the page when text editing ends, and leaves the focus on nothing).
|
|
50
50
|
*
|
|
51
51
|
* Inside a shadow root the canvas's shortcuts follow the focus, so a focus that fell to nothing (the page's `<body>`, or
|
|
52
52
|
* the shadow root's host alone) has to come back to the canvas. A focus that went to something else is not ours to take:
|
|
@@ -68,7 +68,7 @@ export function getTransientHostFor(scopeNode) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Whether the canvas whose element is `scopeNode` should take the keyboard back after the element that held it went away
|
|
71
|
-
* (
|
|
71
|
+
* (the text editor of the board, which is taken out of the page when text editing ends, and leaves the focus on nothing).
|
|
72
72
|
*
|
|
73
73
|
* Inside a shadow root the canvas's shortcuts follow the focus, so a focus that fell to nothing (the page's `<body>`, or
|
|
74
74
|
* the shadow root's host alone) has to come back to the canvas. A focus that went to something else is not ours to take:
|