@pixerate/editor-react 0.156.0 → 0.158.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/dist/animation-editor/ShotInspector.d.cts +1 -1
- package/dist/animation-editor/ShotInspector.d.ts +1 -1
- package/dist/animation-editor/ShotLayers.d.cts +26 -0
- package/dist/animation-editor/ShotLayers.d.ts +26 -0
- package/dist/animation-editor/index.cjs +377 -142
- package/dist/animation-editor/index.d.cts +1 -0
- package/dist/animation-editor/index.d.ts +1 -0
- package/dist/animation-editor/index.js +367 -134
- package/dist/canvas/index.cjs +12 -6
- package/dist/canvas/index.js +13 -6
- package/dist/canvas/useCanvasEditorDocument.d.cts +5 -3
- package/dist/canvas/useCanvasEditorDocument.d.ts +5 -3
- package/package.json +3 -3
package/dist/canvas/index.cjs
CHANGED
|
@@ -1517,10 +1517,6 @@ function useCanvasCapture(options) {
|
|
|
1517
1517
|
// src/canvas/useCanvasEditorDocument.ts
|
|
1518
1518
|
var import_react16 = require("react");
|
|
1519
1519
|
var import_canvas11 = require("@pixerate/editor/canvas");
|
|
1520
|
-
var contentKey = (nodes, edges) => JSON.stringify([
|
|
1521
|
-
nodes.map(({ selected: _s, dragging: _d, measured: _m, resizing: _r, ...rest }) => rest),
|
|
1522
|
-
edges.map(({ selected: _s, ...rest }) => rest)
|
|
1523
|
-
]);
|
|
1524
1520
|
function useCanvasEditorDocument(options) {
|
|
1525
1521
|
const latest = (0, import_react16.useRef)(options);
|
|
1526
1522
|
latest.current = options;
|
|
@@ -1534,19 +1530,29 @@ function useCanvasEditorDocument(options) {
|
|
|
1534
1530
|
history: options.history,
|
|
1535
1531
|
scenes: options.scenes,
|
|
1536
1532
|
readOnly: () => latest.current.readOnly?.() ?? false,
|
|
1533
|
+
// Only offered when given, so a document without it saves no viewport.
|
|
1534
|
+
...options.getViewport ? { getViewport: () => latest.current.getViewport() } : {},
|
|
1535
|
+
setViewport: (viewport) => latest.current.setViewport?.(viewport),
|
|
1536
|
+
validateNode: (node, index) => latest.current.validateNode?.(node, index),
|
|
1537
|
+
normalize: (document2) => latest.current.normalize ? latest.current.normalize(document2) : document2,
|
|
1538
|
+
omitNodeKeys: options.omitNodeKeys,
|
|
1539
|
+
omitEdgeKeys: options.omitEdgeKeys,
|
|
1540
|
+
formatVersion: options.formatVersion,
|
|
1541
|
+
migrations: options.migrations,
|
|
1542
|
+
assets: options.assets,
|
|
1537
1543
|
subscribe: (listener) => {
|
|
1538
1544
|
listeners.current.add(listener);
|
|
1539
1545
|
return () => listeners.current.delete(listener);
|
|
1540
1546
|
}
|
|
1541
1547
|
}),
|
|
1542
1548
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1543
|
-
[options.history, options.scenes]
|
|
1549
|
+
[options.history, options.scenes, options.assets]
|
|
1544
1550
|
);
|
|
1545
1551
|
(0, import_react16.useEffect)(() => () => doc.destroy(), [doc]);
|
|
1546
1552
|
const lastKey = (0, import_react16.useRef)(null);
|
|
1547
1553
|
(0, import_react16.useEffect)(() => {
|
|
1548
1554
|
if (options.nodes.some((n) => n.dragging)) return;
|
|
1549
|
-
const key =
|
|
1555
|
+
const key = (0, import_canvas11.canvasDocumentContentKey)(options.nodes, options.edges, latest.current);
|
|
1550
1556
|
if (lastKey.current !== null && key !== lastKey.current) listeners.current.forEach((listener) => listener());
|
|
1551
1557
|
lastKey.current = key;
|
|
1552
1558
|
}, [options.nodes, options.edges]);
|
package/dist/canvas/index.js
CHANGED
|
@@ -1059,12 +1059,9 @@ function useCanvasCapture(options) {
|
|
|
1059
1059
|
// src/canvas/useCanvasEditorDocument.ts
|
|
1060
1060
|
import { useEffect as useEffect6, useMemo as useMemo6, useRef as useRef10 } from "react";
|
|
1061
1061
|
import {
|
|
1062
|
+
canvasDocumentContentKey,
|
|
1062
1063
|
createCanvasEditorDocument
|
|
1063
1064
|
} from "@pixerate/editor/canvas";
|
|
1064
|
-
var contentKey = (nodes, edges) => JSON.stringify([
|
|
1065
|
-
nodes.map(({ selected: _s, dragging: _d, measured: _m, resizing: _r, ...rest }) => rest),
|
|
1066
|
-
edges.map(({ selected: _s, ...rest }) => rest)
|
|
1067
|
-
]);
|
|
1068
1065
|
function useCanvasEditorDocument(options) {
|
|
1069
1066
|
const latest = useRef10(options);
|
|
1070
1067
|
latest.current = options;
|
|
@@ -1078,19 +1075,29 @@ function useCanvasEditorDocument(options) {
|
|
|
1078
1075
|
history: options.history,
|
|
1079
1076
|
scenes: options.scenes,
|
|
1080
1077
|
readOnly: () => latest.current.readOnly?.() ?? false,
|
|
1078
|
+
// Only offered when given, so a document without it saves no viewport.
|
|
1079
|
+
...options.getViewport ? { getViewport: () => latest.current.getViewport() } : {},
|
|
1080
|
+
setViewport: (viewport) => latest.current.setViewport?.(viewport),
|
|
1081
|
+
validateNode: (node, index) => latest.current.validateNode?.(node, index),
|
|
1082
|
+
normalize: (document2) => latest.current.normalize ? latest.current.normalize(document2) : document2,
|
|
1083
|
+
omitNodeKeys: options.omitNodeKeys,
|
|
1084
|
+
omitEdgeKeys: options.omitEdgeKeys,
|
|
1085
|
+
formatVersion: options.formatVersion,
|
|
1086
|
+
migrations: options.migrations,
|
|
1087
|
+
assets: options.assets,
|
|
1081
1088
|
subscribe: (listener) => {
|
|
1082
1089
|
listeners.current.add(listener);
|
|
1083
1090
|
return () => listeners.current.delete(listener);
|
|
1084
1091
|
}
|
|
1085
1092
|
}),
|
|
1086
1093
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1087
|
-
[options.history, options.scenes]
|
|
1094
|
+
[options.history, options.scenes, options.assets]
|
|
1088
1095
|
);
|
|
1089
1096
|
useEffect6(() => () => doc.destroy(), [doc]);
|
|
1090
1097
|
const lastKey = useRef10(null);
|
|
1091
1098
|
useEffect6(() => {
|
|
1092
1099
|
if (options.nodes.some((n) => n.dragging)) return;
|
|
1093
|
-
const key =
|
|
1100
|
+
const key = canvasDocumentContentKey(options.nodes, options.edges, latest.current);
|
|
1094
1101
|
if (lastKey.current !== null && key !== lastKey.current) listeners.current.forEach((listener) => listener());
|
|
1095
1102
|
lastKey.current = key;
|
|
1096
1103
|
}, [options.nodes, options.edges]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CanvasEdge, type CanvasEdgeLike, type CanvasEditorDocument, type CanvasEditorDocumentOptions, type CanvasNode } from '@pixerate/editor/canvas';
|
|
2
2
|
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
3
|
-
export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasEditorDocumentOptions<TNode, TEdge>, 'history' | 'scenes' | 'readOnly'> {
|
|
3
|
+
export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasEditorDocumentOptions<TNode, TEdge>, 'history' | 'scenes' | 'readOnly' | 'getViewport' | 'setViewport' | 'omitNodeKeys' | 'omitEdgeKeys' | 'validateNode' | 'normalize' | 'formatVersion' | 'migrations' | 'assets'> {
|
|
4
4
|
nodes: TNode[];
|
|
5
5
|
edges: TEdge[];
|
|
6
6
|
setNodes: (nodes: TNode[]) => void;
|
|
@@ -9,7 +9,9 @@ export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = Canva
|
|
|
9
9
|
/**
|
|
10
10
|
* The save / load / undo contract (kind `canvas`) for nodes and edges held in React state, for
|
|
11
11
|
* `useEditorAutosave` or `createDocumentToolProvider`. Besides the history, it counts changes
|
|
12
|
-
* the history does not see (a finished drag, an edge removed by React Flow), but not selection
|
|
13
|
-
* or
|
|
12
|
+
* the history does not see (a finished drag, an edge removed by React Flow), but not selection,
|
|
13
|
+
* measuring, the omitted keys or the viewport, and not the frames of a drag in progress. Pass a
|
|
14
|
+
* stable `history`, `scenes` and `assets`; `omitNodeKeys`, `omitEdgeKeys`, `formatVersion` and
|
|
15
|
+
* `migrations` are read once. The functions are always called in their latest version.
|
|
14
16
|
*/
|
|
15
17
|
export declare function useCanvasEditorDocument<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasEditorDocumentOptions<TNode, TEdge>): EditorDocument<CanvasEditorDocument<TNode, TEdge>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CanvasEdge, type CanvasEdgeLike, type CanvasEditorDocument, type CanvasEditorDocumentOptions, type CanvasNode } from '@pixerate/editor/canvas';
|
|
2
2
|
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
3
|
-
export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasEditorDocumentOptions<TNode, TEdge>, 'history' | 'scenes' | 'readOnly'> {
|
|
3
|
+
export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasEditorDocumentOptions<TNode, TEdge>, 'history' | 'scenes' | 'readOnly' | 'getViewport' | 'setViewport' | 'omitNodeKeys' | 'omitEdgeKeys' | 'validateNode' | 'normalize' | 'formatVersion' | 'migrations' | 'assets'> {
|
|
4
4
|
nodes: TNode[];
|
|
5
5
|
edges: TEdge[];
|
|
6
6
|
setNodes: (nodes: TNode[]) => void;
|
|
@@ -9,7 +9,9 @@ export interface UseCanvasEditorDocumentOptions<TNode extends CanvasNode = Canva
|
|
|
9
9
|
/**
|
|
10
10
|
* The save / load / undo contract (kind `canvas`) for nodes and edges held in React state, for
|
|
11
11
|
* `useEditorAutosave` or `createDocumentToolProvider`. Besides the history, it counts changes
|
|
12
|
-
* the history does not see (a finished drag, an edge removed by React Flow), but not selection
|
|
13
|
-
* or
|
|
12
|
+
* the history does not see (a finished drag, an edge removed by React Flow), but not selection,
|
|
13
|
+
* measuring, the omitted keys or the viewport, and not the frames of a drag in progress. Pass a
|
|
14
|
+
* stable `history`, `scenes` and `assets`; `omitNodeKeys`, `omitEdgeKeys`, `formatVersion` and
|
|
15
|
+
* `migrations` are read once. The functions are always called in their latest version.
|
|
14
16
|
*/
|
|
15
17
|
export declare function useCanvasEditorDocument<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasEditorDocumentOptions<TNode, TEdge>): EditorDocument<CanvasEditorDocument<TNode, TEdge>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.158.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.234.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.234.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|