@pixerate/editor-react 0.209.1 → 0.210.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.
- package/dist/canvas/index.cjs +4 -0
- package/dist/canvas/index.js +4 -0
- package/dist/canvas/useCanvasCapture.d.cts +2 -1
- package/dist/canvas/useCanvasCapture.d.ts +2 -1
- package/dist/hooks/useTextProposals.d.cts +47 -0
- package/dist/hooks/useTextProposals.d.ts +47 -0
- package/dist/index.cjs +838 -768
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +150 -79
- package/package.json +3 -3
package/dist/canvas/index.cjs
CHANGED
|
@@ -1528,6 +1528,10 @@ function useCanvasCapture(options) {
|
|
|
1528
1528
|
},
|
|
1529
1529
|
getViewport: () => latest().getViewport(),
|
|
1530
1530
|
getNodes: () => latest().getNodes(),
|
|
1531
|
+
layers: () => {
|
|
1532
|
+
const layers = latest().layers;
|
|
1533
|
+
return (typeof layers === "function" ? layers() : layers) ?? [];
|
|
1534
|
+
},
|
|
1531
1535
|
getNodeRect: (node, nodes) => (latest().getNodeRect ?? import_canvas10.canvasNodeCaptureRect)(node, nodes),
|
|
1532
1536
|
rasterize: (element, raster) => (latest().rasterize ?? import_tools3.rasterizeElement)(element, raster)
|
|
1533
1537
|
});
|
package/dist/canvas/index.js
CHANGED
|
@@ -1050,6 +1050,10 @@ function useCanvasCapture(options) {
|
|
|
1050
1050
|
},
|
|
1051
1051
|
getViewport: () => latest().getViewport(),
|
|
1052
1052
|
getNodes: () => latest().getNodes(),
|
|
1053
|
+
layers: () => {
|
|
1054
|
+
const layers = latest().layers;
|
|
1055
|
+
return (typeof layers === "function" ? layers() : layers) ?? [];
|
|
1056
|
+
},
|
|
1053
1057
|
getNodeRect: (node, nodes) => (latest().getNodeRect ?? canvasNodeCaptureRect)(node, nodes),
|
|
1054
1058
|
rasterize: (element, raster) => (latest().rasterize ?? rasterizeElement)(element, raster)
|
|
1055
1059
|
});
|
|
@@ -8,7 +8,8 @@ export interface UseCanvasCaptureOptions<TNode extends CanvasNode = CanvasNode>
|
|
|
8
8
|
/**
|
|
9
9
|
* The `capture_view` agent tool for a React Flow canvas: screenshots of the viewport, all
|
|
10
10
|
* content, the selection, nodes by id or a rect in canvas units. Register the result with
|
|
11
|
-
* `useAgentToolProvider`.
|
|
11
|
+
* `useAgentToolProvider`. Pass `layers` for ink or paint drawn outside the flow's viewport, so
|
|
12
|
+
* `content` frames their strokes too. The provider stays the same object across renders (it reads the
|
|
12
13
|
* latest options on each call) and changes only with `id` / `namespace`.
|
|
13
14
|
*
|
|
14
15
|
* ```tsx
|
|
@@ -8,7 +8,8 @@ export interface UseCanvasCaptureOptions<TNode extends CanvasNode = CanvasNode>
|
|
|
8
8
|
/**
|
|
9
9
|
* The `capture_view` agent tool for a React Flow canvas: screenshots of the viewport, all
|
|
10
10
|
* content, the selection, nodes by id or a rect in canvas units. Register the result with
|
|
11
|
-
* `useAgentToolProvider`.
|
|
11
|
+
* `useAgentToolProvider`. Pass `layers` for ink or paint drawn outside the flow's viewport, so
|
|
12
|
+
* `content` frames their strokes too. The provider stays the same object across renders (it reads the
|
|
12
13
|
* latest options on each call) and changes only with `id` / `namespace`.
|
|
13
14
|
*
|
|
14
15
|
* ```tsx
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type TextChange, type TextChangeFeed, type TextProposal, type TextProposals, type TextProposalsOptions, type TextSelection } from '@pixerate/editor/tools';
|
|
2
|
+
import type { HistoryCommitEvent } from '@pixerate/editor/history';
|
|
3
|
+
export interface UseTextProposalsOptions extends Pick<TextProposalsOptions, 'applyEdit' | 'origin' | 'readOnly' | 'idGenerator' | 'now'> {
|
|
4
|
+
/** The text as it is now. Proposals follow it on each render. */
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TextProposalsHandle {
|
|
8
|
+
/** The framework-free store (for `createTextProposalToolProvider` and agents). */
|
|
9
|
+
readonly store: TextProposals;
|
|
10
|
+
/** Pending proposals, with their current ranges. */
|
|
11
|
+
proposals: readonly TextProposal[];
|
|
12
|
+
propose: TextProposals['propose'];
|
|
13
|
+
accept: TextProposals['accept'];
|
|
14
|
+
reject: TextProposals['reject'];
|
|
15
|
+
clear: TextProposals['clear'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Agent-suggested replacements for a text held in React state: suggestions the person accepts
|
|
19
|
+
* (one undo step made by the proposer, through `applyEdit`) or dismisses. Proposals move as the
|
|
20
|
+
* person writes before them and are dropped when they edit the text a proposal would replace.
|
|
21
|
+
* The same API as the Svelte `createTextProposalState`. The options are read when used.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useTextProposals(options: UseTextProposalsOptions): TextProposalsHandle;
|
|
24
|
+
export interface UseTextChangeFeedOptions {
|
|
25
|
+
/** The text as it is now. */
|
|
26
|
+
text: string;
|
|
27
|
+
/** The selection, when the host has one (a caret is `from === to`). */
|
|
28
|
+
selection?: TextSelection | null;
|
|
29
|
+
/** The text's history, for each change's origin (`user` or `agent:<id>`). Pass a stable one. */
|
|
30
|
+
history?: {
|
|
31
|
+
onCommit(listener: (event: HistoryCommitEvent) => void): () => void;
|
|
32
|
+
};
|
|
33
|
+
/** How long the person must stop typing for their burst to end (ms, default 1500; 0: no bursts). Read once. */
|
|
34
|
+
burstMs?: number;
|
|
35
|
+
/** Called with each change, after the render that shows it, and when a typing burst ends. */
|
|
36
|
+
onChange?: (change: TextChange) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What changed in a text held in React state, after each render: the range, what it held and
|
|
40
|
+
* what replaced it, the selection, who made it, word and line boundaries, and when a typing
|
|
41
|
+
* burst ends. For agents that follow what the person writes. Returns the latest change and the
|
|
42
|
+
* feed. The same API as the Svelte `createTextChangeWatcher`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useTextChangeFeed(options: UseTextChangeFeedOptions): {
|
|
45
|
+
feed: TextChangeFeed;
|
|
46
|
+
last: TextChange | null;
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type TextChange, type TextChangeFeed, type TextProposal, type TextProposals, type TextProposalsOptions, type TextSelection } from '@pixerate/editor/tools';
|
|
2
|
+
import type { HistoryCommitEvent } from '@pixerate/editor/history';
|
|
3
|
+
export interface UseTextProposalsOptions extends Pick<TextProposalsOptions, 'applyEdit' | 'origin' | 'readOnly' | 'idGenerator' | 'now'> {
|
|
4
|
+
/** The text as it is now. Proposals follow it on each render. */
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TextProposalsHandle {
|
|
8
|
+
/** The framework-free store (for `createTextProposalToolProvider` and agents). */
|
|
9
|
+
readonly store: TextProposals;
|
|
10
|
+
/** Pending proposals, with their current ranges. */
|
|
11
|
+
proposals: readonly TextProposal[];
|
|
12
|
+
propose: TextProposals['propose'];
|
|
13
|
+
accept: TextProposals['accept'];
|
|
14
|
+
reject: TextProposals['reject'];
|
|
15
|
+
clear: TextProposals['clear'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Agent-suggested replacements for a text held in React state: suggestions the person accepts
|
|
19
|
+
* (one undo step made by the proposer, through `applyEdit`) or dismisses. Proposals move as the
|
|
20
|
+
* person writes before them and are dropped when they edit the text a proposal would replace.
|
|
21
|
+
* The same API as the Svelte `createTextProposalState`. The options are read when used.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useTextProposals(options: UseTextProposalsOptions): TextProposalsHandle;
|
|
24
|
+
export interface UseTextChangeFeedOptions {
|
|
25
|
+
/** The text as it is now. */
|
|
26
|
+
text: string;
|
|
27
|
+
/** The selection, when the host has one (a caret is `from === to`). */
|
|
28
|
+
selection?: TextSelection | null;
|
|
29
|
+
/** The text's history, for each change's origin (`user` or `agent:<id>`). Pass a stable one. */
|
|
30
|
+
history?: {
|
|
31
|
+
onCommit(listener: (event: HistoryCommitEvent) => void): () => void;
|
|
32
|
+
};
|
|
33
|
+
/** How long the person must stop typing for their burst to end (ms, default 1500; 0: no bursts). Read once. */
|
|
34
|
+
burstMs?: number;
|
|
35
|
+
/** Called with each change, after the render that shows it, and when a typing burst ends. */
|
|
36
|
+
onChange?: (change: TextChange) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What changed in a text held in React state, after each render: the range, what it held and
|
|
40
|
+
* what replaced it, the selection, who made it, word and line boundaries, and when a typing
|
|
41
|
+
* burst ends. For agents that follow what the person writes. Returns the latest change and the
|
|
42
|
+
* feed. The same API as the Svelte `createTextChangeWatcher`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useTextChangeFeed(options: UseTextChangeFeedOptions): {
|
|
45
|
+
feed: TextChangeFeed;
|
|
46
|
+
last: TextChange | null;
|
|
47
|
+
};
|