@grida/svg-editor 1.0.0-alpha.13 → 1.0.0-alpha.14
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 +88 -42
- package/dist/{dom-Cvm9Towu.js → dom-BuD8TKmL.js} +1592 -624
- package/dist/dom-D4dy6kq5.d.ts +112 -0
- package/dist/{dom-BlMk07oX.mjs → dom-DSjfCllZ.mjs} +1566 -617
- package/dist/dom-Dz_V6q0Y.d.mts +114 -0
- package/dist/dom.d.mts +3 -3
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +4 -1
- package/dist/dom.mjs +2 -2
- package/dist/{editor-DtuRIs-Q.mjs → editor-B6pchGYk.mjs} +519 -321
- package/dist/{editor-CdyC3uAe.js → editor-BHHU_Nvz.js} +527 -329
- package/dist/{editor-Bd4-VCEJ.d.ts → editor-CJ2KuRh5.d.ts} +472 -24
- package/dist/{editor-BH03X8cX.d.mts → editor-YQwdWHBb.d.mts} +472 -24
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -4
- package/dist/index.mjs +3 -3
- package/dist/model-DIzZmeyf.mjs +3677 -0
- package/dist/model-DqGqV1H4.js +3823 -0
- package/dist/presets.d.mts +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +2 -2
- package/dist/react.d.mts +18 -6
- package/dist/react.d.ts +18 -6
- package/dist/react.js +24 -3
- package/dist/react.mjs +24 -3
- package/package.json +9 -8
- package/dist/dom-DCX-a8Kr.d.ts +0 -57
- package/dist/dom-DgB4f-TE.d.mts +0 -59
- package/dist/insertions-BJ-6o6o5.js +0 -2399
- package/dist/insertions-Okcuo-Ck.mjs +0 -2176
- /package/dist/{chunk-CfYAbeIz.mjs → chunk-D7D4PA-g.mjs} +0 -0
package/dist/presets.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as SvgEditor } from "./editor-
|
|
2
|
-
import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-
|
|
1
|
+
import { c as SvgEditor } from "./editor-YQwdWHBb.mjs";
|
|
2
|
+
import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-Dz_V6q0Y.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/presets/keynote.d.ts
|
|
5
5
|
declare namespace keynote_d_exports {
|
package/dist/presets.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as SvgEditor } from "./editor-
|
|
2
|
-
import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-
|
|
1
|
+
import { c as SvgEditor } from "./editor-CJ2KuRh5.js";
|
|
2
|
+
import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-D4dy6kq5.js";
|
|
3
3
|
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
declare namespace keynote_d_exports {
|
package/dist/presets.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_dom = require("./dom-
|
|
2
|
+
const require_model = require("./model-DqGqV1H4.js");
|
|
3
|
+
const require_dom = require("./dom-BuD8TKmL.js");
|
|
4
4
|
//#region src/presets/keynote.ts
|
|
5
|
-
var keynote_exports = /* @__PURE__ */
|
|
5
|
+
var keynote_exports = /* @__PURE__ */ require_model.__exportAll({ attach: () => attach });
|
|
6
6
|
/**
|
|
7
7
|
* Attach a keynote-shaped DOM surface:
|
|
8
8
|
* - Mounts via `attach_dom_surface` with `fit: true` (slide is visible on
|
package/dist/presets.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-
|
|
2
|
-
import { t as attach_dom_surface } from "./dom-
|
|
1
|
+
import { t as __exportAll } from "./chunk-D7D4PA-g.mjs";
|
|
2
|
+
import { t as attach_dom_surface } from "./dom-DSjfCllZ.mjs";
|
|
3
3
|
//#region src/presets/keynote.ts
|
|
4
4
|
var keynote_exports = /* @__PURE__ */ __exportAll({ attach: () => attach });
|
|
5
5
|
/**
|
package/dist/react.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as DomSurfaceHandle } from "./dom-
|
|
1
|
+
import { A as EditorState, G as PaintPreviewSession, H as NodeId, V as Mode, X as Providers, c as SvgEditor, j as EditorStyle, q as PreviewSession, t as Commands, tt as Tool } from "./editor-YQwdWHBb.mjs";
|
|
2
|
+
import { t as DomSurfaceHandle } from "./dom-Dz_V6q0Y.mjs";
|
|
3
3
|
import cmath from "@grida/cmath";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
5
|
|
|
7
6
|
//#region src/react.d.ts
|
|
8
7
|
type SvgEditorProviderProps = {
|
|
@@ -35,7 +34,7 @@ declare function SvgEditorProvider({
|
|
|
35
34
|
providers,
|
|
36
35
|
style,
|
|
37
36
|
children
|
|
38
|
-
}: SvgEditorProviderProps):
|
|
37
|
+
}: SvgEditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
39
38
|
type SvgEditorCanvasProps = {
|
|
40
39
|
className?: string;
|
|
41
40
|
style?: React.CSSProperties;
|
|
@@ -73,7 +72,7 @@ declare function SvgEditorCanvas({
|
|
|
73
72
|
fit,
|
|
74
73
|
initial_camera,
|
|
75
74
|
onAttach
|
|
76
|
-
}: SvgEditorCanvasProps):
|
|
75
|
+
}: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
77
76
|
declare function useSvgEditor(): SvgEditor;
|
|
78
77
|
/**
|
|
79
78
|
* Subscribe to a slice of `editor.state`. Re-renders when the selected slice
|
|
@@ -109,6 +108,19 @@ declare function useSelection(): readonly NodeId[];
|
|
|
109
108
|
declare function useTool(): Tool;
|
|
110
109
|
/** Current mode (`"select"` | `"edit-content"`). */
|
|
111
110
|
declare function useMode(): Mode;
|
|
111
|
+
/**
|
|
112
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
113
|
+
*
|
|
114
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
115
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
116
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
117
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
118
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
119
|
+
*
|
|
120
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
121
|
+
* selection, and for any tag that's neither path nor text.
|
|
122
|
+
*/
|
|
123
|
+
declare function useContentEditKind(): "path" | "text" | null;
|
|
112
124
|
/** Whether the history stack has an undoable entry. */
|
|
113
125
|
declare function useCanUndo(): boolean;
|
|
114
126
|
/** Whether the history stack has a redoable entry. */
|
|
@@ -131,4 +143,4 @@ declare function useEditorSerialize(): () => string;
|
|
|
131
143
|
*/
|
|
132
144
|
declare function useHoverOverride(): (id: NodeId | null) => void;
|
|
133
145
|
//#endregion
|
|
134
|
-
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
|
146
|
+
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as DomSurfaceHandle } from "./dom-
|
|
1
|
+
import { A as EditorState, G as PaintPreviewSession, H as NodeId, V as Mode, X as Providers, c as SvgEditor, j as EditorStyle, q as PreviewSession, t as Commands, tt as Tool } from "./editor-CJ2KuRh5.js";
|
|
2
|
+
import { t as DomSurfaceHandle } from "./dom-D4dy6kq5.js";
|
|
3
3
|
import cmath from "@grida/cmath";
|
|
4
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
4
|
import { ReactNode } from "react";
|
|
6
5
|
|
|
7
6
|
//#region src/react.d.ts
|
|
@@ -35,7 +34,7 @@ declare function SvgEditorProvider({
|
|
|
35
34
|
providers,
|
|
36
35
|
style,
|
|
37
36
|
children
|
|
38
|
-
}: SvgEditorProviderProps):
|
|
37
|
+
}: SvgEditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
39
38
|
type SvgEditorCanvasProps = {
|
|
40
39
|
className?: string;
|
|
41
40
|
style?: React.CSSProperties;
|
|
@@ -73,7 +72,7 @@ declare function SvgEditorCanvas({
|
|
|
73
72
|
fit,
|
|
74
73
|
initial_camera,
|
|
75
74
|
onAttach
|
|
76
|
-
}: SvgEditorCanvasProps):
|
|
75
|
+
}: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
77
76
|
declare function useSvgEditor(): SvgEditor;
|
|
78
77
|
/**
|
|
79
78
|
* Subscribe to a slice of `editor.state`. Re-renders when the selected slice
|
|
@@ -109,6 +108,19 @@ declare function useSelection(): readonly NodeId[];
|
|
|
109
108
|
declare function useTool(): Tool;
|
|
110
109
|
/** Current mode (`"select"` | `"edit-content"`). */
|
|
111
110
|
declare function useMode(): Mode;
|
|
111
|
+
/**
|
|
112
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
113
|
+
*
|
|
114
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
115
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
116
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
117
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
118
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
119
|
+
*
|
|
120
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
121
|
+
* selection, and for any tag that's neither path nor text.
|
|
122
|
+
*/
|
|
123
|
+
declare function useContentEditKind(): "path" | "text" | null;
|
|
112
124
|
/** Whether the history stack has an undoable entry. */
|
|
113
125
|
declare function useCanUndo(): boolean;
|
|
114
126
|
/** Whether the history stack has a redoable entry. */
|
|
@@ -131,4 +143,4 @@ declare function useEditorSerialize(): () => string;
|
|
|
131
143
|
*/
|
|
132
144
|
declare function useHoverOverride(): (id: NodeId | null) => void;
|
|
133
145
|
//#endregion
|
|
134
|
-
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
|
146
|
+
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./
|
|
4
|
-
const
|
|
5
|
-
const require_dom = require("./dom-Cvm9Towu.js");
|
|
3
|
+
const require_editor = require("./editor-BHHU_Nvz.js");
|
|
4
|
+
const require_dom = require("./dom-BuD8TKmL.js");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
//#region src/react.tsx
|
|
@@ -137,6 +136,27 @@ function useTool() {
|
|
|
137
136
|
function useMode() {
|
|
138
137
|
return useEditorState((s) => s.mode);
|
|
139
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
141
|
+
*
|
|
142
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
143
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
144
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
145
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
146
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
147
|
+
*
|
|
148
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
149
|
+
* selection, and for any tag that's neither path nor text.
|
|
150
|
+
*/
|
|
151
|
+
function useContentEditKind() {
|
|
152
|
+
const editor = useSvgEditor();
|
|
153
|
+
const [mode, id] = useEditorState((s) => `${s.mode}::${s.selection[0] ?? ""}`, (a, b) => a === b).split("::");
|
|
154
|
+
if (mode !== "edit-content" || !id) return null;
|
|
155
|
+
const tag = editor.tree().nodes.get(id)?.tag;
|
|
156
|
+
if (tag === "path") return "path";
|
|
157
|
+
if (tag === "text" || tag === "tspan") return "text";
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
140
160
|
/** Whether the history stack has an undoable entry. */
|
|
141
161
|
function useCanUndo() {
|
|
142
162
|
return useEditorState((s) => s.can_undo);
|
|
@@ -223,6 +243,7 @@ exports.useCameraSnapshot = useCameraSnapshot;
|
|
|
223
243
|
exports.useCanRedo = useCanRedo;
|
|
224
244
|
exports.useCanUndo = useCanUndo;
|
|
225
245
|
exports.useCommands = useCommands;
|
|
246
|
+
exports.useContentEditKind = useContentEditKind;
|
|
226
247
|
exports.useEditorLoad = useEditorLoad;
|
|
227
248
|
exports.useEditorSerialize = useEditorSerialize;
|
|
228
249
|
exports.useEditorState = useEditorState;
|
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { t as createSvgEditor } from "./editor-
|
|
3
|
-
import { t as attach_dom_surface } from "./dom-
|
|
2
|
+
import { t as createSvgEditor } from "./editor-B6pchGYk.mjs";
|
|
3
|
+
import { t as attach_dom_surface } from "./dom-DSjfCllZ.mjs";
|
|
4
4
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react.tsx
|
|
@@ -135,6 +135,27 @@ function useTool() {
|
|
|
135
135
|
function useMode() {
|
|
136
136
|
return useEditorState((s) => s.mode);
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
140
|
+
*
|
|
141
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
142
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
143
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
144
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
145
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
146
|
+
*
|
|
147
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
148
|
+
* selection, and for any tag that's neither path nor text.
|
|
149
|
+
*/
|
|
150
|
+
function useContentEditKind() {
|
|
151
|
+
const editor = useSvgEditor();
|
|
152
|
+
const [mode, id] = useEditorState((s) => `${s.mode}::${s.selection[0] ?? ""}`, (a, b) => a === b).split("::");
|
|
153
|
+
if (mode !== "edit-content" || !id) return null;
|
|
154
|
+
const tag = editor.tree().nodes.get(id)?.tag;
|
|
155
|
+
if (tag === "path") return "path";
|
|
156
|
+
if (tag === "text" || tag === "tspan") return "text";
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
138
159
|
/** Whether the history stack has an undoable entry. */
|
|
139
160
|
function useCanUndo() {
|
|
140
161
|
return useEditorState((s) => s.can_undo);
|
|
@@ -215,4 +236,4 @@ function useHoverOverride() {
|
|
|
215
236
|
}, [editor]);
|
|
216
237
|
}
|
|
217
238
|
//#endregion
|
|
218
|
-
export { SvgEditorCanvas, SvgEditorProvider, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
|
239
|
+
export { SvgEditorCanvas, SvgEditorProvider, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grida/svg-editor",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.14",
|
|
4
4
|
"description": "Headless SVG editor (experimental).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Grida",
|
|
@@ -38,17 +38,18 @@
|
|
|
38
38
|
"tag": "alpha"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@grida/cmath": "0.2.
|
|
42
|
-
"@grida/history": "0.1.
|
|
43
|
-
"@grida/
|
|
44
|
-
"@grida/keybinding": "0.2.
|
|
45
|
-
"@grida/
|
|
46
|
-
"@grida/
|
|
41
|
+
"@grida/cmath": "0.2.3",
|
|
42
|
+
"@grida/history": "0.1.1",
|
|
43
|
+
"@grida/svg": "0.1.1",
|
|
44
|
+
"@grida/keybinding": "0.2.1",
|
|
45
|
+
"@grida/text-editor": "0.1.2",
|
|
46
|
+
"@grida/hud": "0.2.1",
|
|
47
|
+
"@grida/vn": "0.1.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/react": "^19",
|
|
50
51
|
"react": "^19",
|
|
51
|
-
"tsdown": "^0.
|
|
52
|
+
"tsdown": "^0.22.1",
|
|
52
53
|
"typescript": "^6",
|
|
53
54
|
"vitest": "^4"
|
|
54
55
|
},
|
package/dist/dom-DCX-a8Kr.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { c as SvgEditor, p as Gestures, s as SurfaceHandle, y as Camera } from "./editor-Bd4-VCEJ.js";
|
|
2
|
-
import cmath from "@grida/cmath";
|
|
3
|
-
//#region src/core/snap/options.d.ts
|
|
4
|
-
type SnapOptions = {
|
|
5
|
-
/** When false, snap behavior and snap-guide rendering are both off. */enabled: boolean;
|
|
6
|
-
/** Snap threshold in HUD canvas pixels (container CSS px in svg-editor;
|
|
7
|
-
* whatever space the consumer feeds in). Constant across zoom because
|
|
8
|
-
* the input rects are already in screen-equivalent units. */
|
|
9
|
-
threshold_px: number;
|
|
10
|
-
};
|
|
11
|
-
declare const DEFAULT_SNAP_OPTIONS: SnapOptions;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/dom.d.ts
|
|
14
|
-
type DomSurfaceOptions = {
|
|
15
|
-
/** Mount the SVG inside this container. */container: HTMLElement;
|
|
16
|
-
/**
|
|
17
|
-
* Install the default gesture set (wheel-pan/zoom, space-drag, middle-mouse,
|
|
18
|
-
* keyboard zoom). Default `true`. Pass `false` to start blank and bind à la
|
|
19
|
-
* carte via `handle.gestures.bind(...)`.
|
|
20
|
-
*/
|
|
21
|
-
gestures?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Auto-fit the document into the viewport on initial attach. Default
|
|
24
|
-
* `false`. Mirrors Excalidraw's `initialData.scrollToContent`.
|
|
25
|
-
* Subsequent `editor.load()` calls do NOT re-fit — call
|
|
26
|
-
* `handle.camera.fit("<root>")` yourself if you want that behavior.
|
|
27
|
-
*/
|
|
28
|
-
fit?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Initial camera transform. Default `cmath.transform.identity`. Ignored
|
|
31
|
-
* when `fit: true`.
|
|
32
|
-
*/
|
|
33
|
-
initial_camera?: cmath.Transform;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Surface handle for the DOM surface. Extends the editor's core
|
|
37
|
-
* `SurfaceHandle` with the viewport-scoped concerns: pan/zoom (`camera`)
|
|
38
|
-
* and pointer/wheel/keyboard gesture bindings (`gestures`).
|
|
39
|
-
*
|
|
40
|
-
* Camera + gestures are **surface-scoped**: detaching the surface drops
|
|
41
|
-
* both. They never appear on the headless `SvgEditor`.
|
|
42
|
-
*/
|
|
43
|
-
type DomSurfaceHandle = SurfaceHandle & {
|
|
44
|
-
camera: Camera;
|
|
45
|
-
gestures: Gestures;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Attach a DOM surface to a headless editor. Returns a `DomSurfaceHandle`
|
|
49
|
-
* whose `detach()` is the inverse — DOM cleared, listeners removed,
|
|
50
|
-
* gestures uninstalled.
|
|
51
|
-
*
|
|
52
|
-
* Usage is one-shot per container: the surface owns the container's children
|
|
53
|
-
* for its lifetime, and `detach()` restores it to empty.
|
|
54
|
-
*/
|
|
55
|
-
declare function attach_dom_surface(editor: SvgEditor, options: DomSurfaceOptions): DomSurfaceHandle;
|
|
56
|
-
//#endregion
|
|
57
|
-
export { SnapOptions as a, DEFAULT_SNAP_OPTIONS as i, DomSurfaceOptions as n, attach_dom_surface as r, DomSurfaceHandle as t };
|
package/dist/dom-DgB4f-TE.d.mts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { c as SvgEditor, p as Gestures, s as SurfaceHandle, y as Camera } from "./editor-BH03X8cX.mjs";
|
|
2
|
-
import cmath from "@grida/cmath";
|
|
3
|
-
import { guide } from "@grida/cmath/_snap";
|
|
4
|
-
|
|
5
|
-
//#region src/core/snap/options.d.ts
|
|
6
|
-
type SnapOptions = {
|
|
7
|
-
/** When false, snap behavior and snap-guide rendering are both off. */enabled: boolean;
|
|
8
|
-
/** Snap threshold in HUD canvas pixels (container CSS px in svg-editor;
|
|
9
|
-
* whatever space the consumer feeds in). Constant across zoom because
|
|
10
|
-
* the input rects are already in screen-equivalent units. */
|
|
11
|
-
threshold_px: number;
|
|
12
|
-
};
|
|
13
|
-
declare const DEFAULT_SNAP_OPTIONS: SnapOptions;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/dom.d.ts
|
|
16
|
-
type DomSurfaceOptions = {
|
|
17
|
-
/** Mount the SVG inside this container. */container: HTMLElement;
|
|
18
|
-
/**
|
|
19
|
-
* Install the default gesture set (wheel-pan/zoom, space-drag, middle-mouse,
|
|
20
|
-
* keyboard zoom). Default `true`. Pass `false` to start blank and bind à la
|
|
21
|
-
* carte via `handle.gestures.bind(...)`.
|
|
22
|
-
*/
|
|
23
|
-
gestures?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Auto-fit the document into the viewport on initial attach. Default
|
|
26
|
-
* `false`. Mirrors Excalidraw's `initialData.scrollToContent`.
|
|
27
|
-
* Subsequent `editor.load()` calls do NOT re-fit — call
|
|
28
|
-
* `handle.camera.fit("<root>")` yourself if you want that behavior.
|
|
29
|
-
*/
|
|
30
|
-
fit?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Initial camera transform. Default `cmath.transform.identity`. Ignored
|
|
33
|
-
* when `fit: true`.
|
|
34
|
-
*/
|
|
35
|
-
initial_camera?: cmath.Transform;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Surface handle for the DOM surface. Extends the editor's core
|
|
39
|
-
* `SurfaceHandle` with the viewport-scoped concerns: pan/zoom (`camera`)
|
|
40
|
-
* and pointer/wheel/keyboard gesture bindings (`gestures`).
|
|
41
|
-
*
|
|
42
|
-
* Camera + gestures are **surface-scoped**: detaching the surface drops
|
|
43
|
-
* both. They never appear on the headless `SvgEditor`.
|
|
44
|
-
*/
|
|
45
|
-
type DomSurfaceHandle = SurfaceHandle & {
|
|
46
|
-
camera: Camera;
|
|
47
|
-
gestures: Gestures;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Attach a DOM surface to a headless editor. Returns a `DomSurfaceHandle`
|
|
51
|
-
* whose `detach()` is the inverse — DOM cleared, listeners removed,
|
|
52
|
-
* gestures uninstalled.
|
|
53
|
-
*
|
|
54
|
-
* Usage is one-shot per container: the surface owns the container's children
|
|
55
|
-
* for its lifetime, and `detach()` restores it to empty.
|
|
56
|
-
*/
|
|
57
|
-
declare function attach_dom_surface(editor: SvgEditor, options: DomSurfaceOptions): DomSurfaceHandle;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { SnapOptions as a, DEFAULT_SNAP_OPTIONS as i, DomSurfaceOptions as n, attach_dom_surface as r, DomSurfaceHandle as t };
|