@stll/folio-core 0.71.1 → 0.73.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 (213) hide show
  1. package/README.md +14 -8
  2. package/dist/ai-edits/apply.d.ts +6 -114
  3. package/dist/ai-edits/apply.js +9 -131
  4. package/dist/ai-edits/applyTypes.d.ts +85 -0
  5. package/dist/ai-edits/applyTypes.js +24 -0
  6. package/dist/ai-edits/clean-text.d.ts +7 -1
  7. package/dist/ai-edits/clean-text.js +23 -2
  8. package/dist/ai-edits/finalSectionReview.d.ts +1 -1
  9. package/dist/ai-edits/headless.d.ts +29 -147
  10. package/dist/ai-edits/headless.js +213 -1634
  11. package/dist/ai-edits/index.d.ts +3 -3
  12. package/dist/ai-edits/index.js +2 -3
  13. package/dist/ai-edits/pending-suggestions.d.ts +14 -4
  14. package/dist/ai-edits/pending-suggestions.js +183 -90
  15. package/dist/ai-edits/result-validation.js +1 -1
  16. package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
  17. package/dist/ai-edits/snapshot.js +8 -3
  18. package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
  19. package/dist/ai-edits/table-cell-mutations.js +1 -1
  20. package/dist/ai-edits/table-geometry.d.ts +1 -1
  21. package/dist/ai-edits/table-geometry.js +1 -1
  22. package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
  23. package/dist/ai-edits/table-row-column-mutations.js +1 -1
  24. package/dist/ai-edits/tableNodes.d.ts +38 -0
  25. package/dist/ai-edits/tableNodes.js +86 -0
  26. package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
  27. package/dist/ai-edits/undefinedReferences.d.ts +7 -0
  28. package/dist/canonical/batchCommentReferences.js +1 -0
  29. package/dist/canonical/canonicalInlineProjection.js +1 -1
  30. package/dist/canonical/canonicalPublicOperations.js +228 -64
  31. package/dist/canonical/canonicalSession.d.ts +9 -1
  32. package/dist/canonical/canonicalSession.js +95 -15
  33. package/dist/compare/compare.d.ts +1 -1
  34. package/dist/compare/inline-atoms-model.d.ts +1 -1
  35. package/dist/compare/inline-atoms.d.ts +2 -2
  36. package/dist/compare/inline-provenance-model.d.ts +1 -1
  37. package/dist/compare/inline-provenance.d.ts +2 -2
  38. package/dist/compat/eigenpal.d.ts +3 -4
  39. package/dist/compat/eigenpal.js +2 -4
  40. package/dist/controller/canonicalClipboard.d.ts +13 -3
  41. package/dist/controller/canonicalClipboard.js +185 -49
  42. package/dist/controller/canonicalClipboardResources.d.ts +9 -1
  43. package/dist/controller/canonicalClipboardResources.js +22 -2
  44. package/dist/controller/canonicalReview.d.ts +1 -1
  45. package/dist/controller/canonicalReview.js +1 -1
  46. package/dist/controller/canonicalStructure.js +1 -1
  47. package/dist/controller/canonicalWatermark.d.ts +10 -0
  48. package/dist/controller/canonicalWatermark.js +37 -0
  49. package/dist/controller/canonicalYjsRoom.d.ts +1 -1
  50. package/dist/controller/headerFooterEditorManager.d.ts +11 -7
  51. package/dist/controller/headerFooterEditorManager.js +39 -151
  52. package/dist/controller/hiddenEditorApi.d.ts +1 -1
  53. package/dist/controller/hiddenEditorManager.d.ts +6 -40
  54. package/dist/controller/hiddenEditorManager.js +173 -306
  55. package/dist/controller/noteEditorManager.d.ts +3 -10
  56. package/dist/controller/noteEditorManager.js +33 -206
  57. package/dist/document-operations-apply.d.ts +15 -0
  58. package/dist/document-operations-apply.js +280 -0
  59. package/dist/document-operations.d.ts +1 -14
  60. package/dist/document-operations.js +2 -279
  61. package/dist/docx/modelValidation.js +1 -1
  62. package/dist/docx/paragraphParser.js +2 -2
  63. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  64. package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
  65. package/dist/docx/reviewResolutionProvenance.js +32 -9
  66. package/dist/docx/revisionIdNormalization.js +30 -7
  67. package/dist/docx/rezip.js +1 -1
  68. package/dist/docx/serializer/borderSerializer.js +1 -1
  69. package/dist/docx/serializer/commentSerializer.js +1 -1
  70. package/dist/docx/serializer/documentSerializer.js +1 -1
  71. package/dist/docx/serializer/paragraphSerializer.js +3 -3
  72. package/dist/docx/serializer/runSerializer.js +1 -1
  73. package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
  74. package/dist/docx/serializer/tableSerializer.js +5 -37
  75. package/dist/docx/serializer/textFormattingSerializer.js +1 -1
  76. package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
  77. package/dist/docx/server/templatePlan/apply.d.ts +15 -0
  78. package/dist/docx/server/templatePlan/apply.js +600 -0
  79. package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
  80. package/dist/docx/server/templatePlan/blocks.js +355 -0
  81. package/dist/docx/server/templatePlan/builders.d.ts +72 -0
  82. package/dist/docx/server/templatePlan/builders.js +237 -0
  83. package/dist/docx/server/templatePlan/emit.d.ts +118 -0
  84. package/dist/docx/server/templatePlan/emit.js +466 -0
  85. package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
  86. package/dist/docx/server/templatePlan/emphasis.js +173 -0
  87. package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
  88. package/dist/docx/server/templatePlan/inspect.js +177 -0
  89. package/dist/docx/server/templatePlan/labels.d.ts +36 -0
  90. package/dist/docx/server/templatePlan/labels.js +126 -0
  91. package/dist/docx/server/templatePlan/package.d.ts +34 -0
  92. package/dist/docx/server/templatePlan/package.js +99 -0
  93. package/dist/docx/server/templatePlan/plan.d.ts +143 -0
  94. package/dist/docx/server/templatePlan/plan.js +841 -0
  95. package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
  96. package/dist/docx/server/templatePlan/planShape.js +161 -0
  97. package/dist/docx/server/templatePlan/resources.d.ts +41 -0
  98. package/dist/docx/server/templatePlan/resources.js +136 -0
  99. package/dist/docx/server/templatePlan/story.d.ts +128 -0
  100. package/dist/docx/server/templatePlan/story.js +440 -0
  101. package/dist/docx/server/templatePlan/types.d.ts +406 -0
  102. package/dist/docx/server/templatePlan/types.js +28 -0
  103. package/dist/docx/server/templatePlan/verify.d.ts +40 -0
  104. package/dist/docx/server/templatePlan/verify.js +968 -0
  105. package/dist/docx/server/templatePlan/xml.d.ts +69 -0
  106. package/dist/docx/server/templatePlan/xml.js +119 -0
  107. package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
  108. package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
  109. package/dist/docx/storyBlockReplay.js +1 -1
  110. package/dist/docx/structuralXmlPatch.js +9 -1
  111. package/dist/docx/tableGridXml.d.ts +30 -0
  112. package/dist/docx/tableGridXml.js +54 -0
  113. package/dist/docx/tableParser.js +7 -0
  114. package/dist/docx/xmlParser.js +1 -1
  115. package/dist/index.d.ts +3 -4
  116. package/dist/index.js +2 -4
  117. package/dist/internal/paragraphFormattingSerialization.js +1 -1
  118. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  119. package/dist/managers/ContextMenuManager.js +2 -1
  120. package/dist/managers/DocumentLoaderManager.d.ts +0 -4
  121. package/dist/managers/DocumentLoaderManager.js +4 -12
  122. package/dist/managers/editorShortcuts.d.ts +1 -1
  123. package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
  124. package/dist/prosemirror/canonicalCommands.d.ts +1 -1
  125. package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
  126. package/dist/prosemirror/canonicalTableCommands.js +2 -2
  127. package/dist/prosemirror/commands/comments.js +3 -3
  128. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  129. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  130. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  131. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  132. package/dist/prosemirror/commands/sectionBreak.js +1 -1
  133. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
  134. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
  135. package/dist/prosemirror/commentRecords.d.ts +1 -1
  136. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  137. package/dist/prosemirror/conversion/fromProseDoc.js +1 -1
  138. package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
  139. package/dist/prosemirror/documentStructureCounts.js +76 -0
  140. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  141. package/dist/prosemirror/extensions/StarterKit.d.ts +1 -1
  142. package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +1 -7
  143. package/dist/prosemirror/extensions/core/HistoryExtension.js +5 -13
  144. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
  145. package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
  146. package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
  147. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  148. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +2 -35
  149. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +4 -142
  150. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +3 -87
  151. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +7 -162
  152. package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
  153. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  154. package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
  155. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  156. package/dist/prosemirror/extensions/nodes/TableExtension.js +2 -2
  157. package/dist/prosemirror/extensions/types.d.ts +1 -1
  158. package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
  159. package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
  160. package/dist/prosemirror/index.d.ts +1 -1
  161. package/dist/prosemirror/index.js +1 -1
  162. package/dist/prosemirror/insertionGaps.d.ts +1 -1
  163. package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
  164. package/dist/prosemirror/listNumbering.d.ts +1 -1
  165. package/dist/prosemirror/lockedControls.d.ts +1 -1
  166. package/dist/prosemirror/markupViewProjection.d.ts +1 -1
  167. package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
  168. package/dist/prosemirror/noteReferenceReview.js +1 -1
  169. package/dist/prosemirror/numberingAttr.d.ts +1 -2
  170. package/dist/prosemirror/numberingAttr.js +1 -2
  171. package/dist/prosemirror/outlineLevelAttr.d.ts +1 -2
  172. package/dist/prosemirror/outlineLevelAttr.js +1 -2
  173. package/dist/prosemirror/paraIds.d.ts +46 -0
  174. package/dist/prosemirror/paraIds.js +152 -0
  175. package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
  176. package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
  177. package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
  178. package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
  179. package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
  180. package/dist/prosemirror/pastedCommentCopies.js +1 -1
  181. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  182. package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
  183. package/dist/prosemirror/plugins/suggestionMode.d.ts +1 -1
  184. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  185. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
  186. package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
  187. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  188. package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
  189. package/dist/prosemirror/replacedAnnotations.js +16 -1
  190. package/dist/prosemirror/revisionCarriers.d.ts +1 -1
  191. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  192. package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
  193. package/dist/prosemirror/selectionBounds.d.ts +10 -0
  194. package/dist/prosemirror/selectionBounds.js +22 -0
  195. package/dist/prosemirror/storyListNumbering.d.ts +1 -1
  196. package/dist/prosemirror/tableCellPaste.d.ts +1 -1
  197. package/dist/prosemirror/tableGridMutation.d.ts +1 -1
  198. package/dist/prosemirror/textInput.d.ts +1 -1
  199. package/dist/server.d.ts +7 -5
  200. package/dist/server.js +6 -4
  201. package/dist/types/canonicalCapabilities.d.ts +8 -41
  202. package/dist/types/canonicalCapabilities.js +6 -34
  203. package/package.json +4 -6
  204. package/dist/controller/collaborationModules.d.ts +0 -3
  205. package/dist/controller/collaborationModules.js +0 -14
  206. package/dist/docx/server/materializeYjsDocx.d.ts +0 -30
  207. package/dist/docx/server/materializeYjsDocx.js +0 -96
  208. package/dist/docx/server/migrateYjsAttrSchema.d.ts +0 -53
  209. package/dist/docx/server/migrateYjsAttrSchema.js +0 -111
  210. package/dist/prosemirror/plugins/derivedFields.d.ts +0 -8
  211. package/dist/prosemirror/plugins/derivedFields.js +0 -52
  212. package/dist/prosemirror/yjsDocumentMetadata.d.ts +0 -89
  213. package/dist/prosemirror/yjsDocumentMetadata.js +0 -697
