@pixerate/editor 0.59.0 → 0.61.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/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/agent/index.cjs +111 -38
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +30 -2
- package/dist/agent/index.d.ts +30 -2
- package/dist/agent/index.js +96 -23
- package/dist/agent/index.js.map +1 -1
- package/dist/agent-caret-BmYhQF7L.d.cts +106 -0
- package/dist/agent-caret-BmYhQF7L.d.ts +106 -0
- package/dist/animation-editor/index.cjs +197 -82
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +136 -3
- package/dist/animation-editor/index.d.ts +136 -3
- package/dist/animation-editor/index.js +163 -48
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{chunk-LMUDHBWR.js → chunk-4YFMSPBU.js} +2 -2
- package/dist/{chunk-3I6V7PI4.cjs → chunk-7ZSU4MQZ.cjs} +45 -45
- package/dist/{chunk-3I6V7PI4.cjs.map → chunk-7ZSU4MQZ.cjs.map} +1 -1
- package/dist/{chunk-WLVZ235X.js → chunk-OK7T2LHK.js} +229 -2
- package/dist/chunk-OK7T2LHK.js.map +1 -0
- package/dist/{chunk-AHCENCU4.cjs → chunk-T4XWVPJK.cjs} +253 -26
- package/dist/chunk-T4XWVPJK.cjs.map +1 -0
- package/dist/extensions/index.cjs +27 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +2 -1
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/index.js +26 -2
- package/dist/{index-CTCc3m3C.d.ts → index-B16wbOn_.d.ts} +1 -0
- package/dist/{index-BcHyG0Wq.d.cts → index-BAt14aIU.d.cts} +1 -0
- package/dist/index.cjs +32 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHCENCU4.cjs.map +0 -1
- package/dist/chunk-WLVZ235X.js.map +0 -1
- /package/dist/{chunk-LMUDHBWR.js.map → chunk-4YFMSPBU.js.map} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Extension, Editor } from '@tiptap/core';
|
|
2
|
+
import { PluginKey, Plugin, EditorState, Transaction } from '@tiptap/pm/state';
|
|
3
|
+
import { DecorationSet } from '@tiptap/pm/view';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Inline agent carets: a coloured caret with a name tag at a document position, the agent's
|
|
7
|
+
* selection highlighted, and the text it just changed tinted for a moment — as collaborators'
|
|
8
|
+
* cursors look in Google Docs. Decorations, so they follow the text as anyone edits it.
|
|
9
|
+
*
|
|
10
|
+
* `typeAgentText` plays an edit out a few characters at a time and still lands it as one undo step.
|
|
11
|
+
*/
|
|
12
|
+
declare const DEFAULT_AGENT_CARET_COLOR = "#8b5cf6";
|
|
13
|
+
declare const DEFAULT_AGENT_CARET_NAME = "Agent";
|
|
14
|
+
interface AgentCaretInput {
|
|
15
|
+
/** Stable id of the agent (one caret per id). */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Name on the caret's tag (default "Agent"). */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** CSS colour of the caret, tag and highlights (default violet). */
|
|
20
|
+
color?: string;
|
|
21
|
+
/** Selection anchor (document position). */
|
|
22
|
+
from: number;
|
|
23
|
+
/** Selection head, where the caret is drawn (default `from`). */
|
|
24
|
+
to?: number;
|
|
25
|
+
}
|
|
26
|
+
/** A range an agent is typing into, mapped through everyone's edits (see `typeAgentText`). */
|
|
27
|
+
interface TypingSpan {
|
|
28
|
+
from: number;
|
|
29
|
+
to: number;
|
|
30
|
+
/** Someone else changed the document while the agent typed. */
|
|
31
|
+
foreign: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface AgentCaretState {
|
|
34
|
+
carets: AgentCaret[];
|
|
35
|
+
spans: Record<string, TypingSpan>;
|
|
36
|
+
decorations: DecorationSet;
|
|
37
|
+
}
|
|
38
|
+
declare const agentCaretPluginKey: PluginKey<AgentCaretState>;
|
|
39
|
+
/** The ProseMirror plugin behind `AgentCaret` (one per editor). */
|
|
40
|
+
declare function createAgentCaretPlugin(): Plugin<AgentCaretState>;
|
|
41
|
+
interface AgentCaret {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
color: string;
|
|
45
|
+
anchor: number;
|
|
46
|
+
head: number;
|
|
47
|
+
/** Ranges the agent just changed, tinted until `clearAgentChanges`. */
|
|
48
|
+
changed: Array<{
|
|
49
|
+
from: number;
|
|
50
|
+
to: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** TipTap extension drawing agent carets. Optional: the helpers below add the plugin when it's missing. */
|
|
54
|
+
declare const AgentCaret: Extension<any, any>;
|
|
55
|
+
/** Adds the agent caret plugin to a mounted editor that wasn't created with `AgentCaret`. */
|
|
56
|
+
declare function ensureAgentCaret(editor: Editor): void;
|
|
57
|
+
/** Shows (or moves) an agent's caret; `from < to` also highlights its selection. */
|
|
58
|
+
declare function setAgentCaret(editor: Editor, caret: AgentCaretInput): void;
|
|
59
|
+
/** Removes one agent's caret, or every agent caret when `id` is omitted. */
|
|
60
|
+
declare function clearAgentCaret(editor: Editor, id?: string): void;
|
|
61
|
+
/** Tints ranges an agent just changed (replacing its previous ones); `[]` clears them. */
|
|
62
|
+
declare function markAgentChanges(editor: Editor, id: string, ranges: Array<{
|
|
63
|
+
from: number;
|
|
64
|
+
to: number;
|
|
65
|
+
}>): void;
|
|
66
|
+
/** The agent carets in an editor state (empty when the plugin isn't installed). */
|
|
67
|
+
declare function getAgentCarets(state: EditorState): AgentCaret[];
|
|
68
|
+
/**
|
|
69
|
+
* A transaction replacing `from..to` with literal text (HTML is not parsed; newlines split
|
|
70
|
+
* paragraphs), as the rich-text agent tools write it.
|
|
71
|
+
*/
|
|
72
|
+
declare function replaceWithTextTransaction(state: EditorState, from: number, to: number, text: string): Transaction;
|
|
73
|
+
interface AgentTypingOptions {
|
|
74
|
+
/** Typing speed in characters per second (default 60). */
|
|
75
|
+
charsPerSecond?: number;
|
|
76
|
+
/** Longest a single edit takes to type, in ms; longer text types faster (default 1500). */
|
|
77
|
+
maxDurationMs?: number;
|
|
78
|
+
/** How long a replaced range stays highlighted before typing starts, in ms (default 250). */
|
|
79
|
+
selectMs?: number;
|
|
80
|
+
}
|
|
81
|
+
interface TypeAgentTextOptions extends AgentTypingOptions {
|
|
82
|
+
from: number;
|
|
83
|
+
to: number;
|
|
84
|
+
text: string;
|
|
85
|
+
/** The agent's caret, drawn where it types. */
|
|
86
|
+
caret: Omit<AgentCaretInput, "from" | "to">;
|
|
87
|
+
/** Stops typing and leaves the document as it was. */
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
/** Waits between frames (default `setTimeout`; injectable for tests). */
|
|
90
|
+
wait?: (ms: number) => Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Replaces `from..to` with `text` while the agent's caret types it out, then commits the edit as
|
|
94
|
+
* ONE undo step (the frames are kept out of history, rolled back and replaced by a single
|
|
95
|
+
* transaction in the same tick, so the screen never shows the rollback). Without a visible window,
|
|
96
|
+
* or with `charsPerSecond: Infinity`, the edit applies at once. Returns the inserted range.
|
|
97
|
+
*
|
|
98
|
+
* If the signal aborts or the editor is destroyed mid-way, the typed frames are rolled back and
|
|
99
|
+
* the promise rejects; nothing partial stays in the document.
|
|
100
|
+
*/
|
|
101
|
+
declare function typeAgentText(editor: Editor, options: TypeAgentTextOptions): Promise<{
|
|
102
|
+
from: number;
|
|
103
|
+
to: number;
|
|
104
|
+
}>;
|
|
105
|
+
|
|
106
|
+
export { type AgentTypingOptions as A, DEFAULT_AGENT_CARET_COLOR as D, type TypeAgentTextOptions as T, AgentCaret as a, type AgentCaretInput as b, DEFAULT_AGENT_CARET_NAME as c, agentCaretPluginKey as d, clearAgentCaret as e, createAgentCaretPlugin as f, ensureAgentCaret as g, getAgentCarets as h, markAgentChanges as m, replaceWithTextTransaction as r, setAgentCaret as s, typeAgentText as t };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Extension, Editor } from '@tiptap/core';
|
|
2
|
+
import { PluginKey, Plugin, EditorState, Transaction } from '@tiptap/pm/state';
|
|
3
|
+
import { DecorationSet } from '@tiptap/pm/view';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Inline agent carets: a coloured caret with a name tag at a document position, the agent's
|
|
7
|
+
* selection highlighted, and the text it just changed tinted for a moment — as collaborators'
|
|
8
|
+
* cursors look in Google Docs. Decorations, so they follow the text as anyone edits it.
|
|
9
|
+
*
|
|
10
|
+
* `typeAgentText` plays an edit out a few characters at a time and still lands it as one undo step.
|
|
11
|
+
*/
|
|
12
|
+
declare const DEFAULT_AGENT_CARET_COLOR = "#8b5cf6";
|
|
13
|
+
declare const DEFAULT_AGENT_CARET_NAME = "Agent";
|
|
14
|
+
interface AgentCaretInput {
|
|
15
|
+
/** Stable id of the agent (one caret per id). */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Name on the caret's tag (default "Agent"). */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** CSS colour of the caret, tag and highlights (default violet). */
|
|
20
|
+
color?: string;
|
|
21
|
+
/** Selection anchor (document position). */
|
|
22
|
+
from: number;
|
|
23
|
+
/** Selection head, where the caret is drawn (default `from`). */
|
|
24
|
+
to?: number;
|
|
25
|
+
}
|
|
26
|
+
/** A range an agent is typing into, mapped through everyone's edits (see `typeAgentText`). */
|
|
27
|
+
interface TypingSpan {
|
|
28
|
+
from: number;
|
|
29
|
+
to: number;
|
|
30
|
+
/** Someone else changed the document while the agent typed. */
|
|
31
|
+
foreign: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface AgentCaretState {
|
|
34
|
+
carets: AgentCaret[];
|
|
35
|
+
spans: Record<string, TypingSpan>;
|
|
36
|
+
decorations: DecorationSet;
|
|
37
|
+
}
|
|
38
|
+
declare const agentCaretPluginKey: PluginKey<AgentCaretState>;
|
|
39
|
+
/** The ProseMirror plugin behind `AgentCaret` (one per editor). */
|
|
40
|
+
declare function createAgentCaretPlugin(): Plugin<AgentCaretState>;
|
|
41
|
+
interface AgentCaret {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
color: string;
|
|
45
|
+
anchor: number;
|
|
46
|
+
head: number;
|
|
47
|
+
/** Ranges the agent just changed, tinted until `clearAgentChanges`. */
|
|
48
|
+
changed: Array<{
|
|
49
|
+
from: number;
|
|
50
|
+
to: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** TipTap extension drawing agent carets. Optional: the helpers below add the plugin when it's missing. */
|
|
54
|
+
declare const AgentCaret: Extension<any, any>;
|
|
55
|
+
/** Adds the agent caret plugin to a mounted editor that wasn't created with `AgentCaret`. */
|
|
56
|
+
declare function ensureAgentCaret(editor: Editor): void;
|
|
57
|
+
/** Shows (or moves) an agent's caret; `from < to` also highlights its selection. */
|
|
58
|
+
declare function setAgentCaret(editor: Editor, caret: AgentCaretInput): void;
|
|
59
|
+
/** Removes one agent's caret, or every agent caret when `id` is omitted. */
|
|
60
|
+
declare function clearAgentCaret(editor: Editor, id?: string): void;
|
|
61
|
+
/** Tints ranges an agent just changed (replacing its previous ones); `[]` clears them. */
|
|
62
|
+
declare function markAgentChanges(editor: Editor, id: string, ranges: Array<{
|
|
63
|
+
from: number;
|
|
64
|
+
to: number;
|
|
65
|
+
}>): void;
|
|
66
|
+
/** The agent carets in an editor state (empty when the plugin isn't installed). */
|
|
67
|
+
declare function getAgentCarets(state: EditorState): AgentCaret[];
|
|
68
|
+
/**
|
|
69
|
+
* A transaction replacing `from..to` with literal text (HTML is not parsed; newlines split
|
|
70
|
+
* paragraphs), as the rich-text agent tools write it.
|
|
71
|
+
*/
|
|
72
|
+
declare function replaceWithTextTransaction(state: EditorState, from: number, to: number, text: string): Transaction;
|
|
73
|
+
interface AgentTypingOptions {
|
|
74
|
+
/** Typing speed in characters per second (default 60). */
|
|
75
|
+
charsPerSecond?: number;
|
|
76
|
+
/** Longest a single edit takes to type, in ms; longer text types faster (default 1500). */
|
|
77
|
+
maxDurationMs?: number;
|
|
78
|
+
/** How long a replaced range stays highlighted before typing starts, in ms (default 250). */
|
|
79
|
+
selectMs?: number;
|
|
80
|
+
}
|
|
81
|
+
interface TypeAgentTextOptions extends AgentTypingOptions {
|
|
82
|
+
from: number;
|
|
83
|
+
to: number;
|
|
84
|
+
text: string;
|
|
85
|
+
/** The agent's caret, drawn where it types. */
|
|
86
|
+
caret: Omit<AgentCaretInput, "from" | "to">;
|
|
87
|
+
/** Stops typing and leaves the document as it was. */
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
/** Waits between frames (default `setTimeout`; injectable for tests). */
|
|
90
|
+
wait?: (ms: number) => Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Replaces `from..to` with `text` while the agent's caret types it out, then commits the edit as
|
|
94
|
+
* ONE undo step (the frames are kept out of history, rolled back and replaced by a single
|
|
95
|
+
* transaction in the same tick, so the screen never shows the rollback). Without a visible window,
|
|
96
|
+
* or with `charsPerSecond: Infinity`, the edit applies at once. Returns the inserted range.
|
|
97
|
+
*
|
|
98
|
+
* If the signal aborts or the editor is destroyed mid-way, the typed frames are rolled back and
|
|
99
|
+
* the promise rejects; nothing partial stays in the document.
|
|
100
|
+
*/
|
|
101
|
+
declare function typeAgentText(editor: Editor, options: TypeAgentTextOptions): Promise<{
|
|
102
|
+
from: number;
|
|
103
|
+
to: number;
|
|
104
|
+
}>;
|
|
105
|
+
|
|
106
|
+
export { type AgentTypingOptions as A, DEFAULT_AGENT_CARET_COLOR as D, type TypeAgentTextOptions as T, AgentCaret as a, type AgentCaretInput as b, DEFAULT_AGENT_CARET_NAME as c, agentCaretPluginKey as d, clearAgentCaret as e, createAgentCaretPlugin as f, ensureAgentCaret as g, getAgentCarets as h, markAgentChanges as m, replaceWithTextTransaction as r, setAgentCaret as s, typeAgentText as t };
|