office-viewer 0.1.0 → 0.1.4

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 (446) hide show
  1. package/README.md +6 -1
  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 +239 -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 +37 -0
  20. package/esm/openxml/drawing/Drawing.js +173 -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 +4 -1
  30. package/esm/openxml/drawing/Transform.js +63 -0
  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/Tab.d.ts +1 -1
  82. package/esm/openxml/word/Table.d.ts +4 -9
  83. package/esm/openxml/word/Table.js +0 -235
  84. package/esm/openxml/word/WDocument.d.ts +1 -2
  85. package/esm/openxml/word/WDocument.js +53 -7
  86. package/esm/openxml/word/numbering/AbstractNum.js +4 -2
  87. package/esm/openxml/word/numbering/Lvl.js +10 -4
  88. package/esm/openxml/word/numbering/Num.js +12 -4
  89. package/esm/openxml/word/numbering/NumberProperties.js +2 -2
  90. package/esm/openxml/word/numbering/Numbering.js +1 -1
  91. package/esm/openxml/word/table/Tc.d.ts +1 -22
  92. package/esm/openxml/word/table/Tc.js +1 -221
  93. package/esm/openxml/word/table/Tr.d.ts +0 -5
  94. package/esm/openxml/word/table/Tr.js +0 -97
  95. package/esm/openxml/word/wps/WPG.d.ts +14 -0
  96. package/esm/openxml/word/wps/WPG.js +56 -0
  97. package/esm/openxml/word/wps/WPS.d.ts +18 -0
  98. package/esm/openxml/word/wps/WPS.js +148 -0
  99. package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
  100. package/esm/openxml/word/wps/WPSStyle.js +42 -0
  101. package/esm/package/PackageParser.d.ts +1 -1
  102. package/esm/package/XMLPackageParser.d.ts +3 -3
  103. package/esm/package/ZipPackageParser.d.ts +1 -1
  104. package/esm/package/ZipPackageParser.js +7 -8
  105. package/esm/parse/Footnotes.d.ts +3 -0
  106. package/esm/parse/Footnotes.js +25 -0
  107. package/esm/parse/colorNameMap.d.ts +6 -0
  108. package/esm/parse/colorNameMap.js +201 -0
  109. package/esm/parse/jcToTextAlign.js +1 -0
  110. package/esm/parse/mergeSdt.d.ts +4 -0
  111. package/esm/parse/mergeSdt.js +57 -0
  112. package/esm/parse/modifyColor.d.ts +1 -0
  113. package/esm/parse/modifyColor.js +106 -0
  114. package/esm/parse/parseBorder.js +2 -21
  115. package/esm/parse/parseCellMargin.d.ts +2 -0
  116. package/esm/parse/parseCellMargin.js +38 -0
  117. package/esm/parse/parseChildColor.d.ts +5 -0
  118. package/esm/parse/parseChildColor.js +66 -0
  119. package/esm/parse/parseColor.d.ts +4 -0
  120. package/esm/parse/parseColor.js +41 -46
  121. package/esm/parse/parseEndnotes.d.ts +3 -0
  122. package/esm/parse/parseEndnotes.js +25 -0
  123. package/esm/parse/parseFont.js +1 -1
  124. package/esm/parse/parseInsideBorders.d.ts +9 -0
  125. package/esm/parse/parseInsideBorders.js +24 -0
  126. package/esm/parse/parsePr.d.ts +3 -0
  127. package/esm/parse/parsePr.js +108 -11
  128. package/esm/parse/parseRelationship.js +1 -1
  129. package/esm/parse/parseSdt.d.ts +5 -0
  130. package/esm/parse/parseShape.d.ts +10 -0
  131. package/esm/parse/parseShape.js +239 -0
  132. package/esm/parse/parseSize.d.ts +2 -1
  133. package/esm/parse/parseSize.js +7 -1
  134. package/esm/parse/parseSpacing.js +1 -1
  135. package/esm/parse/parseTable.d.ts +3 -0
  136. package/esm/parse/parseTable.js +62 -0
  137. package/esm/parse/parseTablePr.d.ts +3 -0
  138. package/esm/parse/parseTablePr.js +185 -0
  139. package/esm/parse/parseTblWidth.d.ts +4 -0
  140. package/esm/parse/parseTblWidth.js +23 -0
  141. package/esm/parse/parseTc.d.ts +10 -0
  142. package/esm/parse/parseTc.js +64 -0
  143. package/esm/parse/parseTcPr.d.ts +5 -0
  144. package/esm/parse/parseTcPr.js +99 -0
  145. package/esm/parse/parseTextDirection.js +4 -6
  146. package/esm/parse/parseTr.d.ts +6 -0
  147. package/esm/parse/parseTr.js +49 -0
  148. package/esm/parse/parseTrPr.d.ts +3 -0
  149. package/esm/parse/parseTrPr.js +59 -0
  150. package/esm/render/fixAbsolutePosition.d.ts +8 -0
  151. package/esm/render/renderBody.d.ts +6 -2
  152. package/esm/render/renderBody.js +184 -30
  153. package/esm/render/renderBr.d.ts +2 -1
  154. package/esm/render/renderBr.js +4 -1
  155. package/esm/render/renderCustGeom.d.ts +4 -0
  156. package/esm/render/renderCustGeom.js +10 -0
  157. package/esm/render/renderDocument.d.ts +2 -2
  158. package/esm/render/renderDocument.js +2 -2
  159. package/esm/render/renderDrawing.d.ts +3 -2
  160. package/esm/render/renderDrawing.js +238 -21
  161. package/esm/render/renderFont.d.ts +5 -0
  162. package/esm/render/renderFont.js +39 -0
  163. package/esm/render/renderGeom.d.ts +4 -0
  164. package/esm/render/renderGeom.js +14 -0
  165. package/esm/render/renderHeader.d.ts +6 -0
  166. package/esm/render/renderHeader.js +40 -0
  167. package/esm/render/renderHyperLink.js +4 -1
  168. package/esm/render/renderInlineText.js +1 -1
  169. package/esm/render/renderInstrText.js +1 -1
  170. package/esm/render/renderMath.d.ts +3 -0
  171. package/esm/render/renderMath.js +7 -0
  172. package/esm/render/renderNoBreakHyphen.d.ts +1 -0
  173. package/esm/render/renderNoBreakHyphen.js +9 -0
  174. package/esm/render/renderNotes.d.ts +5 -0
  175. package/esm/render/renderNotes.js +77 -0
  176. package/esm/render/renderNumbering.js +8 -10
  177. package/esm/render/renderParagraph.d.ts +1 -1
  178. package/esm/render/renderParagraph.js +58 -18
  179. package/esm/render/renderPict.js +5 -10
  180. package/esm/render/renderRuby.js +1 -1
  181. package/esm/render/renderRun.d.ts +4 -2
  182. package/esm/render/renderRun.js +42 -12
  183. package/esm/render/renderSection.d.ts +3 -2
  184. package/esm/render/renderSection.js +79 -5
  185. package/esm/render/renderSeparator.d.ts +1 -0
  186. package/esm/render/renderSeparator.js +9 -0
  187. package/esm/render/renderSoftHyphen.d.ts +1 -0
  188. package/esm/render/renderSoftHyphen.js +9 -0
  189. package/esm/render/renderStyle.js +36 -35
  190. package/esm/render/renderTab.d.ts +2 -1
  191. package/esm/render/renderTab.js +10 -6
  192. package/esm/render/renderTable.js +23 -20
  193. package/esm/render/setElementStyle.js +7 -2
  194. package/esm/render/zindex.d.ts +1 -0
  195. package/esm/util/blob.js +1 -10
  196. package/esm/util/color.d.ts +48 -0
  197. package/esm/util/color.js +211 -0
  198. package/esm/util/createObject.d.ts +10 -0
  199. package/esm/util/createObject.js +48 -0
  200. package/esm/util/dom.d.ts +8 -4
  201. package/esm/util/dom.js +21 -4
  202. package/esm/util/get.d.ts +4 -0
  203. package/esm/util/get.js +18 -0
  204. package/esm/util/mergeRun.js +1 -1
  205. package/esm/util/parseSides.d.ts +11 -0
  206. package/esm/util/print.d.ts +5 -0
  207. package/esm/util/print.js +54 -0
  208. package/esm/util/replaceVar.d.ts +10 -0
  209. package/esm/util/replaceVar.js +215 -0
  210. package/esm/util/xml.js +4 -1
  211. package/lib/OpenXML.d.ts +19 -0
  212. package/lib/OpenXML.js +44 -1
  213. package/lib/Word.d.ts +132 -15
  214. package/lib/Word.js +244 -59
  215. package/lib/openxml/ContentType.js +20 -6
  216. package/lib/openxml/Settings.d.ts +10 -0
  217. package/lib/openxml/Settings.js +97 -0
  218. package/lib/openxml/Style.d.ts +1 -1
  219. package/lib/openxml/Style.js +15 -15
  220. package/lib/openxml/Theme.js +31 -7
  221. package/lib/openxml/Types.d.ts +179 -2472
  222. package/lib/openxml/drawing/Blip.d.ts +7 -0
  223. package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
  224. package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
  225. package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  226. package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
  227. package/lib/openxml/drawing/CustomGeom.js +21 -0
  228. package/lib/openxml/drawing/Drawing.d.ts +37 -0
  229. package/lib/openxml/drawing/Drawing.js +177 -0
  230. package/lib/openxml/drawing/Geom.d.ts +11 -0
  231. package/lib/openxml/drawing/Geom.js +38 -0
  232. package/lib/openxml/drawing/Path.d.ts +37 -0
  233. package/lib/openxml/drawing/Pic.d.ts +16 -0
  234. package/lib/openxml/drawing/Pic.js +30 -0
  235. package/lib/openxml/drawing/Shape.d.ts +20 -0
  236. package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
  237. package/lib/openxml/drawing/ShapeProperties.js +123 -0
  238. package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +4 -1
  239. package/lib/openxml/drawing/Transform.js +67 -0
  240. package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
  241. package/lib/openxml/drawing/diagram/Diagram.js +28 -0
  242. package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
  243. package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
  244. package/lib/openxml/drawing/presetShape.d.ts +3 -0
  245. package/lib/openxml/drawing/presetShape.js +38789 -0
  246. package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
  247. package/lib/openxml/drawing/svg/arcToA.js +92 -0
  248. package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
  249. package/lib/openxml/drawing/svg/formulas.js +108 -0
  250. package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
  251. package/lib/openxml/drawing/svg/generateDefines.js +148 -0
  252. package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
  253. package/lib/openxml/drawing/svg/presetVal.js +57 -0
  254. package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  255. package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
  256. package/lib/openxml/math/OMath.d.ts +5 -0
  257. package/lib/openxml/math/OMath.js +16 -0
  258. package/lib/openxml/math/convertOOML.d.ts +4 -0
  259. package/lib/openxml/math/convertOOML.js +17 -0
  260. package/lib/openxml/math/xsl.d.ts +4 -0
  261. package/lib/openxml/math/xsl.js +12 -0
  262. package/lib/openxml/word/Body.js +11 -7
  263. package/lib/openxml/word/Break.js +1 -3
  264. package/lib/openxml/word/Font.d.ts +16 -0
  265. package/lib/openxml/word/Font.js +83 -0
  266. package/lib/openxml/word/FontTable.d.ts +9 -0
  267. package/lib/openxml/word/FontTable.js +38 -0
  268. package/lib/openxml/word/Header.d.ts +11 -0
  269. package/lib/openxml/word/Header.js +58 -0
  270. package/lib/openxml/word/Hyperlink.d.ts +1 -0
  271. package/lib/openxml/word/Hyperlink.js +8 -4
  272. package/lib/openxml/word/InlineText.js +2 -2
  273. package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
  274. package/lib/openxml/word/NoBreakHyphen.js +11 -0
  275. package/lib/openxml/word/Note.d.ts +12 -0
  276. package/lib/openxml/word/Note.js +52 -0
  277. package/lib/openxml/word/Paragraph.d.ts +2 -2
  278. package/lib/openxml/word/Paragraph.js +11 -10
  279. package/lib/openxml/word/Pict.d.ts +1 -2
  280. package/lib/openxml/word/Pict.js +5 -3
  281. package/lib/openxml/word/Ruby.js +4 -4
  282. package/lib/openxml/word/Run.d.ts +7 -3
  283. package/lib/openxml/word/Run.js +29 -5
  284. package/lib/openxml/word/Section.d.ts +18 -5
  285. package/lib/openxml/word/Section.js +47 -3
  286. package/lib/openxml/word/Separator.d.ts +5 -0
  287. package/lib/openxml/word/Separator.js +14 -0
  288. package/lib/openxml/word/SoftHyphen.d.ts +5 -0
  289. package/lib/openxml/word/SoftHyphen.js +14 -0
  290. package/lib/openxml/word/Tab.d.ts +1 -1
  291. package/lib/openxml/word/Table.d.ts +4 -9
  292. package/lib/openxml/word/Table.js +0 -235
  293. package/lib/openxml/word/WDocument.d.ts +1 -2
  294. package/lib/openxml/word/WDocument.js +53 -7
  295. package/lib/openxml/word/numbering/AbstractNum.js +5 -3
  296. package/lib/openxml/word/numbering/Lvl.js +11 -5
  297. package/lib/openxml/word/numbering/Num.js +12 -4
  298. package/lib/openxml/word/numbering/NumberProperties.js +2 -2
  299. package/lib/openxml/word/numbering/Numbering.js +3 -3
  300. package/lib/openxml/word/table/Tc.d.ts +1 -22
  301. package/lib/openxml/word/table/Tc.js +0 -224
  302. package/lib/openxml/word/table/Tr.d.ts +0 -5
  303. package/lib/openxml/word/table/Tr.js +0 -97
  304. package/lib/openxml/word/wps/WPG.d.ts +14 -0
  305. package/lib/openxml/word/wps/WPG.js +60 -0
  306. package/lib/openxml/word/wps/WPS.d.ts +18 -0
  307. package/lib/openxml/word/wps/WPS.js +152 -0
  308. package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
  309. package/lib/openxml/word/wps/WPSStyle.js +46 -0
  310. package/lib/package/PackageParser.d.ts +1 -1
  311. package/lib/package/XMLPackageParser.d.ts +3 -3
  312. package/lib/package/ZipPackageParser.d.ts +1 -1
  313. package/lib/package/ZipPackageParser.js +7 -8
  314. package/lib/parse/Footnotes.d.ts +3 -0
  315. package/lib/parse/Footnotes.js +29 -0
  316. package/lib/parse/colorNameMap.d.ts +6 -0
  317. package/lib/parse/colorNameMap.js +205 -0
  318. package/lib/parse/jcToTextAlign.js +1 -0
  319. package/lib/parse/mergeSdt.d.ts +4 -0
  320. package/lib/parse/mergeSdt.js +61 -0
  321. package/lib/parse/modifyColor.d.ts +1 -0
  322. package/lib/parse/modifyColor.js +110 -0
  323. package/lib/parse/parseBorder.js +3 -22
  324. package/lib/parse/parseCellMargin.d.ts +2 -0
  325. package/lib/parse/parseCellMargin.js +42 -0
  326. package/lib/parse/parseChildColor.d.ts +5 -0
  327. package/lib/parse/parseChildColor.js +70 -0
  328. package/lib/parse/parseColor.d.ts +4 -0
  329. package/lib/parse/parseColor.js +41 -45
  330. package/lib/parse/parseEndnotes.d.ts +3 -0
  331. package/lib/parse/parseEndnotes.js +29 -0
  332. package/lib/parse/parseFont.js +2 -2
  333. package/lib/parse/parseInsideBorders.d.ts +9 -0
  334. package/lib/parse/parseInsideBorders.js +28 -0
  335. package/lib/parse/parsePr.d.ts +3 -0
  336. package/lib/parse/parsePr.js +109 -12
  337. package/lib/parse/parseRelationship.js +2 -2
  338. package/lib/parse/parseSdt.d.ts +5 -0
  339. package/lib/parse/parseShape.d.ts +10 -0
  340. package/lib/parse/parseShape.js +247 -0
  341. package/lib/parse/parseSize.d.ts +2 -1
  342. package/lib/parse/parseSize.js +7 -0
  343. package/lib/parse/parseSpacing.js +1 -1
  344. package/lib/parse/parseTable.d.ts +3 -0
  345. package/lib/parse/parseTable.js +66 -0
  346. package/lib/parse/parseTablePr.d.ts +3 -0
  347. package/lib/parse/parseTablePr.js +189 -0
  348. package/lib/parse/parseTblWidth.d.ts +4 -0
  349. package/lib/parse/parseTblWidth.js +27 -0
  350. package/lib/parse/parseTc.d.ts +10 -0
  351. package/lib/parse/parseTc.js +68 -0
  352. package/lib/parse/parseTcPr.d.ts +5 -0
  353. package/lib/parse/parseTcPr.js +104 -0
  354. package/lib/parse/parseTextDirection.js +4 -6
  355. package/lib/parse/parseTr.d.ts +6 -0
  356. package/lib/parse/parseTr.js +53 -0
  357. package/lib/parse/parseTrPr.d.ts +3 -0
  358. package/lib/parse/parseTrPr.js +63 -0
  359. package/lib/render/fixAbsolutePosition.d.ts +8 -0
  360. package/lib/render/renderBody.d.ts +6 -2
  361. package/lib/render/renderBody.js +183 -29
  362. package/lib/render/renderBr.d.ts +2 -1
  363. package/lib/render/renderBr.js +4 -1
  364. package/lib/render/renderCustGeom.d.ts +4 -0
  365. package/lib/render/renderCustGeom.js +14 -0
  366. package/lib/render/renderDocument.d.ts +2 -2
  367. package/lib/render/renderDocument.js +2 -2
  368. package/lib/render/renderDrawing.d.ts +3 -2
  369. package/lib/render/renderDrawing.js +238 -21
  370. package/lib/render/renderFont.d.ts +5 -0
  371. package/lib/render/renderFont.js +43 -0
  372. package/lib/render/renderGeom.d.ts +4 -0
  373. package/lib/render/renderGeom.js +18 -0
  374. package/lib/render/renderHeader.d.ts +6 -0
  375. package/lib/render/renderHeader.js +44 -0
  376. package/lib/render/renderHyperLink.js +5 -2
  377. package/lib/render/renderInlineText.js +2 -2
  378. package/lib/render/renderInstrText.js +2 -2
  379. package/lib/render/renderMath.d.ts +3 -0
  380. package/lib/render/renderMath.js +11 -0
  381. package/lib/render/renderNoBreakHyphen.d.ts +1 -0
  382. package/lib/render/renderNoBreakHyphen.js +13 -0
  383. package/lib/render/renderNotes.d.ts +5 -0
  384. package/lib/render/renderNotes.js +81 -0
  385. package/lib/render/renderNumbering.js +9 -11
  386. package/lib/render/renderParagraph.d.ts +1 -1
  387. package/lib/render/renderParagraph.js +58 -18
  388. package/lib/render/renderPict.js +5 -10
  389. package/lib/render/renderRuby.js +3 -3
  390. package/lib/render/renderRun.d.ts +4 -2
  391. package/lib/render/renderRun.js +41 -11
  392. package/lib/render/renderSection.d.ts +3 -2
  393. package/lib/render/renderSection.js +79 -5
  394. package/lib/render/renderSeparator.d.ts +1 -0
  395. package/lib/render/renderSeparator.js +13 -0
  396. package/lib/render/renderSoftHyphen.d.ts +1 -0
  397. package/lib/render/renderSoftHyphen.js +13 -0
  398. package/lib/render/renderStyle.js +37 -36
  399. package/lib/render/renderTab.d.ts +2 -1
  400. package/lib/render/renderTab.js +10 -6
  401. package/lib/render/renderTable.js +25 -22
  402. package/lib/render/setElementStyle.js +6 -1
  403. package/lib/render/zindex.d.ts +1 -0
  404. package/lib/util/blob.js +0 -10
  405. package/lib/util/color.d.ts +48 -0
  406. package/lib/util/color.js +215 -0
  407. package/lib/util/createObject.d.ts +10 -0
  408. package/lib/util/createObject.js +54 -0
  409. package/lib/util/dom.d.ts +8 -4
  410. package/lib/util/dom.js +24 -5
  411. package/lib/util/get.d.ts +4 -0
  412. package/lib/util/get.js +22 -0
  413. package/lib/util/mergeRun.js +5 -5
  414. package/lib/util/parseSides.d.ts +11 -0
  415. package/lib/util/print.d.ts +5 -0
  416. package/lib/util/print.js +58 -0
  417. package/lib/util/replaceVar.d.ts +10 -0
  418. package/lib/util/replaceVar.js +220 -0
  419. package/lib/util/xml.js +4 -0
  420. package/package.json +17 -7
  421. package/esm/node_modules/tslib/tslib.es6.js +0 -120
  422. package/esm/openxml/Types.js +0 -1003
  423. package/esm/openxml/word/CustomXml.d.ts +0 -8
  424. package/esm/openxml/word/SmartTag.d.ts +0 -8
  425. package/esm/openxml/word/SmartTag.js +0 -18
  426. package/esm/openxml/word/drawing/Blip.d.ts +0 -6
  427. package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
  428. package/esm/openxml/word/drawing/Drawing.js +0 -15
  429. package/esm/openxml/word/drawing/Pic.d.ts +0 -8
  430. package/esm/openxml/word/drawing/Pic.js +0 -16
  431. package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  432. package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
  433. package/esm/openxml/word/drawing/Transform.js +0 -30
  434. package/lib/node_modules/tslib/tslib.es6.js +0 -129
  435. package/lib/openxml/Types.js +0 -1005
  436. package/lib/openxml/word/CustomXml.d.ts +0 -8
  437. package/lib/openxml/word/SmartTag.d.ts +0 -8
  438. package/lib/openxml/word/SmartTag.js +0 -22
  439. package/lib/openxml/word/drawing/Blip.d.ts +0 -6
  440. package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
  441. package/lib/openxml/word/drawing/Drawing.js +0 -19
  442. package/lib/openxml/word/drawing/Pic.d.ts +0 -8
  443. package/lib/openxml/word/drawing/Pic.js +0 -20
  444. package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  445. package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
  446. package/lib/openxml/word/drawing/Transform.js +0 -34
