@stll/folio-core 0.75.0 → 0.77.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 (143) hide show
  1. package/dist/ai-edits/headless.d.ts +8 -5
  2. package/dist/ai-edits/headless.js +49 -26
  3. package/dist/ai-edits/pending-suggestions.d.ts +9 -0
  4. package/dist/ai-edits/pending-suggestions.js +13 -3
  5. package/dist/ai-edits/read.js +33 -4
  6. package/dist/ai-edits/table-geometry.js +12 -4
  7. package/dist/ai-edits/types.d.ts +9 -4
  8. package/dist/canonical/batchCommentReferences.js +2 -1
  9. package/dist/canonical/canonicalBatchReview.js +5 -8
  10. package/dist/canonical/canonicalComments.js +8 -2
  11. package/dist/canonical/canonicalCompilerRefusal.d.ts +2 -4
  12. package/dist/canonical/canonicalCompilerRefusal.js +20 -14
  13. package/dist/canonical/canonicalInlineProjection.d.ts +2 -2
  14. package/dist/canonical/canonicalInlineProjection.js +2 -2
  15. package/dist/canonical/canonicalProjectionBlocks.d.ts +10 -1
  16. package/dist/canonical/canonicalPublicOperations.js +214 -107
  17. package/dist/canonical/canonicalSeedContent.d.ts +18 -3
  18. package/dist/canonical/canonicalSeedContent.js +28 -15
  19. package/dist/canonical/canonicalSession.d.ts +22 -12
  20. package/dist/canonical/canonicalSession.js +181 -187
  21. package/dist/controller/canonicalClipboard.d.ts +3 -2
  22. package/dist/controller/canonicalClipboard.js +377 -58
  23. package/dist/controller/canonicalComposition.js +67 -14
  24. package/dist/controller/canonicalContentControlValue.js +7 -7
  25. package/dist/controller/canonicalReview.d.ts +21 -0
  26. package/dist/controller/canonicalReview.js +44 -9
  27. package/dist/controller/canonicalStoryEditor.js +2 -0
  28. package/dist/controller/canonicalStructure.d.ts +1 -2
  29. package/dist/controller/canonicalStructure.js +51 -24
  30. package/dist/controller/fontReadiness.js +50 -23
  31. package/dist/controller/hiddenEditorManager.js +7 -20
  32. package/dist/docx/bulletMarkers.d.ts +8 -0
  33. package/dist/docx/bulletMarkers.js +9 -1
  34. package/dist/docx/canonicalSessionInput.js +25 -11
  35. package/dist/docx/ensureParaIds.d.ts +31 -0
  36. package/dist/docx/ensureParaIds.js +57 -32
  37. package/dist/docx/ensureUniqueControlIds.d.ts +13 -0
  38. package/dist/docx/ensureUniqueControlIds.js +47 -29
  39. package/dist/docx/ensureUniqueRevisionIds.d.ts +13 -0
  40. package/dist/docx/ensureUniqueRevisionIds.js +52 -29
  41. package/dist/docx/importedIdCollisions.js +29 -4
  42. package/dist/docx/server/templatePlan/apply.js +108 -9
  43. package/dist/docx/server/templatePlan/blocks.d.ts +77 -5
  44. package/dist/docx/server/templatePlan/blocks.js +281 -14
  45. package/dist/docx/server/templatePlan/builders.d.ts +22 -1
  46. package/dist/docx/server/templatePlan/builders.js +37 -3
  47. package/dist/docx/server/templatePlan/effects.d.ts +27 -0
  48. package/dist/docx/server/templatePlan/effects.js +188 -0
  49. package/dist/docx/server/templatePlan/emit.d.ts +4 -1
  50. package/dist/docx/server/templatePlan/emit.js +152 -8
  51. package/dist/docx/server/templatePlan/inspect.js +21 -1
  52. package/dist/docx/server/templatePlan/labels.js +16 -1
  53. package/dist/docx/server/templatePlan/plan.d.ts +35 -3
  54. package/dist/docx/server/templatePlan/plan.js +197 -20
  55. package/dist/docx/server/templatePlan/planShape.js +58 -22
  56. package/dist/docx/server/templatePlan/revisions.d.ts +101 -0
  57. package/dist/docx/server/templatePlan/revisions.js +681 -0
  58. package/dist/docx/server/templatePlan/story.d.ts +61 -2
  59. package/dist/docx/server/templatePlan/story.js +175 -13
  60. package/dist/docx/server/templatePlan/types.d.ts +313 -1
  61. package/dist/docx/server/templatePlan/verify.js +175 -12
  62. package/dist/docx/server/templatePlan/xml.d.ts +3 -0
  63. package/dist/docx/server/templatePlan/xml.js +4 -1
  64. package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
  65. package/dist/docx/tableGridXml.d.ts +3 -7
  66. package/dist/docx/tableGridXml.js +5 -13
  67. package/dist/layout-bridge/convert/footnoteLayout.js +34 -8
  68. package/dist/prosemirror/canonicalMarkupDocument.d.ts +20 -0
  69. package/dist/prosemirror/canonicalMarkupDocument.js +73 -0
  70. package/dist/prosemirror/canonicalTableCommands.d.ts +1 -1
  71. package/dist/prosemirror/canonicalTableCommands.js +1 -3
  72. package/dist/prosemirror/commands/comments.d.ts +6 -234
  73. package/dist/prosemirror/commands/comments.js +5 -2464
  74. package/dist/prosemirror/commands/index.d.ts +4 -2
  75. package/dist/prosemirror/commands/index.js +4 -2
  76. package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
  77. package/dist/prosemirror/conversion/markupViewSource.js +11 -0
  78. package/dist/prosemirror/conversion/toProseDoc.d.ts +3 -0
  79. package/dist/prosemirror/conversion/toProseDoc.js +31 -14
  80. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +6 -8
  81. package/dist/prosemirror/hyperlinkRemoval.d.ts +11 -8
  82. package/dist/prosemirror/hyperlinkRemoval.js +24 -15
  83. package/dist/prosemirror/independentMarkupProjection.d.ts +27 -0
  84. package/dist/prosemirror/independentMarkupProjection.js +147 -0
  85. package/dist/prosemirror/markupViewNotes.d.ts +1 -1
  86. package/dist/prosemirror/markupViewNotes.js +24 -27
  87. package/dist/prosemirror/markupViewPositionMap.d.ts +16 -0
  88. package/dist/prosemirror/markupViewPositionMap.js +316 -0
  89. package/dist/prosemirror/markupViewProjection.d.ts +3 -46
  90. package/dist/prosemirror/markupViewProjection.js +90 -17
  91. package/dist/prosemirror/paraIds.d.ts +1 -14
  92. package/dist/prosemirror/paraIds.js +1 -14
  93. package/dist/prosemirror/paragraphMarkJoin.d.ts +0 -16
  94. package/dist/prosemirror/paragraphMarkJoin.js +3 -46
  95. package/dist/prosemirror/projectionReview.d.ts +49 -0
  96. package/dist/prosemirror/projectionReview.js +292 -0
  97. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -13
  98. package/dist/prosemirror/rebaseParagraphRunFormatting.js +1 -16
  99. package/dist/prosemirror/replacedAnnotations.d.ts +6 -83
  100. package/dist/prosemirror/replacedAnnotations.js +11 -203
  101. package/dist/prosemirror/revisionCarriers.d.ts +9 -1
  102. package/dist/prosemirror/revisionCarriers.js +15 -1
  103. package/dist/prosemirror/revisionRangeQueries.d.ts +32 -0
  104. package/dist/prosemirror/revisionRangeQueries.js +76 -0
  105. package/dist/prosemirror/runFormattingMarkNames.d.ts +1 -1
  106. package/dist/prosemirror/runFormattingMarkNames.js +1 -1
  107. package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
  108. package/dist/prosemirror/styles/styleResolver.js +4 -1
  109. package/dist/prosemirror/suggestionQueries.d.ts +114 -0
  110. package/dist/prosemirror/suggestionQueries.js +320 -0
  111. package/dist/prosemirror/tableGridMutation.d.ts +1 -16
  112. package/dist/prosemirror/tableGridMutation.js +1 -78
  113. package/dist/prosemirror/tableRowRevisionOwnership.d.ts +18 -0
  114. package/dist/prosemirror/tableRowRevisionOwnership.js +7 -0
  115. package/dist/prosemirror/utils/extractTrackedChanges.js +14 -4
  116. package/dist/server.d.ts +2 -2
  117. package/dist/types/canonicalCapabilities.d.ts +4 -35
  118. package/dist/types/canonicalCapabilities.js +4 -33
  119. package/package.json +2 -2
  120. package/dist/internal/headlessRevisionResolutionGuard.d.ts +0 -3
  121. package/dist/internal/headlessRevisionResolutionGuard.js +0 -18
  122. package/dist/internal/revisionResolutionEdits.d.ts +0 -11
  123. package/dist/internal/revisionResolutionEdits.js +0 -18
  124. package/dist/internal/revisionResolutionInline.d.ts +0 -24
  125. package/dist/internal/revisionResolutionInline.js +0 -302
  126. package/dist/internal/revisionResolutionStep.d.ts +0 -32
  127. package/dist/internal/revisionResolutionStep.js +0 -282
  128. package/dist/internal/revisionResolutionTracking.d.ts +0 -9
  129. package/dist/internal/revisionResolutionTracking.js +0 -124
  130. package/dist/internal/wholeStoryRevisionResolution.d.ts +0 -56
  131. package/dist/internal/wholeStoryRevisionResolution.js +0 -783
  132. package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +0 -38
  133. package/dist/prosemirror/commands/resolveAllTableChanges.js +0 -642
  134. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +0 -13
  135. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +0 -45
  136. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -18
  137. package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -207
  138. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +0 -60
  139. package/dist/prosemirror/commands/tableMergeFoldDecisions.js +0 -78
  140. package/dist/prosemirror/rejoinRunCarriers.d.ts +0 -42
  141. package/dist/prosemirror/rejoinRunCarriers.js +0 -65
  142. package/dist/prosemirror/runPropertyChangeResolution.d.ts +0 -15
  143. package/dist/prosemirror/runPropertyChangeResolution.js +0 -34
