@stll/folio-core 0.7.0 → 0.9.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 (193) hide show
  1. package/README.md +39 -0
  2. package/dist/ai-edits/apply.js +18 -4
  3. package/dist/ai-edits/blockRange.d.ts +13 -2
  4. package/dist/ai-edits/blockRange.js +23 -2
  5. package/dist/ai-edits/headless.d.ts +31 -4
  6. package/dist/ai-edits/headless.js +148 -35
  7. package/dist/ai-edits/index.d.ts +6 -4
  8. package/dist/ai-edits/index.js +4 -1
  9. package/dist/ai-edits/scoped-reading.d.ts +9 -0
  10. package/dist/ai-edits/scoped-reading.js +60 -0
  11. package/dist/ai-edits/snapshot.js +53 -7
  12. package/dist/ai-edits/types.d.ts +46 -3
  13. package/dist/compat/eigenpal.d.ts +8 -3
  14. package/dist/compat/eigenpal.js +7 -2
  15. package/dist/controller/fontReadiness.d.ts +29 -0
  16. package/dist/controller/fontReadiness.js +139 -0
  17. package/dist/controller/latestRequestGate.d.ts +13 -0
  18. package/dist/controller/latestRequestGate.js +16 -0
  19. package/dist/controller/layoutPipeline.js +88 -10
  20. package/dist/document-operations.d.ts +10 -3
  21. package/dist/document-operations.js +29 -14
  22. package/dist/docx/blockContentParser.js +53 -10
  23. package/dist/docx/commentParser.js +1 -1
  24. package/dist/docx/compatibility.d.ts +30 -2
  25. package/dist/docx/compatibility.js +118 -39
  26. package/dist/docx/conformance.d.ts +6 -0
  27. package/dist/docx/conformance.js +18 -0
  28. package/dist/docx/encryption/agileDecryption.js +1 -1
  29. package/dist/docx/encryption/encryptionInfo.js +1 -1
  30. package/dist/docx/encryption/openEncryptedDocx.js +1 -1
  31. package/dist/docx/ensureParaIds.d.ts +29 -0
  32. package/dist/docx/ensureParaIds.js +423 -0
  33. package/dist/docx/fontTableParser.d.ts +6 -0
  34. package/dist/docx/fontTableParser.js +72 -0
  35. package/dist/docx/groupDrawingParser.js +7 -2
  36. package/dist/docx/headerFooterParser.js +1 -1
  37. package/dist/docx/normalizeBaseDirection.js +1 -1
  38. package/dist/docx/numberingParser.js +2 -0
  39. package/dist/docx/paragraphParser.js +21 -1
  40. package/dist/docx/paragraphTextBoxEnrichment.js +141 -2
  41. package/dist/docx/parser.d.ts +1 -1
  42. package/dist/docx/parser.js +14 -9
  43. package/dist/docx/rezip.js +70 -5
  44. package/dist/docx/runConsolidator.js +4 -0
  45. package/dist/docx/runParser.js +19 -1
  46. package/dist/docx/selectiveSave.js +3 -3
  47. package/dist/docx/selectiveXmlPatch.d.ts +10 -1
  48. package/dist/docx/selectiveXmlPatch.js +1 -1
  49. package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
  50. package/dist/docx/serializer/fontTableSerializer.js +26 -0
  51. package/dist/docx/serializer/headerFooterSerializer.js +1 -1
  52. package/dist/docx/serializer/paragraphSerializer.js +8 -0
  53. package/dist/docx/serializer/runSerializer.js +14 -2
  54. package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
  55. package/dist/docx/serializer/settingsSerializer.js +16 -0
  56. package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
  57. package/dist/docx/serializer/stylesSerializer.js +56 -0
  58. package/dist/docx/serializer/tableSerializer.js +29 -26
  59. package/dist/docx/serializer/themeSerializer.d.ts +6 -0
  60. package/dist/docx/serializer/themeSerializer.js +36 -0
  61. package/dist/docx/settingsParser.js +46 -0
  62. package/dist/docx/styleParser.js +26 -1
  63. package/dist/docx/tableParser.js +19 -1
  64. package/dist/docx/textBoxParser.js +6 -1
  65. package/dist/docx/vmlImageParser.js +146 -1
  66. package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
  67. package/dist/i18n/messages/catalogs.gen.js +5910 -5910
  68. package/dist/index.d.ts +8 -3
  69. package/dist/index.js +7 -2
  70. package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
  71. package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
  72. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
  73. package/dist/layout-bridge/convert/headerFooterLayout.js +22 -3
  74. package/dist/layout-bridge/convert/paragraphFrames.d.ts +7 -0
  75. package/dist/layout-bridge/convert/paragraphFrames.js +136 -0
  76. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
  77. package/dist/layout-bridge/convert/toFlowBlocks.js +93 -17
  78. package/dist/layout-bridge/engine/hitTest.js +2 -1
  79. package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
  80. package/dist/layout-bridge/engine/measuring/index.js +2 -1
  81. package/dist/layout-bridge/engine/selectionRects.js +2 -1
  82. package/dist/layout-engine/headerFooterRefs.d.ts +7 -0
  83. package/dist/layout-engine/headerFooterRefs.js +40 -0
  84. package/dist/layout-engine/index.d.ts +3 -2
  85. package/dist/layout-engine/index.js +68 -106
  86. package/dist/layout-engine/measure/cache.js +11 -3
  87. package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
  88. package/dist/layout-engine/measure/index.d.ts +2 -1
  89. package/dist/layout-engine/measure/index.js +2 -1
  90. package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
  91. package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
  92. package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
  93. package/dist/layout-engine/measure/lineBreaks.js +11 -18
  94. package/dist/layout-engine/measure/listMarkerWidth.d.ts +4 -1
  95. package/dist/layout-engine/measure/listMarkerWidth.js +33 -8
  96. package/dist/layout-engine/measure/measureBlocks.d.ts +4 -2
  97. package/dist/layout-engine/measure/measureBlocks.js +138 -86
  98. package/dist/layout-engine/measure/measureContainer.js +32 -9
  99. package/dist/layout-engine/measure/measureHelpers.js +5 -2
  100. package/dist/layout-engine/measure/measureParagraph.js +346 -74
  101. package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
  102. package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
  103. package/dist/layout-engine/measure/measureWorker.js +8 -19
  104. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
  105. package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
  106. package/dist/layout-engine/measure/tableCellFloating.js +37 -29
  107. package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
  108. package/dist/layout-engine/measure/tableCellFlow.js +73 -0
  109. package/dist/layout-engine/measure/tableCellGrid.d.ts +15 -0
  110. package/dist/layout-engine/measure/tableCellGrid.js +62 -0
  111. package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +18 -0
  112. package/dist/layout-engine/measure/textBoxParagraphLayout.js +32 -0
  113. package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
  114. package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
  115. package/dist/layout-engine/paginator.d.ts +2 -1
  116. package/dist/layout-engine/paginator.js +7 -6
  117. package/dist/layout-engine/paragraphFrame.d.ts +22 -0
  118. package/dist/layout-engine/paragraphFrame.js +17 -0
  119. package/dist/layout-engine/paragraphSequence.d.ts +7 -0
  120. package/dist/layout-engine/paragraphSequence.js +25 -0
  121. package/dist/layout-engine/paragraphSpacing.d.ts +17 -0
  122. package/dist/layout-engine/paragraphSpacing.js +30 -0
  123. package/dist/layout-engine/renderedBreakReconciliation.d.ts +63 -0
  124. package/dist/layout-engine/renderedBreakReconciliation.js +86 -0
  125. package/dist/layout-engine/tableRowBreak.d.ts +5 -2
  126. package/dist/layout-engine/tableRowBreak.js +62 -29
  127. package/dist/layout-engine/types.d.ts +54 -12
  128. package/dist/layout-engine/types.js +15 -2
  129. package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
  130. package/dist/layout-painter/anchoredImagePosition.js +95 -0
  131. package/dist/layout-painter/borderStroke.d.ts +23 -0
  132. package/dist/layout-painter/borderStroke.js +39 -0
  133. package/dist/layout-painter/renderImage.d.ts +5 -4
  134. package/dist/layout-painter/renderImage.js +18 -4
  135. package/dist/layout-painter/renderPage.d.ts +2 -27
  136. package/dist/layout-painter/renderPage.js +15 -101
  137. package/dist/layout-painter/renderParagraph.js +45 -26
  138. package/dist/layout-painter/renderTable.d.ts +2 -0
  139. package/dist/layout-painter/renderTable.js +257 -47
  140. package/dist/layout-painter/renderTextBox.js +17 -7
  141. package/dist/managers/DocumentLoaderManager.d.ts +1 -1
  142. package/dist/managers/DocumentLoaderManager.js +2 -2
  143. package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
  144. package/dist/paged-layout/sectionBlockWidths.js +9 -0
  145. package/dist/paged-layout/sectionGeometry.js +1 -1
  146. package/dist/prosemirror/attrs/index.d.ts +4 -2
  147. package/dist/prosemirror/attrs/index.js +32 -2
  148. package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
  149. package/dist/prosemirror/conversion/fromProseDoc.js +35 -18
  150. package/dist/prosemirror/conversion/toProseDoc.js +73 -37
  151. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  152. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -2
  153. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  154. package/dist/prosemirror/extensions/features/ListExtension.js +2 -0
  155. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +68 -16
  156. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
  157. package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
  158. package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
  159. package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
  160. package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
  161. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  162. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
  163. package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
  164. package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
  165. package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
  166. package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +2 -1
  167. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +7 -0
  168. package/dist/prosemirror/schema/index.d.ts +2 -2
  169. package/dist/prosemirror/schema/marks.d.ts +6 -1
  170. package/dist/prosemirror/schema/nodes.d.ts +16 -12
  171. package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -0
  172. package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
  173. package/dist/prosemirror/utils/tabCalculator.js +12 -10
  174. package/dist/prosemirror/validation.js +4 -1
  175. package/dist/redline.js +13 -3
  176. package/dist/server.d.ts +9 -4
  177. package/dist/server.js +7 -2
  178. package/dist/style-sets/extract.d.ts +35 -0
  179. package/dist/style-sets/extract.js +123 -0
  180. package/dist/style-sets/stellaStyle.d.ts +13 -0
  181. package/dist/style-sets/stellaStyle.js +516 -0
  182. package/dist/style-sets/types.d.ts +31 -0
  183. package/dist/style-sets/types.js +5 -0
  184. package/dist/types/index.d.ts +2 -1
  185. package/dist/utils/createDocument.d.ts +12 -2
  186. package/dist/utils/createDocument.js +55 -36
  187. package/dist/utils/fontResolver.js +6 -6
  188. package/dist/utils/formatToStyle.js +1 -1
  189. package/dist/utils/hexId.d.ts +8 -1
  190. package/dist/utils/hexId.js +11 -3
  191. package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
  192. package/dist/utils/paragraphFormattingMerge.js +14 -4
  193. package/package.json +5 -1
