office-viewer 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/README.md +7 -2
  2. package/esm/OpenXML.d.ts +19 -0
  3. package/esm/OpenXML.js +43 -2
  4. package/esm/Word.d.ts +132 -15
  5. package/esm/Word.js +233 -54
  6. package/esm/openxml/ContentType.js +20 -6
  7. package/esm/openxml/Settings.d.ts +10 -0
  8. package/esm/openxml/Settings.js +93 -0
  9. package/esm/openxml/Style.d.ts +1 -1
  10. package/esm/openxml/Style.js +12 -12
  11. package/esm/openxml/Theme.js +30 -6
  12. package/esm/openxml/Types.d.ts +179 -2472
  13. package/esm/openxml/drawing/Blip.d.ts +7 -0
  14. package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
  15. package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
  16. package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  17. package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
  18. package/esm/openxml/drawing/CustomGeom.js +17 -0
  19. package/esm/openxml/drawing/Drawing.d.ts +35 -0
  20. package/esm/openxml/drawing/Drawing.js +169 -0
  21. package/esm/openxml/drawing/Geom.d.ts +11 -0
  22. package/esm/openxml/drawing/Geom.js +34 -0
  23. package/esm/openxml/drawing/Path.d.ts +37 -0
  24. package/esm/openxml/drawing/Pic.d.ts +16 -0
  25. package/esm/openxml/drawing/Pic.js +26 -0
  26. package/esm/openxml/drawing/Shape.d.ts +20 -0
  27. package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
  28. package/esm/openxml/drawing/ShapeProperties.js +119 -0
  29. package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +2 -1
  30. package/esm/openxml/{word/drawing → drawing}/Transform.js +7 -3
  31. package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
  32. package/esm/openxml/drawing/diagram/Diagram.js +24 -0
  33. package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
  34. package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
  35. package/esm/openxml/drawing/presetShape.d.ts +3 -0
  36. package/esm/openxml/drawing/presetShape.js +38785 -0
  37. package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
  38. package/esm/openxml/drawing/svg/arcToA.js +88 -0
  39. package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
  40. package/esm/openxml/drawing/svg/formulas.js +103 -0
  41. package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
  42. package/esm/openxml/drawing/svg/generateDefines.js +144 -0
  43. package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
  44. package/esm/openxml/drawing/svg/presetVal.js +53 -0
  45. package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  46. package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
  47. package/esm/openxml/math/OMath.d.ts +5 -0
  48. package/esm/openxml/math/OMath.js +12 -0
  49. package/esm/openxml/math/convertOOML.d.ts +4 -0
  50. package/esm/openxml/math/convertOOML.js +13 -0
  51. package/esm/openxml/math/xsl.d.ts +4 -0
  52. package/esm/openxml/math/xsl.js +8 -0
  53. package/esm/openxml/word/Body.js +11 -7
  54. package/esm/openxml/word/Break.js +1 -3
  55. package/esm/openxml/word/Font.d.ts +16 -0
  56. package/esm/openxml/word/Font.js +78 -0
  57. package/esm/openxml/word/FontTable.d.ts +9 -0
  58. package/esm/openxml/word/FontTable.js +34 -0
  59. package/esm/openxml/word/Header.d.ts +11 -0
  60. package/esm/openxml/word/Header.js +54 -0
  61. package/esm/openxml/word/Hyperlink.d.ts +1 -0
  62. package/esm/openxml/word/Hyperlink.js +7 -3
  63. package/esm/openxml/word/InlineText.js +1 -1
  64. package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
  65. package/esm/openxml/word/NoBreakHyphen.js +7 -0
  66. package/esm/openxml/word/Note.d.ts +12 -0
  67. package/esm/openxml/word/Note.js +48 -0
  68. package/esm/openxml/word/Paragraph.d.ts +2 -2
  69. package/esm/openxml/word/Paragraph.js +10 -9
  70. package/esm/openxml/word/Pict.d.ts +1 -2
  71. package/esm/openxml/word/Pict.js +5 -3
  72. package/esm/openxml/word/Ruby.js +1 -1
  73. package/esm/openxml/word/Run.d.ts +7 -3
  74. package/esm/openxml/word/Run.js +28 -4
  75. package/esm/openxml/word/Section.d.ts +18 -5
  76. package/esm/openxml/word/Section.js +46 -2
  77. package/esm/openxml/word/Separator.d.ts +5 -0
  78. package/esm/openxml/word/Separator.js +10 -0
  79. package/esm/openxml/word/SoftHyphen.d.ts +5 -0
  80. package/esm/openxml/word/SoftHyphen.js +10 -0
  81. package/esm/openxml/word/Table.d.ts +4 -9
  82. package/esm/openxml/word/Table.js +0 -235
  83. package/esm/openxml/word/WDocument.d.ts +1 -2
  84. package/esm/openxml/word/WDocument.js +53 -7
  85. package/esm/openxml/word/numbering/AbstractNum.js +4 -2
  86. package/esm/openxml/word/numbering/Lvl.js +10 -4
  87. package/esm/openxml/word/numbering/Num.js +12 -4
  88. package/esm/openxml/word/numbering/NumberProperties.js +2 -2
  89. package/esm/openxml/word/numbering/Numbering.js +1 -1
  90. package/esm/openxml/word/table/Tc.d.ts +1 -22
  91. package/esm/openxml/word/table/Tc.js +1 -221
  92. package/esm/openxml/word/table/Tr.d.ts +0 -5
  93. package/esm/openxml/word/table/Tr.js +0 -97
  94. package/esm/openxml/word/wps/WPG.d.ts +5 -0
  95. package/esm/openxml/word/wps/WPS.d.ts +18 -0
  96. package/esm/openxml/word/wps/WPS.js +147 -0
  97. package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
  98. package/esm/openxml/word/wps/WPSStyle.js +42 -0
  99. package/esm/package/PackageParser.d.ts +1 -1
  100. package/esm/package/XMLPackageParser.d.ts +3 -3
  101. package/esm/package/ZipPackageParser.d.ts +1 -1
  102. package/esm/package/ZipPackageParser.js +7 -8
  103. package/esm/parse/Footnotes.d.ts +3 -0
  104. package/esm/parse/Footnotes.js +25 -0
  105. package/esm/parse/colorNameMap.d.ts +6 -0
  106. package/esm/parse/colorNameMap.js +201 -0
  107. package/esm/parse/jcToTextAlign.js +1 -0
  108. package/esm/parse/mergeSdt.d.ts +4 -0
  109. package/esm/parse/mergeSdt.js +57 -0
  110. package/esm/parse/modifyColor.d.ts +1 -0
  111. package/esm/parse/modifyColor.js +106 -0
  112. package/esm/parse/parseBorder.js +2 -21
  113. package/esm/parse/parseCellMargin.d.ts +2 -0
  114. package/esm/parse/parseCellMargin.js +38 -0
  115. package/esm/parse/parseChildColor.d.ts +5 -0
  116. package/esm/parse/parseChildColor.js +66 -0
  117. package/esm/parse/parseColor.d.ts +4 -0
  118. package/esm/parse/parseColor.js +41 -46
  119. package/esm/parse/parseEndnotes.d.ts +3 -0
  120. package/esm/parse/parseEndnotes.js +25 -0
  121. package/esm/parse/parseFont.js +1 -1
  122. package/esm/parse/parseInsideBorders.d.ts +9 -0
  123. package/esm/parse/parseInsideBorders.js +24 -0
  124. package/esm/parse/parsePr.d.ts +3 -0
  125. package/esm/parse/parsePr.js +108 -11
  126. package/esm/parse/parseRelationship.js +1 -1
  127. package/esm/parse/parseSdt.d.ts +5 -0
  128. package/esm/parse/parseShape.d.ts +10 -0
  129. package/esm/parse/parseShape.js +239 -0
  130. package/esm/parse/parseSize.d.ts +2 -1
  131. package/esm/parse/parseSize.js +7 -1
  132. package/esm/parse/parseSpacing.js +1 -1
  133. package/esm/parse/parseTable.d.ts +3 -0
  134. package/esm/parse/parseTable.js +62 -0
  135. package/esm/parse/parseTablePr.d.ts +3 -0
  136. package/esm/parse/parseTablePr.js +185 -0
  137. package/esm/parse/parseTblWidth.d.ts +4 -0
  138. package/esm/parse/parseTblWidth.js +23 -0
  139. package/esm/parse/parseTc.d.ts +10 -0
  140. package/esm/parse/parseTc.js +64 -0
  141. package/esm/parse/parseTcPr.d.ts +5 -0
  142. package/esm/parse/parseTcPr.js +99 -0
  143. package/esm/parse/parseTextDirection.js +4 -6
  144. package/esm/parse/parseTr.d.ts +6 -0
  145. package/esm/parse/parseTr.js +49 -0
  146. package/esm/parse/parseTrPr.d.ts +3 -0
  147. package/esm/parse/parseTrPr.js +59 -0
  148. package/esm/render/fixAbsolutePosition.d.ts +8 -0
  149. package/esm/render/renderBody.d.ts +6 -2
  150. package/esm/render/renderBody.js +184 -30
  151. package/esm/render/renderBr.d.ts +2 -1
  152. package/esm/render/renderBr.js +4 -1
  153. package/esm/render/renderCustGeom.d.ts +4 -0
  154. package/esm/render/renderCustGeom.js +10 -0
  155. package/esm/render/renderDocument.d.ts +2 -2
  156. package/esm/render/renderDocument.js +2 -2
  157. package/esm/render/renderDrawing.d.ts +3 -2
  158. package/esm/render/renderDrawing.js +129 -24
  159. package/esm/render/renderFont.d.ts +5 -0
  160. package/esm/render/renderFont.js +39 -0
  161. package/esm/render/renderGeom.d.ts +4 -0
  162. package/esm/render/renderGeom.js +14 -0
  163. package/esm/render/renderHeader.d.ts +6 -0
  164. package/esm/render/renderHeader.js +40 -0
  165. package/esm/render/renderHyperLink.js +4 -1
  166. package/esm/render/renderInlineText.js +1 -1
  167. package/esm/render/renderInstrText.js +1 -1
  168. package/esm/render/renderMath.d.ts +3 -0
  169. package/esm/render/renderMath.js +7 -0
  170. package/esm/render/renderNoBreakHyphen.d.ts +1 -0
  171. package/esm/render/renderNoBreakHyphen.js +9 -0
  172. package/esm/render/renderNotes.d.ts +5 -0
  173. package/esm/render/renderNotes.js +77 -0
  174. package/esm/render/renderNumbering.js +8 -10
  175. package/esm/render/renderParagraph.d.ts +1 -1
  176. package/esm/render/renderParagraph.js +26 -29
  177. package/esm/render/renderPict.js +5 -10
  178. package/esm/render/renderRuby.js +1 -1
  179. package/esm/render/renderRun.d.ts +4 -2
  180. package/esm/render/renderRun.js +35 -10
  181. package/esm/render/renderSection.d.ts +3 -2
  182. package/esm/render/renderSection.js +79 -5
  183. package/esm/render/renderSeparator.d.ts +1 -0
  184. package/esm/render/renderSeparator.js +9 -0
  185. package/esm/render/renderSoftHyphen.d.ts +1 -0
  186. package/esm/render/renderSoftHyphen.js +9 -0
  187. package/esm/render/renderStyle.js +36 -35
  188. package/esm/render/renderTab.d.ts +1 -0
  189. package/esm/render/renderTab.js +4 -6
  190. package/esm/render/renderTable.js +23 -20
  191. package/esm/render/setElementStyle.js +7 -2
  192. package/esm/render/zindex.d.ts +1 -0
  193. package/esm/util/blob.js +1 -10
  194. package/esm/util/color.d.ts +48 -0
  195. package/esm/util/color.js +211 -0
  196. package/esm/util/createObject.d.ts +10 -0
  197. package/esm/util/createObject.js +48 -0
  198. package/esm/util/dom.d.ts +8 -4
  199. package/esm/util/dom.js +21 -4
  200. package/esm/util/mergeRun.js +1 -1
  201. package/esm/util/parseSides.d.ts +11 -0
  202. package/esm/util/print.d.ts +5 -0
  203. package/esm/util/print.js +54 -0
  204. package/esm/util/replaceVar.d.ts +10 -0
  205. package/esm/util/replaceVar.js +214 -0
  206. package/esm/util/xml.js +4 -1
  207. package/lib/OpenXML.d.ts +19 -0
  208. package/lib/OpenXML.js +44 -1
  209. package/lib/Word.d.ts +132 -15
  210. package/lib/Word.js +238 -59
  211. package/lib/openxml/ContentType.js +20 -6
  212. package/lib/openxml/Settings.d.ts +10 -0
  213. package/lib/openxml/Settings.js +97 -0
  214. package/lib/openxml/Style.d.ts +1 -1
  215. package/lib/openxml/Style.js +15 -15
  216. package/lib/openxml/Theme.js +31 -7
  217. package/lib/openxml/Types.d.ts +179 -2472
  218. package/lib/openxml/drawing/Blip.d.ts +7 -0
  219. package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
  220. package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
  221. package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
  222. package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
  223. package/lib/openxml/drawing/CustomGeom.js +21 -0
  224. package/lib/openxml/drawing/Drawing.d.ts +35 -0
  225. package/lib/openxml/drawing/Drawing.js +173 -0
  226. package/lib/openxml/drawing/Geom.d.ts +11 -0
  227. package/lib/openxml/drawing/Geom.js +38 -0
  228. package/lib/openxml/drawing/Path.d.ts +37 -0
  229. package/lib/openxml/drawing/Pic.d.ts +16 -0
  230. package/lib/openxml/drawing/Pic.js +30 -0
  231. package/lib/openxml/drawing/Shape.d.ts +20 -0
  232. package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
  233. package/lib/openxml/drawing/ShapeProperties.js +123 -0
  234. package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +2 -1
  235. package/lib/openxml/{word/drawing → drawing}/Transform.js +7 -3
  236. package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
  237. package/lib/openxml/drawing/diagram/Diagram.js +28 -0
  238. package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
  239. package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
  240. package/lib/openxml/drawing/presetShape.d.ts +3 -0
  241. package/lib/openxml/drawing/presetShape.js +38789 -0
  242. package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
  243. package/lib/openxml/drawing/svg/arcToA.js +92 -0
  244. package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
  245. package/lib/openxml/drawing/svg/formulas.js +108 -0
  246. package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
  247. package/lib/openxml/drawing/svg/generateDefines.js +148 -0
  248. package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
  249. package/lib/openxml/drawing/svg/presetVal.js +57 -0
  250. package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
  251. package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
  252. package/lib/openxml/math/OMath.d.ts +5 -0
  253. package/lib/openxml/math/OMath.js +16 -0
  254. package/lib/openxml/math/convertOOML.d.ts +4 -0
  255. package/lib/openxml/math/convertOOML.js +17 -0
  256. package/lib/openxml/math/xsl.d.ts +4 -0
  257. package/lib/openxml/math/xsl.js +12 -0
  258. package/lib/openxml/word/Body.js +11 -7
  259. package/lib/openxml/word/Break.js +1 -3
  260. package/lib/openxml/word/Font.d.ts +16 -0
  261. package/lib/openxml/word/Font.js +83 -0
  262. package/lib/openxml/word/FontTable.d.ts +9 -0
  263. package/lib/openxml/word/FontTable.js +38 -0
  264. package/lib/openxml/word/Header.d.ts +11 -0
  265. package/lib/openxml/word/Header.js +58 -0
  266. package/lib/openxml/word/Hyperlink.d.ts +1 -0
  267. package/lib/openxml/word/Hyperlink.js +8 -4
  268. package/lib/openxml/word/InlineText.js +2 -2
  269. package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
  270. package/lib/openxml/word/NoBreakHyphen.js +11 -0
  271. package/lib/openxml/word/Note.d.ts +12 -0
  272. package/lib/openxml/word/Note.js +52 -0
  273. package/lib/openxml/word/Paragraph.d.ts +2 -2
  274. package/lib/openxml/word/Paragraph.js +11 -10
  275. package/lib/openxml/word/Pict.d.ts +1 -2
  276. package/lib/openxml/word/Pict.js +5 -3
  277. package/lib/openxml/word/Ruby.js +4 -4
  278. package/lib/openxml/word/Run.d.ts +7 -3
  279. package/lib/openxml/word/Run.js +29 -5
  280. package/lib/openxml/word/Section.d.ts +18 -5
  281. package/lib/openxml/word/Section.js +47 -3
  282. package/lib/openxml/word/Separator.d.ts +5 -0
  283. package/lib/openxml/word/Separator.js +14 -0
  284. package/lib/openxml/word/SoftHyphen.d.ts +5 -0
  285. package/lib/openxml/word/SoftHyphen.js +14 -0
  286. package/lib/openxml/word/Table.d.ts +4 -9
  287. package/lib/openxml/word/Table.js +0 -235
  288. package/lib/openxml/word/WDocument.d.ts +1 -2
  289. package/lib/openxml/word/WDocument.js +53 -7
  290. package/lib/openxml/word/numbering/AbstractNum.js +5 -3
  291. package/lib/openxml/word/numbering/Lvl.js +11 -5
  292. package/lib/openxml/word/numbering/Num.js +12 -4
  293. package/lib/openxml/word/numbering/NumberProperties.js +2 -2
  294. package/lib/openxml/word/numbering/Numbering.js +3 -3
  295. package/lib/openxml/word/table/Tc.d.ts +1 -22
  296. package/lib/openxml/word/table/Tc.js +0 -224
  297. package/lib/openxml/word/table/Tr.d.ts +0 -5
  298. package/lib/openxml/word/table/Tr.js +0 -97
  299. package/lib/openxml/word/wps/WPG.d.ts +5 -0
  300. package/lib/openxml/word/wps/WPS.d.ts +18 -0
  301. package/lib/openxml/word/wps/WPS.js +151 -0
  302. package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
  303. package/lib/openxml/word/wps/WPSStyle.js +46 -0
  304. package/lib/package/PackageParser.d.ts +1 -1
  305. package/lib/package/XMLPackageParser.d.ts +3 -3
  306. package/lib/package/ZipPackageParser.d.ts +1 -1
  307. package/lib/package/ZipPackageParser.js +7 -8
  308. package/lib/parse/Footnotes.d.ts +3 -0
  309. package/lib/parse/Footnotes.js +29 -0
  310. package/lib/parse/colorNameMap.d.ts +6 -0
  311. package/lib/parse/colorNameMap.js +205 -0
  312. package/lib/parse/jcToTextAlign.js +1 -0
  313. package/lib/parse/mergeSdt.d.ts +4 -0
  314. package/lib/parse/mergeSdt.js +61 -0
  315. package/lib/parse/modifyColor.d.ts +1 -0
  316. package/lib/parse/modifyColor.js +110 -0
  317. package/lib/parse/parseBorder.js +3 -22
  318. package/lib/parse/parseCellMargin.d.ts +2 -0
  319. package/lib/parse/parseCellMargin.js +42 -0
  320. package/lib/parse/parseChildColor.d.ts +5 -0
  321. package/lib/parse/parseChildColor.js +70 -0
  322. package/lib/parse/parseColor.d.ts +4 -0
  323. package/lib/parse/parseColor.js +41 -45
  324. package/lib/parse/parseEndnotes.d.ts +3 -0
  325. package/lib/parse/parseEndnotes.js +29 -0
  326. package/lib/parse/parseFont.js +2 -2
  327. package/lib/parse/parseInsideBorders.d.ts +9 -0
  328. package/lib/parse/parseInsideBorders.js +28 -0
  329. package/lib/parse/parsePr.d.ts +3 -0
  330. package/lib/parse/parsePr.js +109 -12
  331. package/lib/parse/parseRelationship.js +2 -2
  332. package/lib/parse/parseSdt.d.ts +5 -0
  333. package/lib/parse/parseShape.d.ts +10 -0
  334. package/lib/parse/parseShape.js +247 -0
  335. package/lib/parse/parseSize.d.ts +2 -1
  336. package/lib/parse/parseSize.js +7 -0
  337. package/lib/parse/parseSpacing.js +1 -1
  338. package/lib/parse/parseTable.d.ts +3 -0
  339. package/lib/parse/parseTable.js +66 -0
  340. package/lib/parse/parseTablePr.d.ts +3 -0
  341. package/lib/parse/parseTablePr.js +189 -0
  342. package/lib/parse/parseTblWidth.d.ts +4 -0
  343. package/lib/parse/parseTblWidth.js +27 -0
  344. package/lib/parse/parseTc.d.ts +10 -0
  345. package/lib/parse/parseTc.js +68 -0
  346. package/lib/parse/parseTcPr.d.ts +5 -0
  347. package/lib/parse/parseTcPr.js +104 -0
  348. package/lib/parse/parseTextDirection.js +4 -6
  349. package/lib/parse/parseTr.d.ts +6 -0
  350. package/lib/parse/parseTr.js +53 -0
  351. package/lib/parse/parseTrPr.d.ts +3 -0
  352. package/lib/parse/parseTrPr.js +63 -0
  353. package/lib/render/fixAbsolutePosition.d.ts +8 -0
  354. package/lib/render/renderBody.d.ts +6 -2
  355. package/lib/render/renderBody.js +183 -29
  356. package/lib/render/renderBr.d.ts +2 -1
  357. package/lib/render/renderBr.js +4 -1
  358. package/lib/render/renderCustGeom.d.ts +4 -0
  359. package/lib/render/renderCustGeom.js +14 -0
  360. package/lib/render/renderDocument.d.ts +2 -2
  361. package/lib/render/renderDocument.js +2 -2
  362. package/lib/render/renderDrawing.d.ts +3 -2
  363. package/lib/render/renderDrawing.js +129 -24
  364. package/lib/render/renderFont.d.ts +5 -0
  365. package/lib/render/renderFont.js +43 -0
  366. package/lib/render/renderGeom.d.ts +4 -0
  367. package/lib/render/renderGeom.js +18 -0
  368. package/lib/render/renderHeader.d.ts +6 -0
  369. package/lib/render/renderHeader.js +44 -0
  370. package/lib/render/renderHyperLink.js +5 -2
  371. package/lib/render/renderInlineText.js +2 -2
  372. package/lib/render/renderInstrText.js +2 -2
  373. package/lib/render/renderMath.d.ts +3 -0
  374. package/lib/render/renderMath.js +11 -0
  375. package/lib/render/renderNoBreakHyphen.d.ts +1 -0
  376. package/lib/render/renderNoBreakHyphen.js +13 -0
  377. package/lib/render/renderNotes.d.ts +5 -0
  378. package/lib/render/renderNotes.js +81 -0
  379. package/lib/render/renderNumbering.js +9 -11
  380. package/lib/render/renderParagraph.d.ts +1 -1
  381. package/lib/render/renderParagraph.js +26 -29
  382. package/lib/render/renderPict.js +5 -10
  383. package/lib/render/renderRuby.js +3 -3
  384. package/lib/render/renderRun.d.ts +4 -2
  385. package/lib/render/renderRun.js +34 -9
  386. package/lib/render/renderSection.d.ts +3 -2
  387. package/lib/render/renderSection.js +79 -5
  388. package/lib/render/renderSeparator.d.ts +1 -0
  389. package/lib/render/renderSeparator.js +13 -0
  390. package/lib/render/renderSoftHyphen.d.ts +1 -0
  391. package/lib/render/renderSoftHyphen.js +13 -0
  392. package/lib/render/renderStyle.js +37 -36
  393. package/lib/render/renderTab.d.ts +1 -0
  394. package/lib/render/renderTab.js +4 -6
  395. package/lib/render/renderTable.js +25 -22
  396. package/lib/render/setElementStyle.js +6 -1
  397. package/lib/render/zindex.d.ts +1 -0
  398. package/lib/util/blob.js +0 -10
  399. package/lib/util/color.d.ts +48 -0
  400. package/lib/util/color.js +215 -0
  401. package/lib/util/createObject.d.ts +10 -0
  402. package/lib/util/createObject.js +54 -0
  403. package/lib/util/dom.d.ts +8 -4
  404. package/lib/util/dom.js +24 -5
  405. package/lib/util/mergeRun.js +5 -5
  406. package/lib/util/parseSides.d.ts +11 -0
  407. package/lib/util/print.d.ts +5 -0
  408. package/lib/util/print.js +58 -0
  409. package/lib/util/replaceVar.d.ts +10 -0
  410. package/lib/util/replaceVar.js +219 -0
  411. package/lib/util/xml.js +4 -0
  412. package/package.json +17 -6
  413. package/esm/node_modules/tslib/tslib.es6.js +0 -120
  414. package/esm/openxml/Types.js +0 -1003
  415. package/esm/openxml/word/CustomXml.d.ts +0 -8
  416. package/esm/openxml/word/SmartTag.d.ts +0 -8
  417. package/esm/openxml/word/SmartTag.js +0 -18
  418. package/esm/openxml/word/drawing/Blip.d.ts +0 -6
  419. package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
  420. package/esm/openxml/word/drawing/Drawing.js +0 -15
  421. package/esm/openxml/word/drawing/Pic.d.ts +0 -8
  422. package/esm/openxml/word/drawing/Pic.js +0 -16
  423. package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  424. package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
  425. package/lib/node_modules/tslib/tslib.es6.js +0 -129
  426. package/lib/openxml/Types.js +0 -1005
  427. package/lib/openxml/word/CustomXml.d.ts +0 -8
  428. package/lib/openxml/word/SmartTag.d.ts +0 -8
  429. package/lib/openxml/word/SmartTag.js +0 -22
  430. package/lib/openxml/word/drawing/Blip.d.ts +0 -6
  431. package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
  432. package/lib/openxml/word/drawing/Drawing.js +0 -19
  433. package/lib/openxml/word/drawing/Pic.d.ts +0 -8
  434. package/lib/openxml/word/drawing/Pic.js +0 -20
  435. package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
  436. package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
