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

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 CHANGED
@@ -249,9 +249,32 @@ editor.dispose(): void; // permanent teardown
249
249
  ```ts
250
250
  editor.load(svg: string): void; // replace the document (e.g. file-on-disk changed)
251
251
  editor.serialize(): string; // emit clean SVG — guaranteed round-trip per P1
252
+ editor.serialize_node(id: NodeId): string; // emit ONE element's subtree — a fragment, see below
252
253
  editor.reset(): void; // back to last load() input, clears history
253
254
  ```
254
255
 
256
+ `serialize_node(id)` exports the markup of a single element — the bridge from
257
+ "what the user selected" (a `NodeId`) to "the SVG for that element," e.g. to
258
+ hand a downstream consumer (an AI agent) the selected subtree without
259
+ re-serializing the whole document. It reuses `serialize()`'s trivia-preserving
260
+ rules (attribute order, quotes, whitespace, comments — emitted as authored).
261
+
262
+ It is deliberately **weaker** than `serialize()`, and the two must not be
263
+ conflated: `serialize()` emits the whole document and carries the P1
264
+ round-trip guarantee; `serialize_node()` emits a **fragment** and does not.
265
+ Namespace declarations that live on an ancestor (`xmlns:xlink` and friends,
266
+ normally on the root `<svg>`) are **not** inlined into the fragment — a node
267
+ using `xlink:href` serializes without `xmlns:xlink`. The fragment is the
268
+ element's markup as authored, not a standalone parseable document. Throws on
269
+ an unknown id or a non-element node (selections are always elements).
270
+
271
+ > A stable reference to a node that survives a `load()` — and survives an
272
+ > external rewrite of the file — is a separate, unsolved problem (`NodeId`
273
+ > regenerates on each parse). Positional child-index paths address only the
274
+ > deterministic-re-parse case, not structural edits; durable node identity is
275
+ > under design — see
276
+ > [durable node identity](https://grida.co/docs/wg/feat-svg-editor/durable-node-identity).
277
+
255
278
  ### Observation — state
256
279
 
257
280
  ```ts
@@ -1,4 +1,4 @@
1
- import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-YQwdWHBb.mjs";
1
+ import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-Dl7c0q5A.mjs";
2
2
  import cmath from "@grida/cmath";
3
3
  import { guide } from "@grida/cmath/_snap";
4
4
 
@@ -1,4 +1,4 @@
1
- import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-CJ2KuRh5.js";
1
+ import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-BKoo9SPL.js";
2
2
  import cmath from "@grida/cmath";
3
3
  //#region src/core/snap/options.d.ts
4
4
  type SnapOptions = {