@stll/folio-core 0.73.0 → 0.74.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 (135) hide show
  1. package/dist/ai-edits/headless.js +2 -5
  2. package/dist/ai-edits/pendingJoin.js +6 -1
  3. package/dist/ai-edits/result-validation.js +1 -1
  4. package/dist/ai-edits/snapshot.js +1 -1
  5. package/dist/ai-edits/table-cell-mutations.js +1 -1
  6. package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
  7. package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
  8. package/dist/canonical/canonicalInlineGaps.js +118 -0
  9. package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
  10. package/dist/canonical/canonicalInlineProjection.js +6 -28
  11. package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
  12. package/dist/canonical/canonicalPublicOperations.js +70 -27
  13. package/dist/canonical/canonicalSelection.js +1 -1
  14. package/dist/canonical/canonicalSession.js +14 -21
  15. package/dist/controller/autocompleteSuggestion.js +1 -1
  16. package/dist/controller/canonicalClipboard.js +2 -2
  17. package/dist/controller/canonicalComposition.js +1 -1
  18. package/dist/controller/canonicalInput.js +1 -1
  19. package/dist/controller/canonicalPresence.js +1 -1
  20. package/dist/controller/canonicalRoomAuthority.js +1 -1
  21. package/dist/controller/canonicalRoomWire.js +1 -1
  22. package/dist/controller/canonicalStructure.js +1 -1
  23. package/dist/controller/canonicalTabRoom.js +1 -1
  24. package/dist/controller/canonicalYjsRoom.js +1 -1
  25. package/dist/controller/hiddenEditorApi.js +2 -17
  26. package/dist/controller/hiddenEditorManager.js +4 -8
  27. package/dist/document-operations.js +1 -1
  28. package/dist/docx/canonicalSave.d.ts +1 -1
  29. package/dist/docx/canonicalSave.js +1 -1
  30. package/dist/docx/canonicalSessionInput.js +1 -1
  31. package/dist/docx/containerChildren.js +1 -1
  32. package/dist/docx/createDocx.d.ts +4 -0
  33. package/dist/docx/createDocx.js +6 -0
  34. package/dist/docx/modelValidation.js +1 -1
  35. package/dist/docx/parser.js +1 -1
  36. package/dist/docx/reviewResolutionProvenance.js +1 -1
  37. package/dist/docx/rezip.d.ts +1 -1
  38. package/dist/docx/rezip.js +2 -2
  39. package/dist/docx/serializer/borderSerializer.js +1 -1
  40. package/dist/docx/serializer/commentSerializer.js +1 -1
  41. package/dist/docx/serializer/documentSerializer.js +1 -1
  42. package/dist/docx/serializer/paragraphSerializer.js +3 -3
  43. package/dist/docx/serializer/runSerializer.js +1 -1
  44. package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
  45. package/dist/docx/serializer/tableSerializer.js +1 -1
  46. package/dist/docx/serializer/textFormattingSerializer.js +1 -1
  47. package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
  48. package/dist/docx/server/templatePlan/apply.js +69 -11
  49. package/dist/docx/server/templatePlan/inspect.js +88 -35
  50. package/dist/docx/server/templatePlan/labels.d.ts +10 -1
  51. package/dist/docx/server/templatePlan/labels.js +31 -2
  52. package/dist/docx/server/templatePlan/plan.d.ts +2 -0
  53. package/dist/docx/server/templatePlan/plan.js +41 -7
  54. package/dist/docx/server/templatePlan/planShape.js +22 -3
  55. package/dist/docx/server/templatePlan/types.d.ts +38 -2
  56. package/dist/docx/server/templatePlan/types.js +1 -0
  57. package/dist/docx/server/templatePlan/verify.js +11 -3
  58. package/dist/docx/server/templatePlan/xml.d.ts +5 -0
  59. package/dist/docx/server/templatePlan/xml.js +7 -1
  60. package/dist/docx/storyBlockReplay.js +1 -1
  61. package/dist/docx/xmlParser.js +1 -1
  62. package/dist/i18n/loadMessages.d.ts +5 -0
  63. package/dist/i18n/loadMessages.js +46 -0
  64. package/dist/i18n/locales.d.ts +3 -0
  65. package/dist/i18n/locales.js +17 -0
  66. package/dist/i18n/messages.d.ts +3 -2
  67. package/dist/i18n/messages.js +4 -16
  68. package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
  69. package/dist/internal/clipboardTransformPlugin.js +13 -0
  70. package/dist/internal/extensionRuntime.d.ts +7 -0
  71. package/dist/internal/extensionRuntime.js +28 -0
  72. package/dist/internal/paragraphFormattingSerialization.js +1 -1
  73. package/dist/internal/starterKitExtensions.d.ts +20 -0
  74. package/dist/internal/starterKitExtensions.js +123 -0
  75. package/dist/internal/wholeStoryRevisionResolution.js +2 -2
  76. package/dist/prosemirror/attrs/index.js +1 -1
  77. package/dist/prosemirror/canonicalSelectionRange.js +1 -1
  78. package/dist/prosemirror/canonicalTableCommands.js +1 -1
  79. package/dist/prosemirror/commands/comments.js +3 -3
  80. package/dist/prosemirror/commands/contentControls.js +1 -1
  81. package/dist/prosemirror/commands/pastePlainText.js +2 -3
  82. package/dist/prosemirror/commands/replaceRangeText.js +1 -1
  83. package/dist/prosemirror/commentRecords.js +2 -2
  84. package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
  85. package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
  86. package/dist/prosemirror/conversion/index.d.ts +2 -2
  87. package/dist/prosemirror/conversion/index.js +2 -2
  88. package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
  89. package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
  90. package/dist/prosemirror/extensions/StarterKit.js +29 -115
  91. package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -2
  92. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
  93. package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
  94. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  95. package/dist/prosemirror/extensions/index.d.ts +2 -1
  96. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
  97. package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
  98. package/dist/prosemirror/hyperlinkRemoval.js +7 -2
  99. package/dist/prosemirror/index.d.ts +2 -2
  100. package/dist/prosemirror/index.js +2 -2
  101. package/dist/prosemirror/keptRangeBoundaries.js +1 -1
  102. package/dist/prosemirror/listNumbering.js +1 -1
  103. package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
  104. package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
  105. package/dist/prosemirror/noteReferenceReview.js +2 -243
  106. package/dist/prosemirror/pastedCommentCopies.js +1 -1
  107. package/dist/prosemirror/plugins/documentNumbering.js +1 -1
  108. package/dist/prosemirror/plugins/documentStyles.js +1 -1
  109. package/dist/prosemirror/replacedAnnotations.js +1 -1
  110. package/dist/prosemirror/suggestionCommands.d.ts +47 -0
  111. package/dist/prosemirror/suggestionCommands.js +31 -0
  112. package/dist/prosemirror/tableCellPaste.js +1 -1
  113. package/dist/prosemirror/tableRunIn.js +1 -1
  114. package/dist/prosemirror/textInput.js +1 -1
  115. package/dist/types/canonicalCapabilities.d.ts +6 -52
  116. package/dist/types/canonicalCapabilities.js +6 -52
  117. package/package.json +2 -2
  118. package/dist/ai-edits/apply.d.ts +0 -94
  119. package/dist/ai-edits/apply.js +0 -6637
  120. package/dist/ai-edits/note-story-inventory.d.ts +0 -5
  121. package/dist/ai-edits/note-story-inventory.js +0 -10
  122. package/dist/ai-edits/revisionStretches.d.ts +0 -32
  123. package/dist/ai-edits/revisionStretches.js +0 -147
  124. package/dist/document-operations-apply.d.ts +0 -15
  125. package/dist/document-operations-apply.js +0 -280
  126. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
  127. package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
  128. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
  129. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
  130. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
  131. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
  132. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
  133. package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
  134. package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
  135. package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
