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
@@ -1,4 +1,4 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __values } from 'tslib';
2
2
  import { createElement, appendChild } from '../util/dom.js';
3
3
  import { Run } from '../openxml/word/Run.js';
4
4
  import { BookmarkStart } from '../openxml/word/Bookmark.js';
@@ -9,45 +9,82 @@ import { renderBookmarkStart } from './renderBookmark.js';
9
9
  import { renderNumbering } from './renderNumbering.js';
10
10
  import { setElementStyle } from './setElementStyle.js';
11
11
  import { renderTab } from './renderTab.js';
12
- import { SmartTag } from '../openxml/word/SmartTag.js';
13
- import renderInlineText from './renderInlineText.js';
12
+ import { OMath } from '../openxml/math/OMath.js';
13
+ import { renderOMath } from './renderMath.js';
14
+ import { Tab } from '../openxml/word/Tab.js';
14
15
 
15
16
  /**
16
17
  * 渲染段落
17
18
  * @param renderEmptySpace 如果是 true 的话,当内容为空时会自动加上  
18
19
  */
19
- function renderParagraph(word, paragraph, renderEmptySpace) {
20
- var e_1, _a, e_2, _b;
20
+ function renderParagraph(word, paragraph, renderEmptySpace, inHeader) {
21
+ var e_1, _a, e_2, _b, e_3, _c;
21
22
  if (renderEmptySpace === void 0) { renderEmptySpace = true; }
23
+ if (inHeader === void 0) { inHeader = false; }
22
24
  word.currentParagraph = paragraph;
23
25
  var p = createElement('p');
24
26
  word.addClass(p, 'p');
25
27
  var properties = paragraph.properties;
26
28
  setElementStyle(word, p, properties);
29
+ // 默认情况下 drawing 是相对段落的
30
+ p.style.position = 'relative';
27
31
  // 渲染列表前缀
28
32
  if (properties.numPr) {
29
33
  appendChild(p, renderNumbering(p, word, properties.numPr));
30
34
  }
31
- if (properties.tabs) {
35
+ var inFldChar = false;
36
+ if (properties.tabs && properties.tabs.length) {
37
+ // 目前只支持渲染第一个,因为第二个位置取决于前面内容位置,挺麻烦
38
+ // 虽然目前这个实现很 hack,但可以支持常见情况
39
+ appendChild(p, renderTab(word, properties.tabs[0], true));
40
+ // 同时删掉第一个 run 中的 tab
41
+ var done = false;
32
42
  try {
33
- for (var _c = __values(properties.tabs), _d = _c.next(); !_d.done; _d = _c.next()) {
34
- var tab = _d.value;
35
- appendChild(p, renderTab(word, tab));
43
+ for (var _d = __values(paragraph.children), _e = _d.next(); !_e.done; _e = _d.next()) {
44
+ var child = _e.value;
45
+ if (done) {
46
+ break;
47
+ }
48
+ if (child instanceof Run) {
49
+ try {
50
+ for (var _f = (e_2 = void 0, __values(child.children)), _g = _f.next(); !_g.done; _g = _f.next()) {
51
+ var runChild = _g.value;
52
+ if (runChild instanceof Tab) {
53
+ child.children.splice(child.children.indexOf(runChild), 1);
54
+ done = true;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
60
+ finally {
61
+ try {
62
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
63
+ }
64
+ finally { if (e_2) throw e_2.error; }
65
+ }
66
+ }
36
67
  }
37
68
  }
38
69
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
39
70
  finally {
40
71
  try {
41
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
72
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
42
73
  }
43
74
  finally { if (e_1) throw e_1.error; }
44
75
  }
45
76
  }
46
77
  try {
47
- for (var _e = __values(paragraph.children), _f = _e.next(); !_f.done; _f = _e.next()) {
48
- var child = _f.value;
78
+ for (var _h = __values(paragraph.children), _j = _h.next(); !_j.done; _j = _h.next()) {
79
+ var child = _j.value;
49
80
  if (child instanceof Run) {
50
- appendChild(p, renderRun(word, child, paragraph));
81
+ if (child.fldChar === 'begin') {
82
+ inFldChar = true;
83
+ }
84
+ else if (child) {
85
+ inFldChar = false;
86
+ }
87
+ appendChild(p, renderRun(word, child, paragraph, inFldChar, inHeader));
51
88
  }
52
89
  else if (child instanceof BookmarkStart) {
53
90
  appendChild(p, renderBookmarkStart(word, child));
@@ -56,17 +93,20 @@ function renderParagraph(word, paragraph, renderEmptySpace) {
56
93
  var hyperlink = renderHyperLink(word, child, paragraph);
57
94
  appendChild(p, hyperlink);
58
95
  }
59
- else if (child instanceof SmartTag) {
60
- renderInlineText(word, child, p);
96
+ else if (child instanceof OMath) {
97
+ appendChild(p, renderOMath(word, child));
98
+ }
99
+ else {
100
+ console.warn('unknow pargraph type', child);
61
101
  }
62
102
  }
63
103
  }
64
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
104
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
65
105
  finally {
66
106
  try {
67
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
107
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
68
108
  }
69
- finally { if (e_2) throw e_2.error; }
109
+ finally { if (e_3) throw e_3.error; }
70
110
  }
71
111
  // 空行自动加个空格,不然会没高度
72
112
  if (p.innerHTML === '' && renderEmptySpace) {
@@ -2,16 +2,11 @@
2
2
  * 老的 vml 格式,目前只支持图片
3
3
  */
4
4
  function renderPict(word, pict) {
5
- var _a;
6
- if (pict.imagedata) {
7
- var img_1 = document.createElement('img');
8
- img_1.style.position = 'relative';
9
- (_a = word.loadImage(pict.imagedata)) === null || _a === void 0 ? void 0 : _a.then(function (url) {
10
- if (url) {
11
- img_1.src = url;
12
- }
13
- });
14
- return img_1;
5
+ if (pict.src) {
6
+ var img = document.createElement('img');
7
+ img.style.position = 'relative';
8
+ img.src = pict.src;
9
+ return img;
15
10
  }
16
11
  return null;
17
12
  }
@@ -1,4 +1,4 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __values } from 'tslib';
2
2
  import { createElement } from '../util/dom.js';
3
3
  import renderRun from './renderRun.js';
4
4
 
@@ -3,12 +3,14 @@
3
3
  */
4
4
  import Word from '../Word';
5
5
  import { Run } from '../openxml/word/Run';
6
- import type { Paragraph } from './../openxml/word/Paragraph';
6
+ import type { Paragraph } from '../openxml/word/Paragraph';
7
7
  /**
8
8
  * 更新文档里的所有变量
9
9
  */
10
10
  export declare function updateVariableText(word: Word): void;
11
11
  /**
12
12
  * 渲染 run 节点
13
+ *
14
+ * @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
13
15
  */
14
- export default function renderRun(word: Word, run: Run, paragraph?: Paragraph): HTMLElement;
16
+ export default function renderRun(word: Word, run: Run, paragraph?: Paragraph, inFldChar?: boolean, inHeader?: boolean): HTMLElement;
@@ -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
@@ -29,12 +35,14 @@ function renderText(span, word, text, paragraph) {
29
35
  var _a;
30
36
  // 简单过滤一下提升性能
31
37
  if (text.indexOf('{{') === -1) {
38
+ var finalText = void 0;
32
39
  if ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.properties) === null || _a === void 0 ? void 0 : _a.autoSpace) {
33
- span.textContent = cjkspace(text.split(''));
40
+ finalText = cjkspace(text.split(''));
34
41
  }
35
42
  else {
36
- span.textContent = text;
43
+ finalText = text;
37
44
  }
45
+ span.textContent = finalText;
38
46
  }
39
47
  else {
40
48
  span.dataset.originText = text;
@@ -42,6 +50,9 @@ function renderText(span, word, text, paragraph) {
42
50
  span.classList.add(VARIABLE_CLASS_NAME);
43
51
  span.textContent = word.replaceText(text);
44
52
  }
53
+ // 大于两个空格才转成 nbsp
54
+ var html = span.innerHTML.split(' ').join('  ');
55
+ span.innerHTML = html;
45
56
  }
46
57
  /**
47
58
  * 更新文档里的所有变量
@@ -56,31 +67,41 @@ function updateVariableText(word) {
56
67
  }
57
68
  /**
58
69
  * 渲染 run 节点
70
+ *
71
+ * @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
59
72
  */
60
- function renderRun(word, run, paragraph) {
73
+ function renderRun(word, run, paragraph, inFldChar, inHeader) {
61
74
  var e_1, _a;
75
+ var _b, _c;
62
76
  var span = createElement('span');
63
77
  word.addClass(span, 'r');
64
78
  setElementStyle(word, span, run.properties);
79
+ // run 不好通过 class 来设置 rStyle,所以单独支持一下
80
+ if ((_b = run.properties) === null || _b === void 0 ? void 0 : _b.rStyle) {
81
+ var style = word.getStyle(run.properties.rStyle);
82
+ if ((_c = style === null || style === void 0 ? void 0 : style.rPr) === null || _c === void 0 ? void 0 : _c.cssStyle) {
83
+ applyStyle(span, style.rPr.cssStyle);
84
+ }
85
+ }
65
86
  if (run.children.length === 1 && run.children[0] instanceof Text) {
66
87
  var text = run.children[0];
67
88
  renderText(span, word, text.text, paragraph);
68
89
  }
69
90
  else {
70
91
  try {
71
- for (var _b = __values(run.children), _c = _b.next(); !_c.done; _c = _b.next()) {
72
- var child = _c.value;
92
+ for (var _d = __values(run.children), _e = _d.next(); !_e.done; _e = _d.next()) {
93
+ var child = _e.value;
73
94
  if (child instanceof Text) {
74
95
  var newSpan = createElement('span');
75
- renderText(span, word, child.text, paragraph);
96
+ renderText(newSpan, word, child.text, paragraph);
76
97
  appendChild(span, newSpan);
77
98
  }
78
99
  else if (child instanceof Break) {
79
- var br = renderBr(child);
100
+ var br = renderBr(word, child);
80
101
  appendChild(span, br);
81
102
  }
82
103
  else if (child instanceof Drawing) {
83
- appendChild(span, renderDrawing(word, child));
104
+ appendChild(span, renderDrawing(word, child, inHeader));
84
105
  }
85
106
  else if (child instanceof Tab) {
86
107
  appendChild(span, renderTab(word, child));
@@ -97,6 +118,15 @@ function renderRun(word, run, paragraph) {
97
118
  else if (child instanceof Sym) {
98
119
  appendChild(span, renderSym(word, child));
99
120
  }
121
+ else if (child instanceof SoftHyphen) {
122
+ appendChild(span, renderSoftHyphen());
123
+ }
124
+ else if (child instanceof NoBreakHyphen) {
125
+ appendChild(span, renderNoBreakHyphen());
126
+ }
127
+ else if (child instanceof Separator) {
128
+ appendChild(span, renderSeparator());
129
+ }
100
130
  else {
101
131
  console.warn('unknown child', child);
102
132
  }
@@ -105,7 +135,7 @@ function renderRun(word, run, paragraph) {
105
135
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
106
136
  finally {
107
137
  try {
108
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
138
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
109
139
  }
110
140
  finally { if (e_1) throw e_1.error; }
111
141
  }
@@ -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 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
- export declare function renderTab(word: Word, tab: Tab): HTMLElement;
8
+ export declare function renderTab(word: Word, tab: Tab, renderWidth?: boolean): HTMLElement;
@@ -1,17 +1,21 @@
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
- function renderTab(word, tab) {
8
+ function renderTab(word, tab, renderWidth) {
9
+ if (renderWidth === void 0) { renderWidth = false; }
9
10
  var tabElement = createElement('span');
10
11
  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';
12
+ tabElement.style.width = '2em';
13
+ tabElement.innerHTML = ' ';
14
+ if (tab.leader === 'dot') {
15
+ tabElement.style.borderBottom = '1pt dotted';
16
+ }
17
+ if (renderWidth && tab.pos && (tab.type === 'start' || tab.type == 'left')) {
18
+ tabElement.style.width = tab.pos;
15
19
  }
16
20
  return tabElement;
17
21
  }