@pixerate/editor 0.19.0 → 0.20.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 (112) hide show
  1. package/README.md +91 -2
  2. package/dist/agent/index.cjs +625 -2
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +286 -2
  5. package/dist/agent/index.d.ts +286 -2
  6. package/dist/agent/index.js +624 -1
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/canvas/index.cjs +1240 -22
  9. package/dist/canvas/index.cjs.map +1 -1
  10. package/dist/canvas/index.d.cts +515 -3
  11. package/dist/canvas/index.d.ts +515 -3
  12. package/dist/canvas/index.js +1219 -1
  13. package/dist/canvas/index.js.map +1 -1
  14. package/dist/chunk-3TYMNULT.js +1367 -0
  15. package/dist/chunk-3TYMNULT.js.map +1 -0
  16. package/dist/chunk-4QPLEUL2.cjs +4480 -0
  17. package/dist/chunk-4QPLEUL2.cjs.map +1 -0
  18. package/dist/chunk-4SUNJZWB.cjs +553 -0
  19. package/dist/chunk-4SUNJZWB.cjs.map +1 -0
  20. package/dist/chunk-A7DKIA72.js +2657 -0
  21. package/dist/chunk-A7DKIA72.js.map +1 -0
  22. package/dist/chunk-AXV2ZW34.cjs +118 -0
  23. package/dist/chunk-AXV2ZW34.cjs.map +1 -0
  24. package/dist/chunk-B2ZRLN4S.js +118 -0
  25. package/dist/chunk-B2ZRLN4S.js.map +1 -0
  26. package/dist/chunk-CYFJCKC4.js +4480 -0
  27. package/dist/chunk-CYFJCKC4.js.map +1 -0
  28. package/dist/chunk-GVW4P7BG.js +2706 -0
  29. package/dist/chunk-GVW4P7BG.js.map +1 -0
  30. package/dist/chunk-JACER6TE.cjs +1 -0
  31. package/dist/chunk-JACER6TE.cjs.map +1 -0
  32. package/dist/chunk-JYRIOFEN.cjs +2657 -0
  33. package/dist/chunk-JYRIOFEN.cjs.map +1 -0
  34. package/dist/chunk-KYRZDWM4.js +299 -0
  35. package/dist/chunk-KYRZDWM4.js.map +1 -0
  36. package/dist/chunk-LA7PEGU3.cjs +299 -0
  37. package/dist/chunk-LA7PEGU3.cjs.map +1 -0
  38. package/dist/chunk-N7FG6CBO.js +1 -0
  39. package/dist/chunk-N7FG6CBO.js.map +1 -0
  40. package/dist/chunk-OYXSKQFR.js +553 -0
  41. package/dist/chunk-OYXSKQFR.js.map +1 -0
  42. package/dist/chunk-TVRC4KVT.cjs +1367 -0
  43. package/dist/chunk-TVRC4KVT.cjs.map +1 -0
  44. package/dist/chunk-U6NDQFOK.cjs +2706 -0
  45. package/dist/chunk-U6NDQFOK.cjs.map +1 -0
  46. package/dist/controller-OUdxPY-X.d.cts +754 -0
  47. package/dist/controller-OUdxPY-X.d.ts +754 -0
  48. package/dist/extensions/index.cjs +144 -3
  49. package/dist/extensions/index.cjs.map +1 -1
  50. package/dist/extensions/index.d.cts +9 -144
  51. package/dist/extensions/index.d.ts +9 -144
  52. package/dist/extensions/index.js +145 -4
  53. package/dist/grammar/index.cjs +31 -3
  54. package/dist/grammar/index.cjs.map +1 -1
  55. package/dist/grammar/index.d.cts +239 -19
  56. package/dist/grammar/index.d.ts +239 -19
  57. package/dist/grammar/index.js +31 -3
  58. package/dist/history/index.d.cts +2 -41
  59. package/dist/history/index.d.ts +2 -41
  60. package/dist/index-Ng1pG7JE.d.ts +899 -0
  61. package/dist/index-k3mFbPx_.d.cts +899 -0
  62. package/dist/index.cjs +457 -20
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +99 -12
  65. package/dist/index.d.ts +99 -12
  66. package/dist/index.js +457 -20
  67. package/dist/index.js.map +1 -1
  68. package/dist/registry-iAHbqkYt.d.cts +128 -0
  69. package/dist/registry-iAHbqkYt.d.ts +128 -0
  70. package/dist/serializers/index.cjs +26 -3
  71. package/dist/serializers/index.cjs.map +1 -1
  72. package/dist/serializers/index.d.cts +119 -6
  73. package/dist/serializers/index.d.ts +119 -6
  74. package/dist/serializers/index.js +24 -1
  75. package/dist/spreadsheet/index.cjs +122 -2
  76. package/dist/spreadsheet/index.cjs.map +1 -1
  77. package/dist/spreadsheet/index.d.cts +371 -313
  78. package/dist/spreadsheet/index.d.ts +371 -313
  79. package/dist/spreadsheet/index.js +127 -7
  80. package/dist/tokens-CyLZmIei.d.cts +76 -0
  81. package/dist/tokens-CyLZmIei.d.ts +76 -0
  82. package/dist/track-changes-G8JcWB8b.d.cts +306 -0
  83. package/dist/track-changes-G8JcWB8b.d.ts +306 -0
  84. package/dist/types-BZgcDsC5.d.cts +42 -0
  85. package/dist/types-BZgcDsC5.d.ts +42 -0
  86. package/dist/{types-JV3S8VeR.d.cts → types-DMe0vFB1.d.cts} +1 -1
  87. package/dist/{types-JV3S8VeR.d.ts → types-DMe0vFB1.d.ts} +1 -1
  88. package/package.json +1 -1
  89. package/dist/chunk-7FWEWE6T.js +0 -1888
  90. package/dist/chunk-7FWEWE6T.js.map +0 -1
  91. package/dist/chunk-AIZUKWTL.js +0 -1715
  92. package/dist/chunk-AIZUKWTL.js.map +0 -1
  93. package/dist/chunk-GLSIZKOX.js +0 -17
  94. package/dist/chunk-GLSIZKOX.js.map +0 -1
  95. package/dist/chunk-LDES3EOS.cjs +0 -1888
  96. package/dist/chunk-LDES3EOS.cjs.map +0 -1
  97. package/dist/chunk-LLUAKTLW.cjs +0 -532
  98. package/dist/chunk-LLUAKTLW.cjs.map +0 -1
  99. package/dist/chunk-MPPXH7U5.cjs +0 -336
  100. package/dist/chunk-MPPXH7U5.cjs.map +0 -1
  101. package/dist/chunk-O7LOPQMH.js +0 -336
  102. package/dist/chunk-O7LOPQMH.js.map +0 -1
  103. package/dist/chunk-QGVMBCT5.js +0 -532
  104. package/dist/chunk-QGVMBCT5.js.map +0 -1
  105. package/dist/chunk-SEDR75VH.cjs +0 -17
  106. package/dist/chunk-SEDR75VH.cjs.map +0 -1
  107. package/dist/chunk-YQCI4CCN.cjs +0 -1715
  108. package/dist/chunk-YQCI4CCN.cjs.map +0 -1
  109. package/dist/mention-Dcevh3ff.d.cts +0 -32
  110. package/dist/mention-Dcevh3ff.d.ts +0 -32
  111. package/dist/tokens-7kRTEtPb.d.cts +0 -39
  112. package/dist/tokens-7kRTEtPb.d.ts +0 -39