@@ -1,19 +1,8 @@
1
1
  import { withoutLostCommentThreads } from "../ai-edits/comment-lifecycle.js";
2
2
  import { visitCommentMarkers } from "../docx/commentAnchorIndex.js";
3
3
  import { isSeparatorEndnote, isSeparatorFootnote } from "../docx/footnoteParser.js";
4
- import { pluginsForHeadlessRevisionResolution } from "../internal/headlessRevisionResolutionGuard.js";
5
- import { addTrackedDeletionMark } from "./addTrackedDeletionMark.js";
6
- import { expectFootnoteRefMarkAttrs, expectParagraphAttrs } from "./attrs/index.js";
7
- import { rejectAIEditRevision } from "./commands/comments.js";
8
- import { proseDocToBlocks } from "./conversion/fromProseDoc.js";
9
- import { footnoteToProseDoc } from "./conversion/toProseDoc.js";
10
- import { createDocumentNumberingPlugin } from "./plugins/documentNumbering.js";
11
- import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
12
- import { mintRevisionId } from "./plugins/revisionIds.js";
13
- import { schema, singletonManager } from "./schema/index.js";
14
- import { Transform } from "prosemirror-transform";
4
+ import { expectFootnoteRefMarkAttrs } from "./attrs/index.js";
15
5
  import { setDocumentBodyComments } from "@stll/docx-core/model";
16
- import { EditorState } from "prosemirror-state";
17
6
  // src/prosemirror/noteReferenceReview.ts
18
7
  const noteKey = (kind, id) => `${kind}:${id}`;
