@stll/folio-core 0.53.0 → 0.54.1

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 (155) hide show
  1. package/dist/ai-edits/apply.js +415 -166
  2. package/dist/ai-edits/batch-claims.d.ts +21 -6
  3. package/dist/ai-edits/batch-claims.js +47 -16
  4. package/dist/ai-edits/headless.d.ts +20 -0
  5. package/dist/ai-edits/headless.js +140 -11
  6. package/dist/ai-edits/pending-suggestions.js +1 -1
  7. package/dist/ai-edits/read.d.ts +5 -3
  8. package/dist/ai-edits/read.js +97 -47
  9. package/dist/ai-edits/revisionStretches.d.ts +17 -0
  10. package/dist/ai-edits/revisionStretches.js +80 -0
  11. package/dist/ai-edits/snapshot.js +3 -2
  12. package/dist/ai-edits/table-cell-mutations.d.ts +3 -1
  13. package/dist/ai-edits/table-cell-mutations.js +2 -1
  14. package/dist/ai-edits/table-row-column-mutations.d.ts +6 -1
  15. package/dist/ai-edits/table-row-column-mutations.js +27 -10
  16. package/dist/compare/content-alignment.d.ts +5 -1
  17. package/dist/compare/content-alignment.js +39 -32
  18. package/dist/compare/inline-provenance.js +1 -1
  19. package/dist/controller/layoutPipeline.js +3 -2
  20. package/dist/docx/archiveInflation.d.ts +127 -0
  21. package/dist/docx/archiveInflation.js +181 -0
  22. package/dist/docx/metadataPrivacy.js +24 -1
  23. package/dist/docx/noteReferenceMark.d.ts +15 -0
  24. package/dist/docx/noteReferenceMark.js +48 -0
  25. package/dist/docx/paragraphParser.js +5 -3
  26. package/dist/docx/paragraphPropertySource.d.ts +1 -1
  27. package/dist/docx/paragraphPropertySource.js +4 -2
  28. package/dist/docx/parser.js +2 -2
  29. package/dist/docx/rezip.js +4 -2
  30. package/dist/docx/selectiveXmlPatch.d.ts +3 -1
  31. package/dist/docx/selectiveXmlPatch.js +81 -3
  32. package/dist/docx/server/boundedArchive.d.ts +8 -13
  33. package/dist/docx/server/boundedArchive.js +70 -59
  34. package/dist/docx/server/extractDocxText.d.ts +8 -2
  35. package/dist/docx/server/extractDocxText.js +2 -2
  36. package/dist/docx/server/validateDocxConformance.d.ts +1 -1
  37. package/dist/docx/server/validateDocxConformance.js +1 -0
  38. package/dist/docx/unzip.d.ts +19 -2
  39. package/dist/docx/unzip.js +135 -24
  40. package/dist/docx/verticalMergeProjection.d.ts +17 -0
  41. package/dist/docx/verticalMergeProjection.js +120 -0
  42. package/dist/fonts/embeddedFonts.js +1 -1
  43. package/dist/i18n/messages/catalogs.gen.d.ts +34 -34
  44. package/dist/i18n/messages/catalogs.gen.js +34 -34
  45. package/dist/i18n/messages/messages.gen.d.ts +2 -2
  46. package/dist/internal/wholeStoryRevisionResolution.js +95 -25
  47. package/dist/layout-engine/measure/measureParagraph.js +2 -2
  48. package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
  49. package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
  50. package/dist/markdown/escape.d.ts +2 -2
  51. package/dist/markdown/escape.js +4 -5
  52. package/dist/markdown/renderBlock.js +91 -25
  53. package/dist/markdown/renderRuns.d.ts +10 -1
  54. package/dist/markdown/renderRuns.js +320 -59
  55. package/dist/prosemirror/clearRunColor.d.ts +6 -0
  56. package/dist/prosemirror/clearRunColor.js +46 -0
  57. package/dist/prosemirror/commands/comments.js +62 -22
  58. package/dist/prosemirror/commands/formatPainter.js +1 -1
  59. package/dist/prosemirror/commands/hyperlink.js +2 -1
  60. package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
  61. package/dist/prosemirror/commands/propertyChangeScope.js +28 -4
  62. package/dist/prosemirror/commands/resolveAllTableChanges.js +40 -41
  63. package/dist/prosemirror/commands/resolveParagraphProperties.js +33 -8
  64. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +7 -1
  65. package/dist/prosemirror/commands/tableCellMergeResolution.js +39 -20
  66. package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +61 -0
  67. package/dist/prosemirror/commands/tableMergeFoldDecisions.js +79 -0
  68. package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
  69. package/dist/prosemirror/containerFinalParagraph.js +7 -6
  70. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
  71. package/dist/prosemirror/conversion/fromProseDoc.js +12 -590
  72. package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -13
  73. package/dist/prosemirror/conversion/toProseDoc.js +28 -262
  74. package/dist/prosemirror/documentSchema.d.ts +8 -0
  75. package/dist/prosemirror/documentSchema.js +18 -0
  76. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  77. package/dist/prosemirror/extensions/core/ParagraphExtension.js +104 -63
  78. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
  79. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
  80. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
  81. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
  82. package/dist/prosemirror/extensions/features/ListExtension.js +10 -9
  83. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  84. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +2 -4
  85. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +14 -8
  86. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
  87. package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
  88. package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
  89. package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
  90. package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
  91. package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -6
  92. package/dist/prosemirror/extensions/marks/markUtils.js +17 -8
  93. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +3 -1
  94. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +12 -1
  95. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
  96. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
  97. package/dist/prosemirror/extensions/nodes/TableExtension.js +104 -210
  98. package/dist/prosemirror/extensions/types.d.ts +7 -0
  99. package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
  100. package/dist/prosemirror/hyperlinkRemoval.js +129 -0
  101. package/dist/prosemirror/index.d.ts +2 -1
  102. package/dist/prosemirror/index.js +2 -1
  103. package/dist/prosemirror/listNumbering.d.ts +3 -21
  104. package/dist/prosemirror/listNumbering.js +24 -39
  105. package/dist/prosemirror/listRendering.d.ts +29 -0
  106. package/dist/prosemirror/listRendering.js +26 -0
  107. package/dist/prosemirror/markupViewNotes.d.ts +8 -0
  108. package/dist/prosemirror/markupViewNotes.js +49 -0
  109. package/dist/prosemirror/markupViewProjection.d.ts +3 -1
  110. package/dist/prosemirror/markupViewProjection.js +7 -2
  111. package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
  112. package/dist/prosemirror/noteReferenceReview.js +332 -0
  113. package/dist/prosemirror/paragraphIndentation.js +5 -2
  114. package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -4
  115. package/dist/prosemirror/paragraphMarkJoin.js +21 -19
  116. package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
  117. package/dist/prosemirror/paragraphPropertyCarry.js +155 -0
  118. package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
  119. package/dist/prosemirror/plugins/documentStyleState.js +32 -0
  120. package/dist/prosemirror/plugins/documentStyles.d.ts +2 -21
  121. package/dist/prosemirror/plugins/documentStyles.js +66 -29
  122. package/dist/prosemirror/plugins/index.d.ts +2 -1
  123. package/dist/prosemirror/plugins/index.js +2 -1
  124. package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
  125. package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
  126. package/dist/prosemirror/plugins/suggestionMode.d.ts +12 -2
  127. package/dist/prosemirror/plugins/suggestionMode.js +387 -28
  128. package/dist/prosemirror/plugins/templateDirectives.d.ts +6 -0
  129. package/dist/prosemirror/plugins/templateDirectives.js +21 -7
  130. package/dist/prosemirror/plugins/templatePreviewValues.js +14 -21
  131. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +22 -2
  132. package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
  133. package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
  134. package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
  135. package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
  136. package/dist/prosemirror/runFormattingFromMarks.js +567 -0
  137. package/dist/prosemirror/runFormattingReconciliation.js +10 -9
  138. package/dist/prosemirror/schema/nodes.d.ts +2 -0
  139. package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
  140. package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
  141. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
  142. package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
  143. package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
  144. package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
  145. package/dist/prosemirror/tableCellPaste.d.ts +74 -0
  146. package/dist/prosemirror/tableCellPaste.js +525 -0
  147. package/dist/prosemirror/tableGridMutation.d.ts +53 -14
  148. package/dist/prosemirror/tableGridMutation.js +166 -18
  149. package/dist/prosemirror/tableRunIn.d.ts +51 -0
  150. package/dist/prosemirror/tableRunIn.js +165 -0
  151. package/dist/prosemirror/textInput.js +11 -2
  152. package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
  153. package/dist/prosemirror/trackedRevisionPath.js +32 -0
  154. package/dist/server.d.ts +2 -2
  155. package/package.json +6 -6
