office-viewer 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/README.md +7 -2
  2. package/esm/OpenXML.d.ts +19 -0
  3. package/esm/OpenXML.js +43 -2
  4. package/esm/Word.d.ts +132 -15
  5. package/esm/Word.js +233 -54
  6. package/esm/openxml/ContentType.js +20 -6
  7. package/esm/openxml/Settings.d.ts +10 -0
  8. package/esm/openxml/Settings.js +93 -0
  9. package/esm/openxml/Style.d.ts +1 -1
  10. package/esm/openxml/Style.js +12 -12
  11. package/esm/openxml/Theme.js +30 -6
  12. package/esm/openxml/Types.d.ts +179 -2472
  13. package/esm/openxml/drawing/Blip.d.ts +7 -0
  14. package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
  15. package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
  16. package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  17. package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
  18. package/esm/openxml/drawing/CustomGeom.js +17 -0
  19. package/esm/openxml/drawing/Drawing.d.ts +35 -0
  20. package/esm/openxml/drawing/Drawing.js +169 -0
  21. package/esm/openxml/drawing/Geom.d.ts +11 -0
  22. package/esm/openxml/drawing/Geom.js +34 -0
  23. package/esm/openxml/drawing/Path.d.ts +37 -0
  24. package/esm/openxml/drawing/Pic.d.ts +16 -0
  25. package/esm/openxml/drawing/Pic.js +26 -0
  26. package/esm/openxml/drawing/Shape.d.ts +20 -0
  27. package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
  28. package/esm/openxml/drawing/ShapeProperties.js +119 -0
  29. package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +2 -1
  30. package/esm/openxml/{word/drawing → drawing}/Transform.js +7 -3
  31. package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
  32. package/esm/openxml/drawing/diagram/Diagram.js +24 -0
  33. package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
  34. package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
  35. package/esm/openxml/drawing/presetShape.d.ts +3 -0
  36. package/esm/openxml/drawing/presetShape.js +38785 -0
  37. package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
  38. package/esm/openxml/drawing/svg/arcToA.js +88 -0
  39. package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
  40. package/esm/openxml/drawing/svg/formulas.js +103 -0
  41. package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
  42. package/esm/openxml/drawing/svg/generateDefines.js +144 -0
  43. package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
  44. package/esm/openxml/drawing/svg/presetVal.js +53 -0
  45. package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  46. package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
  47. package/esm/openxml/math/OMath.d.ts +5 -0
  48. package/esm/openxml/math/OMath.js +12 -0
  49. package/esm/openxml/math/convertOOML.d.ts +4 -0
  50. package/esm/openxml/math/convertOOML.js +13 -0
  51. package/esm/openxml/math/xsl.d.ts +4 -0
  52. package/esm/openxml/math/xsl.js +8 -0
  53. package/esm/openxml/word/Body.js +11 -7
  54. package/esm/openxml/word/Break.js +1 -3
  55. package/esm/openxml/word/Font.d.ts +16 -0
  56. package/esm/openxml/word/Font.js +78 -0
  57. package/esm/openxml/word/FontTable.d.ts +9 -0
  58. package/esm/openxml/word/FontTable.js +34 -0
  59. package/esm/openxml/word/Header.d.ts +11 -0
  60. package/esm/openxml/word/Header.js +54 -0
  61. package/esm/openxml/word/Hyperlink.d.ts +1 -0
  62. package/esm/openxml/word/Hyperlink.js +7 -3
  63. package/esm/openxml/word/InlineText.js +1 -1
  64. package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
  65. package/esm/openxml/word/NoBreakHyphen.js +7 -0
  66. package/esm/openxml/word/Note.d.ts +12 -0
  67. package/esm/openxml/word/Note.js +48 -0
  68. package/esm/openxml/word/Paragraph.d.ts +2 -2
  69. package/esm/openxml/word/Paragraph.js +10 -9
  70. package/esm/openxml/word/Pict.d.ts +1 -2
  71. package/esm/openxml/word/Pict.js +5 -3
  72. package/esm/openxml/word/Ruby.js +1 -1
  73. package/esm/openxml/word/Run.d.ts +7 -3
  74. package/esm/openxml/word/Run.js +28 -4
  75. package/esm/openxml/word/Section.d.ts +18 -5
  76. package/esm/openxml/word/Section.js +46 -2
  77. package/esm/openxml/word/Separator.d.ts +5 -0
  78. package/esm/openxml/word/Separator.js +10 -0
  79. package/esm/openxml/word/SoftHyphen.d.ts +5 -0
  80. package/esm/openxml/word/SoftHyphen.js +10 -0
  81. package/esm/openxml/word/Table.d.ts +4 -9
  82. package/esm/openxml/word/Table.js +0 -235
  83. package/esm/openxml/word/WDocument.d.ts +1 -2
  84. package/esm/openxml/word/WDocument.js +53 -7
  85. package/esm/openxml/word/numbering/AbstractNum.js +4 -2
  86. package/esm/openxml/word/numbering/Lvl.js +10 -4
  87. package/esm/openxml/word/numbering/Num.js +12 -4
  88. package/esm/openxml/word/numbering/NumberProperties.js +2 -2
  89. package/esm/openxml/word/numbering/Numbering.js +1 -1
  90. package/esm/openxml/word/table/Tc.d.ts +1 -22
  91. package/esm/openxml/word/table/Tc.js +1 -221
  92. package/esm/openxml/word/table/Tr.d.ts +0 -5
  93. package/esm/openxml/word/table/Tr.js +0 -97
  94. package/esm/openxml/word/wps/WPG.d.ts +5 -0
  95. package/esm/openxml/word/wps/WPS.d.ts +18 -0
  96. package/esm/openxml/word/wps/WPS.js +147 -0
  97. package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
  98. package/esm/openxml/word/wps/WPSStyle.js +42 -0
  99. package/esm/package/PackageParser.d.ts +1 -1
  100. package/esm/package/XMLPackageParser.d.ts +3 -3
  101. package/esm/package/ZipPackageParser.d.ts +1 -1
  102. package/esm/package/ZipPackageParser.js +7 -8
  103. package/esm/parse/Footnotes.d.ts +3 -0
  104. package/esm/parse/Footnotes.js +25 -0
  105. package/esm/parse/colorNameMap.d.ts +6 -0
  106. package/esm/parse/colorNameMap.js +201 -0
  107. package/esm/parse/jcToTextAlign.js +1 -0
  108. package/esm/parse/mergeSdt.d.ts +4 -0
  109. package/esm/parse/mergeSdt.js +57 -0
  110. package/esm/parse/modifyColor.d.ts +1 -0
  111. package/esm/parse/modifyColor.js +106 -0
  112. package/esm/parse/parseBorder.js +2 -21
  113. package/esm/parse/parseCellMargin.d.ts +2 -0
  114. package/esm/parse/parseCellMargin.js +38 -0
  115. package/esm/parse/parseChildColor.d.ts +5 -0
  116. package/esm/parse/parseChildColor.js +66 -0
  117. package/esm/parse/parseColor.d.ts +4 -0
  118. package/esm/parse/parseColor.js +41 -46
  119. package/esm/parse/parseEndnotes.d.ts +3 -0
  120. package/esm/parse/parseEndnotes.js +25 -0
  121. package/esm/parse/parseFont.js +1 -1
  122. package/esm/parse/parseInsideBorders.d.ts +9 -0
  123. package/esm/parse/parseInsideBorders.js +24 -0
  124. package/esm/parse/parsePr.d.ts +3 -0
  125. package/esm/parse/parsePr.js +108 -11
  126. package/esm/parse/parseRelationship.js +1 -1
  127. package/esm/parse/parseSdt.d.ts +5 -0
  128. package/esm/parse/parseShape.d.ts +10 -0
  129. package/esm/parse/parseShape.js +239 -0
  130. package/esm/parse/parseSize.d.ts +2 -1
  131. package/esm/parse/parseSize.js +7 -1
  132. package/esm/parse/parseSpacing.js +1 -1
  133. package/esm/parse/parseTable.d.ts +3 -0
  134. package/esm/parse/parseTable.js +62 -0
  135. package/esm/parse/parseTablePr.d.ts +3 -0
  136. package/esm/parse/parseTablePr.js +185 -0
  137. package/esm/parse/parseTblWidth.d.ts +4 -0
  138. package/esm/parse/parseTblWidth.js +23 -0
  139. package/esm/parse/parseTc.d.ts +10 -0
  140. package/esm/parse/parseTc.js +64 -0
  141. package/esm/parse/parseTcPr.d.ts +5 -0
  142. package/esm/parse/parseTcPr.js +99 -0
  143. package/esm/parse/parseTextDirection.js +4 -6
  144. package/esm/parse/parseTr.d.ts +6 -0
  145. package/esm/parse/parseTr.js +49 -0
  146. package/esm/parse/parseTrPr.d.ts +3 -0
  147. package/esm/parse/parseTrPr.js +59 -0
  148. package/esm/render/fixAbsolutePosition.d.ts +8 -0
  149. package/esm/render/renderBody.d.ts +6 -2
  150. package/esm/render/renderBody.js +184 -30
  151. package/esm/render/renderBr.d.ts +2 -1
  152. package/esm/render/renderBr.js +4 -1
  153. package/esm/render/renderCustGeom.d.ts +4 -0
  154. package/esm/render/renderCustGeom.js +10 -0
  155. package/esm/render/renderDocument.d.ts +2 -2
  156. package/esm/render/renderDocument.js +2 -2
  157. package/esm/render/renderDrawing.d.ts +3 -2
  158. package/esm/render/renderDrawing.js +129 -24
  159. package/esm/render/renderFont.d.ts +5 -0
  160. package/esm/render/renderFont.js +39 -0
  161. package/esm/render/renderGeom.d.ts +4 -0
  162. package/esm/render/renderGeom.js +14 -0
  163. package/esm/render/renderHeader.d.ts +6 -0
  164. package/esm/render/renderHeader.js +40 -0
  165. package/esm/render/renderHyperLink.js +4 -1
  166. package/esm/render/renderInlineText.js +1 -1
  167. package/esm/render/renderInstrText.js +1 -1
  168. package/esm/render/renderMath.d.ts +3 -0
  169. package/esm/render/renderMath.js +7 -0
  170. package/esm/render/renderNoBreakHyphen.d.ts +1 -0
  171. package/esm/render/renderNoBreakHyphen.js +9 -0
  172. package/esm/render/renderNotes.d.ts +5 -0
  173. package/esm/render/renderNotes.js +77 -0
  174. package/esm/render/renderNumbering.js +8 -10
  175. package/esm/render/renderParagraph.d.ts +1 -1
  176. package/esm/render/renderParagraph.js +26 -29
  177. package/esm/render/renderPict.js +5 -10
  178. package/esm/render/renderRuby.js +1 -1
  179. package/esm/render/renderRun.d.ts +4 -2
  180. package/esm/render/renderRun.js +35 -10
  181. package/esm/render/renderSection.d.ts +3 -2
  182. package/esm/render/renderSection.js +79 -5
  183. package/esm/render/renderSeparator.d.ts +1 -0
  184. package/esm/render/renderSeparator.js +9 -0
  185. package/esm/render/renderSoftHyphen.d.ts +1 -0
  186. package/esm/render/renderSoftHyphen.js +9 -0
  187. package/esm/render/renderStyle.js +36 -35
  188. package/esm/render/renderTab.d.ts +1 -0
  189. package/esm/render/renderTab.js +4 -6
  190. package/esm/render/renderTable.js +23 -20
  191. package/esm/render/setElementStyle.js +7 -2
  192. package/esm/render/zindex.d.ts +1 -0
  193. package/esm/util/blob.js +1 -10
  194. package/esm/util/color.d.ts +48 -0
  195. package/esm/util/color.js +211 -0
  196. package/esm/util/createObject.d.ts +10 -0
  197. package/esm/util/createObject.js +48 -0
  198. package/esm/util/dom.d.ts +8 -4
  199. package/esm/util/dom.js +21 -4
  200. package/esm/util/mergeRun.js +1 -1
  201. package/esm/util/parseSides.d.ts +11 -0
  202. package/esm/util/print.d.ts +5 -0
  203. package/esm/util/print.js +54 -0
  204. package/esm/util/replaceVar.d.ts +10 -0
  205. package/esm/util/replaceVar.js +214 -0
  206. package/esm/util/xml.js +4 -1
  207. package/lib/OpenXML.d.ts +19 -0
  208. package/lib/OpenXML.js +44 -1
  209. package/lib/Word.d.ts +132 -15
  210. package/lib/Word.js +238 -59
  211. package/lib/openxml/ContentType.js +20 -6
  212. package/lib/openxml/Settings.d.ts +10 -0
  213. package/lib/openxml/Settings.js +97 -0
  214. package/lib/openxml/Style.d.ts +1 -1
  215. package/lib/openxml/Style.js +15 -15
  216. package/lib/openxml/Theme.js +31 -7
  217. package/lib/openxml/Types.d.ts +179 -2472
  218. package/lib/openxml/drawing/Blip.d.ts +7 -0
  219. package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
  220. package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
  221. package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  222. package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
  223. package/lib/openxml/drawing/CustomGeom.js +21 -0
  224. package/lib/openxml/drawing/Drawing.d.ts +35 -0
  225. package/lib/openxml/drawing/Drawing.js +173 -0
  226. package/lib/openxml/drawing/Geom.d.ts +11 -0
  227. package/lib/openxml/drawing/Geom.js +38 -0
  228. package/lib/openxml/drawing/Path.d.ts +37 -0
  229. package/lib/openxml/drawing/Pic.d.ts +16 -0
  230. package/lib/openxml/drawing/Pic.js +30 -0
  231. package/lib/openxml/drawing/Shape.d.ts +20 -0
  232. package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
  233. package/lib/openxml/drawing/ShapeProperties.js +123 -0
  234. package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +2 -1
  235. package/lib/openxml/{word/drawing → drawing}/Transform.js +7 -3
  236. package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
  237. package/lib/openxml/drawing/diagram/Diagram.js +28 -0
  238. package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
  239. package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
  240. package/lib/openxml/drawing/presetShape.d.ts +3 -0
  241. package/lib/openxml/drawing/presetShape.js +38789 -0
  242. package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
  243. package/lib/openxml/drawing/svg/arcToA.js +92 -0
  244. package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
  245. package/lib/openxml/drawing/svg/formulas.js +108 -0
  246. package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
  247. package/lib/openxml/drawing/svg/generateDefines.js +148 -0
  248. package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
  249. package/lib/openxml/drawing/svg/presetVal.js +57 -0
  250. package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  251. package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
  252. package/lib/openxml/math/OMath.d.ts +5 -0
  253. package/lib/openxml/math/OMath.js +16 -0
  254. package/lib/openxml/math/convertOOML.d.ts +4 -0
  255. package/lib/openxml/math/convertOOML.js +17 -0
  256. package/lib/openxml/math/xsl.d.ts +4 -0
  257. package/lib/openxml/math/xsl.js +12 -0
  258. package/lib/openxml/word/Body.js +11 -7
  259. package/lib/openxml/word/Break.js +1 -3
  260. package/lib/openxml/word/Font.d.ts +16 -0
  261. package/lib/openxml/word/Font.js +83 -0
  262. package/lib/openxml/word/FontTable.d.ts +9 -0
  263. package/lib/openxml/word/FontTable.js +38 -0
  264. package/lib/openxml/word/Header.d.ts +11 -0
  265. package/lib/openxml/word/Header.js +58 -0
  266. package/lib/openxml/word/Hyperlink.d.ts +1 -0
  267. package/lib/openxml/word/Hyperlink.js +8 -4
  268. package/lib/openxml/word/InlineText.js +2 -2
  269. package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
  270. package/lib/openxml/word/NoBreakHyphen.js +11 -0
  271. package/lib/openxml/word/Note.d.ts +12 -0
  272. package/lib/openxml/word/Note.js +52 -0
  273. package/lib/openxml/word/Paragraph.d.ts +2 -2
  274. package/lib/openxml/word/Paragraph.js +11 -10
  275. package/lib/openxml/word/Pict.d.ts +1 -2
  276. package/lib/openxml/word/Pict.js +5 -3
  277. package/lib/openxml/word/Ruby.js +4 -4
  278. package/lib/openxml/word/Run.d.ts +7 -3
  279. package/lib/openxml/word/Run.js +29 -5
  280. package/lib/openxml/word/Section.d.ts +18 -5
  281. package/lib/openxml/word/Section.js +47 -3
  282. package/lib/openxml/word/Separator.d.ts +5 -0
  283. package/lib/openxml/word/Separator.js +14 -0
  284. package/lib/openxml/word/SoftHyphen.d.ts +5 -0
  285. package/lib/openxml/word/SoftHyphen.js +14 -0
  286. package/lib/openxml/word/Table.d.ts +4 -9
  287. package/lib/openxml/word/Table.js +0 -235
  288. package/lib/openxml/word/WDocument.d.ts +1 -2
  289. package/lib/openxml/word/WDocument.js +53 -7
  290. package/lib/openxml/word/numbering/AbstractNum.js +5 -3
  291. package/lib/openxml/word/numbering/Lvl.js +11 -5
  292. package/lib/openxml/word/numbering/Num.js +12 -4
  293. package/lib/openxml/word/numbering/NumberProperties.js +2 -2
  294. package/lib/openxml/word/numbering/Numbering.js +3 -3
  295. package/lib/openxml/word/table/Tc.d.ts +1 -22
  296. package/lib/openxml/word/table/Tc.js +0 -224
  297. package/lib/openxml/word/table/Tr.d.ts +0 -5
  298. package/lib/openxml/word/table/Tr.js +0 -97
  299. package/lib/openxml/word/wps/WPG.d.ts +5 -0
  300. package/lib/openxml/word/wps/WPS.d.ts +18 -0
  301. package/lib/openxml/word/wps/WPS.js +151 -0
  302. package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
  303. package/lib/openxml/word/wps/WPSStyle.js +46 -0
  304. package/lib/package/PackageParser.d.ts +1 -1
  305. package/lib/package/XMLPackageParser.d.ts +3 -3
  306. package/lib/package/ZipPackageParser.d.ts +1 -1
  307. package/lib/package/ZipPackageParser.js +7 -8
  308. package/lib/parse/Footnotes.d.ts +3 -0
  309. package/lib/parse/Footnotes.js +29 -0
  310. package/lib/parse/colorNameMap.d.ts +6 -0
  311. package/lib/parse/colorNameMap.js +205 -0
  312. package/lib/parse/jcToTextAlign.js +1 -0
  313. package/lib/parse/mergeSdt.d.ts +4 -0
  314. package/lib/parse/mergeSdt.js +61 -0
  315. package/lib/parse/modifyColor.d.ts +1 -0
  316. package/lib/parse/modifyColor.js +110 -0
  317. package/lib/parse/parseBorder.js +3 -22
  318. package/lib/parse/parseCellMargin.d.ts +2 -0
  319. package/lib/parse/parseCellMargin.js +42 -0
  320. package/lib/parse/parseChildColor.d.ts +5 -0
  321. package/lib/parse/parseChildColor.js +70 -0
  322. package/lib/parse/parseColor.d.ts +4 -0
  323. package/lib/parse/parseColor.js +41 -45
  324. package/lib/parse/parseEndnotes.d.ts +3 -0
  325. package/lib/parse/parseEndnotes.js +29 -0
  326. package/lib/parse/parseFont.js +2 -2
  327. package/lib/parse/parseInsideBorders.d.ts +9 -0
  328. package/lib/parse/parseInsideBorders.js +28 -0
  329. package/lib/parse/parsePr.d.ts +3 -0
  330. package/lib/parse/parsePr.js +109 -12
  331. package/lib/parse/parseRelationship.js +2 -2
  332. package/lib/parse/parseSdt.d.ts +5 -0
  333. package/lib/parse/parseShape.d.ts +10 -0
  334. package/lib/parse/parseShape.js +247 -0
  335. package/lib/parse/parseSize.d.ts +2 -1
  336. package/lib/parse/parseSize.js +7 -0
  337. package/lib/parse/parseSpacing.js +1 -1
  338. package/lib/parse/parseTable.d.ts +3 -0
  339. package/lib/parse/parseTable.js +66 -0
  340. package/lib/parse/parseTablePr.d.ts +3 -0
  341. package/lib/parse/parseTablePr.js +189 -0
  342. package/lib/parse/parseTblWidth.d.ts +4 -0
  343. package/lib/parse/parseTblWidth.js +27 -0
  344. package/lib/parse/parseTc.d.ts +10 -0
  345. package/lib/parse/parseTc.js +68 -0
  346. package/lib/parse/parseTcPr.d.ts +5 -0
  347. package/lib/parse/parseTcPr.js +104 -0
  348. package/lib/parse/parseTextDirection.js +4 -6
  349. package/lib/parse/parseTr.d.ts +6 -0
  350. package/lib/parse/parseTr.js +53 -0
  351. package/lib/parse/parseTrPr.d.ts +3 -0
  352. package/lib/parse/parseTrPr.js +63 -0
  353. package/lib/render/fixAbsolutePosition.d.ts +8 -0
  354. package/lib/render/renderBody.d.ts +6 -2
  355. package/lib/render/renderBody.js +183 -29
  356. package/lib/render/renderBr.d.ts +2 -1
  357. package/lib/render/renderBr.js +4 -1
  358. package/lib/render/renderCustGeom.d.ts +4 -0
  359. package/lib/render/renderCustGeom.js +14 -0
  360. package/lib/render/renderDocument.d.ts +2 -2
  361. package/lib/render/renderDocument.js +2 -2
  362. package/lib/render/renderDrawing.d.ts +3 -2
  363. package/lib/render/renderDrawing.js +129 -24
  364. package/lib/render/renderFont.d.ts +5 -0
  365. package/lib/render/renderFont.js +43 -0
  366. package/lib/render/renderGeom.d.ts +4 -0
  367. package/lib/render/renderGeom.js +18 -0
  368. package/lib/render/renderHeader.d.ts +6 -0
  369. package/lib/render/renderHeader.js +44 -0
  370. package/lib/render/renderHyperLink.js +5 -2
  371. package/lib/render/renderInlineText.js +2 -2
  372. package/lib/render/renderInstrText.js +2 -2
  373. package/lib/render/renderMath.d.ts +3 -0
  374. package/lib/render/renderMath.js +11 -0
  375. package/lib/render/renderNoBreakHyphen.d.ts +1 -0
  376. package/lib/render/renderNoBreakHyphen.js +13 -0
  377. package/lib/render/renderNotes.d.ts +5 -0
  378. package/lib/render/renderNotes.js +81 -0
  379. package/lib/render/renderNumbering.js +9 -11
  380. package/lib/render/renderParagraph.d.ts +1 -1
  381. package/lib/render/renderParagraph.js +26 -29
  382. package/lib/render/renderPict.js +5 -10
  383. package/lib/render/renderRuby.js +3 -3
  384. package/lib/render/renderRun.d.ts +4 -2
  385. package/lib/render/renderRun.js +34 -9
  386. package/lib/render/renderSection.d.ts +3 -2
  387. package/lib/render/renderSection.js +79 -5
  388. package/lib/render/renderSeparator.d.ts +1 -0
  389. package/lib/render/renderSeparator.js +13 -0
  390. package/lib/render/renderSoftHyphen.d.ts +1 -0
  391. package/lib/render/renderSoftHyphen.js +13 -0
  392. package/lib/render/renderStyle.js +37 -36
  393. package/lib/render/renderTab.d.ts +1 -0
  394. package/lib/render/renderTab.js +4 -6
  395. package/lib/render/renderTable.js +25 -22
  396. package/lib/render/setElementStyle.js +6 -1
  397. package/lib/render/zindex.d.ts +1 -0
  398. package/lib/util/blob.js +0 -10
  399. package/lib/util/color.d.ts +48 -0
  400. package/lib/util/color.js +215 -0
  401. package/lib/util/createObject.d.ts +10 -0
  402. package/lib/util/createObject.js +54 -0
  403. package/lib/util/dom.d.ts +8 -4
  404. package/lib/util/dom.js +24 -5
  405. package/lib/util/mergeRun.js +5 -5
  406. package/lib/util/parseSides.d.ts +11 -0
  407. package/lib/util/print.d.ts +5 -0
  408. package/lib/util/print.js +58 -0
  409. package/lib/util/replaceVar.d.ts +10 -0
  410. package/lib/util/replaceVar.js +219 -0
  411. package/lib/util/xml.js +4 -0
  412. package/package.json +17 -6
  413. package/esm/node_modules/tslib/tslib.es6.js +0 -120
  414. package/esm/openxml/Types.js +0 -1003
  415. package/esm/openxml/word/CustomXml.d.ts +0 -8
  416. package/esm/openxml/word/SmartTag.d.ts +0 -8
  417. package/esm/openxml/word/SmartTag.js +0 -18
  418. package/esm/openxml/word/drawing/Blip.d.ts +0 -6
  419. package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
  420. package/esm/openxml/word/drawing/Drawing.js +0 -15
  421. package/esm/openxml/word/drawing/Pic.d.ts +0 -8
  422. package/esm/openxml/word/drawing/Pic.js +0 -16
  423. package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  424. package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
  425. package/lib/node_modules/tslib/tslib.es6.js +0 -129
  426. package/lib/openxml/Types.js +0 -1005
  427. package/lib/openxml/word/CustomXml.d.ts +0 -8
  428. package/lib/openxml/word/SmartTag.d.ts +0 -8
  429. package/lib/openxml/word/SmartTag.js +0 -22
  430. package/lib/openxml/word/drawing/Blip.d.ts +0 -6
  431. package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
  432. package/lib/openxml/word/drawing/Drawing.js +0 -19
  433. package/lib/openxml/word/drawing/Pic.d.ts +0 -8
  434. package/lib/openxml/word/drawing/Pic.js +0 -20
  435. package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  436. package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var mergeSdt = require('../../parse/mergeSdt.js');