@@ -0,0 +1,99 @@
1
+ import { __values } from 'tslib';
2
+ import { parseCellMargin } from './parseCellMargin.js';
3
+ import { parseShdColor } from './parseColor.js';
4
+ import { getValBoolean, getVal, getValNumber } from '../OpenXML.js';
5
+ import { parseBorders } from './parseBorder.js';
6
+ import { parseTextDirection } from './parseTextDirection.js';
7
+ import { parseTblWidth } from './parseTblWidth.js';
8
+ import { parseInsideBorders } from './parseInsideBorders.js';
9
+
10
+ function parseVAlign(element, style) {
11
+ var vAlign = getVal(element);
12
+ switch (vAlign) {
13
+ case 'bottom':
14
+ style['vertical-align'] = 'bottom';
15
+ break;
16
+ case 'center':
17
+ style['vertical-align'] = 'middle';
18
+ break;
19
+ case 'top':
20
+ style['vertical-align'] = 'top';
21
+ break;
22
+ }
23
+ }
24
+ function parseTblCellSpacing(element, style) {
25
+ var width = parseTblWidth(element);
26
+ if (width) {
27
+ style['cell-spacing'] = width;
28
+ }
29
+ }
30
+ function parseTcW(element, style) {
31
+ var width = parseTblWidth(element);
32
+ if (width) {
33
+ style.width = width;
34
+ }
35
+ }
36
+ function parseTcPr(word, element) {
37
+ var e_1, _a;
38
+ var properties = {};
39
+ var style = {};
40
+ properties.cssStyle = style;
41
+ try {
42
+ for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
43
+ var child = _c.value;
44
+ var tagName = child.tagName;
45
+ switch (tagName) {
46
+ case 'w:tcMar':
47
+ parseCellMargin(child, style);
48
+ break;
49
+ case 'w:shd':
50
+ style['background-color'] = parseShdColor(word, child);
51
+ break;
52
+ case 'w:tcW':
53
+ parseTcW(child, style);
54
+ break;
55
+ case 'w:noWrap':
56
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noWrap.html
57
+ var noWrap = getValBoolean(child);
58
+ if (noWrap) {
59
+ style['white-space'] = 'nowrap';
60
+ }
61
+ break;
62
+ case 'w:vAlign':
63
+ parseVAlign(child, style);
64
+ break;
65
+ case 'w:tcBorders':
66
+ parseBorders(word, child, style);
67
+ properties.insideBorder = parseInsideBorders(word, child);
68
+ break;
69
+ case 'w:gridSpan':
70
+ properties.gridSpan = getValNumber(child);
71
+ break;
72
+ case 'w:vMerge':
73
+ properties.vMerge = getVal(child) || 'continue';
74
+ break;
75
+ case 'w:textDirection':
76
+ parseTextDirection(child, style);
77
+ break;
78
+ case 'w:cnfStyle':
79
+ // 目前是自动计算的,所以不需要这个了
80
+ break;
81
+ case 'w:hideMark':
82
+ properties.hideMark = getValBoolean(child, true);
83
+ break;
84
+ default:
85
+ console.warn('parseTcPr: ignore', tagName, child);
86
+ }
87
+ }
88
+ }
89
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
90
+ finally {
91
+ try {
92
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
93
+ }
94
+ finally { if (e_1) throw e_1.error; }
95
+ }
96
+ return properties;
97
+ }
98
+
99
+ export { parseTblCellSpacing, parseTcPr };
@@ -1,20 +1,18 @@
1
- import { ST_TextDirection } from '../openxml/Types.js';
2
-
3
1
  function parseTextDirection(element, style) {
4
2
  var val = element.getAttribute('w:val');
5
3
  // 目前值支持 ltr 或 rtl
6
4
  // 奇怪这里的类型定义不完整,可能是脚本的问题
7
5
  switch (val) {
8
- case ST_TextDirection.lr:
9
- case ST_TextDirection.lrV:
6
+ case 'lr':
7
+ case 'lrV':
10
8
  case 'btLr':
11
9
  case 'lrTb':
12
10
  case 'lrTbV':
13
11
  case 'tbLrV':
14
12
  style['direction'] = 'ltr';
15
13
  break;
16
- case ST_TextDirection.rl:
17
- case ST_TextDirection.rlV:
14
+ case 'rl':
15
+ case 'rlV':
18
16
  case 'tbRl':
19
17
  case 'tbRlV':
20
18
  style['direction'] = 'rtl';
@@ -0,0 +1,6 @@
1
+ import Word from '../Word';
2
+ import { Tr } from '../openxml/word/table/Tr';
3
+ import { Tc } from '../openxml/word/table/Tc';
4
+ export declare function parseTr(word: Word, element: Element, rowSpanMap: {
5
+ [key: string]: Tc;
6
+ }): Tr;
@@ -0,0 +1,49 @@
1
+ import { __values } from 'tslib';
2
+ import { Tr } from '../openxml/word/table/Tr.js';
3
+ import { parseTc } from './parseTc.js';
4
+ import { parseTablePr } from './parseTablePr.js';
5
+ import { parseTrPr } from './parseTrPr.js';
6
+ import { mergeSdt } from './mergeSdt.js';
7
+
8
+ function parseTr(word, element, rowSpanMap) {
9
+ var e_1, _a;
10
+ var tr = new Tr();
11
+ // 做成对象是为了传递引用来修改
12
+ var currentCol = {
13
+ index: 0
14
+ };
15
+ try {
16
+ for (var _b = __values(mergeSdt(element)), _c = _b.next(); !_c.done; _c = _b.next()) {
17
+ var child = _c.value;
18
+ var tagName = child.tagName;
19
+ switch (tagName) {
20
+ case 'w:tc':
21
+ var tc = parseTc(word, child, currentCol, rowSpanMap);
22
+ if (tc) {
23
+ tr.tcs.push(tc);
24
+ }
25
+ break;
26
+ case 'w:trPr':
27
+ tr.properties = parseTrPr(word, child);
28
+ break;
29
+ case 'w:tblPrEx':
30
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
31
+ var tablePr = parseTablePr(word, child);
32
+ Object.assign(tr.properties.cssStyle || {}, tablePr.cssStyle);
33
+ break;
34
+ default:
35
+ console.warn("Tr: Unknown tag ", tagName, child);
36
+ }
37
+ }
38
+ }
39
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
40
+ finally {
41
+ try {
42
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
43
+ }
44
+ finally { if (e_1) throw e_1.error; }
45
+ }
46
+ return tr;
47
+ }
48
+
49
+ export { parseTr };
@@ -0,0 +1,3 @@
1
+ import { TrPr } from '../openxml/word/table/Tr';
2
+ import Word from '../Word';
3
+ export declare function parseTrPr(word: Word, element: Element): TrPr;
@@ -0,0 +1,59 @@
1
+ import { __values } from 'tslib';
2
+ import { getVal, getValBoolean } from '../OpenXML.js';
3
+ import { jcToTextAlign } from './jcToTextAlign.js';
4
+ import { parseTablePr } from './parseTablePr.js';
5
+ import { parseTblCellSpacing } from './parseTcPr.js';
6
+ import { parseTrHeight } from './parseTrHeight.js';
7
+
8
+ function parseTrPr(word, element) {
9
+ var e_1, _a;
10
+ var cssStyle = {};
11
+ var tcStyle = {};
12
+ try {
13
+ for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
14
+ var child = _c.value;
15
+ var tagName = child.tagName;
16
+ switch (tagName) {
17
+ case 'w:hidden':
18
+ if (getValBoolean(child)) {
19
+ cssStyle.display = 'none';
20
+ }
21
+ break;
22
+ case 'w:trHeight':
23
+ parseTrHeight(child, cssStyle);
24
+ break;
25
+ case 'w:jc':
26
+ cssStyle['text-align'] = jcToTextAlign(getVal(child));
27
+ break;
28
+ case 'w:cantSplit':
29
+ // 目前也不支持分页
30
+ break;
31
+ case 'w:tblPrEx':
32
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
33
+ var tablePr = parseTablePr(word, child);
34
+ Object.assign(cssStyle, tablePr.cssStyle);
35
+ break;
36
+ case 'w:tblCellSpacing':
37
+ parseTblCellSpacing(child, tcStyle);
38
+ break;
39
+ case 'w:cnfStyle':
40
+ // 目前是自动计算的,所以不需要这个了
41
+ break;
42
+ default:
43
+ console.warn("Tr: Unknown tag ", tagName, child);
44
+ }
45
+ }
46
+ }
47
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
+ finally {
49
+ try {
50
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
51
+ }
52
+ finally { if (e_1) throw e_1.error; }
53
+ }
54
+ return {
55
+ cssStyle: cssStyle
56
+ };
57
+ }
58
+
59
+ export { parseTrPr };
@@ -0,0 +1,8 @@
1
+ import { CSSStyle } from '../openxml/Style';
2
+ import Word from '../Word';
3
+ /**
4
+ * 修复绝对定位的位置,主要是加上 padding,因为 html 中的定位是不考虑 padding 的
5
+ * @param word
6
+ * @param style
7
+ */
8
+ export declare function fixAbsolutePosition(word: Word, style: CSSStyle, inHeader?: boolean): void;
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * 渲染 body 节点
3
3
  */
4
- import Word from '../Word';
4
+ import Word, { WordRenderOptions } from '../Word';
5
5
  import { Body } from '../openxml/word/Body';
6
- export default function renderBody(word: Word, parent: HTMLElement, body: Body): void;
6
+ import { WDocument } from '../openxml/word/WDocument';
7
+ /**
8
+ * 渲染文档主体
9
+ */
10
+ export default function renderBody(root: HTMLElement, word: Word, bodyEl: HTMLElement, wDocument: WDocument, body: Body, renderOptions: WordRenderOptions): void;
@@ -1,8 +1,7 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
2
- import { appendChild } from '../util/dom.js';
1
+ import { __values, __spreadArray, __read } from 'tslib';
2
+ import { appendChild, removeChild } from '../util/dom.js';
3
3
  import { Paragraph } from '../openxml/word/Paragraph.js';
4
4
  import { Table } from '../openxml/word/Table.js';
5
- import { Hyperlink } from '../openxml/word/Hyperlink.js';
6
5
  import renderParagraph from './renderParagraph.js';
7
6
  import { renderSection } from './renderSection.js';
8
7
  import renderTable from './renderTable.js';
@@ -10,44 +9,199 @@ import renderTable from './renderTable.js';
10
9
  /**
11
10
  * 渲染 body 节点
12
11
  */
13
- function renderBody(word, parent, body) {
14
- var e_1, _a, e_2, _b;
15
- try {
16
- for (var _c = __values(body.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
17
- var section = _d.value;
18
- var sectionEl = renderSection(word, section);
19
- appendChild(parent, sectionEl);
20
- try {
21
- for (var _e = (e_2 = void 0, __values(section.children)), _f = _e.next(); !_f.done; _f = _e.next()) {
22
- var child = _f.value;
23
- if (child instanceof Paragraph) {
24
- var p = renderParagraph(word, child);
25
- appendChild(sectionEl, p);
26
- }
27
- else if (child instanceof Table) {
28
- appendChild(sectionEl, renderTable(word, child));
29
- }
30
- else if (child instanceof Hyperlink) {
31
- }
12
+ /**
13
+ * 判断是否需要创建一个新 section,包括强制分页和超出了 section 的高宽或宽度
14
+ */
15
+ function createNewSection(word, sectionEnd, child) {
16
+ // 支持插入分页符
17
+ if (word.breakPage) {
18
+ word.breakPage = false;
19
+ return true;
20
+ }
21
+ var childBound = child.getBoundingClientRect();
22
+ return (childBound.top + childBound.height > sectionEnd.bottom ||
23
+ // 注意这里没有 + childBound.width,因为 width 一般都是 100% 导致容易超出
24
+ childBound.left > sectionEnd.right);
25
+ }
26
+ /**
27
+ * 添加到 section 里,如果超出了就创建一个新的 section
28
+ */
29
+ function appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, child) {
30
+ // 如果是第一个节点,即便超长也得写入,不然就会出现一个空 section
31
+ var isFirst = sectionEl.children.length === 0;
32
+ // 首先尝试写入
33
+ appendChild(sectionEl, child);
34
+ // 如果超出了就新建一个 section
35
+ if (!isFirst && createNewSection(word, sectionEnd, child)) {
36
+ var newChild = child.cloneNode(true);
37
+ removeChild(sectionEl, child);
38
+ var newSectionEl = renderSection(word, wDocument, section, renderOptions);
39
+ appendChild(bodyEl, newSectionEl);
40
+ appendChild(newSectionEl, newChild);
41
+ sectionEnd = getSectionEnd(section, newSectionEl);
42
+ return { sectionEl: newSectionEl, sectionEnd: sectionEnd };
43
+ }
44
+ return { sectionEl: sectionEl, sectionEnd: sectionEnd };
45
+ }
46
+ /**
47
+ * 获取 section 结束的位置,也就是最后能放下子元素的位置
48
+ */
49
+ function getSectionEnd(section, sectionEl) {
50
+ var sectionBound = sectionEl.getBoundingClientRect();
51
+ var pageMargin = section.properties.pageMargin;
52
+ var bottom = sectionBound.top + sectionBound.height;
53
+ if (pageMargin === null || pageMargin === void 0 ? void 0 : pageMargin.bottom) {
54
+ bottom = bottom - parseInt(pageMargin.bottom.replace('px', ''), 10);
55
+ }
56
+ var right = sectionBound.left + sectionBound.width;
57
+ if (pageMargin === null || pageMargin === void 0 ? void 0 : pageMargin.right) {
58
+ right = right - parseInt(pageMargin.right.replace('px', ''), 10);
59
+ }
60
+ return { bottom: bottom, right: right };
61
+ }
62
+ /**
63
+ * 获取缩放比例
64
+ */
65
+ function getTransform(rootWidth, section, renderOptions) {
66
+ var props = section.properties;
67
+ var pageSize = props.pageSize;
68
+ if (renderOptions.zoomFitWidth && !renderOptions.ignoreWidth) {
69
+ var pageWidth = pageSize === null || pageSize === void 0 ? void 0 : pageSize.width;
70
+ if (rootWidth && pageWidth) {
71
+ var pageWidthNum = parseInt(pageWidth.replace('px', ''), 10);
72
+ if (props.pageMargin) {
73
+ var pageMargin = props.pageMargin;
74
+ pageWidthNum += pageMargin.left
75
+ ? parseInt(pageMargin.left.replace('px', ''), 10)
76
+ : 0;
77
+ pageWidthNum += pageMargin.right
78
+ ? parseInt(pageMargin.right.replace('px', ''), 10)
79
+ : 0;
80
+ }
81
+ var zoomWidth = rootWidth / pageWidthNum;
82
+ return zoomWidth;
83
+ }
84
+ }
85
+ return 1;
86
+ }
87
+ /**
88
+ * 分页渲染
89
+ * @param isLastSection 是否是最后一节
90
+ */
91
+ function renderSectionInPage(word, wDocument, bodyEl, renderOptions, sectionEl, section, isLastSection) {
92
+ // 如果不 setTimeout 取到的位置信息不对
93
+ setTimeout(function () {
94
+ var e_1, _a;
95
+ var sectionEnd = getSectionEnd(section, sectionEl);
96
+ try {
97
+ for (var _b = __values(section.children), _c = _b.next(); !_c.done; _c = _b.next()) {
98
+ var child = _c.value;
99
+ if (child instanceof Paragraph) {
100
+ var p = renderParagraph(word, child);
101
+ var appendResult = appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, p);
102
+ sectionEl = appendResult.sectionEl;
103
+ sectionEnd = appendResult.sectionEnd;
104
+ }
105
+ else if (child instanceof Table) {
106
+ var table = renderTable(word, child);
107
+ var appendResult = appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, table);
108
+ sectionEl = appendResult.sectionEl;
109
+ sectionEnd = appendResult.sectionEnd;
110
+ }
111
+ else {
112
+ console.warn('unknown child', child);
32
113
  }
33
114
  }
34
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
35
- finally {
115
+ }
116
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
117
+ finally {
118
+ try {
119
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
120
+ }
121
+ finally { if (e_1) throw e_1.error; }
122
+ }
123
+ if (isLastSection) {
124
+ sectionEl.style.marginBottom = '0';
125
+ }
126
+ }, 0);
127
+ }
128
+ /**
129
+ * 渲染文档主体
130
+ */
131
+ function renderBody(root, word, bodyEl, wDocument, body, renderOptions) {
132
+ var e_2, _a, e_3, _b;
133
+ var page = renderOptions.page || false;
134
+ var rootWidth = root.getBoundingClientRect().width -
135
+ (renderOptions.pageWrapPadding || 0) * 2;
136
+ var zooms = [];
137
+ var index = 0;
138
+ var sections = body.sections;
139
+ var sectionLength = sections.length;
140
+ // 用于最后一个 section 不加 margin-bottom
141
+ var isLastSection = false;
142
+ try {
143
+ for (var sections_1 = __values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
144
+ var section = sections_1_1.value;
145
+ zooms.push(getTransform(rootWidth, section, renderOptions));
146
+ word.currentSection = section;
147
+ var sectionEl = renderSection(word, wDocument, section, renderOptions);
148
+ appendChild(bodyEl, sectionEl);
149
+ index = index + 1;
150
+ if (index === sectionLength) {
151
+ isLastSection = true;
152
+ }
153
+ if (page) {
154
+ renderSectionInPage(word, wDocument, bodyEl, renderOptions, sectionEl, section, isLastSection);
155
+ }
156
+ else {
36
157
  try {
37
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
158
+ for (var _c = (e_3 = void 0, __values(section.children)), _d = _c.next(); !_d.done; _d = _c.next()) {
159
+ var child = _d.value;
160
+ if (child instanceof Paragraph) {
161
+ var p = renderParagraph(word, child);
162
+ appendChild(sectionEl, p);
163
+ }
164
+ else if (child instanceof Table) {
165
+ var table = renderTable(word, child);
166
+ appendChild(sectionEl, table);
167
+ }
168
+ else {
169
+ console.warn('unknown child', child);
170
+ }
171
+ }
172
+ }
173
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
174
+ finally {
175
+ try {
176
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
177
+ }
178
+ finally { if (e_3) throw e_3.error; }
38
179
  }
39
- finally { if (e_2) throw e_2.error; }
40
180
  }
41
- appendChild(parent, sectionEl);
42
181
  }
43
182
  }
44
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
183
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
45
184
  finally {
46
185
  try {
47
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
186
+ if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return)) _a.call(sections_1);
48
187
  }
49
- finally { if (e_1) throw e_1.error; }
188
+ finally { if (e_2) throw e_2.error; }
50
189
  }
190
+ setTimeout(function () {
191
+ if (renderOptions.zoom) {
192
+ // 固定缩放
193
+ bodyEl.style.transformOrigin = '0 0';
194
+ bodyEl.style.transform = "scale(".concat(renderOptions.zoom, ")");
195
+ }
196
+ else if (renderOptions.page &&
197
+ renderOptions.zoomFitWidth &&
198
+ !renderOptions.ignoreWidth) {
199
+ // 自适应宽度的缩放
200
+ var minZoom = Math.min.apply(Math, __spreadArray([], __read(zooms), false));
201
+ bodyEl.style.transformOrigin = '0 0';
202
+ bodyEl.style.transform = "scale(".concat(minZoom, ")");
203
+ }
204
+ }, 0);
51
205
  }
52
206
 
53
207
  export { renderBody as default };
@@ -1,7 +1,8 @@
1
+ import Word from '../Word';
1
2
  import { Break } from '../openxml/word/Break';
2
3
  /**
3
4
  * 解析 br http://officeopenxml.com/WPtextSpecialContent-break.php
4
5
  * 其实还有 column 和 page,但目前还没实现分页渲染,所以目前先简单处理,后续再看看如何处理
5
6
  * @returns 生成的 dom 结构
6
7
  */
7
- export declare function renderBr(brak: Break): HTMLElement;
8
+ export declare function renderBr(word: Word, brak: Break): HTMLElement;
@@ -5,7 +5,10 @@ import { createElement } from '../util/dom.js';
5
5
  * 其实还有 column 和 page,但目前还没实现分页渲染,所以目前先简单处理,后续再看看如何处理
6
6
  * @returns 生成的 dom 结构
7
7
  */
8
- function renderBr(brak) {
8
+ function renderBr(word, brak) {
9
+ if (brak.type === 'page') {
10
+ word.breakPage = true;
11
+ }
9
12
  var br = createElement('br');
10
13
  return br;
11
14
  }
@@ -0,0 +1,4 @@
1
+ import { ShapePr } from '../openxml/drawing/ShapeProperties';
2
+ import { WPSStyle } from '../openxml/word/wps/WPSStyle';
3
+ import { CustomGeom } from '../openxml/drawing/CustomGeom';
4
+ export declare function renderCustGeom(geom: CustomGeom, shapePr: ShapePr, width: number, height: number, wpsStyle?: WPSStyle): SVGElement | null;
@@ -0,0 +1,10 @@
1
+ import { shapeToSVG } from '../openxml/drawing/svg/shapeToSVG.js';
2
+
3
+ function renderCustGeom(geom, shapePr, width, height, wpsStyle) {
4
+ if (geom.shape) {
5
+ return shapeToSVG(geom.shape, [], shapePr, width, height, wpsStyle);
6
+ }
7
+ return null;
8
+ }
9
+
10
+ export { renderCustGeom };
@@ -1,7 +1,7 @@
1
- import Word from '../Word';
1
+ import Word, { WordRenderOptions } from '../Word';
2
2
  import { WDocument } from '../openxml/word/WDocument';
3
3
  /**
4
4
  * 渲染 document 主要入口
5
5
  * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
6
6
  */
7
- export default function renderDocument(word: Word, document: WDocument): HTMLElement;
7
+ export default function renderDocument(root: HTMLElement, word: Word, wDocument: WDocument, renderOptions: WordRenderOptions): HTMLElement;
@@ -5,9 +5,9 @@ import renderBody from './renderBody.js';
5
5
  * 渲染 document 主要入口
6
6
  * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
7
7
  */
8
- function renderDocument(word, document) {
8
+ function renderDocument(root, word, wDocument, renderOptions) {
9
9
  var doc = createElement('article');
10
- renderBody(word, doc, document.body);
10
+ renderBody(root, word, doc, wDocument, wDocument.body, renderOptions);
11
11
  return doc;
12
12
  }
13
13
 
@@ -1,8 +1,9 @@
1
1
  import Word from '../Word';
2
- import { Drawing } from '../openxml/word/drawing/Drawing';
2
+ import { Drawing } from '../openxml/drawing/Drawing';
3
3
  /**
4
4
  * 渲染图片,目前只支持 picture
5
5
  * http://officeopenxml.com/drwOverview.php
6
+ * @param inHeader,如果在 header 中,位置计算要特殊处理
6
7
  *
7
8
  */
8
- export declare function renderDrawing(word: Word, drawing: Drawing): HTMLElement | null;
9
+ export declare function renderDrawing(word: Word, drawing: Drawing, inHeader?: boolean): HTMLElement | null;