@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
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Table nodes an operation inserts: a plain grid of cell texts, or the
3
+ * signature table `insertSignatureTable` places.
4
+ */
5
+ import { TableStructureRevision } from "./table-template.js";
6
+ import { FolioAISignatureParty } from "./types.js";
7
+ import { Node, Schema } from "prosemirror-model";
8
+ type BuildTableNodeOptions = {
9
+ schema: Schema;
10
+ rows: readonly (readonly string[])[];
11
+ /** Present in tracked mode: every row is stamped as an insertion. */
12
+ revision?: TableStructureRevision;
13
+ };
14
+ /**
15
+ * A plain table from a grid of cell texts, `null` when the schema has no
16
+ * tables. In tracked mode every row carries `trIns` and every run inside it
17
+ * carries `w:ins`, which is how the format says "this table is new": there is
18
+ * no whole-table insertion element, only rows that were inserted, and a
19
+ * consumer that reads only run-level revisions keeps the text of a rejected
20
+ * insertion when the row marker stands alone.
21
+ */
22
+ export declare const buildTableNode: ({ schema, rows, revision }: BuildTableNodeOptions) => Node | null;
23
+ type BuildSignatureTableNodeOptions = {
24
+ schema: Schema;
25
+ parties: readonly FolioAISignatureParty[];
26
+ };
27
+ /**
28
+ * Build a borderless PM table mirroring docx-core's
29
+ * `signatureTable` helper: one row, one cell per party, each cell
30
+ * containing party name (bold), two spacer paragraphs, a signature
31
+ * rule, then optional signatory and italic title lines.
32
+ *
33
+ * Returns `null` when the editor schema is missing one of the
34
+ * required node types — callers should surface the op as a skip
35
+ * rather than crashing.
36
+ */
37
+ export declare const buildSignatureTableNode: ({ schema, parties }: BuildSignatureTableNodeOptions) => Node | null;
38
+ export {};
@@ -0,0 +1,86 @@
1
+ import { cleanTextInlineNodes } from "./clean-text.js";
2
+ import { splitCellParagraphTexts } from "./table-row-column-mutations.js";
3
+ // src/ai-edits/tableNodes.ts
4
+ /**
5
+ * Length of the underscore signature rule. Mirrors the constant
6
+ * in `docx-core/legal-source/compile.ts` so the on-screen signature
7
+ * line matches what `create-document` produces.
8
+ */
9
+ const SIGNATURE_LINE = "_".repeat(28);
10
+ /**
11
+ * A plain table from a grid of cell texts, `null` when the schema has no
12
+ * tables. In tracked mode every row carries `trIns` and every run inside it
13
+ * carries `w:ins`, which is how the format says "this table is new": there is
14
+ * no whole-table insertion element, only rows that were inserted, and a
15
+ * consumer that reads only run-level revisions keeps the text of a rejected
16
+ * insertion when the row marker stands alone.
17
+ */
18
+ const buildTableNode = ({ schema, rows, revision }) => {
19
+ const paragraphType = schema.nodes["paragraph"];
20
+ const cellType = schema.nodes["tableCell"];
21
+ const rowType = schema.nodes["tableRow"];
22
+ const tableType = schema.nodes["table"];
23
+ if (!paragraphType || !cellType || !rowType || !tableType || rows.length === 0) return null;
24
+ const insertionType = schema.marks["insertion"];
25
+ const marks = revision && insertionType ? [insertionType.create({
26
+ revisionId: revision.revisionId,
27
+ author: revision.author,
28
+ date: revision.date,
29
+ ...revision.initials != null && { initials: revision.initials },
30
+ ...revision.provenance != null && { provenance: revision.provenance },
31
+ ...revision.suggestionId != null && { suggestionId: revision.suggestionId }
32
+ })] : void 0;
33
+ const rowNodes = rows.map((cells) => rowType.create(revision ? { trIns: revision } : null, cells.map((text) => cellType.create(null, splitCellParagraphTexts(text).map((line) => paragraphType.create(null, line.length > 0 ? cleanTextInlineNodes({
34
+ schema,
35
+ text: line,
36
+ marks
37
+ }) : null))))));
38
+ return tableType.create(null, rowNodes);
39
+ };
40
+ /**
41
+ * Build a borderless PM table mirroring docx-core's
42
+ * `signatureTable` helper: one row, one cell per party, each cell
43
+ * containing party name (bold), two spacer paragraphs, a signature
44
+ * rule, then optional signatory and italic title lines.
45
+ *
46
+ * Returns `null` when the editor schema is missing one of the
47
+ * required node types — callers should surface the op as a skip
48
+ * rather than crashing.
49
+ */
50
+ const buildSignatureTableNode = ({ schema, parties }) => {
51
+ const paragraphType = schema.nodes["paragraph"];
52
+ const cellType = schema.nodes["tableCell"];
53
+ const rowType = schema.nodes["tableRow"];
54
+ const tableType = schema.nodes["table"];
55
+ if (!paragraphType || !cellType || !rowType || !tableType) return null;
56
+ const boldType = schema.marks["bold"];
57
+ const italicType = schema.marks["italic"];
58
+ const buildParagraph = (text, options) => {
59
+ const marks = [];
60
+ if (options.bold && boldType) marks.push(boldType.create());
61
+ if (options.italic && italicType) marks.push(italicType.create());
62
+ const content = text.length > 0 ? schema.text(text, marks) : null;
63
+ return paragraphType.create({ styleId: options.styleId }, content);
64
+ };
65
+ const buildCell = (party) => {
66
+ const cellContent = [
67
+ buildParagraph(party.name, {
68
+ styleId: "SignatureParty",
69
+ bold: true
70
+ }),
71
+ buildParagraph("", { styleId: "SignatureSpacer" }),
72
+ buildParagraph("", { styleId: "SignatureSpacer" }),
73
+ buildParagraph(SIGNATURE_LINE, { styleId: "SignatureRule" })
74
+ ];
75
+ if (party.signatory && party.signatory.length > 0) cellContent.push(buildParagraph(party.signatory, { styleId: "SignatureField" }));
76
+ if (party.title && party.title.length > 0) cellContent.push(buildParagraph(party.title, {
77
+ styleId: "SignatureField",
78
+ italic: true
79
+ }));
80
+ return cellType.create({}, cellContent);
81
+ };
82
+ const cells = parties.map(buildCell);
83
+ const row = rowType.create({}, cells);
84
+ return tableType.create({}, row);
85
+ };
86
+ export { buildSignatureTableNode, buildTableNode };
@@ -1,6 +1,6 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
- import { Node } from "prosemirror-model";
3
2
  import { EditorState } from "prosemirror-state";