@@ -0,0 +1,25 @@
1
+ import { __values } from 'tslib';
2
+ import { Note } from '../openxml/word/Note.js';
3
+
4
+ function parseFootnotes(word, doc) {
5
+ var e_1, _a;
6
+ var footnotes = {};
7
+ var footnotesElement = [].slice.call(doc.getElementsByTagName('w:footnote'));
8
+ try {
9
+ for (var footnotesElement_1 = __values(footnotesElement), footnotesElement_1_1 = footnotesElement_1.next(); !footnotesElement_1_1.done; footnotesElement_1_1 = footnotesElement_1.next()) {
10
+ var footnoteElement = footnotesElement_1_1.value;
11
+ var footnote = Note.fromXML(word, footnoteElement);
12
+ footnotes[footnoteElement.getAttribute('w:id')] = footnote;
13
+ }
14
+ }
15
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
16
+ finally {
17
+ try {
18
+ if (footnotesElement_1_1 && !footnotesElement_1_1.done && (_a = footnotesElement_1.return)) _a.call(footnotesElement_1);
19
+ }
20
+ finally { if (e_1) throw e_1.error; }
21
+ }
22
+ return footnotes;
23
+ }
24
+
25
+ export { parseFootnotes };
@@ -0,0 +1,6 @@
1
+ import { ST_PresetColorVal } from './../openxml/Types';
2
+ /**
3
+ * 内置颜色
4
+ * 参考了 pptxjs 里的例子,并补充了 ST_PresetColorVal 里缺失的定义
5
+ */
6
+ export declare const PresetColorMap: Record<ST_PresetColorVal | 'darkYellow' | 'none' | 'rebeccaPurple', string>;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * 内置颜色
3
+ * 参考了 pptxjs 里的例子,并补充了 ST_PresetColorVal 里缺失的定义
4
+ */
5
+ var PresetColorMap = {
6
+ aliceBlue: '#f0f8ff',
7
+ antiqueWhite: '#faebd7',
8
+ aqua: '#00ffff',
9
+ aquamarine: '#7fffd4',
10
+ azure: '#f0ffff',
11
+ beige: '#f5f5dc',
12
+ bisque: '#ffe4c4',
13
+ black: '#000000',
14
+ blanchedAlmond: '#ffebcd',
15
+ blue: '#0000ff',
16
+ blueViolet: '#8a2be2',
17
+ brown: '#a52a2a',
18
+ burlyWood: '#deb887',
19
+ cadetBlue: '#5f9ea0',
20
+ chartreuse: '#7fff00',
21
+ chocolate: '#d2691e',
22
+ coral: '#ff7f50',
23
+ cornflowerBlue: '#6495ed',
24
+ cornsilk: '#fff8dc',
25
+ crimson: '#dc143c',
26
+ cyan: '#00FFFF',
27
+ darkBlue: '#00008B',
28
+ dkBlue: '#00008B',
29
+ darkCyan: '#008B8B',
30
+ dkCyan: '#008B8B',
31
+ darkGoldenrod: '#b8860b',
32
+ dkGoldenrod: '#b8860b',
33
+ darkGray: '#A9A9A9',
34
+ dkGray: '#A9A9A9',
35
+ darkGreen: '#006400',
36
+ dkGreen: '#006400',
37
+ darkGrey: '#a9a9a9',
38
+ dkGrey: '#a9a9a9',
39
+ darkKhaki: '#bdb76b',
40
+ dkKhaki: '#bdb76b',
41
+ darkMagenta: '#800080',
42
+ dkMagenta: '#800080',
43
+ darkOliveGreen: '#556b2f',
44
+ dkOliveGreen: '#556b2f',
45
+ darkOrange: '#ff8c00',
46
+ dkOrange: '#ff8c00',
47
+ darkOrchid: '#9932cc',
48
+ dkOrchid: '#9932cc',
49
+ darkRed: '#8B0000',
50
+ dkRed: '#8B0000',
51
+ darkSalmon: '#e9967a',
52
+ dkSalmon: '#e9967a',
53
+ darkSeaGreen: '#8fbc8f',
54
+ dkSeaGreen: '#8fbc8f',
55
+ darkSlateBlue: '#483d8b',
56
+ dkSlateBlue: '#483d8b',
57
+ darkSlateGray: '#2f4f4f',
58
+ dkSlateGray: '#2f4f4f',
59
+ darkSlateGrey: '#2f4f4f',
60
+ dkSlateGrey: '#2f4f4f',
61
+ darkTurquoise: '#00ced1',
62
+ dkTurquoise: '#00ced1',
63
+ darkViolet: '#9400d3',
64
+ dkViolet: '#9400d3',
65
+ darkYellow: '#808000',
66
+ deepPink: '#ff1493',
67
+ deepSkyBlue: '#00bfff',
68
+ dimGray: '#696969',
69
+ dimGrey: '#696969',
70
+ dodgerBlue: '#1e90ff',
71
+ firebrick: '#b22222',
72
+ floralWhite: '#fffaf0',
73
+ forestGreen: '#228b22',
74
+ fuchsia: '#ff00ff',
75
+ gainsboro: '#dcdcdc',
76
+ ghostWhite: '#f8f8ff',
77
+ gold: '#ffd700',
78
+ goldenrod: '#daa520',
79
+ gray: '#808080',
80
+ green: '#008000',
81
+ greenYellow: '#adff2f',
82
+ grey: '#808080',
83
+ honeydew: '#f0fff0',
84
+ hotPink: '#ff69b4',
85
+ indianRed: '#cd5c5c',
86
+ indigo: '#4b0082',
87
+ ivory: '#fffff0',
88
+ khaki: '#f0e68c',
89
+ lavender: '#e6e6fa',
90
+ lavenderBlush: '#fff0f5',
91
+ lawnGreen: '#7cfc00',
92
+ lemonChiffon: '#fffacd',
93
+ lightBlue: '#add8e6',
94
+ ltBlue: '#add8e6',
95
+ lightCoral: '#f08080',
96
+ ltCoral: '#f08080',
97
+ lightCyan: '#e0ffff',
98
+ ltCyan: '#e0ffff',
99
+ lightGoldenrodYellow: '#fafad2',
100
+ ltGoldenrodYellow: '#fafad2',
101
+ lightGray: '#D3D3D3',
102
+ ltGray: '#D3D3D3',
103
+ lightGreen: '#90ee90',
104
+ ltGreen: '#90ee90',
105
+ lightGrey: '#d3d3d3',
106
+ ltGrey: '#d3d3d3',
107
+ lightPink: '#ffb6c1',
108
+ ltPink: '#ffb6c1',
109
+ lightSalmon: '#ffa07a',
110
+ ltSalmon: '#ffa07a',
111
+ lightSeaGreen: '#20b2aa',
112
+ ltSeaGreen: '#20b2aa',
113
+ lightSkyBlue: '#87cefa',
114
+ ltSkyBlue: '#87cefa',
115
+ lightSlateGray: '#778899',
116
+ ltSlateGray: '#778899',
117
+ lightSlateGrey: '#778899',
118
+ ltSlateGrey: '#778899',
119
+ lightSteelBlue: '#b0c4de',
120
+ ltSteelBlue: '#b0c4de',
121
+ lightYellow: '#ffffe0',
122
+ ltYellow: '#ffffe0',
123
+ lime: '#00ff00',
124
+ limeGreen: '#32cd32',
125
+ linen: '#faf0e6',
126
+ magenta: '#FF00FF',
127
+ maroon: '#800000',
128
+ mediumAquamarine: '#66cdaa',
129
+ medAquamarine: '#66cdaa',
130
+ mediumBlue: '#0000cd',
131
+ medBlue: '#0000cd',
132
+ mediumOrchid: '#ba55d3',
133
+ medOrchid: '#ba55d3',
134
+ mediumPurple: '#9370db',
135
+ medPurple: '#9370db',
136
+ mediumSeaGreen: '#3cb371',
137
+ medSeaGreen: '#3cb371',
138
+ mediumSlateBlue: '#7b68ee',
139
+ medSlateBlue: '#7b68ee',
140
+ mediumSpringGreen: '#00fa9a',
141
+ medSpringGreen: '#00fa9a',
142
+ mediumTurquoise: '#48d1cc',
143
+ medTurquoise: '#48d1cc',
144
+ mediumVioletRed: '#c71585',
145
+ medVioletRed: '#c71585',
146
+ midnightBlue: '#191970',
147
+ mintCream: '#f5fffa',
148
+ mistyRose: '#ffe4e1',
149
+ moccasin: '#ffe4b5',
150
+ navajoWhite: '#ffdead',
151
+ navy: '#000080',
152
+ none: 'transparent',
153
+ oldLace: '#fdf5e6',
154
+ olive: '#808000',
155
+ oliveDrab: '#6b8e23',
156
+ orange: '#ffa500',
157
+ orangeRed: '#ff4500',
158
+ orchid: '#da70d6',
159
+ paleGoldenrod: '#eee8aa',
160
+ paleGreen: '#98fb98',
161
+ paleTurquoise: '#afeeee',
162
+ paleVioletRed: '#db7093',
163
+ papayaWhip: '#ffefd5',
164
+ peachPuff: '#ffdab9',
165
+ peru: '#cd853f',
166
+ pink: '#ffc0cb',
167
+ plum: '#dda0dd',
168
+ powderBlue: '#b0e0e6',
169
+ purple: '#800080',
170
+ rebeccaPurple: '#663399',
171
+ red: '#ff0000',
172
+ rosyBrown: '#bc8f8f',
173
+ royalBlue: '#4169e1',
174
+ saddleBrown: '#8b4513',
175
+ salmon: '#fa8072',
176
+ sandyBrown: '#f4a460',
177
+ seaGreen: '#2e8b57',
178
+ seaShell: '#fff5ee',
179
+ sienna: '#a0522d',
180
+ silver: '#c0c0c0',
181
+ skyBlue: '#87ceeb',
182
+ slateBlue: '#6a5acd',
183
+ slateGray: '#708090',
184
+ slateGrey: '#708090',
185
+ snow: '#fffafa',
186
+ springGreen: '#00ff7f',
187
+ steelBlue: '#4682b4',
188
+ tan: '#d2b48c',
189
+ teal: '#008080',
190
+ thistle: '#d8bfd8',
191
+ tomato: '#ff6347',
192
+ turquoise: '#40e0d0',
193
+ violet: '#ee82ee',
194
+ wheat: '#f5deb3',
195
+ white: '#ffffff',
196
+ whiteSmoke: '#f5f5f5',
197
+ yellow: '#ffff00',
198
+ yellowGreen: '#9acd32'
199
+ };
200
+
201
+ export { PresetColorMap };
@@ -13,6 +13,7 @@ function jcToTextAlign(jc) {
13
13
  case 'right':
14
14
  return 'right';
15
15
  case 'both':
16
+ case 'distribute':
16
17
  return 'justify';
17
18
  }
