@stll/folio-core 0.37.1 → 0.37.3

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 (63) hide show
  1. package/dist/ai-edits/headless.d.ts +24 -1
  2. package/dist/ai-edits/headless.js +108 -71
  3. package/dist/ai-edits/read.d.ts +9 -1
  4. package/dist/ai-edits/read.js +34 -16
  5. package/dist/ai-edits/snapshot.d.ts +7 -5
  6. package/dist/ai-edits/snapshot.js +39 -12
  7. package/dist/ai-edits/table-cell-mutations.js +10 -5
  8. package/dist/ai-edits/table-template.js +19 -5
  9. package/dist/compare/compare.d.ts +2 -3
  10. package/dist/compare/compare.js +41 -64
  11. package/dist/compare/content-alignment.js +0 -1
  12. package/dist/compare/scenario.d.ts +11 -2
  13. package/dist/compare/scenario.js +6 -2
  14. package/dist/controller/hiddenEditorManager.js +11 -0
  15. package/dist/controller/layoutPipeline.js +1 -1
  16. package/dist/display-list/build/textBoxPrimitives.js +34 -1
  17. package/dist/display-list/dom/renderDisplayListToDom.js +5 -2
  18. package/dist/display-list/primitives.d.ts +1 -1
  19. package/dist/display-list/types.d.ts +8 -4
  20. package/dist/docx/paragraphPropertySource.d.ts +82 -2
  21. package/dist/docx/paragraphPropertySource.js +569 -3
  22. package/dist/docx/parser.js +9 -0
  23. package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
  24. package/dist/docx/server/materializeYjsDocx.js +21 -2
  25. package/dist/headless-layout.js +1 -1
  26. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +7 -1
  27. package/dist/layout-bridge/convert/headerFooterLayout.js +20 -3
  28. package/dist/layout-bridge/convert/toFlowBlocks.js +43 -12
  29. package/dist/layout-engine/index.js +20 -10
  30. package/dist/layout-engine/measure/measureBlocks.d.ts +7 -3
  31. package/dist/layout-engine/measure/measureBlocks.js +10 -7
  32. package/dist/layout-engine/measure/measureParagraph.d.ts +2 -0
  33. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  34. package/dist/layout-engine/paginator.d.ts +1 -1
  35. package/dist/layout-engine/paginator.js +41 -4
  36. package/dist/layout-engine/textBoxFlow.d.ts +2 -0
  37. package/dist/layout-engine/textBoxFlow.js +9 -5
  38. package/dist/layout-engine/types.d.ts +6 -0
  39. package/dist/layout-painter/documentColors.d.ts +10 -1
  40. package/dist/layout-painter/documentColors.js +16 -1
  41. package/dist/layout-painter/renderParagraph.js +9 -24
  42. package/dist/layout-painter/renderTable.js +3 -3
  43. package/dist/layout-painter/renderTextBox.js +2 -1
  44. package/dist/pdf/pageSpace.d.ts +12 -1
  45. package/dist/pdf/pageSpace.js +24 -1
  46. package/dist/pdf/paint.js +2 -2
  47. package/dist/prosemirror/attrs/index.js +19 -8
  48. package/dist/prosemirror/commands/comments.js +12 -3
  49. package/dist/prosemirror/commands/tableCellMergeResolution.js +18 -11
  50. package/dist/prosemirror/conversion/fromProseDoc.js +94 -21
  51. package/dist/prosemirror/conversion/toProseDoc.js +100 -8
  52. package/dist/prosemirror/extensions/core/DocExtension.js +2 -0
  53. package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -0
  54. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +5 -1
  55. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +132 -41
  56. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +2 -0
  57. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +7 -0
  58. package/dist/prosemirror/schema/nodes.d.ts +3 -1
  59. package/dist/prosemirror/yjsParagraphSourceContract.d.ts +9 -0
  60. package/dist/prosemirror/yjsParagraphSourceContract.js +26 -0
  61. package/dist/utils/rotationBoundingBox.d.ts +5 -1
  62. package/dist/utils/rotationBoundingBox.js +9 -1
  63. package/package.json +2 -2
