@grida/svg-editor 1.0.0-alpha.3 → 1.0.0-alpha.4

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.
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
+ import { t as attach_dom_surface } from "./dom-CmOu0HvI.mjs";
3
+ //#region src/presets/keynote.ts
4
+ var keynote_exports = /* @__PURE__ */ __exportAll({ attach: () => attach });
5
+ /**
6
+ * Attach a keynote-shaped DOM surface:
7
+ * - Mounts via `attach_dom_surface` with `fit: true` (slide is visible on
8
+ * first frame).
9
+ * - Installs a `'cover'` camera constraint bound to the document root, so
10
+ * the user can't zoom out past the slide or pan past its edges.
11
+ * - Subscribes to `editor.state.load_version` so every `editor.load(svg)`
12
+ * re-fits the camera to the new document.
13
+ *
14
+ * Returns a `KeynoteSurfaceHandle` — same shape as `DomSurfaceHandle` plus
15
+ * `set_padding` for present-mode toggles. The returned `detach()`
16
+ * additionally tears down the load subscription.
17
+ */
18
+ function attach(editor, opts) {
19
+ let padding = opts.padding ?? 80;
20
+ const inner = attach_dom_surface(editor, {
21
+ ...opts.surface,
22
+ container: opts.container,
23
+ fit: true
24
+ });
25
+ inner.camera.constraints = {
26
+ type: "cover",
27
+ bounds: "<root>",
28
+ padding
29
+ };
30
+ const unsub_load = editor.subscribe_with_selector((s) => s.load_version, () => inner.camera.fit("<root>", { margin: padding }));
31
+ return {
32
+ camera: inner.camera,
33
+ gestures: inner.gestures,
34
+ set_padding(p) {
35
+ padding = p;
36
+ inner.camera.constraints = {
37
+ type: "cover",
38
+ bounds: "<root>",
39
+ padding: p
40
+ };
41
+ inner.camera.fit("<root>", { margin: p });
42
+ },
43
+ detach: () => {
44
+ unsub_load();
45
+ inner.detach();
46
+ }
47
+ };
48
+ }
49
+ //#endregion
50
+ export { keynote_exports as keynote };
package/dist/react.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as EditorStyle, o as SvgEditor, t as Commands, x as EditorState, z as Providers } from "./editor-DSADZszj.mjs";
2
- import { DomSurfaceHandle } from "./dom.mjs";
1
+ import { B as Providers, C as EditorStyle, S as EditorState, o as SvgEditor, t as Commands } from "./editor-Uu6dZX4y.mjs";
2
+ import { t as DomSurfaceHandle } from "./dom-DJnZhtOd.mjs";
3
3
  import cmath from "@grida/cmath";
4
4
  import { ReactNode } from "react";
5
5
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as EditorStyle, o as SvgEditor, t as Commands, x as EditorState, z as Providers } from "./editor-Da446SPO.js";
2
- import { DomSurfaceHandle } from "./dom.js";
1
+ import { B as Providers, C as EditorStyle, S as EditorState, o as SvgEditor, t as Commands } from "./editor-D2l_CDr0.js";
2
+ import { t as DomSurfaceHandle } from "./dom-Cn-RtjRL.js";
3
3
  import cmath from "@grida/cmath";
4
4
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
5
5
  import { ReactNode } from "react";
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_dom = require("./dom-BlJZWpR_.js");
4
- const require_editor = require("./editor-Eon0043Z.js");
3
+ const require_dom = require("./dom-CoVZzFqy.js");
4
+ const require_editor = require("./editor-D2zZAyny.js");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/react.tsx
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { t as createSvgEditor } from "./editor-DP36h-SE.mjs";
3
- import { t as attach_dom_surface } from "./dom-D-5D_3o0.mjs";
2
+ import { t as createSvgEditor } from "./editor-CjK56cgb.mjs";
3
+ import { t as attach_dom_surface } from "./dom-CmOu0HvI.mjs";
4
4
  import { createContext, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/react.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grida/svg-editor",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "Headless SVG editor (experimental).",
5
5
  "license": "MIT",
6
6
  "author": "Grida",
@@ -26,6 +26,11 @@
26
26
  "types": "./dist/react.d.ts",
27
27
  "import": "./dist/react.mjs",
28
28
  "require": "./dist/react.js"
29
+ },
30
+ "./presets": {
31
+ "types": "./dist/presets.d.ts",
32
+ "import": "./dist/presets.mjs",
33
+ "require": "./dist/presets.js"
29
34
  }
30
35
  },
31
36
  "publishConfig": {
@@ -34,11 +39,11 @@
34
39
  },
35
40
  "dependencies": {
36
41
  "svg-pathdata": "^7.2.0",
37
- "@grida/cmath": "0.1.0",
42
+ "@grida/history": "0.1.0",
38
43
  "@grida/hud": "0.1.0",
44
+ "@grida/text-editor": "0.1.0",
39
45
  "@grida/keybinding": "0.1.0",
40
- "@grida/history": "0.1.0",
41
- "@grida/text-editor": "0.1.0"
46
+ "@grida/cmath": "0.1.0"
42
47
  },
43
48
  "devDependencies": {
44
49
  "@types/react": "^19",
File without changes