@@ -3,6 +3,7 @@ import { isValidHexColor } from "../../utils/colorResolver.js";
3
3
  import { serializePreservedAttributes } from "../attributeRemainder.js";
4
4
  import { withPreservedChildren } from "../containerChildren.js";
5
5
  import { TRANSITIONAL_NAME_BY_STRICT_NAME } from "../strictNames.gen.js";
6
+ import { gridColumnCount, modelTableGrid } from "../tableGridXml.js";
6
7
  import { TABLE_LOOK_FLAGS } from "../tableLook.js";
7
8
  import { parseTableCellProperties, parseTableGrid, parseTableGridChange, parseTableProperties, parseTablePropertyExceptions, parseTableRowProperties } from "../tableParser.js";
8
9
  import { serializeEmptyRowProperties } from "../tableRowPropertyPresence.js";
@@ -14,8 +15,8 @@ import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRang
14
15
  import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
15
16
  import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
16
17
  import { intAttr } from "./xmlUtils.js";
17
- import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
18
18
  import { themeColorToken } from "@stll/docx-core/model";
19
+ import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
19
20
  import { serializeSequenceChildren } from "@stll/docx-core/schema";
20
21
  // src/docx/serializer/tableSerializer.ts
21
22
  /**
@@ -430,25 +431,8 @@ function serializeTableCellPropertyChange(change) {
430
431
  return `<w:tcPrChange ${attrs}>${previousTcPrInner.length > 0 ? `<w:tcPr>${previousTcPrInner}</w:tcPr>` : "<w:tcPr/>"}</w:tcPrChange>`;
431
432
  }
432
433
  /**
433
- * Columns the grid has to declare: the widest row's total of skipped columns
434
- * and spans, because a grid narrower than a row leaves cells with no column
435
- * to sit in.
436
- */
437
- function gridColumnCount(table) {
438
- let widest = 0;
439
- for (const row of table.rows) {
440
- let columns = (row.formatting?.gridBefore ?? 0) + (row.formatting?.gridAfter ?? 0);
441
- for (const cell of row.cells) columns += cell.formatting?.gridSpan ?? 1;
442
- widest = Math.max(widest, columns);
443
- }
444
- return widest;
445
- }
446
- /**
447
- * Serialize table grid (w:tblGrid).
448
- *
449
- * `w:tblGrid` is required on every `w:tbl` and `w:w` is optional on a
450
- * `w:gridCol`, so a table whose column widths were never measured — one the
451
- * comparison creates, say — still declares a grid, just without widths.
434
+ * Serialize table grid (w:tblGrid): the grid as it arrived, while it still
435
+ * states the widths the model holds, otherwise the model's grid.
452
436
  */
