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

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-D2eQe8lB.mjs";
2
+ import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-98AUOfsP.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-CYoGJ3Hf.js";
2
+ import { n as DomSurfaceOptions, t as DomSurfaceHandle } from "./dom-BO2-E9oK.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-D0nU_EkL.js");
3
+ const require_dom = require("./dom-U6ae5fQF.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-DOvcMvl4.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-D2eQe8lB.mjs";
2
+ import { t as DomSurfaceHandle } from "./dom-98AUOfsP.mjs";
3
3
  import cmath from "@grida/cmath";
4
4
  import { ReactNode } from "react";
5
5
 
@@ -142,5 +142,22 @@ declare function useEditorSerialize(): () => string;
142
142
  * doesn't stay highlighted on a node that no longer has a panel row.
143
143
  */
144
144
  declare function useHoverOverride(): (id: NodeId | null) => void;
145
+ /**
146
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
147
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
148
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
149
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
150
+ *
151
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
152
+ * kept in a ref so re-subscription is never triggered by handler identity —
153
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
154
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
155
+ *
156
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
157
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
158
+ *
159
+ * @unstable See {@link PickEvent}.
160
+ */
161
+ declare function useEditorPick(handler: (e: PickEvent) => void): void;
145
162
  //#endregion
146
- export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
163
+ 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-CYoGJ3Hf.js";
2
+ import { t as DomSurfaceHandle } from "./dom-BO2-E9oK.js";
3
3
  import cmath from "@grida/cmath";
4
4
  import { ReactNode } from "react";
5
5
 
@@ -142,5 +142,22 @@ declare function useEditorSerialize(): () => string;
142
142
  * doesn't stay highlighted on a node that no longer has a panel row.
143
143
  */
144
144
  declare function useHoverOverride(): (id: NodeId | null) => void;
145
+ /**
146
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
147
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
148
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
149
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
150
+ *
151
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
152
+ * kept in a ref so re-subscription is never triggered by handler identity —
153
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
154
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
155
+ *
156
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
157
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
158
+ *
159
+ * @unstable See {@link PickEvent}.
160
+ */
161
+ declare function useEditorPick(handler: (e: PickEvent) => void): void;
145
162
  //#endregion
146
- export { SvgEditorCanvas, SvgEditorCanvasProps, SvgEditorProvider, SvgEditorProviderProps, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
163
+ 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-C6Lj1In-.js");
4
+ const require_dom = require("./dom-U6ae5fQF.js");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/react.tsx
@@ -236,6 +236,28 @@ function useHoverOverride() {
236
236
  editor.set_surface_hover_override(id);
237
237
  }, [editor]);
238
238
  }
239
+ /**
240
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
241
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
242
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
243
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
244
+ *
245
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
246
+ * kept in a ref so re-subscription is never triggered by handler identity —
247
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
248
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
249
+ *
250
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
251
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
252
+ *
253
+ * @unstable See {@link PickEvent}.
254
+ */
255
+ function useEditorPick(handler) {
256
+ const editor = useSvgEditor();
257
+ const handler_ref = (0, react.useRef)(handler);
258
+ handler_ref.current = handler;
259
+ (0, react.useEffect)(() => editor.subscribe_pick((e) => handler_ref.current(e)), [editor]);
260
+ }
239
261
  //#endregion
240
262
  exports.SvgEditorCanvas = SvgEditorCanvas;
241
263
  exports.SvgEditorProvider = SvgEditorProvider;
@@ -245,6 +267,7 @@ exports.useCanUndo = useCanUndo;
245
267
  exports.useCommands = useCommands;
246
268
  exports.useContentEditKind = useContentEditKind;
247
269
  exports.useEditorLoad = useEditorLoad;
270
+ exports.useEditorPick = useEditorPick;
248
271
  exports.useEditorSerialize = useEditorSerialize;
249
272
  exports.useEditorState = useEditorState;
250
273
  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-DKQOIKuU.mjs";
3
+ import { t as attach_dom_surface } from "./dom-DOvcMvl4.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
@@ -235,5 +235,27 @@ function useHoverOverride() {
235
235
  editor.set_surface_hover_override(id);
236
236
  }, [editor]);
237
237
  }
238
+ /**
239
+ * Observe pick (tap) outcomes — a discrete click on the canvas, reporting the
240
+ * document-space `point`, the `node_id` under it (`null` for empty canvas),
241
+ * the `button`, and `mods`. The handler fires once per tap, after the editor's
242
+ * own selection handling. Observe-only: it cannot prevent or alter selection.
243
+ *
244
+ * This is the React edge-wire over `editor.subscribe_pick`. The handler is
245
+ * kept in a ref so re-subscription is never triggered by handler identity —
246
+ * pass an inline closure freely. Pick is editor-scoped (it survives surface
247
+ * detach), so this is a hook, not a `SvgEditorCanvas` prop.
248
+ *
249
+ * Typical use: a comment / annotation tool anchors a popover at `e.point` and
250
+ * scopes its action to `e.node_id` (or to the whole document when `null`).
251
+ *
252
+ * @unstable See {@link PickEvent}.
253
+ */
254
+ function useEditorPick(handler) {
255
+ const editor = useSvgEditor();
256
+ const handler_ref = useRef(handler);
257
+ handler_ref.current = handler;
258
+ useEffect(() => editor.subscribe_pick((e) => handler_ref.current(e)), [editor]);
259
+ }
238
260
  //#endregion
239
- export { SvgEditorCanvas, SvgEditorProvider, useCameraSnapshot, useCanRedo, useCanUndo, useCommands, useContentEditKind, useEditorLoad, useEditorSerialize, useEditorState, useHoverOverride, useMode, usePaintPreview, usePropertyPreview, useSelection, useSvgEditor, useTool };
261
+ 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.16",
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/history": "0.1.1",
59
63
  "@grida/keybinding": "0.2.1",
60
64
  "@grida/svg": "0.1.1",
61
- "@grida/history": "0.1.1",
62
- "@grida/hud": "0.2.1",
63
65
  "@grida/text-editor": "0.1.2",
64
- "@grida/vn": "0.1.0"
66
+ "@grida/vn": "0.1.0",
67
+ "@grida/hud": "0.2.1"
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/react": "^19",