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,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,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,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,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,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,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 {};
|