453
437
  function serializeTableGrid(table) {
454
438
  const columnWidths = table.columnWidths;
@@ -458,24 +442,8 @@ function serializeTableGrid(table) {
458
442
  const declared = element === null ? 0 : findChildren(element, "w", "gridCol").length;
459
443
  if (canonicalJson(parseTableGrid(element)) === canonicalJson(columnWidths) && declared === (columnWidths?.length || gridColumnCount(table)) && canonicalJson(element === null ? void 0 : parseTableGridChange(element)) === canonicalJson(table.formatting?.gridChange)) return gridSourceXml;
460
444
  }
461
- const change = table.formatting?.gridChange;
462
- const gridChange = change === void 0 ? "" : serializeTableGridChange(change);
463
- if (columnWidths && columnWidths.length > 0) return `<w:tblGrid>${columnWidths.map((w) => `<w:gridCol w:w="${intAttr(w)}"/>`).join("")}${gridChange}</w:tblGrid>`;
464
- const columns = gridColumnCount(table);
465
- return columns === 0 && gridChange === "" ? "<w:tblGrid/>" : `<w:tblGrid>${"<w:gridCol/>".repeat(columns)}${gridChange}</w:tblGrid>`;
445
+ return modelTableGrid(table);
466
446
  }
467
- /**
468
- * Serialize `w:tblGridChange`: the grid a reviewer replaced, from the change's
469
- * own record rather than from the bytes it arrived as.
470
- *
471
- * `w:w` is optional on a `w:gridCol`, so a column the snapshot recorded no
472
- * measure for is written back without one; spelling it as a zero would claim a
473
- * width the source never stated.
474
- */
475
- const serializeTableGridChange = ({ id, columnWidths }) => {
476
- const columns = columnWidths.map((width) => width === void 0 ? "<w:gridCol/>" : `<w:gridCol w:w="${intAttr(width)}"/>`).join("");
477
- return `<w:tblGridChange w:id="${intAttr(id)}"><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
478
- };
479
447
  const tableCarrierKey = (carrier) => carrier.type === "customXml" ? `customXml:${String(carrier.wrapper.id)}` : `sdt:${canonicalJson(carrier.properties)}`;
480
448
  const serializeTableCarriers = (children, depth = 0) => {
481
449
  const parts = [];
@@ -3,8 +3,8 @@ import { isValidHexColor } from "../../utils/colorResolver.js";
3
3
  import { roundHorizontalScalePercentForSerialization } from "../../utils/horizontalScale.js";
4
4
  import { serializePreservedAttributes } from "../attributeRemainder.js";
5
5
  import { intAttr } from "./xmlUtils.js";
6
- import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
7
6
  import { themeColorToken } from "@stll/docx-core/model";
7
+ import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
8
8
  import { serializeSequenceChildren } from "@stll/docx-core/schema";
9
9
  // src/docx/serializer/textFormattingSerializer.ts
10
10
  const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
@@ -1,6 +1,6 @@
1
1
  import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
2
- import { assertValidOoxmlNumericId, escapeXmlAttribute } from "@stll/docx-core";
3
2
  import { normalizeRevisionId } from "@stll/docx-core/model";
3
+ import { assertValidOoxmlNumericId, escapeXmlAttribute } from "@stll/docx-core";
4
4
  // src/docx/serializer/trackedChangeAttributes.ts
5
5
  /** Normalized, unescaped attributes in schema order for an XML element or string serializer. */
6
6
  const trackedChangeAttributeEntries = (info) => {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Apply a source document onto a template from a plan: the output is the
3
+ * template's own package with a new main story. Parts the plan does not
4
+ * touch keep their bytes; the ones it does are spliced, not re-serialized.
5
+ */
6
+ import { ApplyTemplatePlanArgs, ApplyTemplatePlanResult, TemplatePlanError } from "./types.js";
7
+ import { Result } from "better-result";
8
+ /**
9
+ * Apply `source` onto `template` as `plan` says and verify the result.
10
+ *
11
+ * The plan names blocks by id and pins them by hash; the text itself always
12
+ * comes from the source. The output is refused, with the report attached,
13
+ * unless every placed block reads back identical.
14
+ */
15
+ export declare const applyTemplatePlan: (input: ApplyTemplatePlanArgs) => Promise<Result<ApplyTemplatePlanResult, TemplatePlanError>>;