@pixerate/editor-svelte 0.113.0 → 0.114.1

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.
@@ -2,6 +2,7 @@ import type { ToolRegistry } from '@pixerate/editor/tools';
2
2
  import { ImageEditorController, type ImageEffectsToolProviderOptions, type ImageEditorFit, type ImageEditorOptions, type ImageEditorState, type ImageEditorTool, type CropBox, type AspectRatio, type ImageAdjustments, type DepthMaskOptions, type Annotation, type CreateAnnotationPayload, type ExportOptions, type SerializedImageEditorState, type AIResultOptions, type ImagePoint, type AdjustmentKind, type AdjustmentLayerInit, type AdjustmentLayerUpdate, type ImageHistogram } from '@pixerate/editor/image-editor';
3
3
  export declare function createReactiveImageEditor(options?: ImageEditorOptions): {
4
4
  readonly controller: ImageEditorController;
5
+ editorDocument: import("@pixerate/editor/persistence").EditorDocument<SerializedImageEditorState>;
5
6
  readonly state: ImageEditorState;
6
7
  readonly canUndo: boolean;
7
8
  /** Histogram of the last rendered preview (after adjustments and layers); null before a render. */
@@ -1,4 +1,4 @@
1
- import { ImageEditorController, createImageEffectsToolProvider, } from '@pixerate/editor/image-editor';
1
+ import { ImageEditorController, createImageEditorDocument, createImageEffectsToolProvider, } from '@pixerate/editor/image-editor';
2
2
  export function createReactiveImageEditor(options = {}) {
3
3
  const controller = new ImageEditorController(options);
4
4
  let state = $state(controller.getState());
@@ -11,10 +11,13 @@ export function createReactiveImageEditor(options = {}) {
11
11
  const unsubscribeHistogram = controller.subscribeHistogram((h) => {
12
12
  histogram = h;
13
13
  });
14
+ /** The save / load / undo contract, with layer pixels as asset references. */
15
+ const editorDocument = createImageEditorDocument(controller);
14
16
  return {
15
17
  get controller() {
16
18
  return controller;
17
19
  },
20
+ editorDocument,
18
21
  get state() {
19
22
  return state;
20
23
  },
@@ -168,6 +171,7 @@ export function createReactiveImageEditor(options = {}) {
168
171
  destroy() {
169
172
  unsubscribe();
170
173
  unsubscribeHistogram();
174
+ editorDocument.destroy();
171
175
  },
172
176
  };
173
177
  }
@@ -8,6 +8,7 @@ import type { ToolRegistry } from '@pixerate/editor/tools';
8
8
  export declare function createReactivePaintEditor(options?: PaintEditorOptions | PaintEditorController): {
9
9
  readonly controller: PaintEditorController;
10
10
  readonly state: PaintEditorState;
11
+ editorDocument: import("@pixerate/editor/persistence").EditorDocument<import("@pixerate/editor/paint-editor").SerializedPaintDocument>;
11
12
  destroy(): void;
12
13
  };
13
14
  /** The controller's state as a rune, for components (subscribe in an effect, see GOTCHAS). */
@@ -1,5 +1,5 @@
1
1
  import { untrack } from 'svelte';
2
- import { createPaintEffectsToolProvider, PaintDirector, PaintEditorController, PaintPresence } from '@pixerate/editor/paint-editor';
2
+ import { createPaintEditorDocument, createPaintEffectsToolProvider, PaintDirector, PaintEditorController, PaintPresence } from '@pixerate/editor/paint-editor';
3
3
  /**
4
4
  * A `PaintEditorController` (created from `options`, or the one given) with its state as a
5
5
  * rune: `editor.state` updates after every change. Call `destroy()` to unsubscribe.
@@ -10,6 +10,8 @@ export function createReactivePaintEditor(options = {}) {
10
10
  const unsubscribe = controller.subscribe(() => {
11
11
  snapshot = controller.getState();
12
12
  });
13
+ /** The save / load / undo contract, with every image as an asset reference. */
14
+ const editorDocument = createPaintEditorDocument(controller);
13
15
  return {
14
16
  get controller() {
15
17
  return controller;
@@ -17,8 +19,10 @@ export function createReactivePaintEditor(options = {}) {
17
19
  get state() {
18
20
  return snapshot;
19
21
  },
22
+ editorDocument,
20
23
  destroy() {
21
24
  unsubscribe();
25
+ editorDocument.destroy();
22
26
  },
23
27
  };
24
28
  }
@@ -1,4 +1,4 @@
1
- import { parseEditorDocument, toEditorDocumentFile, } from "@pixerate/editor/persistence";
1
+ import { parseEditorDocument, toEditorDocumentFile, withEditorAssets, } from "@pixerate/editor/persistence";
2
2
  import { createAutosave } from "./autosave.svelte.js";
3
3
  /**
4
4
  * `createAutosave` for any editor's `EditorDocument` (e.g.
@@ -9,6 +9,8 @@ import { createAutosave } from "./autosave.svelte.js";
9
9
  export function createEditorAutosave(doc, options) {
10
10
  const autosave = createAutosave({
11
11
  ...options,
12
+ // Image and paint documents hold asset references: their bytes are saved and read with them.
13
+ storage: doc.assets ? withEditorAssets(options.storage, doc.assets) : options.storage,
12
14
  key: options.key ?? doc.kind,
13
15
  getSnapshot: () => toEditorDocumentFile(doc),
14
16
  deserialize: (text) => parseEditorDocument(text, { kind: doc.kind }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.113.0",
3
+ "version": "0.114.1",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -160,7 +160,7 @@
160
160
  "@tiptap/extension-bubble-menu": "^2.27.3",
161
161
  "@tiptap/extension-placeholder": "^2.27.3",
162
162
  "@tiptap/starter-kit": "^2.27.3",
163
- "@pixerate/editor": "0.154.0"
163
+ "@pixerate/editor": "0.156.0"
164
164
  },
165
165
  "peerDependencies": {
166
166
  "@dagrejs/dagre": "^1.1.4",