@portone/docx-editor 0.1.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 (347) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/CONTRIBUTING.md +63 -0
  3. package/LICENSE +203 -0
  4. package/README.md +48 -0
  5. package/assets/editor.png +0 -0
  6. package/dist/DocxEditor.d.ts +123 -0
  7. package/dist/DocxEditor.js +348 -0
  8. package/dist/core.d.ts +36 -0
  9. package/dist/core.js +38 -0
  10. package/dist/docx/comments/constants.d.ts +8 -0
  11. package/dist/docx/comments/constants.js +20 -0
  12. package/dist/docx/comments/model.d.ts +37 -0
  13. package/dist/docx/comments/model.js +104 -0
  14. package/dist/docx/comments/reading.d.ts +36 -0
  15. package/dist/docx/comments/reading.js +149 -0
  16. package/dist/docx/comments/writing.d.ts +11 -0
  17. package/dist/docx/comments/writing.js +327 -0
  18. package/dist/docx/comments.d.ts +3 -0
  19. package/dist/docx/comments.js +4 -0
  20. package/dist/docx/container.d.ts +12 -0
  21. package/dist/docx/container.js +130 -0
  22. package/dist/docx/documentSettings.d.ts +4 -0
  23. package/dist/docx/documentSettings.js +14 -0
  24. package/dist/docx/exportDocx.d.ts +15 -0
  25. package/dist/docx/exportDocx.js +163 -0
  26. package/dist/docx/exportRefs.d.ts +16 -0
  27. package/dist/docx/exportRefs.js +10 -0
  28. package/dist/docx/formatting/direct.d.ts +30 -0
  29. package/dist/docx/formatting/direct.js +201 -0
  30. package/dist/docx/formatting/effectiveParagraph.d.ts +15 -0
  31. package/dist/docx/formatting/effectiveParagraph.js +81 -0
  32. package/dist/docx/formatting/styles.d.ts +67 -0
  33. package/dist/docx/formatting/styles.js +165 -0
  34. package/dist/docx/formatting/tabStops.d.ts +8 -0
  35. package/dist/docx/formatting/tabStops.js +65 -0
  36. package/dist/docx/formatting.d.ts +4 -0
  37. package/dist/docx/formatting.js +4 -0
  38. package/dist/docx/headersFooters.d.ts +36 -0
  39. package/dist/docx/headersFooters.js +218 -0
  40. package/dist/docx/hyperlink.d.ts +75 -0
  41. package/dist/docx/hyperlink.js +71 -0
  42. package/dist/docx/importDocx.d.ts +21 -0
  43. package/dist/docx/importDocx.js +263 -0
  44. package/dist/docx/importParagraph.d.ts +32 -0
  45. package/dist/docx/importParagraph.js +308 -0
  46. package/dist/docx/importTable.d.ts +9 -0
  47. package/dist/docx/importTable.js +275 -0
  48. package/dist/docx/media.d.ts +60 -0
  49. package/dist/docx/media.js +213 -0
  50. package/dist/docx/notes.d.ts +22 -0
  51. package/dist/docx/notes.js +71 -0
  52. package/dist/docx/pageGeometry.d.ts +75 -0
  53. package/dist/docx/pageGeometry.js +88 -0
  54. package/dist/docx/paraProps.d.ts +74 -0
  55. package/dist/docx/paraProps.js +167 -0
  56. package/dist/docx/propsXml.d.ts +49 -0
  57. package/dist/docx/propsXml.js +302 -0
  58. package/dist/docx/relationships.d.ts +42 -0
  59. package/dist/docx/relationships.js +94 -0
  60. package/dist/docx/runProps.d.ts +51 -0
  61. package/dist/docx/runProps.js +207 -0
  62. package/dist/docx/scan.d.ts +20 -0
  63. package/dist/docx/scan.js +110 -0
  64. package/dist/docx/sdt.d.ts +56 -0
  65. package/dist/docx/sdt.js +104 -0
  66. package/dist/docx/sdtProps.d.ts +18 -0
  67. package/dist/docx/sdtProps.js +11 -0
  68. package/dist/docx/serializeBlock.d.ts +4 -0
  69. package/dist/docx/serializeBlock.js +30 -0
  70. package/dist/docx/serializeParagraph.d.ts +15 -0
  71. package/dist/docx/serializeParagraph.js +208 -0
  72. package/dist/docx/serializeTable.d.ts +12 -0
  73. package/dist/docx/serializeTable.js +134 -0
  74. package/dist/docx/session.d.ts +81 -0
  75. package/dist/docx/session.js +79 -0
  76. package/dist/docx/tableFormatting/editing.d.ts +64 -0
  77. package/dist/docx/tableFormatting/editing.js +318 -0
  78. package/dist/docx/tableFormatting/reading.d.ts +96 -0
  79. package/dist/docx/tableFormatting/reading.js +221 -0
  80. package/dist/docx/tableFormatting.d.ts +2 -0
  81. package/dist/docx/tableFormatting.js +3 -0
  82. package/dist/docx/tableTemplate.d.ts +22 -0
  83. package/dist/docx/tableTemplate.js +111 -0
  84. package/dist/docx/theme.d.ts +40 -0
  85. package/dist/docx/theme.js +61 -0
  86. package/dist/docx/uniqueControls.d.ts +14 -0
  87. package/dist/docx/uniqueControls.js +62 -0
  88. package/dist/download.d.ts +57 -0
  89. package/dist/download.js +44 -0
  90. package/dist/editor/clipboard/images.d.ts +14 -0
  91. package/dist/editor/clipboard/images.js +158 -0
  92. package/dist/editor/clipboard/inlineFormatting.d.ts +21 -0
  93. package/dist/editor/clipboard/inlineFormatting.js +232 -0
  94. package/dist/editor/commands/breakCommands.d.ts +8 -0
  95. package/dist/editor/commands/breakCommands.js +19 -0
  96. package/dist/editor/commands/canRunCommand.d.ts +6 -0
  97. package/dist/editor/commands/canRunCommand.js +10 -0
  98. package/dist/editor/commands/commentCommands.d.ts +3 -0
  99. package/dist/editor/commands/commentCommands.js +4 -0
  100. package/dist/editor/commands/comments/editing.d.ts +21 -0
  101. package/dist/editor/commands/comments/editing.js +305 -0
  102. package/dist/editor/commands/comments/model.d.ts +31 -0
  103. package/dist/editor/commands/comments/model.js +0 -0
  104. package/dist/editor/commands/comments/reading.d.ts +8 -0
  105. package/dist/editor/commands/comments/reading.js +58 -0
  106. package/dist/editor/commands/formatting/editing.d.ts +32 -0
  107. package/dist/editor/commands/formatting/editing.js +138 -0
  108. package/dist/editor/commands/formatting/reading.d.ts +57 -0
  109. package/dist/editor/commands/formatting/reading.js +82 -0
  110. package/dist/editor/commands/formatting/shared.d.ts +32 -0
  111. package/dist/editor/commands/formatting/shared.js +53 -0
  112. package/dist/editor/commands/formattingCommands.d.ts +2 -0
  113. package/dist/editor/commands/formattingCommands.js +3 -0
  114. package/dist/editor/commands/historyCommands.d.ts +11 -0
  115. package/dist/editor/commands/historyCommands.js +16 -0
  116. package/dist/editor/commands/indentCommands.d.ts +15 -0
  117. package/dist/editor/commands/indentCommands.js +44 -0
  118. package/dist/editor/commands/index.d.ts +82 -0
  119. package/dist/editor/commands/index.js +171 -0
  120. package/dist/editor/commands/linkCommands.d.ts +56 -0
  121. package/dist/editor/commands/linkCommands.js +146 -0
  122. package/dist/editor/commands/listCommands.d.ts +58 -0
  123. package/dist/editor/commands/listCommands.js +140 -0
  124. package/dist/editor/commands/lockCommands.d.ts +47 -0
  125. package/dist/editor/commands/lockCommands.js +198 -0
  126. package/dist/editor/commands/noteQueries.d.ts +12 -0
  127. package/dist/editor/commands/noteQueries.js +29 -0
  128. package/dist/editor/commands/paragraphCommands.d.ts +59 -0
  129. package/dist/editor/commands/paragraphCommands.js +113 -0
  130. package/dist/editor/commands/spacingCommands.d.ts +23 -0
  131. package/dist/editor/commands/spacingCommands.js +48 -0
  132. package/dist/editor/commands/tabCommands.d.ts +5 -0
  133. package/dist/editor/commands/tabCommands.js +65 -0
  134. package/dist/editor/createEditor.d.ts +59 -0
  135. package/dist/editor/createEditor.js +160 -0
  136. package/dist/editor/documentStyles.d.ts +60 -0
  137. package/dist/editor/documentStyles.js +80 -0
  138. package/dist/editor/externalClipboard.d.ts +11 -0
  139. package/dist/editor/externalClipboard.js +323 -0
  140. package/dist/editor/imageFiles.d.ts +74 -0
  141. package/dist/editor/imageFiles.js +173 -0
  142. package/dist/editor/insertImage.d.ts +31 -0
  143. package/dist/editor/insertImage.js +35 -0
  144. package/dist/editor/insertTable.d.ts +18 -0
  145. package/dist/editor/insertTable.js +44 -0
  146. package/dist/editor/paragraphEdits.d.ts +42 -0
  147. package/dist/editor/paragraphEdits.js +59 -0
  148. package/dist/editor/plainText.d.ts +3 -0
  149. package/dist/editor/plainText.js +50 -0
  150. package/dist/editor/plugins/bookmarkProtection.d.ts +3 -0
  151. package/dist/editor/plugins/bookmarkProtection.js +28 -0
  152. package/dist/editor/plugins/columnResize.d.ts +27 -0
  153. package/dist/editor/plugins/columnResize.js +192 -0
  154. package/dist/editor/plugins/commentDecorations.d.ts +3 -0
  155. package/dist/editor/plugins/commentDecorations.js +23 -0
  156. package/dist/editor/plugins/commentReservations.d.ts +5 -0
  157. package/dist/editor/plugins/commentReservations.js +26 -0
  158. package/dist/editor/plugins/dropCaret.d.ts +10 -0
  159. package/dist/editor/plugins/dropCaret.js +11 -0
  160. package/dist/editor/plugins/imagePaste.d.ts +8 -0
  161. package/dist/editor/plugins/imagePaste.js +265 -0
  162. package/dist/editor/plugins/keymap.d.ts +5 -0
  163. package/dist/editor/plugins/keymap.js +94 -0
  164. package/dist/editor/plugins/linkPanel.d.ts +23 -0
  165. package/dist/editor/plugins/linkPanel.js +39 -0
  166. package/dist/editor/plugins/listInputRules.d.ts +14 -0
  167. package/dist/editor/plugins/listInputRules.js +36 -0
  168. package/dist/editor/plugins/lockedContent.d.ts +6 -0
  169. package/dist/editor/plugins/lockedContent.js +41 -0
  170. package/dist/editor/plugins/noteProtection.d.ts +3 -0
  171. package/dist/editor/plugins/noteProtection.js +25 -0
  172. package/dist/editor/plugins/numberingDecorations.d.ts +42 -0
  173. package/dist/editor/plugins/numberingDecorations.js +110 -0
  174. package/dist/editor/plugins/rowResize.d.ts +15 -0
  175. package/dist/editor/plugins/rowResize.js +196 -0
  176. package/dist/editor/plugins/styledParagraphs.d.ts +15 -0
  177. package/dist/editor/plugins/styledParagraphs.js +65 -0
  178. package/dist/editor/plugins/tabCaret.d.ts +3 -0
  179. package/dist/editor/plugins/tabCaret.js +126 -0
  180. package/dist/editor/plugins/tabDecorations.d.ts +11 -0
  181. package/dist/editor/plugins/tabDecorations.js +87 -0
  182. package/dist/editor/plugins/tabLayout.d.ts +16 -0
  183. package/dist/editor/plugins/tabLayout.js +328 -0
  184. package/dist/editor/plugins/tabPointer.d.ts +7 -0
  185. package/dist/editor/plugins/tabPointer.js +95 -0
  186. package/dist/editor/plugins/tableContextMenu.d.ts +21 -0
  187. package/dist/editor/plugins/tableContextMenu.js +88 -0
  188. package/dist/editor/plugins/textContextMenu.d.ts +15 -0
  189. package/dist/editor/plugins/textContextMenu.js +90 -0
  190. package/dist/editor/views/imageResize.d.ts +53 -0
  191. package/dist/editor/views/imageResize.js +167 -0
  192. package/dist/editor/views/runMarkView.d.ts +15 -0
  193. package/dist/editor/views/runMarkView.js +9 -0
  194. package/dist/editor/views/tableView.d.ts +24 -0
  195. package/dist/editor/views/tableView.js +32 -0
  196. package/dist/index.d.ts +44 -0
  197. package/dist/index.js +38 -0
  198. package/dist/model/format.d.ts +240 -0
  199. package/dist/model/format.js +305 -0
  200. package/dist/model/tabStops.d.ts +17 -0
  201. package/dist/model/tabStops.js +22 -0
  202. package/dist/numbering/listTemplate.d.ts +29 -0
  203. package/dist/numbering/listTemplate.js +83 -0
  204. package/dist/numbering/markers.d.ts +24 -0
  205. package/dist/numbering/markers.js +93 -0
  206. package/dist/numbering/parseNumbering.d.ts +65 -0
  207. package/dist/numbering/parseNumbering.js +116 -0
  208. package/dist/numbering/writeNumbering.d.ts +13 -0
  209. package/dist/numbering/writeNumbering.js +49 -0
  210. package/dist/ooxml/errors.d.ts +39 -0
  211. package/dist/ooxml/errors.js +21 -0
  212. package/dist/ooxml/image.d.ts +88 -0
  213. package/dist/ooxml/image.js +106 -0
  214. package/dist/ooxml/tabStops.d.ts +3 -0
  215. package/dist/ooxml/tabStops.js +51 -0
  216. package/dist/ooxml/units.d.ts +37 -0
  217. package/dist/ooxml/units.js +116 -0
  218. package/dist/ooxml/xml.d.ts +36 -0
  219. package/dist/ooxml/xml.js +89 -0
  220. package/dist/page/PageGuides.d.ts +16 -0
  221. package/dist/page/PageGuides.js +114 -0
  222. package/dist/page/measureBlocks.d.ts +25 -0
  223. package/dist/page/measureBlocks.js +80 -0
  224. package/dist/page/pageDecorations.d.ts +36 -0
  225. package/dist/page/pageDecorations.js +211 -0
  226. package/dist/page/pageLayout.d.ts +176 -0
  227. package/dist/page/pageLayout.js +157 -0
  228. package/dist/page/tableMeasurements.d.ts +10 -0
  229. package/dist/page/tableMeasurements.js +115 -0
  230. package/dist/page/usePageLayout.d.ts +57 -0
  231. package/dist/page/usePageLayout.js +141 -0
  232. package/dist/schema/docxSchema.d.ts +9 -0
  233. package/dist/schema/docxSchema.js +863 -0
  234. package/dist/schema/index.d.ts +2 -0
  235. package/dist/schema/index.js +9 -0
  236. package/dist/schema/locks.d.ts +112 -0
  237. package/dist/schema/locks.js +211 -0
  238. package/dist/schema/rendering.d.ts +6 -0
  239. package/dist/schema/rendering.js +46 -0
  240. package/dist/styles/classNames.d.ts +214 -0
  241. package/dist/styles/classNames.js +208 -0
  242. package/dist/styles/colors.d.ts +11 -0
  243. package/dist/styles/colors.js +14 -0
  244. package/dist/styles/fontSizes.d.ts +6 -0
  245. package/dist/styles/fontSizes.js +20 -0
  246. package/dist/styles/fontStack.d.ts +55 -0
  247. package/dist/styles/fontStack.js +262 -0
  248. package/dist/styles/fonts.d.ts +6 -0
  249. package/dist/styles/fonts.js +11 -0
  250. package/dist/styles/inlineStyle.d.ts +67 -0
  251. package/dist/styles/inlineStyle.js +212 -0
  252. package/dist/styles/lineSpacings.d.ts +11 -0
  253. package/dist/styles/lineSpacings.js +10 -0
  254. package/dist/styles.css +1650 -0
  255. package/dist/table/cellBorders.d.ts +12 -0
  256. package/dist/table/cellBorders.js +9 -0
  257. package/dist/table/cellFormatting.d.ts +57 -0
  258. package/dist/table/cellFormatting.js +173 -0
  259. package/dist/table/columns.d.ts +25 -0
  260. package/dist/table/columns.js +155 -0
  261. package/dist/table/commands.d.ts +19 -0
  262. package/dist/table/commands.js +63 -0
  263. package/dist/table/format.d.ts +35 -0
  264. package/dist/table/format.js +26 -0
  265. package/dist/table/gridBorders.d.ts +42 -0
  266. package/dist/table/gridBorders.js +192 -0
  267. package/dist/table/index.d.ts +16 -0
  268. package/dist/table/index.js +52 -0
  269. package/dist/table/merge.d.ts +36 -0
  270. package/dist/table/merge.js +125 -0
  271. package/dist/table/resize.d.ts +55 -0
  272. package/dist/table/resize.js +66 -0
  273. package/dist/table/rowResize.d.ts +14 -0
  274. package/dist/table/rowResize.js +44 -0
  275. package/dist/table/rows.d.ts +32 -0
  276. package/dist/table/rows.js +89 -0
  277. package/dist/table/widths.d.ts +69 -0
  278. package/dist/table/widths.js +97 -0
  279. package/dist/ui/AlignMenu.d.ts +15 -0
  280. package/dist/ui/AlignMenu.js +64 -0
  281. package/dist/ui/CellStyleGroup.d.ts +15 -0
  282. package/dist/ui/CellStyleGroup.js +232 -0
  283. package/dist/ui/ColorPicker.d.ts +13 -0
  284. package/dist/ui/ColorPicker.js +165 -0
  285. package/dist/ui/CommentsPanel.d.ts +15 -0
  286. package/dist/ui/CommentsPanel.js +348 -0
  287. package/dist/ui/FontFamilySelect.d.ts +14 -0
  288. package/dist/ui/FontFamilySelect.js +59 -0
  289. package/dist/ui/FontSizeSelect.d.ts +11 -0
  290. package/dist/ui/FontSizeSelect.js +49 -0
  291. package/dist/ui/InsertImageButton.d.ts +9 -0
  292. package/dist/ui/InsertImageButton.js +47 -0
  293. package/dist/ui/LinkCard.d.ts +12 -0
  294. package/dist/ui/LinkCard.js +127 -0
  295. package/dist/ui/LinkPanel.d.ts +9 -0
  296. package/dist/ui/LinkPanel.js +121 -0
  297. package/dist/ui/MenuChoice.d.ts +11 -0
  298. package/dist/ui/MenuChoice.js +32 -0
  299. package/dist/ui/NotesPanel.d.ts +6 -0
  300. package/dist/ui/NotesPanel.js +33 -0
  301. package/dist/ui/ParagraphStyleSelect.d.ts +11 -0
  302. package/dist/ui/ParagraphStyleSelect.js +62 -0
  303. package/dist/ui/Popover.d.ts +22 -0
  304. package/dist/ui/Popover.js +74 -0
  305. package/dist/ui/SpacingMenu.d.ts +12 -0
  306. package/dist/ui/SpacingMenu.js +54 -0
  307. package/dist/ui/TableMenu.d.ts +12 -0
  308. package/dist/ui/TableMenu.js +112 -0
  309. package/dist/ui/TableSizePicker.d.ts +9 -0
  310. package/dist/ui/TableSizePicker.js +53 -0
  311. package/dist/ui/TextMenu.d.ts +15 -0
  312. package/dist/ui/TextMenu.js +194 -0
  313. package/dist/ui/Toolbar.d.ts +19 -0
  314. package/dist/ui/Toolbar.js +448 -0
  315. package/dist/ui/ToolbarButton.d.ts +23 -0
  316. package/dist/ui/ToolbarButton.js +56 -0
  317. package/dist/ui/Tooltip.d.ts +19 -0
  318. package/dist/ui/Tooltip.js +47 -0
  319. package/dist/ui/ZoomSelect.d.ts +7 -0
  320. package/dist/ui/ZoomSelect.js +44 -0
  321. package/dist/ui/comments/CommentComposer.d.ts +17 -0
  322. package/dist/ui/comments/CommentComposer.js +59 -0
  323. package/dist/ui/comments/useCommentRailLayout.d.ts +18 -0
  324. package/dist/ui/comments/useCommentRailLayout.js +183 -0
  325. package/dist/ui/keyboardWalk.d.ts +22 -0
  326. package/dist/ui/keyboardWalk.js +70 -0
  327. package/dist/ui/openAddress.d.ts +11 -0
  328. package/dist/ui/openAddress.js +16 -0
  329. package/dist/ui/panelPlacement.d.ts +51 -0
  330. package/dist/ui/panelPlacement.js +71 -0
  331. package/dist/ui/presets.d.ts +11 -0
  332. package/dist/ui/presets.js +0 -0
  333. package/dist/ui/rovingFocus.d.ts +20 -0
  334. package/dist/ui/rovingFocus.js +61 -0
  335. package/dist/ui/runCommand.d.ts +5 -0
  336. package/dist/ui/runCommand.js +13 -0
  337. package/dist/ui/useDismiss.d.ts +6 -0
  338. package/dist/ui/useDismiss.js +31 -0
  339. package/dist/ui/useFitWidthZoom.d.ts +2 -0
  340. package/dist/ui/useFitWidthZoom.js +26 -0
  341. package/dist/ui/useGridKeyboard.d.ts +12 -0
  342. package/dist/ui/useGridKeyboard.js +90 -0
  343. package/dist/ui/useMenuKeyboard.d.ts +12 -0
  344. package/dist/ui/useMenuKeyboard.js +56 -0
  345. package/dist/ui/zoom.d.ts +4 -0
  346. package/dist/ui/zoom.js +21 -0
  347. package/package.json +120 -0