3
+ import { Node } from "prosemirror-model";
4
4
  type TrackedBatchFidelityOptions = {
5
5
  before: EditorState;
6
6
  after: Node;
@@ -14,6 +14,13 @@ import { FolioAIEditOperation } from "./types.js";
14
14
  * What an editing request does with a style or numbering reference the
15
15
  * document does not define: `refuse` the operation, or `keep` the reference
16
16
  * verbatim (source-preserving imports).
17
+ *
18
+ * Editing callers explicitly select `refuse`: an undefined reference would
19
+ * report a formatting edit without changing its appearance. Missing references are skipped with
20
+ * `missingStyle` or `missingNumbering`.
21
+ * Comparison and redline use `keep` for unknown source styles; their import
22
+ * boundary clears destination style collisions with warnings before application.
23
+ * The parser already normalizes undefined source numbering to none.
17
24
  */
18
25
  export type FolioUndefinedReferencePolicy = "refuse" | "keep";
19
26
  /** An operation as either engine holds it: staged (new lists deferred) or as parsed. */
@@ -51,6 +51,7 @@ const mapIntentPositions = (intent, map) => {
51
51
  case "formatRun":
52
52
  case "insertAtom":
53
53
  case "replaceFragment":
54
+ case "pasteBlocks":
54
55
  case "setHyperlink":
55
56
  case "removeHyperlink":
56
57
  case "insertHyperlink": return {
@@ -11,8 +11,8 @@ import { readRangeAnchorAttrs } from "../prosemirror/rangeAnchorAttrs.js";
11
11
  import { PRESERVED_XML_LEVELS } from "../prosemirror/schema/nodes.js";
12
12
  import { itemBefore } from "../utils/listItems.js";
13
13
  import { Result, TaggedError, panic } from "better-result";
14
- import { hasIllegalXmlCharacters } from "@stll/docx-core";
15
14
  import { defaultInsertionGap, inlineLeafSpans, paragraphLogicalText } from "@stll/docx-core/ops";
15
+ import { hasIllegalXmlCharacters } from "@stll/docx-core";
16
16
  // src/canonical/canonicalInlineProjection.ts
17
17
  const CANONICAL_SOURCE_INLINE_POLICIES = {
18
18
  run: "container",