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.
- package/README.md +23 -0
- package/esm/OpenXML.d.ts +21 -0
- package/esm/OpenXML.js +60 -0
- package/esm/Word.d.ts +208 -0
- package/esm/Word.js +370 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/node_modules/tslib/tslib.es6.js +120 -0
- package/esm/openxml/ContentType.d.ts +12 -0
- package/esm/openxml/ContentType.js +15 -0
- package/esm/openxml/Style.d.ts +41 -0
- package/esm/openxml/Style.js +156 -0
- package/esm/openxml/Theme.d.ts +26 -0
- package/esm/openxml/Theme.js +69 -0
- package/esm/openxml/Types.d.ts +2512 -0
- package/esm/openxml/Types.js +1003 -0
- package/esm/openxml/word/Background.d.ts +11 -0
- package/esm/openxml/word/Body.d.ts +18 -0
- package/esm/openxml/word/Body.js +67 -0
- package/esm/openxml/word/Bookmark.d.ts +6 -0
- package/esm/openxml/word/Bookmark.js +18 -0
- package/esm/openxml/word/Border.d.ts +10 -0
- package/esm/openxml/word/Break.d.ts +13 -0
- package/esm/openxml/word/Break.js +19 -0
- package/esm/openxml/word/CustomXml.d.ts +8 -0
- package/esm/openxml/word/FldSimple.d.ts +7 -0
- package/esm/openxml/word/FldSimple.js +15 -0
- package/esm/openxml/word/FrameProperties.d.ts +18 -0
- package/esm/openxml/word/Hyperlink.d.ts +13 -0
- package/esm/openxml/word/Hyperlink.js +53 -0
- package/esm/openxml/word/Indent.d.ts +8 -0
- package/esm/openxml/word/InlineText.d.ts +14 -0
- package/esm/openxml/word/InlineText.js +62 -0
- package/esm/openxml/word/InstrText.d.ts +4 -0
- package/esm/openxml/word/InstrText.js +8 -0
- package/esm/openxml/word/Paragraph.d.ts +34 -0
- package/esm/openxml/word/Paragraph.js +133 -0
- package/esm/openxml/word/Pict.d.ts +6 -0
- package/esm/openxml/word/Pict.js +19 -0
- package/esm/openxml/word/Ruby.d.ts +20 -0
- package/esm/openxml/word/Ruby.js +87 -0
- package/esm/openxml/word/Run.d.ts +31 -0
- package/esm/openxml/word/Run.js +98 -0
- package/esm/openxml/word/Section.d.ts +38 -0
- package/esm/openxml/word/Section.js +59 -0
- package/esm/openxml/word/Shading.d.ts +9 -0
- package/esm/openxml/word/SmartTag.d.ts +8 -0
- package/esm/openxml/word/SmartTag.js +18 -0
- package/esm/openxml/word/Spacing.d.ts +9 -0
- package/esm/openxml/word/Sym.d.ts +8 -0
- package/esm/openxml/word/Sym.js +16 -0
- package/esm/openxml/word/Tab.d.ts +8 -0
- package/esm/openxml/word/Tab.js +17 -0
- package/esm/openxml/word/Table.d.ts +49 -0
- package/esm/openxml/word/Table.js +248 -0
- package/esm/openxml/word/VerticalAlign.d.ts +6 -0
- package/esm/openxml/word/WDocument.d.ts +13 -0
- package/esm/openxml/word/WDocument.js +58 -0
- package/esm/openxml/word/drawing/Blip.d.ts +6 -0
- package/esm/openxml/word/drawing/Blip.js +17 -0
- package/esm/openxml/word/drawing/BlipFill.d.ts +9 -0
- package/esm/openxml/word/drawing/BlipFill.js +20 -0
- package/esm/openxml/word/drawing/Drawing.d.ts +6 -0
- package/esm/openxml/word/drawing/Drawing.js +15 -0
- package/esm/openxml/word/drawing/Pic.d.ts +8 -0
- package/esm/openxml/word/drawing/Pic.js +16 -0
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +9 -0
- package/esm/openxml/word/drawing/ShapeProperties.js +20 -0
- package/esm/openxml/word/drawing/Transform.d.ts +17 -0
- package/esm/openxml/word/drawing/Transform.js +30 -0
- package/esm/openxml/word/numbering/AbstractNum.d.ts +13 -0
- package/esm/openxml/word/numbering/AbstractNum.js +42 -0
- package/esm/openxml/word/numbering/Lvl.d.ts +16 -0
- package/esm/openxml/word/numbering/Lvl.js +62 -0
- package/esm/openxml/word/numbering/Num.d.ts +10 -0
- package/esm/openxml/word/numbering/Num.js +46 -0
- package/esm/openxml/word/numbering/NumberProperties.d.ts +6 -0
- package/esm/openxml/word/numbering/NumberProperties.js +21 -0
- package/esm/openxml/word/numbering/Numbering.d.ts +9 -0
- package/esm/openxml/word/numbering/Numbering.js +50 -0
- package/esm/openxml/word/properties/Properties.d.ts +12 -0
- package/esm/openxml/word/table/Tc.d.ts +46 -0
- package/esm/openxml/word/table/Tc.js +234 -0
- package/esm/openxml/word/table/Tr.d.ts +18 -0
- package/esm/openxml/word/table/Tr.js +106 -0
- package/esm/package/PackageParser.d.ts +26 -0
- package/esm/package/XMLPackageParser.d.ts +31 -0
- package/esm/package/ZipPackageParser.d.ts +29 -0
- package/esm/package/ZipPackageParser.js +70 -0
- package/esm/parse/jcToTextAlign.d.ts +5 -0
- package/esm/parse/jcToTextAlign.js +21 -0
- package/esm/parse/parseBorder.d.ts +13 -0
- package/esm/parse/parseBorder.js +78 -0
- package/esm/parse/parseColor.d.ts +22 -0
- package/esm/parse/parseColor.js +131 -0
- package/esm/parse/parseFont.d.ts +7 -0
- package/esm/parse/parseFont.js +54 -0
- package/esm/parse/parseInd.d.ts +5 -0
- package/esm/parse/parseInd.js +27 -0
- package/esm/parse/parsePr.d.ts +8 -0
- package/esm/parse/parsePr.js +325 -0
- package/esm/parse/parseRelationship.d.ts +12 -0
- package/esm/parse/parseRelationship.js +40 -0
- package/esm/parse/parseSize.d.ts +27 -0
- package/esm/parse/parseSize.js +38 -0
- package/esm/parse/parseSpacing.d.ts +7 -0
- package/esm/parse/parseSpacing.js +43 -0
- package/esm/parse/parseTextDirection.d.ts +2 -0
- package/esm/parse/parseTextDirection.js +25 -0
- package/esm/parse/parseTrHeight.d.ts +2 -0
- package/esm/parse/parseTrHeight.js +17 -0
- package/esm/render/renderBody.d.ts +6 -0
- package/esm/render/renderBody.js +53 -0
- package/esm/render/renderBookmark.d.ts +6 -0
- package/esm/render/renderBookmark.js +17 -0
- package/esm/render/renderBr.d.ts +7 -0
- package/esm/render/renderBr.js +13 -0
- package/esm/render/renderDocument.d.ts +7 -0
- package/esm/render/renderDocument.js +14 -0
- package/esm/render/renderDrawing.d.ts +8 -0
- package/esm/render/renderDrawing.js +38 -0
- package/esm/render/renderHyperLink.d.ts +7 -0
- package/esm/render/renderHyperLink.js +41 -0
- package/esm/render/renderInlineText.d.ts +6 -0
- package/esm/render/renderInlineText.js +39 -0
- package/esm/render/renderInstrText.d.ts +8 -0
- package/esm/render/renderInstrText.js +40 -0
- package/esm/render/renderNumbering.d.ts +7 -0
- package/esm/render/renderNumbering.js +161 -0
- package/esm/render/renderParagraph.d.ts +7 -0
- package/esm/render/renderParagraph.js +78 -0
- package/esm/render/renderPict.d.ts +6 -0
- package/esm/render/renderPict.js +19 -0
- package/esm/render/renderRuby.d.ts +6 -0
- package/esm/render/renderRuby.js +53 -0
- package/esm/render/renderRun.d.ts +14 -0
- package/esm/render/renderRun.js +116 -0
- package/esm/render/renderSection.d.ts +6 -0
- package/esm/render/renderSection.js +36 -0
- package/esm/render/renderStyle.d.ts +13 -0
- package/esm/render/renderStyle.js +194 -0
- package/esm/render/renderSym.d.ts +3 -0
- package/esm/render/renderSym.js +10 -0
- package/esm/render/renderTab.d.ts +7 -0
- package/esm/render/renderTab.js +19 -0
- package/esm/render/renderTable.d.ts +6 -0
- package/esm/render/renderTable.js +186 -0
- package/esm/render/setElementStyle.d.ts +6 -0
- package/esm/render/setElementStyle.js +21 -0
- package/esm/util/autoSpace.d.ts +5 -0
- package/esm/util/autoSpace.js +33 -0
- package/esm/util/blob.d.ts +9 -0
- package/esm/util/blob.js +39 -0
- package/esm/util/dom.d.ts +36 -0
- package/esm/util/dom.js +63 -0
- package/esm/util/mergeRun.d.ts +17 -0
- package/esm/util/mergeRun.js +134 -0
- package/esm/util/xml.d.ts +8 -0
- package/esm/util/xml.js +12 -0
- package/lib/OpenXML.d.ts +21 -0
- package/lib/OpenXML.js +69 -0
- package/lib/Word.d.ts +208 -0
- package/lib/Word.js +374 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +10 -0
- package/lib/node_modules/tslib/tslib.es6.js +129 -0
- package/lib/openxml/ContentType.d.ts +12 -0
- package/lib/openxml/ContentType.js +19 -0
- package/lib/openxml/Style.d.ts +41 -0
- package/lib/openxml/Style.js +160 -0
- package/lib/openxml/Theme.d.ts +26 -0
- package/lib/openxml/Theme.js +73 -0
- package/lib/openxml/Types.d.ts +2512 -0
- package/lib/openxml/Types.js +1005 -0
- package/lib/openxml/word/Background.d.ts +11 -0
- package/lib/openxml/word/Body.d.ts +18 -0
- package/lib/openxml/word/Body.js +71 -0
- package/lib/openxml/word/Bookmark.d.ts +6 -0
- package/lib/openxml/word/Bookmark.js +22 -0
- package/lib/openxml/word/Border.d.ts +10 -0
- package/lib/openxml/word/Break.d.ts +13 -0
- package/lib/openxml/word/Break.js +23 -0
- package/lib/openxml/word/CustomXml.d.ts +8 -0
- package/lib/openxml/word/FldSimple.d.ts +7 -0
- package/lib/openxml/word/FldSimple.js +19 -0
- package/lib/openxml/word/FrameProperties.d.ts +18 -0
- package/lib/openxml/word/Hyperlink.d.ts +13 -0
- package/lib/openxml/word/Hyperlink.js +57 -0
- package/lib/openxml/word/Indent.d.ts +8 -0
- package/lib/openxml/word/InlineText.d.ts +14 -0
- package/lib/openxml/word/InlineText.js +66 -0
- package/lib/openxml/word/InstrText.d.ts +4 -0
- package/lib/openxml/word/InstrText.js +12 -0
- package/lib/openxml/word/Paragraph.d.ts +34 -0
- package/lib/openxml/word/Paragraph.js +137 -0
- package/lib/openxml/word/Pict.d.ts +6 -0
- package/lib/openxml/word/Pict.js +23 -0
- package/lib/openxml/word/Ruby.d.ts +20 -0
- package/lib/openxml/word/Ruby.js +91 -0
- package/lib/openxml/word/Run.d.ts +31 -0
- package/lib/openxml/word/Run.js +103 -0
- package/lib/openxml/word/Section.d.ts +38 -0
- package/lib/openxml/word/Section.js +63 -0
- package/lib/openxml/word/Shading.d.ts +9 -0
- package/lib/openxml/word/SmartTag.d.ts +8 -0
- package/lib/openxml/word/SmartTag.js +22 -0
- package/lib/openxml/word/Spacing.d.ts +9 -0
- package/lib/openxml/word/Sym.d.ts +8 -0
- package/lib/openxml/word/Sym.js +20 -0
- package/lib/openxml/word/Tab.d.ts +8 -0
- package/lib/openxml/word/Tab.js +21 -0
- package/lib/openxml/word/Table.d.ts +49 -0
- package/lib/openxml/word/Table.js +252 -0
- package/lib/openxml/word/VerticalAlign.d.ts +6 -0
- package/lib/openxml/word/WDocument.d.ts +13 -0
- package/lib/openxml/word/WDocument.js +62 -0
- package/lib/openxml/word/drawing/Blip.d.ts +6 -0
- package/lib/openxml/word/drawing/Blip.js +21 -0
- package/lib/openxml/word/drawing/BlipFill.d.ts +9 -0
- package/lib/openxml/word/drawing/BlipFill.js +24 -0
- package/lib/openxml/word/drawing/Drawing.d.ts +6 -0
- package/lib/openxml/word/drawing/Drawing.js +19 -0
- package/lib/openxml/word/drawing/Pic.d.ts +8 -0
- package/lib/openxml/word/drawing/Pic.js +20 -0
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +9 -0
- package/lib/openxml/word/drawing/ShapeProperties.js +24 -0
- package/lib/openxml/word/drawing/Transform.d.ts +17 -0
- package/lib/openxml/word/drawing/Transform.js +34 -0
- package/lib/openxml/word/numbering/AbstractNum.d.ts +13 -0
- package/lib/openxml/word/numbering/AbstractNum.js +46 -0
- package/lib/openxml/word/numbering/Lvl.d.ts +16 -0
- package/lib/openxml/word/numbering/Lvl.js +66 -0
- package/lib/openxml/word/numbering/Num.d.ts +10 -0
- package/lib/openxml/word/numbering/Num.js +50 -0
- package/lib/openxml/word/numbering/NumberProperties.d.ts +6 -0
- package/lib/openxml/word/numbering/NumberProperties.js +25 -0
- package/lib/openxml/word/numbering/Numbering.d.ts +9 -0
- package/lib/openxml/word/numbering/Numbering.js +54 -0
- package/lib/openxml/word/properties/Properties.d.ts +12 -0
- package/lib/openxml/word/table/Tc.d.ts +46 -0
- package/lib/openxml/word/table/Tc.js +242 -0
- package/lib/openxml/word/table/Tr.d.ts +18 -0
- package/lib/openxml/word/table/Tr.js +110 -0
- package/lib/package/PackageParser.d.ts +26 -0
- package/lib/package/XMLPackageParser.d.ts +31 -0
- package/lib/package/ZipPackageParser.d.ts +29 -0
- package/lib/package/ZipPackageParser.js +74 -0
- package/lib/parse/jcToTextAlign.d.ts +5 -0
- package/lib/parse/jcToTextAlign.js +25 -0
- package/lib/parse/parseBorder.d.ts +13 -0
- package/lib/parse/parseBorder.js +83 -0
- package/lib/parse/parseColor.d.ts +22 -0
- package/lib/parse/parseColor.js +137 -0
- package/lib/parse/parseFont.d.ts +7 -0
- package/lib/parse/parseFont.js +58 -0
- package/lib/parse/parseInd.d.ts +5 -0
- package/lib/parse/parseInd.js +31 -0
- package/lib/parse/parsePr.d.ts +8 -0
- package/lib/parse/parsePr.js +329 -0
- package/lib/parse/parseRelationship.d.ts +12 -0
- package/lib/parse/parseRelationship.js +45 -0
- package/lib/parse/parseSize.d.ts +27 -0
- package/lib/parse/parseSize.js +44 -0
- package/lib/parse/parseSpacing.d.ts +7 -0
- package/lib/parse/parseSpacing.js +47 -0
- package/lib/parse/parseTextDirection.d.ts +2 -0
- package/lib/parse/parseTextDirection.js +29 -0
- package/lib/parse/parseTrHeight.d.ts +2 -0
- package/lib/parse/parseTrHeight.js +21 -0
- package/lib/render/renderBody.d.ts +6 -0
- package/lib/render/renderBody.js +57 -0
- package/lib/render/renderBookmark.d.ts +6 -0
- package/lib/render/renderBookmark.js +21 -0
- package/lib/render/renderBr.d.ts +7 -0
- package/lib/render/renderBr.js +17 -0
- package/lib/render/renderDocument.d.ts +7 -0
- package/lib/render/renderDocument.js +18 -0
- package/lib/render/renderDrawing.d.ts +8 -0
- package/lib/render/renderDrawing.js +42 -0
- package/lib/render/renderHyperLink.d.ts +7 -0
- package/lib/render/renderHyperLink.js +45 -0
- package/lib/render/renderInlineText.d.ts +6 -0
- package/lib/render/renderInlineText.js +43 -0
- package/lib/render/renderInstrText.d.ts +8 -0
- package/lib/render/renderInstrText.js +44 -0
- package/lib/render/renderNumbering.d.ts +7 -0
- package/lib/render/renderNumbering.js +165 -0
- package/lib/render/renderParagraph.d.ts +7 -0
- package/lib/render/renderParagraph.js +82 -0
- package/lib/render/renderPict.d.ts +6 -0
- package/lib/render/renderPict.js +23 -0
- package/lib/render/renderRuby.d.ts +6 -0
- package/lib/render/renderRuby.js +57 -0
- package/lib/render/renderRun.d.ts +14 -0
- package/lib/render/renderRun.js +121 -0
- package/lib/render/renderSection.d.ts +6 -0
- package/lib/render/renderSection.js +40 -0
- package/lib/render/renderStyle.d.ts +13 -0
- package/lib/render/renderStyle.js +199 -0
- package/lib/render/renderSym.d.ts +3 -0
- package/lib/render/renderSym.js +14 -0
- package/lib/render/renderTab.d.ts +7 -0
- package/lib/render/renderTab.js +23 -0
- package/lib/render/renderTable.d.ts +6 -0
- package/lib/render/renderTable.js +190 -0
- package/lib/render/setElementStyle.d.ts +6 -0
- package/lib/render/setElementStyle.js +25 -0
- package/lib/util/autoSpace.d.ts +5 -0
- package/lib/util/autoSpace.js +37 -0
- package/lib/util/blob.d.ts +9 -0
- package/lib/util/blob.js +44 -0
- package/lib/util/dom.d.ts +36 -0
- package/lib/util/dom.js +72 -0
- package/lib/util/mergeRun.d.ts +17 -0
- package/lib/util/mergeRun.js +140 -0
- package/lib/util/xml.d.ts +8 -0
- package/lib/util/xml.js +16 -0
- package/package.json +91 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { __values, __extends } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Run } from './Run.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 注音
|
|
6
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ruby.html
|
|
7
|
+
*/
|
|
8
|
+
var RubyBase = /** @class */ (function () {
|
|
9
|
+
function RubyBase() {
|
|
10
|
+
}
|
|
11
|
+
RubyBase.fromXML = function (word, element) {
|
|
12
|
+
var e_1, _a;
|
|
13
|
+
var rubyBase = new RubyBase();
|
|
14
|
+
rubyBase.children = [];
|
|
15
|
+
try {
|
|
16
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
17
|
+
var child = _c.value;
|
|
18
|
+
var tagName = child.tagName;
|
|
19
|
+
switch (tagName) {
|
|
20
|
+
case 'w:r':
|
|
21
|
+
var run = Run.fromXML(word, child);
|
|
22
|
+
if (run) {
|
|
23
|
+
rubyBase.children.push(run);
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
console.warn('parse Ruby: Unknown key', tagName, child);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e_1) throw e_1.error; }
|
|
37
|
+
}
|
|
38
|
+
return rubyBase;
|
|
39
|
+
};
|
|
40
|
+
return RubyBase;
|
|
41
|
+
}());
|
|
42
|
+
// 看起来应该是一样的
|
|
43
|
+
/** @class */ ((function (_super) {
|
|
44
|
+
__extends(RubyText, _super);
|
|
45
|
+
function RubyText() {
|
|
46
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
47
|
+
}
|
|
48
|
+
return RubyText;
|
|
49
|
+
})(RubyBase));
|
|
50
|
+
var Ruby = /** @class */ (function () {
|
|
51
|
+
function Ruby() {
|
|
52
|
+
}
|
|
53
|
+
Ruby.fromXML = function (word, element) {
|
|
54
|
+
var e_2, _a;
|
|
55
|
+
var ruby = new Ruby();
|
|
56
|
+
try {
|
|
57
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
58
|
+
var child = _c.value;
|
|
59
|
+
var tagName = child.tagName;
|
|
60
|
+
switch (tagName) {
|
|
61
|
+
case 'w:rubyPr':
|
|
62
|
+
// 应该是没法控制的
|
|
63
|
+
break;
|
|
64
|
+
case 'w:rt':
|
|
65
|
+
ruby.rt = RubyBase.fromXML(word, child);
|
|
66
|
+
break;
|
|
67
|
+
case 'w:rubyBase':
|
|
68
|
+
ruby.rubyBase = RubyBase.fromXML(word, child);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
console.warn('parse Ruby: Unknown key', tagName, child);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
76
|
+
finally {
|
|
77
|
+
try {
|
|
78
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
79
|
+
}
|
|
80
|
+
finally { if (e_2) throw e_2.error; }
|
|
81
|
+
}
|
|
82
|
+
return ruby;
|
|
83
|
+
};
|
|
84
|
+
return Ruby;
|
|
85
|
+
}());
|
|
86
|
+
|
|
87
|
+
export { 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,98 @@
|
|
|
1
|
+
import { __values } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { getVal } from '../../OpenXML.js';
|
|
3
|
+
import { parsePr } from '../../parse/parsePr.js';
|
|
4
|
+
import { Break } from './Break.js';
|
|
5
|
+
import { Drawing } from './drawing/Drawing.js';
|
|
6
|
+
import { InstrText } from './InstrText.js';
|
|
7
|
+
import { Pict } from './Pict.js';
|
|
8
|
+
import { Ruby } from './Ruby.js';
|
|
9
|
+
import { Sym } from './Sym.js';
|
|
10
|
+
import { Tab } from './Tab.js';
|
|
11
|
+
|
|
12
|
+
var Text = /** @class */ (function () {
|
|
13
|
+
function Text(text) {
|
|
14
|
+
this.preserveSpace = false;
|
|
15
|
+
this.text = String(text);
|
|
16
|
+
}
|
|
17
|
+
return Text;
|
|
18
|
+
}());
|
|
19
|
+
var Run = /** @class */ (function () {
|
|
20
|
+
function Run() {
|
|
21
|
+
this.properties = {};
|
|
22
|
+
this.children = [];
|
|
23
|
+
}
|
|
24
|
+
Run.prototype.addChild = function (child) {
|
|
25
|
+
if (child) {
|
|
26
|
+
this.children.push(child);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
Run.parseRunPr = function (word, element) {
|
|
30
|
+
var cssStyle = parsePr(word, element);
|
|
31
|
+
var rStyle;
|
|
32
|
+
var rStyleElement = element.getElementsByTagName('w:rStyle').item(0);
|
|
33
|
+
if (rStyleElement) {
|
|
34
|
+
rStyle = getVal(rStyleElement);
|
|
35
|
+
}
|
|
36
|
+
return { cssStyle: cssStyle, rStyle: rStyle };
|
|
37
|
+
};
|
|
38
|
+
Run.fromXML = function (word, element) {
|
|
39
|
+
var e_1, _a;
|
|
40
|
+
var run = new Run();
|
|
41
|
+
try {
|
|
42
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
43
|
+
var child = _c.value;
|
|
44
|
+
var tagName = child.tagName;
|
|
45
|
+
switch (tagName) {
|
|
46
|
+
case 'w:t':
|
|
47
|
+
var textContent = child.textContent || '';
|
|
48
|
+
var text = new Text(textContent);
|
|
49
|
+
run.addChild(text);
|
|
50
|
+
break;
|
|
51
|
+
case 'w:rPr':
|
|
52
|
+
run.properties = Run.parseRunPr(word, child);
|
|
53
|
+
break;
|
|
54
|
+
case 'w:br':
|
|
55
|
+
run.addChild(Break.fromXML(word, child));
|
|
56
|
+
break;
|
|
57
|
+
case 'w:drawing':
|
|
58
|
+
run.addChild(Drawing.fromXML(word, child));
|
|
59
|
+
break;
|
|
60
|
+
case 'w:tab':
|
|
61
|
+
run.addChild(Tab.fromXML(word, child));
|
|
62
|
+
break;
|
|
63
|
+
case 'w:fldChar':
|
|
64
|
+
// 似乎只需要支持 instrText
|
|
65
|
+
break;
|
|
66
|
+
case 'w:instrText':
|
|
67
|
+
run.addChild(new InstrText(child.textContent || ''));
|
|
68
|
+
break;
|
|
69
|
+
case 'w:lastRenderedPageBreak':
|
|
70
|
+
// 目前也不支持分页显示
|
|
71
|
+
break;
|
|
72
|
+
case 'w:pict':
|
|
73
|
+
run.addChild(Pict.fromXML(word, child));
|
|
74
|
+
break;
|
|
75
|
+
case 'w:ruby':
|
|
76
|
+
run.addChild(Ruby.fromXML(word, child));
|
|
77
|
+
break;
|
|
78
|
+
case 'w:sym':
|
|
79
|
+
run.addChild(Sym.parseXML(child));
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
console.warn('parse Run: Unknown key', tagName, child);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
87
|
+
finally {
|
|
88
|
+
try {
|
|
89
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
90
|
+
}
|
|
91
|
+
finally { if (e_1) throw e_1.error; }
|
|
92
|
+
}
|
|
93
|
+
return run;
|
|
94
|
+
};
|
|
95
|
+
return Run;
|
|
96
|
+
}());
|
|
97
|
+
|
|
98
|
+
export { Run, 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,59 @@
|
|
|
1
|
+
import { __values } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { parseSize } from '../../parse/parseSize.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* section 属性
|
|
6
|
+
* word 文档是按 section 组织的
|
|
7
|
+
* 参考了 docx 里的类型定义
|
|
8
|
+
*/
|
|
9
|
+
var Section = /** @class */ (function () {
|
|
10
|
+
function Section() {
|
|
11
|
+
this.properties = {};
|
|
12
|
+
this.children = [];
|
|
13
|
+
}
|
|
14
|
+
Section.prototype.addChild = function (child) {
|
|
15
|
+
this.children.push(child);
|
|
16
|
+
};
|
|
17
|
+
Section.parsePr = function (element) {
|
|
18
|
+
var e_1, _a;
|
|
19
|
+
var properties = {};
|
|
20
|
+
try {
|
|
21
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
22
|
+
var child = _c.value;
|
|
23
|
+
var tagName = child.tagName;
|
|
24
|
+
switch (tagName) {
|
|
25
|
+
case 'w:pgSz':
|
|
26
|
+
properties.pageSize = {
|
|
27
|
+
width: parseSize(child, 'w:w'),
|
|
28
|
+
height: parseSize(child, 'w:h')
|
|
29
|
+
};
|
|
30
|
+
break;
|
|
31
|
+
case 'w:pgMar':
|
|
32
|
+
properties.pageMargin = {
|
|
33
|
+
left: parseSize(child, 'w:left'),
|
|
34
|
+
right: parseSize(child, 'w:right'),
|
|
35
|
+
top: parseSize(child, 'w:top'),
|
|
36
|
+
bottom: parseSize(child, 'w:bottom'),
|
|
37
|
+
header: parseSize(child, 'w:header'),
|
|
38
|
+
footer: parseSize(child, 'w:footer'),
|
|
39
|
+
gutter: parseSize(child, 'w:gutter')
|
|
40
|
+
};
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
48
|
+
finally {
|
|
49
|
+
try {
|
|
50
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
51
|
+
}
|
|
52
|
+
finally { if (e_1) throw e_1.error; }
|
|
53
|
+
}
|
|
54
|
+
return properties;
|
|
55
|
+
};
|
|
56
|
+
return Section;
|
|
57
|
+
}());
|
|
58
|
+
|
|
59
|
+
export { Section };
|
|
@@ -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,18 @@
|
|
|
1
|
+
import { __extends } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { InlineText } from './InlineText.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/smartTag.html
|
|
6
|
+
*/
|
|
7
|
+
var SmartTag = /** @class */ (function (_super) {
|
|
8
|
+
__extends(SmartTag, _super);
|
|
9
|
+
function SmartTag() {
|
|
10
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
11
|
+
}
|
|
12
|
+
SmartTag.fromXML = function (word, element) {
|
|
13
|
+
return InlineText.fromXML(word, element);
|
|
14
|
+
};
|
|
15
|
+
return SmartTag;
|
|
16
|
+
}(InlineText));
|
|
17
|
+
|
|
18
|
+
export { 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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/sym.html
|
|
3
|
+
*/
|
|
4
|
+
var Sym = /** @class */ (function () {
|
|
5
|
+
function Sym() {
|
|
6
|
+
}
|
|
7
|
+
Sym.parseXML = function (element) {
|
|
8
|
+
var sym = new Sym();
|
|
9
|
+
sym.font = element.getAttribute('w:font') || '';
|
|
10
|
+
sym.char = element.getAttribute('w:char') || '';
|
|
11
|
+
return sym;
|
|
12
|
+
};
|
|
13
|
+
return Sym;
|
|
14
|
+
}());
|
|
15
|
+
|
|
16
|
+
export { Sym };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getVal } from '../../OpenXML.js';
|
|
2
|
+
import { parseSize } from '../../parse/parseSize.js';
|
|
3
|
+
|
|
4
|
+
var Tab = /** @class */ (function () {
|
|
5
|
+
function Tab() {
|
|
6
|
+
}
|
|
7
|
+
Tab.fromXML = function (word, element) {
|
|
8
|
+
var tab = new Tab();
|
|
9
|
+
tab.pos = parseSize(element, 'w:pos');
|
|
10
|
+
tab.type = getVal(element);
|
|
11
|
+
tab.leader = element.getAttribute('w:leader');
|
|
12
|
+
return tab;
|
|
13
|
+
};
|
|
14
|
+
return Tab;
|
|
15
|
+
}());
|
|
16
|
+
|
|
17
|
+
export { 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 {};
|