@grida/svg-editor 1.0.0-alpha.13 → 1.0.0-alpha.14
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 +88 -42
- package/dist/{dom-Cvm9Towu.js → dom-BuD8TKmL.js} +1592 -624
- package/dist/dom-D4dy6kq5.d.ts +112 -0
- package/dist/{dom-BlMk07oX.mjs → dom-DSjfCllZ.mjs} +1566 -617
- package/dist/dom-Dz_V6q0Y.d.mts +114 -0
- package/dist/dom.d.mts +3 -3
- package/dist/dom.d.ts +3 -3
- package/dist/dom.js +4 -1
- package/dist/dom.mjs +2 -2
- package/dist/{editor-DtuRIs-Q.mjs → editor-B6pchGYk.mjs} +519 -321
- package/dist/{editor-CdyC3uAe.js → editor-BHHU_Nvz.js} +527 -329
- package/dist/{editor-Bd4-VCEJ.d.ts → editor-CJ2KuRh5.d.ts} +472 -24
- package/dist/{editor-BH03X8cX.d.mts → editor-YQwdWHBb.d.mts} +472 -24
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -4
- package/dist/index.mjs +3 -3
- package/dist/model-DIzZmeyf.mjs +3677 -0
- package/dist/model-DqGqV1H4.js +3823 -0
- package/dist/presets.d.mts +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +2 -2
- package/dist/react.d.mts +18 -6
- package/dist/react.d.ts +18 -6
- package/dist/react.js +24 -3
- package/dist/react.mjs +24 -3
- package/package.json +9 -8
- package/dist/dom-DCX-a8Kr.d.ts +0 -57
- package/dist/dom-DgB4f-TE.d.mts +0 -59
- package/dist/insertions-BJ-6o6o5.js +0 -2399
- package/dist/insertions-Okcuo-Ck.mjs +0 -2176
- /package/dist/{chunk-CfYAbeIz.mjs → chunk-D7D4PA-g.mjs} +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-YQwdWHBb.mjs";
|
|
2
|
+
import cmath from "@grida/cmath";
|
|
3
|
+
import { guide } from "@grida/cmath/_snap";
|
|
4
|
+
|
|
5
|
+
//#region src/core/snap/options.d.ts
|
|
6
|
+
type SnapOptions = {
|
|
7
|
+
/** When false, snap behavior and snap-guide rendering are both off. */enabled: boolean;
|
|
8
|
+
/** Snap threshold in HUD canvas pixels (container CSS px in svg-editor;
|
|
9
|
+
* whatever space the consumer feeds in). Constant across zoom because
|
|
10
|
+
* the input rects are already in screen-equivalent units. */
|
|
11
|
+
threshold_px: number;
|
|
12
|
+
};
|
|
13
|
+
declare const DEFAULT_SNAP_OPTIONS: SnapOptions;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/dom.d.ts
|
|
16
|
+
type DomSurfaceOptions = {
|
|
17
|
+
/** Mount the SVG inside this container. */container: HTMLElement;
|
|
18
|
+
/**
|
|
19
|
+
* Install the default gesture set (wheel-pan/zoom, space-drag, middle-mouse,
|
|
20
|
+
* keyboard zoom). Default `true`. Pass `false` to start blank and bind à la
|
|
21
|
+
* carte via `handle.gestures.bind(...)`.
|
|
22
|
+
*/
|
|
23
|
+
gestures?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Auto-fit the document into the viewport on initial attach. Default
|
|
26
|
+
* `false`. Mirrors Excalidraw's `initialData.scrollToContent`.
|
|
27
|
+
* Subsequent `editor.load()` calls do NOT re-fit — call
|
|
28
|
+
* `handle.camera.fit("<root>")` yourself if you want that behavior.
|
|
29
|
+
*/
|
|
30
|
+
fit?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Initial camera transform. Default `cmath.transform.identity`. Ignored
|
|
33
|
+
* when `fit: true`.
|
|
34
|
+
*/
|
|
35
|
+
initial_camera?: cmath.Transform;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Surface handle for the DOM surface. Extends the editor's core
|
|
39
|
+
* `SurfaceHandle` with the viewport-scoped concerns: pan/zoom (`camera`)
|
|
40
|
+
* and pointer/wheel/keyboard gesture bindings (`gestures`).
|
|
41
|
+
*
|
|
42
|
+
* Camera + gestures are **surface-scoped**: detaching the surface drops
|
|
43
|
+
* both. They never appear on the headless `SvgEditor`.
|
|
44
|
+
*/
|
|
45
|
+
type DomSurfaceHandle = SurfaceHandle & {
|
|
46
|
+
camera: Camera;
|
|
47
|
+
gestures: Gestures;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Attach a DOM surface to a headless editor. Returns a `DomSurfaceHandle`
|
|
51
|
+
* whose `detach()` is the inverse — DOM cleared, listeners removed,
|
|
52
|
+
* gestures uninstalled.
|
|
53
|
+
*
|
|
54
|
+
* Usage is one-shot per container: the surface owns the container's children
|
|
55
|
+
* for its lifetime, and `detach()` restores it to empty.
|
|
56
|
+
*/
|
|
57
|
+
declare function attach_dom_surface(editor: SvgEditor, options: DomSurfaceOptions): DomSurfaceHandle;
|
|
58
|
+
/**
|
|
59
|
+
* Affine projection of a point through a 2×3 CTM, then offset by a
|
|
60
|
+
* container origin (in page CSS-px). Mirrors how `line_endpoints_in_container`
|
|
61
|
+
* and `shape_of` (transformed branch) bridge from local SVG coords to the
|
|
62
|
+
* HUD's container-CSS-px space (HUD keeps its own transform at identity;
|
|
63
|
+
* the SVG carries the camera as a CSS transform, which getScreenCTM
|
|
64
|
+
* folds in).
|
|
65
|
+
*
|
|
66
|
+
* Exported for headless test coverage — pure function, no DOM types.
|
|
67
|
+
*/
|
|
68
|
+
declare function project_point_through_ctm(px: number, py: number, ctm: {
|
|
69
|
+
a: number;
|
|
70
|
+
b: number;
|
|
71
|
+
c: number;
|
|
72
|
+
d: number;
|
|
73
|
+
e: number;
|
|
74
|
+
f: number;
|
|
75
|
+
}, container_offset: readonly [number, number]): [number, number];
|
|
76
|
+
/**
|
|
77
|
+
* Inverse of the CTM's linear part applied to a delta vector. Drops
|
|
78
|
+
* translation. Used to convert a HUD-reported container-space drag delta
|
|
79
|
+
* back to the path's local coord space for `PathModel.translateVertices`.
|
|
80
|
+
*
|
|
81
|
+
* Throws on a degenerate (det = 0) matrix — the caller is expected to
|
|
82
|
+
* have a non-singular CTM for any visible element.
|
|
83
|
+
*/
|
|
84
|
+
declare function project_delta_inverse_ctm(dx: number, dy: number, ctm: {
|
|
85
|
+
a: number;
|
|
86
|
+
b: number;
|
|
87
|
+
c: number;
|
|
88
|
+
d: number;
|
|
89
|
+
}): [number, number];
|
|
90
|
+
/**
|
|
91
|
+
* Inverse-project a doc-space rect through a CTM + container offset back
|
|
92
|
+
* into the element's local frame. The output is the AABB of the four
|
|
93
|
+
* inverse-projected corners — when the CTM has a rotation component the
|
|
94
|
+
* AABB is an approximation, but it matches what the user visually
|
|
95
|
+
* expects from a screen-aligned marquee drag.
|
|
96
|
+
*
|
|
97
|
+
* Returns `null` when the CTM's linear part is singular (degenerate
|
|
98
|
+
* camera) — the caller should skip any test that needs the local rect.
|
|
99
|
+
*/
|
|
100
|
+
declare function inverse_project_rect(rect: {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
}, ctm: {
|
|
106
|
+
a: number;
|
|
107
|
+
b: number;
|
|
108
|
+
c: number;
|
|
109
|
+
d: number;
|
|
110
|
+
e: number;
|
|
111
|
+
f: number;
|
|
112
|
+
}, offset: readonly [number, number]): cmath.Rectangle | null;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { project_delta_inverse_ctm as a, SnapOptions as c, inverse_project_rect as i, DomSurfaceOptions as n, project_point_through_ctm as o, attach_dom_surface as r, DEFAULT_SNAP_OPTIONS as s, DomSurfaceHandle as t };
|
package/dist/dom.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as SnapOptions, i as
|
|
3
|
-
export { BoundsResolver, Camera, CameraConstraints, CameraOptions, DEFAULT_SNAP_OPTIONS, DomComputedPaint, DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, GeometryProvider, GeometrySignals, GestureBinding, GestureContext, GestureId, Gestures, MemoizedGeometryProvider, SnapOptions, attach_dom_surface };
|
|
1
|
+
import { C as BoundsResolver, E as CameraOptions, T as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, w as Camera } from "./editor-YQwdWHBb.mjs";
|
|
2
|
+
import { a as project_delta_inverse_ctm, c as SnapOptions, i as inverse_project_rect, n as DomSurfaceOptions, o as project_point_through_ctm, r as attach_dom_surface, s as DEFAULT_SNAP_OPTIONS, t as DomSurfaceHandle } from "./dom-Dz_V6q0Y.mjs";
|
|
3
|
+
export { type BoundsResolver, Camera, type CameraConstraints, type CameraOptions, DEFAULT_SNAP_OPTIONS, type DomComputedPaint, type DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, type GeometryProvider, type GeometrySignals, type GestureBinding, type GestureContext, type GestureId, Gestures, MemoizedGeometryProvider, type SnapOptions, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as SnapOptions, i as
|
|
3
|
-
export { BoundsResolver, Camera, CameraConstraints, CameraOptions, DEFAULT_SNAP_OPTIONS, DomComputedPaint, DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, GeometryProvider, GeometrySignals, GestureBinding, GestureContext, GestureId, Gestures, MemoizedGeometryProvider, SnapOptions, attach_dom_surface };
|
|
1
|
+
import { C as BoundsResolver, E as CameraOptions, T as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, w as Camera } from "./editor-CJ2KuRh5.js";
|
|
2
|
+
import { a as project_delta_inverse_ctm, c as SnapOptions, i as inverse_project_rect, n as DomSurfaceOptions, o as project_point_through_ctm, r as attach_dom_surface, s as DEFAULT_SNAP_OPTIONS, t as DomSurfaceHandle } from "./dom-D4dy6kq5.js";
|
|
3
|
+
export { type BoundsResolver, Camera, type CameraConstraints, type CameraOptions, DEFAULT_SNAP_OPTIONS, type DomComputedPaint, type DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, type GeometryProvider, type GeometrySignals, type GestureBinding, type GestureContext, type GestureId, Gestures, MemoizedGeometryProvider, type SnapOptions, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
|
package/dist/dom.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dom = require("./dom-
|
|
2
|
+
const require_dom = require("./dom-BuD8TKmL.js");
|
|
3
3
|
exports.Camera = require_dom.Camera;
|
|
4
4
|
exports.DEFAULT_SNAP_OPTIONS = require_dom.DEFAULT_SNAP_OPTIONS;
|
|
5
5
|
exports.Gestures = require_dom.Gestures;
|
|
6
6
|
exports.MemoizedGeometryProvider = require_dom.MemoizedGeometryProvider;
|
|
7
7
|
exports.attach_dom_surface = require_dom.attach_dom_surface;
|
|
8
|
+
exports.inverse_project_rect = require_dom.inverse_project_rect;
|
|
9
|
+
exports.project_delta_inverse_ctm = require_dom.project_delta_inverse_ctm;
|
|
10
|
+
exports.project_point_through_ctm = require_dom.project_point_through_ctm;
|
package/dist/dom.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Camera, i as
|
|
2
|
-
export { Camera, DEFAULT_SNAP_OPTIONS, Gestures, MemoizedGeometryProvider, attach_dom_surface };
|
|
1
|
+
import { a as Gestures, c as Camera, i as project_point_through_ctm, n as inverse_project_rect, o as DEFAULT_SNAP_OPTIONS, r as project_delta_inverse_ctm, s as MemoizedGeometryProvider, t as attach_dom_surface } from "./dom-DSjfCllZ.mjs";
|
|
2
|
+
export { Camera, DEFAULT_SNAP_OPTIONS, Gestures, MemoizedGeometryProvider, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
|