@@ -1,39 +1,159 @@
1
1
  import {
2
+ DEFAULT_COLUMN_WIDTH,
3
+ DEFAULT_ROW_HEIGHT,
2
4
  DataSourceBinder,
3
5
  DependencyGraph,
6
+ SPREADSHEET_CLIPBOARD_MIME,
7
+ SPREADSHEET_IMPORT_ADAPTERS,
8
+ SPREADSHEET_TABLE_ACTIONS,
9
+ SpreadsheetController,
10
+ aggregateValues,
11
+ applyFormulaSuggestion,
12
+ bindSpreadsheetTableActions,
13
+ buildSpreadsheetView,
14
+ columnDependencyKey,
15
+ compareCellValues,
16
+ computeFillTarget,
17
+ computeRowGroups,
18
+ createSpreadsheetClipboardData,
19
+ csvImportAdapter,
20
+ escapeCsvField,
21
+ extractCellDependencies,
22
+ fillSeries,
23
+ getFillDirection,
24
+ getFormulaCaretContext,
25
+ getFormulaHints,
26
+ getRowSection,
27
+ getSpreadsheetMenuItems,
28
+ getTableSections,
29
+ importFileIntoSpreadsheet,
30
+ isBlankValue,
31
+ isSingleCellRange,
32
+ mapFormulaReferences,
33
+ matchesFilterRule,
34
+ normalizeRange,
35
+ offsetFormulaReferences,
36
+ parseCsv,
37
+ parseHtmlTable,
38
+ parseTsv,
39
+ rangeContains,
40
+ rangeContainsRange,
41
+ rangesIntersect,
42
+ readSpreadsheetClipboard,
43
+ rebaseClipboardRows,
44
+ registerSpreadsheetImportAdapters,
45
+ remapFormulaReferences,
46
+ roundFloat,
47
+ rowPassesFilters,
48
+ serializeCsv,
49
+ serializeHtmlTable,
50
+ serializeTsv,
51
+ shiftFormulaReferences,
52
+ toNumber,
53
+ tsvImportAdapter
54
+ } from "../chunk-GVW4P7BG.js";
55
+ import {
4
56
  FORMULA_ERRORS,
5
57
  FormulaEvaluator,
6
58
  FormulaParser,
7
- SpreadsheetController,
8
59
  WHOLE_COLUMN_END_ROW,
60
+ checkFormulaArgumentCount,
9
61
  colNameToIndex,
10
- columnDependencyKey,
11
- extractCellDependencies,
62
+ describeFormulaError,
63
+ formatValueWithCode,
64
+ getFormulaArgumentSpecIndex,
65
+ getFormulaFunction,
66
+ getFormulaSignature,
67
+ getFormulaSignatureParts,
12
68
  indexToColName,
13
69
  isFormulaError,
70
+ listFormulaFunctions,
14
71
  parseCellReference,
72
+ parseCriteria,
15
73
  parseFormula,
16
74
  parseRange,
17
- shiftFormulaReferences,
18
- tokenizeFormula
19
- } from "../chunk-AIZUKWTL.js";
75
+ registerFormulaFunction,
76
+ searchFormulaFunctions,
77
+ tokenizeFormula,
78
+ unregisterFormulaFunction,
79
+ wildcardToRegExp
80
+ } from "../chunk-A7DKIA72.js";
20
81
  export {
82
+ DEFAULT_COLUMN_WIDTH,
83
+ DEFAULT_ROW_HEIGHT,
21
84
  DataSourceBinder,
22
85
  DependencyGraph,
23
86
  FORMULA_ERRORS,
24
87
  FormulaEvaluator,
25
88
  FormulaParser,
89
+ SPREADSHEET_CLIPBOARD_MIME,
90
+ SPREADSHEET_IMPORT_ADAPTERS,
91
+ SPREADSHEET_TABLE_ACTIONS,
26
92
  SpreadsheetController,
27
93
  WHOLE_COLUMN_END_ROW,
94
+ aggregateValues,
95
+ applyFormulaSuggestion,
96
+ bindSpreadsheetTableActions,
97
+ buildSpreadsheetView,
98
+ checkFormulaArgumentCount,
28
99
  colNameToIndex,
29
100
  columnDependencyKey,
101
+ compareCellValues,
102
+ computeFillTarget,
103
+ computeRowGroups,
104
+ createSpreadsheetClipboardData,
105
+ csvImportAdapter,
106
+ describeFormulaError,
107
+ escapeCsvField,
30
108
  extractCellDependencies,
109
+ fillSeries,
110
+ formatValueWithCode,
111
+ getFillDirection,
112
+ getFormulaArgumentSpecIndex,
113
+ getFormulaCaretContext,
114
+ getFormulaFunction,
115
+ getFormulaHints,
116
+ getFormulaSignature,
117
+ getFormulaSignatureParts,
118
+ getRowSection,
119
+ getSpreadsheetMenuItems,
120
+ getTableSections,
121
+ importFileIntoSpreadsheet,
31
122
  indexToColName,
123
+ isBlankValue,
32
124
  isFormulaError,
125
+ isSingleCellRange,
126
+ listFormulaFunctions,
127
+ mapFormulaReferences,
128
+ matchesFilterRule,
129
+ normalizeRange,
130
+ offsetFormulaReferences,
33
131
  parseCellReference,
132
+ parseCriteria,
133
+ parseCsv,
34
134
  parseFormula,
135
+ parseHtmlTable,
35
136
  parseRange,
137
+ parseTsv,
138
+ rangeContains,
139
+ rangeContainsRange,
140
+ rangesIntersect,
141
+ readSpreadsheetClipboard,
142
+ rebaseClipboardRows,
143
+ registerFormulaFunction,
144
+ registerSpreadsheetImportAdapters,
145
+ remapFormulaReferences,
146
+ roundFloat,
147
+ rowPassesFilters,
148
+ searchFormulaFunctions,
149
+ serializeCsv,
150
+ serializeHtmlTable,
151
+ serializeTsv,
36
152
  shiftFormulaReferences,
37
- tokenizeFormula
153
+ toNumber,
154
+ tokenizeFormula,
155
+ tsvImportAdapter,
156
+ unregisterFormulaFunction,
157
+ wildcardToRegExp
38
158
  };
