@pixerate/editor 0.21.0 → 0.23.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 +100 -13
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +86 -111
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +77 -102
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +2112 -60
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +712 -181
- package/dist/canvas/index.d.ts +712 -181
- package/dist/canvas/index.js +2105 -53
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/{chunk-TVRC4KVT.cjs → chunk-AA4ZEVCC.cjs} +845 -90
- package/dist/chunk-AA4ZEVCC.cjs.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/{chunk-LA7PEGU3.cjs → chunk-CL37JGFW.cjs} +4 -4
- package/dist/{chunk-LA7PEGU3.cjs.map → chunk-CL37JGFW.cjs.map} +1 -1
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-4QPLEUL2.cjs → chunk-GVSMRPHB.cjs} +1046 -54
- package/dist/chunk-GVSMRPHB.cjs.map +1 -0
- package/dist/{chunk-KYRZDWM4.js → chunk-JJDLPEWL.js} +2 -2
- package/dist/{chunk-GVW4P7BG.js → chunk-K3R5NG2D.js} +448 -54
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-3TYMNULT.js → chunk-MJZBNWG7.js} +807 -52
- package/dist/chunk-MJZBNWG7.js.map +1 -0
- package/dist/{chunk-A7DKIA72.js → chunk-QBJ22YZR.js} +1059 -93
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-CYFJCKC4.js → chunk-QGHGJ56O.js} +997 -5
- package/dist/chunk-QGHGJ56O.js.map +1 -0
- package/dist/{chunk-JYRIOFEN.cjs → chunk-RIKBJLS2.cjs} +1064 -98
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-U6NDQFOK.cjs → chunk-XDMXXC4Z.cjs} +569 -175
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-OUdxPY-X.d.ts → controller-pePCJLT1.d.cts} +216 -11
- package/dist/{controller-OUdxPY-X.d.cts → controller-pePCJLT1.d.ts} +216 -11
- package/dist/extensions/index.cjs +14 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +3 -3
- package/dist/extensions/index.d.ts +3 -3
- package/dist/extensions/index.js +13 -3
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-k3mFbPx_.d.cts → index-CCr_z9kF.d.cts} +3 -3
- package/dist/{index-Ng1pG7JE.d.ts → index-Ck6ajwXh.d.ts} +3 -3
- package/dist/index.cjs +275 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +296 -47
- package/dist/index.d.ts +296 -47
- package/dist/index.js +266 -74
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/{registry-iAHbqkYt.d.cts → registry-GJI4gToU.d.cts} +15 -4
- package/dist/{registry-iAHbqkYt.d.ts → registry-GJI4gToU.d.ts} +15 -4
- package/dist/serializers/index.cjs +3 -3
- package/dist/serializers/index.d.cts +1 -1
- package/dist/serializers/index.d.ts +1 -1
- package/dist/serializers/index.js +2 -2
- package/dist/spreadsheet/index.cjs +23 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +97 -10
- package/dist/spreadsheet/index.d.ts +97 -10
- package/dist/spreadsheet/index.js +22 -2
- package/dist/{track-changes-G8JcWB8b.d.cts → track-changes-BSF58RK0.d.cts} +92 -9
- package/dist/{track-changes-G8JcWB8b.d.ts → track-changes-BSF58RK0.d.ts} +92 -9
- package/dist/{types-DMe0vFB1.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-DMe0vFB1.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-3TYMNULT.js.map +0 -1
- package/dist/chunk-4QPLEUL2.cjs.map +0 -1
- package/dist/chunk-A7DKIA72.js.map +0 -1
- package/dist/chunk-CYFJCKC4.js.map +0 -1
- package/dist/chunk-GVW4P7BG.js.map +0 -1
- package/dist/chunk-JYRIOFEN.cjs.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-TVRC4KVT.cjs.map +0 -1
- package/dist/chunk-U6NDQFOK.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
- /package/dist/{chunk-KYRZDWM4.js.map → chunk-JJDLPEWL.js.map} +0 -0
|
@@ -168,18 +168,22 @@ declare function formatReviewTime(timestamp: number, now?: number): string;
|
|
|
168
168
|
|
|
169
169
|
declare const INSERTION_MARK_NAME = "insertion";
|
|
170
170
|
declare const DELETION_MARK_NAME = "deletion";
|
|
171
|
+
/** Mark recording a tracked formatting change (mark added/removed on existing text). */
|
|
172
|
+
declare const FORMAT_CHANGE_MARK_NAME = "formatChange";
|
|
173
|
+
/** Node attribute recording a tracked block change (type, attributes or wrapping). */
|
|
174
|
+
declare const BLOCK_CHANGE_ATTRIBUTE = "blockChange";
|
|
171
175
|
/**
|
|
172
176
|
* Set this transaction meta to `true` to apply a change without tracking it,
|
|
173
177
|
* e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
|
|
174
178
|
*/
|
|
175
179
|
declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
|
|
176
|
-
type TrackedChangeType = "insertion" | "deletion";
|
|
180
|
+
type TrackedChangeType = "insertion" | "deletion" | "format" | "block";
|
|
177
181
|
/**
|
|
178
182
|
* How tracked content is rendered by serializers:
|
|
179
183
|
* - `accepted` (default): as if every change were accepted (deleted text is
|
|
180
|
-
* dropped, inserted text kept).
|
|
184
|
+
* dropped, inserted text kept, new formatting and block types kept).
|
|
181
185
|
* - `original`: as if every change were rejected.
|
|
182
|
-
* - `all`: both inserted and deleted text.
|
|
186
|
+
* - `all`: both inserted and deleted text, current formatting and blocks.
|
|
183
187
|
*/
|
|
184
188
|
type TrackedChangesView = "accepted" | "original" | "all";
|
|
185
189
|
interface TrackedChangeAttributes {
|
|
@@ -189,6 +193,40 @@ interface TrackedChangeAttributes {
|
|
|
189
193
|
authorColor: string | null;
|
|
190
194
|
createdAt: number;
|
|
191
195
|
}
|
|
196
|
+
/** A serializable mark (`mark.toJSON()`). */
|
|
197
|
+
interface TrackedMark {
|
|
198
|
+
type: string;
|
|
199
|
+
attrs?: Record<string, any>;
|
|
200
|
+
}
|
|
201
|
+
/** Attributes of the `formatChange` mark. */
|
|
202
|
+
interface TrackedFormatChangeAttributes extends TrackedChangeAttributes {
|
|
203
|
+
/** Formatting marks before the change. */
|
|
204
|
+
before: TrackedMark[];
|
|
205
|
+
/** Formatting marks after the change. */
|
|
206
|
+
after: TrackedMark[];
|
|
207
|
+
}
|
|
208
|
+
/** A textblock's type, attributes and enclosing wrappers (lists, quotes). */
|
|
209
|
+
interface TrackedBlockSnapshot {
|
|
210
|
+
type: string;
|
|
211
|
+
attrs: Record<string, any>;
|
|
212
|
+
/** Ancestors from the outermost (below the document) to the parent. */
|
|
213
|
+
wrappers: {
|
|
214
|
+
type: string;
|
|
215
|
+
attrs: Record<string, any>;
|
|
216
|
+
}[];
|
|
217
|
+
}
|
|
218
|
+
/** Value of the `blockChange` node attribute. */
|
|
219
|
+
interface TrackedBlockChangeAttributes extends TrackedChangeAttributes {
|
|
220
|
+
previous: TrackedBlockSnapshot;
|
|
221
|
+
}
|
|
222
|
+
interface TrackedFormatSummary {
|
|
223
|
+
/** Labels of added formatting, e.g. `["Bold"]`. */
|
|
224
|
+
added: string[];
|
|
225
|
+
/** Labels of removed formatting. */
|
|
226
|
+
removed: string[];
|
|
227
|
+
/** Labels of changed formatting (same mark, different attributes), e.g. `["Font size"]`. */
|
|
228
|
+
changed: string[];
|
|
229
|
+
}
|
|
192
230
|
interface TrackedChange {
|
|
193
231
|
id: string;
|
|
194
232
|
type: TrackedChangeType;
|
|
@@ -198,12 +236,24 @@ interface TrackedChange {
|
|
|
198
236
|
from: number;
|
|
199
237
|
/** End of the last range. */
|
|
200
238
|
to: number;
|
|
201
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* A change can be split into several ranges by other marks or blocks.
|
|
241
|
+
* Block changes cover whole textblock nodes.
|
|
242
|
+
*/
|
|
202
243
|
ranges: {
|
|
203
244
|
from: number;
|
|
204
245
|
to: number;
|
|
205
246
|
}[];
|
|
206
247
|
text: string;
|
|
248
|
+
/** Human-readable summary, e.g. `Formatted: Bold` or `Changed Paragraph to Heading 2`. */
|
|
249
|
+
description: string;
|
|
250
|
+
/** Formatting changes (`type: "format"`). */
|
|
251
|
+
format?: TrackedFormatSummary;
|
|
252
|
+
/** Block changes (`type: "block"`): the first block's previous and current state. */
|
|
253
|
+
block?: {
|
|
254
|
+
previous: TrackedBlockSnapshot;
|
|
255
|
+
current: TrackedBlockSnapshot;
|
|
256
|
+
};
|
|
207
257
|
}
|
|
208
258
|
interface TrackChangesSnapshot {
|
|
209
259
|
enabled: boolean;
|
|
@@ -221,6 +271,25 @@ interface TrackChangesOptions {
|
|
|
221
271
|
generateId: () => string;
|
|
222
272
|
insertionHTMLAttributes: Record<string, any>;
|
|
223
273
|
deletionHTMLAttributes: Record<string, any>;
|
|
274
|
+
/** HTML attributes (e.g. `class`) of tracked formatting. Replaces the default dotted underline. */
|
|
275
|
+
formatChangeHTMLAttributes: Record<string, any>;
|
|
276
|
+
/** Class added to blocks with a tracked block change (margin bar by default). */
|
|
277
|
+
blockChangeClass: string;
|
|
278
|
+
/** Track mark changes (bold, links, font size, …) on existing text. Default `true`. */
|
|
279
|
+
trackFormatting: boolean;
|
|
280
|
+
/** Track textblock type/attribute and wrapping (list, quote) changes. Default `true`. */
|
|
281
|
+
trackBlocks: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Track insertions and deletions inside code blocks by allowing the
|
|
284
|
+
* insertion/deletion marks there. Default `true`.
|
|
285
|
+
*/
|
|
286
|
+
trackCodeBlocks: boolean;
|
|
287
|
+
/** Textblock node types that can record block changes. */
|
|
288
|
+
blockTypes: string[];
|
|
289
|
+
/** Extra mark names not tracked as formatting. */
|
|
290
|
+
ignoredMarks: string[];
|
|
291
|
+
/** Node attributes ignored when comparing blocks (e.g. generated ids). */
|
|
292
|
+
ignoredBlockAttributes: string[];
|
|
224
293
|
}
|
|
225
294
|
/**
|
|
226
295
|
* External store over the editor's tracked-change state. Snapshots only
|
|
@@ -277,12 +346,24 @@ declare const TrackedInsertion: Mark<{
|
|
|
277
346
|
declare const TrackedDeletion: Mark<{
|
|
278
347
|
HTMLAttributes: Record<string, any>;
|
|
279
348
|
}, any>;
|
|
349
|
+
/**
|
|
350
|
+
* Existing text whose formatting changed while tracking was on. Stores the
|
|
351
|
+
* formatting before and after the change, rendered as
|
|
352
|
+
* `<span data-change-type="format">` (dotted underline by default).
|
|
353
|
+
*/
|
|
354
|
+
declare const TrackedFormatChange: Mark<{
|
|
355
|
+
HTMLAttributes: Record<string, any>;
|
|
356
|
+
}, any>;
|
|
357
|
+
/** Describes a formatting change, e.g. `Formatted: Bold; Removed formatting: Italic`. */
|
|
358
|
+
declare function describeFormatChange(summary: TrackedFormatSummary): string;
|
|
359
|
+
/** Describes a block change, e.g. `Changed Paragraph to Heading 2`. */
|
|
360
|
+
declare function describeBlockChange(previous: TrackedBlockSnapshot, current: TrackedBlockSnapshot, ignoredAttributes?: readonly string[]): string;
|
|
280
361
|
/**
|
|
281
362
|
* Lists tracked changes in document order. Accepts an editor, an editor
|
|
282
363
|
* state or a ProseMirror document.
|
|
283
364
|
*/
|
|
284
365
|
declare function getTrackedChanges(source: Editor | EditorState | Node | null | undefined): TrackedChange[];
|
|
285
|
-
/** The change containing `pos` (defaults to the selection start). */
|
|
366
|
+
/** The change containing `pos` (defaults to the selection start). Inline changes win over block changes. */
|
|
286
367
|
declare function getTrackedChangeAt(state: EditorState, pos?: number, changes?: readonly TrackedChange[]): TrackedChange | null;
|
|
287
368
|
declare function isTrackChangesEnabled(source: Editor | EditorState | null | undefined): boolean;
|
|
288
369
|
/** Returns the tracked-changes store of an editor using `TrackChanges`. */
|
|
@@ -296,11 +377,13 @@ declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): No
|
|
|
296
377
|
* Suggestion mode / track changes. When enabled, typed and pasted content is
|
|
297
378
|
* marked as an insertion and deleted content is kept but marked as a
|
|
298
379
|
* deletion (struck through) until the change is accepted or rejected.
|
|
380
|
+
* Formatting changes on existing text are recorded with the `formatChange`
|
|
381
|
+
* mark, and textblock type/attribute/wrapping changes with the `blockChange`
|
|
382
|
+
* node attribute.
|
|
299
383
|
*
|
|
300
|
-
* Deleting your own insertion really deletes it.
|
|
301
|
-
*
|
|
302
|
-
* tracked. IME composition is tracked once the composition ends.
|
|
384
|
+
* Deleting your own insertion really deletes it. Paragraph splits and joins
|
|
385
|
+
* are not tracked. IME composition is tracked once the composition ends.
|
|
303
386
|
*/
|
|
304
387
|
declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
|
|
305
388
|
|
|
306
|
-
export {
|
|
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 };
|
|
@@ -168,18 +168,22 @@ declare function formatReviewTime(timestamp: number, now?: number): string;
|
|
|
168
168
|
|
|
169
169
|
declare const INSERTION_MARK_NAME = "insertion";
|
|
170
170
|
declare const DELETION_MARK_NAME = "deletion";
|
|
171
|
+
/** Mark recording a tracked formatting change (mark added/removed on existing text). */
|
|
172
|
+
declare const FORMAT_CHANGE_MARK_NAME = "formatChange";
|
|
173
|
+
/** Node attribute recording a tracked block change (type, attributes or wrapping). */
|
|
174
|
+
declare const BLOCK_CHANGE_ATTRIBUTE = "blockChange";
|
|
171
175
|
/**
|
|
172
176
|
* Set this transaction meta to `true` to apply a change without tracking it,
|
|
173
177
|
* e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
|
|
174
178
|
*/
|
|
175
179
|
declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
|
|
176
|
-
type TrackedChangeType = "insertion" | "deletion";
|
|
180
|
+
type TrackedChangeType = "insertion" | "deletion" | "format" | "block";
|
|
177
181
|
/**
|
|
178
182
|
* How tracked content is rendered by serializers:
|
|
179
183
|
* - `accepted` (default): as if every change were accepted (deleted text is
|
|
180
|
-
* dropped, inserted text kept).
|
|
184
|
+
* dropped, inserted text kept, new formatting and block types kept).
|
|
181
185
|
* - `original`: as if every change were rejected.
|
|
182
|
-
* - `all`: both inserted and deleted text.
|
|
186
|
+
* - `all`: both inserted and deleted text, current formatting and blocks.
|
|
183
187
|
*/
|
|
184
188
|
type TrackedChangesView = "accepted" | "original" | "all";
|
|
185
189
|
interface TrackedChangeAttributes {
|
|
@@ -189,6 +193,40 @@ interface TrackedChangeAttributes {
|
|
|
189
193
|
authorColor: string | null;
|
|
190
194
|
createdAt: number;
|
|
191
195
|
}
|
|
196
|
+
/** A serializable mark (`mark.toJSON()`). */
|
|
197
|
+
interface TrackedMark {
|
|
198
|
+
type: string;
|
|
199
|
+
attrs?: Record<string, any>;
|
|
200
|
+
}
|
|
201
|
+
/** Attributes of the `formatChange` mark. */
|
|
202
|
+
interface TrackedFormatChangeAttributes extends TrackedChangeAttributes {
|
|
203
|
+
/** Formatting marks before the change. */
|
|
204
|
+
before: TrackedMark[];
|
|
205
|
+
/** Formatting marks after the change. */
|
|
206
|
+
after: TrackedMark[];
|
|
207
|
+
}
|
|
208
|
+
/** A textblock's type, attributes and enclosing wrappers (lists, quotes). */
|
|
209
|
+
interface TrackedBlockSnapshot {
|
|
210
|
+
type: string;
|
|
211
|
+
attrs: Record<string, any>;
|
|
212
|
+
/** Ancestors from the outermost (below the document) to the parent. */
|
|
213
|
+
wrappers: {
|
|
214
|
+
type: string;
|
|
215
|
+
attrs: Record<string, any>;
|
|
216
|
+
}[];
|
|
217
|
+
}
|
|
218
|
+
/** Value of the `blockChange` node attribute. */
|
|
219
|
+
interface TrackedBlockChangeAttributes extends TrackedChangeAttributes {
|
|
220
|
+
previous: TrackedBlockSnapshot;
|
|
221
|
+
}
|
|
222
|
+
interface TrackedFormatSummary {
|
|
223
|
+
/** Labels of added formatting, e.g. `["Bold"]`. */
|
|
224
|
+
added: string[];
|
|
225
|
+
/** Labels of removed formatting. */
|
|
226
|
+
removed: string[];
|
|
227
|
+
/** Labels of changed formatting (same mark, different attributes), e.g. `["Font size"]`. */
|
|
228
|
+
changed: string[];
|
|
229
|
+
}
|
|
192
230
|
interface TrackedChange {
|
|
193
231
|
id: string;
|
|
194
232
|
type: TrackedChangeType;
|
|
@@ -198,12 +236,24 @@ interface TrackedChange {
|
|
|
198
236
|
from: number;
|
|
199
237
|
/** End of the last range. */
|
|
200
238
|
to: number;
|
|
201
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* A change can be split into several ranges by other marks or blocks.
|
|
241
|
+
* Block changes cover whole textblock nodes.
|
|
242
|
+
*/
|
|
202
243
|
ranges: {
|
|
203
244
|
from: number;
|
|
204
245
|
to: number;
|
|
205
246
|
}[];
|
|
206
247
|
text: string;
|
|
248
|
+
/** Human-readable summary, e.g. `Formatted: Bold` or `Changed Paragraph to Heading 2`. */
|
|
249
|
+
description: string;
|
|
250
|
+
/** Formatting changes (`type: "format"`). */
|
|
251
|
+
format?: TrackedFormatSummary;
|
|
252
|
+
/** Block changes (`type: "block"`): the first block's previous and current state. */
|
|
253
|
+
block?: {
|
|
254
|
+
previous: TrackedBlockSnapshot;
|
|
255
|
+
current: TrackedBlockSnapshot;
|
|
256
|
+
};
|
|
207
257
|
}
|
|
208
258
|
interface TrackChangesSnapshot {
|
|
209
259
|
enabled: boolean;
|
|
@@ -221,6 +271,25 @@ interface TrackChangesOptions {
|
|
|
221
271
|
generateId: () => string;
|
|
222
272
|
insertionHTMLAttributes: Record<string, any>;
|
|
223
273
|
deletionHTMLAttributes: Record<string, any>;
|
|
274
|
+
/** HTML attributes (e.g. `class`) of tracked formatting. Replaces the default dotted underline. */
|
|
275
|
+
formatChangeHTMLAttributes: Record<string, any>;
|
|
276
|
+
/** Class added to blocks with a tracked block change (margin bar by default). */
|
|
277
|
+
blockChangeClass: string;
|
|
278
|
+
/** Track mark changes (bold, links, font size, …) on existing text. Default `true`. */
|
|
279
|
+
trackFormatting: boolean;
|
|
280
|
+
/** Track textblock type/attribute and wrapping (list, quote) changes. Default `true`. */
|
|
281
|
+
trackBlocks: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Track insertions and deletions inside code blocks by allowing the
|
|
284
|
+
* insertion/deletion marks there. Default `true`.
|
|
285
|
+
*/
|
|
286
|
+
trackCodeBlocks: boolean;
|
|
287
|
+
/** Textblock node types that can record block changes. */
|
|
288
|
+
blockTypes: string[];
|
|
289
|
+
/** Extra mark names not tracked as formatting. */
|
|
290
|
+
ignoredMarks: string[];
|
|
291
|
+
/** Node attributes ignored when comparing blocks (e.g. generated ids). */
|
|
292
|
+
ignoredBlockAttributes: string[];
|
|
224
293
|
}
|
|
225
294
|
/**
|
|
226
295
|
* External store over the editor's tracked-change state. Snapshots only
|
|
@@ -277,12 +346,24 @@ declare const TrackedInsertion: Mark<{
|
|
|
277
346
|
declare const TrackedDeletion: Mark<{
|
|
278
347
|
HTMLAttributes: Record<string, any>;
|
|
279
348
|
}, any>;
|
|
349
|
+
/**
|
|
350
|
+
* Existing text whose formatting changed while tracking was on. Stores the
|
|
351
|
+
* formatting before and after the change, rendered as
|
|
352
|
+
* `<span data-change-type="format">` (dotted underline by default).
|
|
353
|
+
*/
|
|
354
|
+
declare const TrackedFormatChange: Mark<{
|
|
355
|
+
HTMLAttributes: Record<string, any>;
|
|
356
|
+
}, any>;
|
|
357
|
+
/** Describes a formatting change, e.g. `Formatted: Bold; Removed formatting: Italic`. */
|
|
358
|
+
declare function describeFormatChange(summary: TrackedFormatSummary): string;
|
|
359
|
+
/** Describes a block change, e.g. `Changed Paragraph to Heading 2`. */
|
|
360
|
+
declare function describeBlockChange(previous: TrackedBlockSnapshot, current: TrackedBlockSnapshot, ignoredAttributes?: readonly string[]): string;
|
|
280
361
|
/**
|
|
281
362
|
* Lists tracked changes in document order. Accepts an editor, an editor
|
|
282
363
|
* state or a ProseMirror document.
|
|
283
364
|
*/
|
|
284
365
|
declare function getTrackedChanges(source: Editor | EditorState | Node | null | undefined): TrackedChange[];
|
|
285
|
-
/** The change containing `pos` (defaults to the selection start). */
|
|
366
|
+
/** The change containing `pos` (defaults to the selection start). Inline changes win over block changes. */
|
|
286
367
|
declare function getTrackedChangeAt(state: EditorState, pos?: number, changes?: readonly TrackedChange[]): TrackedChange | null;
|
|
287
368
|
declare function isTrackChangesEnabled(source: Editor | EditorState | null | undefined): boolean;
|
|
288
369
|
/** Returns the tracked-changes store of an editor using `TrackChanges`. */
|
|
@@ -296,11 +377,13 @@ declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): No
|
|
|
296
377
|
* Suggestion mode / track changes. When enabled, typed and pasted content is
|
|
297
378
|
* marked as an insertion and deleted content is kept but marked as a
|
|
298
379
|
* deletion (struck through) until the change is accepted or rejected.
|
|
380
|
+
* Formatting changes on existing text are recorded with the `formatChange`
|
|
381
|
+
* mark, and textblock type/attribute/wrapping changes with the `blockChange`
|
|
382
|
+
* node attribute.
|
|
299
383
|
*
|
|
300
|
-
* Deleting your own insertion really deletes it.
|
|
301
|
-
*
|
|
302
|
-
* tracked. IME composition is tracked once the composition ends.
|
|
384
|
+
* Deleting your own insertion really deletes it. Paragraph splits and joins
|
|
385
|
+
* are not tracked. IME composition is tracked once the composition ends.
|
|
303
386
|
*/
|
|
304
387
|
declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
|
|
305
388
|
|
|
306
|
-
export {
|
|
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 };
|
|
@@ -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,
|
|
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,
|
|
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.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "UI-agnostic rich text and media editing core library",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,10 +58,16 @@
|
|
|
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"
|
|
61
66
|
}
|
|
62
67
|
},
|
|
63
68
|
"files": [
|
|
64
|
-
"dist"
|
|
69
|
+
"dist",
|
|
70
|
+
"THIRD_PARTY_NOTICES.md"
|
|
65
71
|
],
|
|
66
72
|
"sideEffects": false,
|
|
67
73
|
"dependencies": {
|