@pixerate/editor-react 0.97.0 → 0.99.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 +2 -2
- package/dist/animation-editor/index.cjs +13 -9
- package/dist/animation-editor/index.js +7 -7
- package/dist/canvas/index.cjs +22 -13
- package/dist/canvas/index.js +14 -9
- package/dist/canvas/useCanvasPlaybackSurface.d.cts +8 -2
- package/dist/canvas/useCanvasPlaybackSurface.d.ts +8 -2
- package/dist/chart/index.cjs +10 -6
- package/dist/chart/index.js +2 -2
- package/dist/{chunk-NC4RLZTK.js → chunk-EFF4YWJK.js} +3169 -3085
- package/dist/{chunk-GECXTPSH.js → chunk-EP6MSQN4.js} +1 -1
- package/dist/{chunk-AILJ4JOW.js → chunk-GDPWLGPD.js} +3 -3
- package/dist/{chunk-IPVWWVSF.js → chunk-GNO54NFG.js} +7 -3
- package/dist/{chunk-7I73DW4V.js → chunk-V2YC5T4R.js} +14 -8
- package/dist/image-editor/AdjustmentLayersPanel.d.cts +2 -0
- package/dist/image-editor/AdjustmentLayersPanel.d.ts +2 -0
- package/dist/image-editor/ControlSlider.d.cts +2 -0
- package/dist/image-editor/ControlSlider.d.ts +2 -0
- package/dist/image-editor/CurvesEditor.d.cts +2 -0
- package/dist/image-editor/CurvesEditor.d.ts +2 -0
- package/dist/image-editor/ImageEditor.d.cts +3 -1
- package/dist/image-editor/ImageEditor.d.ts +3 -1
- package/dist/image-editor/ImageEditorCanvas.d.cts +77 -0
- package/dist/image-editor/ImageEditorCanvas.d.ts +77 -0
- package/dist/image-editor/ImageEffectControls.d.cts +14 -0
- package/dist/image-editor/ImageEffectControls.d.ts +14 -0
- package/dist/image-editor/index.cjs +4659 -4576
- package/dist/image-editor/index.d.cts +2 -0
- package/dist/image-editor/index.d.ts +2 -0
- package/dist/image-editor/index.js +6 -2
- package/dist/image-editor/styles.d.cts +51 -0
- package/dist/image-editor/styles.d.ts +51 -0
- package/dist/index.cjs +5262 -5173
- package/dist/index.js +9 -5
- package/dist/paint-editor/index.cjs +10 -6
- package/dist/paint-editor/index.js +4 -4
- package/dist/parameters/index.cjs +20 -10
- package/dist/parameters/index.js +2 -2
- package/dist/playback/PresenceLayer.d.cts +3 -1
- package/dist/playback/PresenceLayer.d.ts +3 -1
- package/dist/playback/useElementPlaybackSurface.d.cts +5 -4
- package/dist/playback/useElementPlaybackSurface.d.ts +5 -4
- package/dist/spreadsheet/index.cjs +7 -3
- package/dist/spreadsheet/index.js +2 -2
- package/dist/vector/index.cjs +7 -3
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +13 -9
- package/dist/video-editor/index.js +7 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ useAgentToolProvider(registry, provider);
|
|
|
96
96
|
| :--- | :--- |
|
|
97
97
|
| `@pixerate/editor-react` | `usePromptEditor`, `useEditor`, `EditorContent`, `BubbleMenu`, `TemplateRenderer`, `useHistory`, `useHistoryDirty`, `useHistoryShortcuts`, `useNavigationGuard`, `useDismissGuard`, `EditorSlotsProvider` / `useEditorSlots`, `SpreadsheetEditor` / `useSpreadsheetEditor`, `FormulaHints`, `DirtyTracker` |
|
|
98
98
|
| `@pixerate/editor-react/spreadsheet` | `SpreadsheetEditor` (virtualised for large sheets, `virtualize` prop), `useSpreadsheetEditor`, `useSpreadsheetViewport`, `useSpreadsheetTableInteractions`, `FormulaHints`, `SpreadsheetContextMenu`, `SpreadsheetGroupRow`, `SheetTabs`, `NameManager` (also re-exported from the root entry) |
|
|
99
|
-
| `@pixerate/editor-react/image-editor` | `ImageEditor`, `useImageEditor`: crop, rotate/flip, adjustments, annotations, depth masks, Select & Mask (`SelectionOptionsBar`, `RefineEdgePanel`: magic wand, marquees, lasso, Refine Edge, layer masks), and `onInpaint` / `onRemoveBackground` AI hooks |
|
|
99
|
+
| `@pixerate/editor-react/image-editor` | `ImageEditor`, `useImageEditor`, `ImageEditorCanvas` (the canvas alone, for your own chrome; see `docs/image-editor-canvas.md`), `ImageEffectControls`: crop, rotate/flip, adjustments, annotations, depth masks, Select & Mask (`SelectionOptionsBar`, `RefineEdgePanel`: magic wand, marquees, lasso, Refine Edge, layer masks), and `onInpaint` / `onRemoveBackground` AI hooks |
|
|
100
100
|
| `@pixerate/editor-react/paint-editor` | `PaintEditor`, `usePaintEditor`: natural-media painting with `PaintCanvas` (pen pressure, tilt and twist, coalesced and predicted events, palm rejection, view rotation and mirroring), `PaintToolbar` (tools, symmetry, perspective, tracing and reference images, save / open, PNG / JPEG / PSD), `BrushPanel` (library with thumbnails), `PaperPanel`, `ColorPanel` (wheel, harmonies, swatches, mixing pad) and `PaintLayersPanel` |
|
|
101
101
|
| `@pixerate/editor-react/commands` | `CommandPalette`, `useCommandPalette` (`hotkey: "Mod+K"`), `useCommandShortcuts`, `useRegisterCommands` over a `CommandRegistry` from `@pixerate/editor/commands` (also re-exported from the root entry) |
|
|
102
102
|
| `@pixerate/editor-react/persistence` | `useAutosave` (crash-recovery snapshots bound to a history / dirty flag, flushed on `pagehide`, with a recovery check on mount), `useEditorAutosave` (the same for any editor's `EditorDocument`, e.g. `useMermaidDiagram().editorDocument`; `restore` loads the snapshot into the editor) and `<RecoveryPrompt>` (also re-exported from the root entry) |
|
|
@@ -130,7 +130,7 @@ The components are styled with [Tailwind CSS](https://tailwindcss.com) utility c
|
|
|
130
130
|
|
|
131
131
|
2. **Define the theme colors.** `SpreadsheetEditor`, `BubbleMenu`, `TemplateRenderer` and the slot components use [shadcn/ui](https://ui.shadcn.com)-style tokens: `background`, `foreground`, `muted`, `muted-foreground`, `border`, `input`, `primary`, `popover`, `popover-foreground` and `destructive`. Projects already using shadcn/ui have these. Otherwise, define them as colors in your Tailwind theme.
|
|
132
132
|
|
|
133
|
-
`ImageEditor`
|
|
133
|
+
`ImageEditor`, `ImageEditorCanvas` and the image panels use the same theme tokens (plus `accent`, `primary-foreground` and `accent-foreground`), so they follow your light or dark theme; their shared classes are in `image-editor/styles.ts`. Without Tailwind, the components work but render unstyled. Pass `className` to override.
|
|
134
134
|
|
|
135
135
|
## License
|
|
136
136
|
|
|
@@ -88,18 +88,18 @@ function useAnimationEditor(controllerOrOptions = {}) {
|
|
|
88
88
|
return { controller, state, ...actions };
|
|
89
89
|
}
|
|
90
90
|
function useAnimationEditorTools(registry, controller, options = {}) {
|
|
91
|
-
const { id, namespace, readOnly, rasterize } = options;
|
|
91
|
+
const { id, namespace, readOnly, rasterize, playbackSurface } = options;
|
|
92
92
|
(0, import_react.useEffect)(() => {
|
|
93
93
|
if (!registry) return;
|
|
94
|
-
return registry.register((0, import_animation_editor.createAnimationEditorToolProvider)(controller, { id, namespace, readOnly, rasterize }));
|
|
95
|
-
}, [registry, controller, id, namespace, readOnly, rasterize]);
|
|
94
|
+
return registry.register((0, import_animation_editor.createAnimationEditorToolProvider)(controller, { id, namespace, readOnly, rasterize, playbackSurface }));
|
|
95
|
+
}, [registry, controller, id, namespace, readOnly, rasterize, playbackSurface]);
|
|
96
96
|
}
|
|
97
97
|
function useAnimationEffectsTools(registry, controller, options = {}) {
|
|
98
|
-
const { id, namespace, readOnly } = options;
|
|
98
|
+
const { id, namespace, readOnly, playbackSurface } = options;
|
|
99
99
|
(0, import_react.useEffect)(() => {
|
|
100
100
|
if (!registry) return;
|
|
101
|
-
return registry.register((0, import_animation_editor.createAnimationEffectsToolProvider)(controller, { id, namespace, readOnly }));
|
|
102
|
-
}, [registry, controller, id, namespace, readOnly]);
|
|
101
|
+
return registry.register((0, import_animation_editor.createAnimationEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
102
|
+
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// src/animation-editor/AnimationStage.tsx
|
|
@@ -253,7 +253,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
253
253
|
beginGesture: (key) => o().beginGesture?.(key),
|
|
254
254
|
endGesture: () => o().endGesture?.(),
|
|
255
255
|
reveal: () => o().reveal?.(),
|
|
256
|
-
open
|
|
256
|
+
// Only a surface whose options can open things has `open`, so playback skips `open` steps
|
|
257
|
+
// (and their wait) everywhere else. Read per step, like the other options.
|
|
258
|
+
get open() {
|
|
259
|
+
return o().open ? (ref) => o().open?.(ref) : void 0;
|
|
260
|
+
},
|
|
257
261
|
get defaultKind() {
|
|
258
262
|
return o().defaultKind;
|
|
259
263
|
}
|
|
@@ -270,7 +274,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
270
274
|
// src/playback/PresenceLayer.tsx
|
|
271
275
|
var import_react5 = __toESM(require("react"), 1);
|
|
272
276
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
273
|
-
function PresenceLayer({ presence, viewport, className = "" }) {
|
|
277
|
+
function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
274
278
|
const { actors } = (0, import_react5.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
275
279
|
if (!actors.length) return null;
|
|
276
280
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
@@ -280,7 +284,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
|
|
|
280
284
|
className: `pixerate-presence ${className}`.trim(),
|
|
281
285
|
"aria-hidden": "true",
|
|
282
286
|
"data-testid": "presence-layer",
|
|
283
|
-
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
|
|
287
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
|
|
284
288
|
children: actors.map((a) => {
|
|
285
289
|
const at = map(a);
|
|
286
290
|
const ring = a.focus && (() => {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PresenceLayer,
|
|
12
12
|
useAgentPlayback,
|
|
13
13
|
usePlaybackSurface
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-GNO54NFG.js";
|
|
15
15
|
|
|
16
16
|
// src/animation-editor/useAnimationEditor.ts
|
|
17
17
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
@@ -55,18 +55,18 @@ function useAnimationEditor(controllerOrOptions = {}) {
|
|
|
55
55
|
return { controller, state, ...actions };
|
|
56
56
|
}
|
|
57
57
|
function useAnimationEditorTools(registry, controller, options = {}) {
|
|
58
|
-
const { id, namespace, readOnly, rasterize } = options;
|
|
58
|
+
const { id, namespace, readOnly, rasterize, playbackSurface } = options;
|
|
59
59
|
useEffect(() => {
|
|
60
60
|
if (!registry) return;
|
|
61
|
-
return registry.register(createAnimationEditorToolProvider(controller, { id, namespace, readOnly, rasterize }));
|
|
62
|
-
}, [registry, controller, id, namespace, readOnly, rasterize]);
|
|
61
|
+
return registry.register(createAnimationEditorToolProvider(controller, { id, namespace, readOnly, rasterize, playbackSurface }));
|
|
62
|
+
}, [registry, controller, id, namespace, readOnly, rasterize, playbackSurface]);
|
|
63
63
|
}
|
|
64
64
|
function useAnimationEffectsTools(registry, controller, options = {}) {
|
|
65
|
-
const { id, namespace, readOnly } = options;
|
|
65
|
+
const { id, namespace, readOnly, playbackSurface } = options;
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
if (!registry) return;
|
|
68
|
-
return registry.register(createAnimationEffectsToolProvider(controller, { id, namespace, readOnly }));
|
|
69
|
-
}, [registry, controller, id, namespace, readOnly]);
|
|
68
|
+
return registry.register(createAnimationEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
|
|
69
|
+
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// src/animation-editor/AnimationStage.tsx
|
package/dist/canvas/index.cjs
CHANGED
|
@@ -469,7 +469,7 @@ function AgentPresenceLayer({ presences, className = "" }) {
|
|
|
469
469
|
// src/playback/PresenceLayer.tsx
|
|
470
470
|
var import_react = __toESM(require("react"), 1);
|
|
471
471
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
472
|
-
function PresenceLayer({ presence, viewport, className = "" }) {
|
|
472
|
+
function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
473
473
|
const { actors } = (0, import_react.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
474
474
|
if (!actors.length) return null;
|
|
475
475
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
@@ -479,7 +479,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
|
|
|
479
479
|
className: `pixerate-presence ${className}`.trim(),
|
|
480
480
|
"aria-hidden": "true",
|
|
481
481
|
"data-testid": "presence-layer",
|
|
482
|
-
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
|
|
482
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
|
|
483
483
|
children: actors.map((a) => {
|
|
484
484
|
const at = map(a);
|
|
485
485
|
const ring = a.focus && (() => {
|
|
@@ -511,6 +511,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
|
|
|
511
511
|
// src/canvas/useCanvasPlaybackSurface.ts
|
|
512
512
|
var import_react4 = require("react");
|
|
513
513
|
var import_canvas = require("@pixerate/editor/canvas");
|
|
514
|
+
var import_tools2 = require("@pixerate/editor/tools");
|
|
514
515
|
|
|
515
516
|
// src/playback/usePlaybackSurface.ts
|
|
516
517
|
var import_react3 = require("react");
|
|
@@ -545,7 +546,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
545
546
|
beginGesture: (key) => o().beginGesture?.(key),
|
|
546
547
|
endGesture: () => o().endGesture?.(),
|
|
547
548
|
reveal: () => o().reveal?.(),
|
|
548
|
-
open
|
|
549
|
+
// Only a surface whose options can open things has `open`, so playback skips `open` steps
|
|
550
|
+
// (and their wait) everywhere else. Read per step, like the other options.
|
|
551
|
+
get open() {
|
|
552
|
+
return o().open ? (ref) => o().open?.(ref) : void 0;
|
|
553
|
+
},
|
|
549
554
|
get defaultKind() {
|
|
550
555
|
return o().defaultKind;
|
|
551
556
|
}
|
|
@@ -563,7 +568,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
563
568
|
function useCanvasPlaybackSurface(playback, id, options) {
|
|
564
569
|
const latest = (0, import_react4.useRef)(options);
|
|
565
570
|
latest.current = options;
|
|
566
|
-
const
|
|
571
|
+
const locateFlow = (0, import_react4.useMemo)(
|
|
567
572
|
() => (0, import_canvas.createCanvasPlaybackLocator)({
|
|
568
573
|
getNodes: () => latest.current.getNodes(),
|
|
569
574
|
getEdges: () => latest.current.getEdges?.() ?? [],
|
|
@@ -574,9 +579,14 @@ function useCanvasPlaybackSurface(playback, id, options) {
|
|
|
574
579
|
[]
|
|
575
580
|
);
|
|
576
581
|
const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
|
|
582
|
+
const fromViewport = (p) => {
|
|
583
|
+
const r = box();
|
|
584
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
585
|
+
return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
|
|
586
|
+
};
|
|
577
587
|
return usePlaybackSurface(playback, id, {
|
|
578
588
|
defaultKind: "node",
|
|
579
|
-
locate,
|
|
589
|
+
locate: (ref) => locateFlow(ref) ?? (0, import_tools2.locatePlaybackChrome)(ref, latest.current, fromViewport),
|
|
580
590
|
bounds: () => {
|
|
581
591
|
const r = box();
|
|
582
592
|
const { x, y, zoom } = latest.current.viewport;
|
|
@@ -593,12 +603,11 @@ function useCanvasPlaybackSurface(playback, id, options) {
|
|
|
593
603
|
const { x, y, zoom } = latest.current.viewport;
|
|
594
604
|
return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
|
|
595
605
|
},
|
|
596
|
-
fromViewport
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return
|
|
600
|
-
}
|
|
601
|
-
reveal: () => latest.current.reveal?.()
|
|
606
|
+
fromViewport,
|
|
607
|
+
reveal: () => latest.current.reveal?.(),
|
|
608
|
+
get open() {
|
|
609
|
+
return latest.current.open ? (ref) => latest.current.open?.(ref) : void 0;
|
|
610
|
+
}
|
|
602
611
|
});
|
|
603
612
|
}
|
|
604
613
|
|
|
@@ -1415,7 +1424,7 @@ function useCanvasScenes(options = {}) {
|
|
|
1415
1424
|
// src/canvas/useCanvasCapture.ts
|
|
1416
1425
|
var import_react14 = require("react");
|
|
1417
1426
|
var import_canvas9 = require("@pixerate/editor/canvas");
|
|
1418
|
-
var
|
|
1427
|
+
var import_tools3 = require("@pixerate/editor/tools");
|
|
1419
1428
|
function useCanvasCapture(options) {
|
|
1420
1429
|
const optionsRef = (0, import_react14.useRef)(options);
|
|
1421
1430
|
optionsRef.current = options;
|
|
@@ -1432,7 +1441,7 @@ function useCanvasCapture(options) {
|
|
|
1432
1441
|
getViewport: () => latest().getViewport(),
|
|
1433
1442
|
getNodes: () => latest().getNodes(),
|
|
1434
1443
|
getNodeRect: (node, nodes) => (latest().getNodeRect ?? import_canvas9.canvasNodeCaptureRect)(node, nodes),
|
|
1435
|
-
rasterize: (element, raster) => (latest().rasterize ??
|
|
1444
|
+
rasterize: (element, raster) => (latest().rasterize ?? import_tools3.rasterizeElement)(element, raster)
|
|
1436
1445
|
});
|
|
1437
1446
|
}, [options.id, options.namespace]);
|
|
1438
1447
|
}
|
package/dist/canvas/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import "../chunk-3I7FOSLF.js";
|
|
|
9
9
|
import {
|
|
10
10
|
PresenceLayer,
|
|
11
11
|
usePlaybackSurface
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-GNO54NFG.js";
|
|
13
13
|
|
|
14
14
|
// src/canvas/AgentPresenceLayer.tsx
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -78,10 +78,11 @@ function AgentPresenceLayer({ presences, className = "" }) {
|
|
|
78
78
|
// src/canvas/useCanvasPlaybackSurface.ts
|
|
79
79
|
import { useMemo, useRef } from "react";
|
|
80
80
|
import { createCanvasPlaybackLocator } from "@pixerate/editor/canvas";
|
|
81
|
+
import { locatePlaybackChrome } from "@pixerate/editor/tools";
|
|
81
82
|
function useCanvasPlaybackSurface(playback, id, options) {
|
|
82
83
|
const latest = useRef(options);
|
|
83
84
|
latest.current = options;
|
|
84
|
-
const
|
|
85
|
+
const locateFlow = useMemo(
|
|
85
86
|
() => createCanvasPlaybackLocator({
|
|
86
87
|
getNodes: () => latest.current.getNodes(),
|
|
87
88
|
getEdges: () => latest.current.getEdges?.() ?? [],
|
|
@@ -92,9 +93,14 @@ function useCanvasPlaybackSurface(playback, id, options) {
|
|
|
92
93
|
[]
|
|
93
94
|
);
|
|
94
95
|
const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
|
|
96
|
+
const fromViewport = (p) => {
|
|
97
|
+
const r = box();
|
|
98
|
+
const { x, y, zoom } = latest.current.viewport;
|
|
99
|
+
return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
|
|
100
|
+
};
|
|
95
101
|
return usePlaybackSurface(playback, id, {
|
|
96
102
|
defaultKind: "node",
|
|
97
|
-
locate,
|
|
103
|
+
locate: (ref) => locateFlow(ref) ?? locatePlaybackChrome(ref, latest.current, fromViewport),
|
|
98
104
|
bounds: () => {
|
|
99
105
|
const r = box();
|
|
100
106
|
const { x, y, zoom } = latest.current.viewport;
|
|
@@ -111,12 +117,11 @@ function useCanvasPlaybackSurface(playback, id, options) {
|
|
|
111
117
|
const { x, y, zoom } = latest.current.viewport;
|
|
112
118
|
return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
|
|
113
119
|
},
|
|
114
|
-
fromViewport
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
reveal: () => latest.current.reveal?.()
|
|
120
|
+
fromViewport,
|
|
121
|
+
reveal: () => latest.current.reveal?.(),
|
|
122
|
+
get open() {
|
|
123
|
+
return latest.current.open ? (ref) => latest.current.open?.(ref) : void 0;
|
|
124
|
+
}
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
import { type CanvasEdge, type CanvasNode, type NodeRectOptions } from '@pixerate/editor/canvas';
|
|
3
|
-
import type
|
|
4
|
-
|
|
3
|
+
import { type AgentPlayback, type PlaybackChromeOptions, type PresenceStore } from '@pixerate/editor/tools';
|
|
4
|
+
/**
|
|
5
|
+
* `locate`, `locateElement` and `open` (see `PlaybackChromeOptions`) let the host's own chrome over
|
|
6
|
+
* the canvas (a HUD, toolbar or panels) answer refs the canvas does not find, such as
|
|
7
|
+
* `{ kind: 'panel' | 'control', id }`: `locate` in flow coordinates, `locateElement` as an element
|
|
8
|
+
* whose client box is mapped into flow coordinates through the viewport.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> extends PlaybackChromeOptions {
|
|
5
11
|
/** The flow's nodes and edges now (e.g. React Flow's `getNodes` / `getEdges`). */
|
|
6
12
|
getNodes: () => readonly TNode[];
|
|
7
13
|
getEdges?: () => readonly TEdge[];
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
2
|
import { type CanvasEdge, type CanvasNode, type NodeRectOptions } from '@pixerate/editor/canvas';
|
|
3
|
-
import type
|
|
4
|
-
|
|
3
|
+
import { type AgentPlayback, type PlaybackChromeOptions, type PresenceStore } from '@pixerate/editor/tools';
|
|
4
|
+
/**
|
|
5
|
+
* `locate`, `locateElement` and `open` (see `PlaybackChromeOptions`) let the host's own chrome over
|
|
6
|
+
* the canvas (a HUD, toolbar or panels) answer refs the canvas does not find, such as
|
|
7
|
+
* `{ kind: 'panel' | 'control', id }`: `locate` in flow coordinates, `locateElement` as an element
|
|
8
|
+
* whose client box is mapped into flow coordinates through the viewport.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> extends PlaybackChromeOptions {
|
|
5
11
|
/** The flow's nodes and edges now (e.g. React Flow's `getNodes` / `getEdges`). */
|
|
6
12
|
getNodes: () => readonly TNode[];
|
|
7
13
|
getEdges?: () => readonly TEdge[];
|
package/dist/chart/index.cjs
CHANGED
|
@@ -100,12 +100,12 @@ function useChartCommands(registry, controller, options = {}) {
|
|
|
100
100
|
function useChartToolProvider(registry, controller, options = {}) {
|
|
101
101
|
const latest = (0, import_react.useRef)(options);
|
|
102
102
|
latest.current = options;
|
|
103
|
-
const { id, namespace } = options;
|
|
103
|
+
const { id, namespace, playbackSurface } = options;
|
|
104
104
|
(0, import_react.useEffect)(() => {
|
|
105
105
|
if (!registry) return;
|
|
106
106
|
const { rasterize, ...rest } = latest.current;
|
|
107
|
-
return registry.register((0, import_chart.createChartToolProvider)(controller, { ...rest, id, namespace, rasterize: rasterize === false ? void 0 : rasterize ?? (0, import_chart.createChartRasterizer)() }));
|
|
108
|
-
}, [registry, controller, id, namespace]);
|
|
107
|
+
return registry.register((0, import_chart.createChartToolProvider)(controller, { ...rest, id, namespace, playbackSurface, rasterize: rasterize === false ? void 0 : rasterize ?? (0, import_chart.createChartRasterizer)() }));
|
|
108
|
+
}, [registry, controller, id, namespace, playbackSurface]);
|
|
109
109
|
}
|
|
110
110
|
function useOfficeChartToolProvider(registry, options = {}) {
|
|
111
111
|
const latest = (0, import_react.useRef)(options);
|
|
@@ -818,7 +818,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
818
818
|
beginGesture: (key) => o().beginGesture?.(key),
|
|
819
819
|
endGesture: () => o().endGesture?.(),
|
|
820
820
|
reveal: () => o().reveal?.(),
|
|
821
|
-
open
|
|
821
|
+
// Only a surface whose options can open things has `open`, so playback skips `open` steps
|
|
822
|
+
// (and their wait) everywhere else. Read per step, like the other options.
|
|
823
|
+
get open() {
|
|
824
|
+
return o().open ? (ref) => o().open?.(ref) : void 0;
|
|
825
|
+
},
|
|
822
826
|
get defaultKind() {
|
|
823
827
|
return o().defaultKind;
|
|
824
828
|
}
|
|
@@ -835,7 +839,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
835
839
|
// src/playback/PresenceLayer.tsx
|
|
836
840
|
var import_react7 = __toESM(require("react"), 1);
|
|
837
841
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
838
|
-
function PresenceLayer({ presence, viewport, className = "" }) {
|
|
842
|
+
function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
839
843
|
const { actors } = (0, import_react7.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
840
844
|
if (!actors.length) return null;
|
|
841
845
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
@@ -845,7 +849,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
|
|
|
845
849
|
className: `pixerate-presence ${className}`.trim(),
|
|
846
850
|
"aria-hidden": "true",
|
|
847
851
|
"data-testid": "presence-layer",
|
|
848
|
-
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
|
|
852
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
|
|
849
853
|
children: actors.map((a) => {
|
|
850
854
|
const at = map(a);
|
|
851
855
|
const ring = a.focus && (() => {
|
package/dist/chart/index.js
CHANGED
|
@@ -20,12 +20,12 @@ import {
|
|
|
20
20
|
useChartState,
|
|
21
21
|
useChartToolProvider,
|
|
22
22
|
useOfficeChartToolProvider
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-GDPWLGPD.js";
|
|
24
24
|
import {
|
|
25
25
|
PresenceLayer,
|
|
26
26
|
useAgentPlayback,
|
|
27
27
|
usePlaybackSurface
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-GNO54NFG.js";
|
|
29
29
|
|
|
30
30
|
// src/chart/ChartEditor.tsx
|
|
31
31
|
import { useRef, useState } from "react";
|