@pixerate/editor-react 0.166.0 → 0.169.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/canvas/index.cjs +415 -332
- package/dist/canvas/index.d.cts +2 -0
- package/dist/canvas/index.d.ts +2 -0
- package/dist/canvas/index.js +85 -0
- package/dist/canvas/useCanvasProposals.d.cts +52 -0
- package/dist/canvas/useCanvasProposals.d.ts +52 -0
- package/dist/{chunk-65EL63YS.js → chunk-2UD3JH4W.js} +1137 -1376
- package/dist/chunk-EP6C5N54.js +406 -0
- package/dist/image-editor/LayerEffectsPanel.d.cts +3 -2
- package/dist/image-editor/LayerEffectsPanel.d.ts +3 -2
- package/dist/image-editor/index.cjs +121 -121
- package/dist/image-editor/index.js +10 -9
- package/dist/index.cjs +121 -121
- package/dist/index.js +10 -9
- package/dist/paint-editor/PaintLayersPanel.d.cts +2 -1
- package/dist/paint-editor/PaintLayersPanel.d.ts +2 -1
- package/dist/paint-editor/index.cjs +688 -423
- package/dist/paint-editor/index.js +38 -2
- package/package.json +3 -3
- package/dist/chunk-AJCWF6SN.js +0 -125
package/dist/canvas/index.d.cts
CHANGED
|
@@ -43,3 +43,5 @@ export { MermaidThumbnail, type MermaidThumbnailProps } from './MermaidThumbnail
|
|
|
43
43
|
export { useDiagramDirector, usePresenceState, type UseDiagramDirectorOptions } from './useDiagramDirector.cjs';
|
|
44
44
|
export { DiagramPresenceLayer, type DiagramPresenceLayerProps } from './DiagramPresenceLayer.cjs';
|
|
45
45
|
export * from './CanvasEffects.cjs';
|
|
46
|
+
export { useCanvasProposals, useCanvasChangeFeed, type UseCanvasProposalsOptions, type CanvasProposalsHandle, type UseCanvasChangeFeedOptions } from './useCanvasProposals.cjs';
|
|
47
|
+
export { CANVAS_PROPOSAL_CLASS, createCanvasProposals, createCanvasChangeFeed, createCanvasProposalToolProvider, type CanvasProposal, type CanvasProposals, type CanvasProposalsOptions, type CanvasProposalsState, type CanvasProposalInput, type CanvasProposalNodeInput, type CanvasProposalEdgeInput, type CanvasProposalAcceptResult, type CanvasProposalToolProviderOptions, type CanvasChange, type CanvasChangeFeed, type CanvasChangeFeedOptions, type CanvasNodeChange, type CanvasEdgeChange } from '@pixerate/editor/canvas';
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -43,3 +43,5 @@ export { MermaidThumbnail, type MermaidThumbnailProps } from './MermaidThumbnail
|
|
|
43
43
|
export { useDiagramDirector, usePresenceState, type UseDiagramDirectorOptions } from './useDiagramDirector.js';
|
|
44
44
|
export { DiagramPresenceLayer, type DiagramPresenceLayerProps } from './DiagramPresenceLayer.js';
|
|
45
45
|
export * from './CanvasEffects.js';
|
|
46
|
+
export { useCanvasProposals, useCanvasChangeFeed, type UseCanvasProposalsOptions, type CanvasProposalsHandle, type UseCanvasChangeFeedOptions } from './useCanvasProposals.js';
|
|
47
|
+
export { CANVAS_PROPOSAL_CLASS, createCanvasProposals, createCanvasChangeFeed, createCanvasProposalToolProvider, type CanvasProposal, type CanvasProposals, type CanvasProposalsOptions, type CanvasProposalsState, type CanvasProposalInput, type CanvasProposalNodeInput, type CanvasProposalEdgeInput, type CanvasProposalAcceptResult, type CanvasProposalToolProviderOptions, type CanvasChange, type CanvasChangeFeed, type CanvasChangeFeedOptions, type CanvasNodeChange, type CanvasEdgeChange } from '@pixerate/editor/canvas';
|
package/dist/canvas/index.js
CHANGED
|
@@ -3366,6 +3366,85 @@ function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
|
3366
3366
|
/* @__PURE__ */ jsx13("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
|
|
3367
3367
|
] }, a.id)) });
|
|
3368
3368
|
}
|
|
3369
|
+
|
|
3370
|
+
// src/canvas/useCanvasProposals.ts
|
|
3371
|
+
import { useEffect as useEffect16, useMemo as useMemo16, useRef as useRef22, useState as useState12, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
3372
|
+
import {
|
|
3373
|
+
createCanvasChangeFeed,
|
|
3374
|
+
createCanvasProposals
|
|
3375
|
+
} from "@pixerate/editor/canvas";
|
|
3376
|
+
function useCanvasProposals(options) {
|
|
3377
|
+
const latest = useRef22(options);
|
|
3378
|
+
latest.current = options;
|
|
3379
|
+
const live = useRef22({ nodes: options.nodes, edges: options.edges });
|
|
3380
|
+
live.current = { nodes: options.nodes, edges: options.edges };
|
|
3381
|
+
const storeRef = useRef22(null);
|
|
3382
|
+
if (storeRef.current === null) {
|
|
3383
|
+
storeRef.current = createCanvasProposals({
|
|
3384
|
+
getNodes: () => live.current.nodes,
|
|
3385
|
+
getEdges: () => live.current.edges,
|
|
3386
|
+
setNodes: (nodes) => {
|
|
3387
|
+
live.current = { ...live.current, nodes };
|
|
3388
|
+
latest.current.setNodes(nodes);
|
|
3389
|
+
},
|
|
3390
|
+
setEdges: (edges) => {
|
|
3391
|
+
live.current = { ...live.current, edges };
|
|
3392
|
+
latest.current.setEdges(edges);
|
|
3393
|
+
},
|
|
3394
|
+
history: options.history,
|
|
3395
|
+
origin: options.origin,
|
|
3396
|
+
readOnly: () => latest.current.readOnly?.() ?? false,
|
|
3397
|
+
defaultNodeSize: options.defaultNodeSize,
|
|
3398
|
+
visibleRect: () => latest.current.visibleRect?.(),
|
|
3399
|
+
defaultNodeType: options.defaultNodeType,
|
|
3400
|
+
idGenerator: options.idGenerator
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
const store = storeRef.current;
|
|
3404
|
+
const state = useSyncExternalStore7(store.subscribe, store.getState, store.getState);
|
|
3405
|
+
const view = useMemo16(() => store.withGhosts(options.nodes, options.edges), [store, state, options.nodes, options.edges]);
|
|
3406
|
+
return useMemo16(
|
|
3407
|
+
() => ({
|
|
3408
|
+
store,
|
|
3409
|
+
proposals: state.proposals,
|
|
3410
|
+
view,
|
|
3411
|
+
propose: store.propose,
|
|
3412
|
+
accept: store.accept,
|
|
3413
|
+
reject: store.reject,
|
|
3414
|
+
clear: store.clear
|
|
3415
|
+
}),
|
|
3416
|
+
[store, state, view]
|
|
3417
|
+
);
|
|
3418
|
+
}
|
|
3419
|
+
function useCanvasChangeFeed(options) {
|
|
3420
|
+
const latest = useRef22(options);
|
|
3421
|
+
latest.current = options;
|
|
3422
|
+
const [last, setLast] = useState12(null);
|
|
3423
|
+
const feed = useMemo16(
|
|
3424
|
+
() => createCanvasChangeFeed({
|
|
3425
|
+
getNodes: () => latest.current.nodes,
|
|
3426
|
+
getEdges: () => latest.current.edges,
|
|
3427
|
+
ignoreNodeKeys: options.ignoreNodeKeys
|
|
3428
|
+
}),
|
|
3429
|
+
[]
|
|
3430
|
+
);
|
|
3431
|
+
useEffect16(() => options.history?.onCommit(feed.noteCommit), [feed, options.history]);
|
|
3432
|
+
useEffect16(() => {
|
|
3433
|
+
const change = feed.check();
|
|
3434
|
+
if (!change) return;
|
|
3435
|
+
setLast(change);
|
|
3436
|
+
latest.current.onChange?.(change);
|
|
3437
|
+
}, [feed, options.nodes, options.edges]);
|
|
3438
|
+
return { feed, last };
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
// src/canvas/index.ts
|
|
3442
|
+
import {
|
|
3443
|
+
CANVAS_PROPOSAL_CLASS,
|
|
3444
|
+
createCanvasProposals as createCanvasProposals2,
|
|
3445
|
+
createCanvasChangeFeed as createCanvasChangeFeed2,
|
|
3446
|
+
createCanvasProposalToolProvider
|
|
3447
|
+
} from "@pixerate/editor/canvas";
|
|
3369
3448
|
export {
|
|
3370
3449
|
ANIMATABLE_PROPERTIES,
|
|
3371
3450
|
ANIMATION_DATA_KEY,
|
|
@@ -3379,6 +3458,7 @@ export {
|
|
|
3379
3458
|
AnimationTimeline,
|
|
3380
3459
|
CANVAS_COMPONENT_DRAG_TYPE2 as CANVAS_COMPONENT_DRAG_TYPE,
|
|
3381
3460
|
CANVAS_GRADIENT_PRESETS,
|
|
3461
|
+
CANVAS_PROPOSAL_CLASS,
|
|
3382
3462
|
CANVAS_TOKEN_PROPERTIES,
|
|
3383
3463
|
CHILD_LAYOUT_DATA_KEY,
|
|
3384
3464
|
CONNECTION_LINE_TYPES,
|
|
@@ -3460,12 +3540,15 @@ export {
|
|
|
3460
3540
|
createBezierTrajectory,
|
|
3461
3541
|
createCanvasAnimationController2 as createCanvasAnimationController,
|
|
3462
3542
|
createCanvasAutoLayoutController2 as createCanvasAutoLayoutController,
|
|
3543
|
+
createCanvasChangeFeed2 as createCanvasChangeFeed,
|
|
3463
3544
|
createCanvasComponent,
|
|
3464
3545
|
createCanvasComponentsController2 as createCanvasComponentsController,
|
|
3465
3546
|
createCanvasDrawController2 as createCanvasDrawController,
|
|
3466
3547
|
createCanvasExplosionStateController2 as createCanvasExplosionStateController,
|
|
3467
3548
|
createCanvasExplosionToolProvider,
|
|
3468
3549
|
createCanvasInstance,
|
|
3550
|
+
createCanvasProposalToolProvider,
|
|
3551
|
+
createCanvasProposals2 as createCanvasProposals,
|
|
3469
3552
|
createCanvasScenesStore,
|
|
3470
3553
|
createDefaultStrokeStyle,
|
|
3471
3554
|
createFanOutTrajectory2 as createFanOutTrajectory,
|
|
@@ -3711,6 +3794,7 @@ export {
|
|
|
3711
3794
|
useCanvasAutoLayout,
|
|
3712
3795
|
useCanvasBrushes,
|
|
3713
3796
|
useCanvasCapture,
|
|
3797
|
+
useCanvasChangeFeed,
|
|
3714
3798
|
useCanvasClipboard,
|
|
3715
3799
|
useCanvasComponents,
|
|
3716
3800
|
useCanvasDocking,
|
|
@@ -3725,6 +3809,7 @@ export {
|
|
|
3725
3809
|
useCanvasLayout,
|
|
3726
3810
|
useCanvasMeasure,
|
|
3727
3811
|
useCanvasPlaybackSurface,
|
|
3812
|
+
useCanvasProposals,
|
|
3728
3813
|
useCanvasScenes,
|
|
3729
3814
|
useCanvasShortcuts,
|
|
3730
3815
|
useCanvasTokens,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CanvasChange, type CanvasChangeFeed, type CanvasEdge, type CanvasEdgeLike, type CanvasNode, type CanvasProposal, type CanvasProposals, type CanvasProposalsOptions } from '@pixerate/editor/canvas';
|
|
2
|
+
import type { HistoryCommitEvent } from '@pixerate/editor/history';
|
|
3
|
+
export interface UseCanvasProposalsOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasProposalsOptions<TNode, TEdge>, 'history' | 'origin' | 'readOnly' | 'defaultNodeSize' | 'visibleRect' | 'defaultNodeType' | 'idGenerator'> {
|
|
4
|
+
nodes: TNode[];
|
|
5
|
+
edges: TEdge[];
|
|
6
|
+
setNodes: (nodes: TNode[]) => void;
|
|
7
|
+
setEdges: (edges: TEdge[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface CanvasProposalsHandle<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> {
|
|
10
|
+
/** The framework-free store (for `createCanvasProposalToolProvider` and agents). */
|
|
11
|
+
readonly store: CanvasProposals<TNode, TEdge>;
|
|
12
|
+
/** Pending proposals. */
|
|
13
|
+
proposals: readonly CanvasProposal<TNode, TEdge>[];
|
|
14
|
+
/** The canvas with the proposals drawn in as ghosts: render these instead of `nodes` / `edges`. */
|
|
15
|
+
view: {
|
|
16
|
+
nodes: TNode[];
|
|
17
|
+
edges: TEdge[];
|
|
18
|
+
};
|
|
19
|
+
propose: CanvasProposals<TNode, TEdge>['propose'];
|
|
20
|
+
accept: CanvasProposals<TNode, TEdge>['accept'];
|
|
21
|
+
reject: CanvasProposals<TNode, TEdge>['reject'];
|
|
22
|
+
clear: CanvasProposals<TNode, TEdge>['clear'];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Agent-suggested canvas additions for nodes and edges held in React state: ghosts the user
|
|
26
|
+
* accepts (one undo step on `history`, made by the proposer) or rejects. Render `view` instead of
|
|
27
|
+
* your nodes and edges so the ghosts show; changes React Flow reports for ghost ids are no-ops in
|
|
28
|
+
* `applyNodeChanges`. The same API as the Svelte `createCanvasProposalState`. Pass a stable
|
|
29
|
+
* `history`; the other options are read when used.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useCanvasProposals<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasProposalsOptions<TNode, TEdge>): CanvasProposalsHandle<TNode, TEdge>;
|
|
32
|
+
export interface UseCanvasChangeFeedOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> {
|
|
33
|
+
nodes: TNode[];
|
|
34
|
+
edges: TEdge[];
|
|
35
|
+
/** The canvas history, for each change's origin (`user` or `agent:<id>`). Pass a stable one. */
|
|
36
|
+
history?: {
|
|
37
|
+
onCommit(listener: (event: HistoryCommitEvent) => void): () => void;
|
|
38
|
+
};
|
|
39
|
+
/** Node fields to ignore besides the runtime ones. Read once. */
|
|
40
|
+
ignoreNodeKeys?: readonly string[];
|
|
41
|
+
/** Called with each change, after the render that shows it. */
|
|
42
|
+
onChange?: (change: CanvasChange<TNode, TEdge>) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What changed on a canvas held in React state, after each render: nodes and edges added,
|
|
46
|
+
* removed or edited, the selection, and who made it. For agents that follow what the user does.
|
|
47
|
+
* Returns the latest change and the feed. The same API as the Svelte `createCanvasChangeWatcher`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useCanvasChangeFeed<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasChangeFeedOptions<TNode, TEdge>): {
|
|
50
|
+
feed: CanvasChangeFeed<TNode, TEdge>;
|
|
51
|
+
last: CanvasChange<TNode, TEdge> | null;
|
|
52
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CanvasChange, type CanvasChangeFeed, type CanvasEdge, type CanvasEdgeLike, type CanvasNode, type CanvasProposal, type CanvasProposals, type CanvasProposalsOptions } from '@pixerate/editor/canvas';
|
|
2
|
+
import type { HistoryCommitEvent } from '@pixerate/editor/history';
|
|
3
|
+
export interface UseCanvasProposalsOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> extends Pick<CanvasProposalsOptions<TNode, TEdge>, 'history' | 'origin' | 'readOnly' | 'defaultNodeSize' | 'visibleRect' | 'defaultNodeType' | 'idGenerator'> {
|
|
4
|
+
nodes: TNode[];
|
|
5
|
+
edges: TEdge[];
|
|
6
|
+
setNodes: (nodes: TNode[]) => void;
|
|
7
|
+
setEdges: (edges: TEdge[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface CanvasProposalsHandle<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> {
|
|
10
|
+
/** The framework-free store (for `createCanvasProposalToolProvider` and agents). */
|
|
11
|
+
readonly store: CanvasProposals<TNode, TEdge>;
|
|
12
|
+
/** Pending proposals. */
|
|
13
|
+
proposals: readonly CanvasProposal<TNode, TEdge>[];
|
|
14
|
+
/** The canvas with the proposals drawn in as ghosts: render these instead of `nodes` / `edges`. */
|
|
15
|
+
view: {
|
|
16
|
+
nodes: TNode[];
|
|
17
|
+
edges: TEdge[];
|
|
18
|
+
};
|
|
19
|
+
propose: CanvasProposals<TNode, TEdge>['propose'];
|
|
20
|
+
accept: CanvasProposals<TNode, TEdge>['accept'];
|
|
21
|
+
reject: CanvasProposals<TNode, TEdge>['reject'];
|
|
22
|
+
clear: CanvasProposals<TNode, TEdge>['clear'];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Agent-suggested canvas additions for nodes and edges held in React state: ghosts the user
|
|
26
|
+
* accepts (one undo step on `history`, made by the proposer) or rejects. Render `view` instead of
|
|
27
|
+
* your nodes and edges so the ghosts show; changes React Flow reports for ghost ids are no-ops in
|
|
28
|
+
* `applyNodeChanges`. The same API as the Svelte `createCanvasProposalState`. Pass a stable
|
|
29
|
+
* `history`; the other options are read when used.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useCanvasProposals<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasProposalsOptions<TNode, TEdge>): CanvasProposalsHandle<TNode, TEdge>;
|
|
32
|
+
export interface UseCanvasChangeFeedOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge> {
|
|
33
|
+
nodes: TNode[];
|
|
34
|
+
edges: TEdge[];
|
|
35
|
+
/** The canvas history, for each change's origin (`user` or `agent:<id>`). Pass a stable one. */
|
|
36
|
+
history?: {
|
|
37
|
+
onCommit(listener: (event: HistoryCommitEvent) => void): () => void;
|
|
38
|
+
};
|
|
39
|
+
/** Node fields to ignore besides the runtime ones. Read once. */
|
|
40
|
+
ignoreNodeKeys?: readonly string[];
|
|
41
|
+
/** Called with each change, after the render that shows it. */
|
|
42
|
+
onChange?: (change: CanvasChange<TNode, TEdge>) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What changed on a canvas held in React state, after each render: nodes and edges added,
|
|
46
|
+
* removed or edited, the selection, and who made it. For agents that follow what the user does.
|
|
47
|
+
* Returns the latest change and the feed. The same API as the Svelte `createCanvasChangeWatcher`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useCanvasChangeFeed<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: UseCanvasChangeFeedOptions<TNode, TEdge>): {
|
|
50
|
+
feed: CanvasChangeFeed<TNode, TEdge>;
|
|
51
|
+
last: CanvasChange<TNode, TEdge> | null;
|
|
52
|
+
};
|