@grida/svg-editor 1.0.0-alpha.15 → 1.0.0-alpha.17

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.
@@ -1,5 +1,5 @@
1
- import { c as SvgEditor } from "./editor-Dl7c0q5A.mjs";
2
- import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-CK6GlgFF.mjs";
1
+ import { c as SvgEditor } from "./editor-KqpIW1qm.mjs";
2
+ import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-TctdgRnn.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-BKoo9SPL.js";
2
- import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-CsKXTaNw.js";
1
+ import { c as SvgEditor } from "./editor-BSxTUsW_.js";
2
+ import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-BMzX1CXZ.js";
3
3
 
4
4
  //#region \0rolldown/runtime.js
5
5
  declare namespace keynote_d_exports {
package/dist/presets.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model = require("./model-CJ1Ctq14.js");
3
- const require_dom = require("./dom-Dee6FtgZ.js");
2
+ const require_model = require("./model-GpysNbOv.js");
3
+ const require_dom = require("./dom-CaByuo6C.js");
4
4
  //#region src/presets/keynote.ts
5
5
  var keynote_exports = /* @__PURE__ */ require_model.__exportAll({ attach: () => attach });
6
6
  /**
package/dist/presets.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-D7D4PA-g.mjs";
2
- import { t as attach_dom_surface } from "./dom-DILY80j7.mjs";
2
+ import { t as attach_dom_surface } from "./dom-Bjj9xySE.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,5 +1,5 @@
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-Dl7c0q5A.mjs";
2
- import { t as DomSurfaceHandle } from "./dom-CK6GlgFF.mjs";
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-KqpIW1qm.mjs";
2
+ import { t as DomSurfaceHandle } from "./dom-TctdgRnn.mjs";
3
3
  import cmath from "@grida/cmath";
4
4
  import { ReactNode } from "react";
5
5
 
@@ -47,7 +47,13 @@ type SvgEditorCanvasProps = {
47
47
  * Auto-fit the document on initial attach. Default `false`. See
48
48
  * `DomSurfaceOptions.fit`.
49
49
  */
50
- fit?: boolean; /** Initial camera transform. Default identity. */
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. */
51
57
  initial_camera?: cmath.Transform;
52
58
  /**
53
59
  * Receives the `DomSurfaceHandle` once the surface is attached, and
@@ -70,6 +76,7 @@ declare function SvgEditorCanvas({
70
76
  style,
71
77
  gestures,
72
78
  fit,
79
+ clipboard,
73
80
  initial_camera,
74
81
  onAttach
75
82
  }: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
@@ -142,5 +149,22 @@ declare function useEditorSerialize(): () => string;
142
149
  * doesn't stay highlighted on a node that no longer has a panel row.
143
150
  */
144
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;
145
169
  //#endregion
146
- export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
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,5 +1,5 @@
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-BKoo9SPL.js";
2
- import { t as DomSurfaceHandle } from "./dom-CsKXTaNw.js";
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-BSxTUsW_.js";
2
+ import { t as DomSurfaceHandle } from "./dom-BMzX1CXZ.js";
3
3
  import cmath from "@grida/cmath";
4
4
  import { ReactNode } from "react";
5
5
 
@@ -47,7 +47,13 @@ type SvgEditorCanvasProps = {
47
47
  * Auto-fit the document on initial attach. Default `false`. See
48
48
  * `DomSurfaceOptions.fit`.
49
49
  */
50
- fit?: boolean; /** Initial camera transform. Default identity. */
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. */
51
57
  initial_camera?: cmath.Transform;
52
58
  /**
53
59
  * Receives the `DomSurfaceHandle` once the surface is attached, and
@@ -70,6 +76,7 @@ declare function SvgEditorCanvas({
70
76
  style,
71
77
  gestures,
72
78
  fit,
79
+ clipboard,
73
80
  initial_camera,
74
81
  onAttach
75
82
  }: SvgEditorCanvasProps): import("react/jsx-runtime").JSX.Element;
@@ -142,5 +149,22 @@ declare function useEditorSerialize(): () => string;
142
149
  * doesn't stay highlighted on a node that no longer has a panel row.
143
150
  */
144
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;
145
169
  //#endregion
146
- export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_editor = require("./editor-F8ckj9X1.js");
4
- const require_dom = require("./dom-Dee6FtgZ.js");
3
+ const require_editor = require("./editor-N9af0JD2.js");
4
+ const require_dom = require("./dom-CaByuo6C.js");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/react.tsx
@@ -40,7 +40,7 @@ function SvgEditorProvider({ initialSvg, providers, style, children }) {
40
40
  * context for them, because a host may mount multiple canvases in the
41
41
  * same editor session.
42
42
  */
43
- function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAttach }) {
43
+ function SvgEditorCanvas({ className, style, gestures, fit, clipboard, initial_camera, onAttach }) {
44
44
  const editor = useSvgEditor();
45
45
  const ref = (0, react.useRef)(null);
46
46
  const on_attach_ref = (0, react.useRef)(onAttach);
@@ -54,6 +54,7 @@ function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAt
54
54
  container,
55
55
  gestures,
56
56
  fit,
57
+ clipboard,
57
58
  initial_camera: initial_camera_ref.current
58
59
  });
59
60
  on_attach_ref.current?.(handle);
@@ -64,7 +65,8 @@ function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAt
64
65
  }, [
65
66
  editor,
66
67
  gestures,
67
- fit
68
+ fit,
69
+ clipboard
68
70
  ]);