@@ -1,14 +1,45 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { Transaction } from "prosemirror-state";
3
- import { Fragment, Mark, Node } from "prosemirror-model";
3
+ import { Fragment, Mark, Node, NodeType } from "prosemirror-model";
4
4
  //#region src/docx/paragraphPropertySource.d.ts
5
5
  type ParagraphPropertySource = {
6
6
  xml: string;
7
7
  formattingJson: string;
8
8
  };
9
+ declare const PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR = "_docxParagraphSourceToken";
10
+ declare const PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR = "_docxParagraphSourceContract";
11
+ /** Durable identity nested inside opaque collapsed-cell ProseMirror attrs; stripped on restore. */
12
+ declare const TABLE_CELL_PARAGRAPH_SOURCE_BINDING_ATTR = "_docxParagraphSourceBinding";
13
+ declare const PARAGRAPH_PROPERTY_SOURCE_VALIDATION_CODES: readonly ["contract_mismatch", "duplicate_token", "invalid_token", "unknown_token"];
14
+ type ParagraphPropertySourceValidationCode = (typeof PARAGRAPH_PROPERTY_SOURCE_VALIDATION_CODES)[number];
15
+ declare const TABLE_CELL_PARAGRAPH_SOURCE_PAYLOAD_ERROR_CLASSIFICATIONS: readonly ["complexity_limit", "cyclic_or_aliased_graph", "depth_limit", "expected_array", "expected_block", "expected_cell", "expected_inline_content", "expected_paragraph", "expected_record", "expected_row", "invalid_binding", "invalid_block_type", "invalid_cell_type", "invalid_graph_value", "invalid_inline_content_type", "invalid_paragraph_type", "invalid_row_type", "malformed_source_token"];
16
+ type TableCellParagraphSourcePayloadErrorClassification = (typeof TABLE_CELL_PARAGRAPH_SOURCE_PAYLOAD_ERROR_CLASSIFICATIONS)[number];
17
+ declare const ParagraphPropertySourceValidationError_base: import("better-result").TaggedErrorClass<"ParagraphPropertySourceValidationError">;
18
+ declare class ParagraphPropertySourceValidationError extends ParagraphPropertySourceValidationError_base<{
19
+ code: ParagraphPropertySourceValidationCode;
20
+ classification?: TableCellParagraphSourcePayloadErrorClassification;
21
+ message: string;
22
+ path?: string;
23
+ }> {}
24
+ declare const isParagraphPropertySourceToken: (token: unknown) => token is string;
25
+ /** True only for a body-story token derived from the exact source contract. */
26
+ declare const paragraphPropertySourceTokenMatchesContract: (token: unknown, contract: string) => token is string;
27
+ /** Visit the v1 provenance scope in canonical OOXML body-story order. */
28
+ declare const visitDocumentStoryParagraphs: (content: document_d_exports.Document["package"]["document"]["content"], visit: (paragraph: document_d_exports.Paragraph) => void) => void;
9
29
  declare const assignParagraphPropertySource: (paragraph: document_d_exports.Paragraph, source: ParagraphPropertySource) => void;
10
30
  declare const getParagraphPropertySource: (paragraph: document_d_exports.Paragraph) => ParagraphPropertySource | undefined;
31
+ /** Copy the captured `w:pPr` without claiming the source paragraph's durable identity. */
32
+ declare const copyParagraphPropertyCapture: (target: document_d_exports.Paragraph, source: document_d_exports.Paragraph) => void;
11
33
  declare const copyParagraphPropertySource: (target: document_d_exports.Paragraph, source: document_d_exports.Paragraph) => void;