39
159
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Canonical regex patterns for prompt editing tokens.
3
+ */
4
+ declare const TEMPLATE_REGEX: RegExp;
5
+ /**
6
+ * `{name}`, `{name|default}`, `{name|default|description}` and the conditional
7
+ * section tags `{?name}`, `{!name}` and `{/name}`. A backslash escapes the next
8
+ * character, so `\}`, `\{` and `\|` can appear inside defaults and descriptions.
9
+ * Without backslashes this matches exactly what the original `[^{}]+` pattern did.
10
+ */
11
+ declare const VARIABLE_REGEX: RegExp;
12
+ declare const INSTRUCTION_REGEX: RegExp;
13
+ declare const templateRegex: RegExp;
14
+ declare const variableRegex: RegExp;
15
+ declare const instructionRegex: RegExp;
16
+ type TokenType = "template" | "variable" | "instruction" | "conditional" | "text";
17
+ /**
18
+ * Kind of a conditional section tag: `{?name}` opens a section kept when
19
+ * `name` has a value, `{!name}` opens one kept when it has none, and
20
+ * `{/name}` closes either.
21
+ */
22
+ type ConditionalKind = "if" | "unless" | "end";
23
+ interface Token {
24
+ type: TokenType;
25
+ raw: string;
26
+ /** Trimmed name for templates, variables and conditional tags; content otherwise. */
27
+ value: string;
28
+ start: number;
29
+ end: number;
30
+ /** Variables only: unescaped text after the first `|` (may be empty). */
31
+ defaultValue?: string;
32
+ /** Variables only: unescaped text after the second `|` (fill-in prompt). */
33
+ description?: string;
34
+ /** Conditional tags only. */
35
+ conditional?: ConditionalKind;
36
+ }
37
+ /** Values supplied for `{variable}` slots and `{?variable}` conditions. */
38
+ type PromptValue = string | number | boolean | null | undefined;
39
+ type PromptValues = Record<string, PromptValue>;
40
+ type PromptDiagnosticCode = "unclosed-section" | "unexpected-close";
41
+ /**
42
+ * A recoverable grammar problem. The offending tag is treated as literal text.
43
+ * Offsets are relative to the text that contained the tag: the input prompt,
44
+ * or the body of `templateName` when set.
45
+ */
46
+ interface PromptDiagnostic {
47
+ code: PromptDiagnosticCode;
48
+ message: string;
49
+ /** Variable named by the tag. */
50
+ name: string;
51
+ start: number;
52
+ end: number;
53
+ templateName?: string;
54
+ }
55
+ interface TemplateVersion {
56
+ id: string;
57
+ version: string | number;
58
+ body: string;
59
+ createdAt?: any;
60
+ [key: string]: any;
61
+ }
62
+ interface Template {
63
+ id?: string;
64
+ name: string;
65
+ body?: string;
66
+ latestVersion?: string | number;
67
+ versions?: TemplateVersion[];
68
+ color?: string;
69
+ [key: string]: any;
70
+ }
71
+ interface ColorGradient {
72
+ from: string;
73
+ to: string;
74
+ }
75
+
76
+ export { type ColorGradient as C, INSTRUCTION_REGEX as I, type PromptDiagnostic as P, type Token as T, VARIABLE_REGEX as V, type ConditionalKind as a, type PromptDiagnosticCode as b, type PromptValue as c, type PromptValues as d, TEMPLATE_REGEX as e, type Template as f, type TemplateVersion as g, type TokenType as h, instructionRegex as i, templateRegex as t, variableRegex as v };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Canonical regex patterns for prompt editing tokens.
3
+ */
4
+ declare const TEMPLATE_REGEX: RegExp;
5
+ /**
6
+ * `{name}`, `{name|default}`, `{name|default|description}` and the conditional
7
+ * section tags `{?name}`, `{!name}` and `{/name}`. A backslash escapes the next
8
+ * character, so `\}`, `\{` and `\|` can appear inside defaults and descriptions.
9
+ * Without backslashes this matches exactly what the original `[^{}]+` pattern did.
10
+ */
11
+ declare const VARIABLE_REGEX: RegExp;
12
+ declare const INSTRUCTION_REGEX: RegExp;
13
+ declare const templateRegex: RegExp;
14
+ declare const variableRegex: RegExp;
15
+ declare const instructionRegex: RegExp;
16
+ type TokenType = "template" | "variable" | "instruction" | "conditional" | "text";
17
+ /**
18
+ * Kind of a conditional section tag: `{?name}` opens a section kept when
19
+ * `name` has a value, `{!name}` opens one kept when it has none, and
20
+ * `{/name}` closes either.
21
+ */
22
+ type ConditionalKind = "if" | "unless" | "end";
23
+ interface Token {
24
+ type: TokenType;
25
+ raw: string;
26
+ /** Trimmed name for templates, variables and conditional tags; content otherwise. */
27
+ value: string;
28
+ start: number;
29
+ end: number;
30
+ /** Variables only: unescaped text after the first `|` (may be empty). */
31
+ defaultValue?: string;
32
+ /** Variables only: unescaped text after the second `|` (fill-in prompt). */
33
+ description?: string;
34
+ /** Conditional tags only. */
35
+ conditional?: ConditionalKind;
36
+ }
37
+ /** Values supplied for `{variable}` slots and `{?variable}` conditions. */
38
+ type PromptValue = string | number | boolean | null | undefined;
39
+ type PromptValues = Record<string, PromptValue>;
40
+ type PromptDiagnosticCode = "unclosed-section" | "unexpected-close";
41
+ /**
42
+ * A recoverable grammar problem. The offending tag is treated as literal text.
43
+ * Offsets are relative to the text that contained the tag: the input prompt,
44
+ * or the body of `templateName` when set.
45
+ */
46
+ interface PromptDiagnostic {
47
+ code: PromptDiagnosticCode;
48
+ message: string;
49
+ /** Variable named by the tag. */
50
+ name: string;
51
+ start: number;
52
+ end: number;
53
+ templateName?: string;
54
+ }
55
+ interface TemplateVersion {
56
+ id: string;
57
+ version: string | number;
58
+ body: string;
59
+ createdAt?: any;
60
+ [key: string]: any;
61
+ }
62
+ interface Template {
63
+ id?: string;
64
+ name: string;
65
+ body?: string;
66
+ latestVersion?: string | number;
67
+ versions?: TemplateVersion[];
68
+ color?: string;
69
+ [key: string]: any;
70
+ }
71
+ interface ColorGradient {
72
+ from: string;
73
+ to: string;
74
+ }
75
+
76
+ export { type ColorGradient as C, INSTRUCTION_REGEX as I, type PromptDiagnostic as P, type Token as T, VARIABLE_REGEX as V, type ConditionalKind as a, type PromptDiagnosticCode as b, type PromptValue as c, type PromptValues as d, TEMPLATE_REGEX as e, type Template as f, type TemplateVersion as g, type TokenType as h, instructionRegex as i, templateRegex as t, variableRegex as v };
@@ -0,0 +1,306 @@
1
+ import * as _tiptap_core from '@tiptap/core';
2
+ import { Extension, Mark, Editor } from '@tiptap/core';
3
+ import * as _tiptap_extension_mention from '@tiptap/extension-mention';
4
+ import { MentionOptions as MentionOptions$1 } from '@tiptap/extension-mention';
5
+ import { SuggestionOptions } from '@tiptap/suggestion';
6
+ import { EditorState, PluginKey } from '@tiptap/pm/state';
7
+ import { Node } from '@tiptap/pm/model';
8
+
9
+ interface MentionEntity {
10
+ id: string;
11
+ label: string;
12
+ type?: string;
13
+ avatarUrl?: string;
14
+ color?: string;
15
+ handle?: string;
16
+ name?: string;
17
+ hexColor?: string;
18
+ aliases?: string[];
19
+ [key: string]: any;
20
+ }
21
+ interface MentionOptions extends Partial<MentionOptions$1> {
22
+ HTMLAttributes?: Record<string, any>;
23
+ suggestion?: Partial<SuggestionOptions<MentionEntity>>;
24
+ }
25
+ /**
26
+ * First-class native Mention extension for @pixerate/editor.
27
+ * Creates atomic inline <span data-type="mention"> nodes with full suggestion support.
28
+ */
29
+ declare const Mention: _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
30
+ /**
31
+ * Helper to configure the Mention extension with preset defaults.
32
+ */
33
+ declare function createMentionExtension(options?: Partial<MentionOptions>): _tiptap_core.Node<MentionOptions$1<any, _tiptap_extension_mention.MentionNodeAttrs>, any>;
34
+
35
+ /**
36
+ * Who made a comment, reply or tracked change.
37
+ */
38
+ interface ReviewAuthor {
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
+ declare const INSERTION_MARK_NAME = "insertion";
170
+ declare const DELETION_MARK_NAME = "deletion";
171
+ /**
172
+ * Set this transaction meta to `true` to apply a change without tracking it,
173
+ * e.g. `editor.chain().command(({ tr }) => { tr.setMeta(TRACK_CHANGES_SKIP_META, true); return true; }).setContent(…).run()`.
174
+ */
175
+ declare const TRACK_CHANGES_SKIP_META = "trackChangesSkip";
176
+ type TrackedChangeType = "insertion" | "deletion";
177
+ /**
178
+ * How tracked content is rendered by serializers:
179
+ * - `accepted` (default): as if every change were accepted (deleted text is
180
+ * dropped, inserted text kept).
181
+ * - `original`: as if every change were rejected.
182
+ * - `all`: both inserted and deleted text.
183
+ */
184
+ type TrackedChangesView = "accepted" | "original" | "all";
185
+ interface TrackedChangeAttributes {
186
+ changeId: string;
187
+ authorId: string;
188
+ authorName: string;
189
+ authorColor: string | null;
190
+ createdAt: number;
191
+ }
192
+ interface TrackedChange {
193
+ id: string;
194
+ type: TrackedChangeType;
195
+ author: ReviewAuthor;
196
+ createdAt: number;
197
+ /** Start of the first range. */
198
+ from: number;
199
+ /** End of the last range. */
200
+ to: number;
201
+ /** A change can be split into several ranges by other marks or blocks. */
202
+ ranges: {
203
+ from: number;
204
+ to: number;
205
+ }[];
206
+ text: string;
207
+ }
208
+ interface TrackChangesSnapshot {
209
+ enabled: boolean;
210
+ author: ReviewAuthor;
211
+ /** Changes in document order. */
212
+ changes: readonly TrackedChange[];
213
+ /** The change at the selection, if any. */
214
+ currentChangeId: string | null;
215
+ }
216
+ interface TrackChangesOptions {
217
+ /** Whether tracking is on when the editor is created. */
218
+ enabled: boolean;
219
+ author: ReviewAuthor;
220
+ now: () => number;
221
+ generateId: () => string;
222
+ insertionHTMLAttributes: Record<string, any>;
223
+ deletionHTMLAttributes: Record<string, any>;
224
+ }
225
+ /**
226
+ * External store over the editor's tracked-change state. Snapshots only
227
+ * change when the document, selection or tracking state changes, so they can
228
+ * be used with `useSyncExternalStore`. `subscribe` calls the listener
229
+ * immediately (Svelte store contract).
230
+ */
231
+ declare class TrackChangesStore {
232
+ private snapshot;
233
+ private listeners;
234
+ constructor(initial: TrackChangesSnapshot);
235
+ subscribe: (listener: (snapshot: TrackChangesSnapshot) => void) => (() => void);
236
+ getSnapshot: () => TrackChangesSnapshot;
237
+ /** @internal Called by the extension's plugin view. */
238
+ set(snapshot: TrackChangesSnapshot): void;
239
+ }
240
+ interface TrackChangesStorage {
241
+ store: TrackChangesStore;
242
+ }
243
+ interface TrackChangesPluginState {
244
+ enabled: boolean;
245
+ author: ReviewAuthor;
246
+ }
247
+ declare const trackChangesPluginKey: PluginKey<TrackChangesPluginState>;
248
+ declare module "@tiptap/core" {
249
+ interface Commands<ReturnType> {
250
+ trackChanges: {
251
+ setTrackChanges: (enabled: boolean) => ReturnType;
252
+ toggleTrackChanges: () => ReturnType;
253
+ setTrackChangesAuthor: (author: ReviewAuthor) => ReturnType;
254
+ /** Accepts one change (single undo step). */
255
+ acceptChange: (id: string) => ReturnType;
256
+ /** Rejects one change (single undo step). */
257
+ rejectChange: (id: string) => ReturnType;
258
+ acceptAllChanges: () => ReturnType;
259
+ rejectAllChanges: () => ReturnType;
260
+ /** Selects the next change after the selection, wrapping around. */
261
+ selectNextChange: () => ReturnType;
262
+ /** Selects the previous change before the selection, wrapping around. */
263
+ selectPreviousChange: () => ReturnType;
264
+ };
265
+ }
266
+ }
267
+ /**
268
+ * Text inserted while tracking was on. Rendered as `<ins>`.
269
+ */
270
+ declare const TrackedInsertion: Mark<{
271
+ HTMLAttributes: Record<string, any>;
272
+ }, any>;
273
+ /**
274
+ * Text deleted while tracking was on. The text stays in the document until
275
+ * the change is accepted. Rendered as `<del>` (struck through).
276
+ */
277
+ declare const TrackedDeletion: Mark<{
278
+ HTMLAttributes: Record<string, any>;
279
+ }, any>;
280
+ /**
281
+ * Lists tracked changes in document order. Accepts an editor, an editor
282
+ * state or a ProseMirror document.
283
+ */
284
+ declare function getTrackedChanges(source: Editor | EditorState | Node | null | undefined): TrackedChange[];
285
+ /** The change containing `pos` (defaults to the selection start). */
286
+ declare function getTrackedChangeAt(state: EditorState, pos?: number, changes?: readonly TrackedChange[]): TrackedChange | null;
287
+ declare function isTrackChangesEnabled(source: Editor | EditorState | null | undefined): boolean;
288
+ /** Returns the tracked-changes store of an editor using `TrackChanges`. */
289
+ declare function getTrackChangesStore(editor: Editor | null | undefined): TrackChangesStore | null;
290
+ /**
291
+ * Returns a copy of `doc` with tracked changes resolved for `view`
292
+ * (`accepted` by default). The input document is not modified.
293
+ */
294
+ declare function resolveTrackedChanges(doc: Node, view?: TrackedChangesView): Node;
295
+ /**
296
+ * Suggestion mode / track changes. When enabled, typed and pasted content is
297
+ * marked as an insertion and deleted content is kept but marked as a
298
+ * deletion (struck through) until the change is accepted or rejected.
299
+ *
300
+ * Deleting your own insertion really deletes it. Formatting-only changes and
301
+ * block-structure changes (splitting/joining paragraphs, lists) are not
302
+ * tracked. IME composition is tracked once the composition ends.
303
+ */
304
+ declare const TrackChanges: Extension<TrackChangesOptions, TrackChangesStorage>;
305
+
306
+ export { getTrackedChanges as A, isTrackChangesEnabled as B, type CommentAnchor as C, DELETION_MARK_NAME as D, resolveTrackedChanges as E, trackChangesPluginKey as F, INSERTION_MARK_NAME as I, Mention as M, type ReviewAuthor as R, type SerializedComments as S, TRACK_CHANGES_SKIP_META as T, 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 TrackedChange as o, type TrackedChangeAttributes as p, type TrackedChangeType as q, type TrackedChangesView as r, TrackedDeletion as s, TrackedInsertion as t, createCommentStore as u, createMentionExtension as v, createReviewId as w, formatReviewTime as x, getTrackChangesStore as y, getTrackedChangeAt as z };