@@ -7,7 +7,7 @@ import { XmlElement } from "../../xmlParser.js";
7
7
  import { ParagraphNumberingOverride } from "@stll/docx-core/model";
8
8
  /** The mark a footnote or endnote reference leaves in a block's text. */
9
9
  export declare const NOTE_REFERENCE_MARK = "";
10
- export type AtomKind = "text" | "tab" | "lineBreak" | "pageBreak" | "noBreakHyphen" | "softHyphen" | "symbol" | "footnoteReference" | "endnoteReference" | "object";
10
+ export type AtomKind = "text" | "tab" | "lineBreak" | "pageBreak" | "noBreakHyphen" | "softHyphen" | "symbol" | "footnoteReference" | "endnoteReference" | "selfNumber" | "object";
11
11
  export type AtomLink =
12
12
  /** A link through a relationship; `anchor` is the fragment its element adds. */
13
13
  {
@@ -35,7 +35,38 @@ export type InlineAtom = {
35
35
  element: XmlElement | null;
36
36
  /** Fields whose result the atom is part of, outermost first. */
37
37
  fields: readonly number[];
38
+ /** The code of the field a `selfNumber` atom stands for. */
39
+ instruction?: string;
40
+ /** The tracked change the atom is part of, in a reading that keeps them. */
41
+ revision?: AtomRevision;
38
42
  };
43
+ /**
44
+ * A tracked change an atom is part of, as a reading that keeps revisions
45
+ * reports it. An inserted atom is content like any other with this tag. A
46
+ * deleted one is a text atom without text: it takes no place in the text
47
+ * the document reads with its changes accepted, and holds what was deleted
48
+ * in `deleted` (a tab as `\t`, a line break as `\n`, a paragraph mark as
49
+ * the private character a keeping reading carries it as). An inserted
50
+ * paragraph mark is a text atom without text at the end of its paragraph,
51
+ * tagged `mark`.
52
+ */
53
+ export type AtomRevision = {
54
+ kind: "ins" | "del";
55
+ author: string;
56
+ date: string | null;
57
+ deleted?: string;
58
+ mark?: true;
59
+ /**
60
+ * The insertion a deletion sits in: text one hand inserted and another
61
+ * deleted again. It reads in neither view and is on record in both.
62
+ */
63
+ within?: {
64
+ author: string;
65
+ date: string | null;
66
+ };
67
+ };
68
+ /** Whether a field kind prints a number of its own and caches no text. */
69
+ export declare const isSelfNumberingField: (kind: string) => boolean;
39
70
  export type StoryField = {
40
71
  /** Position among the fields of the story, in begin order. */
41
72
  index: number;
@@ -67,8 +98,20 @@ export type StoryState = {
67
98
  formattingRevisions: number;
68
99
  /** Field separators and ends met with no field open to take them. */
69
100
  strayFieldEnds: number;
101
+ /**
102
+ * Whether inline insertions and deletions are read as tagged atoms. Left
103
+ * out, an insertion reads as plain content and a deletion is skipped.
104
+ */
105
+ keepsRevisions: boolean;
106
+ /**
107
+ * Revisions a keeping reading could not tag: one inside another, deleted
108
+ * content that is no text, a change inside a drawing or an equation.
109
+ */
110
+ untaggedRevisions: number;
70
111
  };
71
- export declare const createStoryState: () => StoryState;
112
+ export declare const createStoryState: (options?: {
113
+ keepsRevisions?: boolean;
114
+ }) => StoryState;
72
115
  /** A bookmark start, with how many atoms of its paragraph come before it. */
73
116
  /**
74
117
  * Close a story at its end: a field still open there never closes, and must
@@ -110,6 +153,22 @@ export type ParagraphRead = {
110
153
  pageBreakBefore: boolean | null;
111
154
  /** `w:jc` as the paragraph itself states it, or null. */
112
155
  alignment: string | null;
156
+ /** The space in front and behind (`w:spacing`) the paragraph itself
157
+ * states, in twentieths of a point; null for a side it does not state. */
158
+ spacing: {
159
+ before: number | null;
160
+ after: number | null;
161
+ };
162
+ /** The sides of `w:ind` the paragraph itself states, in twentieths of a
163
+ * point: where its lines start, and what its first line adds to that
164
+ * (negative for a hanging indent). Null for a side it does not state. */
165
+ indent: {
166
+ left: number | null;
167
+ firstLine: number | null;
168
+ };
169
+ /** Whether the paragraph states an indent in characters, which stands
170
+ * over the measured one and cannot be given in twentieths of a point. */
171
+ indentInCharacters: boolean;
113
172
  /** Whether the paragraph mark is a tracked insertion or deletion. */
114
173
  hasTrackedMark: boolean;
115
174
  };
@@ -2,18 +2,32 @@ import { parseFieldType } from "../../fieldParser.js";
2
2
  import { readParagraphNumbering } from "../../numberingReference.js";
3
3
  import { paraIdAttribute } from "../../paraIdAttribute.js";
4
4
  import { getLocalName } from "../../xmlParser.js";
5
- import { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, relationshipAttr, wAttr, wChild, wChildVal, wName } from "./xml.js";
5
+ import { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, relationshipAttr, twipsOrNull, wAttr, wChild, wChildVal, wName } from "./xml.js";
6
6
  // src/docx/server/templatePlan/story.ts
7
7
  /** The mark a footnote or endnote reference leaves in a block's text. */
8
8
  const NOTE_REFERENCE_MARK = "";
9
- const createStoryState = () => ({
9
+ /**
10
+ * Fields that print a number counted when the document is laid out and
11
+ * that hold no result: the number is text of the document that no cached
12
+ * text stands for, so the field itself is the content.
13
+ */
14
+ const SELF_NUMBERING_FIELDS = /* @__PURE__ */ new Set([
15
+ "AUTONUM",
16
+ "AUTONUMLGL",
17
+ "AUTONUMOUT"
18
+ ]);
19
+ /** Whether a field kind prints a number of its own and caches no text. */
20
+ const isSelfNumberingField = (kind) => SELF_NUMBERING_FIELDS.has(kind);
21
+ const createStoryState = (options = {}) => ({
10
22
  fields: [],
11
23
  open: [],
12
24
  paragraphOrdinal: 0,
13
25
  comments: 0,
14
26
  trackedChanges: 0,
15
27
  formattingRevisions: 0,
16
- strayFieldEnds: 0
28
+ strayFieldEnds: 0,
29
+ keepsRevisions: options.keepsRevisions === true,
30
+ untaggedRevisions: 0
17
31
  });
18
32
  /** A bookmark start, with how many atoms of its paragraph come before it. */
19
33
  /**
@@ -24,6 +38,39 @@ const endStory = (state) => {
24
38
  state.strayFieldEnds += state.open.length;
25
39
  state.open = [];
26
40
  };
41
+ /** The sides of `w:ind` that count in characters of the document grid. */
42
+ const CHARACTER_INDENTS = [
43
+ "leftChars",
44
+ "startChars",
45
+ "hangingChars",
46
+ "firstLineChars"
47
+ ];
48
+ /** The sides a `w:ind` states; a hanging indent is a negative first line. */
49
+ const ownIndent = (indent) => {
50
+ const hanging = twipsOrNull(wAttr(indent, "hanging"));
51
+ return {
52
+ left: twipsOrNull(wAttr(indent, "left") ?? wAttr(indent, "start")),
53
+ firstLine: hanging === null ? twipsOrNull(wAttr(indent, "firstLine")) : -hanging
54
+ };
55
+ };
56
+ const SWITCHED_ON = /* @__PURE__ */ new Set([
57
+ "1",
58
+ "true",
59
+ "on"
60
+ ]);
61
+ /**
62
+ * The space in front of a paragraph and behind it as its own `w:spacing`
63
+ * states it in twentieths of a point. A side set to follow the application
64
+ * (`beforeAutospacing`) or counted in lines (`beforeLines`) is not such a
65
+ * measure and reads as not stated.
66
+ */
67
+ const ownSpacing = (spacing) => {
68
+ const side = (name) => SWITCHED_ON.has(wAttr(spacing, `${name}Autospacing`) ?? "") || wAttr(spacing, `${name}Lines`) !== null ? null : twipsOrNull(wAttr(spacing, name));
69
+ return {
70
+ before: side("before"),
71
+ after: side("after")
72
+ };
73
+ };
27
74
  const TOGGLE_OFF = /* @__PURE__ */ new Set([
28
75
  "0",
29
76
  "false",
@@ -159,23 +206,65 @@ const beginField = (walk, instruction) => {
159
206
  read.fieldIndices.push(field.index);
160
207
  return field;
161
208
  };
162
- const readRun = (run, walk, { link }) => {
209
+ /** What a deleted run holds as text; null for content that is none. */
210
+ const deletedTextOf = (child) => {
211
+ switch (wName(child)) {
212
+ case "delText": return textOf(child);
213
+ case "tab": return " ";
214
+ case "cr": return "\n";
215
+ case "br": return wAttr(child, "type") === null ? "\n" : null;
216
+ default: return null;
217
+ }
218
+ };
219
+ /** A deleted run, read as one atom that holds what was deleted. */
220
+ const readDeletedRun = (run, walk, { link, revision }) => {
221
+ let deleted = "";
222
+ for (const child of elementChildren(run)) {
223
+ const name = wName(child);
224
+ const text = deletedTextOf(child);
225
+ if (text !== null) deleted += text;
226
+ else if (name !== "rPr" && name !== "lastRenderedPageBreak") walk.state.untaggedRevisions += 1;
227
+ }
228
+ if (deleted !== "") pushAtom(walk, {
229
+ kind: "text",
230
+ text: "",
231
+ runProperties: wChild(run, "rPr"),
232
+ link,
233
+ element: null,
234
+ revision: {
235
+ ...revision,
236
+ deleted
237
+ }
238
+ });
239
+ };
240
+ const readRun = (run, walk, context) => {
241
+ const { link, revision } = context;
163
242
  const { state, read } = walk;
164
243
  const runProperties = wChild(run, "rPr");
165
244
  if (wChild(runProperties, "rPrChange") !== null) state.formattingRevisions += 1;
245
+ if (revision?.kind === "del") {
246
+ readDeletedRun(run, walk, {
247
+ link,
248
+ revision
249
+ });
250
+ return;
251
+ }
166
252
  const atom = (kind, text, element) => {
167
253
  pushAtom(walk, {
168
254
  kind,
169
255
  text,
170
256
  runProperties,
171
257
  link,
172
- element
258
+ element,
259
+ ...revision === void 0 ? {} : { revision }
173
260
  });
174
261
  };
175
262
  const object = (element) => {
176
263
  if (inCode(state)) return;
177
264
  read.inlineObjects += 1;
178
- state.trackedChanges += countContentRevisions(element);
265
+ const inside = countContentRevisions(element);
266
+ state.trackedChanges += inside;
267
+ state.untaggedRevisions += state.keepsRevisions ? inside : 0;
179
268
  atom("object", "", element);
180
269
  };
181
270
  for (const child of elementChildren(run)) {
@@ -241,6 +330,14 @@ const readRun = (run, walk, { link }) => {
241
330
  top.field.kind = fieldKindOf(top.field.instruction);
242
331
  top.field.endParagraphOrdinal = read.ordinal;
243
332
  top.field.closed = true;
333
+ if (top.phase === "code" && isSelfNumberingField(top.field.kind)) pushAtom(walk, {
334
+ kind: "selfNumber",
335
+ text: "",
336
+ runProperties,
337
+ link,
338
+ element: null,
339
+ instruction: top.field.instruction.trim()
340
+ });
244
341
  }
245
342
  }
246
343
  break;
@@ -255,6 +352,15 @@ const readRun = (run, walk, { link }) => {
255
352
  }
256
353
  }
257
354
  };
355
+ /** The tag of an inline insertion or deletion; null for a move. */
356
+ const revisionOf = (element, name) => {
357
+ if (name !== "ins" && name !== "del") return null;
358
+ return {
359
+ kind: name,
360
+ author: wAttr(element, "author") ?? "",
361
+ date: wAttr(element, "date")
362
+ };
363
+ };
258
364
  const readInline = (container, walk, context) => {
259
365
  const { state, read } = walk;
260
366
  for (const child of elementChildren(container)) {
@@ -262,13 +368,16 @@ const readInline = (container, walk, context) => {
262
368
  if (name === null) {
263
369
  if (child.namespaceUri === MATH_NAMESPACE && !inCode(state) && (getLocalName(child.name) === "oMath" || getLocalName(child.name) === "oMathPara")) {
264
370
  read.inlineObjects += 1;
265
- state.trackedChanges += countContentRevisions(child);
371
+ const inside = countContentRevisions(child);
372
+ state.trackedChanges += inside;
373
+ state.untaggedRevisions += state.keepsRevisions ? inside : 0;
266
374
  pushAtom(walk, {
267
375
  kind: "object",
268
376
  text: "",
269
377
  runProperties: null,
270
378
  link: context.link,
271
- element: child
379
+ element: child,
380
+ ...context.revision === void 0 ? {} : { revision: context.revision }
272
381
  });
273
382
  } else if (!inCode(state)) read.unsupported.push(child.name ?? "");
274
383
  continue;
@@ -298,11 +407,35 @@ const readInline = (container, walk, context) => {
298
407
  readInline(child, walk, context);
299
408
  state.open.pop();
300
409
  field.closed = true;
301
- } else if (REVISION_INCLUDED.has(name)) {
410
+ if (field.result === "" && isSelfNumberingField(field.kind)) pushAtom(walk, {
411
+ kind: "selfNumber",
412
+ text: "",
413
+ runProperties: null,
414
+ link: context.link,
415
+ element: null,
416
+ instruction: field.instruction.trim()
417
+ });
418
+ } else if (REVISION_INCLUDED.has(name) || REVISION_EXCLUDED.has(name)) {
302
419
  state.trackedChanges += 1;
303
- readInline(child, walk, context);
304
- } else if (REVISION_EXCLUDED.has(name)) state.trackedChanges += 1;
305
- else if (name === "sdt") {
420
+ const kept = state.keepsRevisions ? revisionOf(child, name) : null;
421
+ const outer = context.revision;
422
+ if (kept !== null && outer !== void 0) {
423
+ if (kept.kind === "del" && outer.kind === "ins" && !outer.within) kept.within = {
424
+ author: outer.author,
425
+ date: outer.date
426
+ };
427
+ else state.untaggedRevisions += 1;
428
+ }
429
+ if (kept !== null) {
430
+ readInline(child, walk, {
431
+ ...context,
432
+ revision: kept
433
+ });
434
+ continue;
435
+ }
436
+ state.untaggedRevisions += state.keepsRevisions ? 1 : 0;
437
+ if (REVISION_INCLUDED.has(name)) readInline(child, walk, context);
438
+ } else if (name === "sdt") {
306
439
  const content = wChild(child, "sdtContent");
307
440
  if (content !== null) readInline(content, walk, context);
308
441
  } else if (TRANSPARENT_WRAPPERS.has(name)) readInline(child, walk, context);
@@ -318,6 +451,28 @@ const readInline = (container, walk, context) => {
318
451
  else if (!IGNORED_INLINE_CHILDREN.has(name) && !inCode(state)) read.unsupported.push(name);
319
452
  }
320
453
  };
454
+ /**
455
+ * The paragraph mark's own revision, in a reading that keeps them. An
456
+ * inserted mark is an atom at the paragraph's end. A deleted one was joined
457
+ * to the next paragraph before the reading; one still here had none to join.
458
+ */
459
+ const readTrackedMark = (mark, walk) => {
460
+ const inserted = wChild(mark, "ins");
461
+ if (wChild(mark, "del") !== null) walk.state.untaggedRevisions += 1;
462
+ else if (inserted !== null) pushAtom(walk, {
463
+ kind: "text",
464
+ text: "",
465
+ runProperties: null,
466
+ link: null,
467
+ element: null,
468
+ revision: {
469
+ kind: "ins",
470
+ author: wAttr(inserted, "author") ?? "",
471
+ date: wAttr(inserted, "date"),
472
+ mark: true
473
+ }
474
+ });
475
+ };
321
476
  /** Read one `w:p`, advancing the story's field and revision state. */
322
477
  const readParagraph = (element, state) => {
323
478
  const properties = wChild(element, "pPr");
@@ -345,6 +500,12 @@ const readParagraph = (element, state) => {
345
500
  hasSectionBreak: wChild(properties, "sectPr") !== null,
346
501
  pageBreakBefore: toggleOf(wChild(properties, "pageBreakBefore")),
347
502
  alignment: wChildVal(properties, "jc"),
503
+ spacing: ownSpacing(wChild(properties, "spacing")),
504
+ indent: ownIndent(wChild(properties, "ind")),
505
+ indentInCharacters: CHARACTER_INDENTS.some((name) => {
506
+ const value = wAttr(wChild(properties, "ind"), name);
507
+ return value !== null && !/^[+-]?0*$/u.test(value.trim());
508
+ }),
348
509
  hasTrackedMark
349
510
  };
350
511
  state.paragraphOrdinal += 1;
@@ -355,6 +516,7 @@ const readParagraph = (element, state) => {
355
516
  };
356
517
  for (const open of state.open) if (open.phase === "result" && open.field.result !== "") open.field.result += "\n";
357
518
  readInline(element, walk, { link: null });
519
+ if (state.keepsRevisions) readTrackedMark(mark, walk);
358
520
  read.text = read.atoms.map(({ text }) => text).join("");
359
521
  return read;
360
522
  };
@@ -447,4 +609,4 @@ const walkBlocks = (container, visitor, depth = 0) => {
447
609
  } else if (name === null || !IGNORED_BLOCK_CHILDREN.has(name)) visitor.unread(child);
448
610
  }
449
611
  };
450
- export { NOTE_REFERENCE_MARK, createStoryState, endStory, readParagraph, toggleOf, walkBlocks };
612
+ export { NOTE_REFERENCE_MARK, createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks };