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,11 @@
1
+ /**
2
+ * 文档背景
3
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/background.html
4
+ */
5
+ export interface DocumentBackground {
6
+ color?: string;
7
+ themeColor?: string;
8
+ themeShade?: string;
9
+ themeTint?: string;
10
+ vml?: any;
11
+ }
@@ -0,0 +1,18 @@
1
+ import Word from '../../Word';
2
+ import { Section, SectionChild, SectionPr } from './Section';
3
+ /**
4
+ * body 类型定义
5
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/body.html
6
+ */
7
+ export declare class Body {
8
+ sections: Section[];
9
+ currentSection: Section;
10
+ constructor();
11
+ addChild(child: SectionChild): void;
12
+ /**
13
+ * 添加 secetion
14
+ * @param properties 前一个 section 的属性
15
+ */
16
+ addSection(properties: SectionPr): void;
17
+ static fromXML(word: Word, element: Element): Body;
18
+ }
@@ -0,0 +1,71 @@
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 Paragraph = require('./Paragraph.js');
7
+ var Section = require('./Section.js');
8
+ var Table = require('./Table.js');
9
+
10
+ /**
11
+ * body 类型定义
12
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/body.html
13
+ */
14
+ var Body = /** @class */ (function () {
15
+ function Body() {
16
+ this.sections = [];
17
+ // 默认构建第一个 section
18
+ this.currentSection = new Section.Section();
19
+ this.sections.push(this.currentSection);
20
+ }
21
+ Body.prototype.addChild = function (child) {
22
+ this.currentSection.addChild(child);
23
+ };
24
+ /**
25
+ * 添加 secetion
26
+ * @param properties 前一个 section 的属性
27
+ */
28
+ Body.prototype.addSection = function (properties) {
29
+ this.currentSection.properties = properties;
30
+ this.currentSection = new Section.Section();
31
+ this.sections.push(this.currentSection);
32
+ };
33
+ Body.fromXML = function (word, element) {
34
+ var e_1, _a;
35
+ var body = new Body();
36
+ try {
37
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
38
+ var child = _c.value;
39
+ var tagName = child.tagName;
40
+ switch (tagName) {
41
+ case 'w:p':
42
+ var paragraph = Paragraph.Paragraph.fromXML(word, child);
43
+ body.addChild(paragraph);
44
+ break;
45
+ case 'w:sectPr':
46
+ body.addSection(Section.Section.parsePr(child));
47
+ break;
48
+ case 'w:tbl':
49
+ var table = Table.Table.fromXML(word, child);
50
+ body.addChild(table);
51
+ break;
52
+ case 'w:bookmarkEnd':
53
+ break;
54
+ default:
55
+ console.warn('Body.fromXML Unknown key', tagName, child);
56
+ }
57
+ }
58
+ }
59
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
60
+ finally {
61
+ try {
62
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
63
+ }
64
+ finally { if (e_1) throw e_1.error; }
65
+ }
66
+ return body;
67
+ };
68
+ return Body;
69
+ }());
70
+
71
+ exports.Body = Body;
@@ -0,0 +1,6 @@
1
+ import Word from '../../Word';
2
+ export declare class BookmarkStart {
3
+ name: string;
4
+ constructor(name: string);
5
+ static fromXML(word: Word, element: Element): BookmarkStart;
6
+ }
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var BookmarkStart = /** @class */ (function () {
6
+ function BookmarkStart(name) {
7
+ this.name = name;
8
+ }
9
+ BookmarkStart.fromXML = function (word, element) {
10
+ var name = element.getAttribute('w:name');
11
+ if (name) {
12
+ return new BookmarkStart(name);
13
+ }
14
+ else {
15
+ console.warn('Bookmark without name');
16
+ return new BookmarkStart('unknown');
17
+ }
18
+ };
19
+ return BookmarkStart;
20
+ }());
21
+
22
+ exports.BookmarkStart = BookmarkStart;
@@ -0,0 +1,10 @@
1
+ import { ST_Border } from '../Types';
2
+ export interface BorderOptions {
3
+ readonly style: ST_Border;
4
+ /** Border color, in hex (eg 'FF00AA') */
5
+ readonly color?: string;
6
+ /** Size of the border in 1/8 pt */
7
+ readonly size?: number;
8
+ /** Spacing offset. Values are specified in pt */
9
+ readonly space?: number;
10
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/br.html
3
+ */
4
+ import Word from '../../Word';
5
+ import { ST_BrClear, ST_BrType } from '../Types';
6
+ export declare class Break {
7
+ /**
8
+ * 目前也只支持这种
9
+ */
10
+ type: ST_BrType;
11
+ clear?: ST_BrClear;
12
+ static fromXML(word: Word, element: Element): Break;
13
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Types = require('../Types.js');
6
+
7
+ /**
8
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/br.html
9
+ */
10
+ var Break = /** @class */ (function () {
11
+ function Break() {
12
+ /**
13
+ * 目前也只支持这种
14
+ */
15
+ this.type = Types.ST_BrType.textWrapping;
16
+ }
17
+ Break.fromXML = function (word, element) {
18
+ return new Break();
19
+ };
20
+ return Break;
21
+ }());
22
+
23
+ exports.Break = Break;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 不知道是啥,主要是为了避免文本内容丢失,目前先当 SmartTag 处理了
3
+ */
4
+ import Word from '../../Word';
5
+ import { SmartTag } from './SmartTag';
6
+ export declare class CustomXml {
7
+ static fromXML(word: Word, element: Element): SmartTag;
8
+ }
@@ -0,0 +1,7 @@
1
+ import Word from '../../Word';
2
+ import { InlineText } from './InlineText';
3
+ export declare class FldSimple {
4
+ instr: string;
5
+ inlineText: InlineText;
6
+ static fromXML(word: Word, element: Element): FldSimple;
7
+ }
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var InlineText = require('./InlineText.js');
6
+
7
+ var FldSimple = /** @class */ (function () {
8
+ function FldSimple() {
9
+ }
10
+ FldSimple.fromXML = function (word, element) {
11
+ var fldSimple = new FldSimple();
12
+ fldSimple.inlineText = InlineText.InlineText.fromXML(word, element);
13
+ fldSimple.instr = element.getAttribute('w:instr') || '';
14
+ return fldSimple;
15
+ };
16
+ return FldSimple;
17
+ }());
18
+
19
+ exports.FldSimple = FldSimple;
@@ -0,0 +1,18 @@
1
+ import { ST_DropCap, ST_HAnchor, ST_HeightRule, ST_VAnchor, ST_Wrap } from '../Types';
2
+ export interface FramePr {
3
+ readonly anchorLock?: boolean;
4
+ readonly dropCap?: ST_DropCap;
5
+ readonly width: number;
6
+ readonly height: number;
7
+ readonly wrap?: ST_Wrap;
8
+ readonly lines?: number;
9
+ readonly anchor: {
10
+ readonly horizontal: ST_HAnchor;
11
+ readonly vertical: ST_VAnchor;
12
+ };
13
+ readonly space?: {
14
+ readonly horizontal: number;
15
+ readonly vertical: number;
16
+ };
17
+ readonly rule?: ST_HeightRule;
18
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/hyperlink_2.html
3
+ */
4
+ import { Relationship } from '../../parse/parseRelationship';
5
+ import Word from '../../Word';
6
+ import { Run } from './Run';
7
+ export declare class Hyperlink {
8
+ anchor?: string;
9
+ relation?: Relationship;
10
+ children: Run[];
11
+ addChild(Run: Run): void;
12
+ static fromXML(word: Word, element: Element): Hyperlink;
13
+ }
@@ -0,0 +1,57 @@
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
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/hyperlink_2.html
10
+ */
11
+ var Hyperlink = /** @class */ (function () {
12
+ function Hyperlink() {
13
+ this.children = [];
14
+ }
15
+ Hyperlink.prototype.addChild = function (Run) {
16
+ this.children.push(Run);
17
+ };
18
+ Hyperlink.fromXML = function (word, element) {
19
+ var e_1, _a;
20
+ var hyperlink = new Hyperlink();
21
+ var rId = element.getAttribute('r:id');
22
+ if (rId) {
23
+ var rel = word.getRelationship(rId);
24
+ if (rel) {
25
+ hyperlink.relation = rel;
26
+ }
27
+ }
28
+ var anchor = element.getAttribute('anchor');
29
+ if (anchor) {
30
+ hyperlink.anchor = anchor;
31
+ }
32
+ try {
33
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
34
+ var child = _c.value;
35
+ var tagName = child.tagName;
36
+ switch (tagName) {
37
+ case 'w:r':
38
+ hyperlink.addChild(Run.Run.fromXML(word, child));
39
+ break;
40
+ default:
41
+ console.warn('parse Hyperlink: Unknown key', tagName, child);
42
+ }
43
+ }
44
+ }
45
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
46
+ finally {
47
+ try {
48
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
49
+ }
50
+ finally { if (e_1) throw e_1.error; }
51
+ }
52
+ return hyperlink;
53
+ };
54
+ return Hyperlink;
55
+ }());
56
+
57
+ exports.Hyperlink = Hyperlink;
@@ -0,0 +1,8 @@
1
+ export interface Indent {
2
+ readonly start?: number;
3
+ readonly end?: number;
4
+ readonly left?: number;
5
+ readonly right?: number;
6
+ readonly hanging?: number;
7
+ readonly firstLine?: number;
8
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 通用的文本元素
3
+ */
4
+ import Word from '../../Word';
5
+ import { BookmarkStart } from './Bookmark';
6
+ import { Hyperlink } from './Hyperlink';
7
+ import { Run } from './Run';
8
+ type InlineChild = Run | BookmarkStart | Hyperlink;
9
+ export declare class InlineText {
10
+ children: InlineChild[];
11
+ addChild(child: InlineChild): void;
12
+ static fromXML(word: Word, element: Element): InlineText;
13
+ }
14
+ export {};
@@ -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 Bookmark = require('./Bookmark.js');
7
+ var Hyperlink = require('./Hyperlink.js');
8
+ var Run = require('./Run.js');
9
+
10
+ /**
11
+ * 通用的文本元素
12
+ */
13
+ var InlineText = /** @class */ (function () {
14
+ function InlineText() {
15
+ this.children = [];
16
+ }
17
+ InlineText.prototype.addChild = function (child) {
18
+ this.children.push(child);
19
+ };
20
+ InlineText.fromXML = function (word, element) {
21
+ var e_1, _a;
22
+ var smartTag = new InlineText();
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:r':
29
+ smartTag.addChild(Run.Run.fromXML(word, child));
30
+ break;
31
+ case 'w:hyperlink':
32
+ smartTag.addChild(Hyperlink.Hyperlink.fromXML(word, child));
33
+ break;
34
+ case 'w:bookmarkStart':
35
+ smartTag.addChild(Bookmark.BookmarkStart.fromXML(word, child));
36
+ case 'w:bookmarkEnd':
37
+ // 没啥用所以不解析了
38
+ break;
39
+ case 'w:proofErr':
40
+ case 'w:noProof':
41
+ // 语法检查
42
+ break;
43
+ case 'w:smartTagPr':
44
+ // 看起来对渲染没用
45
+ break;
46
+ case 'w:del':
47
+ // del 看起来主要是用于跟踪历史的,先不支持
48
+ break;
49
+ default:
50
+ console.warn('parse Inline: Unknown key', 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 smartTag;
62
+ };
63
+ return InlineText;
64
+ }());
65
+
66
+ exports.InlineText = InlineText;
@@ -0,0 +1,4 @@
1
+ export declare class InstrText {
2
+ readonly text: string;
3
+ constructor(text: string);
4
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var InstrText = /** @class */ (function () {
6
+ function InstrText(text) {
7
+ this.text = text;
8
+ }
9
+ return InstrText;
10
+ }());
11
+
12
+ exports.InstrText = InstrText;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 段落的定义和解析
3
+ */
4
+ import Word from '../../Word';
5
+ import { BookmarkStart } from './Bookmark';
6
+ import { Hyperlink } from './Hyperlink';
7
+ import { NumberPr } from './numbering/NumberProperties';
8
+ import { Properties } from './properties/Properties';
9
+ import { Run, RunPr } from './Run';
10
+ import { Tab } from './Tab';
11
+ import { SmartTag } from './SmartTag';
12
+ import { FldSimple } from './FldSimple';
13
+ /**
14
+ * 这里简化了很多,如果能用 CSS 表示就直接用 CSS 表示
15
+ */
16
+ export interface ParagraphPr extends Properties {
17
+ numPr?: NumberPr;
18
+ runPr?: RunPr;
19
+ tabs?: Tab[];
20
+ /**
21
+ * 其实是区分 autoSpaceDN 和 autoSpaceDE 的,但这里简化了
22
+ */
23
+ autoSpace?: boolean;
24
+ }
25
+ export type ParagraphChild = Run | BookmarkStart | Hyperlink | SmartTag | FldSimple;
26
+ export declare class Paragraph {
27
+ paraId?: string;
28
+ properties: ParagraphPr;
29
+ children: ParagraphChild[];
30
+ fldSimples: FldSimple[];
31
+ addChild(child: ParagraphChild): void;
32
+ static parseParagraphPr(word: Word, element: Element): ParagraphPr;
33
+ static fromXML(word: Word, element: Element): Paragraph;
34
+ }
@@ -0,0 +1,137 @@
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 Bookmark = require('./Bookmark.js');
9
+ var Hyperlink = require('./Hyperlink.js');
10
+ var NumberProperties = require('./numbering/NumberProperties.js');
11
+ var Run = require('./Run.js');
12
+ var Tab = require('./Tab.js');
13
+ var SmartTag = require('./SmartTag.js');
14
+ var FldSimple = require('./FldSimple.js');
15
+
16
+ /**
17
+ * 段落的定义和解析
18
+ */
19
+ // | SymbolRun
20
+ // | PageBreak
21
+ // | ColumnBreak
22
+ // | SequentialIdentifier
23
+ // | FootnoteReferenceRun
24
+ // | InsertedTextRun
25
+ // | DeletedTextRun
26
+ // | Math
27
+ // | SimpleField
28
+ // | SimpleMailMergeField
29
+ // | Comments
30
+ // | Comment
31
+ // | CommentRangeStart
32
+ // | CommentRangeEnd
33
+ // | CommentReference;
34
+ function parseAutoSpace(element) {
35
+ var autoSpaceDE = element.getElementsByTagName('w:autoSpaceDE').item(0);
36
+ var autoSpaceDN = element.getElementsByTagName('w:autoSpaceDN').item(0);
37
+ return !!autoSpaceDE || !!autoSpaceDN;
38
+ }
39
+ var Paragraph = /** @class */ (function () {
40
+ function Paragraph() {
41
+ this.properties = {};
42
+ this.children = [];
43
+ this.fldSimples = [];
44
+ }
45
+ Paragraph.prototype.addChild = function (child) {
46
+ this.children.push(child);
47
+ };
48
+ Paragraph.parseParagraphPr = function (word, element) {
49
+ var e_1, _a;
50
+ var cssStyle = parsePr.parsePr(word, element);
51
+ var pStyle;
52
+ var pStyleTag = element.querySelector('pStyle');
53
+ if (pStyleTag) {
54
+ pStyle = OpenXML.getVal(pStyleTag);
55
+ }
56
+ var numPr;
57
+ var numPrTag = element.querySelector('numPr');
58
+ if (numPrTag) {
59
+ numPr = NumberProperties.NumberPr.fromXML(word, numPrTag);
60
+ }
61
+ var tabs = [];
62
+ var tabElements = element.getElementsByTagName('w:tab');
63
+ try {
64
+ for (var tabElements_1 = tslib_es6.__values(tabElements), tabElements_1_1 = tabElements_1.next(); !tabElements_1_1.done; tabElements_1_1 = tabElements_1.next()) {
65
+ var tabElement = tabElements_1_1.value;
66
+ tabs.push(Tab.Tab.fromXML(word, tabElement));
67
+ }
68
+ }
69
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
70
+ finally {
71
+ try {
72
+ if (tabElements_1_1 && !tabElements_1_1.done && (_a = tabElements_1.return)) _a.call(tabElements_1);
73
+ }
74
+ finally { if (e_1) throw e_1.error; }
75
+ }
76
+ var autoSpace = parseAutoSpace(element);
77
+ return { cssStyle: cssStyle, pStyle: pStyle, numPr: numPr, tabs: tabs, autoSpace: autoSpace };
78
+ };
79
+ Paragraph.fromXML = function (word, element) {
80
+ var e_2, _a;
81
+ var paragraph = new Paragraph();
82
+ paragraph.fldSimples = [];
83
+ paragraph.paraId = element.getAttribute('w14:paraId') || '';
84
+ try {
85
+ for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
86
+ var child = _c.value;
87
+ var tagName = child.tagName;
88
+ switch (tagName) {
89
+ case 'w:pPr':
90
+ paragraph.properties = Paragraph.parseParagraphPr(word, child);
91
+ break;
92
+ case 'w:r':
93
+ paragraph.addChild(Run.Run.fromXML(word, child));
94
+ break;
95
+ case 'w:hyperlink':
96
+ paragraph.addChild(Hyperlink.Hyperlink.fromXML(word, child));
97
+ break;
98
+ case 'w:bookmarkStart':
99
+ paragraph.addChild(Bookmark.BookmarkStart.fromXML(word, child));
100
+ case 'w:bookmarkEnd':
101
+ // 没啥用所以不解析了
102
+ break;
103
+ case 'w:proofErr':
104
+ case 'w:noProof':
105
+ // 语法检查
106
+ break;
107
+ case 'w:del':
108
+ case 'w:moveTo':
109
+ case 'w:moveFrom':
110
+ // del 看起来主要是用于跟踪历史的,先不支持
111
+ break;
112
+ case 'w:smartTag':
113
+ case 'w:customXml':
114
+ paragraph.addChild(SmartTag.SmartTag.fromXML(word, child));
115
+ break;
116
+ case 'w:fldSimple':
117
+ // 这个目前还不想支持
118
+ paragraph.fldSimples.push(FldSimple.FldSimple.fromXML(word, child));
119
+ break;
120
+ default:
121
+ console.warn('parse Paragraph: Unknown key', tagName, child);
122
+ }
123
+ }
124
+ }
125
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
126
+ finally {
127
+ try {
128
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
129
+ }
130
+ finally { if (e_2) throw e_2.error; }
131
+ }
132
+ return paragraph;
133
+ };
134
+ return Paragraph;
135
+ }());
136
+
137
+ exports.Paragraph = Paragraph;
@@ -0,0 +1,6 @@
1
+ import { Relationship } from '../../parse/parseRelationship';
2
+ import Word from '../../Word';
3
+ export declare class Pict {
4
+ imagedata?: Relationship;
5
+ static fromXML(word: Word, element: Element): Pict | null;
6
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Pict = /** @class */ (function () {
6
+ function Pict() {
7
+ }
8
+ Pict.fromXML = function (word, element) {
9
+ var pict = new Pict();
10
+ var imagedataElement = element.querySelector('imagedata');
11
+ if (imagedataElement) {
12
+ var rId = imagedataElement.getAttribute('r:id') || '';
13
+ var rel = word.getRelationship(rId);
14
+ if (rel) {
15
+ pict.imagedata = rel;
16
+ }
17
+ }
18
+ return pict;
19
+ };
20
+ return Pict;
21
+ }());
22
+
23
+ exports.Pict = Pict;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 注音
3
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ruby.html
4
+ */
5
+ import Word from '../../Word';
6
+ import { Run } from './Run';
7
+ export declare class RubyPr {
8
+ }
9
+ declare class RubyBase {
10
+ children: Run[];
11
+ static fromXML(word: Word, element: Element): RubyBase;
12
+ }
13
+ declare class RubyText extends RubyBase {
14
+ }
15
+ export declare class Ruby {
16
+ rt?: RubyText;
17
+ rubyBase?: RubyBase;
18
+ static fromXML(word: Word, element: Element): Ruby;
19
+ }
20
+ export {};