18
19
  return jc;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 将 sdt 内容合并到上层节点,返回合并后的数组
3
+ */
4
+ export declare function mergeSdt(element: Element | Document): Element[];
@@ -0,0 +1,57 @@
1
+ import { __values, __spreadArray, __read } from 'tslib';
2
+
3
+ /**
4
+ * 将 sdt 内容合并到上层节点,返回合并后的数组
5
+ */
6
+ function flattenSdtArray(arr) {
7
+ var e_1, _a;
8
+ var returnArray = arr.slice();
9
+ var index = 0;
10
+ // 如果 sdt 里还有 sdt 就需要递归
11
+ var needRecursion = false;
12
+ try {
13
+ for (var arr_1 = __values(arr), arr_1_1 = arr_1.next(); !arr_1_1.done; arr_1_1 = arr_1.next()) {
14
+ var child = arr_1_1.value;
15
+ var tagName = child.tagName;
16
+ switch (tagName) {
17
+ case 'w:smartTag':
18
+ case 'w:customXml':
19
+ var customXMLChildren = [].slice.call(child.children);
20
+ returnArray.splice.apply(returnArray, __spreadArray([index, 1], __read(customXMLChildren), false));
21
+ index = index + customXMLChildren.length;
22
+ continue;
23
+ case 'w:sdt':
24
+ var sdtContent = child.getElementsByTagName('w:sdtContent').item(0);
25
+ var childSdt = child.getElementsByTagName('w:sdt').item(0);
26
+ if (childSdt) {
27
+ needRecursion = true;
28
+ }
29
+ if (sdtContent) {
30
+ var sdtContentChildren = [].slice.call(sdtContent.children);
31
+ returnArray.splice.apply(returnArray, __spreadArray([index, 1], __read(sdtContentChildren), false));
32
+ index = index + sdtContentChildren.length;
33
+ continue;
34
+ }
35
+ break;
36
+ }
37
+ index = index + 1;
38
+ }
39
+ }
40
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
41
+ finally {
42
+ try {
43
+ if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
44
+ }
45
+ finally { if (e_1) throw e_1.error; }
46
+ }
47
+ if (needRecursion) {
48
+ return flattenSdtArray(returnArray);
49
+ }
50
+ return returnArray;
51
+ }
52
+ function mergeSdt(element) {
53
+ var arr = [].slice.call(element.children);
54
+ return flattenSdtArray(arr);
55
+ }
56
+
57
+ export { mergeSdt };
@@ -0,0 +1 @@
1
+ export declare function modifyColor(element: Element, colorStr: string): string;
@@ -0,0 +1,106 @@
1
+ import { __values } from 'tslib';
2
+ import { getAttrPercent } from '../OpenXML.js';
3
+ import { Color } from '../util/color.js';
4
+ import { convertAngle } from './parseSize.js';
5
+
6
+ // 处理颜色变化
7
+ // 20.1.2.3
8
+ function modifyColor(element, colorStr) {
9
+ var e_1, _a;
10
+ var color = new Color(colorStr);
11
+ if (color.isValid) {
12
+ var alpha = 1;
13
+ try {
14
+ for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
15
+ var child = _c.value;
16
+ var tagName = child.tagName;
17
+ switch (tagName) {
18
+ case 'a:alpha':
19
+ case 'w14:alpha':
20
+ alpha = getAttrPercent(child, 'val');
21
+ break;
22
+ case 'a:blue':
23
+ color.b = 256 * getAttrPercent(child, 'val');
24
+ break;
25
+ case 'a:blueMod':
26
+ color.b = color.b * getAttrPercent(child, 'val');
27
+ break;
28
+ case 'a:blueOff':
29
+ color.b += color.b * getAttrPercent(child, 'val');
30
+ break;
31
+ case 'a:comp':
32
+ color.comp();
33
+ break;
34
+ case 'a:green':
35
+ color.g = 256 * getAttrPercent(child, 'val');
36
+ break;
37
+ case 'a:greenMod':
38
+ color.g = color.g * getAttrPercent(child, 'val');
39
+ break;
40
+ case 'a:greenOff':
41
+ color.g += color.g * getAttrPercent(child, 'val');
42
+ break;
43
+ case 'a:red':
44
+ color.r = 256 * getAttrPercent(child, 'val');
45
+ break;
46
+ case 'a:redMod':
47
+ color.r = color.r * getAttrPercent(child, 'val');
48
+ break;
49
+ case 'a:redOff':
50
+ color.r += color.r * getAttrPercent(child, 'val');
51
+ break;
52
+ case 'a:lum':
53
+ color.lum(getAttrPercent(child, 'val'));
54
+ break;
55
+ case 'a:lumMod':
56
+ color.lumMod(getAttrPercent(child, 'val'));
57
+ break;
58
+ case 'a:lumOff':
59
+ color.lumOff(getAttrPercent(child, 'val'));
60
+ break;
61
+ case 'a:hue':
62
+ color.hue(convertAngle(child.getAttribute('hue')) / 360);
63
+ break;
64
+ case 'a:hueMod':
65
+ color.hueMod(getAttrPercent(child, 'val'));
66
+ break;
67
+ case 'a:hueOff':
68
+ color.hueOff(getAttrPercent(child, 'val'));
69
+ break;
70
+ case 'a:sat':
71
+ color.sat(getAttrPercent(child, 'val'));
72
+ break;
73
+ case 'a:satMod':
74
+ color.satMod(getAttrPercent(child, 'val'));
75
+ break;
76
+ case 'a:satOff':
77
+ color.satOff(getAttrPercent(child, 'val'));
78
+ break;
79
+ case 'a:shade':
80
+ color.shade(getAttrPercent(child, 'val'));
81
+ break;
82
+ case 'a:tint':
83
+ color.tint(getAttrPercent(child, 'val'));
84
+ break;
85
+ default:
86
+ console.log('unknown color modify', child);
87
+ break;
88
+ }
89
+ }
90
+ }
91
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
92
+ finally {
93
+ try {
94
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
95
+ }
96
+ finally { if (e_1) throw e_1.error; }
97
+ }
98
+ if (alpha !== 1) {
99
+ return color.toRgba(alpha);
100
+ }
101
+ return color.toHex();
102
+ }
103
+ return colorStr;
104
+ }
105
+
106
+ export { modifyColor };
@@ -1,8 +1,7 @@
1
- import { __values } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __values } from 'tslib';
2
2
  import { getVal } from '../OpenXML.js';
3
3
  import { parseColorAttr } from './parseColor.js';
4
4
  import { parseSize, LengthUsage } from './parseSize.js';
5
- import { ST_Border } from '../openxml/Types.js';
6
5
 
7
6
  // 默认边框颜色
8
7
  var DEFAULT_BORDER_COLOR = 'black';
@@ -11,27 +10,9 @@ var DEFAULT_BORDER_COLOR = 'black';
11
10
  */
12
11
  function parseBorder(word, element) {
13
12
  var type = getVal(element);
14
- if (type === ST_Border.nil || type === ST_Border.none) {
13
+ if (type === 'nil' || type === 'none') {
15
14
  return 'none';
16
15
  }
17
- // 这里和 css 不完全一致,css 能表现的要少很多,也是导致展现效果难以一致的原因
18
- switch (type) {
19
- case ST_Border.dashed:
20
- case ST_Border.dashDotStroked:
21
- case ST_Border.dashSmallGap:
22
- break;
23
- case ST_Border.dotDash:
24
- case ST_Border.dotDotDash:
25
- case ST_Border.dotted:
26
- break;
27
- case ST_Border.double:
28
- case ST_Border.doubleWave:
29
- break;
30
- case ST_Border.inset:
31
- break;
32
- case ST_Border.outset:
33
- break;
34
- }
35
16
  var color = parseColorAttr(word, element);
36
17
  var size = parseSize(element, 'w:sz', LengthUsage.Border);
37
18
  return "".concat(size, " solid ").concat(color == 'auto' ? DEFAULT_BORDER_COLOR : color);
@@ -0,0 +1,2 @@
1
+ import { CSSStyle } from '../openxml/Style';
2
+ export declare function parseCellMargin(element: Element, style: CSSStyle): void;
@@ -0,0 +1,38 @@
1
+ import { __values } from 'tslib';
2
+ import { parseSize } from './parseSize.js';
3
+
4
+ // http://officeopenxml.com/WPtableCellProperties-Margins.php
5
+ function parseCellMargin(element, style) {
6
+ var e_1, _a;
7
+ try {
8
+ for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
9
+ var child = _c.value;
10
+ var tagName = child.tagName;
11
+ switch (tagName) {
12
+ case 'w:left':
13
+ case 'w:start':
14
+ style['padding-left'] = parseSize(child, 'w:w');
15
+ break;
16
+ case 'w:right':
17
+ case 'w:end':
18
+ style['padding-right'] = parseSize(child, 'w:w');
19
+ break;
20
+ case 'w:top':
21
+ style['padding-top'] = parseSize(child, 'w:w');
22
+ break;
23
+ case 'w:bottom':
24
+ style['padding-bottom'] = parseSize(child, 'w:w');
25
+ break;
26
+ }
27
+ }
28
+ }
29
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
30
+ finally {
31
+ try {
32
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
33
+ }
34
+ finally { if (e_1) throw e_1.error; }
35
+ }
36
+ }
37
+
38
+ export { parseCellMargin };
@@ -0,0 +1,5 @@
1
+ import Word from '../Word';
2
+ /**
3
+ * 解析子节点颜色,这里其实还有 lumMod 和 lumOff
4
+ */
5
+ export declare function parseChildColor(word: Word, element: Element): string;
@@ -0,0 +1,66 @@
1
+ import { getVal, getAttrPercent } from '../OpenXML.js';
2
+ import { Color } from '../util/color.js';
3
+ import { PresetColorMap } from './colorNameMap.js';
4
+ import { modifyColor } from './modifyColor.js';
5
+
6
+ /**
7
+ * 解析子节点颜色,这里其实还有 lumMod 和 lumOff
8
+ */
9
+ function parseChildColor(word, element) {
10
+ var colorChild = element.firstElementChild;
11
+ if (colorChild) {
12
+ var colorType = colorChild.tagName;
13
+ switch (colorType) {
14
+ case 'a:prstClr':
15
+ var color = getVal(colorChild) || '';
16
+ if (color in PresetColorMap) {
17
+ return modifyColor(colorChild, PresetColorMap[color]);
18
+ }
19
+ else {
20
+ console.warn('parseOutline: Unknown color ', color, colorChild);
21
+ }
22
+ break;
23
+ case 'a:srgbClr':
24
+ case 'a:scrgbClr':
25
+ case 'w14:srgbClr':
26
+ var rgbColor = getVal(colorChild);
27
+ if (rgbColor) {
28
+ return modifyColor(colorChild, '#' + rgbColor);
29
+ }
30
+ var r = getAttrPercent(colorChild, 'r');
31
+ var g = getAttrPercent(colorChild, 'g');
32
+ var b = getAttrPercent(colorChild, 'b');
33
+ var scrgbColor = Color.fromRGB(r, g, b);
34
+ return modifyColor(colorChild, scrgbColor.toHex());
35
+ case 'a:hslClr':
36
+ var h = getAttrPercent(colorChild, 'r');
37
+ var s = getAttrPercent(colorChild, 'g');
38
+ var l = getAttrPercent(colorChild, 'b');
39
+ var val = getVal(colorChild);
40
+ // 文档例子里有,不确定
41
+ if (val) {
42
+ return modifyColor(colorChild, '#' + val);
43
+ }
44
+ var hslColor = Color.fromHSL(h, s, l);
45
+ return modifyColor(colorChild, hslColor.toHex());
46
+ case 'a:schemeClr':
47
+ case 'w14:schemeClr':
48
+ var schemeClr = getVal(colorChild);
49
+ if (schemeClr) {
50
+ return modifyColor(colorChild, word.getThemeColor(schemeClr));
51
+ }
52
+ else {
53
+ console.warn('parseOutline: Unknown schemeClr ', colorChild);
54
+ }
55
+ break;
56
+ case 'a:sysClr':
57
+ // 这里每个系统不一样,所以直接依赖浏览器的能力
58
+ return getVal(colorChild);
59
+ default:
60
+ console.warn('parseOutline: Unknown color type ', colorType, colorChild);
61
+ }
62
+ }
63
+ return '';
64
+ }
65
+
66
+ export { parseChildColor };
@@ -2,6 +2,10 @@
2
2
  * 解析颜色,转成 css 的颜色
3
3
  */
4
4
  import Word from '../Word';
5
+ /**
6
+ * css 里可以识别的颜色
7
+ */
8
+ export declare const cssColors: string[];
5
9
  /**
6
10
  *
7
11
  * 解析属性上的 color,比如 <w:top w:val="single" w:sz="24" w:space="1" w:color="FF0000" />