19
8
  /**
@@ -34,236 +23,6 @@ const noteReferenceStates = (doc) => {
34
23
  });
35
24
  return states;
36
25
  };
37
- /** The notes whose reference a change took from pending deletion back to live. */
38
- const noteReferencesRestored = (before, after) => {
39
- const was = noteReferenceStates(before);
40
- return [...noteReferenceStates(after)].flatMap(([key, state]) => state === "live" && was.get(key) === "deleted" ? [key] : []);
41
- };
42
- /**
43
- * The revisions that deleted a note along with its reference: its text and
44
- * its paragraph marks, deleted by the reference deletion's author at its
45
- * date. A deletion in the note made some other time is a change of its own,
46
- * which resolving the reference leaves alone.
47
- */
48
- const noteDeletionRevisions = (doc, reference) => {
49
- const author = String(reference.attrs["author"] ?? "");
50
- const date = String(reference.attrs["date"] ?? "");
51
- const ids = /* @__PURE__ */ new Set();
52
- doc.descendants((node) => {
53
- if (node.type.name === "paragraph") {
54
- const mark = expectParagraphAttrs(node).pPrMark;
55
- if (mark?.kind === "del" && mark.info.author === author && mark.info.date === date) ids.add(mark.info.id);
56
- }
57
- for (const mark of node.marks) if (mark.type.name === "deletion" && String(mark.attrs["author"] ?? "") === author && String(mark.attrs["date"] ?? "") === date) {
58
- const id = mark.attrs["revisionId"];
59
- if (typeof id === "number") ids.add(id);
60
- }
61
- return true;
62
- });
63
- return [...ids];
64
- };
65
- const restoredNote = (note, document, reference) => {
66
- const { styles, theme, numbering } = document.package;
67
- const doc = footnoteToProseDoc(note.content, {
68
- ...styles !== void 0 && { styles },
69
- ...theme !== void 0 && { theme },
70
- ...numbering !== void 0 && { numbering }
71
- });
72
- const revisions = noteDeletionRevisions(doc, reference);
73
- if (revisions.length === 0) return note;
74
- let state = EditorState.create({
75
- schema,
76
- doc,
77
- plugins: [
78
- createDocumentNumberingPlugin(numbering),
79
- ...pluginsForHeadlessRevisionResolution(singletonManager.getPlugins()),
80
- createDocumentStylesPlugin(styles)
81
- ]
82
- });
83
- rejectAIEditRevision(revisions)(state, (transaction) => {
84
- state = state.apply(transaction);
85
- });
86
- if (state.doc.eq(doc)) return note;
87
- return {
88
- ...note,
89
- content: proseDocToBlocks(state.doc, note.content, styles)
90
- };
91
- };
92
- /**
93
- * The document with the named notes' deletions that went with their
94
- * reference rejected: the notes whose reference's deletion was rejected get
95
- * their text back. `before` is the body that still had those deletions.
96
- */
97
- const restoreNotes = (document, keys, before) => {
98
- const deletions = referenceDeletions(before);
99
- const wanted = new Set([...keys].filter((key) => deletions.has(key)));
100
- if (wanted.size === 0) return document;
101
- const restore = (kind, notes) => {
102
- if (!notes?.some((note) => wanted.has(noteKey(kind, note.id)))) return notes;
103
- return notes.map((note) => {
104
- const reference = deletions.get(noteKey(kind, note.id));
105
- return reference ? restoredNote(note, document, reference) : note;
106
- });
107
- };
108
- const footnotes = restore("footnote", document.package.footnotes);
109
- const endnotes = restore("endnote", document.package.endnotes);
110
- if (footnotes === document.package.footnotes && endnotes === document.package.endnotes) return document;
111
- return {
112
- ...document,
113
- package: {
114
- ...document.package,
115
- ...footnotes !== void 0 && { footnotes },
116
- ...endnotes !== void 0 && { endnotes }
117
- }
118
- };
119
- };
120
- /** The deletion each pending-deleted note reference carries. */
121
- const referenceDeletions = (doc) => {
122
- const deletions = /* @__PURE__ */ new Map();
123
- doc.descendants((node) => {
124
- if (!node.isText) return true;
125
- const reference = node.marks.find((mark) => mark.type.name === "footnoteRef");
126
- const deletion = node.marks.find((mark) => mark.type.name === "deletion");
127
- if (reference && deletion) {
128
- const { id, noteType } = expectFootnoteRefMarkAttrs(reference);
129
- deletions.set(noteKey(noteType === "endnote" ? "endnote" : "footnote", Number(id)), deletion);
130
- }
131
- return false;
132
- });
133
- return deletions;
134
- };
135
- /**
136
- * Delete a note's text and its paragraph marks along with its reference: by
137
- * the reference deletion's author at its date, so resolving the reference
138
- * resolves them too (see {@link noteDeletionRevisions}).
139
- */
140
- const deleteNoteWithReference = (transform, reference) => {
141
- const doc = transform.doc;
142
- const markInfo = {
143
- id: mintRevisionId(),
144
- author: String(reference.attrs["author"] ?? ""),
145
- date: String(reference.attrs["date"] ?? "")
146
- };
147
- const { utcDate, initials } = reference.attrs;
148
- const deletion = (doc.type.schema.marks["deletion"] ?? reference.type).create({
149
- revisionId: mintRevisionId(),
150
- author: markInfo.author,
151
- date: markInfo.date,
152
- ...utcDate != null && { utcDate },
153
- ...initials != null && { initials }
154
- });
155
- doc.descendants((node, position) => {
156
- if (node.type.name === "paragraph" && expectParagraphAttrs(node).pPrMark == null) transform.setNodeAttribute(position, "pPrMark", {
157
- kind: "del",
158
- info: markInfo
159
- });
160
- if (node.isInline && !deletion.type.isInSet(node.marks)) addTrackedDeletionMark({
161
- insertionPolicy: "preserve-pending",
162
- tr: transform,
163
- from: position,
164
- to: position + node.nodeSize,
165
- mark: deletion
166
- });
167
- return !node.isInline;
168
- });
169
- return transform;
170
- };
171
- /**
172
- * A note whose reference was deleted: its text and its paragraph marks are
173
- * deleted too, by the reference's author at the reference's date.
174
- */
175
- const deletedNote = (note, document, reference) => {
176
- const { styles, theme, numbering } = document.package;
177
- const doc = footnoteToProseDoc(note.content, {
178
- ...styles !== void 0 && { styles },
179
- ...theme !== void 0 && { theme },
180
- ...numbering !== void 0 && { numbering }
181
- });
182
- const transform = deleteNoteWithReference(new Transform(doc), reference);
183
- if (!transform.docChanged) return note;
184
- return {
185
- ...note,
186
- content: proseDocToBlocks(transform.doc, note.content, styles)
187
- };
188
- };
189
- const editNotes = (document, edits) => {
190
- if (edits.size === 0) return document;
191
- const edit = (kind, notes) => {
192
- if (!notes?.some((note) => edits.has(noteKey(kind, note.id)))) return notes;
193
- return notes.map((note) => edits.get(noteKey(kind, note.id))?.(note) ?? note);
194
- };
195
- const footnotes = edit("footnote", document.package.footnotes);
196
- const endnotes = edit("endnote", document.package.endnotes);
197
- if (footnotes === document.package.footnotes && endnotes === document.package.endnotes) return document;
198
- return {
199
- ...document,
200
- package: {
201
- ...document.package,
202
- ...footnotes !== void 0 && { footnotes },
203
- ...endnotes !== void 0 && { endnotes }
204
- }
205
- };
206
- };
207
- const createNoteReferenceFollower = () => {
208
- let base = null;
209
- const replaced = /* @__PURE__ */ new Map();
210
- const pending = /* @__PURE__ */ new Map();
211
- const recorded = (key, edit) => (note) => {
212
- const result = edit(note);
213
- if (result !== note) pending.set(key, {
214
- from: note,
215
- to: result
216
- });
217
- return result;
218
- };
219
- return {
220
- noteBase: (before) => {
221
- base ??= before;
222
- },
223
- reconcile: (document, body) => {
224
- const before = base;
225
- base = null;
226
- if (!before) return document;
227
- const was = noteReferenceStates(before);
228
- const now = noteReferenceStates(body);
229
- const deletions = referenceDeletions(body);
230
- const rejected = referenceDeletions(before);
231
- const edits = /* @__PURE__ */ new Map();
232
- for (const [key, state] of now) {
233
- const previous = was.get(key);
234
- const rejectedDeletion = rejected.get(key);
235
- if (state === "live" && previous === "deleted" && rejectedDeletion) edits.set(key, recorded(key, (note) => {
236
- const restored = restoredNote(note, document, rejectedDeletion);
237
- if (restored !== note) replaced.set(key, {
238
- restored,
239
- previous: note
240
- });
241
- return restored;
242
- }));
243
- const reference = deletions.get(key);
244
- if (state === "deleted" && previous === "live" && reference) edits.set(key, recorded(key, (note) => {
245
- const earlier = replaced.get(key);
246
- replaced.delete(key);
247
- return earlier?.restored === note ? earlier.previous : deletedNote(note, document, reference);
248
- }));
249
- }
250
- return editNotes(document, edits);
251
- },
252
- withPending: (document) => {
253
- const edits = /* @__PURE__ */ new Map();
254
- for (const [key, { from, to }] of pending) edits.set(key, (note) => {
255
- if (note !== from) pending.delete(key);
256
- return note === from ? to : note;
257
- });
258
- return editNotes(document, edits);
259
- },
260
- reset: () => {
261
- base = null;
262
- replaced.clear();
263
- pending.clear();
264
- }
265
- };
266
- };
267
26
  /** The notes model content refers to, live or pending deletion. */