34
+ /** Bind parsed body paragraphs to one exact source package. */
35
+ declare const assignDocumentParagraphPropertySourceContract: (document: document_d_exports.Document, sourceDigest: string) => void;
36
+ declare const getDocumentParagraphPropertySourceContract: (document: document_d_exports.Document) => string | undefined;
37
+ declare const copyDocumentParagraphPropertySources: (document: document_d_exports.Document) => Map<string, document_d_exports.Paragraph> | undefined;
38
+ declare const paragraphPropertySourceBelongsToDocument: (paragraph: document_d_exports.Paragraph, document: document_d_exports.Document) => boolean;
39
+ declare const getProseDocumentParagraphPropertySourceContract: (document: Node) => string | null;
40
+ declare const getProseParagraphPropertySourceToken: (paragraph: Node) => unknown;
41
+ declare const copyDocumentParagraphPropertySourceContract: (target: document_d_exports.Document, source: document_d_exports.Document) => void;
42
+ declare const getParagraphPropertySourceToken: (paragraph: document_d_exports.Paragraph) => string | undefined;
12
43
  type ParagraphCloneOverrides = Omit<Partial<document_d_exports.Paragraph>, "type">;
13
44
  /** Clone a paragraph while deliberately retaining its parsed `w:pPr` owner. */
14
45
  declare const cloneParagraphWithPropertySource: (paragraph: document_d_exports.Paragraph, overrides: ParagraphCloneOverrides) => document_d_exports.Paragraph;
