@pixerate/editor 0.23.0 → 0.25.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.
Files changed (187) hide show
  1. package/README.md +167 -2
  2. package/THIRD_PARTY_NOTICES.md +80 -0
  3. package/dist/agent/index.cjs +10 -8
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +4 -3
  6. package/dist/agent/index.d.ts +4 -3
  7. package/dist/agent/index.js +4 -2
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/canvas/index.cjs +4437 -411
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.d.cts +934 -4
  12. package/dist/canvas/index.d.ts +934 -4
  13. package/dist/canvas/index.js +4309 -283
  14. package/dist/canvas/index.js.map +1 -1
  15. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  16. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  17. package/dist/chunk-664LQYFJ.js +115 -0
  18. package/dist/chunk-664LQYFJ.js.map +1 -0
  19. package/dist/chunk-7WISYZFO.cjs +740 -0
  20. package/dist/chunk-7WISYZFO.cjs.map +1 -0
  21. package/dist/chunk-AL6JMGWW.cjs +783 -0
  22. package/dist/chunk-AL6JMGWW.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-RIKBJLS2.cjs → chunk-C7P22VIP.cjs} +2001 -279
  26. package/dist/chunk-C7P22VIP.cjs.map +1 -0
  27. package/dist/chunk-D6FH2YAX.cjs +131 -0
  28. package/dist/chunk-D6FH2YAX.cjs.map +1 -0
  29. package/dist/chunk-ECCCYKGL.js +740 -0
  30. package/dist/chunk-ECCCYKGL.js.map +1 -0
  31. package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
  32. package/dist/chunk-FD4LPFAE.cjs.map +1 -0
  33. package/dist/{chunk-QBJ22YZR.js → chunk-FH6F67DN.js} +1999 -277
  34. package/dist/chunk-FH6F67DN.js.map +1 -0
  35. package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
  36. package/dist/chunk-FPENXAEJ.js.map +1 -0
  37. package/dist/chunk-HLIMTC6N.js +1 -0
  38. package/dist/chunk-HLIMTC6N.js.map +1 -0
  39. package/dist/chunk-HRMEDT2L.js +1406 -0
  40. package/dist/chunk-HRMEDT2L.js.map +1 -0
  41. package/dist/{chunk-QGHGJ56O.js → chunk-IXHSYOVY.js} +2518 -122
  42. package/dist/chunk-IXHSYOVY.js.map +1 -0
  43. package/dist/chunk-MKA3AHLV.cjs +256 -0
  44. package/dist/chunk-MKA3AHLV.cjs.map +1 -0
  45. package/dist/chunk-NAXVVS5I.js +783 -0
  46. package/dist/chunk-NAXVVS5I.js.map +1 -0
  47. package/dist/chunk-O5RYH2PG.js +69 -0
  48. package/dist/chunk-O5RYH2PG.js.map +1 -0
  49. package/dist/chunk-OXSV64JX.js +689 -0
  50. package/dist/chunk-OXSV64JX.js.map +1 -0
  51. package/dist/chunk-P3RQ5UJE.cjs +689 -0
  52. package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
  53. package/dist/chunk-P6ODPZ4W.js +256 -0
  54. package/dist/chunk-P6ODPZ4W.js.map +1 -0
  55. package/dist/chunk-PL4JB3BF.cjs +1 -0
  56. package/dist/chunk-PL4JB3BF.cjs.map +1 -0
  57. package/dist/{chunk-GVSMRPHB.cjs → chunk-PO6A6QQH.cjs} +2607 -211
  58. package/dist/chunk-PO6A6QQH.cjs.map +1 -0
  59. package/dist/{chunk-JJDLPEWL.js → chunk-QGYDWPRM.js} +2 -2
  60. package/dist/chunk-RR7F5GUM.js +5726 -0
  61. package/dist/chunk-RR7F5GUM.js.map +1 -0
  62. package/dist/chunk-TNNJXF46.cjs +115 -0
  63. package/dist/chunk-TNNJXF46.cjs.map +1 -0
  64. package/dist/chunk-U5HZSFCS.js +131 -0
  65. package/dist/chunk-U5HZSFCS.js.map +1 -0
  66. package/dist/{chunk-MJZBNWG7.js → chunk-UAKDG62Z.js} +309 -581
  67. package/dist/chunk-UAKDG62Z.js.map +1 -0
  68. package/dist/{chunk-CL37JGFW.cjs → chunk-V3CHHWOE.cjs} +4 -4
  69. package/dist/{chunk-CL37JGFW.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
  70. package/dist/chunk-WSQKHXW7.cjs +5726 -0
  71. package/dist/chunk-WSQKHXW7.cjs.map +1 -0
  72. package/dist/{chunk-AA4ZEVCC.cjs → chunk-X4N4WUKB.cjs} +336 -608
  73. package/dist/chunk-X4N4WUKB.cjs.map +1 -0
  74. package/dist/commands/index.cjs +74 -1
  75. package/dist/commands/index.cjs.map +1 -1
  76. package/dist/commands/index.d.cts +38 -353
  77. package/dist/commands/index.d.ts +38 -353
  78. package/dist/commands/index.js +73 -0
  79. package/dist/commands/index.js.map +1 -1
  80. package/dist/comment-store-BEMgVlAA.d.cts +135 -0
  81. package/dist/comment-store-BEMgVlAA.d.ts +135 -0
  82. package/dist/compare/index.cjs +15 -0
  83. package/dist/compare/index.cjs.map +1 -0
  84. package/dist/compare/index.d.cts +58 -0
  85. package/dist/compare/index.d.ts +58 -0
  86. package/dist/compare/index.js +15 -0
  87. package/dist/compare/index.js.map +1 -0
  88. package/dist/controller-BIJiNoVs.d.cts +1842 -0
  89. package/dist/controller-BIJiNoVs.d.ts +1842 -0
  90. package/dist/documents-CHT1U5Vs.d.ts +86 -0
  91. package/dist/documents-Gp7wb0Me.d.cts +86 -0
  92. package/dist/extensions/index.cjs +100 -5
  93. package/dist/extensions/index.cjs.map +1 -1
  94. package/dist/extensions/index.d.cts +16 -4
  95. package/dist/extensions/index.d.ts +16 -4
  96. package/dist/extensions/index.js +100 -5
  97. package/dist/generation/index.cjs +2317 -0
  98. package/dist/generation/index.cjs.map +1 -0
  99. package/dist/generation/index.d.cts +1015 -0
  100. package/dist/generation/index.d.ts +1015 -0
  101. package/dist/generation/index.js +2317 -0
  102. package/dist/generation/index.js.map +1 -0
  103. package/dist/grammar/index.cjs +48 -3
  104. package/dist/grammar/index.cjs.map +1 -1
  105. package/dist/grammar/index.d.cts +322 -100
  106. package/dist/grammar/index.d.ts +322 -100
  107. package/dist/grammar/index.js +54 -9
  108. package/dist/image-editor/index.cjs +4392 -481
  109. package/dist/image-editor/index.cjs.map +1 -1
  110. package/dist/image-editor/index.d.cts +1249 -97
  111. package/dist/image-editor/index.d.ts +1249 -97
  112. package/dist/image-editor/index.js +4281 -370
  113. package/dist/image-editor/index.js.map +1 -1
  114. package/dist/index-7a6bHTLy.d.ts +1754 -0
  115. package/dist/index-Csd5qI8u.d.cts +1754 -0
  116. package/dist/index.cjs +1682 -99
  117. package/dist/index.cjs.map +1 -1
  118. package/dist/index.d.cts +118 -21
  119. package/dist/index.d.ts +118 -21
  120. package/dist/index.js +1630 -47
  121. package/dist/index.js.map +1 -1
  122. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  123. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  124. package/dist/migrate-iTlm3a8h.d.cts +112 -0
  125. package/dist/migrate-iTlm3a8h.d.ts +112 -0
  126. package/dist/model-C1zApQM8.d.cts +219 -0
  127. package/dist/model-C1zApQM8.d.ts +219 -0
  128. package/dist/persistence/index.cjs +676 -0
  129. package/dist/persistence/index.cjs.map +1 -0
  130. package/dist/persistence/index.d.cts +230 -0
  131. package/dist/persistence/index.d.ts +230 -0
  132. package/dist/persistence/index.js +676 -0
  133. package/dist/persistence/index.js.map +1 -0
  134. package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
  135. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.cts} +12 -1
  136. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.ts} +12 -1
  137. package/dist/registry-D32LpIc4.d.cts +354 -0
  138. package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
  139. package/dist/registry-evKTP4ls.d.ts +354 -0
  140. package/dist/schema-DYDGdYL9.d.cts +41 -0
  141. package/dist/schema-DYDGdYL9.d.ts +41 -0
  142. package/dist/serializers/index.cjs +12 -3
  143. package/dist/serializers/index.cjs.map +1 -1
  144. package/dist/serializers/index.d.cts +40 -12
  145. package/dist/serializers/index.d.ts +40 -12
  146. package/dist/serializers/index.js +12 -3
  147. package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
  148. package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
  149. package/dist/spreadsheet/index.cjs +161 -3
  150. package/dist/spreadsheet/index.cjs.map +1 -1
  151. package/dist/spreadsheet/index.d.cts +611 -20
  152. package/dist/spreadsheet/index.d.ts +611 -20
  153. package/dist/spreadsheet/index.js +168 -10
  154. package/dist/storage-BpFfspHm.d.cts +120 -0
  155. package/dist/storage-BpFfspHm.d.ts +120 -0
  156. package/dist/tokens/index.cjs +115 -0
  157. package/dist/tokens/index.cjs.map +1 -0
  158. package/dist/tokens/index.d.cts +212 -0
  159. package/dist/tokens/index.d.ts +212 -0
  160. package/dist/tokens/index.js +115 -0
  161. package/dist/tokens/index.js.map +1 -0
  162. package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
  163. package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
  164. package/dist/{track-changes-BSF58RK0.d.cts → track-changes-D_VAPELi.d.cts} +110 -144
  165. package/dist/{track-changes-BSF58RK0.d.ts → track-changes-Db_fGEvx.d.ts} +110 -144
  166. package/package.json +21 -1
  167. package/dist/chunk-4SUNJZWB.cjs.map +0 -1
  168. package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
  169. package/dist/chunk-AXV2ZW34.cjs +0 -118
  170. package/dist/chunk-AXV2ZW34.cjs.map +0 -1
  171. package/dist/chunk-B2ZRLN4S.js +0 -118
  172. package/dist/chunk-B2ZRLN4S.js.map +0 -1
  173. package/dist/chunk-GVSMRPHB.cjs.map +0 -1
  174. package/dist/chunk-K3R5NG2D.js +0 -3100
  175. package/dist/chunk-K3R5NG2D.js.map +0 -1
  176. package/dist/chunk-MJZBNWG7.js.map +0 -1
  177. package/dist/chunk-OYXSKQFR.js.map +0 -1
  178. package/dist/chunk-QBJ22YZR.js.map +0 -1
  179. package/dist/chunk-QGHGJ56O.js.map +0 -1
  180. package/dist/chunk-RIKBJLS2.cjs.map +0 -1
  181. package/dist/chunk-XDMXXC4Z.cjs +0 -3100
  182. package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
  183. package/dist/controller-pePCJLT1.d.cts +0 -959
  184. package/dist/controller-pePCJLT1.d.ts +0 -959
  185. package/dist/index-CCr_z9kF.d.cts +0 -899
  186. package/dist/index-Ck6ajwXh.d.ts +0 -899
  187. /package/dist/{chunk-JJDLPEWL.js.map → chunk-QGYDWPRM.js.map} +0 -0
