@pixerate/editor-react 0.94.0 → 0.96.0
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 +3 -1
- package/dist/animation-editor/index.cjs +1240 -195
- package/dist/animation-editor/index.js +4 -2
- package/dist/canvas/index.cjs +1419 -372
- package/dist/canvas/index.js +9 -4
- package/dist/canvas/useMermaidDiagram.d.cts +7 -1
- package/dist/canvas/useMermaidDiagram.d.ts +7 -1
- package/dist/chunk-3I7FOSLF.js +988 -0
- package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
- package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
- package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
- package/dist/chunk-KIRIU53A.js +72 -0
- package/dist/{chunk-NNM633RN.js → chunk-R7MEGRPV.js} +23 -0
- package/dist/color/ColorPicker.d.cts +30 -0
- package/dist/color/ColorPicker.d.ts +30 -0
- package/dist/color/DualColorPicker.d.cts +29 -0
- package/dist/color/DualColorPicker.d.ts +29 -0
- package/dist/color/index.cjs +1067 -0
- package/dist/color/index.d.cts +7 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.js +14 -0
- package/dist/color/useColorScheme.d.cts +16 -0
- package/dist/color/useColorScheme.d.ts +16 -0
- package/dist/effects/index.cjs +1169 -124
- package/dist/effects/index.js +4 -2
- package/dist/gradient/FillPicker.d.cts +27 -0
- package/dist/gradient/FillPicker.d.ts +27 -0
- package/dist/gradient/GradientEditor.d.cts +21 -0
- package/dist/gradient/GradientEditor.d.ts +21 -0
- package/dist/gradient/index.cjs +1601 -0
- package/dist/gradient/index.d.cts +6 -0
- package/dist/gradient/index.d.ts +6 -0
- package/dist/gradient/index.js +617 -0
- package/dist/gradient/useGradientController.d.cts +10 -0
- package/dist/gradient/useGradientController.d.ts +10 -0
- package/dist/image-editor/index.cjs +1742 -697
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +2181 -1115
- package/dist/index.js +9 -5
- package/dist/paint-editor/index.cjs +1233 -188
- package/dist/paint-editor/index.js +4 -2
- package/dist/parameters/fields.d.cts +1 -1
- package/dist/parameters/fields.d.ts +1 -1
- package/dist/parameters/index.cjs +1218 -173
- package/dist/parameters/index.js +3 -1
- package/dist/persistence/index.cjs +25 -4
- package/dist/persistence/index.d.cts +1 -0
- package/dist/persistence/index.d.ts +1 -0
- package/dist/persistence/index.js +5 -3
- package/dist/persistence/useEditorAutosave.d.cts +17 -0
- package/dist/persistence/useEditorAutosave.d.ts +17 -0
- package/dist/vector/index.cjs +1219 -174
- package/dist/vector/index.js +4 -2
- package/dist/video-editor/index.cjs +1230 -185
- package/dist/video-editor/index.js +4 -2
- package/package.json +29 -3
package/dist/parameters/index.js
CHANGED
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
ParameterVector,
|
|
16
16
|
parameterButtonClass,
|
|
17
17
|
parameterInputClass
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-5LFQ2UQZ.js";
|
|
19
|
+
import "../chunk-KIRIU53A.js";
|
|
20
|
+
import "../chunk-3I7FOSLF.js";
|
|
19
21
|
import {
|
|
20
22
|
PresenceLayer,
|
|
21
23
|
useAgentPlayback
|
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var persistence_exports = {};
|
|
22
22
|
__export(persistence_exports, {
|
|
23
23
|
RecoveryPrompt: () => RecoveryPrompt,
|
|
24
|
-
useAutosave: () => useAutosave
|
|
24
|
+
useAutosave: () => useAutosave,
|
|
25
|
+
useEditorAutosave: () => useEditorAutosave
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(persistence_exports);
|
|
27
28
|
|
|
@@ -129,8 +130,27 @@ function useAutosave(options) {
|
|
|
129
130
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
// src/persistence/
|
|
133
|
+
// src/persistence/useEditorAutosave.ts
|
|
134
|
+
var import_react2 = require("react");
|
|
133
135
|
var import_persistence2 = require("@pixerate/editor/persistence");
|
|
136
|
+
function useEditorAutosave(doc, options) {
|
|
137
|
+
const autosave = useAutosave({
|
|
138
|
+
...options,
|
|
139
|
+
key: options.key ?? doc.kind,
|
|
140
|
+
getSnapshot: () => (0, import_persistence2.toEditorDocumentFile)(doc),
|
|
141
|
+
deserialize: (text) => (0, import_persistence2.parseEditorDocument)(text, { kind: doc.kind }),
|
|
142
|
+
history: doc
|
|
143
|
+
});
|
|
144
|
+
const take = autosave.restore;
|
|
145
|
+
const restore = (0, import_react2.useCallback)(() => {
|
|
146
|
+
const snapshot = take();
|
|
147
|
+
return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
|
|
148
|
+
}, [take, doc]);
|
|
149
|
+
return { ...autosave, restore };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/persistence/RecoveryPrompt.tsx
|
|
153
|
+
var import_persistence3 = require("@pixerate/editor/persistence");
|
|
134
154
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
135
155
|
var RecoveryPrompt = ({
|
|
136
156
|
recovery,
|
|
@@ -152,7 +172,7 @@ var RecoveryPrompt = ({
|
|
|
152
172
|
className: `flex flex-wrap items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground shadow-sm ${className}`,
|
|
153
173
|
children: [
|
|
154
174
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
155
|
-
(0,
|
|
175
|
+
(0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
|
|
156
176
|
name ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
|
|
157
177
|
"(",
|
|
158
178
|
name,
|
|
@@ -186,5 +206,6 @@ var RecoveryPrompt = ({
|
|
|
186
206
|
// Annotate the CommonJS export names for ESM import in node:
|
|
187
207
|
0 && (module.exports = {
|
|
188
208
|
RecoveryPrompt,
|
|
189
|
-
useAutosave
|
|
209
|
+
useAutosave,
|
|
210
|
+
useEditorAutosave
|
|
190
211
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EditorDocument, type EditorDocumentFile, type LoadReport } from '@pixerate/editor/persistence';
|
|
2
|
+
import { type UseAutosaveOptions, type UseAutosaveResult } from './useAutosave.cjs';
|
|
3
|
+
export interface UseEditorAutosaveOptions extends Omit<UseAutosaveOptions<EditorDocumentFile>, 'key' | 'getSnapshot' | 'serialize' | 'deserialize' | 'history'> {
|
|
4
|
+
/** Snapshot key (default the document's `kind`). */
|
|
5
|
+
key?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseEditorAutosaveResult extends Omit<UseAutosaveResult<EditorDocumentFile>, 'restore'> {
|
|
8
|
+
/** Loads the recovered snapshot into the document and starts autosaving. */
|
|
9
|
+
restore: () => LoadReport | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `useAutosave` for any editor's `EditorDocument` (e.g. `useMermaidDiagram().editorDocument`):
|
|
13
|
+
* snapshots it as an `EditorDocumentFile` after each change, and `restore` loads a
|
|
14
|
+
* recovered snapshot straight into the editor. Render `<RecoveryPrompt>` with
|
|
15
|
+
* `recovery`, `restore` and `discard`. Pass a stable `doc`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useEditorAutosave(doc: EditorDocument, options: UseEditorAutosaveOptions): UseEditorAutosaveResult;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EditorDocument, type EditorDocumentFile, type LoadReport } from '@pixerate/editor/persistence';
|
|
2
|
+
import { type UseAutosaveOptions, type UseAutosaveResult } from './useAutosave.js';
|
|
3
|
+
export interface UseEditorAutosaveOptions extends Omit<UseAutosaveOptions<EditorDocumentFile>, 'key' | 'getSnapshot' | 'serialize' | 'deserialize' | 'history'> {
|
|
4
|
+
/** Snapshot key (default the document's `kind`). */
|
|
5
|
+
key?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseEditorAutosaveResult extends Omit<UseAutosaveResult<EditorDocumentFile>, 'restore'> {
|
|
8
|
+
/** Loads the recovered snapshot into the document and starts autosaving. */
|
|
9
|
+
restore: () => LoadReport | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `useAutosave` for any editor's `EditorDocument` (e.g. `useMermaidDiagram().editorDocument`):
|
|
13
|
+
* snapshots it as an `EditorDocumentFile` after each change, and `restore` loads a
|
|
14
|
+
* recovered snapshot straight into the editor. Render `<RecoveryPrompt>` with
|
|
15
|
+
* `recovery`, `restore` and `discard`. Pass a stable `doc`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useEditorAutosave(doc: EditorDocument, options: UseEditorAutosaveOptions): UseEditorAutosaveResult;
|