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
@@ -1,9 +1,9 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __values } from 'tslib';
2
2
  import { renderBr } from './renderBr.js';
3
- import { createElement, appendChild } from '../util/dom.js';
3
+ import { createElement, applyStyle, appendChild } from '../util/dom.js';
4
4
  import { Text } from '../openxml/word/Run.js';
5
5
  import { Break } from '../openxml/word/Break.js';
6
- import { Drawing } from '../openxml/word/drawing/Drawing.js';
6
+ import { Drawing } from '../openxml/drawing/Drawing.js';
7
7
  import { renderDrawing } from './renderDrawing.js';
8
8
  import { setElementStyle } from './setElementStyle.js';
9
9
  import { Tab } from '../openxml/word/Tab.js';
@@ -17,6 +17,12 @@ import { renderInstrText } from './renderInstrText.js';
17
17
  import { Sym } from '../openxml/word/Sym.js';
18
18
  import { renderSym } from './renderSym.js';
19
19
  import { cjkspace } from '../util/autoSpace.js';
20
+ import { renderSoftHyphen } from './renderSoftHyphen.js';
21
+ import { SoftHyphen } from '../openxml/word/SoftHyphen.js';
22
+ import { NoBreakHyphen } from '../openxml/word/NoBreakHyphen.js';
23
+ import { renderNoBreakHyphen } from './renderNoBreakHyphen.js';
24
+ import { Separator } from '../openxml/word/Separator.js';
25
+ import { renderSeparator } from './renderSeparator.js';
20
26
 
21
27
  /**
22
28
  * run 相关的 http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Run_1.html
@@ -56,31 +62,41 @@ function updateVariableText(word) {
56
62
  }
57
63
  /**
58
64
  * 渲染 run 节点
65
+ *
66
+ * @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
59
67
  */