@@ -0,0 +1,79 @@
1
+ import { isCellMergeContinuation, isCellMergeStart, isTableCellMergeRevisionContinuation } from "../../docx/tableParser.js";
2
+ import { tableCellHasMeaningfulContent } from "../../docx/verticalMergeProjection.js";
3
+ import { expectTableCellAttrs } from "../attrs/index.js";
4
+ import { standaloneTableCellFromProseMirror } from "../conversion/fromProseDoc.js";
5
+ import { panic } from "better-result";
6
+ import { TableMap } from "prosemirror-tables";
7
+ //#region src/prosemirror/commands/tableMergeFoldDecisions.ts
8
+ /** Resolve raw merge states without converting unrelated table revisions. */
9
+ const tableMergeFoldDecisions = ({ table, mode, revisionSet }) => {
10
+ const decisions = /* @__PURE__ */ new Map();
11
+ const origins = /* @__PURE__ */ new Set();
12
+ const invalid = /* @__PURE__ */ new Set();
13
+ const map = TableMap.get(table);
14
+ const visited = /* @__PURE__ */ new Set();
15
+ for (const [index, position] of map.map.entries()) {
16
+ if (visited.has(position)) continue;
17
+ visited.add(position);
18
+ const cell = table.nodeAt(position);
19
+ if (cell?.attrs["cellMarker"]?.kind !== "merge") continue;
20
+ const marker = expectTableCellAttrs(cell).cellMarker;
21
+ if (marker?.kind !== "merge" || revisionSet !== null && !revisionSet.has(marker.info.revisionId)) continue;
22
+ const continues = isTableCellMergeRevisionContinuation(mode === "accept" ? marker.verticalMerge : marker.verticalMergeOriginal);
23
+ decisions.set(position, continues && (mode === "reject" || !tableCellHasMeaningfulContent(standaloneTableCellFromProseMirror(cell))));
24
+ if (!continues) continue;
25
+ if (Math.floor(index / map.width) === 0) {
26
+ invalid.add(position);
27
+ continue;
28
+ }
29
+ const abovePosition = map.map[index - map.width];
30
+ if (abovePosition === void 0) return panic("Merge resolution lost its origin");
31
+ const above = table.nodeAt(abovePosition);
32
+ if (!above) return panic("Merge resolution lost its origin");
33
+ const rectangle = map.findCell(position);
34
+ const aboveRectangle = map.findCell(abovePosition);
35
+ if (rectangle.left !== aboveRectangle.left || rectangle.right !== aboveRectangle.right || rectangle.top !== aboveRectangle.bottom) {
36
+ invalid.add(position);
37
+ continue;
38
+ }
39
+ const aboveMarker = expectTableCellAttrs(above).cellMarker;
40
+ const aboveContinues = aboveMarker?.kind === "merge" && (revisionSet === null || revisionSet.has(aboveMarker.info.revisionId)) && isTableCellMergeRevisionContinuation(mode === "accept" ? aboveMarker.verticalMerge : aboveMarker.verticalMergeOriginal);
41
+ const aboveModel = standaloneTableCellFromProseMirror(above);
42
+ if (mode === "accept" && (aboveContinues && decisions.get(abovePosition) === false || isCellMergeContinuation(aboveModel) && tableCellHasMeaningfulContent(aboveModel))) decisions.set(position, false);
43
+ if (aboveContinues || isCellMergeContinuation(aboveModel) || isCellMergeStart(aboveModel)) continue;
44
+ origins.add(abovePosition);
45
+ }
46
+ return {
47
+ folds: decisions,
48
+ origins,
49
+ invalid
50
+ };
51
+ };
52
+ /** Persist an implicit merge origin even when reader rules retain its continuation. */
53
+ const resolvedTableMergeOriginAttrs = (cell) => ({
54
+ ...cell.attrs,
55
+ _originalFormatting: {
56
+ ...expectTableCellAttrs(cell)._originalFormatting,
57
+ vMerge: "restart"
58
+ },
59
+ _preserveVMergeRestart: true
60
+ });
61
+ /** A retained continuation must save the merge state the reviewer resolved. */
62
+ const resolvedVisibleTableCellMergeAttrs = ({ cell, mode, origin }) => {
63
+ const attrs = expectTableCellAttrs(cell);
64
+ const marker = attrs.cellMarker;
65
+ if (marker?.kind !== "merge") return panic("Cell has no merge revision");
66
+ const continuation = mode === "accept" ? marker.verticalMerge : marker.verticalMergeOriginal;
67
+ const formatting = { ...attrs._originalFormatting };
68
+ if (origin) formatting.vMerge = "restart";
69
+ else if (isTableCellMergeRevisionContinuation(continuation)) formatting.vMerge = "continue";
70
+ else delete formatting.vMerge;
71
+ return {
72
+ ...cell.attrs,
73
+ cellMarker: null,
74
+ _originalFormatting: formatting,
75
+ _preserveVMergeRestart: origin
76
+ };
77
+ };
78
+ //#endregion
79
+ export { resolvedTableMergeOriginAttrs, resolvedVisibleTableCellMergeAttrs, tableMergeFoldDecisions };
@@ -28,18 +28,24 @@ declare const finalParagraphsOf: (doc: Node, paragraphTypeName: string) => {
28
28
  position: number;
29
29
  node: Node;
30
30
  }[];