268
27
  const noteKeysReferencedIn = (content) => {
269
28
  const keys = /* @__PURE__ */ new Set();
@@ -358,4 +117,4 @@ const withoutUnreferencedNotes = (document, heldUnreferenced) => {
358
117
  }
359
118
  };
360
119
  };
361
- export { createNoteReferenceFollower, deleteNoteWithReference, heldUnreferencedNotes, noteDeletionRevisions, noteKeysReferencedIn, noteReferenceStates, noteReferencesRestored, referenceDeletions, referencedNotes, restoreNotes, withoutUnreferencedNotes };
120
+ export { heldUnreferencedNotes, noteKeysReferencedIn, noteReferenceStates, referencedNotes, withoutUnreferencedNotes };
@@ -6,8 +6,8 @@ import "./extensions/nodes/RangeAnchorExtension.js";
6
6
  import { mapPlacedRanges } from "./pastePlacement.js";
7
7
  import { forEachAnnotationIdInDoc } from "./plugins/revisionIds.js";
8
8
  import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
9
- import { Fragment, Slice } from "prosemirror-model";
10
9
  import { MAX_REVISION_ID } from "@stll/docx-core/model";
10
+ import { Fragment, Slice } from "prosemirror-model";
11
11
  // src/prosemirror/pastedCommentCopies.ts
