@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 +23 -0
- package/dist/{dom-Dz_V6q0Y.d.mts → dom-CK6GlgFF.d.mts} +1 -1
- package/dist/{dom-D4dy6kq5.d.ts → dom-CsKXTaNw.d.ts} +1 -1
- package/dist/{dom-DSjfCllZ.mjs → dom-DILY80j7.mjs} +229 -175
- package/dist/{dom-BuD8TKmL.js → dom-Dee6FtgZ.js} +229 -175
- package/dist/dom.d.mts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/{editor-CJ2KuRh5.d.ts → editor-BKoo9SPL.d.ts} +189 -19
- package/dist/{editor-B6pchGYk.mjs → editor-CvWpD5mu.mjs} +313 -13
- package/dist/{editor-YQwdWHBb.d.mts → editor-Dl7c0q5A.d.mts} +189 -19
- package/dist/{editor-BHHU_Nvz.js → editor-F8ckj9X1.js} +313 -13
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{model-DIzZmeyf.mjs → model-B2UWgViT.mjs} +69 -17
- package/dist/{model-DqGqV1H4.js → model-CJ1Ctq14.js} +69 -17
- package/dist/presets.d.mts +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/react.mjs +2 -2
- package/package.json +25 -4
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-
|
|
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-
|
|
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 = {
|