60
- function renderRun(word, run, paragraph) {
68
+ function renderRun(word, run, paragraph, inFldChar, inHeader) {
61
69
  var e_1, _a;
70
+ var _b, _c;
62
71
  var span = createElement('span');
63
72
  word.addClass(span, 'r');
64
73
  setElementStyle(word, span, run.properties);
74
+ // run 不好通过 class 来设置 rStyle,所以单独支持一下
75
+ if ((_b = run.properties) === null || _b === void 0 ? void 0 : _b.rStyle) {
76
+ var style = word.getStyle(run.properties.rStyle);
77
+ if ((_c = style === null || style === void 0 ? void 0 : style.rPr) === null || _c === void 0 ? void 0 : _c.cssStyle) {
78
+ applyStyle(span, style.rPr.cssStyle);
79
+ }
80
+ }
65
81
  if (run.children.length === 1 && run.children[0] instanceof Text) {
66
82
  var text = run.children[0];
67
83
  renderText(span, word, text.text, paragraph);
68
84
  }
69
85
  else {
70
86
  try {
71
- for (var _b = __values(run.children), _c = _b.next(); !_c.done; _c = _b.next()) {
72
- var child = _c.value;
87
+ for (var _d = __values(run.children), _e = _d.next(); !_e.done; _e = _d.next()) {
88
+ var child = _e.value;
73
89
  if (child instanceof Text) {
74
90
  var newSpan = createElement('span');
75
- renderText(span, word, child.text, paragraph);
91
+ renderText(newSpan, word, child.text, paragraph);
76
92
  appendChild(span, newSpan);
77
93
  }
78
94
  else if (child instanceof Break) {
79
- var br = renderBr(child);
95
+ var br = renderBr(word, child);
80
96
  appendChild(span, br);
81
97
  }
82
98
  else if (child instanceof Drawing) {
83
- appendChild(span, renderDrawing(word, child));
99
+ appendChild(span, renderDrawing(word, child, inHeader));
84
100
  }
85
101
  else if (child instanceof Tab) {
86
102
  appendChild(span, renderTab(word, child));
@@ -97,6 +113,15 @@ function renderRun(word, run, paragraph) {
97
113
  else if (child instanceof Sym) {
98
114
  appendChild(span, renderSym(word, child));
99
115
  }
116
+ else if (child instanceof SoftHyphen) {
117
+ appendChild(span, renderSoftHyphen());
118
+ }
119
+ else if (child instanceof NoBreakHyphen) {
120
+ appendChild(span, renderNoBreakHyphen());
121
+ }
122
+ else if (child instanceof Separator) {
123
+ appendChild(span, renderSeparator());
124
+ }
100
125
  else {
101
126
  console.warn('unknown child', child);
102
127
  }
@@ -105,7 +130,7 @@ function renderRun(word, run, paragraph) {
105
130
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
106
131
  finally {
107
132
  try {
108
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
133
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
109
134
  }
110
135
  finally { if (e_1) throw e_1.error; }
111
136
  }
@@ -1,6 +1,7 @@
1
+ import { WDocument } from '../openxml/word/WDocument';
1
2
  import { Section } from '../openxml/word/Section';
2
- import Word from '../Word';
3
+ import Word, { WordRenderOptions } from '../Word';
3
4
  /**
4
5
  * 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
5
6
  */
6
- export declare function renderSection(word: Word, section: Section): HTMLElement;
7
+ export declare function renderSection(word: Word, wDocument: WDocument, section: Section, renderOptions: WordRenderOptions): HTMLElement;
@@ -1,25 +1,40 @@
1
1
  import { createElement } from '../util/dom.js';
2
+ import { renderHeader } from './renderHeader.js';
2
3
 
3
4
  /**
4
5
  * 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
5
6
  */
6
- function renderSection(word, section) {
7
+ function renderSection(word, wDocument, section, renderOptions) {
7
8
  var sectionEl = createElement('section');
8
9
  // 用于后续绝对定位
9
10
  sectionEl.style.position = 'relative';
11
+ if (wDocument.backgroundColor) {
12
+ sectionEl.style.background = wDocument.backgroundColor;
13
+ }
14
+ if (renderOptions.page) {
15
+ if (renderOptions.pageMarginBottom) {
16
+ sectionEl.style.marginBottom = renderOptions.pageMarginBottom + 'px';
17
+ }
18
+ if (renderOptions.pageShadow) {
19
+ sectionEl.style.boxShadow = '0 0 8px rgba(0, 0, 0, 0.5)';
20
+ }
21
+ if (renderOptions.pageBackground) {
22
+ sectionEl.style.background = renderOptions.pageBackground;
23
+ }
24
+ }
10
25
  var props = section.properties;
11
26
  var pageSize = props.pageSize;
12
27
  if (pageSize) {
13
- if (!word.renderOptions.ignoreWidth) {
28
+ if (!renderOptions.ignoreWidth) {
14
29
  sectionEl.style.width = pageSize.width;
15
30
  }
16
- if (!word.renderOptions.ignoreHeight) {
31
+ if (!renderOptions.ignoreHeight) {
17
32
  sectionEl.style.height = pageSize.height;
18
33
  }
19
34
  }
20
35
  // 强制控制 padding
21
- if (word.renderOptions.padding) {
22
- sectionEl.style.padding = word.renderOptions.padding;
36
+ if (renderOptions.padding) {
37
+ sectionEl.style.padding = renderOptions.padding;
23
38
  }
24
39
  else {
25
40
  var pageMargin = props.pageMargin;
@@ -30,6 +45,65 @@ function renderSection(word, section) {
30
45
  sectionEl.style.paddingBottom = pageMargin.bottom || '0';
31
46
  }
32
47
  }
48
+ if (props.cols) {
49
+ if (props.cols.num && props.cols.num > 1) {
50
+ sectionEl.style.columnCount = '' + props.cols.num;
51
+ if (props.cols.space) {
52
+ sectionEl.style.columnGap = props.cols.space;
53
+ }
54
+ }
55
+ }
56
+ word.currentPage++;
57
+ var width = 'auto';
58
+ if (props.pageSize && props.pageSize.width) {
59
+ width = props.pageSize.width;
60
+ }
61
+ // 只有在分页模式下才渲染页眉
62
+ if (props.headers && renderOptions.page && renderOptions.renderHeader) {
63
+ var headers = props.headers;
64
+ var headerEl = null;
65
+ if (headers.even && word.currentPage % 2 === 0) {
66
+ headerEl = renderHeader(word, headers.even);
67
+ }
68
+ else if (headers.default) {
69
+ headerEl = renderHeader(word, headers.default);
70
+ }
71
+ else {
72
+ console.warn('can not find header', word.currentPage, props.headers);
73
+ }
74
+ if (headerEl) {
75
+ headerEl.style.position = 'absolute';
76
+ var pageMargin = props.pageMargin;
77
+ // todo: 在 word 里如果 header 内容较多会将内容区也撑开,但目前实现不了
78
+ if (pageMargin && pageMargin.header) {
79
+ headerEl.style.top = pageMargin.header;
80
+ headerEl.style.width = width;
81
+ }
82
+ sectionEl.appendChild(headerEl);
83
+ }
84
+ }
85
+ if (props.footers && renderOptions.page && renderOptions.renderFooter) {
86
+ var footers = props.footers;
87
+ var footerEl = null;
88
+ if (footers.even && word.currentPage % 2 === 0) {
89
+ footerEl = renderHeader(word, footers.even);
90
+ }
91
+ else if (footers.default) {
92
+ footerEl = renderHeader(word, footers.default);
93
+ }
94
+ else {
95
+ console.warn('can not find footer', word.currentPage, props.footers);
96
+ }
97
+ if (footerEl) {
98
+ footerEl.style.position = 'absolute';
99
+ var pageMargin = props.pageMargin;
100
+ if (pageMargin && pageMargin.footer) {
101
+ footerEl.style.bottom = pageMargin.footer;
102
+ footerEl.style.width = width;
103
+ }
104
+ sectionEl.appendChild(footerEl);
105
+ }
106
+ }
33
107
  return sectionEl;
34
108
  }
35
109
 
@@ -0,0 +1 @@
1
+ export declare function renderSeparator(): HTMLElement;
@@ -0,0 +1,9 @@
1
+ import { createElement } from '../util/dom.js';
2
+
3
+ function renderSeparator() {
4
+ var sep = createElement('hr');
5
+ sep.style.borderTop = '1pt solid #bbb';
6
+ return sep;
7
+ }
8
+
9
+ export { renderSeparator };
@@ -0,0 +1 @@
1
+ export declare function renderSoftHyphen(): HTMLElement;
@@ -0,0 +1,9 @@
1
+ import { createElement } from '../util/dom.js';
2
+
3
+ function renderSoftHyphen() {
4
+ var softHyphen = createElement('span');
5
+ softHyphen.innerHTML = '­';
6
+ return softHyphen;
7
+ }
8
+
9
+ export { renderSoftHyphen };
@@ -1,5 +1,4 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
2
- import { ST_TblStyleOverrideType } from '../openxml/Types.js';
1
+ import { __values } from 'tslib';
3
2
  import { styleToText, createElement } from '../util/dom.js';
4
3
 
5
4
  /**
@@ -9,6 +8,7 @@ import { styleToText, createElement } from '../util/dom.js';
9
8
  * 文档基础默认样式
10
9
  */
11
10
  function generateDefaultStyle(word) {
11
+ var _a;
12
12
  var styles = word.styles;
13
13
  var defaultStyle = styles.defaultStyle;
14
14
  var defaultPStyle = '';
@@ -19,8 +19,9 @@ function generateDefaultStyle(word) {
19
19
  if (defaultStyle === null || defaultStyle === void 0 ? void 0 : defaultStyle.rPr) {
20
20
  defaultRStyle = styleToText(defaultStyle.rPr.cssStyle);
21
21
  }
22
+ var hyphens = ((_a = word.settings) === null || _a === void 0 ? void 0 : _a.autoHyphenation) ? 'hyphens: auto;' : '';
22
23
  var classPrefix = word.getClassPrefix();
23
- return "\n .".concat(word.wrapClassName, " {\n\n }\n\n .").concat(word.wrapClassName, " > article > section {\n background: white;\n }\n\n /** docDefaults **/\n\n .").concat(classPrefix, " p {\n margin: 0;\n padding: 0;\n }\n\n .").concat(classPrefix, " table {\n border-spacing: 0;\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-p {\n ").concat(defaultPStyle, "\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-r {\n white-space: pre-wrap;\n overflow-wrap: break-word;\n ").concat(defaultRStyle, "\n }\n ");
24
+ return "\n\n\n /** docDefaults **/\n .".concat(classPrefix, " {\n --docx-theme-font-minorHAnsi: Calibri, Helvetica, Arial, 'Helvetica Neue';\n --docx-theme-font-minorEastAsia: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'STHeiti',\n 'Microsoft YaHei';\n }\n\n .").concat(classPrefix, " p {\n margin: 0;\n padding: 0;\n line-height: 1.5;\n ").concat(hyphens, "\n }\n\n .").concat(classPrefix, " .justify:after {\n content: \"\";\n display: inline-block;\n width: 100%;\n }\n\n .").concat(classPrefix, " table {\n border-spacing: 0;\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-p {\n ").concat(defaultPStyle, "\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-r {\n white-space: pre-wrap;\n overflow-wrap: break-word;\n ").concat(defaultRStyle, "\n }\n ");
24
25
  }
25
26
  /**
26
27
  * 生成表格级别样式
@@ -50,81 +51,81 @@ function generateTableStyle(classPrefix, styleDisplayId, style) {
50
51
  return tblStyleText;
51
52
  }
52
53
  // 用于生成表格 override 相关的样式,用于行或列
53
- function genTblOverrideStyle(prefix, overrideType, tblStylePrStyle) {
54
+ function genTblOverrideStyle(tblPrefix, classPrefix, overrideType, tblStylePrStyle) {
54
55
  var _a, _b, _c, _d, _e, _f;
55
56
  var styleText = '';
56
57
  var trStyle = styleToText((_a = tblStylePrStyle.trPr) === null || _a === void 0 ? void 0 : _a.cssStyle);
57
58
  var enableType = '';
58
59
  // 在 tblLook 里可以通过这些属性来控制是否启用
59
60
  switch (overrideType) {
60
- case ST_TblStyleOverrideType.firstCol:
61
+ case 'firstCol':
61
62
  enableType = 'enable-firstColumn';
62
63
  break;
63
- case ST_TblStyleOverrideType.lastCol:
64
+ case 'lastCol':
64
65
  enableType = 'enable-lastColumn';
65
66
  break;
66
- case ST_TblStyleOverrideType.firstRow:
67
+ case 'firstRow':
67
68
  enableType = 'enable-firstRow';
68
69
  break;
69
- case ST_TblStyleOverrideType.lastRow:
70
+ case 'lastRow':
70
71
  enableType = 'enable-lastRow';
71
72
  break;
72
- case ST_TblStyleOverrideType.band1Horz:
73
- case ST_TblStyleOverrideType.band2Horz:
73
+ case 'band1Horz':
74
+ case 'band2Horz':
74
75
  enableType = 'enable-hBand';
75
76
  break;
76
- case ST_TblStyleOverrideType.band1Vert:
77
- case ST_TblStyleOverrideType.band2Vert:
77
+ case 'band1Vert':
78
+ case 'band2Vert':
78
79
  enableType = 'enable-vBand';
79
80
  break;
80
81
  }
81
82
  if (trStyle) {
82
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr.").concat(overrideType, "{\n ").concat(trStyle, "\n }\n ");
83
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr.").concat(overrideType, "{\n ").concat(trStyle, "\n }\n ");
83
84
  }
84
85
  var tcStyle = styleToText((_b = tblStylePrStyle.tcPr) === null || _b === void 0 ? void 0 : _b.cssStyle);
85
86
  if (tcStyle) {
86
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n ").concat(tcStyle, "\n }\n ");
87
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n ").concat(tcStyle, "\n }\n ");
87
88
  if ((_c = tblStylePrStyle.tcPr) === null || _c === void 0 ? void 0 : _c.insideBorder) {
88
89
  var insideBorder = (_d = tblStylePrStyle.tcPr) === null || _d === void 0 ? void 0 : _d.insideBorder;
89
90
  if (insideBorder.H) {
90
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-top: ").concat(insideBorder.H, ";\n }");
91
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-top: ").concat(insideBorder.H, ";\n }");
91
92
  }
92
93
  if (insideBorder.V) {
93
94
  // 这个主要是为了应对 GridTable5Dark-Accent5 里 firstRow 的情况,它其实有 right 设置,也得去掉
94
95
  if (insideBorder.V === 'none') {
95
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: none;\n border-right: none;\n }");
96
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: none;\n border-right: none;\n }");
96
97
  }
97
98
  else {
98
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: ").concat(insideBorder.V, ";\n }");
99
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: ").concat(insideBorder.V, ";\n }");
99
100
  }
100
101
  }
101
102
  }
102
103
  }
103
104
  var pStyle = styleToText((_e = tblStylePrStyle.pPr) === null || _e === void 0 ? void 0 : _e.cssStyle);
104
105
  if (pStyle) {
105
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .p {\n ").concat(pStyle, "\n }\n ");
106
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p {\n ").concat(pStyle, "\n }\n ");
106
107
  }
107
108
  var rStyle = styleToText((_f = tblStylePrStyle.rPr) === null || _f === void 0 ? void 0 : _f.cssStyle);
108
109
  if (rStyle) {
109
- styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .p > .r {\n ").concat(rStyle, "\n }\n ");
110
+ styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
110
111
  }
111
112
  return styleText;
112
113
  }
113
114
  // 表格覆盖样式的顺序,权重高的放后面
114
115
  var overrideTypeOrder = new Set([
115
- ST_TblStyleOverrideType.wholeTable,
116
- ST_TblStyleOverrideType.band1Horz,
117
- ST_TblStyleOverrideType.band2Horz,
118
- ST_TblStyleOverrideType.band1Vert,
119
- ST_TblStyleOverrideType.band2Vert,
120
- ST_TblStyleOverrideType.firstCol,
121
- ST_TblStyleOverrideType.firstRow,
122
- ST_TblStyleOverrideType.lastCol,
123
- ST_TblStyleOverrideType.lastRow,
124
- ST_TblStyleOverrideType.neCell,
125
- ST_TblStyleOverrideType.nwCell,
126
- ST_TblStyleOverrideType.seCell,
127
- ST_TblStyleOverrideType.swCell
116
+ 'wholeTable',
117
+ 'band1Horz',
118
+ 'band2Horz',
119
+ 'band1Vert',
120
+ 'band2Vert',
121
+ 'firstCol',
122
+ 'firstRow',
123
+ 'lastCol',
124
+ 'lastRow',
125
+ 'neCell',
126
+ 'nwCell',
127
+ 'seCell',
128
+ 'swCell'
128
129
  ]);
129
130
  // 生成表格覆盖样式
130
131
  function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
@@ -139,7 +140,7 @@ function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
139
140
  var overrideType = overrideTypeOrder_1_1.value;
140
141
  if (overrideType in tblStylePr) {
141
142
  var overrideStylePr = tblStylePr[overrideType];
142
- tblStylePrText += genTblOverrideStyle(stylePrefix, overrideType, overrideStylePr);
143
+ tblStylePrText += genTblOverrideStyle(stylePrefix, classPrefix, overrideType, overrideStylePr);
143
144
  }
144
145
  }
145
146
  }
@@ -172,7 +173,7 @@ function generateStyle(word) {
172
173
  var rStyleText = '';
173
174
  if (styleData.rPr) {
174
175
  var rStyle = styleToText(styleData.rPr.cssStyle);
175
- rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .r {\n ").concat(rStyle, "\n }\n ");
176
+ rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
176
177
  }
177
178
  var tblStyleText = generateTableStyle(classPrefix, styleDisplayId, styleData);
178
179
  var tblStylePr = genOverrideTblStylePr(classPrefix, styleDisplayId, styleData.tblStylePr);
@@ -187,7 +188,7 @@ function renderStyle(word) {
187
188
  var style = createElement('style');
188
189
  var docDefaults = generateDefaultStyle(word);
189
190
  var styleText = generateStyle(word);
190
- style.innerHTML = "\n ".concat(docDefaults, "\n\n ").concat(styleText, "\n ");
191
+ style.textContent = "\n ".concat(docDefaults, "\n\n ").concat(styleText, "\n ");
191
192
  return style;
192
193
  }
193
194
 
@@ -2,6 +2,7 @@ import { Tab } from '../openxml/word/Tab';
2
2
  import Word from '../Word';
3
3
  /**
4
4
  * 渲染 tab
5
+ * 不支持 tabs 里的自定义宽度,因为要算渲染后的宽度,比较麻烦
5
6
  * http://officeopenxml.com/WPtab.php
6
7
  */
7
8
  export declare function renderTab(word: Word, tab: Tab): HTMLElement;
@@ -1,17 +1,15 @@
1
- import { ST_TabTlc } from '../openxml/Types.js';
2
1
  import { createElement } from '../util/dom.js';
3
2
 
4
3
  /**
5
4
  * 渲染 tab
5
+ * 不支持 tabs 里的自定义宽度,因为要算渲染后的宽度,比较麻烦
6
6
  * http://officeopenxml.com/WPtab.php
7
7
  */
8
8
  function renderTab(word, tab) {
9
9
  var tabElement = createElement('span');
10
- tabElement.style.display = 'inline-block';
11
- tabElement.style.width = tab.pos;
12
- tabElement.innerHTML = ' ';
13
- if (tab.leader === ST_TabTlc.dot) {
14
- tabElement.style.borderBottom = '1px dotted';
10
+ tabElement.innerHTML = ' ';
11
+ if (tab.leader === 'dot') {
12
+ tabElement.style.borderBottom = '1pt dotted';
15
13
  }
16
14
  return tabElement;
17
15
  }
@@ -1,8 +1,7 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
2
- import { ST_TblStyleOverrideType } from '../openxml/Types.js';
1
+ import { __values } from 'tslib';
3
2
  import { Paragraph } from '../openxml/word/Paragraph.js';
4
3
  import { Table } from '../openxml/word/Table.js';
5
- import { addClassName, setStyle, appendChild } from '../util/dom.js';
4
+ import { addClassName, applyStyle, appendChild } from '../util/dom.js';
6
5
  import renderParagraph from './renderParagraph.js';
7
6
  import { generateTableStyle } from './renderStyle.js';
8
7
  import { setElementStyle } from './setElementStyle.js';
@@ -14,51 +13,51 @@ import { setElementStyle } from './setElementStyle.js';
14
13
  function setTdClassName(rowIndex, colIndex, rowLength, colLength, element, rowBandSize, colBandSize) {
15
14
  // 左上角
16
15
  if (rowIndex === 0 && colIndex === 0) {
17
- element.classList.add(ST_TblStyleOverrideType.nwCell);
16
+ element.classList.add('nwCell');
18
17
  }
19
18
  // 右上角
20
19
  if (rowIndex === 0 && colIndex === colLength - 1) {
21
- element.classList.add(ST_TblStyleOverrideType.neCell);
20
+ element.classList.add('neCell');
22
21
  }
23
22
  // 左下角
24
23
  if (rowIndex === rowLength - 1 && colIndex === 0) {
25
- element.classList.add(ST_TblStyleOverrideType.swCell);
24
+ element.classList.add('swCell');
26
25
  }
27
26
  // 右下角
28
27
  if (rowIndex === rowLength - 1 && colIndex === colLength - 1) {
29
- element.classList.add(ST_TblStyleOverrideType.seCell);
28
+ element.classList.add('seCell');
30
29
  }
31
30
  // 第一行
32
31
  if (rowIndex === 0) {
33
- element.classList.add(ST_TblStyleOverrideType.firstRow);
32
+ element.classList.add('firstRow');
34
33
  }
35
34
  // 最后一行
36
35
  if (rowIndex === rowLength - 1) {
37
- element.classList.add(ST_TblStyleOverrideType.lastRow);
36
+ element.classList.add('lastRow');
38
37
  }
39
38
  // 第一列
40
39
  if (colIndex === 0) {
41
- element.classList.add(ST_TblStyleOverrideType.firstCol);
40
+ element.classList.add('firstCol');
42
41
  }
43
42
  // 最后一列
44
43
  if (colIndex === colLength - 1) {
45
- element.classList.add(ST_TblStyleOverrideType.lastCol);
44
+ element.classList.add('lastCol');
46
45
  }
47
46
  // 奇数行
48
47
  if (isOdd(rowIndex + 1)) {
49
- element.classList.add(ST_TblStyleOverrideType.band1Horz);
48
+ element.classList.add('band1Horz');
50
49
  }
51
50
  // 偶数行
52
51
  if (!isOdd(rowIndex + 1)) {
53
- element.classList.add(ST_TblStyleOverrideType.band2Horz);
52
+ element.classList.add('band2Horz');
54
53
  }
55
54
  // 奇数列
56
55
  if (isOdd(colIndex + 1)) {
57
- element.classList.add(ST_TblStyleOverrideType.band1Vert);
56
+ element.classList.add('band1Vert');
58
57
  }
59
58
  // 偶数列
60
59
  if (!isOdd(colIndex + 1)) {
61
- element.classList.add(ST_TblStyleOverrideType.band2Vert);
60
+ element.classList.add('band2Vert');
62
61
  }
63
62
  }
64
63
  /**
@@ -120,7 +119,7 @@ function renderTable(word, table) {
120
119
  setTdClassName(rowIndex, colIndex, table.trs.length, tr.tcs.length, tdEl, properties.rowBandSize, properties.colBandSize);
121
120
  // tr 也能设置 tc style,所以先应用这个
122
121
  if (tr.properties.tcStyle) {
123
- setStyle(tdEl, tr.properties.tcStyle);
122
+ applyStyle(tdEl, tr.properties.tcStyle);
124
123
  }
125
124
  var tcPr = tc.properties;
126
125
  setElementStyle(word, tdEl, tcPr);
@@ -130,17 +129,21 @@ function renderTable(word, table) {
130
129
  if (tcPr.rowSpan) {
131
130
  tdEl.rowSpan = tcPr.rowSpan;
132
131
  }
133
- // 如果已经有表格的话,就不再渲染空段落了,避免底部多个空行
134
- var hasTable = false;
132
+ var renderSpace = true;
133
+ // 如果有 tcPr.hideMark 就不渲染空格
134
+ if (tcPr.hideMark) {
135
+ renderSpace = false;
136
+ }
135
137
  try {
136
138
  for (var _h = (e_3 = void 0, __values(tc.children)), _j = _h.next(); !_j.done; _j = _h.next()) {
137
139
  var tcChild = _j.value;
138
140
  if (tcChild instanceof Paragraph) {
139
- var p = renderParagraph(word, tcChild, !hasTable);
141
+ var p = renderParagraph(word, tcChild, renderSpace);
140
142
  appendChild(tdEl, p);
141
143
  }
142
144
  else if (tcChild instanceof Table) {
143
- hasTable = true;
145
+ // 如果已经有表格的话,就不再渲染空段落了,避免底部多个空行
146
+ renderSpace = false;
144
147
  appendChild(tdEl, renderTable(word, tcChild));
145
148
  }
146
149
  else {
@@ -1,4 +1,4 @@
1
- import { setStyle, addClassNames } from '../util/dom.js';
1
+ import { applyStyle, addClassName, addClassNames } from '../util/dom.js';
2
2
 
3
3
  /**
4
4
  * 设置元素样式,因为好几个地方用所以统一一下
@@ -8,7 +8,12 @@ function setElementStyle(word, element, properties) {
8
8
  return;
9
9
  }
10
10
  if (properties.cssStyle) {
11
- setStyle(element, properties.cssStyle);
11
+ applyStyle(element, properties.cssStyle);
12
+ // 需要依赖这个 class 才能实现水平分布
13
+ // https://stackoverflow.com/a/21199162
14
+ if (properties.cssStyle['text-align'] === 'justify') {
15
+ addClassName(element, 'justify');
16
+ }
12
17
  }
13
18
  if (properties.pStyle) {
14
19
  addClassNames(element, word.getStyleClassName(properties.pStyle));
@@ -0,0 +1 @@
1
+ export declare const behindIndex = "1";
package/esm/util/blob.js CHANGED
@@ -1,15 +1,6 @@
1
1
  /**
2
2
  * 将 blob 转成 data url
3
3
  */
4
- function blobToDataURL(blob) {
5
- return new Promise(function (resolve, reject) {
6
- var reader = new FileReader();
7
- reader.onload = function (_e) { return resolve(reader.result); };
8
- reader.onerror = function (_e) { return reject(reader.error); };
9
- reader.onabort = function (_e) { return reject(new Error('Read aborted')); };
10
- reader.readAsDataURL(blob);
11
- });
12
- }
13
4
  /**
14
5
  * 下载 blob
15
6
  * https://dev.to/nombrekeff/download-file-from-blob-21ho
@@ -36,4 +27,4 @@ function downloadBlob(blob, name) {
36
27
  document.body.removeChild(link);
37
28
  }
38
29
 
39
- export { blobToDataURL, downloadBlob };
30
+ export { downloadBlob };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 处理颜色相关的函数,目前只支持 rgb
3
+ */
4
+ export declare class Color {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ isValid: boolean;
9
+ constructor(input: string);
10
+ static fromHSL(h: number, s: number, l: number): Color;
11
+ static fromRGB(r: number, g: number, b: number): Color;
12
+ /**
13
+ * 设置 lum
14
+ */
15
+ lum(l: number): this;
16
+ /**
17
+ * 改变 lum 百分比,其实不太对,但差不太多
18
+ * @param l 百分比,比如 2 相当于 200 %
19
+ */
20
+ lumMod(l: number): this;
21
+ /**
22
+ * 改变百分比
23
+ * @param l 百分比,比如 -0.2 相当于减少 20 %
24
+ */
25
+ lumOff(l: number): this;
26
+ /**
27
+ * h 取值范围是 0-1
28
+ */
29
+ hue(h: number): this;
30
+ hueMod(h: number): this;
31
+ hueOff(h: number): this;
32
+ sat(s: number): this;
33
+ satMod(s: number): this;
34
+ satOff(s: number): this;
35
+ /**
36
+ * 修改 hsl 中某个部分的值
37
+ */
38
+ changeHsl(num: number, com: 'h' | 's' | 'l', changeType: 'set' | 'mod' | 'off'): this;
39
+ /**
40
+ * 互补色
41
+ */
42
+ comp(): this;
43
+ shade(s: number): void;
44
+ tint(t: number): void;
45
+ inv(): this;
46
+ toHex(): string;
47
+ toRgba(alpha: number): string;
48
+ }