12
12
  /**
13
13
  * One range per comment id, for a paste or a drop into a ProseMirror session.
@@ -2,8 +2,8 @@ import { getCachedNumberingMap } from "../../docx/numberingParser.js";
2
2
  import { completeNumberingForDoc, paragraphListReferences } from "../listInstanceReferences.js";
3
3
  import { createPluginKeyOwner } from "../pluginKeyOwner.js";
4
4
  import { panic } from "better-result";
5
- import { AddMarkStep, DocAttrStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
6
5
  import { Plugin } from "prosemirror-state";
6
+ import { AddMarkStep, DocAttrStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
7
7
  // src/prosemirror/plugins/documentNumbering.ts
8
8
  /** Document-scoped numbering definitions for list-editing commands. */
9
9
  const documentNumberingKey = createPluginKeyOwner("documentNumbering");
@@ -4,9 +4,9 @@ import { StyleResolver, createStyleResolver } from "../styles/styleResolver.js";
4
4
  import { getDocumentNumbering } from "./documentNumbering.js";
5
5
  import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver } from "./documentStyleState.js";
6
6
  import { resolveEditedParagraphStyles } from "./paragraphStyleResolution.js";
7
+ import { Plugin } from "prosemirror-state";
7
8
  import { Mark } from "prosemirror-model";
8
9
  import { Mapping, ReplaceStep } from "prosemirror-transform";
9
- import { Plugin } from "prosemirror-state";
10
10
  import { isHistoryTransaction } from "prosemirror-history";
11
11
  // src/prosemirror/plugins/documentStyles.ts