31
+ type AddedBreakCarrierBeforeOptions = {
32
+ at: ResolvedPos;
33
+ paragraphTypeName: string;
34
+ canCrossTable?: (table: Node) => boolean;
35
+ };
31
36
  /**
32
37
  * The paragraph an added break can rotate BACK onto from the one at `at`: the
33
38
  * paragraph the run of inserted ones was appended after.
34
39
  *
35
40
  * The walk crosses the inserted paragraphs — their own marks stay where they
36
41
  * are, and only which paragraph is left markless changes — and stops at the
37
- * first one whose mark is free. `null` when there is none: a table in between,
38
- * which no mark joins across; a paragraph whose mark says something else,
39
- * which the rotation must not overwrite; or a container whose every paragraph
40
- * is new.
42
+ * first one whose mark is free. A table blocks the walk unless the caller
43
+ * authorizes a wholly inserted table: rejecting it removes that barrier too.
44
+ * `null` when there is no carrier: a table the caller cannot cross, a
45
+ * paragraph whose mark the rotation must not overwrite, or a container whose
46
+ * every paragraph is new.
41
47
  */
42
- declare const addedBreakCarrierBefore: (at: ResolvedPos, paragraphTypeName: string) => {
48
+ declare const addedBreakCarrierBefore: ({ at, paragraphTypeName, canCrossTable }: AddedBreakCarrierBeforeOptions) => {
43
49
  position: number;
44
50
  node: Node;
45
51
  } | null;
@@ -66,18 +66,19 @@ const marksAnAddedBreak = (node) => {
66
66
  *
67
67
  * The walk crosses the inserted paragraphs — their own marks stay where they
68
68
  * are, and only which paragraph is left markless changes — and stops at the
69
- * first one whose mark is free. `null` when there is none: a table in between,
70
- * which no mark joins across; a paragraph whose mark says something else,
71
- * which the rotation must not overwrite; or a container whose every paragraph
72
- * is new.
69
+ * first one whose mark is free. A table blocks the walk unless the caller
70
+ * authorizes a wholly inserted table: rejecting it removes that barrier too.
71
+ * `null` when there is no carrier: a table the caller cannot cross, a
72
+ * paragraph whose mark the rotation must not overwrite, or a container whose
73
+ * every paragraph is new.
73
74
  */
74
- const addedBreakCarrierBefore = (at, paragraphTypeName) => {
75
+ const addedBreakCarrierBefore = ({ at, paragraphTypeName, canCrossTable }) => {
75
76
  let position = at.pos;
76
77
  for (let index = at.index() - 1; index >= 0; index--) {
77
78
  const sibling = at.parent.child(index);
78
79
  position -= sibling.nodeSize;
79
80
  if (sibling.type.name !== paragraphTypeName) {
80
- if (isAContainerChild(sibling, paragraphTypeName)) return null;
81
+ if (isAContainerChild(sibling, paragraphTypeName) && !canCrossTable?.(sibling)) return null;
81
82
  continue;
82
83
  }
83
84
  if (sibling.attrs["pPrMark"] == null) return {
@@ -1,7 +1,7 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
2
  import { TableAttrs, TableCellAttrs, TableRowAttrs } from "../schema/nodes.js";
3
- import { RunStyleResolver } from "../runStyleFormatting.js";
4
- import { Mark, Node } from "prosemirror-model";
3
+ import { marksToTextFormatting } from "../runFormattingFromMarks.js";
4
+ import { Node } from "prosemirror-model";
5
5
  //#region src/prosemirror/conversion/fromProseDoc.d.ts
6
6
  /**
7
7
  * Whether a record the editor did not change may come back from the base
@@ -21,17 +21,6 @@ type FromProseDocOptions = {
21
21
  };
22
22
  /** Convert a ProseMirror document to the document model. */
23
23
  declare function fromProseDoc(pmDoc: Node, baseDocument?: document_d_exports.Document, { reuse }?: FromProseDocOptions): document_d_exports.Document;
24
- /**
25
- * Convert ProseMirror marks to TextFormatting
26
- */
27
- type MarksToTextFormattingOptions = {
28
- baseParagraphFormatting?: document_d_exports.TextFormatting | undefined;
29
- inheritedFormatting?: document_d_exports.TextFormatting | undefined;
30
- paragraphMarkFormatting?: document_d_exports.TextFormatting | undefined;
31
- paragraphMarkPrecedesStyle?: boolean | undefined;
32
- styleResolver?: RunStyleResolver | null | undefined;
33
- };
34
- declare function marksToTextFormatting(marks: readonly Mark[], options?: MarksToTextFormattingOptions): document_d_exports.TextFormatting;
35
24
  declare function tableAttrsToFormatting(attrs: TableAttrs): document_d_exports.TableFormatting | undefined;
36
25
  /**
37
26
  * Convert ProseMirror table row attrs to TableRowFormatting