@@ -5,6 +5,7 @@ import { MentionOptions as MentionOptions$1 } from '@tiptap/extension-mention';
5
5
  import { SuggestionOptions } from '@tiptap/suggestion';
6
6
  import { EditorState, PluginKey } from '@tiptap/pm/state';
7
7
  import { Node } from '@tiptap/pm/model';
8
+ import { R as ReviewAuthor } from './comment-store-BEMgVlAA.cjs';
8
9
 
9
10
  interface MentionEntity {
10
11
  id: string;
@@ -27,144 +28,30 @@ interface MentionOptions extends Partial<MentionOptions$1> {
27
28
  * Creates atomic inline <span data-type="mention"> nodes with full suggestion support.
28
29
  */
29
30
  declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
30
- /**
31
- * Helper to configure the Mention extension with preset defaults.
32
- */
33
- declare function createMentionExtension(options?: Partial<MentionOptions>): _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
34
-
35
- /**
36
- * Who made a comment, reply or tracked change.
37
- */
38
- interface ReviewAuthor {
31
+ /** Mention nodes in a document, with their positions (for role pickers). */
32
+ interface MentionNodeInfo {
33
+ pos: number;
39
34
  id: string;
40
- name: string;
41
- color?: string;
42
- avatarUrl?: string;
43
- }
44
- /**
45
- * Where a comment thread is attached in the document. `from`/`to` are
46
- * ProseMirror positions and `quote` is the commented text at the time the
47
- * anchor was last synced. Positions are only meaningful for the current
48
- * document; the `comment` mark in the document is the source of truth.
49
- */
50
- interface CommentAnchor {
51
- from: number;
52
- to: number;
53
- quote: string;
54
- }
55
- interface CommentReply {
56
- id: string;
57
- author: ReviewAuthor;
58
- body: string;
59
- createdAt: number;
60
- editedAt?: number;
61
- }
62
- interface CommentThread {
63
- id: string;
64
- /** `null` while the thread has no text in the document (see `orphaned`). */
65
- anchor: CommentAnchor | null;
66
- author: ReviewAuthor;
67
- createdAt: number;
68
- /** An empty body marks a draft that has not been posted yet. */
69
- body: string;
70
- editedAt?: number;
71
- replies: CommentReply[];
72
- resolved: boolean;
73
- resolvedAt?: number;
74
- resolvedBy?: ReviewAuthor;
75
- /**
76
- * True when the commented text was deleted from the document. Undoing the
77
- * deletion re-attaches the thread.
78
- */
79
- orphaned: boolean;
80
- /** The quote the thread had before it was orphaned. */
81
- lastQuote?: string;
82
- }
83
- interface CommentStoreSnapshot {
84
- /** Threads in document order (anchored first), then orphaned threads. */
85
- threads: readonly CommentThread[];
86
- activeThreadId: string | null;
87
- }
88
- /** JSON shape produced by `CommentStore.toJSON()`. */
89
- interface SerializedComments {
90
- version: 1;
91
- threads: CommentThread[];
92
- }
93
- interface CommentStoreOptions {
94
- threads?: CommentThread[] | SerializedComments;
95
- generateId?: () => string;
96
- now?: () => number;
97
- }
98
- interface CreateThreadInput {
99
- id?: string;
100
- body: string;
101
- author: ReviewAuthor;
102
- anchor?: CommentAnchor | null;
103
- createdAt?: number;
35
+ label: string;
36
+ type?: string;
37
+ role?: string;
104
38
  }
105
- type CommentStoreListener = (snapshot: CommentStoreSnapshot) => void;
106
- /**
107
- * Generates a reasonably unique id without depending on `crypto`.
108
- */
109
- declare function createReviewId(prefix?: string): string;
39
+ /** Every mention node of an editor's document, in document order. */
40
+ declare function getMentionNodes(editor: {
41
+ state: {
42
+ doc: any;
43
+ };
44
+ }): MentionNodeInfo[];
110
45
  /**
111
- * Headless, framework-agnostic store of comment threads.
112
- *
113
- * The store never talks to a server: persist `toJSON()` yourself and pass it
114
- * back via `new CommentStore({ threads })` or `load()`. Snapshots are
115
- * immutable and only replaced when something changes, so `getSnapshot` is safe
116
- * to use with React's `useSyncExternalStore`. `subscribe` calls the listener
117
- * immediately (Svelte store contract).
46
+ * Sets (or with `null` clears) the role of the mention node at `pos`, as one
47
+ * undoable step. Returns `false` when there is no mention at `pos` or the role
48
+ * name is invalid.
118
49
  */
119
- declare class CommentStore {
120
- private threads;
121
- private activeThreadId;
122
- private snapshot;
123
- private listeners;
124
- /** Deleted threads, kept so undoing a "Delete Comment" can restore them. */
125
- private deleted;
126
- private generateId;
127
- private now;
128
- constructor(options?: CommentStoreOptions);
129
- /** Parses `toJSON()` output (or a plain thread array). */
130
- static parse(json: string | CommentThread[] | SerializedComments): CommentThread[];
131
- subscribe: (listener: CommentStoreListener) => (() => void);
132
- getSnapshot: () => CommentStoreSnapshot;
133
- getThread(id: string): CommentThread | undefined;
134
- createThread(input: CreateThreadInput): CommentThread;
135
- /** Edits the thread's body, or one of its replies when `replyId` is given. */
136
- editComment(threadId: string, body: string, replyId?: string): boolean;
137
- addReply(threadId: string, input: {
138
- body: string;
139
- author: ReviewAuthor;
140
- id?: string;
141
- }): CommentReply | null;
142
- deleteReply(threadId: string, replyId: string): boolean;
143
- resolveThread(id: string, resolved?: boolean, by?: ReviewAuthor): boolean;
144
- deleteThread(id: string): boolean;
145
- /** Deletes every thread whose text is no longer in the document. */
146
- removeOrphanedThreads(): string[];
147
- setActiveThread(id: string | null): void;
148
- /**
149
- * Updates anchors from the document. Threads missing from `anchors` become
150
- * orphaned. Threads that were deleted but whose mark re-appeared (e.g. after
151
- * undoing "Delete Comment") are restored. Returns true if anything changed.
152
- */
153
- syncAnchors(anchors: Map<string, CommentAnchor>): boolean;
154
- /** Replaces all threads, e.g. with data loaded from a server. */
155
- load(json: string | CommentThread[] | SerializedComments): void;
156
- clear(): void;
157
- toJSON(): SerializedComments;
158
- private updateThread;
159
- private computeSnapshot;
160
- private emit;
161
- }
162
- declare function createCommentStore(options?: CommentStoreOptions): CommentStore;
50
+ declare function setMentionRoleAt(editor: any, pos: number, role: string | null): boolean;
163
51
  /**
164
- * Short, human-readable timestamp for review UIs ("just now", "5m ago",
165
- * "3h ago", then a locale date). Shared by the React and Svelte components.
52
+ * Helper to configure the Mention extension with preset defaults.
166
53
  */
167
- declare function formatReviewTime(timestamp: number, now?: number): string;
54
+ declare function createMentionExtension(options?: Partial<MentionOptions>): _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
168
55
 
169
56
  declare const INSERTION_MARK_NAME = "insertion";
170
57
  declare const DELETION_MARK_NAME = "deletion";
@@ -172,12 +59,18 @@ declare const DELETION_MARK_NAME = "deletion";
172
59
  declare const FORMAT_CHANGE_MARK_NAME = "formatChange";
173
60
  /** Node attribute recording a tracked block change (type, attributes or wrapping). */
174
61
  declare const BLOCK_CHANGE_ATTRIBUTE = "blockChange";
62
+ /**
63
+ * Attribute of the insertion and deletion marks linking the two ends of a
64
+ * tracked move: the deletion is where the text moved from, the insertion
65
+ * where it moved to. Serialized as `data-move-id`.
66
+ */
67
+ declare const MOVE_ID_ATTRIBUTE = "moveId";
175
68
  /**
176
69
  * Set this transaction meta to `true` to apply a change without tracking it,
177
70
  * e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
178
71
  */
179
72
  declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
180
- type TrackedChangeType = "insertion" | "deletion" | "format" | "block";
73
+ type TrackedChangeType = "insertion" | "deletion" | "format" | "block" | "move";
181
74
  /**
182
75
  * How tracked content is rendered by serializers:
183
76
  * - `accepted` (default): as if every change were accepted (deleted text is
@@ -192,6 +85,11 @@ interface TrackedChangeAttributes {
192
85
  authorName: string;
193
86
  authorColor: string | null;
194
87
  createdAt: number;
88
+ /**
89
+ * Insertion/deletion marks only: links a deletion (moved from) and an
90
+ * insertion (moved to) into one tracked move.
91
+ */
92
+ moveId?: string | null;
195
93
  }
196
94
  /** A serializable mark (`mark.toJSON()`). */
197
95
  interface TrackedMark {
@@ -215,9 +113,16 @@ interface TrackedBlockSnapshot {
215
113
  attrs: Record<string, any>;
216
114
  }[];
217
115
  }
116
+ /**
117
+ * Whole-block operation of a `blockChange` record: the block was inserted
118
+ * (rejecting removes it) or deleted (accepting removes it). Produced by
119
+ * `compareDocuments`; absent for type/attribute/wrapping changes.
120
+ */
121
+ type TrackedBlockOperation = "insert" | "delete";
218
122
  /** Value of the `blockChange` node attribute. */
219
123
  interface TrackedBlockChangeAttributes extends TrackedChangeAttributes {
220
124
  previous: TrackedBlockSnapshot;
125
+ operation?: TrackedBlockOperation;
221
126
  }
222
127
  interface TrackedFormatSummary {
223
128
  /** Labels of added formatting, e.g. `["Bold"]`. */
@@ -249,10 +154,32 @@ interface TrackedChange {
249
154
  description: string;
250
155
  /** Formatting changes (`type: "format"`). */
251
156
  format?: TrackedFormatSummary;
252
- /** Block changes (`type: "block"`): the first block's previous and current state. */
157
+ /**
158
+ * Block changes (`type: "block"`): the first block's previous and current
159
+ * state, and the whole-block operation for inserted/deleted blocks.
160
+ */
253
161
  block?: {
254
162
  previous: TrackedBlockSnapshot;
255
163
  current: TrackedBlockSnapshot;
164
+ operation?: TrackedBlockOperation;
165
+ };
166
+ /**
167
+ * Moves (`type: "move"`): where the text was moved from (struck through
168
+ * until accepted) and where it was moved to. `ranges` holds both.
169
+ */
170
+ move?: {
171
+ from: {
172
+ from: number;
173
+ to: number;
174
+ }[];
175
+ to: {
176
+ from: number;
177
+ to: number;
178
+ }[];
179
+ /** The moved text at its source. */
180
+ fromText: string;
181
+ /** The moved text at its destination. */
182
+ toText: string;
256
183
  };
257
184
  }
258
185
  interface TrackChangesSnapshot {
@@ -275,6 +202,10 @@ interface TrackChangesOptions {
275
202
  formatChangeHTMLAttributes: Record<string, any>;
276
203
  /** Class added to blocks with a tracked block change (margin bar by default). */
277
204
  blockChangeClass: string;
205
+ /** Extra class of wholly inserted blocks (`blockChange.operation: "insert"`, from comparisons). */
206
+ blockInsertedClass: string;
207
+ /** Extra class of wholly deleted blocks (`blockChange.operation: "delete"`, from comparisons). */
208
+ blockDeletedClass: string;
278
209
  /** Track mark changes (bold, links, font size, …) on existing text. Default `true`. */
279
210
  trackFormatting: boolean;
280
211
  /** Track textblock type/attribute and wrapping (list, quote) changes. Default `true`. */
@@ -290,6 +221,19 @@ interface TrackChangesOptions {
290
221
  ignoredMarks: string[];
291
222
  /** Node attributes ignored when comparing blocks (e.g. generated ids). */
292
223
  ignoredBlockAttributes: string[];
224
+ /**
225
+ * Record a cut and paste (or a drag) of the same text as one tracked move
226
+ * instead of a deletion and an insertion. Default `true`.
227
+ */
228
+ trackMoves: boolean;
229
+ /**
230
+ * Decides whether moved text is big enough to be a move. Default
231
+ * `isMoveSized` (a paragraph, or at least a sentence of two words, as in
232
+ * Word); pass `() => true` to record every cut/paste or drag as a move.
233
+ */
234
+ isMove: (text: string) => boolean;
235
+ /** HTML attributes (e.g. `class`) of moved text, at both ends. Replaces the default green double line. */
236
+ moveHTMLAttributes: Record<string, any>;
293
237
  }
294
238
  /**
295
239
  * External store over the editor's tracked-change state. Snapshots only
@@ -325,27 +269,39 @@ declare module "@tiptap/core" {
325
269
  /** Rejects one change (single undo step). */
326
270
  rejectChange: (id: string) => ReturnType;
327
271
  acceptAllChanges: () => ReturnType;
272
+ /** Accepts a tracked move: removes the source, keeps the destination. */
273
+ acceptMove: (id: string) => ReturnType;
274
+ /** Rejects a tracked move: restores the source, removes the destination. */
275
+ rejectMove: (id: string) => ReturnType;
328
276
  rejectAllChanges: () => ReturnType;
329
277
  /** Selects the next change after the selection, wrapping around. */
330
278
  selectNextChange: () => ReturnType;
331
279
  /** Selects the previous change before the selection, wrapping around. */
332
280
  selectPreviousChange: () => ReturnType;
281
+ /** Selects a change (a move's destination, a block change's content). */
282
+ selectChange: (id: string) => ReturnType;
333
283
  };
334
284
  }
335
285
  }
286
+ interface TrackedMarkOptions {
287
+ HTMLAttributes: Record<string, any>;
288
+ /** Attributes used instead of `HTMLAttributes` when the mark is one end of a move. */
289
+ moveHTMLAttributes: Record<string, any>;
290
+ }
291
+ /** Default classes of moved text: green double underline (destination) / strike (source), as in Word. */
292
+ declare const MOVE_TO_CLASS = "pixerate-move-to underline decoration-double decoration-emerald-600 text-emerald-700 dark:text-emerald-400";
293
+ declare const MOVE_FROM_CLASS = "pixerate-move-from line-through decoration-double decoration-emerald-600 text-emerald-700 dark:text-emerald-400";
336
294
  /**
337
- * Text inserted while tracking was on. Rendered as `<ins>`.
295
+ * Text inserted while tracking was on. Rendered as `<ins>`. With a `moveId`
296
+ * it is the destination of a tracked move.
338
297
  */
339
- declare const TrackedInsertion: Mark<{
340
- HTMLAttributes: Record<string, any>;
341
- }, any>;
298
+ declare const TrackedInsertion: Mark<TrackedMarkOptions, any>;
342
299
  /**
343
300
  * Text deleted while tracking was on. The text stays in the document until
344
- * the change is accepted. Rendered as `<del>` (struck through).
301
+ * the change is accepted. Rendered as `<del>` (struck through). With a
302
+ * `moveId` it is the source of a tracked move.
345
303
  */
346
- declare const TrackedDeletion: Mark<{
347
- HTMLAttributes: Record<string, any>;
348
- }, any>;
304
+ declare const TrackedDeletion: Mark<TrackedMarkOptions, any>;
349
305
  /**
350
306
  * Existing text whose formatting changed while tracking was on. Stores the
351
307
  * formatting before and after the change, rendered as
@@ -358,6 +314,8 @@ declare const TrackedFormatChange: Mark<{
358
314
  declare function describeFormatChange(summary: TrackedFormatSummary): string;
359
315
  /** Describes a block change, e.g. `Changed Paragraph to Heading 2`. */
360
316
  declare function describeBlockChange(previous: TrackedBlockSnapshot, current: TrackedBlockSnapshot, ignoredAttributes?: readonly string[]): string;
317
+ /** Short label of a change's type for review UIs (`Moved` for a move). */
318
+ declare function trackedChangeLabel(change: Pick<TrackedChange, "type">): string;
361
319
  /**
362
320
  * Lists tracked changes in document order. Accepts an editor, an editor
363
321
  * state or a ProseMirror document.
@@ -373,17 +331,25 @@ declare function getTrackChangesStore(editor: Editor | null | undefined): TrackC
373
331
  * (`accepted` by default). The input document is not modified.
374
332
  */
375
333
  declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): Node;
334
+ /**
335
+ * Whether moved text is big enough to be recorded as a move rather than a
336
+ * deletion and an insertion, as in Word: a paragraph (the text holds a
337
+ * paragraph break) or at least a sentence of two or more words.
338
+ */
339
+ declare function isMoveSized(text: string): boolean;
376
340
  /**
377
341
  * Suggestion mode / track changes. When enabled, typed and pasted content is
378
342
  * marked as an insertion and deleted content is kept but marked as a
379
343
  * deletion (struck through) until the change is accepted or rejected.
380
344
  * Formatting changes on existing text are recorded with the `formatChange`
381
345
  * mark, and textblock type/attribute/wrapping changes with the `blockChange`
382
- * node attribute.
346
+ * node attribute. A cut and paste (or a drag) of a sentence or paragraph is
347
+ * recorded as a move: a deletion and an insertion linked by `moveId`, listed
348
+ * as one change and accepted or rejected together.
383
349
  *
384
350
  * Deleting your own insertion really deletes it. Paragraph splits and joins
385
351
  * are not tracked. IME composition is tracked once the composition ends.
386
352
  */
387
353
  declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
388
354
 
389
- export { createCommentStore as A, BLOCK_CHANGE_ATTRIBUTE as B, type CommentAnchor as C, DELETION_MARK_NAME as D, createMentionExtension as E, FORMAT_CHANGE_MARK_NAME as F, createReviewId as G, describeBlockChange as H, INSERTION_MARK_NAME as I, describeFormatChange as J, formatReviewTime as K, getTrackChangesStore as L, Mention as M, getTrackedChangeAt as N, getTrackedChanges as O, isTrackChangesEnabled as P, resolveTrackedChanges as Q, type ReviewAuthor as R, type SerializedComments as S, TRACK_CHANGES_SKIP_META as T, trackChangesPluginKey as U, type CommentReply as a, CommentStore as b, type CommentStoreListener as c, type CommentStoreOptions as d, type CommentStoreSnapshot as e, type CommentThread as f, type CreateThreadInput as g, type MentionEntity as h, type MentionOptions as i, TrackChanges as j, type TrackChangesOptions as k, type TrackChangesSnapshot as l, type TrackChangesStorage as m, TrackChangesStore as n, type TrackedBlockChangeAttributes as o, type TrackedBlockSnapshot as p, type TrackedChange as q, type TrackedChangeAttributes as r, type TrackedChangeType as s, type TrackedChangesView as t, TrackedDeletion as u, TrackedFormatChange as v, type TrackedFormatChangeAttributes as w, type TrackedFormatSummary as x, TrackedInsertion as y, type TrackedMark as z };
355
+ export { describeFormatChange as A, BLOCK_CHANGE_ATTRIBUTE as B, getMentionNodes as C, DELETION_MARK_NAME as D, getTrackChangesStore as E, FORMAT_CHANGE_MARK_NAME as F, getTrackedChangeAt as G, getTrackedChanges as H, INSERTION_MARK_NAME as I, isMoveSized as J, isTrackChangesEnabled as K, resolveTrackedChanges as L, MOVE_FROM_CLASS as M, setMentionRoleAt as N, trackChangesPluginKey as O, trackedChangeLabel as P, TRACK_CHANGES_SKIP_META as T, MOVE_ID_ATTRIBUTE as a, MOVE_TO_CLASS as b, Mention as c, type MentionEntity as d, type MentionNodeInfo as e, type MentionOptions as f, TrackChanges as g, type TrackChangesOptions as h, type TrackChangesSnapshot as i, type TrackChangesStorage as j, TrackChangesStore as k, type TrackedBlockChangeAttributes as l, type TrackedBlockOperation as m, type TrackedBlockSnapshot as n, type TrackedChange as o, type TrackedChangeAttributes as p, type TrackedChangeType as q, type TrackedChangesView as r, TrackedDeletion as s, TrackedFormatChange as t, type TrackedFormatChangeAttributes as u, type TrackedFormatSummary as v, TrackedInsertion as w, type TrackedMark as x, createMentionExtension as y, describeBlockChange as z };