@@ -0,0 +1,35 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { DocumentStyleSet } from "./types.js";
3
+ import { DocxInput } from "../utils/docxInput.js";
4
+
5
+ //#region src/style-sets/extract.d.ts
6
+ type ExtractDocumentStyleSetOptions = {
7
+ name: string; /** Style IDs selected by the user. Omit to extract every style. */
8
+ styleIds?: readonly string[]; /** Defaults to the source document's default paragraph style. */
9
+ initialParagraphStyleId?: string;
10
+ };
11
+ type DocumentStyleCatalogEntry = {
12
+ styleId: string;
13
+ name: string;
14
+ type: document_d_exports.Style["type"];
15
+ role: "default" | "quick" | "available" | "supporting";
16
+ dependencies: string[];
17
+ numberingId?: number;
18
+ };
19
+ type DocumentStyleCatalog = {
20
+ defaultParagraphStyleId?: string;
21
+ styles: DocumentStyleCatalogEntry[];
22
+ };
23
+ declare const inspectDocumentStyles: (document: document_d_exports.Document) => DocumentStyleCatalog;
24
+ declare const inspectDocumentStylesFromDocx: (input: DocxInput) => Promise<DocumentStyleCatalog>;
25
+ /**
26
+ * Extract a sanitized style set from a parsed document.
27
+ *
28
+ * Selected styles expand to a dependency closure over basedOn, next, and link
29
+ * references. Only numbering definitions referenced by the resulting styles
30
+ * are retained. No source content or package relationship can enter the result.
31
+ */
32
+ declare const extractDocumentStyleSet: (document: document_d_exports.Document, options: ExtractDocumentStyleSetOptions) => DocumentStyleSet;
33
+ declare const extractDocumentStyleSetFromDocx: (input: DocxInput, options: ExtractDocumentStyleSetOptions) => Promise<DocumentStyleSet>;
34
+ //#endregion
35
+ export { DocumentStyleCatalog, DocumentStyleCatalogEntry, ExtractDocumentStyleSetOptions, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx };
@@ -0,0 +1,123 @@
1
+ import "./types.js";
2
+ import { parseDocx } from "../docx/parser.js";
3
+ import { panic } from "better-result";
4
+ //#region src/style-sets/extract.ts
5
+ const inspectDocumentStyles = (document) => {
6
+ const styles = document.package.styles?.styles ?? [];
7
+ const defaultParagraphStyleId = styles.find((style) => style.type === "paragraph" && style.default)?.styleId;
8
+ return {
9
+ ...defaultParagraphStyleId ? { defaultParagraphStyleId } : {},
10
+ styles: styles.map(toCatalogEntry)
11
+ };
12
+ };
13
+ const inspectDocumentStylesFromDocx = async (input) => inspectDocumentStyles(await parseDocx(input, {
14
+ preloadFonts: false,
15
+ parseHeadersFooters: false,
16
+ parseNotes: false,
17
+ detectVariables: false
18
+ }));
19
+ /**
20
+ * Extract a sanitized style set from a parsed document.
21
+ *
22
+ * Selected styles expand to a dependency closure over basedOn, next, and link
23
+ * references. Only numbering definitions referenced by the resulting styles
24
+ * are retained. No source content or package relationship can enter the result.
25
+ */
26
+ const extractDocumentStyleSet = (document, options) => {
27
+ const definitions = document.package.styles;
28
+ if (!definitions || definitions.styles.length === 0) return panic("Cannot extract a style set from a document without styles");
29
+ const stylesById = new Map(definitions.styles.map((style) => [style.styleId, style]));
30
+ const selectedStyleIds = options.styleIds === void 0 ? new Set(stylesById.keys()) : collectStyleDependencyClosure(stylesById, options.styleIds);
31
+ const styles = definitions.styles.filter((style) => selectedStyleIds.has(style.styleId));
32
+ if (styles.length === 0) return panic("Cannot extract an empty style set");
33
+ const defaultParagraphStyle = styles.find((style) => style.type === "paragraph" && style.default);
34
+ const initialParagraphStyleId = options.initialParagraphStyleId ?? defaultParagraphStyle?.styleId ?? "Normal";
35
+ if (!styles.find((style) => style.styleId === initialParagraphStyleId && style.type === "paragraph")) return panic(`Initial paragraph style "${initialParagraphStyleId}" is not present in the extracted set`);
36
+ const numbering = extractReferencedNumbering(styles, document);
37
+ const fontTable = sanitizeFontTable(document.package.fontTable);
38
+ return structuredClone({
39
+ version: 1,
40
+ name: options.name,
41
+ initialParagraphStyleId,
42
+ styles: {
43
+ ...definitions.docDefaults ? { docDefaults: definitions.docDefaults } : {},
44
+ ...definitions.latentStyles ? { latentStyles: definitions.latentStyles } : {},
45
+ styles
46
+ },
47
+ ...numbering ? { numbering } : {},
48
+ ...document.package.theme ? { theme: document.package.theme } : {},
49
+ ...fontTable ? { fontTable } : {},
50
+ ...document.package.settings ? { settings: document.package.settings } : {}
51
+ });
52
+ };
53
+ const extractDocumentStyleSetFromDocx = async (input, options) => {
54
+ const document = await parseDocx(input, {
55
+ preloadFonts: false,
56
+ parseHeadersFooters: false,
57
+ parseNotes: false,
58
+ detectVariables: false
59
+ });
60
+ return extractDocumentStyleSet(document, options);
61
+ };
62
+ const collectStyleDependencyClosure = (stylesById, requestedStyleIds) => {
63
+ const selected = /* @__PURE__ */ new Set();
64
+ const pending = [...requestedStyleIds];
65
+ while (pending.length > 0) {
66
+ const styleId = pending.pop();
67
+ if (styleId === void 0 || selected.has(styleId)) continue;
68
+ const style = stylesById.get(styleId);
69
+ if (!style) return panic(`Cannot extract unknown style "${styleId}"`);
70
+ selected.add(styleId);
71
+ for (const dependency of [
72
+ style.basedOn,
73
+ style.next,
74
+ style.link
75
+ ]) if (dependency !== void 0 && !selected.has(dependency)) pending.push(dependency);
76
+ }
77
+ return selected;
78
+ };
79
+ const extractReferencedNumbering = (styles, document) => {
80
+ const source = document.package.numbering;
81
+ if (!source) return;
82
+ const referencedNumIds = /* @__PURE__ */ new Set();
83
+ for (const style of styles) {
84
+ const numId = style.pPr?.numPr?.numId;
85
+ if (numId !== void 0) referencedNumIds.add(numId);
86
+ }
87
+ if (referencedNumIds.size === 0) return;
88
+ const nums = source.nums.filter((numbering) => referencedNumIds.has(numbering.numId));
89
+ const referencedAbstractNumIds = new Set(nums.map((numbering) => numbering.abstractNumId));
90
+ return {
91
+ abstractNums: source.abstractNums.filter((numbering) => referencedAbstractNumIds.has(numbering.abstractNumId)),
92
+ nums
93
+ };
94
+ };
95
+ const sanitizeFontTable = (fontTable) => {
96
+ if (!fontTable) return;
97
+ return { fonts: fontTable.fonts.map(stripEmbeddedFontRelationships) };
98
+ };
99
+ const stripEmbeddedFontRelationships = ({ embedRegular: _embedRegular, embedBold: _embedBold, embedItalic: _embedItalic, embedBoldItalic: _embedBoldItalic, ...font }) => font;
100
+ const toCatalogEntry = (style) => {
101
+ const entry = {
102
+ styleId: style.styleId,
103
+ name: style.name ?? style.styleId,
104
+ type: style.type,
105
+ role: styleRole(style),
106
+ dependencies: [...new Set([
107
+ style.basedOn,
108
+ style.next,
109
+ style.link
110
+ ].filter((dependency) => dependency !== void 0))]
111
+ };
112
+ const numberingId = style.pPr?.numPr?.numId;
113
+ if (numberingId !== void 0) entry.numberingId = numberingId;
114
+ return entry;
115
+ };
116
+ const styleRole = (style) => {
117
+ if (style.default) return "default";
118
+ if (style.qFormat) return "quick";
119
+ if (!style.hidden && !style.semiHidden) return "available";
120
+ return "supporting";
121
+ };
122
+ //#endregion
123
+ export { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx };
@@ -0,0 +1,13 @@
1
+ import { DocumentPreset, DocumentStyleSet } from "./types.js";
2
+
3
+ //#region src/style-sets/stellaStyle.d.ts
4
+ declare const STELLA_STYLE_SET_NAME = "Stella Style";
5
+ /**
6
+ * A conservative legal drafting system inspired by common continental and
7
+ * common-law contract structure. It uses explicit fonts and neutral punctuation
8
+ * so the package does not depend on a locale-specific Office theme.
9
+ */
10
+ declare const createStellaStyleSet: () => DocumentStyleSet;
11
+ declare const createStellaStyleDocumentPreset: () => DocumentPreset;
12
+ //#endregion
13
+ export { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet };
@@ -0,0 +1,516 @@
1
+ import "./types.js";
2
+ //#region src/style-sets/stellaStyle.ts
3
+ const CLAUSE_NUMBERING_ID = 1;
4
+ const DEFINITIONS_NUMBERING_ID = 2;
5
+ const RECITALS_NUMBERING_ID = 3;
6
+ const PARTIES_NUMBERING_ID = 4;
7
+ const BULLET_NUMBERING_ID = 5;
8
+ const CLAUSE_ABSTRACT_NUMBERING_ID = 1;
9
+ const DEFINITIONS_ABSTRACT_NUMBERING_ID = 2;
10
+ const PARENTHETICAL_ABSTRACT_NUMBERING_ID = 3;
11
+ const BULLET_ABSTRACT_NUMBERING_ID = 4;
12
+ const STELLA_STYLE_SET_NAME = "Stella Style";
13
+ /**
14
+ * A conservative legal drafting system inspired by common continental and
15
+ * common-law contract structure. It uses explicit fonts and neutral punctuation
16
+ * so the package does not depend on a locale-specific Office theme.
17
+ */
18
+ const createStellaStyleSet = () => ({
19
+ version: 1,
20
+ name: STELLA_STYLE_SET_NAME,
21
+ initialParagraphStyleId: "BodyText",
22
+ settings: { defaultTabStop: 720 },
23
+ fontTable: { fonts: [{
24
+ name: "Arial",
25
+ family: "swiss",
26
+ pitch: "variable"
27
+ }, {
28
+ name: "Georgia",
29
+ family: "roman",
30
+ pitch: "variable"
31
+ }] },
32
+ styles: {
33
+ docDefaults: { rPr: {
34
+ fontFamily: {
35
+ ascii: "Arial",
36
+ hAnsi: "Arial",
37
+ cs: "Arial"
38
+ },
39
+ fontSize: 20,
40
+ fontSizeCs: 20
41
+ } },
42
+ styles: [
43
+ {
44
+ styleId: "Normal",
45
+ type: "paragraph",
46
+ name: "Normal",
47
+ default: true,
48
+ qFormat: true,
49
+ uiPriority: 0,
50
+ pPr: {
51
+ alignment: "both",
52
+ spaceAfter: 240
53
+ },
54
+ rPr: {
55
+ fontFamily: {
56
+ ascii: "Arial",
57
+ hAnsi: "Arial",
58
+ cs: "Arial"
59
+ },
60
+ fontSize: 20,
61
+ fontSizeCs: 20
62
+ }
63
+ },
64
+ {
65
+ styleId: "DefaultParagraphFont",
66
+ type: "character",
67
+ name: "Default Paragraph Font",
68
+ default: true,
69
+ semiHidden: true,
70
+ unhideWhenUsed: true
71
+ },
72
+ {
73
+ styleId: "BodyText",
74
+ type: "paragraph",
75
+ name: "Body Text",
76
+ basedOn: "Normal",
77
+ qFormat: true,
78
+ uiPriority: 1
79
+ },
80
+ {
81
+ styleId: "Title",
82
+ type: "paragraph",
83
+ name: "Title",
84
+ basedOn: "BodyText",
85
+ next: "BodyText",
86
+ qFormat: true,
87
+ uiPriority: 2,
88
+ pPr: {
89
+ alignment: "center",
90
+ keepNext: true,
91
+ spaceAfter: 360
92
+ },
93
+ rPr: {
94
+ bold: true,
95
+ fontSize: 32,
96
+ fontSizeCs: 32
97
+ }
98
+ },
99
+ {
100
+ styleId: "TitleWithSubtitle",
101
+ type: "paragraph",
102
+ name: "Title with Subtitle",
103
+ basedOn: "Title",
104
+ next: "Subtitle",
105
+ qFormat: true,
106
+ uiPriority: 3,
107
+ pPr: { spaceAfter: 0 }
108
+ },
109
+ {
110
+ styleId: "Subtitle",
111
+ type: "paragraph",
112
+ name: "Subtitle",
113
+ basedOn: "Title",
114
+ next: "BodyText",
115
+ qFormat: true,
116
+ uiPriority: 4,
117
+ rPr: {
118
+ fontFamily: {
119
+ ascii: "Georgia",
120
+ hAnsi: "Georgia"
121
+ },
122
+ italic: true,
123
+ color: { rgb: "7F7F7F" }
124
+ }
125
+ },
126
+ {
127
+ styleId: "RecitalsHeading",
128
+ type: "paragraph",
129
+ name: "Recitals Heading",
130
+ basedOn: "BodyText",
131
+ next: "Recital",
132
+ qFormat: true,
133
+ uiPriority: 5,
134
+ pPr: { keepNext: true },
135
+ rPr: { bold: true }
136
+ },
137
+ {
138
+ styleId: "Recital",
139
+ type: "paragraph",
140
+ name: "Recital",
141
+ basedOn: "BodyText",
142
+ qFormat: true,
143
+ uiPriority: 6,
144
+ pPr: { numPr: {
145
+ numId: RECITALS_NUMBERING_ID,
146
+ ilvl: 0
147
+ } }
148
+ },
149
+ {
150
+ styleId: "AgreedTerms",
151
+ type: "paragraph",
152
+ name: "Agreed Terms",
153
+ basedOn: "BodyText",
154
+ next: "ClauseHeading1",
155
+ qFormat: true,
156
+ uiPriority: 7,
157
+ pPr: {
158
+ keepNext: true,
159
+ spaceBefore: 240
160
+ },
161
+ rPr: { bold: true }
162
+ },
163
+ ...createClauseStyles(),
164
+ ...createDefinitionStyles(),
165
+ {
166
+ styleId: "Party",
167
+ type: "paragraph",
168
+ name: "Party",
169
+ basedOn: "BodyText",
170
+ qFormat: true,
171
+ uiPriority: 30,
172
+ pPr: { numPr: {
173
+ numId: PARTIES_NUMBERING_ID,
174
+ ilvl: 0
175
+ } }
176
+ },
177
+ {
178
+ styleId: "ListParagraph",
179
+ type: "paragraph",
180
+ name: "List Paragraph",
181
+ basedOn: "BodyText",
182
+ qFormat: true,
183
+ uiPriority: 31,
184
+ pPr: { numPr: {
185
+ numId: BULLET_NUMBERING_ID,
186
+ ilvl: 0
187
+ } }
188
+ },
189
+ {
190
+ styleId: "TableText",
191
+ type: "paragraph",
192
+ name: "Table Text",
193
+ basedOn: "Normal",
194
+ qFormat: true,
195
+ uiPriority: 32,
196
+ pPr: { spaceAfter: 0 }
197
+ },
198
+ {
199
+ styleId: "ScheduleHeading",
200
+ type: "paragraph",
201
+ name: "Schedule Heading",
202
+ basedOn: "Title",
203
+ next: "BodyText",
204
+ qFormat: true,
205
+ uiPriority: 33,
206
+ pPr: {
207
+ pageBreakBefore: true,
208
+ keepNext: true,
209
+ spaceAfter: 240
210
+ }
211
+ },
212
+ {
213
+ styleId: "FootnoteText",
214
+ type: "paragraph",
215
+ name: "Footnote Text",
216
+ basedOn: "Normal",
217
+ link: "FootnoteTextChar",
218
+ semiHidden: true,
219
+ unhideWhenUsed: true,
220
+ uiPriority: 99,
221
+ pPr: { spaceAfter: 0 },
222
+ rPr: {
223
+ fontSize: 18,
224
+ fontSizeCs: 18
225
+ }
226
+ },
227
+ {
228
+ styleId: "FootnoteTextChar",
229
+ type: "character",
230
+ name: "Footnote Text Char",
231
+ basedOn: "DefaultParagraphFont",
232
+ link: "FootnoteText",
233
+ semiHidden: true,
234
+ unhideWhenUsed: true,
235
+ uiPriority: 99,
236
+ rPr: {
237
+ fontSize: 18,
238
+ fontSizeCs: 18
239
+ }
240
+ },
241
+ {
242
+ styleId: "FootnoteReference",
243
+ type: "character",
244
+ name: "Footnote Reference",
245
+ basedOn: "DefaultParagraphFont",
246
+ semiHidden: true,
247
+ unhideWhenUsed: true,
248
+ uiPriority: 99,
249
+ rPr: { vertAlign: "superscript" }
250
+ },
251
+ {
252
+ styleId: "Footer",
253
+ type: "paragraph",
254
+ name: "Footer",
255
+ basedOn: "Normal",
256
+ pPr: {
257
+ alignment: "right",
258
+ spaceAfter: 0
259
+ },
260
+ rPr: {
261
+ color: { rgb: "7F7F7F" },
262
+ fontSize: 18,
263
+ fontSizeCs: 18
264
+ }
265
+ },
266
+ {
267
+ styleId: "Hyperlink",
268
+ type: "character",
269
+ name: "Hyperlink",
270
+ basedOn: "DefaultParagraphFont",
271
+ unhideWhenUsed: true,
272
+ uiPriority: 99,
273
+ rPr: {
274
+ color: { rgb: "0563C1" },
275
+ underline: { style: "single" }
276
+ }
277
+ },
278
+ {
279
+ styleId: "TableNormal",
280
+ type: "table",
281
+ name: "Normal Table",
282
+ default: true,
283
+ semiHidden: true,
284
+ unhideWhenUsed: true,
285
+ uiPriority: 99
286
+ },
287
+ {
288
+ styleId: "TableGrid",
289
+ type: "table",
290
+ name: "Table Grid",
291
+ basedOn: "TableNormal",
292
+ qFormat: true,
293
+ uiPriority: 59,
294
+ tblPr: { borders: {
295
+ top: {
296
+ style: "single",
297
+ size: 4,
298
+ color: { rgb: "BFBFBF" }
299
+ },
300
+ left: {
301
+ style: "single",
302
+ size: 4,
303
+ color: { rgb: "BFBFBF" }
304
+ },
305
+ bottom: {
306
+ style: "single",
307
+ size: 4,
308
+ color: { rgb: "BFBFBF" }
309
+ },
310
+ right: {
311
+ style: "single",
312
+ size: 4,
313
+ color: { rgb: "BFBFBF" }
314
+ },
315
+ insideH: {
316
+ style: "single",
317
+ size: 4,
318
+ color: { rgb: "BFBFBF" }
319
+ },
320
+ insideV: {
321
+ style: "single",
322
+ size: 4,
323
+ color: { rgb: "BFBFBF" }
324
+ }
325
+ } }
326
+ }
327
+ ]
328
+ },
329
+ numbering: createLegalNumbering()
330
+ });
331
+ const createStellaStyleDocumentPreset = () => ({
332
+ version: 1,
333
+ name: STELLA_STYLE_SET_NAME,
334
+ styleSet: createStellaStyleSet(),
335
+ sectionProperties: {
336
+ pageWidth: 11906,
337
+ pageHeight: 16838,
338
+ orientation: "portrait",
339
+ marginTop: 1440,
340
+ marginBottom: 1440,
341
+ marginLeft: 1440,
342
+ marginRight: 1440,
343
+ headerDistance: 708,
344
+ footerDistance: 708,
345
+ gutter: 0,
346
+ columnCount: 1,
347
+ columnSpace: 708,
348
+ equalWidth: true,
349
+ sectionStart: "nextPage",
350
+ verticalAlign: "top"
351
+ }
352
+ });
353
+ const createClauseStyles = () => {
354
+ return [
355
+ {
356
+ styleId: "ClauseHeading1",
357
+ name: "Clause Heading",
358
+ level: 0,
359
+ bold: true,
360
+ next: "ClauseParagraph1"
361
+ },
362
+ {
363
+ styleId: "ClauseParagraph1",
364
+ name: "Clause 1.1",
365
+ level: 1,
366
+ bold: false,
367
+ next: "ClauseParagraph1"
368
+ },
369
+ {
370
+ styleId: "ClauseParagraph2",
371
+ name: "Clause (a)",
372
+ level: 2,
373
+ bold: false,
374
+ next: "ClauseParagraph2"
375
+ },
376
+ {
377
+ styleId: "ClauseParagraph3",
378
+ name: "Clause (i)",
379
+ level: 3,
380
+ bold: false,
381
+ next: "ClauseParagraph3"
382
+ },
383
+ {
384
+ styleId: "ClauseParagraph4",
385
+ name: "Clause (A)",
386
+ level: 4,
387
+ bold: false,
388
+ next: "ClauseParagraph4"
389
+ }
390
+ ].map(({ styleId, name, level, bold, next }) => {
391
+ const style = {
392
+ styleId,
393
+ type: "paragraph",
394
+ name,
395
+ basedOn: "BodyText",
396
+ next,
397
+ qFormat: true,
398
+ uiPriority: 10 + level,
399
+ pPr: {
400
+ numPr: {
401
+ numId: CLAUSE_NUMBERING_ID,
402
+ ilvl: level
403
+ },
404
+ keepNext: level < 2,
405
+ spaceBefore: clauseSpaceBefore(level)
406
+ }
407
+ };
408
+ if (bold) return Object.assign(style, { rPr: { bold: true } });
409
+ return style;
410
+ });
411
+ };
412
+ const clauseSpaceBefore = (level) => {
413
+ if (level === 0) return 360;
414
+ return 0;
415
+ };
416
+ const createDefinitionStyles = () => {
417
+ return [
418
+ {
419
+ styleId: "Definition1",
420
+ name: "Definition (a)",
421
+ level: 0
422
+ },
423
+ {
424
+ styleId: "Definition2",
425
+ name: "Definition (i)",
426
+ level: 1
427
+ },
428
+ {
429
+ styleId: "Definition3",
430
+ name: "Definition (A)",
431
+ level: 2
432
+ }
433
+ ].map(({ styleId, name, level }) => ({
434
+ styleId,
435
+ type: "paragraph",
436
+ name,
437
+ basedOn: "BodyText",
438
+ qFormat: true,
439
+ uiPriority: 20 + level,
440
+ pPr: { numPr: {
441
+ numId: DEFINITIONS_NUMBERING_ID,
442
+ ilvl: level
443
+ } }
444
+ }));
445
+ };
446
+ const createLegalNumbering = () => ({
447
+ abstractNums: [
448
+ {
449
+ abstractNumId: CLAUSE_ABSTRACT_NUMBERING_ID,
450
+ multiLevelType: "multilevel",
451
+ levels: [
452
+ legalLevel(0, "decimal", "%1", 567, 567, true),
453
+ legalLevel(1, "decimal", "%1.%2", 567, 567, true),
454
+ legalLevel(2, "lowerLetter", "(%3)", 1134, 567),
455
+ legalLevel(3, "lowerRoman", "(%4)", 1701, 567),
456
+ legalLevel(4, "upperLetter", "(%5)", 2268, 567)
457
+ ]
458
+ },
459
+ {
460
+ abstractNumId: DEFINITIONS_ABSTRACT_NUMBERING_ID,
461
+ multiLevelType: "multilevel",
462
+ levels: [
463
+ legalLevel(0, "lowerLetter", "(%1)", 720, 360),
464
+ legalLevel(1, "lowerRoman", "(%2)", 1440, 360),
465
+ legalLevel(2, "upperLetter", "(%3)", 2160, 360)
466
+ ]
467
+ },
468
+ {
469
+ abstractNumId: PARENTHETICAL_ABSTRACT_NUMBERING_ID,
470
+ multiLevelType: "singleLevel",
471
+ levels: [legalLevel(0, "upperLetter", "(%1)", 720, 360)]
472
+ },
473
+ {
474
+ abstractNumId: BULLET_ABSTRACT_NUMBERING_ID,
475
+ multiLevelType: "singleLevel",
476
+ levels: [legalLevel(0, "bullet", "•", 720, 360)]
477
+ }
478
+ ],
479
+ nums: [
480
+ {
481
+ numId: CLAUSE_NUMBERING_ID,
482
+ abstractNumId: CLAUSE_ABSTRACT_NUMBERING_ID
483
+ },
484
+ {
485
+ numId: DEFINITIONS_NUMBERING_ID,
486
+ abstractNumId: DEFINITIONS_ABSTRACT_NUMBERING_ID
487
+ },
488
+ {
489
+ numId: RECITALS_NUMBERING_ID,
490
+ abstractNumId: PARENTHETICAL_ABSTRACT_NUMBERING_ID
491
+ },
492
+ {
493
+ numId: PARTIES_NUMBERING_ID,
494
+ abstractNumId: PARENTHETICAL_ABSTRACT_NUMBERING_ID
495
+ },
496
+ {
497
+ numId: BULLET_NUMBERING_ID,
498
+ abstractNumId: BULLET_ABSTRACT_NUMBERING_ID
499
+ }
500
+ ]
501
+ });
502
+ const legalLevel = (ilvl, numFmt, lvlText, indentLeft, hangingIndent, isLegal = false) => ({
503
+ ilvl,
504
+ start: 1,
505
+ numFmt,
506
+ lvlText,
507
+ suffix: "tab",
508
+ ...isLegal ? { isLgl: true } : {},
509
+ pPr: {
510
+ indentLeft,
511
+ indentFirstLine: hangingIndent,
512
+ hangingIndent: true
513
+ }
514
+ });
515
+ //#endregion
516
+ export { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet };