@pixerate/editor-react 0.209.1 → 0.210.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/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
|
@@ -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
|
+
};
|