@@ -0,0 +1,163 @@
1
+ // src/docx/exportDocx.ts
2
+ import { toParagraphFormat } from "../model/format.js";
3
+ import { parseNumbering } from "../numbering/parseNumbering.js";
4
+ import { addListDefinitions } from "../numbering/writeNumbering.js";
5
+ import { DocxExportError } from "../ooxml/errors.js";
6
+ import { decodeUtf8, encodeUtf8, parseXml, W_NS } from "../ooxml/xml.js";
7
+ import { planCommentParts } from "./comments.js";
8
+ import { repackParts } from "./container.js";
9
+ import { hyperlinkRefs } from "./hyperlink.js";
10
+ import { NO_IMAGE_REFS, planImageMedia } from "./media.js";
11
+ import {
12
+ readRelationships,
13
+ relationshipWriter,
14
+ relsPathOf
15
+ } from "./relationships.js";
16
+ import { serializeBlock } from "./serializeBlock.js";
17
+ import {
18
+ originalBlock,
19
+ sessionOf
20
+ } from "./session.js";
21
+ import { withUniqueControls } from "./uniqueControls.js";
22
+ function blockXml(node, session, refs) {
23
+ const imported = originalBlock(node, session);
24
+ if (imported && node.eq(imported.node)) return imported.xml;
25
+ return serializeBlock(node, session, refs);
26
+ }
27
+ function buildDocumentXml(doc, session, refs) {
28
+ const pieces = [session.documentPrefix];
29
+ withUniqueControls(doc).forEach((child) => {
30
+ pieces.push(blockXml(child, session, refs));
31
+ });
32
+ pieces.push(session.documentSuffix);
33
+ return pieces.join("");
34
+ }
35
+ function localAttribute(el, name) {
36
+ return Array.from(el.attributes).find((attribute) => attribute.localName === name)?.value ?? null;
37
+ }
38
+ function assertBookmarkPairs(documentXml) {
39
+ let root;
40
+ try {
41
+ root = parseXml(documentXml).documentElement;
42
+ } catch (cause) {
43
+ throw new DocxExportError(
44
+ "malformed-xml",
45
+ "the exported main document XML could not be parsed",
46
+ { cause }
47
+ );
48
+ }
49
+ const open = /* @__PURE__ */ new Set();
50
+ const used = /* @__PURE__ */ new Set();
51
+ for (const element of root.getElementsByTagName("*")) {
52
+ if (element.namespaceURI !== W_NS) continue;
53
+ if (element.localName !== "bookmarkStart" && element.localName !== "bookmarkEnd") {
54
+ continue;
55
+ }
56
+ const id = localAttribute(element, "id");
57
+ if (id === null) {
58
+ throw new DocxExportError(
59
+ "malformed-xml",
60
+ `a ${element.localName} has no id`
61
+ );
62
+ }
63
+ if (element.localName === "bookmarkStart") {
64
+ if (used.has(id)) {
65
+ throw new DocxExportError(
66
+ "malformed-xml",
67
+ `bookmark ${id} has more than one start marker`
68
+ );
69
+ }
70
+ open.add(id);
71
+ used.add(id);
72
+ } else if (!open.delete(id)) {
73
+ throw new DocxExportError(
74
+ "malformed-xml",
75
+ `bookmark ${id} ends without an earlier start marker`
76
+ );
77
+ }
78
+ }
79
+ const missingEnd = open.values().next().value;
80
+ if (missingEnd !== void 0) {
81
+ throw new DocxExportError(
82
+ "malformed-xml",
83
+ `bookmark ${missingEnd} has no end marker`
84
+ );
85
+ }
86
+ }
87
+ function collectNumIds(node, into) {
88
+ const visit = (candidate) => {
89
+ if (candidate.type.name !== "paragraph") return true;
90
+ const numId = toParagraphFormat(candidate.attrs.format)?.numbering?.numId;
91
+ if (numId !== void 0) into.add(numId);
92
+ return false;
93
+ };
94
+ if (visit(node)) node.descendants(visit);
95
+ }
96
+ function numIdsIn(node) {
97
+ const used = /* @__PURE__ */ new Set();
98
+ collectNumIds(node, used);
99
+ return used;
100
+ }
101
+ function numIdsAtOpen(session) {
102
+ const used = /* @__PURE__ */ new Set();
103
+ for (const block of session.blocks) collectNumIds(block.node, used);
104
+ return used;
105
+ }
106
+ function newNumIds(doc, session) {
107
+ const defined = parseNumbering(session.numberingXml).lists;
108
+ const atOpen = numIdsAtOpen(session);
109
+ return Array.from(numIdsIn(doc)).filter((numId) => !defined.has(numId) && !atOpen.has(numId)).sort((a, b) => a - b);
110
+ }
111
+ function newNumberingPart(doc, session) {
112
+ const added = newNumIds(doc, session);
113
+ if (added.length === 0) return null;
114
+ const path = session.numberingPartPath;
115
+ const original = path === null ? void 0 : session.parts.get(path);
116
+ if (path === null || original === void 0) {
117
+ throw new DocxExportError(
118
+ "missing-numbering-part",
119
+ "cannot add a new list to a document that has no numbering.xml"
120
+ );
121
+ }
122
+ const { text, hadBom } = decodeUtf8(original);
123
+ return {
124
+ path,
125
+ bytes: encodeUtf8(addListDefinitions(text, added), hadBom)
126
+ };
127
+ }
128
+ function exportDocx(doc, session) {
129
+ const store = sessionOf(session);
130
+ const relsPath = relsPathOf(store.mainPartPath);
131
+ const relationships = relationshipWriter(
132
+ readRelationships(store.parts, relsPath)
133
+ );
134
+ const media = planImageMedia(doc, store, relationships);
135
+ const comments = planCommentParts(
136
+ doc,
137
+ store,
138
+ relationships,
139
+ media?.parts.get("[Content_Types].xml")
140
+ );
141
+ const documentXml = buildDocumentXml(doc, store, {
142
+ images: media?.refs ?? NO_IMAGE_REFS,
143
+ links: hyperlinkRefs(relationships)
144
+ });
145
+ assertBookmarkPairs(documentXml);
146
+ const replacements = /* @__PURE__ */ new Map([
147
+ [store.mainPartPath, encodeUtf8(documentXml, store.documentHadBom)]
148
+ ]);
149
+ const numbering = newNumberingPart(doc, store);
150
+ if (numbering) replacements.set(numbering.path, numbering.bytes);
151
+ for (const [path, bytes] of media?.parts ?? []) {
152
+ replacements.set(path, bytes);
153
+ }
154
+ for (const [path, bytes] of comments?.parts ?? []) {
155
+ replacements.set(path, bytes);
156
+ }
157
+ const rels = relationships.part(store.parts.get(relsPath));
158
+ if (rels) replacements.set(relsPath, rels);
159
+ return repackParts(store.parts, replacements);
160
+ }
161
+ export {
162
+ exportDocx
163
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What the serializers need from the rest of the package while a body is being written: which
3
+ * relationship an inserted image ended up on (`docx/media`), and which one each link's address
4
+ * lives on (`docx/hyperlink`).
5
+ *
6
+ * They travel as one value so that a serializer taking a body apart passes on everything the
7
+ * pieces of it may need, whatever a later kind of content turns out to require.
8
+ */
9
+ import { type LinkRefs } from "./hyperlink";
10
+ import { type ImageRefs } from "./media";
11
+ export interface ExportRefs {
12
+ images: ImageRefs;
13
+ links: LinkRefs;
14
+ }
15
+ /** What a serializer called on its own, outside an export, has to work with */
16
+ export declare const NO_EXPORT_REFS: ExportRefs;
@@ -0,0 +1,10 @@
1
+ // src/docx/exportRefs.ts
2
+ import { NO_LINK_REFS } from "./hyperlink.js";
3
+ import { NO_IMAGE_REFS } from "./media.js";
4
+ var NO_EXPORT_REFS = {
5
+ images: NO_IMAGE_REFS,
6
+ links: NO_LINK_REFS
7
+ };
8
+ export {
9
+ NO_EXPORT_REFS
10
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Reads direct formatting XML into display values.
3
+ *
4
+ * The values produced here are used for display only.
5
+ * What goes back into the document is always the original XML string, so no matter what is read
6
+ * here, export is undisturbed.
7
+ */
8
+ import { type DocumentDefaults, type LineSpacing, type RunFormat } from "../../model/format";
9
+ import { type ThemeFonts } from "../theme";
10
+ import type { ParagraphFormatLayer } from "./tabStops";
11
+ /**
12
+ * The font names held in a display value.
13
+ * Splits the CSS name list `fontFamilyOf` produced back into individual names.
14
+ */
15
+ export declare function fontNamesOf(cssNames: string | undefined | null): string[];
16
+ /**
17
+ * The line spacing from `w:spacing`.
18
+ * auto means a multiple in 240ths, and the rest are heights pinned down in twips.
19
+ */
20
+ export declare function readLineSpacing(pPr: Element): LineSpacing | null;
21
+ export declare function readParagraphFormat(pPr: Element | null): ParagraphFormatLayer | null;
22
+ export declare function readRunFormat(rPr: Element | null, themeFonts?: ThemeFonts): RunFormat | null;
23
+ export declare const NO_DOCUMENT_DEFAULTS: DocumentDefaults;
24
+ /** Reads the paragraph-property layer at the base of the OOXML hierarchy. */
25
+ export declare function readDefaultParagraphFormat(styles: Document): ParagraphFormatLayer;
26
+ /**
27
+ * Reads the document default font size, font, and line spacing from docDefaults in styles.xml.
28
+ * What is absent is left as null, and the on-screen fallback is decided by the display layer.
29
+ */
30
+ export declare function readDocumentDefaults(styles: Document, themeFonts?: ThemeFonts): DocumentDefaults;
@@ -0,0 +1,201 @@
1
+ // src/docx/formatting/direct.ts
2
+ import {
3
+ isHighlightName,
4
+ isUnderlineKind
5
+ } from "../../model/format.js";
6
+ import { readTabStopDirectives } from "../../ooxml/tabStops.js";
7
+ import {
8
+ ALIGN_BY_JC,
9
+ borderSide,
10
+ childValue,
11
+ halfPointsToPt,
12
+ isOn,
13
+ round,
14
+ shadingOf,
15
+ toHexColor,
16
+ toNumber,
17
+ twipsToPt,
18
+ wAttr
19
+ } from "../../ooxml/units.js";
20
+ import { childByLocalName } from "../../ooxml/xml.js";
21
+ import {
22
+ NO_THEME_FONTS,
23
+ THEME_ATTRS,
24
+ themeFontName
25
+ } from "../theme.js";
26
+ var VERTICAL_ALIGN_BY_VAL = {
27
+ superscript: "superscript",
28
+ subscript: "subscript"
29
+ };
30
+ function fontNamesOf(cssNames) {
31
+ if (!cssNames) return [];
32
+ return cssNames.split(",").map((name) => name.trim().replace(/^"|"$/g, "")).filter((name) => name.length > 0);
33
+ }
34
+ var FONT_SLOTS = ["ascii", "eastAsia", "hAnsi", "cs"];
35
+ function slotFontName(rFonts, slot, themeFonts) {
36
+ const written = wAttr(rFonts, slot);
37
+ if (written !== null) return written;
38
+ for (const attr of THEME_ATTRS[slot] ?? []) {
39
+ const resolved = themeFontName(themeFonts, wAttr(rFonts, attr));
40
+ if (resolved !== null) return resolved;
41
+ }
42
+ return null;
43
+ }
44
+ function fontFamilyOf(rFonts, themeFonts) {
45
+ const names = FONT_SLOTS.map((slot) => slotFontName(rFonts, slot, themeFonts)).filter((name) => name !== null).filter((name) => name.length > 0 && !/["';\\]/.test(name));
46
+ const unique = Array.from(new Set(names));
47
+ return unique.length > 0 ? unique.map((name) => `"${name}"`).join(",") : null;
48
+ }
49
+ function langOf(rPr) {
50
+ const lang = childByLocalName(rPr, "lang");
51
+ if (!lang) return null;
52
+ const eastAsia = wAttr(lang, "eastAsia");
53
+ if (eastAsia !== null && eastAsia.length > 0) return eastAsia;
54
+ const value = wAttr(lang, "val");
55
+ return value !== null && value.length > 0 ? value : null;
56
+ }
57
+ function drawnBorder(pBdr, side) {
58
+ const css = borderSide(pBdr, side);
59
+ return css === "none" ? null : css;
60
+ }
61
+ function readBorders(pPr) {
62
+ const pBdr = childByLocalName(pPr, "pBdr");
63
+ if (!pBdr) return {};
64
+ const format = {};
65
+ const top = drawnBorder(pBdr, "top");
66
+ if (top) format.borderTop = top;
67
+ const bottom = drawnBorder(pBdr, "bottom");
68
+ if (bottom) format.borderBottom = bottom;
69
+ const left = drawnBorder(pBdr, "left");
70
+ if (left) format.borderLeft = left;
71
+ const right = drawnBorder(pBdr, "right");
72
+ if (right) format.borderRight = right;
73
+ return format;
74
+ }
75
+ function readIndent(pPr) {
76
+ const ind = childByLocalName(pPr, "ind");
77
+ if (!ind) return {};
78
+ const format = {};
79
+ const start = twipsToPt(wAttr(ind, "start") ?? wAttr(ind, "left"));
80
+ if (start !== null) format.indentStartPt = start;
81
+ const end = twipsToPt(wAttr(ind, "end") ?? wAttr(ind, "right"));
82
+ if (end !== null) format.indentEndPt = end;
83
+ const hanging = twipsToPt(wAttr(ind, "hanging"));
84
+ const firstLine = twipsToPt(wAttr(ind, "firstLine"));
85
+ if (hanging !== null) format.textIndentPt = -hanging;
86
+ else if (firstLine !== null) format.textIndentPt = firstLine;
87
+ return format;
88
+ }
89
+ function readLineSpacing(pPr) {
90
+ const spacing = childByLocalName(pPr, "spacing");
91
+ if (!spacing) return null;
92
+ const line = toNumber(wAttr(spacing, "line"));
93
+ if (line === null) return null;
94
+ const rule = wAttr(spacing, "lineRule");
95
+ if (rule === "exact") return { rule: "exact", pt: round(line / 20) };
96
+ if (rule === "atLeast") return { rule: "atLeast", pt: round(line / 20) };
97
+ return { rule: "auto", lines: round(line / 240) };
98
+ }
99
+ function readSpacing(pPr) {
100
+ const spacing = childByLocalName(pPr, "spacing");
101
+ if (!spacing) return {};
102
+ const format = {};
103
+ const before = twipsToPt(wAttr(spacing, "before"));
104
+ if (before !== null) format.spaceBeforePt = before;
105
+ const after = twipsToPt(wAttr(spacing, "after"));
106
+ if (after !== null) format.spaceAfterPt = after;
107
+ const lineSpacing = readLineSpacing(pPr);
108
+ if (lineSpacing) format.lineSpacing = lineSpacing;
109
+ return format;
110
+ }
111
+ function readNumbering(pPr) {
112
+ const numPr = childByLocalName(pPr, "numPr");
113
+ if (!numPr) return {};
114
+ const numId = toNumber(childValue(numPr, "numId"));
115
+ if (numId === 0) return { numbering: null };
116
+ if (numId === null || numId < 0) return {};
117
+ return {
118
+ numbering: {
119
+ numId: Math.trunc(numId),
120
+ ilvl: Math.trunc(toNumber(childValue(numPr, "ilvl")) ?? 0)
121
+ }
122
+ };
123
+ }
124
+ function readParagraphFormat(pPr) {
125
+ if (!pPr) return null;
126
+ const format = {
127
+ ...readIndent(pPr),
128
+ ...readSpacing(pPr),
129
+ ...readNumbering(pPr),
130
+ ...readBorders(pPr)
131
+ };
132
+ const tabStops = readTabStopDirectives(pPr);
133
+ if (tabStops.length > 0) format.tabStops = tabStops;
134
+ const align = ALIGN_BY_JC[childValue(pPr, "jc") ?? ""];
135
+ if (align) format.align = align;
136
+ if (childByLocalName(pPr, "bidi")) {
137
+ format.direction = isOn(pPr, "bidi") ? "rtl" : "ltr";
138
+ }
139
+ if (isOn(pPr, "pageBreakBefore")) format.pageBreakBefore = true;
140
+ const background = shadingOf(pPr);
141
+ if (background) format.background = background;
142
+ return format;
143
+ }
144
+ function readRunFormat(rPr, themeFonts = NO_THEME_FONTS) {
145
+ if (!rPr) return null;
146
+ const format = {};
147
+ if (isOn(rPr, "b")) format.bold = true;
148
+ if (isOn(rPr, "i")) format.italic = true;
149
+ if (isOn(rPr, "strike")) format.strike = true;
150
+ if (isOn(rPr, "smallCaps")) format.smallCaps = true;
151
+ const underline = childValue(rPr, "u");
152
+ if (isUnderlineKind(underline)) format.underline = underline;
153
+ const fontSizePt = halfPointsToPt(childValue(rPr, "sz"));
154
+ if (fontSizePt !== null) format.fontSizePt = fontSizePt;
155
+ const rFonts = childByLocalName(rPr, "rFonts");
156
+ const fontFamily = rFonts ? fontFamilyOf(rFonts, themeFonts) : null;
157
+ if (fontFamily) format.fontFamily = fontFamily;
158
+ const color = toHexColor(childValue(rPr, "color"));
159
+ if (color) format.color = color;
160
+ const highlight = childValue(rPr, "highlight");
161
+ if (isHighlightName(highlight)) format.highlight = highlight;
162
+ const background = shadingOf(rPr);
163
+ if (background) format.background = background;
164
+ const verticalAlign = VERTICAL_ALIGN_BY_VAL[childValue(rPr, "vertAlign") ?? ""];
165
+ if (verticalAlign) format.verticalAlign = verticalAlign;
166
+ const lang = langOf(rPr);
167
+ if (lang) format.lang = lang;
168
+ return format;
169
+ }
170
+ var NO_DOCUMENT_DEFAULTS = {
171
+ fontSizePt: null,
172
+ fontFamily: null,
173
+ lineSpacing: null
174
+ };
175
+ function defaultProperties(styles, slot, name) {
176
+ const docDefaults = childByLocalName(styles.documentElement, "docDefaults");
177
+ const wrapper = docDefaults ? childByLocalName(docDefaults, slot) : null;
178
+ return wrapper ? childByLocalName(wrapper, name) : null;
179
+ }
180
+ function readDefaultParagraphFormat(styles) {
181
+ return readParagraphFormat(defaultProperties(styles, "pPrDefault", "pPr")) ?? {};
182
+ }
183
+ function readDocumentDefaults(styles, themeFonts = NO_THEME_FONTS) {
184
+ const rPr = defaultProperties(styles, "rPrDefault", "rPr");
185
+ const pPr = defaultProperties(styles, "pPrDefault", "pPr");
186
+ const rFonts = rPr ? childByLocalName(rPr, "rFonts") : null;
187
+ return {
188
+ fontSizePt: rPr ? halfPointsToPt(childValue(rPr, "sz")) : null,
189
+ fontFamily: rFonts ? fontFamilyOf(rFonts, themeFonts) : null,
190
+ lineSpacing: pPr ? readLineSpacing(pPr) : null
191
+ };
192
+ }
193
+ export {
194
+ NO_DOCUMENT_DEFAULTS,
195
+ fontNamesOf,
196
+ readDefaultParagraphFormat,
197
+ readDocumentDefaults,
198
+ readLineSpacing,
199
+ readParagraphFormat,
200
+ readRunFormat
201
+ };
@@ -0,0 +1,15 @@
1
+ import { type ParagraphFormat } from "../../model/format";
2
+ import { type Numbering } from "../../numbering/parseNumbering";
3
+ import { type StyleFormat, type StyleTable } from "./styles";
4
+ import { type ParagraphFormatLayer } from "./tabStops";
5
+ export interface ParagraphFormattingContext {
6
+ styles: StyleTable;
7
+ defaultStyleId: string | null;
8
+ defaults: ParagraphFormatLayer;
9
+ numbering: Numbering;
10
+ }
11
+ export declare const NO_PARAGRAPH_FORMATTING: ParagraphFormattingContext;
12
+ /** Resolves the effective OOXML paragraph-property hierarchy for display. */
13
+ export declare function effectiveParagraphFormat(pPr: unknown, context: ParagraphFormattingContext): ParagraphFormat | null;
14
+ /** Resolves the run properties supplied by the paragraph style. */
15
+ export declare function effectiveParagraphStyle(pPr: unknown, context: ParagraphFormattingContext): StyleFormat | undefined;
@@ -0,0 +1,81 @@
1
+ // src/docx/formatting/effectiveParagraph.ts
2
+ import { toParagraphFormat } from "../../model/format.js";
3
+ import { mergeTabStops } from "../../model/tabStops.js";
4
+ import {
5
+ EMPTY_NUMBERING,
6
+ levelIndentPt
7
+ } from "../../numbering/parseNumbering.js";
8
+ import { parsePropsXml } from "../propsXml.js";
9
+ import { readParagraphFormat } from "./direct.js";
10
+ import {
11
+ paragraphStyleFormat
12
+ } from "./styles.js";
13
+ import { layerParagraphValues } from "./tabStops.js";
14
+ var NO_PARAGRAPH_FORMATTING = {
15
+ styles: /* @__PURE__ */ new Map(),
16
+ defaultStyleId: null,
17
+ defaults: {},
18
+ numbering: EMPTY_NUMBERING
19
+ };
20
+ function numberingRef(defaults, style, direct) {
21
+ let value = defaults.numbering;
22
+ if (style.numbering !== void 0) value = style.numbering;
23
+ if (direct.numbering !== void 0) value = direct.numbering;
24
+ return value;
25
+ }
26
+ function numberingLayer(ref, numbering) {
27
+ if (!ref) return {};
28
+ const level = numbering.lists.get(ref.numId)?.levels.get(ref.ilvl);
29
+ if (!level) return {};
30
+ const indent = levelIndentPt(level.indent);
31
+ const leadingIndentPt = indent.startPt;
32
+ const implicitHangingStop = leadingIndentPt !== null && indent.textIndentPt !== null && indent.textIndentPt < 0 ? [{ positionPt: leadingIndentPt, align: "start" }] : [];
33
+ return {
34
+ tabStops: [...implicitHangingStop, ...level.tabStops ?? []]
35
+ };
36
+ }
37
+ function withImplicitHangingStop(format) {
38
+ const leadingIndentPt = format?.indentStartPt ?? format?.indentLeftPt;
39
+ if (format?.textIndentPt === void 0 || format.textIndentPt >= 0 || leadingIndentPt === void 0) {
40
+ return format;
41
+ }
42
+ const implicit = {
43
+ positionPt: leadingIndentPt,
44
+ align: "start"
45
+ };
46
+ return {
47
+ ...format,
48
+ tabStops: mergeTabStops([implicit], format.tabStops ?? [])
49
+ };
50
+ }
51
+ function directLayer(pPr) {
52
+ if (typeof pPr !== "string") return {};
53
+ return readParagraphFormat(parsePropsXml(pPr)) ?? {};
54
+ }
55
+ function styleFor(pPr, context) {
56
+ return paragraphStyleFormat(pPr, context.styles, context.defaultStyleId);
57
+ }
58
+ function effectiveParagraphFormat(pPr, context) {
59
+ const direct = directLayer(pPr);
60
+ const style = styleFor(pPr, context)?.paragraph ?? {};
61
+ const level = numberingLayer(
62
+ numberingRef(context.defaults, style, direct),
63
+ context.numbering
64
+ );
65
+ const layered = [level, style, direct].reduce(
66
+ layerParagraphValues,
67
+ context.defaults
68
+ );
69
+ const format = toParagraphFormat(layered);
70
+ return withImplicitHangingStop(
71
+ format !== null && Object.keys(format).length === 0 ? null : format
72
+ );
73
+ }
74
+ function effectiveParagraphStyle(pPr, context) {
75
+ return styleFor(pPr, context);
76
+ }
77
+ export {
78
+ NO_PARAGRAPH_FORMATTING,
79
+ effectiveParagraphFormat,
80
+ effectiveParagraphStyle
81
+ };
@@ -0,0 +1,67 @@
1
+ /** Reads and layers styles.xml values used by the display model. */
2
+ import { type CellMargins, type InsideBorders, type ParagraphFormat, type RunFormat, type TableFormat } from "../../model/format";
3
+ import { type ThemeFonts } from "../theme";
4
+ import { type ParagraphFormatLayer } from "./tabStops";
5
+ /** The display values one style passes down to paragraphs, to text, and to tables */
6
+ export interface StyleFormat {
7
+ paragraph: ParagraphFormatLayer;
8
+ run: RunFormat;
9
+ table: TableFormat;
10
+ /** The lines between cells the style laid down. A side it says nothing about is null */
11
+ tableInside: InsideBorders;
12
+ /** The cell margins the style laid down. A side it says nothing about is null */
13
+ tableCellMargins: CellMargins;
14
+ }
15
+ /** A table looked up by style name. The `basedOn` chain has already been layered into the values */
16
+ export type StyleTable = ReadonlyMap<string, StyleFormat>;
17
+ export declare const NO_STYLES: StyleTable;
18
+ /**
19
+ * Reads the style chain from styles.xml into effective values for display.
20
+ *
21
+ * A style name is unique across all kinds (paragraph, character, table), so we take them in
22
+ * without telling the kinds apart.
23
+ * The names a paragraph points at are only ever paragraph styles, so the other kinds are never looked up.
24
+ */
25
+ export declare function readStyles(styles: Document, themeFonts?: ThemeFonts): StyleTable;
26
+ /**
27
+ * The default table style, which for most documents is where a plain table gets its cell margins
28
+ * and its lines from
29
+ */
30
+ export declare function defaultTableStyleIdOf(styles: Document): string | null;
31
+ /** The default paragraph style (usually Normal), which every paragraph with no `w:pStyle` wears */
32
+ export declare function defaultParagraphStyleIdOf(styles: Document): string | null;
33
+ /** One paragraph style the document defines, as the style picker shows it */
34
+ export interface ParagraphStyleOption {
35
+ id: string;
36
+ /** The display name `w:name` states. Falls back on the id */
37
+ name: string;
38
+ /** Set on the one style the document marked `w:default="1"`, which a paragraph with no pStyle already wears */
39
+ isDefault: boolean;
40
+ /** Set on a primary style (`w:qFormat`) intended for a prominent style gallery */
41
+ primary: boolean;
42
+ /** Set on a style Word keeps out of its own gallery */
43
+ hidden: boolean;
44
+ }
45
+ /**
46
+ * The paragraph styles a document defines, in the order styles.xml lists them.
47
+ *
48
+ * The latent styles a document carries around without using them (`w:semiHidden`, `w:hidden`) come
49
+ * along all the same, flagged as hidden, because a paragraph can still point at one and then its
50
+ * `w:name` is the only name there is to show for it.
51
+ * Where several styles claim to be the default, only the last one is marked, the same rule
52
+ * `defaultParagraphStyleIdOf` reads them by.
53
+ */
54
+ export declare function readParagraphStyles(styles: Document): ParagraphStyleOption[];
55
+ /** The style name the paragraph formatting XML points at. null if it points at none */
56
+ export declare function styleIdOf(pPr: unknown): string | null;
57
+ /**
58
+ * The values the style a paragraph wears lays down.
59
+ *
60
+ * That is the style its `w:pStyle` names, and for a paragraph naming none, the document's default
61
+ * paragraph style: OOXML applies that one to every paragraph that points at no style of its own.
62
+ */
63
+ export declare function paragraphStyleFormat(pPr: unknown, styles: StyleTable, defaultStyleId?: string | null): StyleFormat | undefined;
64
+ /** Lays direct formatting on top of the values the style laid down. What the paragraph wrote down always wins */
65
+ export declare function layerParagraphFormat(style: ParagraphFormatLayer, direct: ParagraphFormatLayer | null): ParagraphFormat | null;
66
+ export declare function layerRunFormat(style: RunFormat, direct: RunFormat | null): RunFormat | null;
67
+ export declare function layerTableFormat(style: TableFormat, direct: TableFormat | null): TableFormat | null;