@stll/folio-core 0.8.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 (152) hide show
  1. package/README.md +39 -0
  2. package/dist/ai-edits/apply.js +18 -4
  3. package/dist/ai-edits/headless.d.ts +31 -4
  4. package/dist/ai-edits/headless.js +148 -35
  5. package/dist/ai-edits/index.d.ts +3 -3
  6. package/dist/ai-edits/index.js +2 -1
  7. package/dist/ai-edits/snapshot.js +40 -3
  8. package/dist/ai-edits/types.d.ts +2 -1
  9. package/dist/compat/eigenpal.d.ts +6 -4
  10. package/dist/compat/eigenpal.js +5 -3
  11. package/dist/controller/latestRequestGate.d.ts +13 -0
  12. package/dist/controller/latestRequestGate.js +16 -0
  13. package/dist/controller/layoutPipeline.js +12 -1
  14. package/dist/document-operations.d.ts +10 -3
  15. package/dist/document-operations.js +29 -14
  16. package/dist/docx/blockContentParser.js +2 -2
  17. package/dist/docx/commentParser.js +1 -1
  18. package/dist/docx/compatibility.d.ts +3 -7
  19. package/dist/docx/compatibility.js +0 -11
  20. package/dist/docx/encryption/agileDecryption.js +1 -1
  21. package/dist/docx/encryption/encryptionInfo.js +1 -1
  22. package/dist/docx/encryption/openEncryptedDocx.js +1 -1
  23. package/dist/docx/fontTableParser.d.ts +6 -0
  24. package/dist/docx/fontTableParser.js +72 -0
  25. package/dist/docx/groupDrawingParser.js +7 -2
  26. package/dist/docx/headerFooterParser.js +1 -1
  27. package/dist/docx/normalizeBaseDirection.js +1 -1
  28. package/dist/docx/numberingParser.js +1 -0
  29. package/dist/docx/paragraphParser.js +12 -1
  30. package/dist/docx/parser.d.ts +1 -1
  31. package/dist/docx/parser.js +12 -9
  32. package/dist/docx/rezip.js +70 -5
  33. package/dist/docx/runConsolidator.js +4 -0
  34. package/dist/docx/runParser.js +19 -1
  35. package/dist/docx/selectiveSave.js +3 -3
  36. package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
  37. package/dist/docx/serializer/fontTableSerializer.js +26 -0
  38. package/dist/docx/serializer/headerFooterSerializer.js +1 -1
  39. package/dist/docx/serializer/paragraphSerializer.js +4 -0
  40. package/dist/docx/serializer/runSerializer.js +7 -0
  41. package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
  42. package/dist/docx/serializer/settingsSerializer.js +16 -0
  43. package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
  44. package/dist/docx/serializer/stylesSerializer.js +56 -0
  45. package/dist/docx/serializer/tableSerializer.js +25 -26
  46. package/dist/docx/serializer/themeSerializer.d.ts +6 -0
  47. package/dist/docx/serializer/themeSerializer.js +36 -0
  48. package/dist/docx/settingsParser.js +46 -0
  49. package/dist/docx/styleParser.js +26 -1
  50. package/dist/docx/tableParser.js +11 -1
  51. package/dist/docx/vmlImageParser.js +1 -0
  52. package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
  53. package/dist/i18n/messages/catalogs.gen.js +5910 -5910
  54. package/dist/index.d.ts +6 -4
  55. package/dist/index.js +5 -3
  56. package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
  57. package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
  58. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
  59. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  60. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
  61. package/dist/layout-bridge/convert/toFlowBlocks.js +51 -14
  62. package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
  63. package/dist/layout-bridge/engine/measuring/index.js +2 -1
  64. package/dist/layout-engine/index.js +36 -28
  65. package/dist/layout-engine/measure/cache.js +11 -3
  66. package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
  67. package/dist/layout-engine/measure/index.d.ts +2 -1
  68. package/dist/layout-engine/measure/index.js +2 -1
  69. package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
  70. package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
  71. package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
  72. package/dist/layout-engine/measure/lineBreaks.js +11 -18
  73. package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
  74. package/dist/layout-engine/measure/listMarkerWidth.js +12 -6
  75. package/dist/layout-engine/measure/measureBlocks.d.ts +1 -2
  76. package/dist/layout-engine/measure/measureBlocks.js +6 -36
  77. package/dist/layout-engine/measure/measureContainer.js +32 -9
  78. package/dist/layout-engine/measure/measureHelpers.js +5 -2
  79. package/dist/layout-engine/measure/measureParagraph.js +335 -72
  80. package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
  81. package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
  82. package/dist/layout-engine/measure/measureWorker.js +8 -19
  83. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
  84. package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
  85. package/dist/layout-engine/measure/tableCellFloating.js +37 -29
  86. package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
  87. package/dist/layout-engine/measure/tableCellFlow.js +73 -0
  88. package/dist/layout-engine/measure/tableCellGrid.js +1 -1
  89. package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
  90. package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
  91. package/dist/layout-engine/renderedBreakReconciliation.d.ts +6 -1
  92. package/dist/layout-engine/renderedBreakReconciliation.js +34 -11
  93. package/dist/layout-engine/tableRowBreak.d.ts +5 -2
  94. package/dist/layout-engine/tableRowBreak.js +62 -29
  95. package/dist/layout-engine/types.d.ts +40 -7
  96. package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
  97. package/dist/layout-painter/anchoredImagePosition.js +95 -0
  98. package/dist/layout-painter/borderStroke.d.ts +23 -0
  99. package/dist/layout-painter/borderStroke.js +39 -0
  100. package/dist/layout-painter/renderImage.d.ts +5 -4
  101. package/dist/layout-painter/renderImage.js +18 -4
  102. package/dist/layout-painter/renderPage.d.ts +2 -27
  103. package/dist/layout-painter/renderPage.js +13 -99
  104. package/dist/layout-painter/renderParagraph.js +41 -23
  105. package/dist/layout-painter/renderTable.d.ts +2 -0
  106. package/dist/layout-painter/renderTable.js +223 -43
  107. package/dist/managers/DocumentLoaderManager.d.ts +1 -1
  108. package/dist/managers/DocumentLoaderManager.js +2 -2
  109. package/dist/prosemirror/attrs/index.d.ts +4 -2
  110. package/dist/prosemirror/attrs/index.js +21 -2
  111. package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
  112. package/dist/prosemirror/conversion/fromProseDoc.js +33 -18
  113. package/dist/prosemirror/conversion/toProseDoc.js +50 -18
  114. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  115. package/dist/prosemirror/extensions/core/ParagraphExtension.js +7 -2
  116. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
  117. package/dist/prosemirror/extensions/features/ListExtension.js +1 -0
  118. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
  119. package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
  120. package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
  121. package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
  122. package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
  123. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  124. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
  125. package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
  126. package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
  127. package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
  128. package/dist/prosemirror/schema/index.d.ts +2 -2
  129. package/dist/prosemirror/schema/marks.d.ts +6 -1
  130. package/dist/prosemirror/schema/nodes.d.ts +13 -11
  131. package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
  132. package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
  133. package/dist/prosemirror/utils/tabCalculator.js +12 -10
  134. package/dist/prosemirror/validation.js +4 -1
  135. package/dist/redline.js +13 -3
  136. package/dist/server.d.ts +6 -3
  137. package/dist/server.js +5 -2
  138. package/dist/style-sets/extract.d.ts +35 -0
  139. package/dist/style-sets/extract.js +123 -0
  140. package/dist/style-sets/stellaStyle.d.ts +13 -0
  141. package/dist/style-sets/stellaStyle.js +516 -0
  142. package/dist/style-sets/types.d.ts +31 -0
  143. package/dist/style-sets/types.js +5 -0
  144. package/dist/utils/createDocument.d.ts +12 -2
  145. package/dist/utils/createDocument.js +42 -31
  146. package/dist/utils/fontResolver.js +6 -6
  147. package/dist/utils/formatToStyle.js +1 -1
  148. package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
  149. package/dist/utils/paragraphFormattingMerge.js +14 -4
  150. package/package.json +5 -1
  151. package/dist/docx/capabilities.d.ts +0 -41
  152. package/dist/docx/capabilities.js +0 -322
@@ -59,9 +59,9 @@ const APTOS_MEASURED_LINE_HEIGHT = {
59
59
  * font's `FontLineHeight`, never hand-written. For "hhea" entries the raw
60
60
  * `hheaAscent`/`hheaDescent`/`hheaLineGap`/`unitsPerEm` fields below are read
61
61
  * directly from the real font files' `hhea` table; the ratio is whatever
62
- * falls out of the formula in `singleLineRatioOf`. "legacy" entries (e.g.
63
- * garamond, lucida sans, lucida console) are unverified hand-transcribed
64
- * ratios carried over unchanged, pending measurement.
62
+ * falls out of the formula in `singleLineRatioOf`. The remaining "legacy"
63
+ * entry (lucida sans) is an unverified hand-transcribed ratio carried over
64
+ * unchanged, pending measurement.
65
65
  */
66
66
  const FONT_MAPPINGS = {
67
67
  aptos: {
@@ -355,9 +355,9 @@ const FONT_MAPPINGS = {
355
355
  "serif"
356
356
  ],
357
357
  singleLineRatio: singleLineRatioOf({
358
- source: "legacy",
359
- ratio: 1.068,
360
- note: "Unverified hand-transcribed ratio; not yet measured against real Word output."
358
+ source: "measured",
359
+ ratio: 1.1273,
360
+ note: "Measured at 11pt against a 12.4pt reference-layout line pitch."
361
361
  })
362
362
  },
363
363
  "century gothic": {
@@ -1,6 +1,6 @@
1
1
  import { AUTO_PARAGRAPH_SPACING_PX, eighthsToPixels, formatPx, halfPointsToPixels, halfPointsToPoints, twipsToPixels } from "./units.js";
2
- import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
3
2
  import { resolveColor, resolveHighlightToCss, resolveShadingColor } from "./colorResolver.js";
3
+ import { resolveFontFamily, resolveThemeFont } from "./fontResolver.js";
4
4
  //#region src/utils/formatToStyle.ts
5
5
  /**
6
6
  * Convert TextFormatting to CSS properties for a run/span
@@ -1,14 +1,25 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
 
3
3
  //#region src/utils/paragraphFormattingMerge.d.ts
4
+ /**
5
+ * Merge custom tab stops across OOXML paragraph-property layers.
6
+ *
7
+ * Tabs cascade by position rather than replacing the inherited collection:
8
+ * a higher-priority stop supersedes the stop at the same position, while a
9
+ * `clear` stop removes that inherited position during layout. Keeping the
10
+ * clear entry also lets the tab calculator suppress an automatic stop at the
11
+ * same position.
12
+ */
13
+ declare function mergeParagraphTabStops(inherited: document_d_exports.TabStop[] | undefined, direct: document_d_exports.TabStop[]): document_d_exports.TabStop[];
14
+ declare function mergeParagraphTabStops(inherited: document_d_exports.TabStop[] | undefined, direct: document_d_exports.TabStop[] | undefined): document_d_exports.TabStop[] | undefined;
4
15
  /**
5
16
  * Merge paragraph properties for OOXML style cascade resolution.
6
17
  *
7
18
  * The source is the higher-priority layer. Most `w:pPr` properties replace an
8
19
  * inherited value when present; nested child containers merge by child field;
9
- * tabs replace as a complete ordered collection; paragraph mark `w:rPr` uses
10
- * the run-formatting merge rules.
20
+ * tabs merge by position; paragraph mark `w:rPr` uses the run-formatting
21
+ * merge rules.
11
22
  */
12
23
  declare function mergeParagraphFormatting(target: document_d_exports.ParagraphFormatting | undefined, source: document_d_exports.ParagraphFormatting | undefined): document_d_exports.ParagraphFormatting | undefined;
13
24
  //#endregion
14
- export { mergeParagraphFormatting };
25
+ export { mergeParagraphFormatting, mergeParagraphTabStops };
@@ -3,6 +3,8 @@ import { mergeTextFormatting } from "./textFormattingMerge.js";
3
3
  const PARAGRAPH_REPLACE_KEYS = [
4
4
  "alignment",
5
5
  "bidi",
6
+ "kinsoku",
7
+ "overflowPunctuation",
6
8
  "spaceBefore",
7
9
  "spaceAfter",
8
10
  "lineSpacing",
@@ -30,13 +32,20 @@ const copyDefinedParagraphProperty = (target, source, key) => {
30
32
  const value = source[key];
31
33
  if (value !== void 0) target[key] = value;
32
34
  };
35
+ function mergeParagraphTabStops(inherited, direct) {
36
+ if (direct === void 0) return inherited === void 0 ? void 0 : [...inherited];
37
+ const stopsByPosition = /* @__PURE__ */ new Map();
38
+ for (const stop of inherited ?? []) stopsByPosition.set(stop.position, stop);
39
+ for (const stop of direct) stopsByPosition.set(stop.position, stop);
40
+ return [...stopsByPosition.values()].toSorted((a, b) => a.position - b.position);
41
+ }
33
42
  /**
34
43
  * Merge paragraph properties for OOXML style cascade resolution.
35
44
  *
36
45
  * The source is the higher-priority layer. Most `w:pPr` properties replace an
37
46
  * inherited value when present; nested child containers merge by child field;
38
- * tabs replace as a complete ordered collection; paragraph mark `w:rPr` uses
39
- * the run-formatting merge rules.
47
+ * tabs merge by position; paragraph mark `w:rPr` uses the run-formatting
48
+ * merge rules.
40
49
  */
41
50
  function mergeParagraphFormatting(target, source) {
42
51
  if (!source) return target;
@@ -47,6 +56,7 @@ function mergeParagraphFormatting(target, source) {
47
56
  }
48
57
  const result = { ...target };
49
58
  for (const key of PARAGRAPH_REPLACE_KEYS) copyDefinedParagraphProperty(result, source, key);
59
+ if (source.indentFirstLine !== void 0) result.hangingIndent = source.hangingIndent === true;
50
60
  const mergedRunProperties = mergeTextFormatting(result.runProperties, source.runProperties);
51
61
  if (mergedRunProperties) result.runProperties = mergedRunProperties;
52
62
  if (source.borders !== void 0) result.borders = {
@@ -61,8 +71,8 @@ function mergeParagraphFormatting(target, source) {
61
71
  ...result.frame,
62
72
  ...source.frame
63
73
  };
64
- if (source.tabs !== void 0) result.tabs = [...source.tabs];
74
+ if (source.tabs !== void 0) result.tabs = mergeParagraphTabStops(result.tabs, source.tabs);
65
75
  return result;
66
76
  }
67
77
  //#endregion
68
- export { mergeParagraphFormatting };
78
+ export { mergeParagraphFormatting, mergeParagraphTabStops };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -113,6 +113,7 @@
113
113
  "better-result": "2.9.2",
114
114
  "csstype": "^3.1.3",
115
115
  "fast-xml-parser": "^5.9.3",
116
+ "hyphen": "1.14.1",
116
117
  "jszip": "3.10.1",
117
118
  "marked": "^18.0.5",
118
119
  "prosemirror-commands": "^1.7.1",
@@ -130,6 +131,9 @@
130
131
  "y-prosemirror": "^1.3.7",
131
132
  "yjs": "^13.6.31"
132
133
  },
134
+ "devDependencies": {
135
+ "@types/hyphen": "1.14.0"
136
+ },
133
137
  "main": "./dist/index.js",
134
138
  "types": "./dist/index.d.ts",
135
139
  "files": [
@@ -1,41 +0,0 @@
1
- //#region src/docx/capabilities.d.ts
2
- declare const FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION: 1;
3
- declare const FOLIO_DOCX_CAPABILITY_HOSTS: readonly ["browser", "server"];
4
- declare const FOLIO_DOCX_COMPATIBILITY_HOSTS: readonly ["browser", "server", "unknown"];
5
- declare const FOLIO_DOCX_PROFILES: readonly ["strict", "transitional"];
6
- declare const FOLIO_DOCX_COMPATIBILITY_PROFILES: readonly ["strict", "transitional", "unknown"];
7
- declare const FOLIO_DOCX_CAPABILITY_OPERATIONS: readonly ["create", "edit", "preserve", "read", "render"];
8
- declare const FOLIO_DOCX_SUPPORT_STATES: readonly ["supported", "partial", "unsupported"];
9
- declare const FOLIO_DOCX_CAPABILITY_IDS: readonly ["comments", "contentControls", "fields", "headersFooters", "hyperlinks", "images", "math", "notes", "numbering", "opaqueDrawing", "paragraphs", "sections", "styles", "tables", "trackedChanges"];
10
- type FolioDocxCapabilityHost = (typeof FOLIO_DOCX_CAPABILITY_HOSTS)[number];
11
- type FolioDocxCompatibilityHost = (typeof FOLIO_DOCX_COMPATIBILITY_HOSTS)[number];
12
- type FolioDocxProfile = (typeof FOLIO_DOCX_PROFILES)[number];
13
- type FolioDocxCompatibilityProfile = (typeof FOLIO_DOCX_COMPATIBILITY_PROFILES)[number];
14
- type FolioDocxCapabilityOperation = (typeof FOLIO_DOCX_CAPABILITY_OPERATIONS)[number];
15
- type FolioDocxSupportState = (typeof FOLIO_DOCX_SUPPORT_STATES)[number];
16
- type FolioDocxCapabilityId = (typeof FOLIO_DOCX_CAPABILITY_IDS)[number];
17
- type FolioDocxFeatureCapability = {
18
- readonly id: FolioDocxCapabilityId;
19
- readonly feature: "comments" | "contentControls" | "drawings" | "fields" | "headersFooters" | "hyperlinks" | "images" | "math" | "notes" | "numbering" | "paragraphs" | "revisions" | "sections" | "styles" | "tables";
20
- readonly hosts: readonly FolioDocxCapabilityHost[];
21
- readonly profiles: readonly FolioDocxProfile[];
22
- readonly support: Readonly<Record<FolioDocxCapabilityOperation, FolioDocxSupportState>>;
23
- readonly evidence: readonly {
24
- readonly type: "test";
25
- readonly path: string;
26
- }[];
27
- };
28
- type FolioDocxCapabilityManifest = {
29
- readonly version: typeof FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION;
30
- readonly capabilities: Readonly<Record<FolioDocxCapabilityId, FolioDocxFeatureCapability>>;
31
- };
32
- declare const FOLIO_DOCX_CAPABILITY_MANIFEST: FolioDocxCapabilityManifest;
33
- declare const InvalidFolioDocxCapabilityIdError_base: import("better-result").TaggedErrorClass<"InvalidFolioDocxCapabilityIdError", {
34
- message: string;
35
- receivedId: unknown;
36
- }>;
37
- declare class InvalidFolioDocxCapabilityIdError extends InvalidFolioDocxCapabilityIdError_base {}
38
- declare const isFolioDocxCapabilityId: (value: unknown) => value is FolioDocxCapabilityId;
39
- declare const getFolioDocxCapability: (id: unknown) => FolioDocxFeatureCapability;
40
- //#endregion
41
- export { FOLIO_DOCX_CAPABILITY_HOSTS, FOLIO_DOCX_CAPABILITY_IDS, FOLIO_DOCX_CAPABILITY_MANIFEST, FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION, FOLIO_DOCX_CAPABILITY_OPERATIONS, FOLIO_DOCX_COMPATIBILITY_HOSTS, FOLIO_DOCX_COMPATIBILITY_PROFILES, FOLIO_DOCX_PROFILES, FOLIO_DOCX_SUPPORT_STATES, FolioDocxCapabilityHost, FolioDocxCapabilityId, FolioDocxCapabilityManifest, FolioDocxCapabilityOperation, FolioDocxCompatibilityHost, FolioDocxCompatibilityProfile, FolioDocxFeatureCapability, FolioDocxProfile, FolioDocxSupportState, InvalidFolioDocxCapabilityIdError, getFolioDocxCapability, isFolioDocxCapabilityId };
@@ -1,322 +0,0 @@
1
- import { TaggedError } from "better-result";
2
- //#region src/docx/capabilities.ts
3
- const FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION = 1;
4
- const FOLIO_DOCX_CAPABILITY_HOSTS = Object.freeze(["browser", "server"]);
5
- const FOLIO_DOCX_COMPATIBILITY_HOSTS = Object.freeze([...FOLIO_DOCX_CAPABILITY_HOSTS, "unknown"]);
6
- const FOLIO_DOCX_PROFILES = Object.freeze(["strict", "transitional"]);
7
- const FOLIO_DOCX_COMPATIBILITY_PROFILES = Object.freeze([...FOLIO_DOCX_PROFILES, "unknown"]);
8
- const FOLIO_DOCX_CAPABILITY_OPERATIONS = Object.freeze([
9
- "create",
10
- "edit",
11
- "preserve",
12
- "read",
13
- "render"
14
- ]);
15
- const FOLIO_DOCX_SUPPORT_STATES = Object.freeze([
16
- "supported",
17
- "partial",
18
- "unsupported"
19
- ]);
20
- const FOLIO_DOCX_CAPABILITY_IDS = Object.freeze([
21
- "comments",
22
- "contentControls",
23
- "fields",
24
- "headersFooters",
25
- "hyperlinks",
26
- "images",
27
- "math",
28
- "notes",
29
- "numbering",
30
- "opaqueDrawing",
31
- "paragraphs",
32
- "sections",
33
- "styles",
34
- "tables",
35
- "trackedChanges"
36
- ]);
37
- const TRANSITIONAL_PROFILE_COVERAGE = Object.freeze(["transitional"]);
38
- const STRUCTURED_FEATURE_SUPPORT = Object.freeze({
39
- create: "supported",
40
- edit: "supported",
41
- preserve: "supported",
42
- read: "supported",
43
- render: "partial"
44
- });
45
- const PARTIAL_AUTHORING_FEATURE_SUPPORT = Object.freeze({
46
- create: "partial",
47
- edit: "partial",
48
- preserve: "supported",
49
- read: "supported",
50
- render: "partial"
51
- });
52
- const COMMENTS_CAPABILITY = Object.freeze({
53
- id: "comments",
54
- feature: "comments",
55
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
56
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
57
- support: STRUCTURED_FEATURE_SUPPORT,
58
- evidence: Object.freeze([{
59
- type: "test",
60
- path: "packages/core/src/docx/commentReplyThreads.test.ts"
61
- }, {
62
- type: "test",
63
- path: "packages/core/src/prosemirror/commands/comments.test.ts"
64
- }])
65
- });
66
- const CONTENT_CONTROLS_CAPABILITY = Object.freeze({
67
- id: "contentControls",
68
- feature: "contentControls",
69
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
70
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
71
- support: Object.freeze({
72
- ...PARTIAL_AUTHORING_FEATURE_SUPPORT,
73
- edit: "supported"
74
- }),
75
- evidence: Object.freeze([{
76
- type: "test",
77
- path: "packages/core/src/content-controls/contentControls.test.ts"
78
- }, {
79
- type: "test",
80
- path: "packages/core/src/docx/sdtRoundtrip.property.test.ts"
81
- }])
82
- });
83
- const FIELDS_CAPABILITY = Object.freeze({
84
- id: "fields",
85
- feature: "fields",
86
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
87
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
88
- support: PARTIAL_AUTHORING_FEATURE_SUPPORT,
89
- evidence: Object.freeze([{
90
- type: "test",
91
- path: "packages/core/src/fields/evaluateField.test.ts"
92
- }, {
93
- type: "test",
94
- path: "packages/core/src/prosemirror/extensions/nodes/FieldExtension.test.ts"
95
- }])
96
- });
97
- const HEADERS_FOOTERS_CAPABILITY = Object.freeze({
98
- id: "headersFooters",
99
- feature: "headersFooters",
100
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
101
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
102
- support: STRUCTURED_FEATURE_SUPPORT,
103
- evidence: Object.freeze([{
104
- type: "test",
105
- path: "packages/core/src/docx/headerFooterParser.test.ts"
106
- }, {
107
- type: "test",
108
- path: "packages/core/src/docx/headerFooterMaterialize.test.ts"
109
- }])
110
- });
111
- const HYPERLINKS_CAPABILITY = Object.freeze({
112
- id: "hyperlinks",
113
- feature: "hyperlinks",
114
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
115
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
116
- support: PARTIAL_AUTHORING_FEATURE_SUPPORT,
117
- evidence: Object.freeze([{
118
- type: "test",
119
- path: "packages/core/src/docx/hyperlinkParser.test.ts"
120
- }, {
121
- type: "test",
122
- path: "packages/core/src/prosemirror/conversion/toProseDoc-hyperlink-content.test.ts"
123
- }])
124
- });
125
- const IMAGES_CAPABILITY = Object.freeze({
126
- id: "images",
127
- feature: "images",
128
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
129
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
130
- support: Object.freeze({
131
- ...PARTIAL_AUTHORING_FEATURE_SUPPORT,
132
- edit: "supported"
133
- }),
134
- evidence: Object.freeze([{
135
- type: "test",
136
- path: "packages/core/src/docx/__tests__/image-crop-roundtrip.test.ts"
137
- }, {
138
- type: "test",
139
- path: "packages/core/src/prosemirror/commands/image.test.ts"
140
- }])
141
- });
142
- const MATH_CAPABILITY = Object.freeze({
143
- id: "math",
144
- feature: "math",
145
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
146
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
147
- support: PARTIAL_AUTHORING_FEATURE_SUPPORT,
148
- evidence: Object.freeze([{
149
- type: "test",
150
- path: "packages/core/src/docx/mathToMathml.test.ts"
151
- }, {
152
- type: "test",
153
- path: "packages/core/src/docx/serializer/math-roundtrip.test.ts"
154
- }])
155
- });
156
- const NOTES_CAPABILITY = Object.freeze({
157
- id: "notes",
158
- feature: "notes",
159
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
160
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
161
- support: Object.freeze({
162
- create: "partial",
163
- edit: "supported",
164
- preserve: "supported",
165
- read: "supported",
166
- render: "partial"
167
- }),
168
- evidence: Object.freeze([{
169
- type: "test",
170
- path: "packages/core/src/docx/noteSave.test.ts"
171
- }, {
172
- type: "test",
173
- path: "packages/core/src/layout-bridge/convert/footnoteLayout-collect.test.ts"
174
- }])
175
- });
176
- const NUMBERING_CAPABILITY = Object.freeze({
177
- id: "numbering",
178
- feature: "numbering",
179
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
180
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
181
- support: Object.freeze({
182
- create: "partial",
183
- edit: "supported",
184
- preserve: "supported",
185
- read: "supported",
186
- render: "partial"
187
- }),
188
- evidence: Object.freeze([{
189
- type: "test",
190
- path: "packages/core/src/docx/numberingParser-custom-format.test.ts"
191
- }, {
192
- type: "test",
193
- path: "packages/core/src/docx/numberingSave.test.ts"
194
- }])
195
- });
196
- const OPAQUE_DRAWING_CAPABILITY = Object.freeze({
197
- id: "opaqueDrawing",
198
- feature: "drawings",
199
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
200
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
201
- support: Object.freeze({
202
- create: "unsupported",
203
- edit: "unsupported",
204
- preserve: "supported",
205
- read: "supported",
206
- render: "partial"
207
- }),
208
- evidence: Object.freeze([{
209
- type: "test",
210
- path: "packages/core/src/docx/compatibility.test.ts"
211
- }, {
212
- type: "test",
213
- path: "packages/core/src/docx/rezip.test.ts"
214
- }])
215
- });
216
- const PARAGRAPHS_CAPABILITY = Object.freeze({
217
- id: "paragraphs",
218
- feature: "paragraphs",
219
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
220
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
221
- support: STRUCTURED_FEATURE_SUPPORT,
222
- evidence: Object.freeze([{
223
- type: "test",
224
- path: "packages/core/src/docx/paragraphParser.test.ts"
225
- }, {
226
- type: "test",
227
- path: "packages/core/src/docx/serializer/paragraphSerializer.test.ts"
228
- }])
229
- });
230
- const SECTIONS_CAPABILITY = Object.freeze({
231
- id: "sections",
232
- feature: "sections",
233
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
234
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
235
- support: STRUCTURED_FEATURE_SUPPORT,
236
- evidence: Object.freeze([{
237
- type: "test",
238
- path: "packages/core/src/docx/serializer/sectionPropertiesSerializer.test.ts"
239
- }, {
240
- type: "test",
241
- path: "packages/core/src/prosemirror/commands/sectionBreak.test.ts"
242
- }])
243
- });
244
- const STYLES_CAPABILITY = Object.freeze({
245
- id: "styles",
246
- feature: "styles",
247
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
248
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
249
- support: Object.freeze({
250
- create: "partial",
251
- edit: "partial",
252
- preserve: "supported",
253
- read: "supported",
254
- render: "partial"
255
- }),
256
- evidence: Object.freeze([{
257
- type: "test",
258
- path: "packages/core/src/docx/styleParser.test.ts"
259
- }, {
260
- type: "test",
261
- path: "packages/core/src/prosemirror/conversion/characterStyleRoundtrip.test.ts"
262
- }])
263
- });
264
- const TABLES_CAPABILITY = Object.freeze({
265
- id: "tables",
266
- feature: "tables",
267
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
268
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
269
- support: STRUCTURED_FEATURE_SUPPORT,
270
- evidence: Object.freeze([{
271
- type: "test",
272
- path: "packages/core/src/docx/tableParser.test.ts"
273
- }, {
274
- type: "test",
275
- path: "packages/core/src/prosemirror/conversion/tableBordersRoundtrip.test.ts"
276
- }])
277
- });
278
- const TRACKED_CHANGES_CAPABILITY = Object.freeze({
279
- id: "trackedChanges",
280
- feature: "revisions",
281
- hosts: FOLIO_DOCX_CAPABILITY_HOSTS,
282
- profiles: TRANSITIONAL_PROFILE_COVERAGE,
283
- support: STRUCTURED_FEATURE_SUPPORT,
284
- evidence: Object.freeze([{
285
- type: "test",
286
- path: "packages/core/src/redline.test.ts"
287
- }, {
288
- type: "test",
289
- path: "packages/core/src/prosemirror/plugins/suggestionMode.test.ts"
290
- }])
291
- });
292
- const FOLIO_DOCX_CAPABILITY_MANIFEST = Object.freeze({
293
- version: 1,
294
- capabilities: Object.freeze({
295
- comments: COMMENTS_CAPABILITY,
296
- contentControls: CONTENT_CONTROLS_CAPABILITY,
297
- fields: FIELDS_CAPABILITY,
298
- headersFooters: HEADERS_FOOTERS_CAPABILITY,
299
- hyperlinks: HYPERLINKS_CAPABILITY,
300
- images: IMAGES_CAPABILITY,
301
- math: MATH_CAPABILITY,
302
- notes: NOTES_CAPABILITY,
303
- numbering: NUMBERING_CAPABILITY,
304
- opaqueDrawing: OPAQUE_DRAWING_CAPABILITY,
305
- paragraphs: PARAGRAPHS_CAPABILITY,
306
- sections: SECTIONS_CAPABILITY,
307
- styles: STYLES_CAPABILITY,
308
- tables: TABLES_CAPABILITY,
309
- trackedChanges: TRACKED_CHANGES_CAPABILITY
310
- })
311
- });
312
- var InvalidFolioDocxCapabilityIdError = class extends TaggedError("InvalidFolioDocxCapabilityIdError")() {};
313
- const isFolioDocxCapabilityId = (value) => FOLIO_DOCX_CAPABILITY_IDS.some((id) => id === value);
314
- const getFolioDocxCapability = (id) => {
315
- if (!isFolioDocxCapabilityId(id)) throw new InvalidFolioDocxCapabilityIdError({
316
- message: "Invalid DOCX capability id.",
317
- receivedId: id
318
- });
319
- return FOLIO_DOCX_CAPABILITY_MANIFEST.capabilities[id];
320
- };
321
- //#endregion
322
- export { FOLIO_DOCX_CAPABILITY_HOSTS, FOLIO_DOCX_CAPABILITY_IDS, FOLIO_DOCX_CAPABILITY_MANIFEST, FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION, FOLIO_DOCX_CAPABILITY_OPERATIONS, FOLIO_DOCX_COMPATIBILITY_HOSTS, FOLIO_DOCX_COMPATIBILITY_PROFILES, FOLIO_DOCX_PROFILES, FOLIO_DOCX_SUPPORT_STATES, InvalidFolioDocxCapabilityIdError, getFolioDocxCapability, isFolioDocxCapabilityId };