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,116 @@
1
+ import { __values } from '../node_modules/tslib/tslib.es6.js';
2
+ import { renderBr } from './renderBr.js';
3
+ import { createElement, appendChild } from '../util/dom.js';
4
+ import { Text } from '../openxml/word/Run.js';
5
+ import { Break } from '../openxml/word/Break.js';
6
+ import { Drawing } from '../openxml/word/drawing/Drawing.js';
7
+ import { renderDrawing } from './renderDrawing.js';
8
+ import { setElementStyle } from './setElementStyle.js';
9
+ import { Tab } from '../openxml/word/Tab.js';
10
+ import { renderTab } from './renderTab.js';
11
+ import { renderPict } from './renderPict.js';
12
+ import { Pict } from '../openxml/word/Pict.js';
13
+ import { Ruby } from '../openxml/word/Ruby.js';
14
+ import { renderRuby } from './renderRuby.js';
15
+ import { InstrText } from '../openxml/word/InstrText.js';
16
+ import { renderInstrText } from './renderInstrText.js';
17
+ import { Sym } from '../openxml/word/Sym.js';
18
+ import { renderSym } from './renderSym.js';
19
+ import { cjkspace } from '../util/autoSpace.js';
20
+
21
+ /**
22
+ * run 相关的 http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Run_1.html
23
+ */
24
+ var VARIABLE_CLASS_NAME = 'variable';
25
+ /**
26
+ * 对文本进行替换
27
+ */
28
+ function renderText(span, word, text, paragraph) {
29
+ var _a;
30
+ // 简单过滤一下提升性能
31
+ if (text.indexOf('{{') === -1) {
32
+ if ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.properties) === null || _a === void 0 ? void 0 : _a.autoSpace) {
33
+ span.textContent = cjkspace(text.split(''));
34
+ }
35
+ else {
36
+ span.textContent = text;
37
+ }
38
+ }
39
+ else {
40
+ span.dataset.originText = text;
41
+ // 加个标识,后续可以通过它来查找哪些变量需要替换,这样就不用重新渲染整个文档了
42
+ span.classList.add(VARIABLE_CLASS_NAME);
43
+ span.textContent = word.replaceText(text);
44
+ }
45
+ }
46
+ /**
47
+ * 更新文档里的所有变量
48
+ */
49
+ function updateVariableText(word) {
50
+ var spans = word.rootElement.querySelectorAll(".".concat(VARIABLE_CLASS_NAME));
51
+ for (var i = 0; i < spans.length; i++) {
52
+ var span = spans[i];
53
+ var text = span.dataset.originText || '';
54
+ span.textContent = word.replaceText(text);
55
+ }
56
+ }
57
+ /**
58
+ * 渲染 run 节点
59
+ */
60
+ function renderRun(word, run, paragraph) {
61
+ var e_1, _a;
62
+ var span = createElement('span');
63
+ word.addClass(span, 'r');
64
+ setElementStyle(word, span, run.properties);
65
+ if (run.children.length === 1 && run.children[0] instanceof Text) {
66
+ var text = run.children[0];
67
+ renderText(span, word, text.text, paragraph);
68
+ }
69
+ else {
70
+ try {
71
+ for (var _b = __values(run.children), _c = _b.next(); !_c.done; _c = _b.next()) {
72
+ var child = _c.value;
73
+ if (child instanceof Text) {
74
+ var newSpan = createElement('span');
75
+ renderText(span, word, child.text, paragraph);
76
+ appendChild(span, newSpan);
77
+ }
78
+ else if (child instanceof Break) {
79
+ var br = renderBr(child);
80
+ appendChild(span, br);
81
+ }
82
+ else if (child instanceof Drawing) {
83
+ appendChild(span, renderDrawing(word, child));
84
+ }
85
+ else if (child instanceof Tab) {
86
+ appendChild(span, renderTab(word, child));
87
+ }
88
+ else if (child instanceof Pict) {
89
+ appendChild(span, renderPict(word, child));
90
+ }
91
+ else if (child instanceof Ruby) {
92
+ appendChild(span, renderRuby(word, child));
93
+ }
94
+ else if (child instanceof InstrText) {
95
+ appendChild(span, renderInstrText(word, child));
96
+ }
97
+ else if (child instanceof Sym) {
98
+ appendChild(span, renderSym(word, child));
99
+ }
100
+ else {
101
+ console.warn('unknown child', child);
102
+ }
103
+ }
104
+ }
105
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
106
+ finally {
107
+ try {
108
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
109
+ }
110
+ finally { if (e_1) throw e_1.error; }
111
+ }
112
+ }
113
+ return span;
114
+ }
115
+
116
+ export { renderRun as default, updateVariableText };
@@ -0,0 +1,6 @@
1
+ import { Section } from '../openxml/word/Section';
2
+ import Word from '../Word';
3
+ /**
4
+ * 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
5
+ */
6
+ export declare function renderSection(word: Word, section: Section): HTMLElement;
@@ -0,0 +1,36 @@
1
+ import { createElement } from '../util/dom.js';
2
+
3
+ /**
4
+ * 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
5
+ */
6
+ function renderSection(word, section) {
7
+ var sectionEl = createElement('section');
8
+ // 用于后续绝对定位
9
+ sectionEl.style.position = 'relative';
10
+ var props = section.properties;
11
+ var pageSize = props.pageSize;
12
+ if (pageSize) {
13
+ if (!word.renderOptions.ignoreWidth) {
14
+ sectionEl.style.width = pageSize.width;
15
+ }
16
+ if (!word.renderOptions.ignoreHeight) {
17
+ sectionEl.style.height = pageSize.height;
18
+ }
19
+ }
20
+ // 强制控制 padding
21
+ if (word.renderOptions.padding) {
22
+ sectionEl.style.padding = word.renderOptions.padding;
23
+ }
24
+ else {
25
+ var pageMargin = props.pageMargin;
26
+ if (pageMargin) {
27
+ sectionEl.style.paddingLeft = pageMargin.left || '0';
28
+ sectionEl.style.paddingRight = pageMargin.right || '0';
29
+ sectionEl.style.paddingTop = pageMargin.top || '0';
30
+ sectionEl.style.paddingBottom = pageMargin.bottom || '0';
31
+ }
32
+ }
33
+ return sectionEl;
34
+ }
35
+
36
+ export { renderSection };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 渲染内置样式及自定义样式
3
+ */
4
+ import { TblStylePrStyle } from '../openxml/Style';
5
+ import Word from '../Word';
6
+ /**
7
+ * 生成表格级别样式
8
+ */
9
+ export declare function generateTableStyle(classPrefix: string, styleDisplayId: string, style: TblStylePrStyle): string;
10
+ /**
11
+ * 渲染所有样式
12
+ */
13
+ export declare function renderStyle(word: Word): HTMLStyleElement;
@@ -0,0 +1,194 @@
1
+ import { __values } from '../node_modules/tslib/tslib.es6.js';
2
+ import { ST_TblStyleOverrideType } from '../openxml/Types.js';
3
+ import { styleToText, createElement } from '../util/dom.js';
4
+
5
+ /**
6
+ * 渲染内置样式及自定义样式
7
+ */
8
+ /**
9
+ * 文档基础默认样式
10
+ */
11
+ function generateDefaultStyle(word) {
12
+ var styles = word.styles;
13
+ var defaultStyle = styles.defaultStyle;
14
+ var defaultPStyle = '';
15
+ if (defaultStyle === null || defaultStyle === void 0 ? void 0 : defaultStyle.pPr) {
16
+ defaultPStyle = styleToText(defaultStyle.pPr.cssStyle);
17
+ }
18
+ var defaultRStyle = '';
19
+ if (defaultStyle === null || defaultStyle === void 0 ? void 0 : defaultStyle.rPr) {
20
+ defaultRStyle = styleToText(defaultStyle.rPr.cssStyle);
21
+ }
22
+ var classPrefix = word.getClassPrefix();
23
+ return "\n .".concat(word.wrapClassName, " {\n\n }\n\n .").concat(word.wrapClassName, " > article > section {\n background: white;\n }\n\n /** docDefaults **/\n\n .").concat(classPrefix, " p {\n margin: 0;\n padding: 0;\n }\n\n .").concat(classPrefix, " table {\n border-spacing: 0;\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-p {\n ").concat(defaultPStyle, "\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-r {\n white-space: pre-wrap;\n overflow-wrap: break-word;\n ").concat(defaultRStyle, "\n }\n ");
24
+ }
25
+ /**
26
+ * 生成表格级别样式
27
+ */
28
+ function generateTableStyle(classPrefix, styleDisplayId, style) {
29
+ var tblStyleText = '';
30
+ var tblPr = style.tblPr;
31
+ var tcPr = style.tcPr;
32
+ if (tblPr) {
33
+ var tblStyle = styleToText(tblPr.cssStyle);
34
+ var tblTcStyle = styleToText(tblPr.tcCSSStyle);
35
+ tblStyleText += "\n .".concat(classPrefix, " .").concat(styleDisplayId, " {\n border-collapse: collapse;\n ").concat(tblStyle, "\n }\n\n .").concat(classPrefix, " .").concat(styleDisplayId, " > tbody > tr > td {\n ").concat(tblTcStyle, "\n }\n ");
36
+ if (tblPr.insideBorder) {
37
+ var insideBorder = tblPr.insideBorder;
38
+ if (insideBorder.H) {
39
+ tblStyleText += "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > tbody > tr > td {\n border-top: ").concat(insideBorder.H, ";\n }");
40
+ }
41
+ if (insideBorder.V) {
42
+ tblStyleText += "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > tbody > tr > td {\n border-left: ").concat(insideBorder.V, ";\n }");
43
+ }
44
+ }
45
+ }
46
+ if (tcPr) {
47
+ var tcStyle = styleToText(tcPr.cssStyle);
48
+ tblStyleText += "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > tbody > tr > td {\n ").concat(tcStyle, "\n }\n ");
49
+ }
50
+ return tblStyleText;
51
+ }
52
+ // 用于生成表格 override 相关的样式,用于行或列
53
+ function genTblOverrideStyle(prefix, overrideType, tblStylePrStyle) {
54
+ var _a, _b, _c, _d, _e, _f;
55
+ var styleText = '';
56
+ var trStyle = styleToText((_a = tblStylePrStyle.trPr) === null || _a === void 0 ? void 0 : _a.cssStyle);
57
+ var enableType = '';
58
+ // 在 tblLook 里可以通过这些属性来控制是否启用
59
+ switch (overrideType) {
60
+ case ST_TblStyleOverrideType.firstCol:
61
+ enableType = 'enable-firstColumn';
62
+ break;
63
+ case ST_TblStyleOverrideType.lastCol:
64
+ enableType = 'enable-lastColumn';
65
+ break;
66
+ case ST_TblStyleOverrideType.firstRow:
67
+ enableType = 'enable-firstRow';
68
+ break;
69
+ case ST_TblStyleOverrideType.lastRow:
70
+ enableType = 'enable-lastRow';
71
+ break;
72
+ case ST_TblStyleOverrideType.band1Horz:
73
+ case ST_TblStyleOverrideType.band2Horz:
74
+ enableType = 'enable-hBand';
75
+ break;
76
+ case ST_TblStyleOverrideType.band1Vert:
77
+ case ST_TblStyleOverrideType.band2Vert:
78
+ enableType = 'enable-vBand';
79
+ break;
80
+ }
81
+ if (trStyle) {
82
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr.").concat(overrideType, "{\n ").concat(trStyle, "\n }\n ");
83
+ }
84
+ var tcStyle = styleToText((_b = tblStylePrStyle.tcPr) === null || _b === void 0 ? void 0 : _b.cssStyle);
85
+ if (tcStyle) {
86
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n ").concat(tcStyle, "\n }\n ");
87
+ if ((_c = tblStylePrStyle.tcPr) === null || _c === void 0 ? void 0 : _c.insideBorder) {
88
+ var insideBorder = (_d = tblStylePrStyle.tcPr) === null || _d === void 0 ? void 0 : _d.insideBorder;
89
+ if (insideBorder.H) {
90
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-top: ").concat(insideBorder.H, ";\n }");
91
+ }
92
+ if (insideBorder.V) {
93
+ // 这个主要是为了应对 GridTable5Dark-Accent5 里 firstRow 的情况,它其实有 right 设置,也得去掉
94
+ if (insideBorder.V === 'none') {
95
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: none;\n border-right: none;\n }");
96
+ }
97
+ else {
98
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: ").concat(insideBorder.V, ";\n }");
99
+ }
100
+ }
101
+ }
102
+ }
103
+ var pStyle = styleToText((_e = tblStylePrStyle.pPr) === null || _e === void 0 ? void 0 : _e.cssStyle);
104
+ if (pStyle) {
105
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .p {\n ").concat(pStyle, "\n }\n ");
106
+ }
107
+ var rStyle = styleToText((_f = tblStylePrStyle.rPr) === null || _f === void 0 ? void 0 : _f.cssStyle);
108
+ if (rStyle) {
109
+ styleText += "\n ".concat(prefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .p > .r {\n ").concat(rStyle, "\n }\n ");
110
+ }
111
+ return styleText;
112
+ }
113
+ // 表格覆盖样式的顺序,权重高的放后面
114
+ var overrideTypeOrder = new Set([
115
+ ST_TblStyleOverrideType.wholeTable,
116
+ ST_TblStyleOverrideType.band1Horz,
117
+ ST_TblStyleOverrideType.band2Horz,
118
+ ST_TblStyleOverrideType.band1Vert,
119
+ ST_TblStyleOverrideType.band2Vert,
120
+ ST_TblStyleOverrideType.firstCol,
121
+ ST_TblStyleOverrideType.firstRow,
122
+ ST_TblStyleOverrideType.lastCol,
123
+ ST_TblStyleOverrideType.lastRow,
124
+ ST_TblStyleOverrideType.neCell,
125
+ ST_TblStyleOverrideType.nwCell,
126
+ ST_TblStyleOverrideType.seCell,
127
+ ST_TblStyleOverrideType.swCell
128
+ ]);
129
+ // 生成表格覆盖样式
130
+ function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
131
+ var e_1, _a;
132
+ if (!tblStylePr) {
133
+ return '';
134
+ }
135
+ var tblStylePrText = '';
136
+ var stylePrefix = ".".concat(classPrefix, " .").concat(styleDisplayId);
137
+ try {
138
+ for (var overrideTypeOrder_1 = __values(overrideTypeOrder), overrideTypeOrder_1_1 = overrideTypeOrder_1.next(); !overrideTypeOrder_1_1.done; overrideTypeOrder_1_1 = overrideTypeOrder_1.next()) {
139
+ var overrideType = overrideTypeOrder_1_1.value;
140
+ if (overrideType in tblStylePr) {
141
+ var overrideStylePr = tblStylePr[overrideType];
142
+ tblStylePrText += genTblOverrideStyle(stylePrefix, overrideType, overrideStylePr);
143
+ }
144
+ }
145
+ }
146
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
147
+ finally {
148
+ try {
149
+ if (overrideTypeOrder_1_1 && !overrideTypeOrder_1_1.done && (_a = overrideTypeOrder_1.return)) _a.call(overrideTypeOrder_1);
150
+ }
151
+ finally { if (e_1) throw e_1.error; }
152
+ }
153
+ return tblStylePrText;
154
+ }
155
+ /**
156
+ * 生成样式类
157
+ */
158
+ function generateStyle(word) {
159
+ var styles = word.styles;
160
+ var styleMap = styles.styleMap;
161
+ var classPrefix = word.getClassPrefix();
162
+ var styleResult = '';
163
+ for (var styleId in styleMap) {
164
+ var styleDisplayId = word.getStyleIdDisplayName(styleId);
165
+ var styleData = styleMap[styleId];
166
+ var pPr = styleData.pPr;
167
+ var pStyleText = '';
168
+ if (pPr) {
169
+ var pStyle = styleToText(pPr.cssStyle);
170
+ pStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " {\n ").concat(pStyle, "\n }\n ");
171
+ }
172
+ var rStyleText = '';
173
+ if (styleData.rPr) {
174
+ var rStyle = styleToText(styleData.rPr.cssStyle);
175
+ rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .r {\n ").concat(rStyle, "\n }\n ");
176
+ }
177
+ var tblStyleText = generateTableStyle(classPrefix, styleDisplayId, styleData);
178
+ var tblStylePr = genOverrideTblStylePr(classPrefix, styleDisplayId, styleData.tblStylePr);
179
+ styleResult += "\n ".concat(pStyleText, "\n ").concat(rStyleText, "\n ").concat(tblStyleText, "\n ").concat(tblStylePr, "\n ");
180
+ }
181
+ return styleResult;
182
+ }
183
+ /**
184
+ * 渲染所有样式
185
+ */
186
+ function renderStyle(word) {
187
+ var style = createElement('style');
188
+ var docDefaults = generateDefaultStyle(word);
189
+ var styleText = generateStyle(word);
190
+ style.innerHTML = "\n ".concat(docDefaults, "\n\n ").concat(styleText, "\n ");
191
+ return style;
192
+ }
193
+
194
+ export { generateTableStyle, renderStyle };
@@ -0,0 +1,3 @@
1
+ import { Sym } from '../openxml/word/Sym';
2
+ import Word from '../Word';
3
+ export declare function renderSym(word: Word, sym: Sym): HTMLElement;
@@ -0,0 +1,10 @@
1
+ import { createElement } from '../util/dom.js';
2
+
3
+ function renderSym(word, sym) {
4
+ var span = createElement('span');
5
+ span.style.fontFamily = sym.font;
6
+ span.innerHTML = "&#x".concat(sym.char, ";");
7
+ return span;
8
+ }
9
+
10
+ export { renderSym };
@@ -0,0 +1,7 @@
1
+ import { Tab } from '../openxml/word/Tab';
2
+ import Word from '../Word';
3
+ /**
4
+ * 渲染 tab
5
+ * http://officeopenxml.com/WPtab.php
6
+ */
7
+ export declare function renderTab(word: Word, tab: Tab): HTMLElement;
@@ -0,0 +1,19 @@
1
+ import { ST_TabTlc } from '../openxml/Types.js';
2
+ import { createElement } from '../util/dom.js';
3
+
4
+ /**
5
+ * 渲染 tab
6
+ * http://officeopenxml.com/WPtab.php
7
+ */
8
+ function renderTab(word, tab) {
9
+ var tabElement = createElement('span');
10
+ tabElement.style.display = 'inline-block';
11
+ tabElement.style.width = tab.pos;
12
+ tabElement.innerHTML = '&nbsp;';
13
+ if (tab.leader === ST_TabTlc.dot) {
14
+ tabElement.style.borderBottom = '1px dotted';
15
+ }
16
+ return tabElement;
17
+ }
18
+
19
+ export { renderTab };
@@ -0,0 +1,6 @@
1
+ import { Table } from '../openxml/word/Table';
2
+ import Word from '../Word';
3
+ /**
4
+ * 渲染表格
5
+ */
6
+ export default function renderTable(word: Word, table: Table): HTMLTableElement;
@@ -0,0 +1,186 @@
1
+ import { __values } from '../node_modules/tslib/tslib.es6.js';
2
+ import { ST_TblStyleOverrideType } from '../openxml/Types.js';
3
+ import { Paragraph } from '../openxml/word/Paragraph.js';
4
+ import { Table } from '../openxml/word/Table.js';
5
+ import { addClassName, setStyle, appendChild } from '../util/dom.js';
6
+ import renderParagraph from './renderParagraph.js';
7
+ import { generateTableStyle } from './renderStyle.js';
8
+ import { setElementStyle } from './setElementStyle.js';
9
+
10
+ /**
11
+ * 设置 td 的类,用于支持各种表格条件样式
12
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ST_TblStyleOverrideType.html
13
+ */
14
+ function setTdClassName(rowIndex, colIndex, rowLength, colLength, element, rowBandSize, colBandSize) {
15
+ // 左上角
16
+ if (rowIndex === 0 && colIndex === 0) {
17
+ element.classList.add(ST_TblStyleOverrideType.nwCell);
18
+ }
19
+ // 右上角
20
+ if (rowIndex === 0 && colIndex === colLength - 1) {
21
+ element.classList.add(ST_TblStyleOverrideType.neCell);
22
+ }
23
+ // 左下角
24
+ if (rowIndex === rowLength - 1 && colIndex === 0) {
25
+ element.classList.add(ST_TblStyleOverrideType.swCell);
26
+ }
27
+ // 右下角
28
+ if (rowIndex === rowLength - 1 && colIndex === colLength - 1) {
29
+ element.classList.add(ST_TblStyleOverrideType.seCell);
30
+ }
31
+ // 第一行
32
+ if (rowIndex === 0) {
33
+ element.classList.add(ST_TblStyleOverrideType.firstRow);
34
+ }
35
+ // 最后一行
36
+ if (rowIndex === rowLength - 1) {
37
+ element.classList.add(ST_TblStyleOverrideType.lastRow);
38
+ }
39
+ // 第一列
40
+ if (colIndex === 0) {
41
+ element.classList.add(ST_TblStyleOverrideType.firstCol);
42
+ }
43
+ // 最后一列
44
+ if (colIndex === colLength - 1) {
45
+ element.classList.add(ST_TblStyleOverrideType.lastCol);
46
+ }
47
+ // 奇数行
48
+ if (isOdd(rowIndex + 1)) {
49
+ element.classList.add(ST_TblStyleOverrideType.band1Horz);
50
+ }
51
+ // 偶数行
52
+ if (!isOdd(rowIndex + 1)) {
53
+ element.classList.add(ST_TblStyleOverrideType.band2Horz);
54
+ }
55
+ // 奇数列
56
+ if (isOdd(colIndex + 1)) {
57
+ element.classList.add(ST_TblStyleOverrideType.band1Vert);
58
+ }
59
+ // 偶数列
60
+ if (!isOdd(colIndex + 1)) {
61
+ element.classList.add(ST_TblStyleOverrideType.band2Vert);
62
+ }
63
+ }
64
+ /**
65
+ * 根据倍数判断是否是奇数,目前看来似乎 word 编辑器也没提供 size 设置
66
+ * http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblStyleRowBandSize.html
67
+ */
68
+ function isOdd(num, size) {
69
+ return !(num % 2);
70
+ }
71
+ /**
72
+ * 渲染表格
73
+ */
74
+ function renderTable(word, table) {
75
+ var e_1, _a, e_2, _b, e_3, _c;
76
+ var tableEl = document.createElement('table');
77
+ var properties = table.properties;
78
+ if (properties.tblCaption) {
79
+ var caption = document.createElement('caption');
80
+ caption.textContent = properties.tblCaption;
81
+ tableEl.appendChild(caption);
82
+ }
83
+ if (properties.tblLook) {
84
+ for (var key in properties.tblLook) {
85
+ // 这两个属性是反过来的
86
+ if (key === 'noHBand') {
87
+ if (!properties.tblLook[key]) {
88
+ addClassName(tableEl, 'enable-hBand');
89
+ }
90
+ }
91
+ else if (key === 'noVBand') {
92
+ if (!properties.tblLook[key]) {
93
+ addClassName(tableEl, 'enable-vBand');
94
+ }
95
+ }
96
+ else if (properties.tblLook[key]) {
97
+ addClassName(tableEl, 'enable-' + key);
98
+ }
99
+ }
100
+ }
101
+ setElementStyle(word, tableEl, properties);
102
+ var customClass = word.genClassName();
103
+ tableEl.classList.add(customClass);
104
+ word.appendStyle(generateTableStyle(word.getClassPrefix(), customClass, { tblPr: properties }));
105
+ // 这里或许应该生成 classname 来支持 tcCSSStyle
106
+ var tbody = document.createElement('tbody');
107
+ tableEl.appendChild(tbody);
108
+ var rowIndex = 0;
109
+ try {
110
+ for (var _d = __values(table.trs), _e = _d.next(); !_e.done; _e = _d.next()) {
111
+ var tr = _e.value;
112
+ var trEl = document.createElement('tr');
113
+ tbody.appendChild(trEl);
114
+ var colIndex = 0;
115
+ try {
116
+ for (var _f = (e_2 = void 0, __values(tr.tcs)), _g = _f.next(); !_g.done; _g = _f.next()) {
117
+ var tc = _g.value;
118
+ var tdEl = document.createElement('td');
119
+ trEl.appendChild(tdEl);
120
+ setTdClassName(rowIndex, colIndex, table.trs.length, tr.tcs.length, tdEl, properties.rowBandSize, properties.colBandSize);
121
+ // tr 也能设置 tc style,所以先应用这个
122
+ if (tr.properties.tcStyle) {
123
+ setStyle(tdEl, tr.properties.tcStyle);
124
+ }
125
+ var tcPr = tc.properties;
126
+ setElementStyle(word, tdEl, tcPr);
127
+ if (tcPr.gridSpan) {
128
+ tdEl.colSpan = tcPr.gridSpan;
129
+ }
130
+ if (tcPr.rowSpan) {
131
+ tdEl.rowSpan = tcPr.rowSpan;
132
+ }
133
+ // 如果已经有表格的话,就不再渲染空段落了,避免底部多个空行
134
+ var hasTable = false;
135
+ try {
136
+ for (var _h = (e_3 = void 0, __values(tc.children)), _j = _h.next(); !_j.done; _j = _h.next()) {
137
+ var tcChild = _j.value;
138
+ if (tcChild instanceof Paragraph) {
139
+ var p = renderParagraph(word, tcChild, !hasTable);
140
+ appendChild(tdEl, p);
141
+ }
142
+ else if (tcChild instanceof Table) {
143
+ hasTable = true;
144
+ appendChild(tdEl, renderTable(word, tcChild));
145
+ }
146
+ else {
147
+ console.warn('unknown child type: ' + tcChild);
148
+ }
149
+ }
150
+ }
151
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
152
+ finally {
153
+ try {
154
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
155
+ }
156
+ finally { if (e_3) throw e_3.error; }
157
+ }
158
+ if (tcPr.rowSpan) {
159
+ colIndex += tcPr.rowSpan;
160
+ }
161
+ else {
162
+ colIndex++;
163
+ }
164
+ }
165
+ }
166
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
167
+ finally {
168
+ try {
169
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
170
+ }
171
+ finally { if (e_2) throw e_2.error; }
172
+ }
173
+ rowIndex++;
174
+ }
175
+ }
176
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
177
+ finally {
178
+ try {
179
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
180
+ }
181
+ finally { if (e_1) throw e_1.error; }
182
+ }
183
+ return tableEl;
184
+ }
185
+
186
+ export { renderTable as default };
@@ -0,0 +1,6 @@
1
+ import { Properties } from '../openxml/word/properties/Properties';
2
+ import Word from '../Word';
3
+ /**
4
+ * 设置元素样式,因为好几个地方用所以统一一下
5
+ */
6
+ export declare function setElementStyle(word: Word, element: HTMLElement, properties: Properties | undefined): void;
@@ -0,0 +1,21 @@
1
+ import { setStyle, addClassNames } from '../util/dom.js';
2
+
3
+ /**
4
+ * 设置元素样式,因为好几个地方用所以统一一下
5
+ */
6
+ function setElementStyle(word, element, properties) {
7
+ if (!properties) {
8
+ return;
9
+ }
10
+ if (properties.cssStyle) {
11
+ setStyle(element, properties.cssStyle);
12
+ }
13
+ if (properties.pStyle) {
14
+ addClassNames(element, word.getStyleClassName(properties.pStyle));
15
+ }
16
+ if (properties.rStyle) {
17
+ addClassNames(element, word.getStyleClassName(properties.rStyle));
18
+ }
19
+ }
20
+
21
+ export { setElementStyle };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 中英文间自动加空格,基于下面代码改的,去掉了 lodash 依赖
3
+ * https://gist.github.com/wyl8899/e0f31068681023480e20c34f6b19a275
4
+ */
5
+ export declare const cjkspace: (strings: string[]) => string;