7
+ var parseTable = require('../../parse/parseTable.js');
8
+ var Paragraph = require('./Paragraph.js');
9
+
10
+ /**
11
+ * header 的定义,footer 也是用这个,因为结构是一样的
12
+ */
13
+ var Header = /** @class */ (function () {
14
+ function Header() {
15
+ this.children = [];
16
+ }
17
+ Header.fromXML = function (word, doc) {
18
+ var e_1, _a;
19
+ var footer = new Header();
20
+ var children = [];
21
+ footer.children = children;
22
+ var elm = doc;
23
+ var firstChild = doc.firstElementChild;
24
+ if (firstChild &&
25
+ (firstChild.tagName === 'w:hdr' || firstChild.tagName === 'w:ftr')) {
26
+ elm = firstChild;
27
+ }
28
+ try {
29
+ for (var _b = tslib.__values(mergeSdt.mergeSdt(elm)), _c = _b.next(); !_c.done; _c = _b.next()) {
30
+ var child = _c.value;
31
+ var tagName = child.tagName;
32
+ switch (tagName) {
33
+ case 'w:p':
34
+ var paragraph = Paragraph.Paragraph.fromXML(word, child);
35
+ children.push(paragraph);
36
+ break;
37
+ case 'w:tbl':
38
+ var table = parseTable.parseTable(word, child);
39
+ children.push(table);
40
+ break;
41
+ default:
42
+ console.warn('Header.fromXML Unknown key', tagName, child);
43
+ }
44
+ }
45
+ }
46
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
47
+ finally {
48
+ try {
49
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
50
+ }
51
+ finally { if (e_1) throw e_1.error; }
52
+ }
53
+ return footer;
54
+ };
55
+ return Header;
56
+ }());
57
+
58
+ exports.Header = Header;
@@ -8,6 +8,7 @@ export declare class Hyperlink {
8
8
  anchor?: string;
9
9
  relation?: Relationship;
10
10
  children: Run[];
11
+ tooltip?: string;
11
12
  addChild(Run: Run): void;
12
13
  static fromXML(word: Word, element: Element): Hyperlink;
13
14
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var Run = require('./Run.js');
7
7
 
8
8
  /**
@@ -20,17 +20,21 @@ var Hyperlink = /** @class */ (function () {
20
20
  var hyperlink = new Hyperlink();
21
21
  var rId = element.getAttribute('r:id');
22
22
  if (rId) {
23
- var rel = word.getRelationship(rId);
23
+ var rel = word.getDocumentRels(rId);
24
24
  if (rel) {
25
25
  hyperlink.relation = rel;
26
26
  }
27
27
  }
28
- var anchor = element.getAttribute('anchor');
28
+ var anchor = element.getAttribute('w:anchor');
29
29
  if (anchor) {
30
30
  hyperlink.anchor = anchor;
31
31
  }
32
+ var tooltip = element.getAttribute('w:tooltip');
33
+ if (tooltip) {
34
+ hyperlink.tooltip = tooltip;
35
+ }
32
36
  try {
33
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
37
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
34
38
  var child = _c.value;
35
39
  var tagName = child.tagName;
36
40
  switch (tagName) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var Bookmark = require('./Bookmark.js');
7
7
  var Hyperlink = require('./Hyperlink.js');
8
8
  var Run = require('./Run.js');
@@ -21,7 +21,7 @@ var InlineText = /** @class */ (function () {
21
21
  var e_1, _a;
22
22
  var smartTag = new InlineText();
23
23
  try {
24
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
24
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
25
25
  var child = _c.value;
26
26
  var tagName = child.tagName;
27
27
  switch (tagName) {
@@ -0,0 +1,2 @@
1
+ export declare class NoBreakHyphen {
2
+ }
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var NoBreakHyphen = /** @class */ (function () {
6
+ function NoBreakHyphen() {
7
+ }
8
+ return NoBreakHyphen;
9
+ }());
10
+
11
+ exports.NoBreakHyphen = NoBreakHyphen;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * footnote 和 endnote 的结构几乎是一样的,所以统一叫 Note 了
3
+ */
4
+ import Word from '../../Word';
5
+ import { Paragraph } from './Paragraph';
6
+ import { Table } from './Table';
7
+ export type NoteChild = Paragraph | Table;
8
+ export declare class Note {
9
+ children: NoteChild[];
10
+ addChild(child: NoteChild): void;
11
+ static fromXML(word: Word, element: Element): Note;
12
+ }
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var parseTable = require('../../parse/parseTable.js');
7
+ var Paragraph = require('./Paragraph.js');
8
+
9
+ /**
10
+ * footnote 和 endnote 的结构几乎是一样的,所以统一叫 Note 了
11
+ */
12
+ var Note = /** @class */ (function () {
13
+ function Note() {
14
+ this.children = [];
15
+ }
16
+ Note.prototype.addChild = function (child) {
17
+ this.children.push(child);
18
+ };
19
+ Note.fromXML = function (word, element) {
20
+ var e_1, _a;
21
+ var note = new Note();
22
+ try {
23
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
24
+ var child = _c.value;
25
+ var tagName = child.tagName;
26
+ switch (tagName) {
27
+ case 'w:p':
28
+ var paragraph = Paragraph.Paragraph.fromXML(word, child);
29
+ note.addChild(paragraph);
30
+ break;
31
+ case 'w:tbl':
32
+ var table = parseTable.parseTable(word, child);
33
+ note.addChild(table);
34
+ break;
35
+ default:
36
+ console.warn('Note.fromXML unknown tag', tagName, child);
37
+ }
38
+ }
39
+ }
40
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
41
+ finally {
42
+ try {
43
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
44
+ }
45
+ finally { if (e_1) throw e_1.error; }
46
+ }
47
+ return note;
48
+ };
49
+ return Note;
50
+ }());
51
+
52
+ exports.Note = Note;
@@ -8,8 +8,8 @@ import { NumberPr } from './numbering/NumberProperties';
8
8
  import { Properties } from './properties/Properties';
9
9
  import { Run, RunPr } from './Run';
10
10
  import { Tab } from './Tab';
11
- import { SmartTag } from './SmartTag';
12
11
  import { FldSimple } from './FldSimple';
12
+ import { OMath } from '../math/OMath';
13
13
  /**
14
14
  * 这里简化了很多,如果能用 CSS 表示就直接用 CSS 表示
15
15
  */
@@ -22,7 +22,7 @@ export interface ParagraphPr extends Properties {
22
22
  */
23
23
  autoSpace?: boolean;
24
24
  }
25
- export type ParagraphChild = Run | BookmarkStart | Hyperlink | SmartTag | FldSimple;
25
+ export type ParagraphChild = Run | BookmarkStart | Hyperlink | FldSimple | OMath;
26
26
  export declare class Paragraph {
27
27
  paraId?: string;
28
28
  properties: ParagraphPr;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var OpenXML = require('../../OpenXML.js');
7
7
  var parsePr = require('../../parse/parsePr.js');
8
8
  var Bookmark = require('./Bookmark.js');
@@ -10,8 +10,9 @@ var Hyperlink = require('./Hyperlink.js');
10
10
  var NumberProperties = require('./numbering/NumberProperties.js');
11
11
  var Run = require('./Run.js');
12
12
  var Tab = require('./Tab.js');
13
- var SmartTag = require('./SmartTag.js');
14
13
  var FldSimple = require('./FldSimple.js');
14
+ var OMath = require('../math/OMath.js');
15
+ var mergeSdt = require('../../parse/mergeSdt.js');
15
16
 
16
17
  /**
17
18
  * 段落的定义和解析
@@ -49,19 +50,19 @@ var Paragraph = /** @class */ (function () {
49
50
  var e_1, _a;
50
51
  var cssStyle = parsePr.parsePr(word, element);
51
52
  var pStyle;
52
- var pStyleTag = element.querySelector('pStyle');
53
+ var pStyleTag = element.getElementsByTagName('w:pStyle').item(0);
53
54
  if (pStyleTag) {
54
55
  pStyle = OpenXML.getVal(pStyleTag);
55
56
  }
56
57
  var numPr;
57
- var numPrTag = element.querySelector('numPr');
58
+ var numPrTag = element.getElementsByTagName('w:numPr').item(0);
58
59
  if (numPrTag) {
59
60
  numPr = NumberProperties.NumberPr.fromXML(word, numPrTag);
60
61
  }
61
62
  var tabs = [];
62
63
  var tabElements = element.getElementsByTagName('w:tab');
63
64
  try {
64
- for (var tabElements_1 = tslib_es6.__values(tabElements), tabElements_1_1 = tabElements_1.next(); !tabElements_1_1.done; tabElements_1_1 = tabElements_1.next()) {
65
+ for (var tabElements_1 = tslib.__values(tabElements), tabElements_1_1 = tabElements_1.next(); !tabElements_1_1.done; tabElements_1_1 = tabElements_1.next()) {
65
66
  var tabElement = tabElements_1_1.value;
66
67
  tabs.push(Tab.Tab.fromXML(word, tabElement));
67
68
  }
@@ -82,7 +83,7 @@ var Paragraph = /** @class */ (function () {
82
83
  paragraph.fldSimples = [];
83
84
  paragraph.paraId = element.getAttribute('w14:paraId') || '';
84
85
  try {
85
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
86
+ for (var _b = tslib.__values(mergeSdt.mergeSdt(element)), _c = _b.next(); !_c.done; _c = _b.next()) {
86
87
  var child = _c.value;
87
88
  var tagName = child.tagName;
88
89
  switch (tagName) {
@@ -109,14 +110,14 @@ var Paragraph = /** @class */ (function () {
109
110
  case 'w:moveFrom':
110
111
  // del 看起来主要是用于跟踪历史的,先不支持
111
112
  break;
112
- case 'w:smartTag':
113
- case 'w:customXml':
114
- paragraph.addChild(SmartTag.SmartTag.fromXML(word, child));
115
- break;
116
113
  case 'w:fldSimple':
117
114
  // 这个目前还不想支持
118
115
  paragraph.fldSimples.push(FldSimple.FldSimple.fromXML(word, child));
119
116
  break;
117
+ case 'm:oMathPara':
118
+ case 'm:oMath':
119
+ paragraph.addChild(OMath.OMath.fromXML(word, child));
120
+ break;
120
121
  default:
121
122
  console.warn('parse Paragraph: Unknown key', tagName, child);
122
123
  }
@@ -1,6 +1,5 @@
1
- import { Relationship } from '../../parse/parseRelationship';
2
1
  import Word from '../../Word';
3
2
  export declare class Pict {
4
- imagedata?: Relationship;
3
+ src?: string | null;
5
4
  static fromXML(word: Word, element: Element): Pict | null;
6
5
  }
@@ -7,12 +7,14 @@ var Pict = /** @class */ (function () {
7
7
  }
8
8
  Pict.fromXML = function (word, element) {
9
9
  var pict = new Pict();
10
- var imagedataElement = element.querySelector('imagedata');
10
+ var imagedataElement = element
11
+ .getElementsByTagName('v:imagedata')
12
+ .item(0);
11
13
  if (imagedataElement) {
12
14
  var rId = imagedataElement.getAttribute('r:id') || '';
13
- var rel = word.getRelationship(rId);
15
+ var rel = word.getDocumentRels(rId);
14
16
  if (rel) {
15
- pict.imagedata = rel;
17
+ pict.src = word.loadImage(rel);
16
18
  }
17
19
  }
18
20
  return pict;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var Run = require('./Run.js');
7
7
 
8
8
  /**
@@ -17,7 +17,7 @@ var RubyBase = /** @class */ (function () {
17
17
  var rubyBase = new RubyBase();
18
18
  rubyBase.children = [];
19
19
  try {
20
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
20
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
21
21
  var child = _c.value;
22
22
  var tagName = child.tagName;
23
23
  switch (tagName) {
@@ -45,7 +45,7 @@ var RubyBase = /** @class */ (function () {
45
45
  }());
46
46
  // 看起来应该是一样的
47
47
  /** @class */ ((function (_super) {
48
- tslib_es6.__extends(RubyText, _super);
48
+ tslib.__extends(RubyText, _super);
49
49
  function RubyText() {
50
50
  return _super !== null && _super.apply(this, arguments) || this;
51
51
  }
@@ -58,7 +58,7 @@ var Ruby = /** @class */ (function () {
58
58
  var e_2, _a;
59
59
  var ruby = new Ruby();
60
60
  try {
61
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
61
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
62
62
  var child = _c.value;
63
63
  var tagName = child.tagName;
64
64
  switch (tagName) {
@@ -1,11 +1,14 @@
1
1
  import Word from '../../Word';
2
- import { ST_VerticalAlignRun } from '../Types';
2
+ import { ST_FldCharType, ST_VerticalAlignRun } from '../Types';
3
3
  import { Break } from './Break';
4
- import { Drawing } from './drawing/Drawing';
4
+ import { Drawing } from '../drawing/Drawing';
5
5
  import { InstrText } from './InstrText';
6
+ import { NoBreakHyphen } from './NoBreakHyphen';
6
7
  import { Pict } from './Pict';
7
8
  import { Properties } from './properties/Properties';
8
9
  import { Ruby } from './Ruby';
10
+ import { Separator } from './Separator';
11
+ import { SoftHyphen } from './SoftHyphen';
9
12
  import { Sym } from './Sym';
10
13
  import { Tab } from './Tab';
11
14
  /**
@@ -20,10 +23,11 @@ export declare class Text {
20
23
  text: string;
21
24
  constructor(text: string | number);
22
25
  }
23
- type RunChild = Break | Drawing | Text | Tab | Pict | Ruby | InstrText | Sym;
26
+ type RunChild = Break | Drawing | Text | Tab | Pict | Ruby | InstrText | Sym | SoftHyphen | Separator | NoBreakHyphen;
24
27
  export declare class Run {
25
28
  properties: RunPr;
26
29
  children: RunChild[];
30
+ fldChar?: ST_FldCharType;
27
31
  addChild(child: RunChild | null): void;
28
32
  static parseRunPr(word: Word, element: Element): RunPr;
29
33
  static fromXML(word: Word, element: Element): Run;
@@ -2,14 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var OpenXML = require('../../OpenXML.js');
7
7
  var parsePr = require('../../parse/parsePr.js');
8
8
  var Break = require('./Break.js');
9
- var Drawing = require('./drawing/Drawing.js');
9
+ var Drawing = require('../drawing/Drawing.js');
10
10
  var InstrText = require('./InstrText.js');
11
+ var NoBreakHyphen = require('./NoBreakHyphen.js');
11
12
  var Pict = require('./Pict.js');
12
13
  var Ruby = require('./Ruby.js');
14
+ var Separator = require('./Separator.js');
15
+ var SoftHyphen = require('./SoftHyphen.js');
13
16
  var Sym = require('./Sym.js');
14
17
  var Tab = require('./Tab.js');
15
18
 
@@ -43,7 +46,7 @@ var Run = /** @class */ (function () {
43
46
  var e_1, _a;
44
47
  var run = new Run();
45
48
  try {
46
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
49
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
47
50
  var child = _c.value;
48
51
  var tagName = child.tagName;
49
52
  switch (tagName) {
@@ -56,6 +59,7 @@ var Run = /** @class */ (function () {
56
59
  run.properties = Run.parseRunPr(word, child);
57
60
  break;
58
61
  case 'w:br':
62
+ case 'w:cr':
59
63
  run.addChild(Break.Break.fromXML(word, child));
60
64
  break;
61
65
  case 'w:drawing':
@@ -65,13 +69,15 @@ var Run = /** @class */ (function () {
65
69
  run.addChild(Tab.Tab.fromXML(word, child));
66
70
  break;
67
71
  case 'w:fldChar':
68
- // 似乎只需要支持 instrText
72
+ run.fldChar = child.getAttribute('w:fldCharType');
69
73
  break;
70
74
  case 'w:instrText':
71
75
  run.addChild(new InstrText.InstrText(child.textContent || ''));
72
76
  break;
73
77
  case 'w:lastRenderedPageBreak':
74
- // 目前也不支持分页显示
78
+ var pageBreak = new Break.Break();
79
+ pageBreak.type = 'page';
80
+ run.addChild(pageBreak);
75
81
  break;
76
82
  case 'w:pict':
77
83
  run.addChild(Pict.Pict.fromXML(word, child));
@@ -82,6 +88,24 @@ var Run = /** @class */ (function () {
82
88
  case 'w:sym':
83
89
  run.addChild(Sym.Sym.parseXML(child));
84
90
  break;
91
+ case 'mc:AlternateContent':
92
+ var drawingChild = child.getElementsByTagName('w:drawing').item(0);
93
+ if (drawingChild) {
94
+ run.addChild(Drawing.Drawing.fromXML(word, drawingChild));
95
+ }
96
+ break;
97
+ case 'w:softHyphen':
98
+ run.addChild(new SoftHyphen.SoftHyphen());
99
+ break;
100
+ case 'w:noBreakHyphen':
101
+ run.addChild(new NoBreakHyphen.NoBreakHyphen());
102
+ break;
103
+ case 'w:separator':
104
+ run.addChild(new Separator.Separator());
105
+ break;
106
+ case 'w:continuationSeparator':
107
+ // TODO: 还不知道是啥
108
+ break;
85
109
  default:
86
110
  console.warn('parse Run: Unknown key', tagName, child);
87
111
  }
@@ -3,10 +3,12 @@
3
3
  * word 文档是按 section 组织的
4
4
  * 参考了 docx 里的类型定义
5
5
  */
6
+ import Word from '../../Word';
6
7
  import { ST_PageOrientation } from '../Types';
7
- import { Hyperlink } from './Hyperlink';
8
8
  import { Paragraph } from './Paragraph';
9
9
  import { Table } from './Table';
10
+ import { Body } from './Body';
11
+ import { Header } from './Header';
10
12
  export type PageSize = {
11
13
  width: string;
12
14
  height: string;
@@ -21,18 +23,29 @@ export type PageMargin = {
21
23
  footer?: string;
22
24
  gutter?: string;
23
25
  };
26
+ /**
27
+ * 列设置,其实这里支持
28
+ */
24
29
  export interface Column {
25
- width?: number;
26
- space?: number;
30
+ num?: number;
31
+ space?: string;
27
32
  }
28
- export type SectionChild = Paragraph | Table | Hyperlink;
33
+ export type SectionChild = Paragraph | Table;
29
34
  export interface SectionPr {
30
35
  pageSize?: PageSize;
31
36
  pageMargin?: PageMargin;
37
+ cols?: Column;
38
+ headers?: {
39
+ [key in HeaderType]?: Header;
40
+ };
41
+ footers?: {
42
+ [key in HeaderType]?: Header;
43
+ };
32
44
  }
45
+ export type HeaderType = 'default' | 'first' | 'even';
33
46
  export declare class Section {
34
47
  properties: SectionPr;
35
48
  children: SectionChild[];
36
49
  addChild(child: SectionChild): void;
37
- static parsePr(element: Element): SectionPr;
50
+ static parsePr(word: Word, element: Element, body: Body): SectionPr;
38
51
  }
@@ -2,14 +2,34 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
5
+ var tslib = require('tslib');
6
6
  var parseSize = require('../../parse/parseSize.js');
7
+ var OpenXML = require('../../OpenXML.js');
8
+ var Header = require('./Header.js');
7
9
 
8
10
  /**
9
11
  * section 属性
10
12
  * word 文档是按 section 组织的
11
13
  * 参考了 docx 里的类型定义
12
14
  */
15
+ function parseHeader(word, element, type) {
16
+ var headerType = element.getAttribute('w:type');
17
+ var headerId = element.getAttribute('r:id');
18
+ if (headerType && headerId) {
19
+ var headerRel = word.getDocumentRels(headerId);
20
+ if (headerRel) {
21
+ var headerDoc = word.getXML('/word/' + headerRel.target);
22
+ if (headerDoc) {
23
+ var header = Header.Header.fromXML(word, headerDoc);
24
+ return {
25
+ headerType: headerType,
26
+ header: header
27
+ };
28
+ }
29
+ }
30
+ }
31
+ return null;
32
+ }
13
33
  var Section = /** @class */ (function () {
14
34
  function Section() {
15
35
  this.properties = {};
@@ -18,11 +38,13 @@ var Section = /** @class */ (function () {
18
38
  Section.prototype.addChild = function (child) {
19
39
  this.children.push(child);
20
40
  };
21
- Section.parsePr = function (element) {
41
+ Section.parsePr = function (word, element, body) {
22
42
  var e_1, _a;
23
43
  var properties = {};
44
+ properties.headers = {};
45
+ properties.footers = {};
24
46
  try {
25
- for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
47
+ for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
26
48
  var child = _c.value;
27
49
  var tagName = child.tagName;
28
50
  switch (tagName) {
@@ -43,6 +65,28 @@ var Section = /** @class */ (function () {
43
65
  gutter: parseSize.parseSize(child, 'w:gutter')
44
66
  };
45
67
  break;
68
+ case 'w:headerReference':
69
+ var header = parseHeader(word, child, 'header');
70
+ if (header) {
71
+ properties.headers[header.headerType] = header.header;
72
+ }
73
+ break;
74
+ case 'w:footerReference':
75
+ var footer = parseHeader(word, child, 'footer');
76
+ if (footer) {
77
+ properties.footers[footer.headerType] = footer.header;
78
+ }
79
+ break;
80
+ case 'w:cols':
81
+ var cols = {};
82
+ var num = OpenXML.getAttrNumber(child, 'w:num', 1);
83
+ cols.num = num;
84
+ var space = parseSize.parseSize(child, 'w:space');
85
+ if (space) {
86
+ cols.space = space;
87
+ }
88
+ properties.cols = cols;
89
+ break;
46
90
  default:
47
91
  break;
48
92
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * endnote 和 footnote 的分隔符
3
+ */
4
+ export declare class Separator {
5
+ }
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * endnote 和 footnote 的分隔符
7
+ */
8
+ var Separator = /** @class */ (function () {
9
+ function Separator() {
10
+ }
11
+ return Separator;
12
+ }());
13
+
14
+ exports.Separator = Separator;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 对应 w:softHyphen
3
+ */
4
+ export declare class SoftHyphen {
5
+ }
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * 对应 w:softHyphen
7
+ */
8
+ var SoftHyphen = /** @class */ (function () {
9
+ function SoftHyphen() {
10
+ }
11
+ return SoftHyphen;
12
+ }());
13
+
14
+ exports.SoftHyphen = SoftHyphen;