@pixerate/editor 0.24.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.
- package/README.md +71 -1
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/agent/index.cjs +10 -9
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +4 -3
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +3173 -340
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +617 -4
- package/dist/canvas/index.d.ts +617 -4
- package/dist/canvas/index.js +3105 -272
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-4BVP64JJ.cjs +1406 -0
- package/dist/chunk-4BVP64JJ.cjs.map +1 -0
- package/dist/{chunk-XNORY7M6.cjs → chunk-7WISYZFO.cjs} +105 -50
- package/dist/chunk-7WISYZFO.cjs.map +1 -0
- package/dist/{chunk-OLZJXL4R.cjs → chunk-AL6JMGWW.cjs} +59 -25
- package/dist/chunk-AL6JMGWW.cjs.map +1 -0
- package/dist/chunk-BVP3TSLH.cjs +69 -0
- package/dist/chunk-BVP3TSLH.cjs.map +1 -0
- package/dist/{chunk-MCSJFWAO.cjs → chunk-C7P22VIP.cjs} +670 -96
- package/dist/chunk-C7P22VIP.cjs.map +1 -0
- package/dist/{chunk-PGNZKFQS.js → chunk-ECCCYKGL.js} +76 -21
- package/dist/chunk-ECCCYKGL.js.map +1 -0
- package/dist/{chunk-3CN2WD3X.js → chunk-FH6F67DN.js} +646 -72
- package/dist/chunk-FH6F67DN.js.map +1 -0
- package/dist/chunk-HRMEDT2L.js +1406 -0
- package/dist/chunk-HRMEDT2L.js.map +1 -0
- package/dist/{chunk-ITBSKI26.js → chunk-IXHSYOVY.js} +941 -9
- package/dist/chunk-IXHSYOVY.js.map +1 -0
- package/dist/{chunk-FODNLX5N.js → chunk-NAXVVS5I.js} +38 -4
- package/dist/chunk-NAXVVS5I.js.map +1 -0
- package/dist/chunk-O5RYH2PG.js +69 -0
- package/dist/chunk-O5RYH2PG.js.map +1 -0
- package/dist/{chunk-SBCZ6RN5.cjs → chunk-PO6A6QQH.cjs} +1039 -107
- package/dist/chunk-PO6A6QQH.cjs.map +1 -0
- package/dist/{chunk-3LV6RRPH.js → chunk-QGYDWPRM.js} +2 -2
- package/dist/{chunk-U5KWZU4X.js → chunk-RR7F5GUM.js} +2632 -129
- package/dist/chunk-RR7F5GUM.js.map +1 -0
- package/dist/{chunk-5S3Z4PPF.js → chunk-UAKDG62Z.js} +232 -25
- package/dist/chunk-UAKDG62Z.js.map +1 -0
- package/dist/{chunk-SML64VJG.cjs → chunk-V3CHHWOE.cjs} +4 -4
- package/dist/{chunk-SML64VJG.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
- package/dist/chunk-WSQKHXW7.cjs +5726 -0
- package/dist/chunk-WSQKHXW7.cjs.map +1 -0
- package/dist/{chunk-D27YFC46.cjs → chunk-X4N4WUKB.cjs} +267 -60
- package/dist/chunk-X4N4WUKB.cjs.map +1 -0
- package/dist/commands/index.cjs +74 -1
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +34 -1
- package/dist/commands/index.d.ts +34 -1
- package/dist/commands/index.js +73 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/compare/index.cjs +3 -3
- package/dist/compare/index.d.cts +1 -1
- package/dist/compare/index.d.ts +1 -1
- package/dist/compare/index.js +2 -2
- package/dist/controller-BIJiNoVs.d.cts +1842 -0
- package/dist/controller-BIJiNoVs.d.ts +1842 -0
- package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
- package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
- package/dist/extensions/index.cjs +53 -6
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +12 -4
- package/dist/extensions/index.d.ts +12 -4
- package/dist/extensions/index.js +53 -6
- package/dist/generation/index.cjs +1013 -69
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +474 -13
- package/dist/generation/index.d.ts +474 -13
- package/dist/generation/index.js +976 -32
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +3385 -1275
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +693 -128
- package/dist/image-editor/index.d.ts +693 -128
- package/dist/image-editor/index.js +3325 -1215
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-fJrlkJCd.d.ts → index-7a6bHTLy.d.ts} +494 -5
- package/dist/{index-BhJBSm2d.d.cts → index-Csd5qI8u.d.cts} +494 -5
- package/dist/index.cjs +1491 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -19
- package/dist/index.d.ts +110 -19
- package/dist/index.js +1464 -18
- package/dist/index.js.map +1 -1
- package/dist/mention-text-CDnCFd3c.d.cts +53 -0
- package/dist/mention-text-CDnCFd3c.d.ts +53 -0
- package/dist/model-C1zApQM8.d.cts +219 -0
- package/dist/model-C1zApQM8.d.ts +219 -0
- package/dist/persistence/index.d.cts +3 -120
- package/dist/persistence/index.d.ts +3 -120
- package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
- package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
- package/dist/serializers/index.cjs +12 -4
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +39 -12
- package/dist/serializers/index.d.ts +39 -12
- package/dist/serializers/index.js +12 -4
- package/dist/spreadsheet/index.cjs +127 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +431 -11
- package/dist/spreadsheet/index.d.ts +431 -11
- package/dist/spreadsheet/index.js +127 -3
- package/dist/storage-BpFfspHm.d.cts +120 -0
- package/dist/storage-BpFfspHm.d.ts +120 -0
- package/dist/tokens/index.cjs +115 -0
- package/dist/tokens/index.cjs.map +1 -0
- package/dist/tokens/index.d.cts +212 -0
- package/dist/tokens/index.d.ts +212 -0
- package/dist/tokens/index.js +115 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
- package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
- package/package.json +6 -1
- package/dist/chunk-3CN2WD3X.js.map +0 -1
- package/dist/chunk-5S3Z4PPF.js.map +0 -1
- package/dist/chunk-D27YFC46.cjs.map +0 -1
- package/dist/chunk-FODNLX5N.js.map +0 -1
- package/dist/chunk-ITBSKI26.js.map +0 -1
- package/dist/chunk-MA2F5KHF.cjs +0 -3223
- package/dist/chunk-MA2F5KHF.cjs.map +0 -1
- package/dist/chunk-MCSJFWAO.cjs.map +0 -1
- package/dist/chunk-OLZJXL4R.cjs.map +0 -1
- package/dist/chunk-PGNZKFQS.js.map +0 -1
- package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
- package/dist/chunk-U5KWZU4X.js.map +0 -1
- package/dist/chunk-XNORY7M6.cjs.map +0 -1
- package/dist/controller-BhLLAoi8.d.cts +0 -1000
- package/dist/controller-BhLLAoi8.d.ts +0 -1000
- /package/dist/{chunk-3LV6RRPH.js.map → chunk-QGYDWPRM.js.map} +0 -0
|
@@ -28,6 +28,26 @@ interface MentionOptions extends Partial<MentionOptions$1> {
|
|
|
28
28
|
* Creates atomic inline <span data-type="mention"> nodes with full suggestion support.
|
|
29
29
|
*/
|
|
30
30
|
declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
|
|
31
|
+
/** Mention nodes in a document, with their positions (for role pickers). */
|
|
32
|
+
interface MentionNodeInfo {
|
|
33
|
+
pos: number;
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
role?: string;
|
|
38
|
+
}
|
|
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[];
|
|
45
|
+
/**
|
|
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.
|
|
49
|
+
*/
|
|
50
|
+
declare function setMentionRoleAt(editor: any, pos: number, role: string | null): boolean;
|
|
31
51
|
/**
|
|
32
52
|
* Helper to configure the Mention extension with preset defaults.
|
|
33
53
|
*/
|
|
@@ -39,12 +59,18 @@ declare const DELETION_MARK_NAME = "deletion";
|
|
|
39
59
|
declare const FORMAT_CHANGE_MARK_NAME = "formatChange";
|
|
40
60
|
/** Node attribute recording a tracked block change (type, attributes or wrapping). */
|
|
41
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";
|
|
42
68
|
/**
|
|
43
69
|
* Set this transaction meta to `true` to apply a change without tracking it,
|
|
44
70
|
* e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
|
|
45
71
|
*/
|
|
46
72
|
declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
|
|
47
|
-
type TrackedChangeType = "insertion" | "deletion" | "format" | "block";
|
|
73
|
+
type TrackedChangeType = "insertion" | "deletion" | "format" | "block" | "move";
|
|
48
74
|
/**
|
|
49
75
|
* How tracked content is rendered by serializers:
|
|
50
76
|
* - `accepted` (default): as if every change were accepted (deleted text is
|
|
@@ -59,6 +85,11 @@ interface TrackedChangeAttributes {
|
|
|
59
85
|
authorName: string;
|
|
60
86
|
authorColor: string | null;
|
|
61
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;
|
|
62
93
|
}
|
|
63
94
|
/** A serializable mark (`mark.toJSON()`). */
|
|
64
95
|
interface TrackedMark {
|
|
@@ -132,6 +163,24 @@ interface TrackedChange {
|
|
|
132
163
|
current: TrackedBlockSnapshot;
|
|
133
164
|
operation?: TrackedBlockOperation;
|
|
134
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;
|
|
183
|
+
};
|
|
135
184
|
}
|
|
136
185
|
interface TrackChangesSnapshot {
|
|
137
186
|
enabled: boolean;
|
|
@@ -172,6 +221,19 @@ interface TrackChangesOptions {
|
|
|
172
221
|
ignoredMarks: string[];
|
|
173
222
|
/** Node attributes ignored when comparing blocks (e.g. generated ids). */
|
|
174
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>;
|
|
175
237
|
}
|
|
176
238
|
/**
|
|
177
239
|
* External store over the editor's tracked-change state. Snapshots only
|
|
@@ -207,27 +269,39 @@ declare module "@tiptap/core" {
|
|
|
207
269
|
/** Rejects one change (single undo step). */
|
|
208
270
|
rejectChange: (id: string) => ReturnType;
|
|
209
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;
|
|
210
276
|
rejectAllChanges: () => ReturnType;
|
|
211
277
|
/** Selects the next change after the selection, wrapping around. */
|
|
212
278
|
selectNextChange: () => ReturnType;
|
|
213
279
|
/** Selects the previous change before the selection, wrapping around. */
|
|
214
280
|
selectPreviousChange: () => ReturnType;
|
|
281
|
+
/** Selects a change (a move's destination, a block change's content). */
|
|
282
|
+
selectChange: (id: string) => ReturnType;
|
|
215
283
|
};
|
|
216
284
|
}
|
|
217
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";
|
|
218
294
|
/**
|
|
219
|
-
* 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.
|
|
220
297
|
*/
|
|
221
|
-
declare const TrackedInsertion: Mark<
|
|
222
|
-
HTMLAttributes: Record<string, any>;
|
|
223
|
-
}, any>;
|
|
298
|
+
declare const TrackedInsertion: Mark<TrackedMarkOptions, any>;
|
|
224
299
|
/**
|
|
225
300
|
* Text deleted while tracking was on. The text stays in the document until
|
|
226
|
-
* 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.
|
|
227
303
|
*/
|
|
228
|
-
declare const TrackedDeletion: Mark<
|
|
229
|
-
HTMLAttributes: Record<string, any>;
|
|
230
|
-
}, any>;
|
|
304
|
+
declare const TrackedDeletion: Mark<TrackedMarkOptions, any>;
|
|
231
305
|
/**
|
|
232
306
|
* Existing text whose formatting changed while tracking was on. Stores the
|
|
233
307
|
* formatting before and after the change, rendered as
|
|
@@ -240,6 +314,8 @@ declare const TrackedFormatChange: Mark<{
|
|
|
240
314
|
declare function describeFormatChange(summary: TrackedFormatSummary): string;
|
|
241
315
|
/** Describes a block change, e.g. `Changed Paragraph to Heading 2`. */
|
|
242
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;
|
|
243
319
|
/**
|
|
244
320
|
* Lists tracked changes in document order. Accepts an editor, an editor
|
|
245
321
|
* state or a ProseMirror document.
|
|
@@ -255,17 +331,25 @@ declare function getTrackChangesStore(editor: Editor | null | undefined): TrackC
|
|
|
255
331
|
* (`accepted` by default). The input document is not modified.
|
|
256
332
|
*/
|
|
257
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;
|
|
258
340
|
/**
|
|
259
341
|
* Suggestion mode / track changes. When enabled, typed and pasted content is
|
|
260
342
|
* marked as an insertion and deleted content is kept but marked as a
|
|
261
343
|
* deletion (struck through) until the change is accepted or rejected.
|
|
262
344
|
* Formatting changes on existing text are recorded with the `formatChange`
|
|
263
345
|
* mark, and textblock type/attribute/wrapping changes with the `blockChange`
|
|
264
|
-
* 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.
|
|
265
349
|
*
|
|
266
350
|
* Deleting your own insertion really deletes it. Paragraph splits and joins
|
|
267
351
|
* are not tracked. IME composition is tracked once the composition ends.
|
|
268
352
|
*/
|
|
269
353
|
declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
|
|
270
354
|
|
|
271
|
-
export {
|
|
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 };
|
|
@@ -28,6 +28,26 @@ interface MentionOptions extends Partial<MentionOptions$1> {
|
|
|
28
28
|
* Creates atomic inline <span data-type="mention"> nodes with full suggestion support.
|
|
29
29
|
*/
|
|
30
30
|
declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
|
|
31
|
+
/** Mention nodes in a document, with their positions (for role pickers). */
|
|
32
|
+
interface MentionNodeInfo {
|
|
33
|
+
pos: number;
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
role?: string;
|
|
38
|
+
}
|
|
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[];
|
|
45
|
+
/**
|
|
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.
|
|
49
|
+
*/
|
|
50
|
+
declare function setMentionRoleAt(editor: any, pos: number, role: string | null): boolean;
|
|
31
51
|
/**
|
|
32
52
|
* Helper to configure the Mention extension with preset defaults.
|
|
33
53
|
*/
|
|
@@ -39,12 +59,18 @@ declare const DELETION_MARK_NAME = "deletion";
|
|
|
39
59
|
declare const FORMAT_CHANGE_MARK_NAME = "formatChange";
|
|
40
60
|
/** Node attribute recording a tracked block change (type, attributes or wrapping). */
|
|
41
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";
|
|
42
68
|
/**
|
|
43
69
|
* Set this transaction meta to `true` to apply a change without tracking it,
|
|
44
70
|
* e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
|
|
45
71
|
*/
|
|
46
72
|
declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
|
|
47
|
-
type TrackedChangeType = "insertion" | "deletion" | "format" | "block";
|
|
73
|
+
type TrackedChangeType = "insertion" | "deletion" | "format" | "block" | "move";
|
|
48
74
|
/**
|
|
49
75
|
* How tracked content is rendered by serializers:
|
|
50
76
|
* - `accepted` (default): as if every change were accepted (deleted text is
|
|
@@ -59,6 +85,11 @@ interface TrackedChangeAttributes {
|
|
|
59
85
|
authorName: string;
|
|
60
86
|
authorColor: string | null;
|
|
61
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;
|
|
62
93
|
}
|
|
63
94
|
/** A serializable mark (`mark.toJSON()`). */
|
|
64
95
|
interface TrackedMark {
|
|
@@ -132,6 +163,24 @@ interface TrackedChange {
|
|
|
132
163
|
current: TrackedBlockSnapshot;
|
|
133
164
|
operation?: TrackedBlockOperation;
|
|
134
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;
|
|
183
|
+
};
|
|
135
184
|
}
|
|
136
185
|
interface TrackChangesSnapshot {
|
|
137
186
|
enabled: boolean;
|
|
@@ -172,6 +221,19 @@ interface TrackChangesOptions {
|
|
|
172
221
|
ignoredMarks: string[];
|
|
173
222
|
/** Node attributes ignored when comparing blocks (e.g. generated ids). */
|
|
174
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>;
|
|
175
237
|
}
|
|
176
238
|
/**
|
|
177
239
|
* External store over the editor's tracked-change state. Snapshots only
|
|
@@ -207,27 +269,39 @@ declare module "@tiptap/core" {
|
|
|
207
269
|
/** Rejects one change (single undo step). */
|
|
208
270
|
rejectChange: (id: string) => ReturnType;
|
|
209
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;
|
|
210
276
|
rejectAllChanges: () => ReturnType;
|
|
211
277
|
/** Selects the next change after the selection, wrapping around. */
|
|
212
278
|
selectNextChange: () => ReturnType;
|
|
213
279
|
/** Selects the previous change before the selection, wrapping around. */
|
|
214
280
|
selectPreviousChange: () => ReturnType;
|
|
281
|
+
/** Selects a change (a move's destination, a block change's content). */
|
|
282
|
+
selectChange: (id: string) => ReturnType;
|
|
215
283
|
};
|
|
216
284
|
}
|
|
217
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";
|
|
218
294
|
/**
|
|
219
|
-
* 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.
|
|
220
297
|
*/
|
|
221
|
-
declare const TrackedInsertion: Mark<
|
|
222
|
-
HTMLAttributes: Record<string, any>;
|
|
223
|
-
}, any>;
|
|
298
|
+
declare const TrackedInsertion: Mark<TrackedMarkOptions, any>;
|
|
224
299
|
/**
|
|
225
300
|
* Text deleted while tracking was on. The text stays in the document until
|
|
226
|
-
* 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.
|
|
227
303
|
*/
|
|
228
|
-
declare const TrackedDeletion: Mark<
|
|
229
|
-
HTMLAttributes: Record<string, any>;
|
|
230
|
-
}, any>;
|
|
304
|
+
declare const TrackedDeletion: Mark<TrackedMarkOptions, any>;
|
|
231
305
|
/**
|
|
232
306
|
* Existing text whose formatting changed while tracking was on. Stores the
|
|
233
307
|
* formatting before and after the change, rendered as
|
|
@@ -240,6 +314,8 @@ declare const TrackedFormatChange: Mark<{
|
|
|
240
314
|
declare function describeFormatChange(summary: TrackedFormatSummary): string;
|
|
241
315
|
/** Describes a block change, e.g. `Changed Paragraph to Heading 2`. */
|
|
242
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;
|
|
243
319
|
/**
|
|
244
320
|
* Lists tracked changes in document order. Accepts an editor, an editor
|
|
245
321
|
* state or a ProseMirror document.
|
|
@@ -255,17 +331,25 @@ declare function getTrackChangesStore(editor: Editor | null | undefined): TrackC
|
|
|
255
331
|
* (`accepted` by default). The input document is not modified.
|
|
256
332
|
*/
|
|
257
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;
|
|
258
340
|
/**
|
|
259
341
|
* Suggestion mode / track changes. When enabled, typed and pasted content is
|
|
260
342
|
* marked as an insertion and deleted content is kept but marked as a
|
|
261
343
|
* deletion (struck through) until the change is accepted or rejected.
|
|
262
344
|
* Formatting changes on existing text are recorded with the `formatChange`
|
|
263
345
|
* mark, and textblock type/attribute/wrapping changes with the `blockChange`
|
|
264
|
-
* 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.
|
|
265
349
|
*
|
|
266
350
|
* Deleting your own insertion really deletes it. Paragraph splits and joins
|
|
267
351
|
* are not tracked. IME composition is tracked once the composition ends.
|
|
268
352
|
*/
|
|
269
353
|
declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
|
|
270
354
|
|
|
271
|
-
export {
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "UI-agnostic rich text and media editing core library",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -78,6 +78,11 @@
|
|
|
78
78
|
"types": "./dist/compare/index.d.ts",
|
|
79
79
|
"import": "./dist/compare/index.js",
|
|
80
80
|
"require": "./dist/compare/index.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./tokens": {
|
|
83
|
+
"types": "./dist/tokens/index.d.ts",
|
|
84
|
+
"import": "./dist/tokens/index.js",
|
|
85
|
+
"require": "./dist/tokens/index.cjs"
|
|
81
86
|
}
|
|
82
87
|
},
|
|
83
88
|
"files": [
|