@pixerate/editor 0.22.0 → 0.24.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 (188) hide show
  1. package/README.md +175 -2
  2. package/THIRD_PARTY_NOTICES.md +139 -0
  3. package/dist/agent/index.cjs +87 -111
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +70 -211
  6. package/dist/agent/index.d.ts +70 -211
  7. package/dist/agent/index.js +78 -102
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
  10. package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
  11. package/dist/canvas/index.cjs +2075 -86
  12. package/dist/canvas/index.cjs.map +1 -1
  13. package/dist/canvas/index.d.cts +608 -186
  14. package/dist/canvas/index.d.ts +608 -186
  15. package/dist/canvas/index.js +2060 -71
  16. package/dist/canvas/index.js.map +1 -1
  17. package/dist/chunk-26BVFKHU.cjs +453 -0
  18. package/dist/chunk-26BVFKHU.cjs.map +1 -0
  19. package/dist/chunk-2H7ZHPEJ.js +762 -0
  20. package/dist/chunk-2H7ZHPEJ.js.map +1 -0
  21. package/dist/{chunk-DENSCKFC.js → chunk-3CN2WD3X.js} +1730 -189
  22. package/dist/chunk-3CN2WD3X.js.map +1 -0
  23. package/dist/{chunk-JJDLPEWL.js → chunk-3LV6RRPH.js} +2 -2
  24. package/dist/{chunk-MJZBNWG7.js → chunk-5S3Z4PPF.js} +78 -557
  25. package/dist/chunk-5S3Z4PPF.js.map +1 -0
  26. package/dist/chunk-664LQYFJ.js +115 -0
  27. package/dist/chunk-664LQYFJ.js.map +1 -0
  28. package/dist/chunk-7DWMJCAT.js +453 -0
  29. package/dist/chunk-7DWMJCAT.js.map +1 -0
  30. package/dist/chunk-ARRTP33I.js +101 -0
  31. package/dist/chunk-ARRTP33I.js.map +1 -0
  32. package/dist/chunk-CPOKFNBG.cjs +101 -0
  33. package/dist/chunk-CPOKFNBG.cjs.map +1 -0
  34. package/dist/{chunk-AA4ZEVCC.cjs → chunk-D27YFC46.cjs} +101 -580
  35. package/dist/chunk-D27YFC46.cjs.map +1 -0
  36. package/dist/chunk-D6FH2YAX.cjs +131 -0
  37. package/dist/chunk-D6FH2YAX.cjs.map +1 -0
  38. package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
  39. package/dist/chunk-FD4LPFAE.cjs.map +1 -0
  40. package/dist/chunk-FODNLX5N.js +749 -0
  41. package/dist/chunk-FODNLX5N.js.map +1 -0
  42. package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
  43. package/dist/chunk-FPENXAEJ.js.map +1 -0
  44. package/dist/chunk-G2I4QJOT.cjs +762 -0
  45. package/dist/chunk-G2I4QJOT.cjs.map +1 -0
  46. package/dist/chunk-HLIMTC6N.js +1 -0
  47. package/dist/chunk-HLIMTC6N.js.map +1 -0
  48. package/dist/{chunk-QGHGJ56O.js → chunk-ITBSKI26.js} +1483 -19
  49. package/dist/chunk-ITBSKI26.js.map +1 -0
  50. package/dist/{chunk-6M3BCTBD.cjs → chunk-MA2F5KHF.cjs} +470 -242
  51. package/dist/chunk-MA2F5KHF.cjs.map +1 -0
  52. package/dist/{chunk-SAZRENEZ.cjs → chunk-MCSJFWAO.cjs} +1733 -192
  53. package/dist/chunk-MCSJFWAO.cjs.map +1 -0
  54. package/dist/chunk-MKA3AHLV.cjs +256 -0
  55. package/dist/chunk-MKA3AHLV.cjs.map +1 -0
  56. package/dist/chunk-OLZJXL4R.cjs +749 -0
  57. package/dist/chunk-OLZJXL4R.cjs.map +1 -0
  58. package/dist/chunk-OXSV64JX.js +689 -0
  59. package/dist/chunk-OXSV64JX.js.map +1 -0
  60. package/dist/chunk-P3RQ5UJE.cjs +689 -0
  61. package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
  62. package/dist/chunk-P6ODPZ4W.js +256 -0
  63. package/dist/chunk-P6ODPZ4W.js.map +1 -0
  64. package/dist/chunk-PGNZKFQS.js +685 -0
  65. package/dist/chunk-PGNZKFQS.js.map +1 -0
  66. package/dist/chunk-PL4JB3BF.cjs +1 -0
  67. package/dist/chunk-PL4JB3BF.cjs.map +1 -0
  68. package/dist/{chunk-GVSMRPHB.cjs → chunk-SBCZ6RN5.cjs} +1568 -104
  69. package/dist/chunk-SBCZ6RN5.cjs.map +1 -0
  70. package/dist/{chunk-CL37JGFW.cjs → chunk-SML64VJG.cjs} +4 -4
  71. package/dist/{chunk-CL37JGFW.cjs.map → chunk-SML64VJG.cjs.map} +1 -1
  72. package/dist/chunk-TNNJXF46.cjs +115 -0
  73. package/dist/chunk-TNNJXF46.cjs.map +1 -0
  74. package/dist/chunk-U5HZSFCS.js +131 -0
  75. package/dist/chunk-U5HZSFCS.js.map +1 -0
  76. package/dist/{chunk-RU52I7QO.js → chunk-U5KWZU4X.js} +388 -160
  77. package/dist/chunk-U5KWZU4X.js.map +1 -0
  78. package/dist/chunk-XNORY7M6.cjs +685 -0
  79. package/dist/chunk-XNORY7M6.cjs.map +1 -0
  80. package/dist/commands/index.cjs +860 -0
  81. package/dist/commands/index.cjs.map +1 -0
  82. package/dist/commands/index.d.cts +244 -0
  83. package/dist/commands/index.d.ts +244 -0
  84. package/dist/commands/index.js +860 -0
  85. package/dist/commands/index.js.map +1 -0
  86. package/dist/comment-store-BEMgVlAA.d.cts +135 -0
  87. package/dist/comment-store-BEMgVlAA.d.ts +135 -0
  88. package/dist/compare/index.cjs +15 -0
  89. package/dist/compare/index.cjs.map +1 -0
  90. package/dist/compare/index.d.cts +58 -0
  91. package/dist/compare/index.d.ts +58 -0
  92. package/dist/compare/index.js +15 -0
  93. package/dist/compare/index.js.map +1 -0
  94. package/dist/{controller-B7GIybc4.d.cts → controller-BhLLAoi8.d.cts} +119 -5
  95. package/dist/{controller-B7GIybc4.d.ts → controller-BhLLAoi8.d.ts} +119 -5
  96. package/dist/documents-BQjzJNe2.d.ts +76 -0
  97. package/dist/documents-KRTPhvst.d.cts +76 -0
  98. package/dist/extensions/index.cjs +53 -5
  99. package/dist/extensions/index.cjs.map +1 -1
  100. package/dist/extensions/index.d.cts +7 -3
  101. package/dist/extensions/index.d.ts +7 -3
  102. package/dist/extensions/index.js +52 -4
  103. package/dist/generation/index.cjs +1373 -0
  104. package/dist/generation/index.cjs.map +1 -0
  105. package/dist/generation/index.d.cts +554 -0
  106. package/dist/generation/index.d.ts +554 -0
  107. package/dist/generation/index.js +1373 -0
  108. package/dist/generation/index.js.map +1 -0
  109. package/dist/grammar/index.cjs +48 -3
  110. package/dist/grammar/index.cjs.map +1 -1
  111. package/dist/grammar/index.d.cts +322 -100
  112. package/dist/grammar/index.d.ts +322 -100
  113. package/dist/grammar/index.js +54 -9
  114. package/dist/history/index.cjs +12 -2
  115. package/dist/history/index.cjs.map +1 -1
  116. package/dist/history/index.d.cts +211 -7
  117. package/dist/history/index.d.ts +211 -7
  118. package/dist/history/index.js +13 -3
  119. package/dist/image-editor/index.cjs +2244 -38
  120. package/dist/image-editor/index.cjs.map +1 -1
  121. package/dist/image-editor/index.d.cts +742 -4
  122. package/dist/image-editor/index.d.ts +742 -4
  123. package/dist/image-editor/index.js +2222 -16
  124. package/dist/image-editor/index.js.map +1 -1
  125. package/dist/{index-CCr_z9kF.d.cts → index-BhJBSm2d.d.cts} +370 -4
  126. package/dist/{index-Ck6ajwXh.d.ts → index-fJrlkJCd.d.ts} +370 -4
  127. package/dist/index.cjs +193 -98
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +17 -48
  130. package/dist/index.d.ts +17 -48
  131. package/dist/index.js +198 -103
  132. package/dist/index.js.map +1 -1
  133. package/dist/migrate-iTlm3a8h.d.cts +112 -0
  134. package/dist/migrate-iTlm3a8h.d.ts +112 -0
  135. package/dist/persistence/index.cjs +676 -0
  136. package/dist/persistence/index.cjs.map +1 -0
  137. package/dist/persistence/index.d.cts +347 -0
  138. package/dist/persistence/index.d.ts +347 -0
  139. package/dist/persistence/index.js +676 -0
  140. package/dist/persistence/index.js.map +1 -0
  141. package/dist/registry-BDe-vlv3.d.ts +171 -0
  142. package/dist/registry-D32LpIc4.d.cts +354 -0
  143. package/dist/registry-DnzpgY27.d.cts +171 -0
  144. package/dist/registry-evKTP4ls.d.ts +354 -0
  145. package/dist/schema-DYDGdYL9.d.cts +41 -0
  146. package/dist/schema-DYDGdYL9.d.ts +41 -0
  147. package/dist/serializers/index.cjs +4 -3
  148. package/dist/serializers/index.cjs.map +1 -1
  149. package/dist/serializers/index.d.cts +2 -1
  150. package/dist/serializers/index.d.ts +2 -1
  151. package/dist/serializers/index.js +3 -2
  152. package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
  153. package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
  154. package/dist/spreadsheet/index.cjs +53 -3
  155. package/dist/spreadsheet/index.cjs.map +1 -1
  156. package/dist/spreadsheet/index.d.cts +247 -18
  157. package/dist/spreadsheet/index.d.ts +247 -18
  158. package/dist/spreadsheet/index.js +58 -8
  159. package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
  160. package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
  161. package/dist/{track-changes-BSF58RK0.d.cts → track-changes-BK5sVf4_.d.cts} +18 -136
  162. package/dist/{track-changes-BSF58RK0.d.ts → track-changes-CDjCrwKe.d.ts} +18 -136
  163. package/dist/{types-CJ4U-HHI.d.ts → types-DX4Mh4SL.d.cts} +1 -1
  164. package/dist/{types-CJ4U-HHI.d.cts → types-DX4Mh4SL.d.ts} +1 -1
  165. package/dist/types-GT5a5YAX.d.cts +86 -0
  166. package/dist/types-GT5a5YAX.d.ts +86 -0
  167. package/package.json +23 -2
  168. package/dist/chunk-2TWGLC5K.cjs +0 -262
  169. package/dist/chunk-2TWGLC5K.cjs.map +0 -1
  170. package/dist/chunk-4SUNJZWB.cjs.map +0 -1
  171. package/dist/chunk-6M3BCTBD.cjs.map +0 -1
  172. package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
  173. package/dist/chunk-AXV2ZW34.cjs +0 -118
  174. package/dist/chunk-AXV2ZW34.cjs.map +0 -1
  175. package/dist/chunk-B2ZRLN4S.js +0 -118
  176. package/dist/chunk-B2ZRLN4S.js.map +0 -1
  177. package/dist/chunk-DENSCKFC.js.map +0 -1
  178. package/dist/chunk-GVSMRPHB.cjs.map +0 -1
  179. package/dist/chunk-KAADNAPF.js +0 -262
  180. package/dist/chunk-KAADNAPF.js.map +0 -1
  181. package/dist/chunk-MJZBNWG7.js.map +0 -1
  182. package/dist/chunk-OYXSKQFR.js.map +0 -1
  183. package/dist/chunk-QGHGJ56O.js.map +0 -1
  184. package/dist/chunk-RU52I7QO.js.map +0 -1
  185. package/dist/chunk-SAZRENEZ.cjs.map +0 -1
  186. package/dist/types-BZgcDsC5.d.cts +0 -42
  187. package/dist/types-BZgcDsC5.d.ts +0 -42
  188. /package/dist/{chunk-JJDLPEWL.js.map → chunk-3LV6RRPH.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;
@@ -32,140 +33,6 @@ declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension
32
33
  */
33
34
  declare function createMentionExtension(options?: Partial<MentionOptions>): _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
34
35
 
35
- /**
36
- * Who made a comment, reply or tracked change.
37
- */
38
- interface ReviewAuthor {
39
- 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;
104
- }
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;
110
- /**
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).
118
- */
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;
163
- /**
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.
166
- */
167
- declare function formatReviewTime(timestamp: number, now?: number): string;
168
-
169
36
  declare const INSERTION_MARK_NAME = "insertion";
170
37
  declare const DELETION_MARK_NAME = "deletion";
171
38
  /** Mark recording a tracked formatting change (mark added/removed on existing text). */
@@ -215,9 +82,16 @@ interface TrackedBlockSnapshot {
215
82
  attrs: Record<string, any>;
216
83
  }[];
217
84
  }