69
71
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
70
72
  ref,
@@ -236,6 +238,28 @@ function useHoverOverride() {
236
238
  editor.set_surface_hover_override(id);
237
239
  }, [editor]);
238
240
  }
241
+ /**
242
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
243
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
244
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
245
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
246
+ *
247
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
248
+ * kept in a ref so re-subscription is never triggered by handler identity —
249
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
250
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
251
+ *
252
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
253
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
254
+ *
255
+ * @unstable See {@link PickEvent}.
256
+ */
257
+ function useEditorPick(handler) {
258
+ const editor = useSvgEditor();
259
+ const handler_ref = (0, react.useRef)(handler);
260
+ handler_ref.current = handler;
261
+ (0, react.useEffect)(() => editor.subscribe_pick((e) => handler_ref.current(e)), [editor]);
262
+ }
239
263
  //#endregion
240
264
  exports.SvgEditorCanvas = SvgEditorCanvas;
241
265
  exports.SvgEditorProvider = SvgEditorProvider;
@@ -245,6 +269,7 @@ exports.useCanUndo = useCanUndo;
245
269
  exports.useCommands = useCommands;
246
270
  exports.useContentEditKind = useContentEditKind;
247
271
  exports.useEditorLoad = useEditorLoad;
272
+ exports.useEditorPick = useEditorPick;
248
273
  exports.useEditorSerialize = useEditorSerialize;
249
274
  exports.useEditorState = useEditorState;
250
275
  exports.useHoverOverride = useHoverOverride;
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { t as createSvgEditor } from "./editor-CvWpD5mu.mjs";
3
- import { t as attach_dom_surface } from "./dom-DILY80j7.mjs";
2
+ import { t as createSvgEditor } from "./editor-BLsELHSZ.mjs";
3
+ import { t as attach_dom_surface } from "./dom-Bjj9xySE.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
@@ -39,7 +39,7 @@ function SvgEditorProvider({ initialSvg, providers, style, children }) {
39
39
  * context for them, because a host may mount multiple canvases in the
40
40
  * same editor session.
41
41
  */
42
- function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAttach }) {
42
+ function SvgEditorCanvas({ className, style, gestures, fit, clipboard, initial_camera, onAttach }) {
43
43
  const editor = useSvgEditor();
44
44
  const ref = useRef(null);
45
45
  const on_attach_ref = useRef(onAttach);
@@ -53,6 +53,7 @@ function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAt
53
53
  container,
54
54
  gestures,
55
55
  fit,
56
+ clipboard,
56
57
  initial_camera: initial_camera_ref.current
57
58
  });
58
59
  on_attach_ref.current?.(handle);
@@ -63,7 +64,8 @@ function SvgEditorCanvas({ className, style, gestures, fit, initial_camera, onAt
63
64
  }, [
64
65
  editor,
65
66
  gestures,
66
- fit
67
+ fit,
68
+ clipboard
67
69
  ]);
68
70
  return /* @__PURE__ */ jsx("div", {
69
71
  ref,
@@ -235,5 +237,27 @@ function useHoverOverride() {
235
237
  editor.set_surface_hover_override(id);
236
238
  }, [editor]);
237
239
  }
240
+ /**
241
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
242
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
243
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
244
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
245
+ *
246
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
247
+ * kept in a ref so re-subscription is never triggered by handler identity —
248
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
249
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
250
+ *
251
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
252
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
253
+ *
254
+ * @unstable See {@link PickEvent}.
255
+ */
256
+ function useEditorPick(handler) {
257
+ const editor = useSvgEditor();
258
+ const handler_ref = useRef(handler);
259
+ handler_ref.current = handler;
260
+ useEffect(() => editor.subscribe_pick((e) => handler_ref.current(e)), [editor]);
261
+ }
238
262
  //#endregion
239
- export { SvgEditorCanvas, SvgEditorProvider, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
263
+ export { SvgEditorCanvas, SvgEditorProvider, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorPick, 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.15",
3
+ "version": "1.0.0-alpha.17",
4
4
  "description": "Headless SVG editor (experimental).",
5
5
  "keywords": [
6
6
  "bezier",
@@ -21,7 +21,10 @@
21
21
  "homepage": "https://grida.co/packages/@grida/svg-editor",
22
22
  "license": "MIT",
23
23
  "author": "Grida",
24
- "repository": "https://github.com/gridaco/grida",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/gridaco/grida"
27
+ },
25
28
  "files": [
26
29
  "dist"
27
30
  ],
@@ -56,12 +59,12 @@
56
59
  },
57
60
  "dependencies": {
58
61
  "@grida/cmath": "0.2.3",
62
+ "@grida/hud": "0.2.2",
59
63
  "@grida/keybinding": "0.2.1",
60
- "@grida/svg": "0.1.1",
64
+ "@grida/svg": "0.2.0",
61
65
  "@grida/history": "0.1.1",
62
- "@grida/hud": "0.2.1",
63
- "@grida/text-editor": "0.1.2",
64
- "@grida/vn": "0.1.0"
66
+ "@grida/vn": "0.1.0",
67
+ "@grida/text-editor": "0.1.2"
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/react": "^19",