12
12
  /**
@@ -12,8 +12,8 @@ import { readMoveRangeBoundaryAttrs } from "./moveRangeBoundaryAttrs.js";
12
12
  import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
13
13
  import { isZeroWidthAnchor } from "./zeroWidthAnchors.js";
14
14
  import { panic } from "better-result";
15
- import { Fragment, Mark } from "prosemirror-model";
16
15
  import { isCommentExhausted, withoutCommentThreads } from "@stll/docx-core/ops";
16
+ import { Fragment, Mark } from "prosemirror-model";
17
17
  // src/prosemirror/replacedAnnotations.ts
18
18
  /**
19
19
  * What survives when an edit replaces a span of inline content.
@@ -0,0 +1,47 @@
1
+ import { EditorState, Transaction } from "prosemirror-state";
2
+ import { Slice } from "prosemirror-model";
3
+ import { EditorView } from "prosemirror-view";
4
+ export declare const SUGGESTION_META = "suggestionModeApplied";
5
+ export declare const SUGGESTION_BYPASS_META = "suggestionModeBypass";
6
+ /** Text typed before list autoformat rules get to see it. */
7
+ export declare const SUGGESTED_TEXT_INPUT_META = "suggestionModeTextInput";
8
+ export type SuggestionMode = {
9
+ active: boolean;
10
+ author: string;
11
+ };
12
+ export type SuggestedRangeDeletion = {
13
+ state: EditorState;
14
+ tr: Transaction;
15
+ from: number;
16
+ to: number;
17
+ };
18
+ type SuggestionModeState = SuggestionMode & {
19
+ commands: {
20
+ paste: (view: EditorView, slice: Slice, mode: SuggestionMode) => boolean;
21
+ deleteRange: (range: SuggestedRangeDeletion) => boolean;
22
+ deleteSelection: (state: EditorState, dispatch: (tr: Transaction) => void) => boolean;
23
+ };
24
+ };
25
+ export declare const suggestionModeKey: Readonly<{
26
+ key: string;
27
+ createKey: () => import("prosemirror-state").PluginKey<SuggestionModeState>;
28
+ owns: (plugin: import("prosemirror-state").Plugin<SuggestionModeState>) => boolean;
29
+ get: (state: EditorState) => import("prosemirror-state").Plugin<SuggestionModeState> | undefined;
30
+ getState: (state: EditorState) => SuggestionModeState | undefined;
31
+ }>;
32
+ export declare const isSuggestionModeActive: (state: EditorState) => boolean;
33
+ export type SuggestionMarkAttrs = {
34
+ revisionId: number;
35
+ author: string;
36
+ date: string;
37
+ };
38
+ export declare const makeMarkAttrs: ({ author }: SuggestionMode) => SuggestionMarkAttrs;
39
+ export declare const makeRevisionInfo: (state: EditorState) => {
40
+ id: number;
41
+ author: string;
42
+ date: string;
43
+ } | null;
44
+ export declare const pasteAsSuggestion: (view: EditorView, slice: Slice) => boolean;
45
+ export declare const suggestRangeDeletion: (range: SuggestedRangeDeletion) => boolean;
46
+ export declare const deleteSelectionAsSuggestion: (state: EditorState, dispatch: (tr: Transaction) => void) => boolean;
47
+ export {};
@@ -0,0 +1,31 @@
1
+ import { createPluginKeyOwner } from "./pluginKeyOwner.js";
2
+ import { mintRevisionId } from "./plugins/revisionIds.js";
3
+ // src/prosemirror/suggestionCommands.ts
4
+ const SUGGESTION_META = "suggestionModeApplied";
5
+ const SUGGESTION_BYPASS_META = "suggestionModeBypass";
6
+ /** Text typed before list autoformat rules get to see it. */
7
+ const SUGGESTED_TEXT_INPUT_META = "suggestionModeTextInput";
8
+ const suggestionModeKey = createPluginKeyOwner("suggestionMode");
9
+ const isSuggestionModeActive = (state) => suggestionModeKey.getState(state)?.active ?? false;
10
+ const makeMarkAttrs = ({ author }) => ({
11
+ revisionId: mintRevisionId(),
12
+ author,
13
+ date: (/* @__PURE__ */ new Date()).toISOString()
14
+ });
15
+ const makeRevisionInfo = (state) => {
16
+ const mode = suggestionModeKey.getState(state);
17
+ if (!mode?.active) return null;
18
+ const { revisionId, author, date } = makeMarkAttrs(mode);
19
+ return {
20
+ id: revisionId,
21
+ author,
22
+ date
23
+ };
24
+ };
25
+ const pasteAsSuggestion = (view, slice) => {
26
+ const mode = suggestionModeKey.getState(view.state);
27
+ return mode?.active ? mode.commands.paste(view, slice, mode) : false;
28
+ };
29
+ const suggestRangeDeletion = (range) => suggestionModeKey.getState(range.state)?.commands.deleteRange(range) ?? false;
30
+ const deleteSelectionAsSuggestion = (state, dispatch) => suggestionModeKey.getState(state)?.commands.deleteSelection(state, dispatch) ?? false;
31
+ export { SUGGESTED_TEXT_INPUT_META, SUGGESTION_BYPASS_META, SUGGESTION_META, deleteSelectionAsSuggestion, isSuggestionModeActive, makeMarkAttrs, makeRevisionInfo, pasteAsSuggestion, suggestRangeDeletion, suggestionModeKey };
@@ -2,8 +2,8 @@ import { decodeTableCellParagraphSourcePayload, transportTableCellsWithParagraph
2
2
  import { maxOf } from "../utils/extremes.js";
3
3
  import { expectTableAttrs, mergeTableAttrs } from "./attrs/index.js";
4
4
  import { setPastedRepeats } from "./pastePlacement.js";
5
- import { Fragment, Slice } from "prosemirror-model";
6
5
  import { CellSelection, TableMap, cellAround, tableNodeTypes } from "prosemirror-tables";
6
+ import { Fragment, Slice } from "prosemirror-model";
7
7
  import { Transform } from "prosemirror-transform";
8
8
  // src/prosemirror/tableCellPaste.ts
9
9
  /**
@@ -7,9 +7,9 @@ import { rebaseParagraphRuns } from "./rebaseParagraphRunFormatting.js";
7
7
  import { paragraphRunStyleContext } from "./runStyleFormatting.js";
8
8
  import { trackedRevisionPathOf } from "./trackedRevisionPath.js";
9
9
  import { paragraphContentOf } from "./zeroWidthAnchors.js";
10
+ import { paragraphMarkOutcome } from "@stll/docx-core/ops";
10
11
  import { Fragment, Slice } from "prosemirror-model";
11
12
  import { ReplaceAroundStep, ReplaceStep, StepMap } from "prosemirror-transform";
12
- import { paragraphMarkOutcome } from "@stll/docx-core/ops";
13
13
  // src/prosemirror/tableRunIn.ts
14
14
  /**
15
15
  * A paragraph whose mark goes, right before a table.
@@ -2,8 +2,8 @@ import { adoptNativeSelection, isCompositionKeyDown } from "./nativeSelection.js
2
2
  import { createPluginKeyOwner } from "./pluginKeyOwner.js";
3
3
  import { RUN_FORMATTING_MARK_NAMES } from "./runFormattingMarkNames.js";
4
4
  import { isZeroWidthAnchor } from "./zeroWidthAnchors.js";
5
- import { Mapping } from "prosemirror-transform";
6
5
  import { AllSelection, Plugin, Selection, TextSelection } from "prosemirror-state";
6
+ import { Mapping } from "prosemirror-transform";
7
7
  // src/prosemirror/textInput.ts
8
8
  const LOCKED_CONTROL_LOCKS = /* @__PURE__ */ new Set(["contentLocked", "sdtContentLocked"]);
9
9
  const isLockedControl = (node) => node?.type.name === "sdt" && LOCKED_CONTROL_LOCKS.has(node.attrs["lock"]);
@@ -8,13 +8,7 @@ export declare const CANONICAL_GAP: {
8
8
  readonly modelEdits: "direct-model-edits";
9
9
  readonly sectionProperties: "section-properties";
10
10
  readonly dispatch: "unclassified-transactions";
11
- readonly save: "pm-save-projection";
12
- readonly history: "pm-history";
13
- readonly suggestionPlugin: "pm-suggestion-plugin";
14
- readonly paragraphTracker: "pm-paragraph-tracker";
15
- readonly tableGeometry: "pm-table-geometry";
16
- readonly paragraphIdentity: "pm-paragraph-identity";
17
- readonly documentOperations: "pm-document-operations";
11
+ readonly saveSerialization: "save-serialization";
18
12
  readonly publicComments: "publicOps.comments";
19
13
  readonly publicUnsupportedInline: "publicOps.unsupportedInline";
20
14
  readonly commentReplacementAlignment: "comment-replacement-alignment";
@@ -113,59 +107,20 @@ export declare const CANONICAL_CAPABILITIES: {
113
107
  readonly adapters: readonly ["react", "vue"];
114
108
  readonly summary: "A host plugin or raw dispatch that changes the document is refused, naming the transaction's meta keys; hosts express edits as document operations (applyDocumentOperations).";
115
109
  };
116
- readonly "pm-save-projection": {
110
+ readonly "save-serialization": {
117
111
  readonly owner: "controller";
118
- readonly kind: "routing";
119
- readonly adapters: readonly ["react", "vue"];
120
- readonly summary: "Legacy save and read paths reconstruct documents from PM.";
121
- };
122
- readonly "pm-history": {
123
- readonly owner: "prosemirror";
124
- readonly kind: "mutation-source";
125
- readonly adapters: readonly ["react", "vue"];
126
- readonly summary: "PM history remains installed for legacy sessions.";
127
- };
128
- readonly "pm-suggestion-plugin": {
129
- readonly owner: "prosemirror";
130
- readonly kind: "mutation-source";
131
- readonly adapters: readonly ["react", "vue"];
132
- readonly summary: "The legacy suggestion plugin produces PM transactions.";
133
- };
134
- readonly "pm-paragraph-tracker": {
135
- readonly owner: "prosemirror";
136
- readonly kind: "mutation-source";
137
- readonly adapters: readonly ["react", "vue"];
138
- readonly summary: "Dirty tracking and section bookkeeping still observe PM transactions.";
139
- };
140
- readonly "pm-table-geometry": {
141
- readonly owner: "prosemirror";
142
- readonly kind: "mutation-source";
143
- readonly adapters: readonly ["react", "vue"];
144
- readonly summary: "Table geometry, resize and repair still produce PM transactions.";
145
- };
146
- readonly "pm-paragraph-identity": {
147
- readonly owner: "prosemirror";
148
- readonly kind: "mutation-source";
149
- readonly adapters: readonly ["react", "vue"];
150
- readonly summary: "Legacy paragraph identity repair remains a PM append transaction.";
151
- };
152
- readonly "pm-document-operations": {
153
- readonly owner: "document-operations";
154
- readonly legacySessionMutation: "pm-public-operations";
155
- readonly kind: "mutation-source";
112
+ readonly kind: "refusal";
156
113
  readonly adapters: readonly ["react", "vue"];
157
- readonly summary: "Public document operations still execute against a held PM view.";
114
+ readonly summary: "Canonical save waits for composition to finish and reports package serialization refusals and fidelity fallbacks.";
158
115
  };
159
116
  readonly "publicOps.comments": {
160
117
  readonly owner: "document-operations";
161
- readonly legacySessionMutation: "pm-public-operations";
162
- readonly kind: "routing";
118
+ readonly kind: "refusal";
163
119
  readonly adapters: readonly ["react", "vue"];
164
- readonly summary: "Canonical public comments compile to semantic operations; legacy sessions retain PM comments.";
120
+ readonly summary: "Public comment edits refuse when their anchors or revision structure cannot be represented.";
165
121
  };
166
122
  readonly "publicOps.unsupportedInline": {
167
123
  readonly owner: "document-operations";
168
- readonly legacySessionMutation: "pm-public-operations";
169
124
  readonly kind: "refusal";
170
125
  readonly adapters: readonly ["react", "vue"];
171
126
  readonly summary: "Unsupported public payloads refuse with a typed compiler capability gap.";
@@ -178,7 +133,6 @@ export declare const CANONICAL_CAPABILITIES: {
178
133
  };
179
134
  readonly "publicOps.headlessSession": {
180
135
  readonly owner: "document-operations";
181
- readonly legacySessionMutation: "canonical";
182
136
  readonly kind: "refusal";
183
137
  readonly adapters: readonly ["react", "vue"];
184
138
  readonly summary: "A reviewer refuses to resolve one story of a suggestion that reaches several, which resolves only whole.";
@@ -9,13 +9,7 @@ const CANONICAL_GAP = {
9
9
  modelEdits: "direct-model-edits",
10
10
  sectionProperties: "section-properties",
11
11
  dispatch: "unclassified-transactions",
12
- save: "pm-save-projection",
13
- history: "pm-history",
14
- suggestionPlugin: "pm-suggestion-plugin",
15
- paragraphTracker: "pm-paragraph-tracker",
16
- tableGeometry: "pm-table-geometry",
17
- paragraphIdentity: "pm-paragraph-identity",
18
- documentOperations: "pm-document-operations",
12
+ saveSerialization: "save-serialization",
19
13
  publicComments: "publicOps.comments",
20
14
  publicUnsupportedInline: "publicOps.unsupportedInline",
21
15
  commentReplacementAlignment: "comment-replacement-alignment",
@@ -103,59 +97,20 @@ const CANONICAL_CAPABILITIES = {
103
97
  adapters: ["react", "vue"],
104
98
  summary: "A host plugin or raw dispatch that changes the document is refused, naming the transaction's meta keys; hosts express edits as document operations (applyDocumentOperations)."
105
99
  },
106
- [CANONICAL_GAP.save]: {
100
+ [CANONICAL_GAP.saveSerialization]: {
107
101
  owner: "controller",
108
- kind: "routing",
109
- adapters: ["react", "vue"],
110
- summary: "Legacy save and read paths reconstruct documents from PM."
111
- },
112
- [CANONICAL_GAP.history]: {
113
- owner: "prosemirror",
114
- kind: "mutation-source",
115
- adapters: ["react", "vue"],
116
- summary: "PM history remains installed for legacy sessions."
117
- },
118
- [CANONICAL_GAP.suggestionPlugin]: {
119
- owner: "prosemirror",
120
- kind: "mutation-source",
121
- adapters: ["react", "vue"],
122
- summary: "The legacy suggestion plugin produces PM transactions."
123
- },
124
- [CANONICAL_GAP.paragraphTracker]: {
125
- owner: "prosemirror",
126
- kind: "mutation-source",
127
- adapters: ["react", "vue"],
128
- summary: "Dirty tracking and section bookkeeping still observe PM transactions."
129
- },
130
- [CANONICAL_GAP.tableGeometry]: {
131
- owner: "prosemirror",
132
- kind: "mutation-source",
133
- adapters: ["react", "vue"],
134
- summary: "Table geometry, resize and repair still produce PM transactions."
135
- },
136
- [CANONICAL_GAP.paragraphIdentity]: {
137
- owner: "prosemirror",
138
- kind: "mutation-source",
139
- adapters: ["react", "vue"],
140
- summary: "Legacy paragraph identity repair remains a PM append transaction."
141
- },
142
- [CANONICAL_GAP.documentOperations]: {
143
- owner: "document-operations",
144
- legacySessionMutation: "pm-public-operations",
145
- kind: "mutation-source",
102
+ kind: "refusal",
146
103
  adapters: ["react", "vue"],
147
- summary: "Public document operations still execute against a held PM view."
104
+ summary: "Canonical save waits for composition to finish and reports package serialization refusals and fidelity fallbacks."
148
105
  },
149
106
  [CANONICAL_GAP.publicComments]: {
150
107
  owner: "document-operations",
151
- legacySessionMutation: "pm-public-operations",
152
- kind: "routing",
108
+ kind: "refusal",
153
109
  adapters: ["react", "vue"],
154
- summary: "Canonical public comments compile to semantic operations; legacy sessions retain PM comments."
110
+ summary: "Public comment edits refuse when their anchors or revision structure cannot be represented."
155
111
  },
156
112
  [CANONICAL_GAP.publicUnsupportedInline]: {
157
113
  owner: "document-operations",
158
- legacySessionMutation: "pm-public-operations",
159
114
  kind: "refusal",
160
115
  adapters: ["react", "vue"],
161
116
  summary: "Unsupported public payloads refuse with a typed compiler capability gap."
@@ -168,7 +123,6 @@ const CANONICAL_CAPABILITIES = {
168
123
  },
169
124
  [CANONICAL_GAP.publicHeadlessSession]: {
170
125
  owner: "document-operations",
171
- legacySessionMutation: "canonical",
172
126
  kind: "refusal",
173
127
  adapters: ["react", "vue"],
174
128
  summary: "A reviewer refuses to resolve one story of a suggestion that reaches several, which resolves only whole."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.73.0",
3
+ "version": "0.74.0",
4
4
  "description": "Headless DOCX engine: reads .docx into a typed OOXML model, applies every edit as a validated operation, paginates it, and writes .docx back with untouched parts byte for byte.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -173,7 +173,7 @@
173
173
  "perf": "bun scripts/profile-editor.ts"
174
174
  },
175
175
  "dependencies": {
176
- "@stll/docx-core": "^0.45.0",
176
+ "@stll/docx-core": "^0.45.1",
177
177
  "@stll/template-conditions": "^0.7.0",
178
178
  "@stll/utf8-boundaries": "0.2.0",
179
179
  "better-result": "3.0.1",