85
+ /**
86
+ * Whole-block operation of a `blockChange` record: the block was inserted
87
+ * (rejecting removes it) or deleted (accepting removes it). Produced by
88
+ * `compareDocuments`; absent for type/attribute/wrapping changes.
89
+ */
90
+ type TrackedBlockOperation = "insert" | "delete";
218
91
  /** Value of the `blockChange` node attribute. */
219
92
  interface TrackedBlockChangeAttributes extends TrackedChangeAttributes {
220
93
  previous: TrackedBlockSnapshot;
94
+ operation?: TrackedBlockOperation;
221
95
  }
222
96
  interface TrackedFormatSummary {
223
97
  /** Labels of added formatting, e.g. `["Bold"]`. */
@@ -249,10 +123,14 @@ interface TrackedChange {
249
123
  description: string;
250
124
  /** Formatting changes (`type: "format"`). */
251
125
  format?: TrackedFormatSummary;
252
- /** Block changes (`type: "block"`): the first block's previous and current state. */
126
+ /**
127
+ * Block changes (`type: "block"`): the first block's previous and current
128
+ * state, and the whole-block operation for inserted/deleted blocks.
129
+ */
253
130
  block?: {
254
131
  previous: TrackedBlockSnapshot;
255
132
  current: TrackedBlockSnapshot;
133
+ operation?: TrackedBlockOperation;
256
134
  };
257
135
  }
258
136
  interface TrackChangesSnapshot {
@@ -275,6 +153,10 @@ interface TrackChangesOptions {
275
153
  formatChangeHTMLAttributes: Record<string, any>;
276
154
  /** Class added to blocks with a tracked block change (margin bar by default). */
277
155
  blockChangeClass: string;
156
+ /** Extra class of wholly inserted blocks (`blockChange.operation: "insert"`, from comparisons). */
157
+ blockInsertedClass: string;
158
+ /** Extra class of wholly deleted blocks (`blockChange.operation: "delete"`, from comparisons). */
159
+ blockDeletedClass: string;
278
160
  /** Track mark changes (bold, links, font size, …) on existing text. Default `true`. */
279
161
  trackFormatting: boolean;
280
162
  /** Track textblock type/attribute and wrapping (list, quote) changes. Default `true`. */
@@ -386,4 +268,4 @@ declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): No
386
268
  */
387
269
  declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
388
270
 
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 };
271
+ export { isTrackChangesEnabled as A, BLOCK_CHANGE_ATTRIBUTE as B, resolveTrackedChanges as C, DELETION_MARK_NAME as D, trackChangesPluginKey as E, FORMAT_CHANGE_MARK_NAME as F, INSERTION_MARK_NAME as I, Mention as M, TRACK_CHANGES_SKIP_META as T, type MentionEntity as a, type MentionOptions as b, TrackChanges as c, type TrackChangesOptions as d, type TrackChangesSnapshot as e, type TrackChangesStorage as f, TrackChangesStore as g, type TrackedBlockChangeAttributes as h, type TrackedBlockOperation as i, type TrackedBlockSnapshot as j, type TrackedChange as k, type TrackedChangeAttributes as l, type TrackedChangeType as m, type TrackedChangesView as n, TrackedDeletion as o, TrackedFormatChange as p, type TrackedFormatChangeAttributes as q, type TrackedFormatSummary as r, TrackedInsertion as s, type TrackedMark as t, createMentionExtension as u, describeBlockChange as v, describeFormatChange as w, getTrackChangesStore as x, getTrackedChangeAt as y, getTrackedChanges as z };
@@ -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.js';
8
9
 
9
10
  interface MentionEntity {
10
11
  id: string;
@@ -32,140 +33,6 @@ declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension
32
33
  */
33
34
  declare function createMentionExtension(options?: Partial<MentionOptions>): _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
34
35
 
35
- /**
36
- * Who made a comment, reply or tracked change.
37
- */
38
- interface ReviewAuthor {
39
- 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;
104
- }
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;
110
- /**
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).
118
- */
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;
163
- /**
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.
166
- */
167
- declare function formatReviewTime(timestamp: number, now?: number): string;
168
-
169
36
  declare const INSERTION_MARK_NAME = "insertion";
170
37
  declare const DELETION_MARK_NAME = "deletion";
171
38
  /** Mark recording a tracked formatting change (mark added/removed on existing text). */
@@ -215,9 +82,16 @@ interface TrackedBlockSnapshot {
215
82
  attrs: Record<string, any>;
216
83
  }[];
217
84
  }
85
+ /**
86
+ * Whole-block operation of a `blockChange` record: the block was inserted
87
+ * (rejecting removes it) or deleted (accepting removes it). Produced by
88
+ * `compareDocuments`; absent for type/attribute/wrapping changes.
89
+ */
90
+ type TrackedBlockOperation = "insert" | "delete";
218
91
  /** Value of the `blockChange` node attribute. */
219
92
  interface TrackedBlockChangeAttributes extends TrackedChangeAttributes {
220
93
  previous: TrackedBlockSnapshot;
94
+ operation?: TrackedBlockOperation;
221
95
  }
222
96
  interface TrackedFormatSummary {
223
97
  /** Labels of added formatting, e.g. `["Bold"]`. */
@@ -249,10 +123,14 @@ interface TrackedChange {
249
123
  description: string;
250
124
  /** Formatting changes (`type: "format"`). */
251
125
  format?: TrackedFormatSummary;
252
- /** Block changes (`type: "block"`): the first block's previous and current state. */
126
+ /**
127
+ * Block changes (`type: "block"`): the first block's previous and current
128
+ * state, and the whole-block operation for inserted/deleted blocks.
129
+ */
253
130
  block?: {
254
131
  previous: TrackedBlockSnapshot;
255
132
  current: TrackedBlockSnapshot;
133
+ operation?: TrackedBlockOperation;
256
134
  };
257
135
  }
258
136
  interface TrackChangesSnapshot {
@@ -275,6 +153,10 @@ interface TrackChangesOptions {
275
153
  formatChangeHTMLAttributes: Record<string, any>;
276
154
  /** Class added to blocks with a tracked block change (margin bar by default). */
277
155
  blockChangeClass: string;
156
+ /** Extra class of wholly inserted blocks (`blockChange.operation: "insert"`, from comparisons). */
157
+ blockInsertedClass: string;
158
+ /** Extra class of wholly deleted blocks (`blockChange.operation: "delete"`, from comparisons). */
159
+ blockDeletedClass: string;
278
160
  /** Track mark changes (bold, links, font size, …) on existing text. Default `true`. */
279
161
  trackFormatting: boolean;
280
162
  /** Track textblock type/attribute and wrapping (list, quote) changes. Default `true`. */
@@ -386,4 +268,4 @@ declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): No
386
268
  */
387
269
  declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
388
270
 
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 };
271
+ export { isTrackChangesEnabled as A, BLOCK_CHANGE_ATTRIBUTE as B, resolveTrackedChanges as C, DELETION_MARK_NAME as D, trackChangesPluginKey as E, FORMAT_CHANGE_MARK_NAME as F, INSERTION_MARK_NAME as I, Mention as M, TRACK_CHANGES_SKIP_META as T, type MentionEntity as a, type MentionOptions as b, TrackChanges as c, type TrackChangesOptions as d, type TrackChangesSnapshot as e, type TrackChangesStorage as f, TrackChangesStore as g, type TrackedBlockChangeAttributes as h, type TrackedBlockOperation as i, type TrackedBlockSnapshot as j, type TrackedChange as k, type TrackedChangeAttributes as l, type TrackedChangeType as m, type TrackedChangesView as n, TrackedDeletion as o, TrackedFormatChange as p, type TrackedFormatChangeAttributes as q, type TrackedFormatSummary as r, TrackedInsertion as s, type TrackedMark as t, createMentionExtension as u, describeBlockChange as v, describeFormatChange as w, getTrackChangesStore as x, getTrackedChangeAt as y, getTrackedChanges as z };
@@ -214,4 +214,4 @@ interface CanvasDockingCallbacks<TNode extends CanvasNode = CanvasNode> {
214
214
  onDockDrop?: (dockTarget: TNode, draggedNode: TNode) => void;
215
215
  }
216
216
 
217
- export type { CanvasNode as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, PlaceBesideOptions as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasEdge as a, CanvasLayoutOptions as b, CanvasNodeStyle as c, ReflowDisplacementOptions as d, CanvasClipboardPayload as e, Position as f, Point as g, CanvasDockingCallbacks as h, CollapseNodeOptions as i, DisplacementDirection as j, DockStrategy as k, ExplosionSnapshot as l, TrajectoryPoint as m };
217
+ export type { CanvasNode as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, PlaceBesideOptions as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasNodeStyle as a, CanvasEdge as b, CanvasLayoutOptions as c, ReflowDisplacementOptions as d, CanvasClipboardPayload as e, Position as f, Point as g, CanvasDockingCallbacks as h, CollapseNodeOptions as i, DisplacementDirection as j, DockStrategy as k, ExplosionSnapshot as l, TrajectoryPoint as m };
@@ -214,4 +214,4 @@ interface CanvasDockingCallbacks<TNode extends CanvasNode = CanvasNode> {
214
214
  onDockDrop?: (dockTarget: TNode, draggedNode: TNode) => void;
215
215
  }
216
216
 
217
- export type { CanvasNode as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, PlaceBesideOptions as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasEdge as a, CanvasLayoutOptions as b, CanvasNodeStyle as c, ReflowDisplacementOptions as d, CanvasClipboardPayload as e, Position as f, Point as g, CanvasDockingCallbacks as h, CollapseNodeOptions as i, DisplacementDirection as j, DockStrategy as k, ExplosionSnapshot as l, TrajectoryPoint as m };
217
+ export type { CanvasNode as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, PlaceBesideOptions as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasNodeStyle as a, CanvasEdge as b, CanvasLayoutOptions as c, ReflowDisplacementOptions as d, CanvasClipboardPayload as e, Position as f, Point as g, CanvasDockingCallbacks as h, CollapseNodeOptions as i, DisplacementDirection as j, DockStrategy as k, ExplosionSnapshot as l, TrajectoryPoint as m };
@@ -0,0 +1,86 @@
1
+ interface Command {
2
+ execute: () => void;
3
+ undo: () => void;
4
+ redo?: () => void;
5
+ name: string;
6
+ tag?: string;
7
+ timestamp?: number;
8
+ /**
9
+ * Approximate memory held by this command (closures, snapshots), in bytes.
10
+ * Counted against `HistoryManagerOptions.maxBytes` when no `sizeOf` hook is set.
11
+ */
12
+ byteSize?: number;
13
+ }
14
+ interface HistoryState {
15
+ canUndo: boolean;
16
+ canRedo: boolean;
17
+ undoName: string;
18
+ redoName: string;
19
+ undoCount: number;
20
+ redoCount: number;
21
+ }
22
+ interface HistoryManagerOptions {
23
+ /**
24
+ * Maximum number of undo states to keep. Defaults to 50.
25
+ */
26
+ maxDepth?: number;
27
+ /**
28
+ * Approximate memory budget in bytes for the undo and redo stacks
29
+ * (0 or omitted = unlimited). The oldest undo steps that do not fit are
30
+ * dropped; the most recent one is always kept so the last step can be undone.
31
+ */
32
+ maxBytes?: number;
33
+ /**
34
+ * Measures a command for `maxBytes`. Defaults to `command.byteSize ?? 0`.
35
+ */
36
+ sizeOf?: (command: Command) => number;
37
+ /**
38
+ * Optional callback fired whenever the history state changes.
39
+ */
40
+ onStateChange?: (state: HistoryState) => void;
41
+ }
42
+ interface SnapshotCommandOptions<T> {
43
+ name: string;
44
+ before: T;
45
+ after: T;
46
+ apply: (state: T) => void;
47
+ tag?: string;
48
+ }
49
+ interface MergedExecutionOptions {
50
+ /**
51
+ * Window in milliseconds during which commands with the same tag will be coalesced.
52
+ * Defaults to 300ms. Ignored when `key` is set or a gesture is held.
53
+ */
54
+ windowMs?: number;
55
+ /**
56
+ * Gesture key. Consecutive merged executes with the same key fold into one
57
+ * undo step regardless of timing, until another command is recorded, undo /
58
+ * redo / `revertTo` / `goTo` runs, or `endGesture()` is called.
59
+ */
60
+ key?: string;
61
+ }
62
+ /** One row of a History panel (see `HistoryManager.getEntries`). */
63
+ interface HistoryEntry {
64
+ /** Stable id of the step (unchanged while a gesture merges into it). */
65
+ id: number;
66
+ /** The step's command name. */
67
+ label: string;
68
+ /** Position in the timeline: undo steps first (oldest = 0), then redo steps. */
69
+ index: number;
70
+ /** True for the step that produced the current state (the top of the undo stack). */
71
+ current: boolean;
72
+ /** True for steps on the redo stack (undone, can be redone). */
73
+ undone: boolean;
74
+ }
75
+ /**
76
+ * A point in the undo history, from `HistoryManager.mark()`, for `revertTo`.
77
+ * Treat it as opaque.
78
+ */
79
+ interface HistoryMark {
80
+ readonly topId: number | null;
81
+ readonly nextId: number;
82
+ readonly epoch: number;
83
+ readonly dropped: number;
84
+ }
85
+
86
+ export type { Command as C, HistoryState as H, MergedExecutionOptions as M, SnapshotCommandOptions as S, HistoryEntry as a, HistoryManagerOptions as b, HistoryMark as c };
@@ -0,0 +1,86 @@
1
+ interface Command {
2
+ execute: () => void;
3
+ undo: () => void;
4
+ redo?: () => void;
5
+ name: string;
6
+ tag?: string;
7
+ timestamp?: number;
8
+ /**
9
+ * Approximate memory held by this command (closures, snapshots), in bytes.
10
+ * Counted against `HistoryManagerOptions.maxBytes` when no `sizeOf` hook is set.
11
+ */
12
+ byteSize?: number;
13
+ }
14
+ interface HistoryState {
15
+ canUndo: boolean;
16
+ canRedo: boolean;
17
+ undoName: string;
18
+ redoName: string;
19
+ undoCount: number;
20
+ redoCount: number;
21
+ }
22
+ interface HistoryManagerOptions {
23
+ /**
24
+ * Maximum number of undo states to keep. Defaults to 50.
25
+ */
26
+ maxDepth?: number;
27
+ /**
28
+ * Approximate memory budget in bytes for the undo and redo stacks
29
+ * (0 or omitted = unlimited). The oldest undo steps that do not fit are
30
+ * dropped; the most recent one is always kept so the last step can be undone.
31
+ */
32
+ maxBytes?: number;
33
+ /**
34
+ * Measures a command for `maxBytes`. Defaults to `command.byteSize ?? 0`.
35
+ */
36
+ sizeOf?: (command: Command) => number;
37
+ /**
38
+ * Optional callback fired whenever the history state changes.
39
+ */
40
+ onStateChange?: (state: HistoryState) => void;
41
+ }
42
+ interface SnapshotCommandOptions<T> {
43
+ name: string;
44
+ before: T;
45
+ after: T;
46
+ apply: (state: T) => void;
47
+ tag?: string;
48
+ }
49
+ interface MergedExecutionOptions {
50
+ /**
51
+ * Window in milliseconds during which commands with the same tag will be coalesced.
52
+ * Defaults to 300ms. Ignored when `key` is set or a gesture is held.
53
+ */
54
+ windowMs?: number;
55
+ /**
56
+ * Gesture key. Consecutive merged executes with the same key fold into one
57
+ * undo step regardless of timing, until another command is recorded, undo /
58
+ * redo / `revertTo` / `goTo` runs, or `endGesture()` is called.
59
+ */
60
+ key?: string;
61
+ }
62
+ /** One row of a History panel (see `HistoryManager.getEntries`). */
63
+ interface HistoryEntry {
64
+ /** Stable id of the step (unchanged while a gesture merges into it). */
65
+ id: number;
66
+ /** The step's command name. */
67
+ label: string;
68
+ /** Position in the timeline: undo steps first (oldest = 0), then redo steps. */
69
+ index: number;
70
+ /** True for the step that produced the current state (the top of the undo stack). */
71
+ current: boolean;
72
+ /** True for steps on the redo stack (undone, can be redone). */
73
+ undone: boolean;
74
+ }
75
+ /**
76
+ * A point in the undo history, from `HistoryManager.mark()`, for `revertTo`.
77
+ * Treat it as opaque.
78
+ */
79
+ interface HistoryMark {
80
+ readonly topId: number | null;
81
+ readonly nextId: number;
82
+ readonly epoch: number;
83
+ readonly dropped: number;
84
+ }
85
+
86
+ export type { Command as C, HistoryState as H, MergedExecutionOptions as M, SnapshotCommandOptions as S, HistoryEntry as a, HistoryManagerOptions as b, HistoryMark as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -58,10 +58,31 @@
58
58
  "types": "./dist/image-editor/index.d.ts",
59
59
  "import": "./dist/image-editor/index.js",
60
60
  "require": "./dist/image-editor/index.cjs"
61
+ },
62
+ "./commands": {
63
+ "types": "./dist/commands/index.d.ts",
64
+ "import": "./dist/commands/index.js",
65
+ "require": "./dist/commands/index.cjs"
66
+ },
67
+ "./persistence": {
68
+ "types": "./dist/persistence/index.d.ts",
69
+ "import": "./dist/persistence/index.js",
70
+ "require": "./dist/persistence/index.cjs"
71
+ },
72
+ "./generation": {
73
+ "types": "./dist/generation/index.d.ts",
74
+ "import": "./dist/generation/index.js",
75
+ "require": "./dist/generation/index.cjs"
76
+ },
77
+ "./compare": {
78
+ "types": "./dist/compare/index.d.ts",
79
+ "import": "./dist/compare/index.js",
80
+ "require": "./dist/compare/index.cjs"
61
81
  }
62
82
  },
63
83
  "files": [
64
- "dist"
84
+ "dist",
85
+ "THIRD_PARTY_NOTICES.md"
65
86
  ],
66
87
  "sideEffects": false,
67
88
  "dependencies": {