@yuzhouu/canvas-kit 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/_vendor/canvas-core/editor/commands.d.ts +11 -1
- package/_vendor/canvas-core/editor/createEditorWithRuntimePlugins.d.ts +6 -0
- package/_vendor/canvas-core/editor/editor.d.ts +6 -1
- package/_vendor/canvas-core/editor/index.d.ts +1 -1
- package/_vendor/canvas-core/editor/managers/documentSnapshotManager.d.ts +1 -1
- package/_vendor/canvas-core/editor/managers/snapCalculations.d.ts +34 -4
- package/_vendor/canvas-core/editor/managers/snapManager.d.ts +7 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.d.ts +15 -0
- package/_vendor/canvas-core/editor/middleMousePanInteraction.d.ts +2 -0
- package/_vendor/canvas-core/index.d.ts +6 -6
- package/_vendor/canvas-core/plugins/{editorPlugin.d.ts → editorRuntimePlugin.d.ts} +3 -3
- package/_vendor/canvas-core/plugins/index.d.ts +1 -1
- package/_vendor/canvas-core/schema/records.d.ts +10 -1
- package/_vendor/canvas-core/shapes/shapeUtil.d.ts +14 -5
- package/_vendor/canvas-core/shapes/types.d.ts +2 -2
- package/_vendor/canvas-react/components/CanvasView.d.ts +3 -3
- package/_vendor/canvas-react/components/useCanvasDomEvents.d.ts +2 -0
- package/_vendor/canvas-react/host/actionRegistry.d.ts +15 -0
- package/_vendor/canvas-react/host/{canvasPlugin.d.ts → canvasRenderPlugin.d.ts} +5 -5
- package/_vendor/canvas-react/host/canvasRenderPluginHost.d.ts +2 -0
- package/_vendor/canvas-react/host/canvasRenderPluginHostManifest.d.ts +2 -0
- package/_vendor/canvas-react/host/canvasRenderPluginHostRuntime.d.ts +3 -0
- package/_vendor/canvas-react/host/canvasRenderPluginHostTypes.d.ts +104 -0
- package/_vendor/canvas-react/host/canvasRenderPluginHostValidation.d.ts +11 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.d.ts +8 -3
- package/_vendor/canvas-react/host/domEventGuards.d.ts +3 -3
- package/_vendor/canvas-react/host/extension.d.ts +4 -4
- package/_vendor/canvas-react/host/index.d.ts +5 -4
- package/_vendor/canvas-react/host/overlayRegistry.d.ts +3 -3
- package/_vendor/canvas-react/host/rendererRegistry.d.ts +3 -3
- package/_vendor/canvas-react/host/toolbarRegistry.d.ts +9 -13
- package/_vendor/plugin-arrow/arrowShapeUtil.d.ts +4 -3
- package/_vendor/plugin-arrow/arrowTerminalCommands.d.ts +1 -0
- package/_vendor/plugin-arrow/canvasRender.d.ts +2 -0
- package/_vendor/plugin-arrow/{editor.d.ts → editorRuntime.d.ts} +2 -2
- package/_vendor/plugin-arrow/index.d.ts +2 -2
- package/_vendor/plugin-draw/canvasRender.d.ts +2 -0
- package/_vendor/plugin-draw/{editor.d.ts → editorRuntime.d.ts} +2 -2
- package/_vendor/plugin-draw/index.d.ts +2 -2
- package/_vendor/plugin-eraser/canvasRender.d.ts +2 -0
- package/_vendor/plugin-eraser/editorRuntime.d.ts +2 -0
- package/_vendor/plugin-eraser/index.d.ts +2 -2
- package/_vendor/plugin-frame/{canvas.d.ts → canvasRender.d.ts} +2 -2
- package/_vendor/plugin-frame/{editor.d.ts → editorRuntime.d.ts} +2 -2
- package/_vendor/plugin-frame/index.d.ts +2 -2
- package/_vendor/plugin-geo/{canvas.d.ts → canvasRender.d.ts} +2 -2
- package/_vendor/plugin-geo/{editor.d.ts → editorRuntime.d.ts} +2 -2
- package/_vendor/plugin-geo/geoGeometry.d.ts +19 -3
- package/_vendor/plugin-geo/index.d.ts +2 -2
- package/_vendor/plugin-geo/types.d.ts +1 -0
- package/_vendor/plugin-group/{canvas.d.ts → canvasRender.d.ts} +2 -2
- package/_vendor/plugin-group/{editor.d.ts → editorRuntime.d.ts} +2 -2
- package/_vendor/plugin-group/index.d.ts +2 -2
- package/_vendor/plugin-image/{editor.d.ts → actionIds.d.ts} +1 -8
- package/_vendor/plugin-image/canvasRender.d.ts +2 -0
- package/_vendor/plugin-image/cornerRadius.d.ts +6 -0
- package/_vendor/plugin-image/cropRuntime.d.ts +2 -0
- package/_vendor/plugin-image/editorRuntime.d.ts +5 -0
- package/_vendor/plugin-image/imageHostActionContract.d.ts +2 -0
- package/_vendor/plugin-image/imageShapeUtil.d.ts +2 -1
- package/_vendor/plugin-image/imageSvgExporter.d.ts +6 -0
- package/_vendor/plugin-image/index.d.ts +8 -4
- package/_vendor/plugin-image/runtimeShared.d.ts +5 -0
- package/_vendor/plugin-image/smudge.d.ts +56 -0
- package/_vendor/plugin-image/smudgeInteractions.d.ts +2 -0
- package/_vendor/plugin-image/smudgeRuntime.d.ts +2 -0
- package/_vendor/plugin-image/styleRuntime.d.ts +17 -0
- package/_vendor/plugin-image/toolbarRuntime.d.ts +3 -0
- package/_vendor/plugin-image/types.d.ts +17 -1
- package/_vendor/plugin-laser/canvasRender.d.ts +2 -0
- package/_vendor/plugin-laser/editorRuntime.d.ts +2 -0
- package/_vendor/plugin-laser/index.d.ts +2 -2
- package/_vendor/plugin-text/canvasRender.d.ts +5 -0
- package/_vendor/plugin-text/editorRuntime.d.ts +5 -0
- package/_vendor/plugin-text/host/RichTextLinkPopover.d.ts +14 -0
- package/_vendor/plugin-text/host/richTextRendering.d.ts +9 -1
- package/_vendor/plugin-text/index.d.ts +2 -0
- package/_vendor/plugin-text/richTextLinks.d.ts +3 -0
- package/_vendor/plugin-text/richTextUtils.d.ts +2 -1
- package/browser/indexedDb.d.ts +10 -0
- package/browser/persistence.d.ts +2 -4
- package/builtins/controller/createBuiltInCanvasController.d.ts +1 -1
- package/builtins/controller/layerController.d.ts +1 -1
- package/builtins/controller/shapeCreationController.d.ts +9 -2
- package/builtins/index.d.ts +1 -1
- package/chrome/toolbar/CanvasKitWheelCapture.d.ts +2 -0
- package/chrome/{FloatingSelectionToolbarPageSpace.d.ts → toolbar/FloatingSelectionToolbarPageSpace.d.ts} +1 -1
- package/{core/features → chrome}/toolbar/toolbarLabels.d.ts +1 -1
- package/chrome/{bindings → toolbar}/useToolbarSurfaces.d.ts +2 -2
- package/chrome/types.d.ts +12 -8
- package/chrome/useCanvasKitChromeContext.d.ts +6 -4
- package/chrome/{bindings/useCanvasKitLayerTree.d.ts → useCanvasKitLayerTree.d.ts} +1 -1
- package/chrome/{bindings/useContextMenuSurface.d.ts → useContextMenuSurface.d.ts} +3 -3
- package/chrome/useHistoryControls.d.ts +12 -0
- package/chrome/usePageControls.d.ts +16 -0
- package/chrome/{bindings/useSvgExport.d.ts → useSvgExport.d.ts} +2 -2
- package/chrome/useZoomControls.d.ts +9 -0
- package/controller/canvasKitController.d.ts +10 -7
- package/core/api/apiRegistry.d.ts +12 -0
- package/core/index.d.ts +4 -19
- package/core/{controller → product-controller}/canvasProductController.d.ts +53 -4
- package/core/product-controller/index.d.ts +2 -0
- package/core/runtime/productDefinition.d.ts +5 -4
- package/core/runtime/productHost.d.ts +5 -2
- package/{core/features/actions/canvasActionContext.d.ts → features/actions/actionRuntime.d.ts} +7 -1
- package/{core/features → features}/clipboard/clipboardContextMenuContributions.d.ts +1 -1
- package/features/clipboard/clipboardContribution.d.ts +11 -0
- package/features/clipboard/clipboardHostExtension.d.ts +2 -0
- package/{core/features → features}/clipboard/clipboardService.d.ts +3 -3
- package/features/context-menu/contextMenuRuntime.d.ts +13 -0
- package/{core/features → features}/export/svgExport.d.ts +1 -1
- package/features/image/asset/imageAssetService.d.ts +11 -0
- package/features/image/{imageBlobStore.d.ts → asset/imageBlobStore.d.ts} +3 -2
- package/features/image/asset/imageFileHelpers.d.ts +49 -0
- package/features/image/{svgImageAssetInliner.d.ts → asset/svgImageAssetInliner.d.ts} +1 -1
- package/features/image/controller/imageProductController.d.ts +27 -0
- package/features/image/imageHostExtension.d.ts +10 -5
- package/features/image/{ImageImportController.d.ts → import/ImageImportController.d.ts} +3 -3
- package/features/image/{useImageImport.d.ts → import/useImageImport.d.ts} +3 -4
- package/features/image/index.d.ts +17 -15
- package/features/image/smudge/imageSmudgeHostActions.d.ts +10 -0
- package/features/image/smudge/imageSmudgeTypes.d.ts +24 -0
- package/features/image/toolbar/imageHostActions.d.ts +69 -0
- package/features/image/{imageToolbarHostBridge.d.ts → toolbar/imageToolbarHostBridge.d.ts} +2 -2
- package/features/keyboard/keyboardShortcutHostExtension.d.ts +2 -0
- package/features/keyboard/useCanvasKitKeyboardShortcuts.d.ts +6 -0
- package/{react → features/persistence}/CanvasKitPersistenceNotice.d.ts +1 -1
- package/features/persistence/persistenceHostExtension.d.ts +2 -0
- package/{core/features/actions/canvasActions.d.ts → features/selection/selectionActions.d.ts} +3 -9
- package/{core/features/toolbar → features/selection}/selectionContextMenuContributions.d.ts +1 -1
- package/features/selection/selectionHostExtension.d.ts +2 -0
- package/features/selection/selectionToolbarContributions.d.ts +2 -0
- package/features/tool/toolActions.d.ts +2 -0
- package/{core/features/toolbar → features/tool}/toolContextMenuContributions.d.ts +1 -1
- package/features/tool/toolHostExtension.d.ts +2 -0
- package/features/tool/toolToolbarContributions.d.ts +2 -0
- package/features/view/viewActions.d.ts +5 -0
- package/{core/features/context-menu → features/view}/viewContextMenuContributions.d.ts +1 -1
- package/features/view/viewHostExtension.d.ts +2 -0
- package/host/defaultHostExtensions.d.ts +2 -0
- package/index.d.ts +13 -7
- package/index.mjs +96 -74
- package/package.json +1 -1
- package/product/canvasKitProduct.d.ts +8 -7
- package/react/useCanvasKitController.d.ts +1 -1
- package/react/useCanvasKitRuntime.d.ts +1 -1
- package/runtime/canvasKitHostContracts.d.ts +135 -0
- package/runtime/canvasKitHostFeatureHooks.d.ts +12 -0
- package/runtime/canvasKitRuntime.d.ts +8 -6
- package/runtime/canvasKitRuntimePlan.d.ts +50 -0
- package/_vendor/canvas-core/editor/createEditorWithPlugins.d.ts +0 -6
- package/_vendor/canvas-react/host/pluginHost.d.ts +0 -2
- package/_vendor/canvas-react/host/pluginHostManifest.d.ts +0 -2
- package/_vendor/canvas-react/host/pluginHostRuntime.d.ts +0 -3
- package/_vendor/canvas-react/host/pluginHostTypes.d.ts +0 -102
- package/_vendor/canvas-react/host/pluginHostValidation.d.ts +0 -11
- package/_vendor/plugin-arrow/canvas.d.ts +0 -2
- package/_vendor/plugin-draw/canvas.d.ts +0 -2
- package/_vendor/plugin-eraser/canvas.d.ts +0 -2
- package/_vendor/plugin-eraser/editor.d.ts +0 -2
- package/_vendor/plugin-image/canvas.d.ts +0 -2
- package/_vendor/plugin-laser/canvas.d.ts +0 -2
- package/_vendor/plugin-laser/editor.d.ts +0 -2
- package/_vendor/plugin-text/canvas.d.ts +0 -5
- package/_vendor/plugin-text/editor.d.ts +0 -5
- package/chrome/bindings/useCanvasKitChromeControls.d.ts +0 -27
- package/core/controller/featureControllerRegistry.d.ts +0 -12
- package/core/controller/index.d.ts +0 -4
- package/core/features/clipboard/clipboardContribution.d.ts +0 -19
- package/core/features/context-menu/contextMenuActions.d.ts +0 -12
- package/core/features/context-menu/contextMenuContext.d.ts +0 -6
- package/core/features/context-menu/contextMenuContribution.d.ts +0 -4
- package/core/features/hostActionIds.d.ts +0 -1
- package/core/features/toolbar/toolbarContribution.d.ts +0 -4
- package/core/runtime/productContributions.d.ts +0 -9
- package/features/image/imageAssetService.d.ts +0 -7
- package/features/image/imageFileHelpers.d.ts +0 -35
- package/features/image/imageHostActions.d.ts +0 -36
- package/features/image/imageProductController.d.ts +0 -22
- package/features/image/imageProductToolbarActions.d.ts +0 -2
- package/react/useCanvasKitKeyboardShortcuts.d.ts +0 -6
- package/runtime/canvasKitHostExtensions.d.ts +0 -19
- package/runtime/canvasKitRuntimeInitializer.d.ts +0 -11
- /package/chrome/{CanvasKitFloatingToolbarLayer.d.ts → toolbar/CanvasKitFloatingToolbarLayer.d.ts} +0 -0
- /package/core/{controller → product-controller}/productLayerTree.d.ts +0 -0
package/README.md
CHANGED
|
@@ -116,11 +116,15 @@ confirmation.
|
|
|
116
116
|
|
|
117
117
|
The public product remains opaque. Internally, `defineCanvasKit()` resolves options into explicit product fields:
|
|
118
118
|
|
|
119
|
-
- `LandExtension[]` installs editor/canvas plugins through `@land/canvas-react/host`.
|
|
119
|
+
- `LandExtension[]` installs editor/canvas render plugins through `@land/canvas-react/host`.
|
|
120
120
|
- `CanvasKitHostExtension[]` installs product-host behavior such as clipboard, toolbar, context menu, image import, asset URL resolution, SVG asset inlining, and controller components.
|
|
121
121
|
- Service factories and asset resolver tokens wire product-level services into runtime.
|
|
122
122
|
- `CanvasKitRuntime` creates services, the plugin host runtime, the editor, controller registry, and then runs product runtime setup.
|
|
123
123
|
|
|
124
|
+
Advanced products can pass additional `hostExtensions` to `defineCanvasKit()`
|
|
125
|
+
for product-host behavior that should compose with the built-in runtime instead
|
|
126
|
+
of being hard-coded in chrome or canvas runtime modules.
|
|
127
|
+
|
|
124
128
|
This keeps app chrome on the root package controller while keeping browser-specific host behavior out of concrete shape plugins and out of `canvas-core`.
|
|
125
129
|
|
|
126
130
|
## Public Exports
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Editor } from "./editor";
|
|
2
2
|
import type { ChangeSource } from "../../store/index";
|
|
3
|
-
import type { AssetId, AssetRecord, AssetRecordBase, BindingId, BindingRecordBase, BindingRecord, Camera, PageId, PageRecord, ShapeId, ShapeParentId, ShapeRecordBase, ShapeRecord, ShapeEditingEntryMode } from "../schema/records";
|
|
3
|
+
import type { AssetId, AssetRecord, AssetRecordBase, BindingId, BindingRecordBase, BindingRecord, Camera, DocumentMetadataRecord, PageId, PageRecord, ShapeId, ShapeParentId, ShapeRecordBase, ShapeRecord, ShapeEditingEntryMode } from "../schema/records";
|
|
4
4
|
export interface EditorCommandOptions {
|
|
5
5
|
source?: ChangeSource;
|
|
6
6
|
}
|
|
@@ -43,6 +43,7 @@ export interface ShapeUpdate {
|
|
|
43
43
|
parentId?: ShapeParentId;
|
|
44
44
|
index?: string;
|
|
45
45
|
props?: Record<string, unknown>;
|
|
46
|
+
meta?: Record<string, unknown>;
|
|
46
47
|
}
|
|
47
48
|
export interface ReparentShapesInput {
|
|
48
49
|
ids: ShapeId[];
|
|
@@ -83,6 +84,13 @@ export interface RenamePageInput {
|
|
|
83
84
|
id: PageId;
|
|
84
85
|
name: string;
|
|
85
86
|
}
|
|
87
|
+
export interface UpdateDocumentMetaInput {
|
|
88
|
+
patch: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
export interface UpdatePageMetaInput {
|
|
91
|
+
id: PageId;
|
|
92
|
+
patch: Record<string, unknown>;
|
|
93
|
+
}
|
|
86
94
|
export interface MovePageInput {
|
|
87
95
|
id: PageId;
|
|
88
96
|
toIndex: number;
|
|
@@ -95,6 +103,8 @@ export interface EditorCommands {
|
|
|
95
103
|
createPage(input?: CreatePageInput, options?: EditorCommandOptions): PageRecord;
|
|
96
104
|
deletePage(id: PageId, options?: EditorCommandOptions): boolean;
|
|
97
105
|
renamePage(input: RenamePageInput, options?: EditorCommandOptions): void;
|
|
106
|
+
updateDocumentMeta(input: UpdateDocumentMetaInput, options?: EditorCommandOptions): DocumentMetadataRecord;
|
|
107
|
+
updatePageMeta(input: UpdatePageMetaInput, options?: EditorCommandOptions): PageRecord | null;
|
|
98
108
|
movePage(input: MovePageInput, options?: EditorCommandOptions): void;
|
|
99
109
|
createShapes(inputs: CreateShapeInput[], options?: EditorCommandOptions): ShapeRecord[];
|
|
100
110
|
/**
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type LandEditorRuntimePlugin } from "../plugins";
|
|
2
|
+
import { Editor, type EditorOptions } from "./editor";
|
|
3
|
+
export interface CreateEditorWithRuntimePluginsOptions extends Omit<EditorOptions, "shapeUtils" | "shapeSvgExporters" | "bindingUtils" | "shapeCapabilities"> {
|
|
4
|
+
editorRuntimePlugins?: readonly LandEditorRuntimePlugin[];
|
|
5
|
+
}
|
|
6
|
+
export declare function createEditorWithRuntimePlugins(options?: CreateEditorWithRuntimePluginsOptions): Editor;
|
|
@@ -5,7 +5,7 @@ import { BindingUtilRegistry } from "../bindings/bindingUtilRegistry";
|
|
|
5
5
|
import { Box } from "../geometry/box";
|
|
6
6
|
import { Mat } from "../geometry/mat";
|
|
7
7
|
import { Vec } from "../geometry/vec";
|
|
8
|
-
import { type BindingId, type BindingRecord, type AssetId, type AssetRecord, type Camera, type PageId, type PageRecord, type EditorRecord, type RecordScope, type SessionRecord, type ShapeId, type ShapeParentId, type ShapeRecord, type ShapeEditingEntryRequest, type ShapeEditingSession } from "../schema/records";
|
|
8
|
+
import { type BindingId, type BindingRecord, type AssetId, type AssetRecord, type Camera, type DocumentMetadataRecord, type PageId, type PageRecord, type EditorRecord, type RecordScope, type SessionRecord, type ShapeId, type ShapeParentId, type ShapeRecord, type ShapeEditingEntryRequest, type ShapeEditingSession } from "../schema/records";
|
|
9
9
|
import { type DocumentSnapshot, type SessionSnapshot } from "../schema/snapshots";
|
|
10
10
|
import type { ShapeSelectionFlipAxis, ShapeUtil } from "../shapes/shapeUtil";
|
|
11
11
|
import { ShapeUtilRegistry } from "../shapes/shapeUtilRegistry";
|
|
@@ -49,6 +49,7 @@ export interface EditorOptions {
|
|
|
49
49
|
shapeCapabilities?: readonly ShapeCapabilityDefinition[];
|
|
50
50
|
resolveAssetUrl?: (assetId: AssetId) => string | null;
|
|
51
51
|
documentSnapshot?: unknown;
|
|
52
|
+
documentMeta?: Record<string, unknown>;
|
|
52
53
|
sessionSnapshot?: unknown;
|
|
53
54
|
}
|
|
54
55
|
export interface ContainerBoundsQueryOptions {
|
|
@@ -293,6 +294,7 @@ export declare class Editor {
|
|
|
293
294
|
readonly selectionOverlaySignal: Signal<SelectionOverlayState | null>;
|
|
294
295
|
readonly overlayDebugStateSignal: Signal<EditorOverlayDebugState>;
|
|
295
296
|
constructor(options?: EditorOptions);
|
|
297
|
+
private registerBuiltInInteractions;
|
|
296
298
|
private registerBuiltInShortcuts;
|
|
297
299
|
private registerBuiltInSideEffects;
|
|
298
300
|
dispatch(event: EditorEvent): void;
|
|
@@ -304,6 +306,7 @@ export declare class Editor {
|
|
|
304
306
|
listen(listener: (change: StoreChange<EditorRecord>) => void): () => void;
|
|
305
307
|
getRenderItems(): RenderItem[];
|
|
306
308
|
getPages(): PageRecord[];
|
|
309
|
+
getDocumentMetadataRecord(): DocumentMetadataRecord | undefined;
|
|
307
310
|
getCurrentPageId(): PageId;
|
|
308
311
|
getActiveToolId(): string;
|
|
309
312
|
isToolLocked(): boolean;
|
|
@@ -320,6 +323,8 @@ export declare class Editor {
|
|
|
320
323
|
createPageAndSelect(input?: CreatePageInput, source?: ChangeSource): PageRecord;
|
|
321
324
|
selectPage(pageId: PageId, source?: ChangeSource): void;
|
|
322
325
|
renamePage(pageId: PageId, name: string, source?: ChangeSource): void;
|
|
326
|
+
updateDocumentMeta(patch: Record<string, unknown>, source?: ChangeSource): DocumentMetadataRecord;
|
|
327
|
+
updatePageMeta(pageId: PageId, patch: Record<string, unknown>, source?: ChangeSource): PageRecord | null;
|
|
323
328
|
deletePage(pageId: PageId, source?: ChangeSource): boolean;
|
|
324
329
|
setActiveTool(toolId: string, source?: ChangeSource): void;
|
|
325
330
|
setToolLocked(locked: boolean, source?: ChangeSource): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Editor } from "./editor";
|
|
2
|
-
export {
|
|
2
|
+
export { createEditorWithRuntimePlugins, type CreateEditorWithRuntimePluginsOptions, } from "./createEditorWithRuntimePlugins";
|
|
3
3
|
export { StateNode } from "./stateNode";
|
|
4
4
|
export { HistoryManager } from "./historyManager";
|
|
5
5
|
export { InputsManager } from "./managers/inputsManager";
|
|
@@ -9,7 +9,7 @@ import type { Editor } from "../editor";
|
|
|
9
9
|
export declare class DocumentSnapshotManager {
|
|
10
10
|
private readonly editor;
|
|
11
11
|
constructor(editor: Editor);
|
|
12
|
-
buildInitialRecords(documentSnapshot: unknown, sessionSnapshot: unknown): EditorRecord[];
|
|
12
|
+
buildInitialRecords(documentSnapshot: unknown, sessionSnapshot: unknown, documentMeta?: Record<string, unknown>): EditorRecord[];
|
|
13
13
|
getDocumentSnapshot(): DocumentSnapshot;
|
|
14
14
|
getSessionSnapshot(): SessionSnapshot;
|
|
15
15
|
loadDocumentSnapshot(snapshot: unknown, options?: {
|
|
@@ -2,15 +2,20 @@ import { Box } from "../../geometry/box";
|
|
|
2
2
|
import { Vec } from "../../geometry/vec";
|
|
3
3
|
import type { ShapeId } from "../../schema/records";
|
|
4
4
|
import type { SelectionResizeHandleId } from "../selection";
|
|
5
|
-
import type { ResizeSnapInput, SnapAxis, SnapNode, SnapPoint } from "./snapTypes";
|
|
5
|
+
import type { ResizeSnapInput, SnapAxis, SnapNode, SnapPointIndex, SnapPoint } from "./snapTypes";
|
|
6
6
|
export interface PointSnapPair {
|
|
7
7
|
selectionPoint: Vec;
|
|
8
8
|
candidatePoint: Vec;
|
|
9
|
+
candidatePointId: string;
|
|
9
10
|
candidateNodeId: ShapeId;
|
|
10
11
|
}
|
|
11
12
|
export interface PointAxisSnap {
|
|
12
13
|
type: "points";
|
|
14
|
+
id: string;
|
|
13
15
|
nudge: number;
|
|
16
|
+
distance: number;
|
|
17
|
+
weight: number;
|
|
18
|
+
candidatePointIds: string[];
|
|
14
19
|
pairs: PointSnapPair[];
|
|
15
20
|
}
|
|
16
21
|
export interface Gap {
|
|
@@ -22,11 +27,36 @@ export interface Gap {
|
|
|
22
27
|
}
|
|
23
28
|
export interface GapAxisSnap {
|
|
24
29
|
type: "gaps";
|
|
30
|
+
id: string;
|
|
25
31
|
nudge: number;
|
|
32
|
+
distance: number;
|
|
26
33
|
gaps: Gap[];
|
|
27
34
|
}
|
|
28
35
|
export type AxisSnap = PointAxisSnap | GapAxisSnap;
|
|
29
|
-
export
|
|
36
|
+
export interface PointSnapOptions {
|
|
37
|
+
previousCandidatePointIds?: ReadonlySet<string>;
|
|
38
|
+
releaseThreshold?: number;
|
|
39
|
+
switchDistance?: number;
|
|
40
|
+
stats?: PointSnapStats;
|
|
41
|
+
}
|
|
42
|
+
export interface GapSnapOptions {
|
|
43
|
+
previousSnapId?: string | null;
|
|
44
|
+
releaseThreshold?: number;
|
|
45
|
+
switchDistance?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface AxisSnapOptions {
|
|
48
|
+
previousSnap?: {
|
|
49
|
+
type: AxisSnap["type"];
|
|
50
|
+
id: string;
|
|
51
|
+
} | null;
|
|
52
|
+
switchDistance?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface PointSnapStats {
|
|
55
|
+
candidatePointCount: number;
|
|
56
|
+
matchedPointCount: number;
|
|
57
|
+
}
|
|
58
|
+
export declare function buildSnapPointIndex(points: readonly SnapPoint[]): SnapPointIndex;
|
|
59
|
+
export declare function getPointSnap(axis: SnapAxis, selectionPoints: Vec[], pointIndex: SnapPointIndex, threshold: number, options?: PointSnapOptions): PointAxisSnap | null;
|
|
30
60
|
export declare function getResizeSnapPointsForHandle(handleId: SelectionResizeHandleId | "any", bounds: Box): Vec[];
|
|
31
61
|
export declare function getResizeResultAfterNudge(input: ResizeSnapInput, nudge: Vec): {
|
|
32
62
|
bounds: Box;
|
|
@@ -36,5 +66,5 @@ export declare function getResizeResultAfterNudge(input: ResizeSnapInput, nudge:
|
|
|
36
66
|
export declare function getResizeBoundsAfterNudge(input: ResizeSnapInput, nudge: Vec): Box;
|
|
37
67
|
export declare function collectGaps(nodes: SnapNode[], axis: SnapAxis): Gap[];
|
|
38
68
|
export declare function createGap(direction: Gap["direction"], startNode: SnapNode, endNode: SnapNode, axis: SnapAxis): Gap | null;
|
|
39
|
-
export declare function getGapSnap(axis: SnapAxis, selectionBounds: Box, visibleGaps: Gap[], threshold: number): GapAxisSnap | null;
|
|
40
|
-
export declare function chooseAxisSnap(pointSnap: PointAxisSnap | null, gapSnap: GapAxisSnap | null): AxisSnap | null;
|
|
69
|
+
export declare function getGapSnap(axis: SnapAxis, selectionBounds: Box, visibleGaps: Gap[], threshold: number, options?: GapSnapOptions): GapAxisSnap | null;
|
|
70
|
+
export declare function chooseAxisSnap(pointSnap: PointAxisSnap | null, gapSnap: GapAxisSnap | null, options?: AxisSnapOptions): AxisSnap | null;
|
|
@@ -9,9 +9,16 @@ export declare class SnapManager {
|
|
|
9
9
|
readonly indicatorsSignal: Signal<SnapIndicatorState[]>;
|
|
10
10
|
readonly activeSignal: import("../../../signals/index").Computed<boolean>;
|
|
11
11
|
private readonly snapshots;
|
|
12
|
+
private readonly axisSnapMemory;
|
|
12
13
|
constructor(editor: Editor);
|
|
13
14
|
setIndicators(indicators: SnapIndicatorState[]): void;
|
|
14
15
|
clearIndicators(): void;
|
|
16
|
+
private clearAxisSnapMemory;
|
|
17
|
+
private getSwitchDistance;
|
|
18
|
+
private getReleaseThreshold;
|
|
19
|
+
private updateAxisSnapMemory;
|
|
20
|
+
private writeDebugState;
|
|
21
|
+
private getNow;
|
|
15
22
|
createTranslateSnapshot({ movingShapeIds, coordinateSpace, }: {
|
|
16
23
|
movingShapeIds: Iterable<ShapeId>;
|
|
17
24
|
coordinateSpace: SnapCoordinateSpace;
|
|
@@ -4,6 +4,7 @@ import type { ShapeId, ShapeParentId } from "../../schema/records";
|
|
|
4
4
|
import type { SelectionHandle, SelectionResizeHandleId, SnapIndicatorState } from "../selection";
|
|
5
5
|
export type SnapAxis = "x" | "y";
|
|
6
6
|
export type HandleSnapMode = "none" | "point" | "align";
|
|
7
|
+
export type SnapPointKind = "corner" | "edge_midpoint" | "center" | "custom";
|
|
7
8
|
export interface SnapCoordinateSpace {
|
|
8
9
|
rotation: number;
|
|
9
10
|
rotationCenter: Vec;
|
|
@@ -12,6 +13,16 @@ export interface SnapPoint {
|
|
|
12
13
|
id: string;
|
|
13
14
|
nodeId: ShapeId;
|
|
14
15
|
point: Vec;
|
|
16
|
+
kind?: SnapPointKind;
|
|
17
|
+
weight?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SnapPointIndexEntry {
|
|
20
|
+
value: number;
|
|
21
|
+
point: SnapPoint;
|
|
22
|
+
}
|
|
23
|
+
export interface SnapPointIndex {
|
|
24
|
+
x: SnapPointIndexEntry[];
|
|
25
|
+
y: SnapPointIndexEntry[];
|
|
15
26
|
}
|
|
16
27
|
export interface SnapNode {
|
|
17
28
|
id: string;
|
|
@@ -25,6 +36,8 @@ export interface HandleSnapPoint {
|
|
|
25
36
|
id: string;
|
|
26
37
|
nodeId: ShapeId;
|
|
27
38
|
point: Vec;
|
|
39
|
+
kind?: SnapPointKind;
|
|
40
|
+
weight?: number;
|
|
28
41
|
}
|
|
29
42
|
export interface HandleSnapOutline {
|
|
30
43
|
id: ShapeId;
|
|
@@ -38,6 +51,7 @@ export interface HandleSnapSnapshot {
|
|
|
38
51
|
}
|
|
39
52
|
export interface TranslateSnapSnapshot {
|
|
40
53
|
points: SnapPoint[];
|
|
54
|
+
pointIndex: SnapPointIndex;
|
|
41
55
|
nodes: SnapNode[];
|
|
42
56
|
coordinateSpace: SnapCoordinateSpace;
|
|
43
57
|
scopeParentId?: ShapeParentId | null;
|
|
@@ -56,6 +70,7 @@ export interface TranslateSnapResult {
|
|
|
56
70
|
}
|
|
57
71
|
export interface ResizeSnapSnapshot {
|
|
58
72
|
points: SnapPoint[];
|
|
73
|
+
pointIndex: SnapPointIndex;
|
|
59
74
|
nodes: SnapNode[];
|
|
60
75
|
coordinateSpace: SnapCoordinateSpace;
|
|
61
76
|
scopeParentId?: ShapeParentId | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Editor } from "./editor/editor";
|
|
2
|
-
export {
|
|
2
|
+
export { createEditorWithRuntimePlugins, type CreateEditorWithRuntimePluginsOptions, } from "./editor/createEditorWithRuntimePlugins";
|
|
3
3
|
export { distanceBetweenSegments, distanceToSegment, nearestPointOnSegment, segmentsIntersect, } from "./geometry";
|
|
4
4
|
export { getShapeGeometry, getShapeExportBounds, getShapeExportPageBounds, getShapeExportToPageTransform, getShapeLocalBounds, getShapeLocalToPageTransform, getShapePositionedOutlineVertices, getShapePositionedToPageTransform, getShapePageBounds, getShapePageCenter, getShapePageCorners, getShapePageOutlineVertices, pagePointToShapePositionedPoint, positionedShapePointToPagePoint, getShapeRenderBounds, getShapeRenderToPageTransform, } from "./editor/queries/shapeTransforms";
|
|
5
5
|
export type { ShapeGeometry } from "./editor/queries/shapeTransforms";
|
|
@@ -15,7 +15,7 @@ export type { ContainerBoundsQueryOptions, EditorPageState, EditorOverlayDebugSt
|
|
|
15
15
|
export type { ShapeContainment } from "./editor/managers/queryManager";
|
|
16
16
|
export type { ShapeAtPointOptions, ShapeLineSegmentHitTestOptions, SpatialQueryOptions, } from "./editor/managers/spatialIndexManager";
|
|
17
17
|
export type { TerminalBindingTargetInput, ConnectionPoint, ConnectionTerminal, TerminalBindingResolver, TerminalBindingResolverInput, ResolvedTerminalBinding, } from "./bindings/terminalBinding";
|
|
18
|
-
export type { EditorCommandOptions, EditorCommands, CreateAssetInput, CreateBindingInput, CreatePageInput, MovePageInput, RenamePageInput, ReparentShapesInput, CreateShapeInput, SetCameraInput, ShapeUpdate, StartEditingShapeInput, UpdateAssetInput, UpdateBindingInput, } from "./editor/commands";
|
|
18
|
+
export type { EditorCommandOptions, EditorCommands, CreateAssetInput, CreateBindingInput, CreatePageInput, MovePageInput, RenamePageInput, ReparentShapesInput, CreateShapeInput, SetCameraInput, ShapeUpdate, StartEditingShapeInput, UpdateAssetInput, UpdateBindingInput, UpdateDocumentMetaInput, UpdatePageMetaInput, } from "./editor/commands";
|
|
19
19
|
export { reparentShapeToContainingParent } from "./editor/commands";
|
|
20
20
|
export { isEditorClipboardPayload, } from "./editor/clipboard";
|
|
21
21
|
export type { ClipboardAssetSidecar, DuplicateSelectionInput, EditorClipboardPayload, PasteClipboardPayloadInput, } from "./editor/clipboard";
|
|
@@ -26,9 +26,9 @@ export type { DocumentSnapshot, SessionSnapshot, SnapshotMigration, } from "./sc
|
|
|
26
26
|
export { createDocumentSnapshotSupport, filterDocumentSnapshotBySupport, getDocumentSnapshotRequirements, getUnsupportedDocumentSnapshotRequirements, } from "./schema/snapshotSupport";
|
|
27
27
|
export type { DocumentSnapshotRequirements, DocumentSnapshotSupport, FilterDocumentSnapshotBySupportResult, UnsupportedDocumentSnapshotRequirements, } from "./schema/snapshotSupport";
|
|
28
28
|
export { ShapeUtil } from "./shapes/shapeUtil";
|
|
29
|
-
export type { ShapeBoundsSnapGeometry, ShapeBrushSelectInput, ShapeBrushWrapInput, ShapeBindingPointInput, ShapeBindingTargetHitTestInput, ShapeEditEndResult, ShapeGeometryInput, ShapeHandleSnapContext, ShapeHandleSnapGeometry, ShapeLineSegmentHitTestInput, ShapePointHitTestInput, ShapeSelectionHandleAnchorInput, ShapeSelectionHandleAnchors, ShapeSelectionFrameInput, ShapeSelectionFlipAxis, ShapeSelectionFlipInput, ShapeSelectionOverlayInfo, ShapeSelectionOverlayInfoInput, ShapeSelectionPagePoints, ShapeSelectionPagePointsInput, ShapeSelectionResizeAspectRatioLockInput, ShapeSelectionResizeInput, ShapeSelectionTranslateInput, } from "./shapes/shapeUtil";
|
|
29
|
+
export type { ShapeBoundsSnapGeometry, ShapeBrushSelectInput, ShapeBrushWrapInput, ShapeBindingPointInput, ShapeBindingTargetHitTestInput, ShapeEditEndInput, ShapeEditEndResult, ShapeGeometryInput, ShapeHandleSnapContext, ShapeHandleSnapGeometry, ShapeLineSegmentHitTestInput, ShapePointHitTestInput, ShapeSnapPoint, ShapeSnapPointKind, ShapeSelectionHandleAnchorInput, ShapeSelectionHandleAnchors, ShapeSelectionFrameInput, ShapeSelectionFlipAxis, ShapeSelectionFlipInput, ShapeSelectionOverlayInfo, ShapeSelectionOverlayInfoInput, ShapeSelectionPagePoints, ShapeSelectionPagePointsInput, ShapeSelectionResizeAspectRatioLockInput, ShapeSelectionResizeInput, ShapeSelectionTranslateInput, } from "./shapes/shapeUtil";
|
|
30
30
|
export type { LaserTrailState } from "./editor/managers/interactionTransientManager";
|
|
31
|
-
export type { HandleSnapContext, HandleSnapInput, HandleSnapMode, HandleSnapResult, HandleSnapSnapshot, HandleSnapSnapshotInput, ResizeSnapInput, ResizeSnapResult, ResizeSnapSnapshot, SnapAxis, SnapCoordinateSpace, TranslateSnapInput, TranslateSnapResult, TranslateSnapSnapshot, } from "./editor/managers/snapTypes";
|
|
31
|
+
export type { HandleSnapContext, HandleSnapInput, HandleSnapMode, HandleSnapResult, HandleSnapSnapshot, HandleSnapSnapshotInput, ResizeSnapInput, ResizeSnapResult, ResizeSnapSnapshot, SnapAxis, SnapCoordinateSpace, SnapPointIndex, SnapPointIndexEntry, SnapPointKind, TranslateSnapInput, TranslateSnapResult, TranslateSnapSnapshot, } from "./editor/managers/snapTypes";
|
|
32
32
|
export { ShapeUtilRegistry } from "./shapes/shapeUtilRegistry";
|
|
33
33
|
export { resolveTerminalBindingAtPoint, } from "./bindings/terminalBinding";
|
|
34
34
|
export { ShapeSvgExporterRegistry, exportShapesToSvgString, renderSvgNode, } from "./exports/svg";
|
|
@@ -48,10 +48,10 @@ export { SET_ACTIVE_TOOL_TOOLBAR_ACTION_ID, TOGGLE_TOOL_LOCKED_TOOLBAR_ACTION_ID
|
|
|
48
48
|
export { LAND_DEFAULT_THEME_COLOR_FALLBACKS, LAND_THEME_COLOR_SLOTS, LAND_THEME_COLOR_TOKEN_BY_SLOT, areShapeColorsEqual, createCustomShapeColor, createThemeShapeColor, getThemeColorTokenName, isCustomShapeColorRef, isShapeColor, isThemeShapeColorRef, isTransparentShapeColor, normalizeShapeColor, resolveShapeColor, shapeColorToCssColor, } from "./shapes/colors";
|
|
49
49
|
export type { CustomShapeColorRef, ShapeColor, ShapeColorRef, ThemeColorSlot, ThemeColorTokenName, ThemeShapeColorRef, } from "./shapes/colors";
|
|
50
50
|
export type { ContextMenuBadgeItem, ContextMenuCanvasTarget, ContextMenuCommandItem, ContextMenuContext, ContextMenuContribution, ContextMenuContributionTarget, ContextMenuItem, ActiveContextMenu, ContextMenuSection, ContextMenuSelectionTarget, ContextMenuSeparatorItem, ContextMenuShapeTarget, ContextMenuTarget, } from "./surfaces/contextMenu";
|
|
51
|
-
export {
|
|
51
|
+
export { getEditorOptionsFromEditorRuntimePlugins, setupEditorRuntimePlugins, type LandEditorRuntimePlugin, } from "./plugins";
|
|
52
52
|
export type { CanvasAction, CanvasActionRunInput, CanvasActionValue, CanvasActionContext, CanvasSelectionSnapshot, CanvasToolSnapshot, } from "./surfaces/actions";
|
|
53
53
|
export type { ToolbarBadgeItem, ToolbarButtonItem, ToolbarContribution, ToolbarGroup, ToolbarItem, ToolbarSegmentedItem, ToolbarSegmentedOption, ToolbarSeparatorItem, ToolbarStepperItem, ToolbarStepperOption, ToolbarTextInputItem, ToolbarPlacement, ToolbarSurface, ToolbarSwatchesItem, ToolbarSwatchOption, } from "./surfaces/toolbar";
|
|
54
|
-
export { DEFAULT_CAMERA, DEFAULT_PAGE_ID, DEFAULT_SESSION_ID, createDefaultPage, createDefaultSession, isAnyAssetRecord, isAnyBindingRecord, isAnyShapeRecord, isAssetRecord, isBindingRecord, isDocumentRecord, isPageRecord, isSessionRecord, isShapeRecord, type AnyBindingRecord, type AnyAssetRecord, type AnyShapeRecord, type AssetId, type AssetRecord, type AssetRecordBase, type BaseRecord, type BindingId, type BindingRecordBase, type BindingRecord, type Camera, type DocumentRecord, type EditorRecord, type PageCameraById, type PageId, type PageSelectionById, type PageRecord, type RecordScope, type SessionRecord, type ShapeId, type ShapeParentId, type ShapeRecordBase, type ShapeRecord, type ShapeEditingEntryRequest, type ShapeEditingEntryMode, type ShapeEditingPoint, type ShapeEditingSession, } from "./schema/records";
|
|
54
|
+
export { DEFAULT_CAMERA, DEFAULT_DOCUMENT_ID, DEFAULT_PAGE_ID, DEFAULT_SESSION_ID, createDefaultDocument, createDefaultPage, createDefaultSession, isAnyAssetRecord, isAnyBindingRecord, isAnyShapeRecord, isAssetRecord, isBindingRecord, isDocumentRecord, isDocumentMetadataRecord, isPageRecord, isSessionRecord, isShapeRecord, type AnyBindingRecord, type AnyAssetRecord, type AnyShapeRecord, type AssetId, type AssetRecord, type AssetRecordBase, type BaseRecord, type BindingId, type BindingRecordBase, type BindingRecord, type Camera, type DocumentId, type DocumentMetadataRecord, type DocumentRecord, type EditorRecord, type PageCameraById, type PageId, type PageSelectionById, type PageRecord, type RecordScope, type SessionRecord, type ShapeId, type ShapeParentId, type ShapeRecordBase, type ShapeRecord, type ShapeEditingEntryRequest, type ShapeEditingEntryMode, type ShapeEditingPoint, type ShapeEditingSession, } from "./schema/records";
|
|
55
55
|
export { Vec } from "./geometry/vec";
|
|
56
56
|
export { Box } from "./geometry/box";
|
|
57
57
|
export { Mat } from "./geometry/mat";
|
|
@@ -7,7 +7,7 @@ import type { ShapeUtil } from "../shapes/shapeUtil";
|
|
|
7
7
|
import type { CanvasAction } from "../surfaces/actions";
|
|
8
8
|
import type { ContextMenuContribution } from "../surfaces/contextMenu";
|
|
9
9
|
import type { ToolbarContribution } from "../surfaces/toolbar";
|
|
10
|
-
export interface
|
|
10
|
+
export interface LandEditorRuntimePlugin {
|
|
11
11
|
id: string;
|
|
12
12
|
shapeCapabilities?: ShapeCapabilityDefinition[];
|
|
13
13
|
shapeUtils?: ShapeUtil[];
|
|
@@ -19,10 +19,10 @@ export interface LandEditorPlugin {
|
|
|
19
19
|
contextMenuContributions?: ContextMenuContribution[];
|
|
20
20
|
setup?(editor: Editor): void;
|
|
21
21
|
}
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function getEditorOptionsFromEditorRuntimePlugins(plugins: readonly LandEditorRuntimePlugin[]): {
|
|
23
23
|
shapeUtils: ShapeUtil[];
|
|
24
24
|
shapeSvgExporters: ShapeSvgExporter[];
|
|
25
25
|
bindingUtils: BindingUtil[];
|
|
26
26
|
shapeCapabilities: ShapeCapabilityDefinition[];
|
|
27
27
|
};
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function setupEditorRuntimePlugins(editor: Editor, plugins: readonly LandEditorRuntimePlugin[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getEditorOptionsFromEditorRuntimePlugins, setupEditorRuntimePlugins, type LandEditorRuntimePlugin, } from "./editorRuntimePlugin";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type RecordScope = "document" | "session";
|
|
2
2
|
export type PageId = `page:${string}`;
|
|
3
|
+
export type DocumentId = "document:main";
|
|
3
4
|
export type ShapeId = `shape:${string}`;
|
|
4
5
|
export type BindingId = `binding:${string}`;
|
|
5
6
|
export type AssetId = `asset:${string}`;
|
|
@@ -36,6 +37,11 @@ export interface BaseRecord {
|
|
|
36
37
|
scope: RecordScope;
|
|
37
38
|
meta: Record<string, unknown>;
|
|
38
39
|
}
|
|
40
|
+
export interface DocumentMetadataRecord extends BaseRecord {
|
|
41
|
+
id: DocumentId;
|
|
42
|
+
typeName: "document";
|
|
43
|
+
scope: "document";
|
|
44
|
+
}
|
|
39
45
|
export interface PageRecord extends BaseRecord {
|
|
40
46
|
id: PageId;
|
|
41
47
|
typeName: "page";
|
|
@@ -94,14 +100,17 @@ export interface SessionRecord extends BaseRecord {
|
|
|
94
100
|
pageCameraById: PageCameraById;
|
|
95
101
|
pageSelectedShapeIdsById: PageSelectionById;
|
|
96
102
|
}
|
|
97
|
-
export type DocumentRecord = PageRecord | AnyShapeRecord | AnyBindingRecord | AnyAssetRecord;
|
|
103
|
+
export type DocumentRecord = DocumentMetadataRecord | PageRecord | AnyShapeRecord | AnyBindingRecord | AnyAssetRecord;
|
|
98
104
|
export type EditorRecord = DocumentRecord | SessionRecord;
|
|
105
|
+
export declare const DEFAULT_DOCUMENT_ID: DocumentId;
|
|
99
106
|
export declare const DEFAULT_PAGE_ID: PageId;
|
|
100
107
|
export declare const DEFAULT_SESSION_ID: SessionId;
|
|
101
108
|
export declare const DEFAULT_CAMERA: Camera;
|
|
109
|
+
export declare function createDefaultDocument(meta?: Record<string, unknown>): DocumentMetadataRecord;
|
|
102
110
|
export declare function createDefaultPage(): PageRecord;
|
|
103
111
|
export declare function createDefaultSession(currentPageId?: PageId): SessionRecord;
|
|
104
112
|
export declare function isPageRecord(record: BaseRecord | null | undefined): record is PageRecord;
|
|
113
|
+
export declare function isDocumentMetadataRecord(record: BaseRecord | null | undefined): record is DocumentMetadataRecord;
|
|
105
114
|
export declare function isShapeRecord(record: BaseRecord | null | undefined): record is ShapeRecord;
|
|
106
115
|
export declare function isAnyShapeRecord(record: BaseRecord | null | undefined): record is AnyShapeRecord;
|
|
107
116
|
export declare function isSessionRecord(record: BaseRecord | null | undefined): record is SessionRecord;
|
|
@@ -9,6 +9,9 @@ import type { ShapeId, ShapeRecordBase } from "../schema/records";
|
|
|
9
9
|
export interface ShapeEditEndResult {
|
|
10
10
|
deleteShapeIds?: ShapeId[];
|
|
11
11
|
}
|
|
12
|
+
export interface ShapeEditEndInput {
|
|
13
|
+
editor: Editor;
|
|
14
|
+
}
|
|
12
15
|
export interface ShapeBindingPointInput {
|
|
13
16
|
rawPagePoint: Vec;
|
|
14
17
|
oppositePagePoint: Vec;
|
|
@@ -65,8 +68,14 @@ export interface ShapePointHitTestInput extends ShapeGeometryInput {
|
|
|
65
68
|
}
|
|
66
69
|
export interface ShapeBindingTargetHitTestInput extends ShapePointHitTestInput {
|
|
67
70
|
}
|
|
71
|
+
export type ShapeSnapPointKind = "corner" | "edge_midpoint" | "center" | "custom";
|
|
72
|
+
export interface ShapeSnapPoint {
|
|
73
|
+
point: Vec;
|
|
74
|
+
kind?: ShapeSnapPointKind;
|
|
75
|
+
weight?: number;
|
|
76
|
+
}
|
|
68
77
|
export interface ShapeBoundsSnapGeometry {
|
|
69
|
-
points?: readonly
|
|
78
|
+
points?: readonly ShapeSnapPoint[];
|
|
70
79
|
}
|
|
71
80
|
export interface ShapeHandleSnapContext {
|
|
72
81
|
shapeId: ShapeId;
|
|
@@ -74,9 +83,9 @@ export interface ShapeHandleSnapContext {
|
|
|
74
83
|
currentPagePoint: Vec;
|
|
75
84
|
}
|
|
76
85
|
export interface ShapeHandleSnapGeometry {
|
|
77
|
-
points?: readonly
|
|
86
|
+
points?: readonly ShapeSnapPoint[];
|
|
78
87
|
outline?: readonly Vec[] | null;
|
|
79
|
-
getSelfSnapPoints?(context: ShapeHandleSnapContext): readonly
|
|
88
|
+
getSelfSnapPoints?(context: ShapeHandleSnapContext): readonly ShapeSnapPoint[];
|
|
80
89
|
getSelfSnapOutline?(context: ShapeHandleSnapContext): readonly Vec[] | null;
|
|
81
90
|
}
|
|
82
91
|
export interface ShapeSelectionHandleAnchorInput {
|
|
@@ -129,7 +138,7 @@ export declare abstract class ShapeUtil<S extends ShapeRecordBase = ShapeRecordB
|
|
|
129
138
|
isTransformDescendantContainer(_shape: S): boolean;
|
|
130
139
|
shouldRotateDescendants(shape: S): boolean;
|
|
131
140
|
canUngroupChildren(_shape: S): boolean;
|
|
132
|
-
canStartTranslateFromSelectionBounds(_shape: S): boolean;
|
|
141
|
+
canStartTranslateFromSelectionBounds(_shape: S, _input: ShapeSelectionFrameInput): boolean;
|
|
133
142
|
canSnap(_shape: S): boolean;
|
|
134
143
|
getBoundsSnapGeometry(_shape: S): ShapeBoundsSnapGeometry;
|
|
135
144
|
getHandleSnapGeometry(shape: S): ShapeHandleSnapGeometry;
|
|
@@ -143,7 +152,7 @@ export declare abstract class ShapeUtil<S extends ShapeRecordBase = ShapeRecordB
|
|
|
143
152
|
canReceiveChildren(_shape: S): boolean;
|
|
144
153
|
canReceiveTerminalBinding(_shape: S, _input?: ShapeGeometryInput): boolean;
|
|
145
154
|
repairLoadedShape(_shape: S): S | null;
|
|
146
|
-
onEditEnd(_shape: S): ShapeEditEndResult | void;
|
|
155
|
+
onEditEnd(_shape: S, _input: ShapeEditEndInput): ShapeEditEndResult | void;
|
|
147
156
|
hitTest(shape: S, positionedPoint: Vec, _input?: ShapePointHitTestInput): boolean;
|
|
148
157
|
hitTestBindingTarget(shape: S, positionedPoint: Vec, input?: ShapeBindingTargetHitTestInput): boolean;
|
|
149
158
|
hitTestLineSegment(shape: S, input: ShapeLineSegmentHitTestInput): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { BindingId, BindingRecord, PageRecord, PageId, EditorRecord, ShapeRecord, ShapeId, SessionRecord, } from "../schema/records";
|
|
2
|
-
export { DEFAULT_PAGE_ID, DEFAULT_SESSION_ID, createDefaultPage, createDefaultSession, isBindingRecord, isPageRecord, isShapeRecord, isSessionRecord, } from "../schema/records";
|
|
1
|
+
export type { BindingId, BindingRecord, DocumentId, DocumentMetadataRecord, PageRecord, PageId, EditorRecord, ShapeRecord, ShapeId, SessionRecord, } from "../schema/records";
|
|
2
|
+
export { DEFAULT_DOCUMENT_ID, DEFAULT_PAGE_ID, DEFAULT_SESSION_ID, createDefaultDocument, createDefaultPage, createDefaultSession, isBindingRecord, isDocumentMetadataRecord, isPageRecord, isShapeRecord, isSessionRecord, } from "../schema/records";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ActiveContextMenu } from "../../canvas-core/index";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CanvasRenderPluginComponent, CanvasRenderPluginProvider } from "../host/canvasRenderPlugin";
|
|
3
3
|
import { type CanvasRendererRegistry } from "../host/rendererRegistry";
|
|
4
4
|
import { type CanvasOverlayRegistry } from "../host/overlayRegistry";
|
|
5
5
|
import { type CanvasDomEventGuardRegistry } from "../host/domEventGuards";
|
|
6
6
|
export declare function Canvas({ canvasComponents, canvasProviders, domEventGuardRegistry, onContextMenuRequest, overlayRegistry, rendererRegistry, showGrid, }?: {
|
|
7
|
-
canvasComponents?: readonly
|
|
8
|
-
canvasProviders?: readonly
|
|
7
|
+
canvasComponents?: readonly CanvasRenderPluginComponent[];
|
|
8
|
+
canvasProviders?: readonly CanvasRenderPluginProvider[];
|
|
9
9
|
domEventGuardRegistry?: CanvasDomEventGuardRegistry;
|
|
10
10
|
onContextMenuRequest?: (activeContextMenu: ActiveContextMenu) => void;
|
|
11
11
|
overlayRegistry?: CanvasOverlayRegistry;
|
|
@@ -3,12 +3,14 @@ import { type ActiveContextMenu, type Editor, type ShapeEditingSession } from ".
|
|
|
3
3
|
import type { CanvasDomEventGuardRegistry } from "../host/domEventGuards";
|
|
4
4
|
export interface CanvasDomEventHandlers {
|
|
5
5
|
onPointerDown: (event: ReactPointerEvent<HTMLDivElement>) => void;
|
|
6
|
+
onAuxClick: (event: ReactMouseEvent<HTMLDivElement>) => void;
|
|
6
7
|
onContextMenu: (event: ReactMouseEvent<HTMLDivElement>) => void;
|
|
7
8
|
}
|
|
8
9
|
export interface CanvasDomEventState {
|
|
9
10
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
10
11
|
handlers: CanvasDomEventHandlers;
|
|
11
12
|
isPointerActive: boolean;
|
|
13
|
+
isMiddleButtonPanning: boolean;
|
|
12
14
|
surfaceCursor: string | undefined;
|
|
13
15
|
}
|
|
14
16
|
export declare function useCanvasDomEvents({ activeDomEventGuards, activeToolId, editor, onContextMenuRequest, shapeEditingSession, }: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CanvasAction, LandEditorRuntimePlugin } from "../../canvas-core/index";
|
|
2
|
+
export declare class CanvasActionRegistry {
|
|
3
|
+
private readonly actions;
|
|
4
|
+
private readonly hostActionIds;
|
|
5
|
+
private readonly duplicateActionIds;
|
|
6
|
+
registerAction(action: CanvasAction, options?: {
|
|
7
|
+
replace?: boolean;
|
|
8
|
+
}): void;
|
|
9
|
+
registerHostAction(action: CanvasAction): void;
|
|
10
|
+
registerEditorRuntimePlugins(plugins: readonly LandEditorRuntimePlugin[]): void;
|
|
11
|
+
getAction(actionId: string): CanvasAction | null;
|
|
12
|
+
getHostActionIds(): string[];
|
|
13
|
+
getDuplicateActionIds(): string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function createCanvasActionRegistry(plugins?: readonly LandEditorRuntimePlugin[]): CanvasActionRegistry;
|
|
@@ -30,11 +30,11 @@ export interface CanvasOverlayContribution {
|
|
|
30
30
|
layer?: CanvasOverlayLayer;
|
|
31
31
|
order?: number;
|
|
32
32
|
}
|
|
33
|
-
export interface
|
|
33
|
+
export interface CanvasRenderPluginComponent {
|
|
34
34
|
id: string;
|
|
35
35
|
component: ComponentType;
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface CanvasRenderPluginProvider {
|
|
38
38
|
id: string;
|
|
39
39
|
component: ComponentType<{
|
|
40
40
|
children: ReactNode;
|
|
@@ -62,12 +62,12 @@ export interface CanvasDomEventGuard {
|
|
|
62
62
|
handle(input: CanvasDomEventGuardInput): CanvasDomEventGuardDecision;
|
|
63
63
|
getCursor?(input: CanvasDomEventGuardCursorInput): string | undefined;
|
|
64
64
|
}
|
|
65
|
-
export interface
|
|
65
|
+
export interface LandCanvasRenderPlugin {
|
|
66
66
|
id: string;
|
|
67
67
|
shapeRenderers?: readonly AnyRegisteredShapeRenderer[];
|
|
68
68
|
canvasOverlays?: readonly CanvasOverlayContribution[];
|
|
69
69
|
selectionCustomHandleRenderers?: readonly AnyRegisteredSelectionCustomHandleRenderer[];
|
|
70
70
|
domEventGuards?: readonly CanvasDomEventGuard[];
|
|
71
|
-
canvasProviders?: readonly
|
|
72
|
-
canvasComponents?: readonly
|
|
71
|
+
canvasProviders?: readonly CanvasRenderPluginProvider[];
|
|
72
|
+
canvasComponents?: readonly CanvasRenderPluginComponent[];
|
|
73
73
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createCanvasRenderPluginHostRuntime } from "./canvasRenderPluginHostRuntime";
|
|
2
|
+
export type { CanvasRenderPluginHostManifestContextMenuContributionEntry, CanvasRenderPluginHostManifestEntry, CanvasRenderPluginHostManifestToolbarContributionEntry, CanvasRenderPluginHostRuntime, CanvasRenderPluginHostShapeValidationSummary, CanvasRenderPluginHostSource, CanvasRenderPluginHostValidationIssue, CanvasRenderPluginHostValidationIssueSeverity, CanvasRenderPluginHostValidationSummary, CanvasRenderPluginHostVerdict, CreateCanvasRenderPluginHostRuntimeOptions, } from "./canvasRenderPluginHostTypes";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type LandExtension } from "./extension";
|
|
2
|
+
import type { CanvasRenderPluginHostRuntime, CreateCanvasRenderPluginHostRuntimeOptions } from "./canvasRenderPluginHostTypes";
|
|
3
|
+
export declare function createCanvasRenderPluginHostRuntime(extensions: readonly LandExtension[], options?: CreateCanvasRenderPluginHostRuntimeOptions): CanvasRenderPluginHostRuntime;
|