office-viewer 0.1.0

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 (318) hide show
  1. package/README.md +23 -0
  2. package/esm/OpenXML.d.ts +21 -0
  3. package/esm/OpenXML.js +60 -0
  4. package/esm/Word.d.ts +208 -0
  5. package/esm/Word.js +370 -0
  6. package/esm/index.d.ts +6 -0
  7. package/esm/index.js +6 -0
  8. package/esm/node_modules/tslib/tslib.es6.js +120 -0
  9. package/esm/openxml/ContentType.d.ts +12 -0
  10. package/esm/openxml/ContentType.js +15 -0
  11. package/esm/openxml/Style.d.ts +41 -0
  12. package/esm/openxml/Style.js +156 -0
  13. package/esm/openxml/Theme.d.ts +26 -0
  14. package/esm/openxml/Theme.js +69 -0
  15. package/esm/openxml/Types.d.ts +2512 -0
  16. package/esm/openxml/Types.js +1003 -0
  17. package/esm/openxml/word/Background.d.ts +11 -0
  18. package/esm/openxml/word/Body.d.ts +18 -0
  19. package/esm/openxml/word/Body.js +67 -0
  20. package/esm/openxml/word/Bookmark.d.ts +6 -0
  21. package/esm/openxml/word/Bookmark.js +18 -0
  22. package/esm/openxml/word/Border.d.ts +10 -0
  23. package/esm/openxml/word/Break.d.ts +13 -0
  24. package/esm/openxml/word/Break.js +19 -0
  25. package/esm/openxml/word/CustomXml.d.ts +8 -0
  26. package/esm/openxml/word/FldSimple.d.ts +7 -0
  27. package/esm/openxml/word/FldSimple.js +15 -0
  28. package/esm/openxml/word/FrameProperties.d.ts +18 -0
  29. package/esm/openxml/word/Hyperlink.d.ts +13 -0
  30. package/esm/openxml/word/Hyperlink.js +53 -0
  31. package/esm/openxml/word/Indent.d.ts +8 -0
  32. package/esm/openxml/word/InlineText.d.ts +14 -0
  33. package/esm/openxml/word/InlineText.js +62 -0
  34. package/esm/openxml/word/InstrText.d.ts +4 -0
  35. package/esm/openxml/word/InstrText.js +8 -0
  36. package/esm/openxml/word/Paragraph.d.ts +34 -0
  37. package/esm/openxml/word/Paragraph.js +133 -0
  38. package/esm/openxml/word/Pict.d.ts +6 -0
  39. package/esm/openxml/word/Pict.js +19 -0
  40. package/esm/openxml/word/Ruby.d.ts +20 -0
  41. package/esm/openxml/word/Ruby.js +87 -0
  42. package/esm/openxml/word/Run.d.ts +31 -0
  43. package/esm/openxml/word/Run.js +98 -0
  44. package/esm/openxml/word/Section.d.ts +38 -0
  45. package/esm/openxml/word/Section.js +59 -0
  46. package/esm/openxml/word/Shading.d.ts +9 -0
  47. package/esm/openxml/word/SmartTag.d.ts +8 -0
  48. package/esm/openxml/word/SmartTag.js +18 -0
  49. package/esm/openxml/word/Spacing.d.ts +9 -0
  50. package/esm/openxml/word/Sym.d.ts +8 -0
  51. package/esm/openxml/word/Sym.js +16 -0
  52. package/esm/openxml/word/Tab.d.ts +8 -0
  53. package/esm/openxml/word/Tab.js +17 -0
  54. package/esm/openxml/word/Table.d.ts +49 -0
  55. package/esm/openxml/word/Table.js +248 -0
  56. package/esm/openxml/word/VerticalAlign.d.ts +6 -0
  57. package/esm/openxml/word/WDocument.d.ts +13 -0
  58. package/esm/openxml/word/WDocument.js +58 -0
  59. package/esm/openxml/word/drawing/Blip.d.ts +6 -0
  60. package/esm/openxml/word/drawing/Blip.js +17 -0
  61. package/esm/openxml/word/drawing/BlipFill.d.ts +9 -0
  62. package/esm/openxml/word/drawing/BlipFill.js +20 -0
  63. package/esm/openxml/word/drawing/Drawing.d.ts +6 -0
  64. package/esm/openxml/word/drawing/Drawing.js +15 -0
  65. package/esm/openxml/word/drawing/Pic.d.ts +8 -0
  66. package/esm/openxml/word/drawing/Pic.js +16 -0
  67. package/esm/openxml/word/drawing/ShapeProperties.d.ts +9 -0
  68. package/esm/openxml/word/drawing/ShapeProperties.js +20 -0
  69. package/esm/openxml/word/drawing/Transform.d.ts +17 -0
  70. package/esm/openxml/word/drawing/Transform.js +30 -0
  71. package/esm/openxml/word/numbering/AbstractNum.d.ts +13 -0
  72. package/esm/openxml/word/numbering/AbstractNum.js +42 -0
  73. package/esm/openxml/word/numbering/Lvl.d.ts +16 -0
  74. package/esm/openxml/word/numbering/Lvl.js +62 -0
  75. package/esm/openxml/word/numbering/Num.d.ts +10 -0
  76. package/esm/openxml/word/numbering/Num.js +46 -0
  77. package/esm/openxml/word/numbering/NumberProperties.d.ts +6 -0
  78. package/esm/openxml/word/numbering/NumberProperties.js +21 -0
  79. package/esm/openxml/word/numbering/Numbering.d.ts +9 -0
  80. package/esm/openxml/word/numbering/Numbering.js +50 -0
  81. package/esm/openxml/word/properties/Properties.d.ts +12 -0
  82. package/esm/openxml/word/table/Tc.d.ts +46 -0
  83. package/esm/openxml/word/table/Tc.js +234 -0
  84. package/esm/openxml/word/table/Tr.d.ts +18 -0
  85. package/esm/openxml/word/table/Tr.js +106 -0
  86. package/esm/package/PackageParser.d.ts +26 -0
  87. package/esm/package/XMLPackageParser.d.ts +31 -0
  88. package/esm/package/ZipPackageParser.d.ts +29 -0
  89. package/esm/package/ZipPackageParser.js +70 -0
  90. package/esm/parse/jcToTextAlign.d.ts +5 -0
  91. package/esm/parse/jcToTextAlign.js +21 -0
  92. package/esm/parse/parseBorder.d.ts +13 -0
  93. package/esm/parse/parseBorder.js +78 -0
  94. package/esm/parse/parseColor.d.ts +22 -0
  95. package/esm/parse/parseColor.js +131 -0
  96. package/esm/parse/parseFont.d.ts +7 -0
  97. package/esm/parse/parseFont.js +54 -0
  98. package/esm/parse/parseInd.d.ts +5 -0
  99. package/esm/parse/parseInd.js +27 -0
  100. package/esm/parse/parsePr.d.ts +8 -0
  101. package/esm/parse/parsePr.js +325 -0
  102. package/esm/parse/parseRelationship.d.ts +12 -0
  103. package/esm/parse/parseRelationship.js +40 -0
  104. package/esm/parse/parseSize.d.ts +27 -0
  105. package/esm/parse/parseSize.js +38 -0
  106. package/esm/parse/parseSpacing.d.ts +7 -0
  107. package/esm/parse/parseSpacing.js +43 -0
  108. package/esm/parse/parseTextDirection.d.ts +2 -0
  109. package/esm/parse/parseTextDirection.js +25 -0
  110. package/esm/parse/parseTrHeight.d.ts +2 -0
  111. package/esm/parse/parseTrHeight.js +17 -0
  112. package/esm/render/renderBody.d.ts +6 -0
  113. package/esm/render/renderBody.js +53 -0
  114. package/esm/render/renderBookmark.d.ts +6 -0
  115. package/esm/render/renderBookmark.js +17 -0
  116. package/esm/render/renderBr.d.ts +7 -0
  117. package/esm/render/renderBr.js +13 -0
  118. package/esm/render/renderDocument.d.ts +7 -0
  119. package/esm/render/renderDocument.js +14 -0
  120. package/esm/render/renderDrawing.d.ts +8 -0
  121. package/esm/render/renderDrawing.js +38 -0
  122. package/esm/render/renderHyperLink.d.ts +7 -0
  123. package/esm/render/renderHyperLink.js +41 -0
  124. package/esm/render/renderInlineText.d.ts +6 -0
  125. package/esm/render/renderInlineText.js +39 -0
  126. package/esm/render/renderInstrText.d.ts +8 -0
  127. package/esm/render/renderInstrText.js +40 -0
  128. package/esm/render/renderNumbering.d.ts +7 -0
  129. package/esm/render/renderNumbering.js +161 -0
  130. package/esm/render/renderParagraph.d.ts +7 -0
  131. package/esm/render/renderParagraph.js +78 -0
  132. package/esm/render/renderPict.d.ts +6 -0
  133. package/esm/render/renderPict.js +19 -0
  134. package/esm/render/renderRuby.d.ts +6 -0
  135. package/esm/render/renderRuby.js +53 -0
  136. package/esm/render/renderRun.d.ts +14 -0
  137. package/esm/render/renderRun.js +116 -0
  138. package/esm/render/renderSection.d.ts +6 -0
  139. package/esm/render/renderSection.js +36 -0
  140. package/esm/render/renderStyle.d.ts +13 -0
  141. package/esm/render/renderStyle.js +194 -0
  142. package/esm/render/renderSym.d.ts +3 -0
  143. package/esm/render/renderSym.js +10 -0
  144. package/esm/render/renderTab.d.ts +7 -0
  145. package/esm/render/renderTab.js +19 -0
  146. package/esm/render/renderTable.d.ts +6 -0
  147. package/esm/render/renderTable.js +186 -0
  148. package/esm/render/setElementStyle.d.ts +6 -0
  149. package/esm/render/setElementStyle.js +21 -0
  150. package/esm/util/autoSpace.d.ts +5 -0
  151. package/esm/util/autoSpace.js +33 -0
  152. package/esm/util/blob.d.ts +9 -0
  153. package/esm/util/blob.js +39 -0
  154. package/esm/util/dom.d.ts +36 -0
  155. package/esm/util/dom.js +63 -0
  156. package/esm/util/mergeRun.d.ts +17 -0
  157. package/esm/util/mergeRun.js +134 -0
  158. package/esm/util/xml.d.ts +8 -0
  159. package/esm/util/xml.js +12 -0
  160. package/lib/OpenXML.d.ts +21 -0
  161. package/lib/OpenXML.js +69 -0
  162. package/lib/Word.d.ts +208 -0
  163. package/lib/Word.js +374 -0
  164. package/lib/index.d.ts +6 -0
  165. package/lib/index.js +10 -0
  166. package/lib/node_modules/tslib/tslib.es6.js +129 -0
  167. package/lib/openxml/ContentType.d.ts +12 -0
  168. package/lib/openxml/ContentType.js +19 -0
  169. package/lib/openxml/Style.d.ts +41 -0
  170. package/lib/openxml/Style.js +160 -0
  171. package/lib/openxml/Theme.d.ts +26 -0
  172. package/lib/openxml/Theme.js +73 -0
  173. package/lib/openxml/Types.d.ts +2512 -0
  174. package/lib/openxml/Types.js +1005 -0
  175. package/lib/openxml/word/Background.d.ts +11 -0
  176. package/lib/openxml/word/Body.d.ts +18 -0
  177. package/lib/openxml/word/Body.js +71 -0
  178. package/lib/openxml/word/Bookmark.d.ts +6 -0
  179. package/lib/openxml/word/Bookmark.js +22 -0
  180. package/lib/openxml/word/Border.d.ts +10 -0
  181. package/lib/openxml/word/Break.d.ts +13 -0
  182. package/lib/openxml/word/Break.js +23 -0
  183. package/lib/openxml/word/CustomXml.d.ts +8 -0
  184. package/lib/openxml/word/FldSimple.d.ts +7 -0
  185. package/lib/openxml/word/FldSimple.js +19 -0
  186. package/lib/openxml/word/FrameProperties.d.ts +18 -0
  187. package/lib/openxml/word/Hyperlink.d.ts +13 -0
  188. package/lib/openxml/word/Hyperlink.js +57 -0
  189. package/lib/openxml/word/Indent.d.ts +8 -0
  190. package/lib/openxml/word/InlineText.d.ts +14 -0
  191. package/lib/openxml/word/InlineText.js +66 -0
  192. package/lib/openxml/word/InstrText.d.ts +4 -0
  193. package/lib/openxml/word/InstrText.js +12 -0
  194. package/lib/openxml/word/Paragraph.d.ts +34 -0
  195. package/lib/openxml/word/Paragraph.js +137 -0
  196. package/lib/openxml/word/Pict.d.ts +6 -0
  197. package/lib/openxml/word/Pict.js +23 -0
  198. package/lib/openxml/word/Ruby.d.ts +20 -0
  199. package/lib/openxml/word/Ruby.js +91 -0
  200. package/lib/openxml/word/Run.d.ts +31 -0
  201. package/lib/openxml/word/Run.js +103 -0
  202. package/lib/openxml/word/Section.d.ts +38 -0
  203. package/lib/openxml/word/Section.js +63 -0
  204. package/lib/openxml/word/Shading.d.ts +9 -0
  205. package/lib/openxml/word/SmartTag.d.ts +8 -0
  206. package/lib/openxml/word/SmartTag.js +22 -0
  207. package/lib/openxml/word/Spacing.d.ts +9 -0
  208. package/lib/openxml/word/Sym.d.ts +8 -0
  209. package/lib/openxml/word/Sym.js +20 -0
  210. package/lib/openxml/word/Tab.d.ts +8 -0
  211. package/lib/openxml/word/Tab.js +21 -0
  212. package/lib/openxml/word/Table.d.ts +49 -0
  213. package/lib/openxml/word/Table.js +252 -0
  214. package/lib/openxml/word/VerticalAlign.d.ts +6 -0
  215. package/lib/openxml/word/WDocument.d.ts +13 -0
  216. package/lib/openxml/word/WDocument.js +62 -0
  217. package/lib/openxml/word/drawing/Blip.d.ts +6 -0
  218. package/lib/openxml/word/drawing/Blip.js +21 -0
  219. package/lib/openxml/word/drawing/BlipFill.d.ts +9 -0
  220. package/lib/openxml/word/drawing/BlipFill.js +24 -0
  221. package/lib/openxml/word/drawing/Drawing.d.ts +6 -0
  222. package/lib/openxml/word/drawing/Drawing.js +19 -0
  223. package/lib/openxml/word/drawing/Pic.d.ts +8 -0
  224. package/lib/openxml/word/drawing/Pic.js +20 -0
  225. package/lib/openxml/word/drawing/ShapeProperties.d.ts +9 -0
  226. package/lib/openxml/word/drawing/ShapeProperties.js +24 -0
  227. package/lib/openxml/word/drawing/Transform.d.ts +17 -0
  228. package/lib/openxml/word/drawing/Transform.js +34 -0
  229. package/lib/openxml/word/numbering/AbstractNum.d.ts +13 -0
  230. package/lib/openxml/word/numbering/AbstractNum.js +46 -0
  231. package/lib/openxml/word/numbering/Lvl.d.ts +16 -0
  232. package/lib/openxml/word/numbering/Lvl.js +66 -0
  233. package/lib/openxml/word/numbering/Num.d.ts +10 -0
  234. package/lib/openxml/word/numbering/Num.js +50 -0
  235. package/lib/openxml/word/numbering/NumberProperties.d.ts +6 -0
  236. package/lib/openxml/word/numbering/NumberProperties.js +25 -0
  237. package/lib/openxml/word/numbering/Numbering.d.ts +9 -0
  238. package/lib/openxml/word/numbering/Numbering.js +54 -0
  239. package/lib/openxml/word/properties/Properties.d.ts +12 -0
  240. package/lib/openxml/word/table/Tc.d.ts +46 -0
  241. package/lib/openxml/word/table/Tc.js +242 -0
  242. package/lib/openxml/word/table/Tr.d.ts +18 -0
  243. package/lib/openxml/word/table/Tr.js +110 -0
  244. package/lib/package/PackageParser.d.ts +26 -0
  245. package/lib/package/XMLPackageParser.d.ts +31 -0
  246. package/lib/package/ZipPackageParser.d.ts +29 -0
  247. package/lib/package/ZipPackageParser.js +74 -0
  248. package/lib/parse/jcToTextAlign.d.ts +5 -0
  249. package/lib/parse/jcToTextAlign.js +25 -0
  250. package/lib/parse/parseBorder.d.ts +13 -0
  251. package/lib/parse/parseBorder.js +83 -0
  252. package/lib/parse/parseColor.d.ts +22 -0
  253. package/lib/parse/parseColor.js +137 -0
  254. package/lib/parse/parseFont.d.ts +7 -0
  255. package/lib/parse/parseFont.js +58 -0
  256. package/lib/parse/parseInd.d.ts +5 -0
  257. package/lib/parse/parseInd.js +31 -0
  258. package/lib/parse/parsePr.d.ts +8 -0
  259. package/lib/parse/parsePr.js +329 -0
  260. package/lib/parse/parseRelationship.d.ts +12 -0
  261. package/lib/parse/parseRelationship.js +45 -0
  262. package/lib/parse/parseSize.d.ts +27 -0
  263. package/lib/parse/parseSize.js +44 -0
  264. package/lib/parse/parseSpacing.d.ts +7 -0
  265. package/lib/parse/parseSpacing.js +47 -0
  266. package/lib/parse/parseTextDirection.d.ts +2 -0
  267. package/lib/parse/parseTextDirection.js +29 -0
  268. package/lib/parse/parseTrHeight.d.ts +2 -0
  269. package/lib/parse/parseTrHeight.js +21 -0
  270. package/lib/render/renderBody.d.ts +6 -0
  271. package/lib/render/renderBody.js +57 -0
  272. package/lib/render/renderBookmark.d.ts +6 -0
  273. package/lib/render/renderBookmark.js +21 -0
  274. package/lib/render/renderBr.d.ts +7 -0
  275. package/lib/render/renderBr.js +17 -0
  276. package/lib/render/renderDocument.d.ts +7 -0
  277. package/lib/render/renderDocument.js +18 -0
  278. package/lib/render/renderDrawing.d.ts +8 -0
  279. package/lib/render/renderDrawing.js +42 -0
  280. package/lib/render/renderHyperLink.d.ts +7 -0
  281. package/lib/render/renderHyperLink.js +45 -0
  282. package/lib/render/renderInlineText.d.ts +6 -0
  283. package/lib/render/renderInlineText.js +43 -0
  284. package/lib/render/renderInstrText.d.ts +8 -0
  285. package/lib/render/renderInstrText.js +44 -0
  286. package/lib/render/renderNumbering.d.ts +7 -0
  287. package/lib/render/renderNumbering.js +165 -0
  288. package/lib/render/renderParagraph.d.ts +7 -0
  289. package/lib/render/renderParagraph.js +82 -0
  290. package/lib/render/renderPict.d.ts +6 -0
  291. package/lib/render/renderPict.js +23 -0
  292. package/lib/render/renderRuby.d.ts +6 -0
  293. package/lib/render/renderRuby.js +57 -0
  294. package/lib/render/renderRun.d.ts +14 -0
  295. package/lib/render/renderRun.js +121 -0
  296. package/lib/render/renderSection.d.ts +6 -0
  297. package/lib/render/renderSection.js +40 -0
  298. package/lib/render/renderStyle.d.ts +13 -0
  299. package/lib/render/renderStyle.js +199 -0
  300. package/lib/render/renderSym.d.ts +3 -0
  301. package/lib/render/renderSym.js +14 -0
  302. package/lib/render/renderTab.d.ts +7 -0
  303. package/lib/render/renderTab.js +23 -0
  304. package/lib/render/renderTable.d.ts +6 -0
  305. package/lib/render/renderTable.js +190 -0
  306. package/lib/render/setElementStyle.d.ts +6 -0
  307. package/lib/render/setElementStyle.js +25 -0
  308. package/lib/util/autoSpace.d.ts +5 -0
  309. package/lib/util/autoSpace.js +37 -0
  310. package/lib/util/blob.d.ts +9 -0
  311. package/lib/util/blob.js +44 -0
  312. package/lib/util/dom.d.ts +36 -0
  313. package/lib/util/dom.js +72 -0
  314. package/lib/util/mergeRun.d.ts +17 -0
  315. package/lib/util/mergeRun.js +140 -0
  316. package/lib/util/xml.d.ts +8 -0
  317. package/lib/util/xml.js +16 -0
  318. package/package.json +91 -0
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var Run = require('../Run.js');
7
+ var OpenXML = require('../../../OpenXML.js');
8
+ var Types = require('../../Types.js');
9
+ var Paragraph = require('../Paragraph.js');
10
+
11
+ var Lvl = /** @class */ (function () {
12
+ function Lvl() {
13
+ this.start = 1;
14
+ this.lvlText = '%1.';
15
+ this.isLgl = false;
16
+ this.lvlJc = Types.ST_Jc.start;
17
+ this.suff = Types.ST_LevelSuffix.space;
18
+ }
19
+ Lvl.fromXML = function (word, element) {
20
+ var e_1, _a;
21
+ var lvl = new Lvl();
22
+ lvl.ilvl = element.getAttribute('w:ilvl');
23
+ try {
24
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
25
+ var child = _c.value;
26
+ var tagName = child.tagName;
27
+ switch (tagName) {
28
+ case 'w:start':
29
+ lvl.start = OpenXML.getValNumber(child);
30
+ break;
31
+ case 'w:numFmt':
32
+ lvl.numFmt = OpenXML.getVal(child);
33
+ break;
34
+ case 'w:lvlText':
35
+ lvl.lvlText = OpenXML.getVal(child);
36
+ break;
37
+ case 'w:lvlJc':
38
+ lvl.lvlJc = OpenXML.getVal(child);
39
+ break;
40
+ case 'w:pPr':
41
+ lvl.pPr = Paragraph.Paragraph.parseParagraphPr(word, child);
42
+ break;
43
+ case 'w:rPr':
44
+ lvl.rPr = Run.Run.parseRunPr(word, child);
45
+ break;
46
+ case 'w:isLgl':
47
+ lvl.isLgl = OpenXML.getValBoolean(child);
48
+ break;
49
+ default:
50
+ console.warn("Lvl: Unknown tag ", tagName, child);
51
+ }
52
+ }
53
+ }
54
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
55
+ finally {
56
+ try {
57
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
58
+ }
59
+ finally { if (e_1) throw e_1.error; }
60
+ }
61
+ return lvl;
62
+ };
63
+ return Lvl;
64
+ }());
65
+
66
+ exports.Lvl = Lvl;
@@ -0,0 +1,10 @@
1
+ import Word from '../../../Word';
2
+ import { Lvl } from './Lvl';
3
+ export declare class Num {
4
+ numId: string;
5
+ abstractNumId: string;
6
+ lvlOverride: {
7
+ lvls: Record<string, Lvl>;
8
+ };
9
+ static fromXML(word: Word, element: Element): Num;
10
+ }
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var OpenXML = require('../../../OpenXML.js');
7
+ var Lvl = require('./Lvl.js');
8
+
9
+ var Num = /** @class */ (function () {
10
+ function Num() {
11
+ this.lvlOverride = { lvls: {} };
12
+ }
13
+ Num.fromXML = function (word, element) {
14
+ var e_1, _a;
15
+ var num = new Num();
16
+ num.numId = element.getAttribute('w:numId') || '';
17
+ var abstractNumId = element.querySelector('abstractNumId');
18
+ if (abstractNumId) {
19
+ num.abstractNumId = OpenXML.getVal(abstractNumId);
20
+ }
21
+ var lvlOverride = element.querySelector('lvlOverride');
22
+ if (lvlOverride) {
23
+ try {
24
+ for (var _b = tslib_es6.__values(lvlOverride.children), _c = _b.next(); !_c.done; _c = _b.next()) {
25
+ var child = _c.value;
26
+ var tagName = child.tagName;
27
+ switch (tagName) {
28
+ case 'w:lvl':
29
+ var lvlId = child.getAttribute('w:lvlId') || '';
30
+ num.lvlOverride.lvls[lvlId] = Lvl.Lvl.fromXML(word, child);
31
+ break;
32
+ default:
33
+ console.warn("Num: Unknown tag ", tagName, child);
34
+ }
35
+ }
36
+ }
37
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
38
+ finally {
39
+ try {
40
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
41
+ }
42
+ finally { if (e_1) throw e_1.error; }
43
+ }
44
+ }
45
+ return num;
46
+ };
47
+ return Num;
48
+ }());
49
+
50
+ exports.Num = Num;
@@ -0,0 +1,6 @@
1
+ import Word from '../../../Word';
2
+ export declare class NumberPr {
3
+ ilvl: string;
4
+ numId: string;
5
+ static fromXML(word: Word, element: Element): NumberPr;
6
+ }
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var OpenXML = require('../../../OpenXML.js');
6
+
7
+ var NumberPr = /** @class */ (function () {
8
+ function NumberPr() {
9
+ }
10
+ NumberPr.fromXML = function (word, element) {
11
+ var numPr = new NumberPr();
12
+ var ilvl = element.querySelector('ilvl');
13
+ if (ilvl) {
14
+ numPr.ilvl = OpenXML.getVal(ilvl);
15
+ }
16
+ var numId = element.querySelector('numId');
17
+ if (numId) {
18
+ numPr.numId = OpenXML.getVal(numId);
19
+ }
20
+ return numPr;
21
+ };
22
+ return NumberPr;
23
+ }());
24
+
25
+ exports.NumberPr = NumberPr;
@@ -0,0 +1,9 @@
1
+ import Word from '../../../Word';
2
+ import { AbstractNum } from './AbstractNum';
3
+ import { Num } from './Num';
4
+ export declare class Numbering {
5
+ abstractNums: Record<string, AbstractNum>;
6
+ nums: Record<string, Num>;
7
+ numData: Record<string, Record<string, number>>;
8
+ static fromXML(word: Word, element: Document): Numbering;
9
+ }
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var AbstractNum = require('./AbstractNum.js');
7
+ var Num = require('./Num.js');
8
+
9
+ var Numbering = /** @class */ (function () {
10
+ function Numbering() {
11
+ this.abstractNums = {};
12
+ this.nums = {};
13
+ // 某个 numId 当前值,如果要重新渲染文档,需要将这个置空,
14
+ // 第一个 key 是 numId,第二个 key 是 ilvl,第一个 key 会自动初始化
15
+ this.numData = {};
16
+ }
17
+ Numbering.fromXML = function (word, element) {
18
+ var e_1, _a, e_2, _b;
19
+ var numbering = new Numbering();
20
+ try {
21
+ for (var _c = tslib_es6.__values(element.getElementsByTagName('w:abstractNum')), _d = _c.next(); !_d.done; _d = _c.next()) {
22
+ var abstractNumElement = _d.value;
23
+ var abstractNum = AbstractNum.AbstractNum.fromXML(word, abstractNumElement);
24
+ numbering.abstractNums[abstractNum.abstractNumId] = abstractNum;
25
+ }
26
+ }
27
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
28
+ finally {
29
+ try {
30
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
31
+ }
32
+ finally { if (e_1) throw e_1.error; }
33
+ }
34
+ try {
35
+ for (var _e = tslib_es6.__values(element.getElementsByTagName('w:num')), _f = _e.next(); !_f.done; _f = _e.next()) {
36
+ var numElement = _f.value;
37
+ var num = Num.Num.fromXML(word, numElement);
38
+ numbering.nums[num.numId] = num;
39
+ numbering.numData[num.numId] = {};
40
+ }
41
+ }
42
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
43
+ finally {
44
+ try {
45
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
46
+ }
47
+ finally { if (e_2) throw e_2.error; }
48
+ }
49
+ return numbering;
50
+ };
51
+ return Numbering;
52
+ }());
53
+
54
+ exports.Numbering = Numbering;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 属性通用设置项
3
+ */
4
+ import { CSSStyle } from '../../Style';
5
+ export interface Properties {
6
+ /**
7
+ * 解析后的 css 样式
8
+ */
9
+ cssStyle?: CSSStyle;
10
+ pStyle?: string;
11
+ rStyle?: string;
12
+ }
@@ -0,0 +1,46 @@
1
+ import Word from '../../../Word';
2
+ import { CSSStyle } from '../../Style';
3
+ import { Paragraph } from '../Paragraph';
4
+ import { Table } from '../Table';
5
+ import { ST_Merge } from '../../Types';
6
+ export interface TcPr {
7
+ cssStyle?: CSSStyle;
8
+ hideMark?: false;
9
+ vMerge?: ST_Merge;
10
+ gridSpan?: number;
11
+ rowSpan?: number;
12
+ /**
13
+ * 内部 border,需要作用于非第一列的单元格
14
+ */
15
+ insideBorder?: {
16
+ H?: string;
17
+ V?: string;
18
+ };
19
+ }
20
+ type TcChild = Paragraph | Table;
21
+ export declare function parseCellMargin(element: Element, style: CSSStyle): void;
22
+ export declare function parseTblCellSpacing(element: Element, style: CSSStyle): void;
23
+ /**
24
+ * parseBorders 不支持 insideH 和 insideV,所以单独支持一下
25
+ * 实际显示时需要过滤掉第一列
26
+ */
27
+ export declare function parseInsideBorders(word: Word, element: Element): {
28
+ H: string | undefined;
29
+ V: string | undefined;
30
+ };
31
+ /**
32
+ * http://officeopenxml.com/WPtableWidth.php
33
+ */
34
+ export declare function parseTblWidth(element: Element): string;
35
+ export declare class Tc {
36
+ properties: TcPr;
37
+ children: TcChild[];
38
+ add(child: TcChild): void;
39
+ static parseTcPr(word: Word, element: Element): TcPr;
40
+ static fromXML(word: Word, element: Element, currentCol: {
41
+ index: number;
42
+ }, rowSpanMap: {
43
+ [key: string]: Tc;
44
+ }): Tc | null;
45
+ }
46
+ export {};
@@ -0,0 +1,242 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var OpenXML = require('../../../OpenXML.js');
7
+ var Paragraph = require('../Paragraph.js');
8
+ var Table = require('../Table.js');
9
+ var parseSize = require('../../../parse/parseSize.js');
10
+ var parseColor = require('../../../parse/parseColor.js');
11
+ var parseBorder = require('../../../parse/parseBorder.js');
12
+ var parseTextDirection = require('../../../parse/parseTextDirection.js');
13
+ var Types = require('../../Types.js');
14
+
15
+ // http://officeopenxml.com/WPtableCellProperties-Margins.php
16
+ function parseCellMargin(element, style) {
17
+ var e_1, _a;
18
+ try {
19
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
20
+ var child = _c.value;
21
+ var tagName = child.tagName;
22
+ switch (tagName) {
23
+ case 'w:left':
24
+ case 'w:start':
25
+ style['padding-left'] = parseSize.parseSize(child, 'w:w');
26
+ break;
27
+ case 'w:right':
28
+ case 'w:end':
29
+ style['padding-right'] = parseSize.parseSize(child, 'w:w');
30
+ break;
31
+ case 'w:top':
32
+ style['padding-top'] = parseSize.parseSize(child, 'w:w');
33
+ break;
34
+ case 'w:bottom':
35
+ style['padding-bottom'] = parseSize.parseSize(child, 'w:w');
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
41
+ finally {
42
+ try {
43
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
44
+ }
45
+ finally { if (e_1) throw e_1.error; }
46
+ }
47
+ }
48
+ function parseVAlign(element, style) {
49
+ var vAlign = OpenXML.getVal(element);
50
+ switch (vAlign) {
51
+ case Types.ST_VerticalJc.bottom:
52
+ style['vertical-align'] = 'bottom';
53
+ break;
54
+ case Types.ST_VerticalJc.center:
55
+ style['vertical-align'] = 'middle';
56
+ break;
57
+ case Types.ST_VerticalJc.top:
58
+ style['vertical-align'] = 'top';
59
+ break;
60
+ }
61
+ }
62
+ function parseTblCellSpacing(element, style) {
63
+ var width = parseTblWidth(element);
64
+ if (width) {
65
+ style['cell-spacing'] = width;
66
+ }
67
+ }
68
+ /**
69
+ * parseBorders 不支持 insideH 和 insideV,所以单独支持一下
70
+ * 实际显示时需要过滤掉第一列
71
+ */
72
+ function parseInsideBorders(word, element) {
73
+ var H;
74
+ var insideH = element.querySelector('insideH');
75
+ if (insideH) {
76
+ H = parseBorder.parseBorder(word, insideH);
77
+ }
78
+ var V;
79
+ var insideV = element.querySelector('insideV');
80
+ if (insideV) {
81
+ V = parseBorder.parseBorder(word, insideV);
82
+ }
83
+ return {
84
+ H: H,
85
+ V: V
86
+ };
87
+ }
88
+ /**
89
+ * http://officeopenxml.com/WPtableWidth.php
90
+ */
91
+ function parseTblWidth(element) {
92
+ var type = element.getAttribute('w:type');
93
+ if (!type || type === Types.ST_TblWidth.dxa) {
94
+ return parseSize.parseSize(element, 'w:w');
95
+ }
96
+ else if (type === Types.ST_TblWidth.pct) {
97
+ return parseSize.parseSize(element, 'w:w', parseSize.LengthUsage.Percent);
98
+ }
99
+ else if (type === Types.ST_TblWidth.auto) {
100
+ return 'auto';
101
+ }
102
+ else {
103
+ console.warn('parseTblWidth: ignore type', type, element);
104
+ }
105
+ return '';
106
+ }
107
+ function parseTcW(element, style) {
108
+ var width = parseTblWidth(element);
109
+ if (width) {
110
+ style.width = width;
111
+ }
112
+ }
113
+ var Tc = /** @class */ (function () {
114
+ function Tc() {
115
+ this.properties = {};
116
+ this.children = [];
117
+ }
118
+ Tc.prototype.add = function (child) {
119
+ if (child) {
120
+ this.children.push(child);
121
+ }
122
+ };
123
+ Tc.parseTcPr = function (word, element) {
124
+ var e_2, _a;
125
+ var properties = {};
126
+ var style = {};
127
+ properties.cssStyle = style;
128
+ try {
129
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
130
+ var child = _c.value;
131
+ var tagName = child.tagName;
132
+ switch (tagName) {
133
+ case 'w:tcMar':
134
+ parseCellMargin(child, style);
135
+ break;
136
+ case 'w:shd':
137
+ style['background-color'] = parseColor.parseShdColor(word, child);
138
+ break;
139
+ case 'w:tcW':
140
+ parseTcW(child, style);
141
+ break;
142
+ case 'w:noWrap':
143
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noWrap.html
144
+ var noWrap = OpenXML.getValBoolean(child);
145
+ if (noWrap) {
146
+ style['white-space'] = 'nowrap';
147
+ }
148
+ break;
149
+ case 'w:vAlign':
150
+ parseVAlign(child, style);
151
+ break;
152
+ case 'w:tcBorders':
153
+ parseBorder.parseBorders(word, child, style);
154
+ properties.insideBorder = parseInsideBorders(word, child);
155
+ break;
156
+ case 'w:gridSpan':
157
+ properties.gridSpan = OpenXML.getValNumber(child);
158
+ break;
159
+ case 'w:vMerge':
160
+ properties.vMerge = OpenXML.getVal(child) || Types.ST_Merge.continue;
161
+ break;
162
+ case 'w:textDirection':
163
+ parseTextDirection.parseTextDirection(child, style);
164
+ break;
165
+ case 'w:cnfStyle':
166
+ // 目前是自动计算的,所以不需要这个了
167
+ break;
168
+ default:
169
+ console.warn('parseTcPr: ignore', tagName, child);
170
+ }
171
+ }
172
+ }
173
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
174
+ finally {
175
+ try {
176
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
177
+ }
178
+ finally { if (e_2) throw e_2.error; }
179
+ }
180
+ return properties;
181
+ };
182
+ Tc.fromXML = function (word, element, currentCol, rowSpanMap) {
183
+ var e_3, _a;
184
+ var tc = new Tc();
185
+ try {
186
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
187
+ var child = _c.value;
188
+ var tagName = child.tagName;
189
+ switch (tagName) {
190
+ case 'w:tcPr':
191
+ tc.properties = Tc.parseTcPr(word, child);
192
+ break;
193
+ case 'w:p':
194
+ tc.add(Paragraph.Paragraph.fromXML(word, child));
195
+ break;
196
+ case 'w:tbl':
197
+ tc.add(Table.Table.fromXML(word, child));
198
+ break;
199
+ }
200
+ }
201
+ }
202
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
203
+ finally {
204
+ try {
205
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
206
+ }
207
+ finally { if (e_3) throw e_3.error; }
208
+ }
209
+ var lastCol = rowSpanMap[currentCol.index];
210
+ // 如果是 continue 意味着这个被合并了
211
+ if (tc.properties.vMerge) {
212
+ if (tc.properties.vMerge === Types.ST_Merge.restart) {
213
+ tc.properties.rowSpan = 1;
214
+ rowSpanMap[currentCol.index] = tc;
215
+ }
216
+ else if (lastCol) {
217
+ if (lastCol.properties && lastCol.properties.rowSpan) {
218
+ lastCol.properties.rowSpan = lastCol.properties.rowSpan + 1;
219
+ var colSpan_1 = tc.properties.gridSpan || 1;
220
+ currentCol.index += colSpan_1;
221
+ return null;
222
+ }
223
+ else {
224
+ console.warn('Tc.fromXML: continue but not found lastCol', currentCol.index, tc, rowSpanMap);
225
+ }
226
+ }
227
+ }
228
+ else {
229
+ delete rowSpanMap[currentCol.index];
230
+ }
231
+ var colSpan = tc.properties.gridSpan || 1;
232
+ currentCol.index += colSpan;
233
+ return tc;
234
+ };
235
+ return Tc;
236
+ }());
237
+
238
+ exports.Tc = Tc;
239
+ exports.parseCellMargin = parseCellMargin;
240
+ exports.parseInsideBorders = parseInsideBorders;
241
+ exports.parseTblCellSpacing = parseTblCellSpacing;
242
+ exports.parseTblWidth = parseTblWidth;
@@ -0,0 +1,18 @@
1
+ import { CSSStyle } from '../../Style';
2
+ import { Tc } from './Tc';
3
+ import Word from '../../../Word';
4
+ export interface TrPr {
5
+ cssStyle?: CSSStyle;
6
+ /**
7
+ * 单元格样式
8
+ */
9
+ tcStyle?: CSSStyle;
10
+ }
11
+ export declare class Tr {
12
+ properties: TrPr;
13
+ tcs: Tc[];
14
+ static parseTrPr(word: Word, element: Element): TrPr;
15
+ static fromXML(word: Word, element: Element, rowSpanMap: {
16
+ [key: string]: Tc;
17
+ }): Tr;
18
+ }
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
6
+ var OpenXML = require('../../../OpenXML.js');
7
+ var Tc = require('./Tc.js');
8
+ var parseTrHeight = require('../../../parse/parseTrHeight.js');
9
+ var jcToTextAlign = require('../../../parse/jcToTextAlign.js');
10
+ var Table = require('../Table.js');
11
+
12
+ var Tr = /** @class */ (function () {
13
+ function Tr() {
14
+ this.properties = {};
15
+ this.tcs = [];
16
+ }
17
+ Tr.parseTrPr = function (word, element) {
18
+ var e_1, _a;
19
+ var cssStyle = {};
20
+ var tcStyle = {};
21
+ try {
22
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
23
+ var child = _c.value;
24
+ var tagName = child.tagName;
25
+ switch (tagName) {
26
+ case 'w:hidden':
27
+ if (OpenXML.getValBoolean(child)) {
28
+ cssStyle.display = 'none';
29
+ }
30
+ break;
31
+ case 'w:trHeight':
32
+ parseTrHeight.parseTrHeight(child, cssStyle);
33
+ break;
34
+ case 'w:jc':
35
+ cssStyle['text-align'] = jcToTextAlign.jcToTextAlign(OpenXML.getVal(child));
36
+ break;
37
+ case 'w:cantSplit':
38
+ // 目前也不支持分页
39
+ break;
40
+ case 'w:tblPrEx':
41
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
42
+ var tablePr = Table.Table.parseTablePr(word, child);
43
+ Object.assign(cssStyle, tablePr.cssStyle);
44
+ break;
45
+ case 'w:tblCellSpacing':
46
+ Tc.parseTblCellSpacing(child, tcStyle);
47
+ break;
48
+ case 'w:cnfStyle':
49
+ // 目前是自动计算的,所以不需要这个了
50
+ break;
51
+ default:
52
+ console.warn("Tr: Unknown tag ", tagName, child);
53
+ }
54
+ }
55
+ }
56
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
57
+ finally {
58
+ try {
59
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
60
+ }
61
+ finally { if (e_1) throw e_1.error; }
62
+ }
63
+ return {
64
+ cssStyle: cssStyle
65
+ };
66
+ };
67
+ Tr.fromXML = function (word, element, rowSpanMap) {
68
+ var e_2, _a;
69
+ var tr = new Tr();
70
+ // 做成对象是为了传递引用来修改
71
+ var currentCol = {
72
+ index: 0
73
+ };
74
+ try {
75
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
76
+ var child = _c.value;
77
+ var tagName = child.tagName;
78
+ switch (tagName) {
79
+ case 'w:tc':
80
+ var tc = Tc.Tc.fromXML(word, child, currentCol, rowSpanMap);
81
+ if (tc) {
82
+ tr.tcs.push(tc);
83
+ }
84
+ break;
85
+ case 'w:trPr':
86
+ tr.properties = Tr.parseTrPr(word, child);
87
+ break;
88
+ case 'w:tblPrEx':
89
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
90
+ var tablePr = Table.Table.parseTablePr(word, child);
91
+ Object.assign(tr.properties.cssStyle || {}, tablePr.cssStyle);
92
+ break;
93
+ default:
94
+ console.warn("Tr: Unknown tag ", tagName, child);
95
+ }
96
+ }
97
+ }
98
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
99
+ finally {
100
+ try {
101
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
102
+ }
103
+ finally { if (e_2) throw e_2.error; }
104
+ }
105
+ return tr;
106
+ };
107
+ return Tr;
108
+ }());
109
+
110
+ exports.Tr = Tr;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 文件加载器默认是直接读取 zip,如果要对文件做特殊加密处理,可以实现这个接口
3
+ */
4
+ export interface PackageParser {
5
+ load(docxFile: ArrayBuffer | string): void;
6
+ /**
7
+ * 读取 xml 文件,转成 json 对象
8
+ * @param filePath 文件路径
9
+ * @returns 转成 json 的结果
10
+ */
11
+ getXML(filePath: string): Document;
12
+ /**
13
+ * 根据类型读取文件
14
+ */
15
+ getFileByType(filePath: string, type: 'string' | 'blob'): string | Blob;
16
+ /**
17
+ * 文件是否存在
18
+ */
19
+ fileExists(filePath: string): boolean;
20
+ /**
21
+ * 生成新的 zip 文件
22
+ *
23
+ * @param docContent 新的 word/document.xml 文件内容
24
+ */
25
+ generateZip(docContent: string): Blob;
26
+ }