@grida/svg-editor 1.0.0-alpha.4 → 1.0.0
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 +365 -384
- package/dist/dom-BEjG2bSw.d.mts +320 -0
- package/dist/dom-DYD1BHTo.js +6050 -0
- package/dist/dom-Y2QR7QSi.d.ts +318 -0
- package/dist/dom-tM3Dr1EK.mjs +5971 -0
- package/dist/dom.d.mts +3 -2
- package/dist/dom.d.ts +3 -2
- package/dist/dom.js +13 -1
- package/dist/dom.mjs +2 -2
- package/dist/editor-CWNtt1vu.mjs +2998 -0
- package/dist/editor-CZgwg8BK.d.mts +2537 -0
- package/dist/editor-CesShk9o.js +3004 -0
- package/dist/editor-kFTYSb_8.d.ts +2537 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -2
- package/dist/index.mjs +3 -2
- package/dist/model-D0iEDcg3.mjs +5451 -0
- package/dist/model-tywvTGZv.js +5640 -0
- package/dist/presets.d.mts +17 -2
- package/dist/presets.d.ts +17 -2
- package/dist/presets.js +20 -15
- package/dist/presets.mjs +19 -15
- package/dist/react.d.mts +88 -10
- package/dist/react.d.ts +88 -10
- package/dist/react.js +169 -14
- package/dist/react.mjs +159 -16
- package/package.json +35 -9
- package/dist/dom-CmOu0HvI.mjs +0 -1623
- package/dist/dom-Cn-RtjRL.d.ts +0 -48
- package/dist/dom-CoVZzFqy.js +0 -1672
- package/dist/dom-DJnZhtOd.d.mts +0 -48
- package/dist/editor-CjK56cgb.mjs +0 -1823
- package/dist/editor-D2l_CDr0.d.ts +0 -818
- package/dist/editor-D2zZAyny.js +0 -1835
- package/dist/editor-Uu6dZX4y.d.mts +0 -818
- package/dist/index-CHiXYO9-.d.ts +0 -1
- package/dist/index-ThDLM4Am.d.mts +0 -1
- package/dist/paint-Cfiw4g_J.mjs +0 -477
- package/dist/paint-dDV-Trt9.js +0 -531
- /package/dist/{chunk-CfYAbeIz.mjs → chunk-D7D4PA-g.mjs} +0 -0
package/dist/presets.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { c as SvgEditor } from "./editor-CZgwg8BK.mjs";
|
|
2
|
+
import { n as DomSurfaceHandle, r as DomSurfaceOptions } from "./dom-BEjG2bSw.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/presets/keynote.d.ts
|
|
3
5
|
declare namespace keynote_d_exports {
|
|
4
6
|
export { KeynoteAttachOptions, KeynoteSurfaceHandle, attach };
|
|
5
7
|
}
|
|
@@ -10,6 +12,13 @@ type KeynoteAttachOptions = {
|
|
|
10
12
|
* Used for both initial fit and the cover-constraint clamp. Default 80.
|
|
11
13
|
*/
|
|
12
14
|
padding?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Screen-pixel scroll slack past the slide edge when zoomed in past fit.
|
|
17
|
+
* Forwarded to the cover constraint's `pan_overshoot`. Default 0 — strict
|
|
18
|
+
* cover behavior (no panning past the slide edge). Applies only when an
|
|
19
|
+
* axis is scrollable; a fitted axis stays locked at center.
|
|
20
|
+
*/
|
|
21
|
+
pan_overshoot?: number;
|
|
13
22
|
/**
|
|
14
23
|
* Forward additional surface options (e.g. `gestures: false`). `container`,
|
|
15
24
|
* `fit`, and `initial_camera` are owned by the preset.
|
|
@@ -27,6 +36,12 @@ type KeynoteSurfaceHandle = DomSurfaceHandle & {
|
|
|
27
36
|
* the captured padding used by load-triggered refits.
|
|
28
37
|
*/
|
|
29
38
|
set_padding(p: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Update the scroll-past slack at runtime. Mutates the live constraint;
|
|
41
|
+
* `reenforce()` pulls a previously over-panned transform back into the
|
|
42
|
+
* new range when the value is decreased.
|
|
43
|
+
*/
|
|
44
|
+
set_pan_overshoot(o: number): void;
|
|
30
45
|
};
|
|
31
46
|
/**
|
|
32
47
|
* Attach a keynote-shaped DOM surface:
|
package/dist/presets.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { c as SvgEditor } from "./editor-kFTYSb_8.js";
|
|
2
|
+
import { n as DomSurfaceHandle, r as DomSurfaceOptions } from "./dom-Y2QR7QSi.js";
|
|
3
|
+
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
3
5
|
declare namespace keynote_d_exports {
|
|
4
6
|
export { KeynoteAttachOptions, KeynoteSurfaceHandle, attach };
|
|
5
7
|
}
|
|
@@ -10,6 +12,13 @@ type KeynoteAttachOptions = {
|
|
|
10
12
|
* Used for both initial fit and the cover-constraint clamp. Default 80.
|
|
11
13
|
*/
|
|
12
14
|
padding?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Screen-pixel scroll slack past the slide edge when zoomed in past fit.
|
|
17
|
+
* Forwarded to the cover constraint's `pan_overshoot`. Default 0 — strict
|
|
18
|
+
* cover behavior (no panning past the slide edge). Applies only when an
|
|
19
|
+
* axis is scrollable; a fitted axis stays locked at center.
|
|
20
|
+
*/
|
|
21
|
+
pan_overshoot?: number;
|
|
13
22
|
/**
|
|
14
23
|
* Forward additional surface options (e.g. `gestures: false`). `container`,
|
|
15
24
|
* `fit`, and `initial_camera` are owned by the preset.
|
|
@@ -27,6 +36,12 @@ type KeynoteSurfaceHandle = DomSurfaceHandle & {
|
|
|
27
36
|
* the captured padding used by load-triggered refits.
|
|
28
37
|
*/
|
|
29
38
|
set_padding(p: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Update the scroll-past slack at runtime. Mutates the live constraint;
|
|
41
|
+
* `reenforce()` pulls a previously over-panned transform back into the
|
|
42
|
+
* new range when the value is decreased.
|
|
43
|
+
*/
|
|
44
|
+
set_pan_overshoot(o: number): void;
|
|
30
45
|
};
|
|
31
46
|
/**
|
|
32
47
|
* Attach a keynote-shaped DOM surface:
|
package/dist/presets.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_model = require("./model-tywvTGZv.js");
|
|
3
|
+
const require_dom = require("./dom-DYD1BHTo.js");
|
|
3
4
|
//#region src/presets/keynote.ts
|
|
4
|
-
var keynote_exports = /* @__PURE__ */
|
|
5
|
+
var keynote_exports = /* @__PURE__ */ require_model.__exportAll({ attach: () => attach });
|
|
5
6
|
/**
|
|
6
7
|
* Attach a keynote-shaped DOM surface:
|
|
7
8
|
* - Mounts via `attach_dom_surface` with `fit: true` (slide is visible on
|
|
@@ -16,30 +17,34 @@ var keynote_exports = /* @__PURE__ */ require_dom.__exportAll({ attach: () => at
|
|
|
16
17
|
* additionally tears down the load subscription.
|
|
17
18
|
*/
|
|
18
19
|
function attach(editor, opts) {
|
|
19
|
-
let padding = opts.padding ?? 80;
|
|
20
20
|
const inner = require_dom.attach_dom_surface(editor, {
|
|
21
21
|
...opts.surface,
|
|
22
22
|
container: opts.container,
|
|
23
23
|
fit: true
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
let padding = opts.padding ?? 80;
|
|
26
|
+
let pan_overshoot = opts.pan_overshoot ?? 0;
|
|
27
|
+
const apply = () => {
|
|
28
|
+
inner.camera.constraints = {
|
|
29
|
+
type: "cover",
|
|
30
|
+
bounds: "<root>",
|
|
31
|
+
padding,
|
|
32
|
+
pan_overshoot
|
|
33
|
+
};
|
|
29
34
|
};
|
|
30
|
-
|
|
35
|
+
apply();
|
|
36
|
+
const unsub_load = editor.subscribe_with_selector((s) => s.load_version, () => inner.camera.fit("<root>", { margin: inner.camera.constraints?.padding ?? 0 }));
|
|
31
37
|
return {
|
|
32
|
-
|
|
33
|
-
gestures: inner.gestures,
|
|
38
|
+
...inner,
|
|
34
39
|
set_padding(p) {
|
|
35
40
|
padding = p;
|
|
36
|
-
|
|
37
|
-
type: "cover",
|
|
38
|
-
bounds: "<root>",
|
|
39
|
-
padding: p
|
|
40
|
-
};
|
|
41
|
+
apply();
|
|
41
42
|
inner.camera.fit("<root>", { margin: p });
|
|
42
43
|
},
|
|
44
|
+
set_pan_overshoot(o) {
|
|
45
|
+
pan_overshoot = o;
|
|
46
|
+
apply();
|
|
47
|
+
},
|
|
43
48
|
detach: () => {
|
|
44
49
|
unsub_load();
|
|
45
50
|
inner.detach();
|
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-tM3Dr1EK.mjs";
|
|
3
3
|
//#region src/presets/keynote.ts
|
|
4
4
|
var keynote_exports = /* @__PURE__ */ __exportAll({ attach: () => attach });
|
|
5
5
|
/**
|
|
@@ -16,30 +16,34 @@ var keynote_exports = /* @__PURE__ */ __exportAll({ attach: () => attach });
|
|
|
16
16
|
* additionally tears down the load subscription.
|
|
17
17
|
*/
|
|
18
18
|
function attach(editor, opts) {
|
|
19
|
-
let padding = opts.padding ?? 80;
|
|
20
19
|
const inner = attach_dom_surface(editor, {
|
|
21
20
|
...opts.surface,
|
|
22
21
|
container: opts.container,
|
|
23
22
|
fit: true
|
|
24
23
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
let padding = opts.padding ?? 80;
|
|
25
|
+
let pan_overshoot = opts.pan_overshoot ?? 0;
|
|
26
|
+
const apply = () => {
|
|
27
|
+
inner.camera.constraints = {
|
|
28
|
+
type: "cover",
|
|
29
|
+
bounds: "<root>",
|
|
30
|
+
padding,
|
|
31
|
+
pan_overshoot
|
|
32
|
+
};
|
|
29
33
|
};
|
|
30
|
-
|
|
34
|
+
apply();
|
|
35
|
+
const unsub_load = editor.subscribe_with_selector((s) => s.load_version, () => inner.camera.fit("<root>", { margin: inner.camera.constraints?.padding ?? 0 }));
|
|
31
36
|
return {
|
|
32
|
-
|
|
33
|
-
gestures: inner.gestures,
|
|
37
|
+
...inner,
|
|
34
38
|
set_padding(p) {
|
|
35
39
|
padding = p;
|
|
36
|
-
|
|
37
|
-
type: "cover",
|
|
38
|
-
bounds: "<root>",
|
|
39
|
-
padding: p
|
|
40
|
-
};
|
|
40
|
+
apply();
|
|
41
41
|
inner.camera.fit("<root>", { margin: p });
|
|
42
42
|
},
|
|
43
|
+
set_pan_overshoot(o) {
|
|
44
|
+
pan_overshoot = o;
|
|
45
|
+
apply();
|
|
46
|
+
},
|
|
43
47
|
detach: () => {
|
|
44
48
|
unsub_load();
|
|
45
49
|
inner.detach();
|
package/dist/react.d.mts
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as EditorState, H as Mode, J as PickEvent, K as PaintPreviewSession, Q as Providers, U as NodeId, Y as PreviewSession, c as SvgEditor, j as EditorStyle, rt as Tool, t as Commands } from "./editor-CZgwg8BK.mjs";
|
|
2
|
+
import { n as DomSurfaceHandle } from "./dom-BEjG2bSw.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 = {
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Initial document for the editor. Read **once** on first render —
|
|
10
|
+
* subsequent changes to this prop are silently ignored. For live updates
|
|
11
|
+
* (file open, page switch, reset to a snapshot), pull the editor from
|
|
12
|
+
* context with `useSvgEditor()` and call `editor.load(...)` imperatively.
|
|
13
|
+
*
|
|
14
|
+
* This is the same shape Lexical (`initialConfig.editorState`), Slate
|
|
15
|
+
* (`initialValue`), and TipTap (`content` option) settled on for the
|
|
16
|
+
* same reason: a reactive document prop creates a feedback loop with the
|
|
17
|
+
* editor's own emissions. The editor instance is the source of truth
|
|
18
|
+
* for the document during a session; React state is not.
|
|
19
|
+
*/
|
|
20
|
+
initialSvg: string;
|
|
10
21
|
providers?: Providers;
|
|
11
22
|
style?: Partial<EditorStyle>;
|
|
12
23
|
children: ReactNode;
|
|
13
24
|
};
|
|
14
25
|
/**
|
|
15
26
|
* Owns the headless editor and exposes it via context. The editor is created
|
|
16
|
-
* once on first render
|
|
27
|
+
* once on first render with `initialSvg`; subsequent changes to that prop are
|
|
28
|
+
* silently ignored. To replace the document at runtime, call
|
|
29
|
+
* `useSvgEditor().load(...)` imperatively, or remount the provider with a
|
|
30
|
+
* different `key`.
|
|
17
31
|
*/
|
|
18
32
|
declare function SvgEditorProvider({
|
|
19
|
-
|
|
33
|
+
initialSvg,
|
|
20
34
|
providers,
|
|
21
35
|
style,
|
|
22
36
|
children
|
|
23
|
-
}: SvgEditorProviderProps):
|
|
37
|
+
}: SvgEditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
24
38
|
type SvgEditorCanvasProps = {
|
|
25
39
|
className?: string;
|
|
26
40
|
style?: React.CSSProperties;
|
|
@@ -33,7 +47,13 @@ type SvgEditorCanvasProps = {
|
|
|
33
47
|
* Auto-fit the document on initial attach. Default `false`. See
|
|
34
48
|
* `DomSurfaceOptions.fit`.
|
|
35
49
|
*/
|
|
36
|
-
fit?: boolean;
|
|
50
|
+
fit?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Wire native ClipboardEvent transport (copy/cut/paste). Default `true`.
|
|
53
|
+
* Pass `false` to route all clipboard traffic through the
|
|
54
|
+
* `ClipboardProvider` seam. See `DomSurfaceOptions.clipboard`.
|
|
55
|
+
*/
|
|
56
|
+
clipboard?: boolean; /** Initial camera transform. Default identity. */
|
|
37
57
|
initial_camera?: cmath.Transform;
|
|
38
58
|
/**
|
|
39
59
|
* Receives the `DomSurfaceHandle` once the surface is attached, and
|
|
@@ -56,9 +76,10 @@ declare function SvgEditorCanvas({
|
|
|
56
76
|
style,
|
|
57
77
|
gestures,
|
|
58
78
|
fit,
|
|
79
|
+
clipboard,
|
|
59
80
|
initial_camera,
|
|
60
81
|
onAttach
|
|
61
|
-
}: SvgEditorCanvasProps):
|
|
82
|
+
}: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
62
83
|
declare function useSvgEditor(): SvgEditor;
|
|
63
84
|
/**
|
|
64
85
|
* Subscribe to a slice of `editor.state`. Re-renders when the selected slice
|
|
@@ -88,5 +109,62 @@ declare function useCommands(): Commands;
|
|
|
88
109
|
* mismatch with the first client render.
|
|
89
110
|
*/
|
|
90
111
|
declare function useCameraSnapshot<T>(handle: DomSurfaceHandle | null, selector: (camera: DomSurfaceHandle["camera"]) => T, fallback: T): T;
|
|
112
|
+
/** Current selection (frozen, identity-stable across no-op emits). */
|
|
113
|
+
declare function useSelection(): readonly NodeId[];
|
|
114
|
+
/** Active tool. Identity-stable when `set_tool` is a no-op. */
|
|
115
|
+
declare function useTool(): Tool;
|
|
116
|
+
/** Current mode (`"select"` | `"edit-content"`). */
|
|
117
|
+
declare function useMode(): Mode;
|
|
118
|
+
/**
|
|
119
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
120
|
+
*
|
|
121
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
122
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
123
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
124
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
125
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
126
|
+
*
|
|
127
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
128
|
+
* selection, and for any tag that's neither path nor text.
|
|
129
|
+
*/
|
|
130
|
+
declare function useContentEditKind(): "path" | "text" | null;
|
|
131
|
+
/** Whether the history stack has an undoable entry. */
|
|
132
|
+
declare function useCanUndo(): boolean;
|
|
133
|
+
/** Whether the history stack has a redoable entry. */
|
|
134
|
+
declare function useCanRedo(): boolean;
|
|
135
|
+
/** Hook-owned `PaintPreviewSession`. See block comment above. */
|
|
136
|
+
declare function usePaintPreview(channel: "fill" | "stroke"): PaintPreviewSession;
|
|
137
|
+
/** Hook-owned `PreviewSession` for a CSS/SVG property. See block comment above. */
|
|
138
|
+
declare function usePropertyPreview(name: string): PreviewSession;
|
|
139
|
+
/** Bound `editor.load(svg)`. Stable across renders. */
|
|
140
|
+
declare function useEditorLoad(): (svg: string) => void;
|
|
141
|
+
/** Bound `editor.serialize()`. Stable across renders. */
|
|
142
|
+
declare function useEditorSerialize(): () => string;
|
|
143
|
+
/**
|
|
144
|
+
* Push a hover override into the HUD surface — e.g. when the user hovers
|
|
145
|
+
* a row in a layers panel. The HUD will render the override's outline.
|
|
146
|
+
*
|
|
147
|
+
* Pass `null` to clear and let the pointer pick take over again. On
|
|
148
|
+
* unmount, the hook clears any override it set last so the canvas
|
|
149
|
+
* doesn't stay highlighted on a node that no longer has a panel row.
|
|
150
|
+
*/
|
|
151
|
+
declare function useHoverOverride(): (id: NodeId | null) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
|
|
154
|
+
* document-space `point`, the `node_id` under it (`null` for empty canvas),
|
|
155
|
+
* the `button`, and `mods`. The handler fires once per tap, after the editor's
|
|
156
|
+
* own selection handling. Observe-only: it cannot prevent or alter selection.
|
|
157
|
+
*
|
|
158
|
+
* This is the React edge-wire over `editor.subscribe_pick`. The handler is
|
|
159
|
+
* kept in a ref so re-subscription is never triggered by handler identity —
|
|
160
|
+
* pass an inline closure freely. Pick is editor-scoped (it survives surface
|
|
161
|
+
* detach), so this is a hook, not a `SvgEditorCanvas` prop.
|
|
162
|
+
*
|
|
163
|
+
* Typical use: a comment / annotation tool anchors a popover at `e.point` and
|
|
164
|
+
* scopes its action to `e.node_id` (or to the whole document when `null`).
|
|
165
|
+
*
|
|
166
|
+
* @unstable See {@link PickEvent}.
|
|
167
|
+
*/
|
|
168
|
+
declare function useEditorPick(handler: (e: PickEvent) => void): void;
|
|
91
169
|
//#endregion
|
|
92
|
-
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCommands, useEditorState, useSvgEditor };
|
|
170
|
+
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorPick, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as EditorState, H as Mode, J as PickEvent, K as PaintPreviewSession, Q as Providers, U as NodeId, Y as PreviewSession, c as SvgEditor, j as EditorStyle, rt as Tool, t as Commands } from "./editor-kFTYSb_8.js";
|
|
2
|
+
import { n as DomSurfaceHandle } from "./dom-Y2QR7QSi.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
|
|
8
7
|
type SvgEditorProviderProps = {
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Initial document for the editor. Read **once** on first render —
|
|
10
|
+
* subsequent changes to this prop are silently ignored. For live updates
|
|
11
|
+
* (file open, page switch, reset to a snapshot), pull the editor from
|
|
12
|
+
* context with `useSvgEditor()` and call `editor.load(...)` imperatively.
|
|
13
|
+
*
|
|
14
|
+
* This is the same shape Lexical (`initialConfig.editorState`), Slate
|
|
15
|
+
* (`initialValue`), and TipTap (`content` option) settled on for the
|
|
16
|
+
* same reason: a reactive document prop creates a feedback loop with the
|
|
17
|
+
* editor's own emissions. The editor instance is the source of truth
|
|
18
|
+
* for the document during a session; React state is not.
|
|
19
|
+
*/
|
|
20
|
+
initialSvg: string;
|
|
10
21
|
providers?: Providers;
|
|
11
22
|
style?: Partial<EditorStyle>;
|
|
12
23
|
children: ReactNode;
|
|
13
24
|
};
|
|
14
25
|
/**
|
|
15
26
|
* Owns the headless editor and exposes it via context. The editor is created
|
|
16
|
-
* once on first render
|
|
27
|
+
* once on first render with `initialSvg`; subsequent changes to that prop are
|
|
28
|
+
* silently ignored. To replace the document at runtime, call
|
|
29
|
+
* `useSvgEditor().load(...)` imperatively, or remount the provider with a
|
|
30
|
+
* different `key`.
|
|
17
31
|
*/
|
|
18
32
|
declare function SvgEditorProvider({
|
|
19
|
-
|
|
33
|
+
initialSvg,
|
|
20
34
|
providers,
|
|
21
35
|
style,
|
|
22
36
|
children
|
|
23
|
-
}: SvgEditorProviderProps):
|
|
37
|
+
}: SvgEditorProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
24
38
|
type SvgEditorCanvasProps = {
|
|
25
39
|
className?: string;
|
|
26
40
|
style?: React.CSSProperties;
|
|
@@ -33,7 +47,13 @@ type SvgEditorCanvasProps = {
|
|
|
33
47
|
* Auto-fit the document on initial attach. Default `false`. See
|
|
34
48
|
* `DomSurfaceOptions.fit`.
|
|
35
49
|
*/
|
|
36
|
-
fit?: boolean;
|
|
50
|
+
fit?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Wire native ClipboardEvent transport (copy/cut/paste). Default `true`.
|
|
53
|
+
* Pass `false` to route all clipboard traffic through the
|
|
54
|
+
* `ClipboardProvider` seam. See `DomSurfaceOptions.clipboard`.
|
|
55
|
+
*/
|
|
56
|
+
clipboard?: boolean; /** Initial camera transform. Default identity. */
|
|
37
57
|
initial_camera?: cmath.Transform;
|
|
38
58
|
/**
|
|
39
59
|
* Receives the `DomSurfaceHandle` once the surface is attached, and
|
|
@@ -56,9 +76,10 @@ declare function SvgEditorCanvas({
|
|
|
56
76
|
style,
|
|
57
77
|
gestures,
|
|
58
78
|
fit,
|
|
79
|
+
clipboard,
|
|
59
80
|
initial_camera,
|
|
60
81
|
onAttach
|
|
61
|
-
}: SvgEditorCanvasProps):
|
|
82
|
+
}: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
62
83
|
declare function useSvgEditor(): SvgEditor;
|
|
63
84
|
/**
|
|
64
85
|
* Subscribe to a slice of `editor.state`. Re-renders when the selected slice
|
|
@@ -88,5 +109,62 @@ declare function useCommands(): Commands;
|
|
|
88
109
|
* mismatch with the first client render.
|
|
89
110
|
*/
|
|
90
111
|
declare function useCameraSnapshot<T>(handle: DomSurfaceHandle | null, selector: (camera: DomSurfaceHandle["camera"]) => T, fallback: T): T;
|
|
112
|
+
/** Current selection (frozen, identity-stable across no-op emits). */
|
|
113
|
+
declare function useSelection(): readonly NodeId[];
|
|
114
|
+
/** Active tool. Identity-stable when `set_tool` is a no-op. */
|
|
115
|
+
declare function useTool(): Tool;
|
|
116
|
+
/** Current mode (`"select"` | `"edit-content"`). */
|
|
117
|
+
declare function useMode(): Mode;
|
|
118
|
+
/**
|
|
119
|
+
* What kind of content-edit is active, or `null` when not in content-edit.
|
|
120
|
+
*
|
|
121
|
+
* Symmetric with `useMode()` but at a finer grain — resolves whether the
|
|
122
|
+
* single selected node is a path or a text node so consumers (e.g. the
|
|
123
|
+
* vector-edit toolbar) can render the right affordances. Mirrors the
|
|
124
|
+
* dispatch logic in the host's `enter_content_edit` router which checks
|
|
125
|
+
* `tag_of(id) === "path"` vs `"text" / "tspan"`.
|
|
126
|
+
*
|
|
127
|
+
* Returns `null` for the (defensive) case of `edit-content` with no
|
|
128
|
+
* selection, and for any tag that's neither path nor text.
|
|
129
|
+
*/
|
|
130
|
+
declare function useContentEditKind(): "path" | "text" | null;
|
|
131
|
+
/** Whether the history stack has an undoable entry. */
|
|
132
|
+
declare function useCanUndo(): boolean;
|
|
133
|
+
/** Whether the history stack has a redoable entry. */
|
|
134
|
+
declare function useCanRedo(): boolean;
|
|
135
|
+
/** Hook-owned `PaintPreviewSession`. See block comment above. */
|
|
136
|
+
declare function usePaintPreview(channel: "fill" | "stroke"): PaintPreviewSession;
|
|
137
|
+
/** Hook-owned `PreviewSession` for a CSS/SVG property. See block comment above. */
|
|
138
|
+
declare function usePropertyPreview(name: string): PreviewSession;
|
|
139
|
+
/** Bound `editor.load(svg)`. Stable across renders. */
|
|
140
|
+
declare function useEditorLoad(): (svg: string) => void;
|
|
141
|
+
/** Bound `editor.serialize()`. Stable across renders. */
|
|
142
|
+
declare function useEditorSerialize(): () => string;
|
|
143
|
+
/**
|
|
144
|
+
* Push a hover override into the HUD surface — e.g. when the user hovers
|
|
145
|
+
* a row in a layers panel. The HUD will render the override's outline.
|
|
146
|
+
*
|
|
147
|
+
* Pass `null` to clear and let the pointer pick take over again. On
|
|
148
|
+
* unmount, the hook clears any override it set last so the canvas
|
|
149
|
+
* doesn't stay highlighted on a node that no longer has a panel row.
|
|
150
|
+
*/
|
|
151
|
+
declare function useHoverOverride(): (id: NodeId | null) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
|
|
154
|
+
* document-space `point`, the `node_id` under it (`null` for empty canvas),
|
|
155
|
+
* the `button`, and `mods`. The handler fires once per tap, after the editor's
|
|
156
|
+
* own selection handling. Observe-only: it cannot prevent or alter selection.
|
|
157
|
+
*
|
|
158
|
+
* This is the React edge-wire over `editor.subscribe_pick`. The handler is
|
|
159
|
+
* kept in a ref so re-subscription is never triggered by handler identity —
|
|
160
|
+
* pass an inline closure freely. Pick is editor-scoped (it survives surface
|
|
161
|
+
* detach), so this is a hook, not a `SvgEditorCanvas` prop.
|
|
162
|
+
*
|
|
163
|
+
* Typical use: a comment / annotation tool anchors a popover at `e.point` and
|
|
164
|
+
* scopes its action to `e.node_id` (or to the whole document when `null`).
|
|
165
|
+
*
|
|
166
|
+
* @unstable See {@link PickEvent}.
|
|
167
|
+
*/
|
|
168
|
+
declare function useEditorPick(handler: (e: PickEvent) => void): void;
|
|
91
169
|
//#endregion
|
|
92
|
-
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCommands, useEditorState, useSvgEditor };
|
|
170
|
+
export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorPick, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
|