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,91 @@
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
+
8
+ /**
9
+ * 注音
10
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ruby.html
11
+ */
12
+ var RubyBase = /** @class */ (function () {
13
+ function RubyBase() {
14
+ }
15
+ RubyBase.fromXML = function (word, element) {
16
+ var e_1, _a;
17
+ var rubyBase = new RubyBase();
18
+ rubyBase.children = [];
19
+ try {
20
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
21
+ var child = _c.value;
22
+ var tagName = child.tagName;
23
+ switch (tagName) {
24
+ case 'w:r':
25
+ var run = Run.Run.fromXML(word, child);
26
+ if (run) {
27
+ rubyBase.children.push(run);
28
+ }
29
+ break;
30
+ default:
31
+ console.warn('parse Ruby: Unknown key', tagName, child);
32
+ }
33
+ }
34
+ }
35
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36
+ finally {
37
+ try {
38
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
39
+ }
40
+ finally { if (e_1) throw e_1.error; }
41
+ }
42
+ return rubyBase;
43
+ };
44
+ return RubyBase;
45
+ }());
46
+ // 看起来应该是一样的
47
+ /** @class */ ((function (_super) {
48
+ tslib_es6.__extends(RubyText, _super);
49
+ function RubyText() {
50
+ return _super !== null && _super.apply(this, arguments) || this;
51
+ }
52
+ return RubyText;
53
+ })(RubyBase));
54
+ var Ruby = /** @class */ (function () {
55
+ function Ruby() {
56
+ }
57
+ Ruby.fromXML = function (word, element) {
58
+ var e_2, _a;
59
+ var ruby = new Ruby();
60
+ try {
61
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
62
+ var child = _c.value;
63
+ var tagName = child.tagName;
64
+ switch (tagName) {
65
+ case 'w:rubyPr':
66
+ // 应该是没法控制的
67
+ break;
68
+ case 'w:rt':
69
+ ruby.rt = RubyBase.fromXML(word, child);
70
+ break;
71
+ case 'w:rubyBase':
72
+ ruby.rubyBase = RubyBase.fromXML(word, child);
73
+ break;
74
+ default:
75
+ console.warn('parse Ruby: Unknown key', tagName, child);
76
+ }
77
+ }
78
+ }
79
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
80
+ finally {
81
+ try {
82
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
83
+ }
84
+ finally { if (e_2) throw e_2.error; }
85
+ }
86
+ return ruby;
87
+ };
88
+ return Ruby;
89
+ }());
90
+
91
+ exports.Ruby = Ruby;
@@ -0,0 +1,31 @@
1
+ import Word from '../../Word';
2
+ import { ST_VerticalAlignRun } from '../Types';
3
+ import { Break } from './Break';
4
+ import { Drawing } from './drawing/Drawing';
5
+ import { InstrText } from './InstrText';
6
+ import { Pict } from './Pict';
7
+ import { Properties } from './properties/Properties';
8
+ import { Ruby } from './Ruby';
9
+ import { Sym } from './Sym';
10
+ import { Tab } from './Tab';
11
+ /**
12
+ * 一段文本
13
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Run_1.html
14
+ */
15
+ export interface RunPr extends Properties {
16
+ vertAlign?: ST_VerticalAlignRun;
17
+ }
18
+ export declare class Text {
19
+ preserveSpace: boolean;
20
+ text: string;
21
+ constructor(text: string | number);
22
+ }
23
+ type RunChild = Break | Drawing | Text | Tab | Pict | Ruby | InstrText | Sym;
24
+ export declare class Run {
25
+ properties: RunPr;
26
+ children: RunChild[];
27
+ addChild(child: RunChild | null): void;
28
+ static parseRunPr(word: Word, element: Element): RunPr;
29
+ static fromXML(word: Word, element: Element): Run;
30
+ }
31
+ export {};
@@ -0,0 +1,103 @@
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 parsePr = require('../../parse/parsePr.js');
8
+ var Break = require('./Break.js');
9
+ var Drawing = require('./drawing/Drawing.js');
10
+ var InstrText = require('./InstrText.js');
11
+ var Pict = require('./Pict.js');
12
+ var Ruby = require('./Ruby.js');
13
+ var Sym = require('./Sym.js');
14
+ var Tab = require('./Tab.js');
15
+
16
+ var Text = /** @class */ (function () {
17
+ function Text(text) {
18
+ this.preserveSpace = false;
19
+ this.text = String(text);
20
+ }
21
+ return Text;
22
+ }());
23
+ var Run = /** @class */ (function () {
24
+ function Run() {
25
+ this.properties = {};
26
+ this.children = [];
27
+ }
28
+ Run.prototype.addChild = function (child) {
29
+ if (child) {
30
+ this.children.push(child);
31
+ }
32
+ };
33
+ Run.parseRunPr = function (word, element) {
34
+ var cssStyle = parsePr.parsePr(word, element);
35
+ var rStyle;
36
+ var rStyleElement = element.getElementsByTagName('w:rStyle').item(0);
37
+ if (rStyleElement) {
38
+ rStyle = OpenXML.getVal(rStyleElement);
39
+ }
40
+ return { cssStyle: cssStyle, rStyle: rStyle };
41
+ };
42
+ Run.fromXML = function (word, element) {
43
+ var e_1, _a;
44
+ var run = new Run();
45
+ try {
46
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
47
+ var child = _c.value;
48
+ var tagName = child.tagName;
49
+ switch (tagName) {
50
+ case 'w:t':
51
+ var textContent = child.textContent || '';
52
+ var text = new Text(textContent);
53
+ run.addChild(text);
54
+ break;
55
+ case 'w:rPr':
56
+ run.properties = Run.parseRunPr(word, child);
57
+ break;
58
+ case 'w:br':
59
+ run.addChild(Break.Break.fromXML(word, child));
60
+ break;
61
+ case 'w:drawing':
62
+ run.addChild(Drawing.Drawing.fromXML(word, child));
63
+ break;
64
+ case 'w:tab':
65
+ run.addChild(Tab.Tab.fromXML(word, child));
66
+ break;
67
+ case 'w:fldChar':
68
+ // 似乎只需要支持 instrText
69
+ break;
70
+ case 'w:instrText':
71
+ run.addChild(new InstrText.InstrText(child.textContent || ''));
72
+ break;
73
+ case 'w:lastRenderedPageBreak':
74
+ // 目前也不支持分页显示
75
+ break;
76
+ case 'w:pict':
77
+ run.addChild(Pict.Pict.fromXML(word, child));
78
+ break;
79
+ case 'w:ruby':
80
+ run.addChild(Ruby.Ruby.fromXML(word, child));
81
+ break;
82
+ case 'w:sym':
83
+ run.addChild(Sym.Sym.parseXML(child));
84
+ break;
85
+ default:
86
+ console.warn('parse Run: Unknown key', tagName, child);
87
+ }
88
+ }
89
+ }
90
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
91
+ finally {
92
+ try {
93
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
94
+ }
95
+ finally { if (e_1) throw e_1.error; }
96
+ }
97
+ return run;
98
+ };
99
+ return Run;
100
+ }());
101
+
102
+ exports.Run = Run;
103
+ exports.Text = Text;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * section 属性
3
+ * word 文档是按 section 组织的
4
+ * 参考了 docx 里的类型定义
5
+ */
6
+ import { ST_PageOrientation } from '../Types';
7
+ import { Hyperlink } from './Hyperlink';
8
+ import { Paragraph } from './Paragraph';
9
+ import { Table } from './Table';
10
+ export type PageSize = {
11
+ width: string;
12
+ height: string;
13
+ orientation?: ST_PageOrientation;
14
+ };
15
+ export type PageMargin = {
16
+ top?: string;
17
+ right?: string;
18
+ bottom?: string;
19
+ left?: string;
20
+ header?: string;
21
+ footer?: string;
22
+ gutter?: string;
23
+ };
24
+ export interface Column {
25
+ width?: number;
26
+ space?: number;
27
+ }
28
+ export type SectionChild = Paragraph | Table | Hyperlink;
29
+ export interface SectionPr {
30
+ pageSize?: PageSize;
31
+ pageMargin?: PageMargin;
32
+ }
33
+ export declare class Section {
34
+ properties: SectionPr;
35
+ children: SectionChild[];
36
+ addChild(child: SectionChild): void;
37
+ static parsePr(element: Element): SectionPr;
38
+ }
@@ -0,0 +1,63 @@
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 parseSize = require('../../parse/parseSize.js');
7
+
8
+ /**
9
+ * section 属性
10
+ * word 文档是按 section 组织的
11
+ * 参考了 docx 里的类型定义
12
+ */
13
+ var Section = /** @class */ (function () {
14
+ function Section() {
15
+ this.properties = {};
16
+ this.children = [];
17
+ }
18
+ Section.prototype.addChild = function (child) {
19
+ this.children.push(child);
20
+ };
21
+ Section.parsePr = function (element) {
22
+ var e_1, _a;
23
+ var properties = {};
24
+ try {
25
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
26
+ var child = _c.value;
27
+ var tagName = child.tagName;
28
+ switch (tagName) {
29
+ case 'w:pgSz':
30
+ properties.pageSize = {
31
+ width: parseSize.parseSize(child, 'w:w'),
32
+ height: parseSize.parseSize(child, 'w:h')
33
+ };
34
+ break;
35
+ case 'w:pgMar':
36
+ properties.pageMargin = {
37
+ left: parseSize.parseSize(child, 'w:left'),
38
+ right: parseSize.parseSize(child, 'w:right'),
39
+ top: parseSize.parseSize(child, 'w:top'),
40
+ bottom: parseSize.parseSize(child, 'w:bottom'),
41
+ header: parseSize.parseSize(child, 'w:header'),
42
+ footer: parseSize.parseSize(child, 'w:footer'),
43
+ gutter: parseSize.parseSize(child, 'w:gutter')
44
+ };
45
+ break;
46
+ default:
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
52
+ finally {
53
+ try {
54
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
55
+ }
56
+ finally { if (e_1) throw e_1.error; }
57
+ }
58
+ return properties;
59
+ };
60
+ return Section;
61
+ }());
62
+
63
+ exports.Section = Section;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * http://officeopenxml.com/WPshading.php
3
+ */
4
+ import { ST_Shd } from '../Types';
5
+ export interface Shading {
6
+ readonly fill?: string;
7
+ readonly color?: string;
8
+ readonly type?: ST_Shd;
9
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/smartTag.html
3
+ */
4
+ import Word from '../../Word';
5
+ import { InlineText } from './InlineText';
6
+ export declare class SmartTag extends InlineText {
7
+ static fromXML(word: Word, element: Element): InlineText;
8
+ }
@@ -0,0 +1,22 @@
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 InlineText = require('./InlineText.js');
7
+
8
+ /**
9
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/smartTag.html
10
+ */
11
+ var SmartTag = /** @class */ (function (_super) {
12
+ tslib_es6.__extends(SmartTag, _super);
13
+ function SmartTag() {
14
+ return _super !== null && _super.apply(this, arguments) || this;
15
+ }
16
+ SmartTag.fromXML = function (word, element) {
17
+ return InlineText.InlineText.fromXML(word, element);
18
+ };
19
+ return SmartTag;
20
+ }(InlineText.InlineText));
21
+
22
+ exports.SmartTag = SmartTag;
@@ -0,0 +1,9 @@
1
+ import { ST_LineSpacingRule } from '../Types';
2
+ export interface Spacing {
3
+ readonly after?: number;
4
+ readonly before?: number;
5
+ readonly line?: number;
6
+ readonly lineRule?: ST_LineSpacingRule;
7
+ readonly beforeAutoSpacing?: boolean;
8
+ readonly afterAutoSpacing?: boolean;
9
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/sym.html
3
+ */
4
+ export declare class Sym {
5
+ font: string;
6
+ char: string;
7
+ static parseXML(element: Element): Sym;
8
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/sym.html
7
+ */
8
+ var Sym = /** @class */ (function () {
9
+ function Sym() {
10
+ }
11
+ Sym.parseXML = function (element) {
12
+ var sym = new Sym();
13
+ sym.font = element.getAttribute('w:font') || '';
14
+ sym.char = element.getAttribute('w:char') || '';
15
+ return sym;
16
+ };
17
+ return Sym;
18
+ }());
19
+
20
+ exports.Sym = Sym;
@@ -0,0 +1,8 @@
1
+ import Word from '../../Word';
2
+ import { ST_TabJc, ST_TabTlc } from '../Types';
3
+ export declare class Tab {
4
+ type: ST_TabJc;
5
+ pos: string;
6
+ leader?: ST_TabTlc;
7
+ static fromXML(word: Word, element: Element): Tab;
8
+ }
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var OpenXML = require('../../OpenXML.js');
6
+ var parseSize = require('../../parse/parseSize.js');
7
+
8
+ var Tab = /** @class */ (function () {
9
+ function Tab() {
10
+ }
11
+ Tab.fromXML = function (word, element) {
12
+ var tab = new Tab();
13
+ tab.pos = parseSize.parseSize(element, 'w:pos');
14
+ tab.type = OpenXML.getVal(element);
15
+ tab.leader = element.getAttribute('w:leader');
16
+ return tab;
17
+ };
18
+ return Tab;
19
+ }());
20
+
21
+ exports.Tab = Tab;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * http://officeopenxml.com/WPtable.php
3
+ */
4
+ import Word from '../../Word';
5
+ import { CSSStyle } from '../Style';
6
+ import { CT_TblLook } from '../Types';
7
+ import { Properties } from './properties/Properties';
8
+ import { Tr } from './table/Tr';
9
+ export type CT_TblLookKey = keyof CT_TblLook;
10
+ export interface TablePr extends Properties {
11
+ /**
12
+ * 表格标题
13
+ */
14
+ tblCaption?: string;
15
+ /**
16
+ * 单元格样式
17
+ */
18
+ tcCSSStyle?: CSSStyle;
19
+ /**
20
+ * 内部 border,需要作用于非第一列的单元格
21
+ */
22
+ insideBorder?: {
23
+ H?: string;
24
+ V?: string;
25
+ };
26
+ /**
27
+ * 条件格式
28
+ */
29
+ tblLook?: Record<CT_TblLookKey, boolean>;
30
+ /**
31
+ * 行间隔
32
+ */
33
+ rowBandSize?: number;
34
+ /**
35
+ * 列间隔
36
+ */
37
+ colBandSize?: number;
38
+ }
39
+ interface GridCol {
40
+ w: string;
41
+ }
42
+ export declare class Table {
43
+ properties: TablePr;
44
+ tblGrid: GridCol[];
45
+ trs: Tr[];
46
+ static parseTablePr(word: Word, element: Element): TablePr;
47
+ static fromXML(word: Word, element: Element): Table;
48
+ }
49
+ export {};