@@ -20,7 +51,50 @@ declare const cloneParagraphWithoutPropertySource: (paragraph: document_d_export
20
51
  * mismatch is an internal invariant failure rather than a position heuristic.
21
52
  */
22
53
  declare const cloneDocumentWithParagraphPropertySources: (document: document_d_exports.Document) => document_d_exports.Document;
54
+ type TableCellParagraphPropertySourceBinding = Readonly<{
55
+ type: "authored";
56
+ }> | Readonly<{
57
+ token: string;
58
+ type: "source";
59
+ }>;
60
+ declare const decodedTableCellParagraphSourcePayloadBrand: unique symbol;
61
+ type DecodedTableCellParagraphSourcePayload = Readonly<{
62
+ [decodedTableCellParagraphSourcePayloadBrand]: true;
63
+ cells: readonly document_d_exports.TableCell[];
64
+ }>;
65
+ /** Decode and freeze the opaque collapsed-cell wire payload before typed use. */
66
+ declare const decodeTableCellParagraphSourcePayload: (value: unknown) => DecodedTableCellParagraphSourcePayload;
67
+ /** Prepare opaque continuation cells for ProseMirror and Yjs transport. */
68
+ declare const transportTableCellsWithParagraphPropertySources: (cells: document_d_exports.TableCell[]) => document_d_exports.TableCell[];
69
+ /** Restore decoded identities privately and remove them from the document model. */
70
+ declare const restoreTableCellsWithParagraphPropertySources: (payload: DecodedTableCellParagraphSourcePayload) => document_d_exports.TableCell[];
71
+ /** Visit every transported hidden paragraph in canonical cell-story order. */
72
+ declare const visitTableCellParagraphPropertySourceBindings: (payload: DecodedTableCellParagraphSourcePayload, visit: (binding: TableCellParagraphPropertySourceBinding, path: string) => void) => void;
73
+ /**
74
+ * Clone package-crossing vertical-merge payloads with their captured `w:pPr`,
75
+ * but without the durable paragraph tokens owned by the source package.
76
+ */
77
+ declare const cloneTableCellsWithParagraphPropertyCaptures: (payload: DecodedTableCellParagraphSourcePayload) => document_d_exports.TableCell[];
23
78
  declare const linkProseParagraphPropertySource: (proseParagraph: Node, sourceParagraph: document_d_exports.Paragraph) => void;
79
+ type CreateProseParagraphOptions = {
80
+ attrs?: Node["attrs"];
81
+ content?: Fragment | Node | readonly Node[] | null;
82
+ marks?: readonly Mark[];
83
+ };
84
+ /** Create a parsed paragraph with both its same-process owner and durable body token. */
85
+ declare const createProseParagraphWithPropertySource: (nodeType: NodeType | undefined, sourceParagraph: document_d_exports.Paragraph, options?: CreateProseParagraphOptions) => Node;
86
+ type ParagraphPropertySourceTransfer = {
87
+ displacedToken: string | null;
88
+ selectedToken: string | null;
89
+ };
90
+ type JoinProseParagraphsWithRightPropertySourceOptions = {
91
+ attrs: Node["attrs"];
92
+ pos: number;
93
+ transaction: Transaction;
94
+ };
95
+ /** Join adjacent paragraphs when revision semantics deliberately select the right owner. */
96
+ declare const joinProseParagraphsWithRightPropertySource: ({ attrs, pos, transaction }: JoinProseParagraphsWithRightPropertySourceOptions) => Transaction;
97
+ declare const getExplicitParagraphPropertySourceTransfers: (transaction: Transaction) => readonly ParagraphPropertySourceTransfer[];
24
98
  type RecreateProseNodeOptions = {
25
99
  attrs?: Node["attrs"];
26
100
  content?: Fragment | Node | readonly Node[] | null;
@@ -28,6 +102,12 @@ type RecreateProseNodeOptions = {
28
102
  };
29
103
  /** Rebuild a PM node and retain paragraph provenance when the node is one. */
30
104
  declare const recreateProseNodeWithParagraphPropertySource: (source: Node, options?: RecreateProseNodeOptions) => Node;
105
+ /**
106
+ * Rebuild a PM node that is crossing from another package: retain its
107
+ * same-process paragraph-property capture, but detach the durable token that
108
+ * can only name a paragraph in the package it came from.
109
+ */
110
+ declare const recreateProseNodeWithDetachedParagraphPropertySource: (source: Node, options?: RecreateProseNodeOptions) => Node;
31
111
  type SetProseParagraphMarkupOptions = {
32
112
  attrs: Node["attrs"];
33
113
  ownership: "preserve" | "transfer-allocated-id";
@@ -46,4 +126,4 @@ declare const linkParagraphPropertySourceCandidate: (target: document_d_exports.
46
126
  declare const getParagraphPropertySourceCandidate: (paragraph: document_d_exports.Paragraph) => document_d_exports.Paragraph | undefined;
47
127
  declare const getParagraphPropertySourceTransferId: (paragraph: document_d_exports.Paragraph) => string | undefined;
48
128
  //#endregion
49
- export { assignParagraphPropertySource, cloneDocumentWithParagraphPropertySources, cloneParagraphWithPropertySource, cloneParagraphWithoutPropertySource, copyParagraphPropertySource, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceTransferId, linkParagraphPropertySourceCandidate, linkProseParagraphPropertySource, recreateProseNodeWithParagraphPropertySource, setProseParagraphMarkupWithPropertySource, transferProseParagraphPropertySource };
129
+ export { DecodedTableCellParagraphSourcePayload, PARAGRAPH_PROPERTY_SOURCE_VALIDATION_CODES, PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR, ParagraphPropertySourceValidationCode, ParagraphPropertySourceValidationError, TABLE_CELL_PARAGRAPH_SOURCE_BINDING_ATTR, TABLE_CELL_PARAGRAPH_SOURCE_PAYLOAD_ERROR_CLASSIFICATIONS, TableCellParagraphPropertySourceBinding, TableCellParagraphSourcePayloadErrorClassification, assignDocumentParagraphPropertySourceContract, assignParagraphPropertySource, cloneDocumentWithParagraphPropertySources, cloneParagraphWithPropertySource, cloneParagraphWithoutPropertySource, cloneTableCellsWithParagraphPropertyCaptures, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, createProseParagraphWithPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getExplicitParagraphPropertySourceTransfers, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, isParagraphPropertySourceToken, joinProseParagraphsWithRightPropertySource, linkParagraphPropertySourceCandidate, linkProseParagraphPropertySource, paragraphPropertySourceBelongsToDocument, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithDetachedParagraphPropertySource, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, setProseParagraphMarkupWithPropertySource, transferProseParagraphPropertySource, transportTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings };