@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
@@ -4,26 +4,76 @@ import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
4
4
  import { Plugin, PluginKey } from "prosemirror-state";
5
5
  //#region src/prosemirror/extensions/features/ParaIdAllocatorExtension.ts
6
6
  const paraIdAllocatorKey = new PluginKey("paraIdAllocator");
7
- const collectParaIdUpdates = (doc) => {
8
- const seen = /* @__PURE__ */ new Set();
9
- const updates = [];
7
+ const isUsableParaId = (value) => typeof value === "string" && value.length > 0 && value !== "00000000";
8
+ /**
9
+ * For every valid paraId in the pre-transaction doc, the position its
10
+ * paragraph ends up at after `transactions` — the occurrence that
11
+ * rightfully keeps the id when the new doc holds duplicates. Ids whose
12
+ * paragraph start was deleted by the steps are left out.
13
+ */
14
+ const mapKeeperPositions = (oldDoc, transactions) => {
15
+ const keepers = /* @__PURE__ */ new Map();
16
+ oldDoc.descendants((node, pos) => {
17
+ if (node.type.name !== "paragraph") return true;
18
+ const id = node.attrs["paraId"];
19
+ if (!isUsableParaId(id) || keepers.has(id)) return false;
20
+ let mapped = pos;
21
+ let deleted = false;
22
+ for (const tr of transactions) {
23
+ const result = tr.mapping.mapResult(mapped);
24
+ if (result.deleted) {
25
+ deleted = true;
26
+ break;
27
+ }
28
+ mapped = result.pos;
29
+ }
30
+ if (!deleted) keepers.set(id, mapped);
31
+ return false;
32
+ });
33
+ return keepers;
34
+ };
35
+ const collectParaIdUpdates = (doc, keeperPositions) => {
36
+ const missing = [];
37
+ const occurrencesById = /* @__PURE__ */ new Map();
10
38
  doc.descendants((node, pos) => {
11
- if (node.type.name !== "paragraph") return;
39
+ if (node.type.name !== "paragraph") return true;
12
40
  const id = node.attrs["paraId"];
13
- if (typeof id !== "string" || id.length === 0 || seen.has(id)) {
14
- let newId = generateHexId();
15
- while (seen.has(newId)) newId = generateHexId();
16
- seen.add(newId);
17
- updates.push({
41
+ if (!isUsableParaId(id)) missing.push({
42
+ pos,
43
+ attrs: node.attrs
44
+ });
45
+ else {
46
+ const occurrences = occurrencesById.get(id) ?? [];
47
+ occurrences.push({
18
48
  pos,
19
- attrs: {
20
- ...node.attrs,
21
- paraId: newId
22
- }
49
+ attrs: node.attrs
23
50
  });
24
- } else seen.add(id);
51
+ occurrencesById.set(id, occurrences);
52
+ }
25
53
  return false;
26
54
  });
55
+ const needFreshId = [...missing];
56
+ for (const [id, occurrences] of occurrencesById) {
57
+ if (occurrences.length === 1) continue;
58
+ const keeperPos = keeperPositions?.get(id);
59
+ const keeper = occurrences.find((occurrence) => occurrence.pos === keeperPos) ?? occurrences[0];
60
+ for (const occurrence of occurrences) if (occurrence !== keeper) needFreshId.push(occurrence);
61
+ }
62
+ const taken = new Set(occurrencesById.keys());
63
+ const updates = [];
64
+ for (const { pos, attrs } of needFreshId) {
65
+ let newId = generateHexId();
66
+ while (taken.has(newId)) newId = generateHexId();
67
+ taken.add(newId);
68
+ updates.push({
69
+ pos,
70
+ attrs: {
71
+ ...attrs,
72
+ paraId: newId
73
+ }
74
+ });
75
+ }
76
+ updates.sort((a, b) => a.pos - b.pos);
27
77
  return updates;
28
78
  };
29
79
  const ensureParaIdsInState = (state) => {
@@ -38,12 +88,14 @@ const ensureParaIdsInState = (state) => {
38
88
  };
39
89
  const createParaIdAllocatorPlugin = () => new Plugin({
40
90
  key: paraIdAllocatorKey,
41
- appendTransaction(transactions, _oldState, newState) {
91
+ appendTransaction(transactions, oldState, newState) {
42
92
  if (!transactions.some((t) => t.docChanged)) return null;
43
- const updates = collectParaIdUpdates(newState.doc);
93
+ const keeperPositions = mapKeeperPositions(oldState.doc, transactions);
94
+ const updates = collectParaIdUpdates(newState.doc, keeperPositions);
44
95
  if (updates.length === 0) return null;
45
96
  const tr = newState.tr;
46
97
  for (const u of updates) tr.setNodeMarkup(u.pos, void 0, u.attrs);
98
+ ignoreTrackedChanges(tr);
47
99
  tr.setMeta(paraIdAllocatorKey, "allocated");
48
100
  tr.setMeta("addToHistory", false);
49
101
  return tr;
@@ -16,6 +16,7 @@ const FootnoteRefExtension = createMarkExtension({
16
16
  name: "footnoteRef",
17
17
  schemaMarkName: "footnoteRef",
18
18
  markSpec: {
19
+ inclusive: false,
19
20
  attrs: {
20
21
  id: {},
21
22
  noteType: { default: "footnote" },
@@ -1,6 +1,6 @@
1
1
  import { HIGHLIGHT_COLOR_VALUES } from "../../../types/documentEnumValues.js";
2
- import { resolveHighlightToCss } from "../../../utils/colorResolver.js";
3
2
  import { expectHighlightMarkAttrs } from "../../attrs/index.js";
3
+ import { resolveHighlightToCss } from "../../../utils/colorResolver.js";
4
4
  import { createMarkExtension } from "../create.js";
5
5
  import { removeMark, setMark } from "./markUtils.js";
6
6
  import { panic } from "better-result";
@@ -0,0 +1,7 @@
1
+ import { MarkExtension } from "../types.js";
2
+
3
+ //#region src/prosemirror/extensions/marks/LanguageExtension.d.ts
4
+ /** Preserve OOXML `w:lang` and expose its primary language to the editing DOM. */
5
+ declare const LanguageExtension: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
6
+ //#endregion
7
+ export { LanguageExtension };
@@ -0,0 +1,30 @@
1
+ import { expectLanguageMarkAttrs } from "../../attrs/index.js";
2
+ import { createMarkExtension } from "../create.js";
3
+ //#region src/prosemirror/extensions/marks/LanguageExtension.ts
4
+ /** Preserve OOXML `w:lang` and expose its primary language to the editing DOM. */
5
+ const LanguageExtension = createMarkExtension({
6
+ name: "language",
7
+ schemaMarkName: "language",
8
+ markSpec: {
9
+ attrs: {
10
+ val: { default: null },
11
+ eastAsia: { default: null },
12
+ bidi: { default: null }
13
+ },
14
+ parseDOM: [{
15
+ tag: "span[lang]",
16
+ getAttrs: (dom) => typeof dom === "string" ? false : { val: dom.getAttribute("lang") ?? void 0 }
17
+ }],
18
+ toDOM(mark) {
19
+ const { val, eastAsia, bidi } = expectLanguageMarkAttrs(mark);
20
+ const language = val ?? eastAsia ?? bidi;
21
+ return language ? [
22
+ "span",
23
+ { lang: language },
24
+ 0
25
+ ] : ["span", 0];
26
+ }
27
+ }
28
+ });
29
+ //#endregion
30
+ export { LanguageExtension };
@@ -1,5 +1,5 @@
1
- import { ensureHexPrefix } from "../../../utils/colorResolver.js";
2
1
  import { expectRunShadingMarkAttrs } from "../../attrs/index.js";
2
+ import { ensureHexPrefix } from "../../../utils/colorResolver.js";
3
3
  import { createMarkExtension } from "../create.js";
4
4
  import { normalizeCssColorKey, parseDOMHighlightColor } from "./HighlightExtension.js";
5
5
  //#region src/prosemirror/extensions/marks/RunShadingExtension.ts
@@ -1,5 +1,5 @@
1
- import { textToStyle } from "../../../utils/formatToStyle.js";
2
1
  import { expectTextColorMarkAttrs } from "../../attrs/index.js";
2
+ import { textToStyle } from "../../../utils/formatToStyle.js";
3
3
  import { createMarkExtension } from "../create.js";
4
4
  import { removeMark, setMark } from "./markUtils.js";
5
5
  import { panic } from "better-result";
@@ -1,6 +1,6 @@
1
- import { AUTHOR_COLORS, getAuthorColorIdx } from "../../../utils/authorColors.js";
2
1
  import { expectTrackedChangeMarkAttrs } from "../../attrs/index.js";
3
2
  import { createMarkExtension } from "../create.js";
3
+ import { AUTHOR_COLORS, getAuthorColorIdx } from "../../../utils/authorColors.js";
4
4
  //#region src/prosemirror/extensions/marks/TrackedChangeExtensions.ts
5
5
  /**
6
6
  * Tracked Change Mark Extensions — insertion and deletion marks
@@ -43,6 +43,17 @@ function marksToTextFormatting(marks) {
43
43
  };
44
44
  break;
45
45
  }
46
+ case "language": {
47
+ const val = mark.attrs["val"];
48
+ const eastAsia = mark.attrs["eastAsia"];
49
+ const bidi = mark.attrs["bidi"];
50
+ formatting.language = {
51
+ ...typeof val === "string" ? { val } : {},
52
+ ...typeof eastAsia === "string" ? { eastAsia } : {},
53
+ ...typeof bidi === "string" ? { bidi } : {}
54
+ };
55
+ break;
56
+ }
46
57
  case "superscript":
47
58
  formatting.vertAlign = "superscript";
48
59
  break;
@@ -186,6 +197,7 @@ function textFormattingToMarks(formatting, schema) {
186
197
  hAnsi: formatting.fontFamily.hAnsi,
187
198
  asciiTheme: formatting.fontFamily.asciiTheme
188
199
  }));
200
+ if (formatting.language && schema.marks["language"]) marks.push(schema.marks["language"].create(formatting.language));
189
201
  if (formatting.vertAlign === "superscript" && schema.marks["superscript"]) marks.push(schema.marks["superscript"].create());
190
202
  if (formatting.vertAlign === "subscript" && schema.marks["subscript"]) marks.push(schema.marks["subscript"].create());
191
203
  if (formatting.rtl && schema.marks["rtl"]) marks.push(schema.marks["rtl"].create());
@@ -38,7 +38,8 @@ const ImageExtension = createNodeExtension({
38
38
  borderStyle: { default: null },
39
39
  wrapText: { default: null },
40
40
  hlinkHref: { default: null },
41
- _docxRawXml: { default: null }
41
+ _docxRawXml: { default: null },
42
+ _docxObjectPreview: { default: null }
42
43
  },
43
44
  parseDOM: [{
44
45
  tag: "img[src]",
@@ -1,11 +1,11 @@
1
1
  import { TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_WIDTH_TYPE_VALUES } from "../../../types/documentEnumValues.js";
2
- import { resolveColor } from "../../../utils/colorResolver.js";
3
2
  import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
3
+ import { resolveColor } from "../../../utils/colorResolver.js";
4
4
  import { createExtension, createNodeExtension } from "../create.js";
5
5
  import { panic } from "better-result";
6
6
  import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
7
- import { Decoration, DecorationSet } from "prosemirror-view";
8
7
  import { CellSelection, TableMap, columnResizing, mergeCells, removeRow, selectedRect, splitCell, tableEditing } from "prosemirror-tables";
8
+ import { Decoration, DecorationSet } from "prosemirror-view";
9
9
  //#region src/prosemirror/extensions/nodes/TableExtension.ts
10
10
  /**
11
11
  * Table Extension — 4 node specs + plugins + commands
@@ -310,6 +310,7 @@ const tableCellSpec = {
310
310
  widthType: { default: null },
311
311
  verticalAlign: { default: null },
312
312
  backgroundColor: { default: null },
313
+ _resolvedBackgroundColor: { default: null },
313
314
  borders: { default: null },
314
315
  margins: { default: null },
315
316
  textDirection: { default: null },
@@ -363,6 +364,7 @@ const tableHeaderSpec = {
363
364
  widthType: { default: null },
364
365
  verticalAlign: { default: null },
365
366
  backgroundColor: { default: null },
367
+ _resolvedBackgroundColor: { default: null },
366
368
  borders: { default: null },
367
369
  margins: { default: null },
368
370
  textDirection: { default: null },
@@ -6,7 +6,8 @@ import { ImagePositionAttrs } from "../../schema/nodes.js";
6
6
  //#region src/prosemirror/extensions/nodes/TextBoxExtension.d.ts
7
7
  type TextBoxAttrs = {
8
8
  /** Width in pixels */width?: number; /** Height in pixels */
9
- height?: number; /** Unique identifier */
9
+ height?: number; /** Text fitting behavior */
10
+ autoFit?: document_d_exports.ShapeTextBody["autoFit"]; /** Unique identifier */
10
11
  textBoxId?: string; /** Fill color as CSS color */
11
12
  fillColor?: string; /** Outline width in pixels */
12
13
  outlineWidth?: number; /** Outline color as CSS color */
@@ -15,6 +15,9 @@ function parseTextBoxPosition(raw) {
15
15
  function parseTextBoxWrapType(raw) {
16
16
  for (const value of IMAGE_WRAP_TYPE_VALUES) if (value === raw) return value;
17
17
  }
18
+ function parseTextBoxAutoFit(raw) {
19
+ if (raw === "none" || raw === "normal" || raw === "shape") return raw;
20
+ }
18
21
  const TextBoxExtension = createNodeExtension({
19
22
  name: "textBox",
20
23
  schemaNodeName: "textBox",
@@ -26,6 +29,7 @@ const TextBoxExtension = createNodeExtension({
26
29
  attrs: {
27
30
  width: { default: 200 },
28
31
  height: { default: null },
32
+ autoFit: { default: null },
29
33
  textBoxId: { default: null },
30
34
  fillColor: { default: null },
31
35
  outlineWidth: { default: null },
@@ -55,9 +59,11 @@ const TextBoxExtension = createNodeExtension({
55
59
  const d = dom.dataset;
56
60
  const position = parseTextBoxPosition(d["position"]);
57
61
  const wrapType = parseTextBoxWrapType(d["wrapType"]);
62
+ const autoFit = parseTextBoxAutoFit(d["autoFit"]);
58
63
  return {
59
64
  ...d["width"] ? { width: Number(d["width"]) } : {},
60
65
  ...d["height"] ? { height: Number(d["height"]) } : {},
66
+ ...autoFit ? { autoFit } : {},
61
67
  ...d["textboxId"] ? { textBoxId: d["textboxId"] } : {},
62
68
  ...d["fillColor"] ? { fillColor: d["fillColor"] } : {},
63
69
  ...d["outlineWidth"] ? { outlineWidth: Number(d["outlineWidth"]) } : {},
@@ -85,6 +91,7 @@ const TextBoxExtension = createNodeExtension({
85
91
  const domAttrs = { class: "docx-textbox" };
86
92
  if (attrs.width) domAttrs["data-width"] = String(attrs.width);
87
93
  if (attrs.height) domAttrs["data-height"] = String(attrs.height);
94
+ if (attrs.autoFit) domAttrs["data-auto-fit"] = attrs.autoFit;
88
95
  if (attrs.textBoxId) domAttrs["data-textbox-id"] = attrs.textBoxId;
89
96
  if (attrs.fillColor) domAttrs["data-fill-color"] = attrs.fillColor;
90
97
  if (attrs.outlineWidth) domAttrs["data-outline-width"] = String(attrs.outlineWidth);
@@ -1,6 +1,6 @@
1
1
  import { ExtensionManager } from "../extensions/ExtensionManager.js";
2
2
  import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
3
- import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
3
+ import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
4
4
 
5
5
  //#region src/prosemirror/schema/index.d.ts
6
6
  declare const singletonManager: ExtensionManager;
@@ -12,4 +12,4 @@ type DocxSchema = typeof schema;
12
12
  type DocxNode = ReturnType<typeof schema.node>;
13
13
  type DocxMark = ReturnType<typeof schema.mark>;
14
14
  //#endregion
15
- export { type BlockSdtAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type MathAttrs, type ParagraphAttrs, type RunFormattingOverrideAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
15
+ export { type BlockSdtAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type ParagraphAttrs, type RunFormattingOverrideAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
@@ -40,6 +40,11 @@ type FontFamilyAttrs = {
40
40
  eastAsiaTheme?: string;
41
41
  csTheme?: string;
42
42
  };
43
+ type LanguageAttrs = {
44
+ val?: string;
45
+ eastAsia?: string;
46
+ bidi?: string;
47
+ };
43
48
  type HighlightAttrs = {
44
49
  color: NonNullable<document_d_exports.TextFormatting["highlight"]>;
45
50
  };
@@ -115,4 +120,4 @@ type HyperlinkAttrs = {
115
120
  _docxHyperlinkIndex?: number;
116
121
  };
117
122
  //#endregion
118
- export { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs };
123
+ export { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs };
@@ -13,7 +13,10 @@ type HardBreakAttrs = {
13
13
  type ParagraphAttrs = {
14
14
  paraId?: string;
15
15
  textId?: string;
16
- alignment?: document_d_exports.ParagraphAlignment;
16
+ alignment?: document_d_exports.ParagraphAlignment; /** Effective East Asian line-edge policy (`w:kinsoku`). */
17
+ kinsoku?: boolean; /** Effective hanging-punctuation policy (`w:overflowPunct`). */
18
+ overflowPunctuation?: boolean; /** Effective paragraph opt-out from document automatic hyphenation. */
19
+ suppressAutoHyphens?: boolean;
17
20
  spaceBefore?: number;
18
21
  spaceAfter?: number;
19
22
  lineSpacing?: number;
@@ -46,7 +49,9 @@ type ParagraphAttrs = {
46
49
  listMarker?: string; /** Whether the list marker is hidden (w:vanish on numbering level rPr) */
47
50
  listMarkerHidden?: boolean; /** Marker font family from numbering level rPr */
48
51
  listMarkerFontFamily?: string; /** Marker font size from numbering level rPr, in points */
49
- listMarkerFontSize?: number;
52
+ listMarkerFontSize?: number; /** Marker bold state from numbering level rPr */
53
+ listMarkerBold?: boolean; /** Horizontal alignment of the marker around the paragraph's list anchor. */
54
+ listMarkerAlignment?: "left" | "center" | "right";
50
55
  /**
51
56
  * `w:suff` (§17.9.25) — what follows the marker before body text.
52
57
  * `tab` (default) grows the marker to the next tab stop; `space` adds one
@@ -82,7 +87,8 @@ type ParagraphAttrs = {
82
87
  shading?: document_d_exports.ShadingProperties;
83
88
  tabs?: document_d_exports.TabStop[];
84
89
  pageBreakBefore?: boolean; /** Word's cached rendered-page-break marker; preserved for round-trip only. */
85
- renderedPageBreakBefore?: boolean;
90
+ renderedPageBreakBefore?: boolean; /** Internal import marker for a paragraph whose only run content is a hard page break. */
91
+ _pageBreakCarrier?: boolean;
86
92
  keepNext?: boolean;
87
93
  keepLines?: boolean;
88
94
  widowControl?: boolean; /** Contextual spacing — suppress space between same-style paragraphs */
@@ -197,7 +203,8 @@ type ImageAttrs = {
197
203
  borderStyle?: string; /** Wrap text setting from DOCX (left, right, bothSides, largest) for round-trip */
198
204
  wrapText?: NonNullable<document_d_exports.ImageWrap["wrapText"]>; /** Hyperlink URL for clickable image */
199
205
  hlinkHref?: string; /** Original OOXML for opaque/unsupported DOCX drawings. */
200
- _docxRawXml?: string;
206
+ _docxRawXml?: string; /** Embedded-object previews use their authored box as the exact line height. */
207
+ _docxObjectPreview?: boolean;
201
208
  };
202
209
  /**
203
210
  * Field node attributes
@@ -307,7 +314,8 @@ type ShapeAttrs = {
307
314
  */
308
315
  type TextBoxAttrs = {
309
316
  /** Width in pixels */width?: number; /** Height in pixels */
310
- height?: number; /** Unique identifier */
317
+ height?: number; /** Text fitting behavior */
318
+ autoFit?: document_d_exports.ShapeTextBody["autoFit"]; /** Unique identifier */
311
319
  textBoxId?: string; /** Fill color as CSS color */
312
320
  fillColor?: string; /** Outline width in pixels */
313
321
  outlineWidth?: number; /** Outline color as CSS color */
@@ -373,15 +381,11 @@ type TableCellAttrs = {
373
381
  width?: number; /** Cell width type */
374
382
  widthType?: document_d_exports.TableWidthType; /** Vertical alignment */
375
383
  verticalAlign?: "top" | "center" | "bottom"; /** Background color (RGB hex) */
376
- backgroundColor?: string; /** OOXML text direction (e.g. 'tbRl', 'btLr') */
384
+ backgroundColor?: string; /** Resolved source color. PM-only; distinguishes theme rendering from a user override. */
385
+ _resolvedBackgroundColor?: string; /** OOXML text direction (e.g. 'tbRl', 'btLr') */
377
386
  textDirection?: NonNullable<document_d_exports.TableCellFormatting["textDirection"]>; /** No text wrapping in cell */
378
387
  noWrap?: boolean; /** Cell borders — full BorderSpec per side (style, color, size) */
379
- borders?: {
380
- top?: document_d_exports.BorderSpec;
381
- bottom?: document_d_exports.BorderSpec;
382
- left?: document_d_exports.BorderSpec;
383
- right?: document_d_exports.BorderSpec;
384
- }; /** Cell margins/padding in twips per side */
388
+ borders?: document_d_exports.TableCellBorders; /** Cell margins/padding in twips per side */
385
389
  margins?: {
386
390
  top?: number;
387
391
  bottom?: number;
@@ -86,6 +86,8 @@ function listAttrsFromResolvedStyle(resolved, numbering) {
86
86
  listMarkerHidden: rendering?.markerHidden ?? null,
87
87
  listMarkerFontFamily: rendering?.markerFontFamily ?? null,
88
88
  listMarkerFontSize: rendering?.markerFontSize ?? null,
89
+ listMarkerBold: rendering?.markerBold ?? null,
90
+ listMarkerAlignment: rendering?.markerAlignment ?? null,
89
91
  listMarkerSuffix: rendering?.markerSuffix ?? null,
90
92
  listMarkerAllCaps: rendering?.markerAllCaps ?? null,
91
93
  listImplicitChildLevelAdvances: null,
@@ -64,7 +64,9 @@ declare function pixelsToTwips(pixels: number): number;
64
64
  * Compute the list of effective tab stops for a paragraph
65
65
  *
66
66
  * Merges explicit stops with default stops at regular intervals.
67
- * Filters out stops that fall before the left indent.
67
+ * Explicit stops before the left indent remain available to a hanging first
68
+ * line. Continuation lines naturally skip them because their cursor already
69
+ * starts at the left indent.
68
70
  *
69
71
  * @param context - Tab context with explicit stops and settings
70
72
  * @returns Sorted array of tab stops in twips
@@ -27,25 +27,27 @@ function pixelsToTwips(pixels) {
27
27
  * Compute the list of effective tab stops for a paragraph
28
28
  *
29
29
  * Merges explicit stops with default stops at regular intervals.
30
- * Filters out stops that fall before the left indent.
30
+ * Explicit stops before the left indent remain available to a hanging first
31
+ * line. Continuation lines naturally skip them because their cursor already
32
+ * starts at the left indent.
31
33
  *
32
34
  * @param context - Tab context with explicit stops and settings
33
35
  * @returns Sorted array of tab stops in twips
34
36
  */
35
37
  function computeTabStops(context) {
36
38
  const { explicitStops = [], defaultTabInterval = 720, leftIndent = 0 } = context;
37
- const validExplicitStops = explicitStops.filter((stop) => stop.val !== "clear").filter((stop) => stop.pos >= leftIndent);
39
+ const validExplicitStops = explicitStops.filter((stop) => stop.val !== "clear");
38
40
  const clearPositions = explicitStops.filter((stop) => stop.val === "clear").map((stop) => stop.pos);
39
41
  let maxExplicit = 0;
40
42
  for (const stop of validExplicitStops) maxExplicit = Math.max(maxExplicit, stop.pos);
41
43
  const stops = [...validExplicitStops];
42
- if (leftIndent > 0 && !validExplicitStops.some((s) => s.pos <= leftIndent)) {
43
- if (!clearPositions.some((p) => Math.abs(p - leftIndent) < 20)) stops.push({
44
- val: "start",
45
- pos: leftIndent,
46
- leader: "none"
47
- });
48
- }
44
+ const hasLeftIndentClear = clearPositions.some((p) => Math.abs(p - leftIndent) < 20);
45
+ const addsImplicitLeftIndent = leftIndent > 0 && !hasLeftIndentClear && !validExplicitStops.some((stop) => stop.pos <= leftIndent);
46
+ if (addsImplicitLeftIndent) stops.push({
47
+ val: "start",
48
+ pos: leftIndent,
49
+ leader: "none"
50
+ });
49
51
  let pos = Math.floor(Math.max(maxExplicit, leftIndent) / defaultTabInterval) * defaultTabInterval;
50
52
  const limitPos = leftIndent + 14400;
51
53
  while (pos < limitPos) {
@@ -60,7 +62,7 @@ function computeTabStops(context) {
60
62
  hasClearStop = true;
61
63
  break;
62
64
  }
63
- const isAtLeftIndent = leftIndent > 0 && Math.abs(pos - leftIndent) < 20;
65
+ const isAtLeftIndent = addsImplicitLeftIndent && Math.abs(pos - leftIndent) < 20;
64
66
  if (!hasExplicitStop && !hasClearStop && !isAtLeftIndent) stops.push({
65
67
  val: "start",
66
68
  pos,
@@ -1,4 +1,4 @@
1
- import { readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
1
+ import { readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
2
2
  //#region src/prosemirror/validation.ts
3
3
  var ProseMirrorDocumentValidationError = class extends Error {
4
4
  issues;
@@ -133,6 +133,9 @@ const validateMarks = (marks, path, issues) => {
133
133
  case "fontFamily":
134
134
  appendAttrIssues(markPath, readFontFamilyMarkAttrs(mark), issues);
135
135
  continue;
136
+ case "language":
137
+ appendAttrIssues(markPath, readLanguageMarkAttrs(mark), issues);
138
+ continue;
136
139
  case "characterSpacing":
137
140
  appendAttrIssues(markPath, readCharacterSpacingMarkAttrs(mark), issues);
138
141
  continue;
package/dist/redline.js CHANGED
@@ -69,7 +69,7 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
69
69
  const operations = [];
70
70
  let operationSeq = 0;
71
71
  const nextOperationId = () => `redline-${++operationSeq}`;
72
- /** Additions past the last base block, inserted after it in reverse so the final order matches the revised document. */
72
+ /** Additions past the last base block, kept in revised-document order. */
73
73
  const trailingAdditions = [];
74
74
  const lastBaseBlockId = baseSnapshot.blocks.at(-1)?.id ?? null;
75
75
  events.forEach((event, eventIndex) => {
@@ -106,10 +106,20 @@ const generateRedlineDocx = async (base, revised, options = {}) => {
106
106
  ...event.block.styleId !== void 0 && { styleId: event.block.styleId }
107
107
  });
108
108
  });
109
- for (const addition of trailingAdditions.toReversed()) operations.push({
109
+ if (lastBaseBlockId === null && baseSnapshot.emptyDocumentAnchorId !== void 0) {
110
+ const firstAddition = trailingAdditions.shift();
111
+ if (firstAddition !== void 0) operations.push({
112
+ id: nextOperationId(),
113
+ type: "replaceBlock",
114
+ blockId: baseSnapshot.emptyDocumentAnchorId,
115
+ text: firstAddition.text,
116
+ ...firstAddition.styleId !== void 0 && { styleId: firstAddition.styleId }
117
+ });
118
+ }
119
+ for (const addition of trailingAdditions) operations.push({
110
120
  id: nextOperationId(),
111
121
  type: "insertAfterBlock",
112
- blockId: lastBaseBlockId ?? "redline-unanchored",
122
+ blockId: lastBaseBlockId ?? baseSnapshot.emptyDocumentAnchorId ?? "redline-unanchored",
113
123
  text: addition.text,
114
124
  ...addition.styleId !== void 0 && { styleId: addition.styleId }
115
125
  });
package/dist/server.d.ts CHANGED
@@ -1,14 +1,19 @@
1
- import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineFormatting, FolioAITextRangeHandle } from "./ai-edits/types.js";
2
- import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationStatus, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
1
+ import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineFormatting, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./ai-edits/types.js";
2
+ import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
3
3
  import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
4
- import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FolioApplyDocumentOperationsOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocxReviewer, FolioDocxReviewerOptions, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
4
+ import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
5
5
  import { createFolioAITextRangeHandle } from "./ai-edits/snapshot.js";
6
+ import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
6
7
  import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
8
+ import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocumentPreset, DocumentStyleSet } from "./style-sets/types.js";
7
9
  import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
10
+ import { DocumentStyleCatalog, DocumentStyleCatalogEntry, ExtractDocumentStyleSetOptions, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "./style-sets/extract.js";
11
+ import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "./style-sets/stellaStyle.js";
8
12
  import { createDocx } from "./docx/rezip.js";
13
+ import { EnsureParaIdsError, EnsureParaIdsOptions, EnsureParaIdsResult, ensureParaIds } from "./docx/ensureParaIds.js";
9
14
  import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
10
15
  import { DocxArchiveError } from "./docx/server/boundedArchive.js";
11
16
  import { DocxParagraphSource, ExtractedDocxParagraph, ExtractedDocxText, extractDocxText } from "./docx/server/extractDocxText.js";
12
17
  import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, generateRedlineDocx } from "./redline.js";
13
18
  import { FolioBlockDiff, FolioFormatProperty, FolioVersionDiff, FolioVersionDiffSegment, compareDocxVersions } from "./version-comparison.js";
14
- export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, type DeriveBlockIdInput, DocxArchiveError, type DocxParagraphSource, type ExtractedDocxParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioFormatProperty, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioVersionDiff, type FolioVersionDiffSegment, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, deriveBlockId, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, replyToComment };
19
+ export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxParagraphSource, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioVersionDiff, type FolioVersionDiffSegment, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, InvalidFolioDocumentOperationBatchError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment };
package/dist/server.js CHANGED
@@ -1,12 +1,17 @@
1
1
  import { deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
2
2
  import { createFolioAITextRangeHandle } from "./ai-edits/snapshot.js";
3
3
  import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
4
+ import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "./style-sets/types.js";
4
5
  import { createEmptyDocument } from "./utils/createDocument.js";
6
+ import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "./style-sets/extract.js";
7
+ import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "./style-sets/stellaStyle.js";
5
8
  import { createDocx } from "./docx/rezip.js";
9
+ import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
6
10
  import { replyToComment } from "./docx/replyToComment.js";
7
- import { FolioDocxReviewer, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
11
+ import { FolioDocumentStoryNotFoundError, FolioDocxReviewer, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
8
12
  import { compareDocxVersions } from "./version-comparison.js";
9
13
  import { generateRedlineDocx } from "./redline.js";
14
+ import { EnsureParaIdsError, ensureParaIds } from "./docx/ensureParaIds.js";
10
15
  import { DocxArchiveError } from "./docx/server/boundedArchive.js";
11
16
  import { extractDocxText } from "./docx/server/extractDocxText.js";
12
- export { DocxArchiveError, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocxReviewer, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, deriveBlockId, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, replyToComment };
17
+ export { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocxArchiveError, EnsureParaIdsError, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentStoryNotFoundError, FolioDocxReviewer, InvalidFolioDocumentOperationBatchError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, applyFolioAIEditsToBuffer, assertSupportedFolioDocumentOperationVersion, compareDocxVersions, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, ensureParaIds, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, inspectDocumentStyles, inspectDocumentStylesFromDocx, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, readFolioDocumentSection, replyToComment };