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,46 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { getVal } from '../../../OpenXML.js';
|
|
3
|
+
import { Lvl } from './Lvl.js';
|
|
4
|
+
|
|
5
|
+
var Num = /** @class */ (function () {
|
|
6
|
+
function Num() {
|
|
7
|
+
this.lvlOverride = { lvls: {} };
|
|
8
|
+
}
|
|
9
|
+
Num.fromXML = function (word, element) {
|
|
10
|
+
var e_1, _a;
|
|
11
|
+
var num = new Num();
|
|
12
|
+
num.numId = element.getAttribute('w:numId') || '';
|
|
13
|
+
var abstractNumId = element.querySelector('abstractNumId');
|
|
14
|
+
if (abstractNumId) {
|
|
15
|
+
num.abstractNumId = getVal(abstractNumId);
|
|
16
|
+
}
|
|
17
|
+
var lvlOverride = element.querySelector('lvlOverride');
|
|
18
|
+
if (lvlOverride) {
|
|
19
|
+
try {
|
|
20
|
+
for (var _b = __values(lvlOverride.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
|
+
var child = _c.value;
|
|
22
|
+
var tagName = child.tagName;
|
|
23
|
+
switch (tagName) {
|
|
24
|
+
case 'w:lvl':
|
|
25
|
+
var lvlId = child.getAttribute('w:lvlId') || '';
|
|
26
|
+
num.lvlOverride.lvls[lvlId] = Lvl.fromXML(word, child);
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
console.warn("Num: Unknown tag ", tagName, child);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
34
|
+
finally {
|
|
35
|
+
try {
|
|
36
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
37
|
+
}
|
|
38
|
+
finally { if (e_1) throw e_1.error; }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return num;
|
|
42
|
+
};
|
|
43
|
+
return Num;
|
|
44
|
+
}());
|
|
45
|
+
|
|
46
|
+
export { Num };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getVal } from '../../../OpenXML.js';
|
|
2
|
+
|
|
3
|
+
var NumberPr = /** @class */ (function () {
|
|
4
|
+
function NumberPr() {
|
|
5
|
+
}
|
|
6
|
+
NumberPr.fromXML = function (word, element) {
|
|
7
|
+
var numPr = new NumberPr();
|
|
8
|
+
var ilvl = element.querySelector('ilvl');
|
|
9
|
+
if (ilvl) {
|
|
10
|
+
numPr.ilvl = getVal(ilvl);
|
|
11
|
+
}
|
|
12
|
+
var numId = element.querySelector('numId');
|
|
13
|
+
if (numId) {
|
|
14
|
+
numPr.numId = getVal(numId);
|
|
15
|
+
}
|
|
16
|
+
return numPr;
|
|
17
|
+
};
|
|
18
|
+
return NumberPr;
|
|
19
|
+
}());
|
|
20
|
+
|
|
21
|
+
export { NumberPr };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Word from '../../../Word';
|
|
2
|
+
import { AbstractNum } from './AbstractNum';
|
|
3
|
+
import { Num } from './Num';
|
|
4
|
+
export declare class Numbering {
|
|
5
|
+
abstractNums: Record<string, AbstractNum>;
|
|
6
|
+
nums: Record<string, Num>;
|
|
7
|
+
numData: Record<string, Record<string, number>>;
|
|
8
|
+
static fromXML(word: Word, element: Document): Numbering;
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { AbstractNum } from './AbstractNum.js';
|
|
3
|
+
import { Num } from './Num.js';
|
|
4
|
+
|
|
5
|
+
var Numbering = /** @class */ (function () {
|
|
6
|
+
function Numbering() {
|
|
7
|
+
this.abstractNums = {};
|
|
8
|
+
this.nums = {};
|
|
9
|
+
// 某个 numId 当前值,如果要重新渲染文档,需要将这个置空,
|
|
10
|
+
// 第一个 key 是 numId,第二个 key 是 ilvl,第一个 key 会自动初始化
|
|
11
|
+
this.numData = {};
|
|
12
|
+
}
|
|
13
|
+
Numbering.fromXML = function (word, element) {
|
|
14
|
+
var e_1, _a, e_2, _b;
|
|
15
|
+
var numbering = new Numbering();
|
|
16
|
+
try {
|
|
17
|
+
for (var _c = __values(element.getElementsByTagName('w:abstractNum')), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
18
|
+
var abstractNumElement = _d.value;
|
|
19
|
+
var abstractNum = AbstractNum.fromXML(word, abstractNumElement);
|
|
20
|
+
numbering.abstractNums[abstractNum.abstractNumId] = abstractNum;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e_1) throw e_1.error; }
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
for (var _e = __values(element.getElementsByTagName('w:num')), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
32
|
+
var numElement = _f.value;
|
|
33
|
+
var num = Num.fromXML(word, numElement);
|
|
34
|
+
numbering.nums[num.numId] = num;
|
|
35
|
+
numbering.numData[num.numId] = {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
39
|
+
finally {
|
|
40
|
+
try {
|
|
41
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
42
|
+
}
|
|
43
|
+
finally { if (e_2) throw e_2.error; }
|
|
44
|
+
}
|
|
45
|
+
return numbering;
|
|
46
|
+
};
|
|
47
|
+
return Numbering;
|
|
48
|
+
}());
|
|
49
|
+
|
|
50
|
+
export { Numbering };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Word from '../../../Word';
|
|
2
|
+
import { CSSStyle } from '../../Style';
|
|
3
|
+
import { Paragraph } from '../Paragraph';
|
|
4
|
+
import { Table } from '../Table';
|
|
5
|
+
import { ST_Merge } from '../../Types';
|
|
6
|
+
export interface TcPr {
|
|
7
|
+
cssStyle?: CSSStyle;
|
|
8
|
+
hideMark?: false;
|
|
9
|
+
vMerge?: ST_Merge;
|
|
10
|
+
gridSpan?: number;
|
|
11
|
+
rowSpan?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 内部 border,需要作用于非第一列的单元格
|
|
14
|
+
*/
|
|
15
|
+
insideBorder?: {
|
|
16
|
+
H?: string;
|
|
17
|
+
V?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type TcChild = Paragraph | Table;
|
|
21
|
+
export declare function parseCellMargin(element: Element, style: CSSStyle): void;
|
|
22
|
+
export declare function parseTblCellSpacing(element: Element, style: CSSStyle): void;
|
|
23
|
+
/**
|
|
24
|
+
* parseBorders 不支持 insideH 和 insideV,所以单独支持一下
|
|
25
|
+
* 实际显示时需要过滤掉第一列
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseInsideBorders(word: Word, element: Element): {
|
|
28
|
+
H: string | undefined;
|
|
29
|
+
V: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* http://officeopenxml.com/WPtableWidth.php
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseTblWidth(element: Element): string;
|
|
35
|
+
export declare class Tc {
|
|
36
|
+
properties: TcPr;
|
|
37
|
+
children: TcChild[];
|
|
38
|
+
add(child: TcChild): void;
|
|
39
|
+
static parseTcPr(word: Word, element: Element): TcPr;
|
|
40
|
+
static fromXML(word: Word, element: Element, currentCol: {
|
|
41
|
+
index: number;
|
|
42
|
+
}, rowSpanMap: {
|
|
43
|
+
[key: string]: Tc;
|
|
44
|
+
}): Tc | null;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { getVal, getValNumber, getValBoolean } from '../../../OpenXML.js';
|
|
3
|
+
import { Paragraph } from '../Paragraph.js';
|
|
4
|
+
import { Table } from '../Table.js';
|
|
5
|
+
import { parseSize, LengthUsage } from '../../../parse/parseSize.js';
|
|
6
|
+
import { parseShdColor } from '../../../parse/parseColor.js';
|
|
7
|
+
import { parseBorders, parseBorder } from '../../../parse/parseBorder.js';
|
|
8
|
+
import { parseTextDirection } from '../../../parse/parseTextDirection.js';
|
|
9
|
+
import { ST_Merge, ST_VerticalJc, ST_TblWidth } from '../../Types.js';
|
|
10
|
+
|
|
11
|
+
// http://officeopenxml.com/WPtableCellProperties-Margins.php
|
|
12
|
+
function parseCellMargin(element, style) {
|
|
13
|
+
var e_1, _a;
|
|
14
|
+
try {
|
|
15
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
16
|
+
var child = _c.value;
|
|
17
|
+
var tagName = child.tagName;
|
|
18
|
+
switch (tagName) {
|
|
19
|
+
case 'w:left':
|
|
20
|
+
case 'w:start':
|
|
21
|
+
style['padding-left'] = parseSize(child, 'w:w');
|
|
22
|
+
break;
|
|
23
|
+
case 'w:right':
|
|
24
|
+
case 'w:end':
|
|
25
|
+
style['padding-right'] = parseSize(child, 'w:w');
|
|
26
|
+
break;
|
|
27
|
+
case 'w:top':
|
|
28
|
+
style['padding-top'] = parseSize(child, 'w:w');
|
|
29
|
+
break;
|
|
30
|
+
case 'w:bottom':
|
|
31
|
+
style['padding-bottom'] = parseSize(child, 'w:w');
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37
|
+
finally {
|
|
38
|
+
try {
|
|
39
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
40
|
+
}
|
|
41
|
+
finally { if (e_1) throw e_1.error; }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function parseVAlign(element, style) {
|
|
45
|
+
var vAlign = getVal(element);
|
|
46
|
+
switch (vAlign) {
|
|
47
|
+
case ST_VerticalJc.bottom:
|
|
48
|
+
style['vertical-align'] = 'bottom';
|
|
49
|
+
break;
|
|
50
|
+
case ST_VerticalJc.center:
|
|
51
|
+
style['vertical-align'] = 'middle';
|
|
52
|
+
break;
|
|
53
|
+
case ST_VerticalJc.top:
|
|
54
|
+
style['vertical-align'] = 'top';
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function parseTblCellSpacing(element, style) {
|
|
59
|
+
var width = parseTblWidth(element);
|
|
60
|
+
if (width) {
|
|
61
|
+
style['cell-spacing'] = width;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* parseBorders 不支持 insideH 和 insideV,所以单独支持一下
|
|
66
|
+
* 实际显示时需要过滤掉第一列
|
|
67
|
+
*/
|
|
68
|
+
function parseInsideBorders(word, element) {
|
|
69
|
+
var H;
|
|
70
|
+
var insideH = element.querySelector('insideH');
|
|
71
|
+
if (insideH) {
|
|
72
|
+
H = parseBorder(word, insideH);
|
|
73
|
+
}
|
|
74
|
+
var V;
|
|
75
|
+
var insideV = element.querySelector('insideV');
|
|
76
|
+
if (insideV) {
|
|
77
|
+
V = parseBorder(word, insideV);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
H: H,
|
|
81
|
+
V: V
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* http://officeopenxml.com/WPtableWidth.php
|
|
86
|
+
*/
|
|
87
|
+
function parseTblWidth(element) {
|
|
88
|
+
var type = element.getAttribute('w:type');
|
|
89
|
+
if (!type || type === ST_TblWidth.dxa) {
|
|
90
|
+
return parseSize(element, 'w:w');
|
|
91
|
+
}
|
|
92
|
+
else if (type === ST_TblWidth.pct) {
|
|
93
|
+
return parseSize(element, 'w:w', LengthUsage.Percent);
|
|
94
|
+
}
|
|
95
|
+
else if (type === ST_TblWidth.auto) {
|
|
96
|
+
return 'auto';
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.warn('parseTblWidth: ignore type', type, element);
|
|
100
|
+
}
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
function parseTcW(element, style) {
|
|
104
|
+
var width = parseTblWidth(element);
|
|
105
|
+
if (width) {
|
|
106
|
+
style.width = width;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
var Tc = /** @class */ (function () {
|
|
110
|
+
function Tc() {
|
|
111
|
+
this.properties = {};
|
|
112
|
+
this.children = [];
|
|
113
|
+
}
|
|
114
|
+
Tc.prototype.add = function (child) {
|
|
115
|
+
if (child) {
|
|
116
|
+
this.children.push(child);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
Tc.parseTcPr = function (word, element) {
|
|
120
|
+
var e_2, _a;
|
|
121
|
+
var properties = {};
|
|
122
|
+
var style = {};
|
|
123
|
+
properties.cssStyle = style;
|
|
124
|
+
try {
|
|
125
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
126
|
+
var child = _c.value;
|
|
127
|
+
var tagName = child.tagName;
|
|
128
|
+
switch (tagName) {
|
|
129
|
+
case 'w:tcMar':
|
|
130
|
+
parseCellMargin(child, style);
|
|
131
|
+
break;
|
|
132
|
+
case 'w:shd':
|
|
133
|
+
style['background-color'] = parseShdColor(word, child);
|
|
134
|
+
break;
|
|
135
|
+
case 'w:tcW':
|
|
136
|
+
parseTcW(child, style);
|
|
137
|
+
break;
|
|
138
|
+
case 'w:noWrap':
|
|
139
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noWrap.html
|
|
140
|
+
var noWrap = getValBoolean(child);
|
|
141
|
+
if (noWrap) {
|
|
142
|
+
style['white-space'] = 'nowrap';
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case 'w:vAlign':
|
|
146
|
+
parseVAlign(child, style);
|
|
147
|
+
break;
|
|
148
|
+
case 'w:tcBorders':
|
|
149
|
+
parseBorders(word, child, style);
|
|
150
|
+
properties.insideBorder = parseInsideBorders(word, child);
|
|
151
|
+
break;
|
|
152
|
+
case 'w:gridSpan':
|
|
153
|
+
properties.gridSpan = getValNumber(child);
|
|
154
|
+
break;
|
|
155
|
+
case 'w:vMerge':
|
|
156
|
+
properties.vMerge = getVal(child) || ST_Merge.continue;
|
|
157
|
+
break;
|
|
158
|
+
case 'w:textDirection':
|
|
159
|
+
parseTextDirection(child, style);
|
|
160
|
+
break;
|
|
161
|
+
case 'w:cnfStyle':
|
|
162
|
+
// 目前是自动计算的,所以不需要这个了
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
console.warn('parseTcPr: ignore', tagName, child);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
170
|
+
finally {
|
|
171
|
+
try {
|
|
172
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
173
|
+
}
|
|
174
|
+
finally { if (e_2) throw e_2.error; }
|
|
175
|
+
}
|
|
176
|
+
return properties;
|
|
177
|
+
};
|
|
178
|
+
Tc.fromXML = function (word, element, currentCol, rowSpanMap) {
|
|
179
|
+
var e_3, _a;
|
|
180
|
+
var tc = new Tc();
|
|
181
|
+
try {
|
|
182
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
183
|
+
var child = _c.value;
|
|
184
|
+
var tagName = child.tagName;
|
|
185
|
+
switch (tagName) {
|
|
186
|
+
case 'w:tcPr':
|
|
187
|
+
tc.properties = Tc.parseTcPr(word, child);
|
|
188
|
+
break;
|
|
189
|
+
case 'w:p':
|
|
190
|
+
tc.add(Paragraph.fromXML(word, child));
|
|
191
|
+
break;
|
|
192
|
+
case 'w:tbl':
|
|
193
|
+
tc.add(Table.fromXML(word, child));
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
199
|
+
finally {
|
|
200
|
+
try {
|
|
201
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
202
|
+
}
|
|
203
|
+
finally { if (e_3) throw e_3.error; }
|
|
204
|
+
}
|
|
205
|
+
var lastCol = rowSpanMap[currentCol.index];
|
|
206
|
+
// 如果是 continue 意味着这个被合并了
|
|
207
|
+
if (tc.properties.vMerge) {
|
|
208
|
+
if (tc.properties.vMerge === ST_Merge.restart) {
|
|
209
|
+
tc.properties.rowSpan = 1;
|
|
210
|
+
rowSpanMap[currentCol.index] = tc;
|
|
211
|
+
}
|
|
212
|
+
else if (lastCol) {
|
|
213
|
+
if (lastCol.properties && lastCol.properties.rowSpan) {
|
|
214
|
+
lastCol.properties.rowSpan = lastCol.properties.rowSpan + 1;
|
|
215
|
+
var colSpan_1 = tc.properties.gridSpan || 1;
|
|
216
|
+
currentCol.index += colSpan_1;
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
console.warn('Tc.fromXML: continue but not found lastCol', currentCol.index, tc, rowSpanMap);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
delete rowSpanMap[currentCol.index];
|
|
226
|
+
}
|
|
227
|
+
var colSpan = tc.properties.gridSpan || 1;
|
|
228
|
+
currentCol.index += colSpan;
|
|
229
|
+
return tc;
|
|
230
|
+
};
|
|
231
|
+
return Tc;
|
|
232
|
+
}());
|
|
233
|
+
|
|
234
|
+
export { Tc, parseCellMargin, parseInsideBorders, parseTblCellSpacing, parseTblWidth };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CSSStyle } from '../../Style';
|
|
2
|
+
import { Tc } from './Tc';
|
|
3
|
+
import Word from '../../../Word';
|
|
4
|
+
export interface TrPr {
|
|
5
|
+
cssStyle?: CSSStyle;
|
|
6
|
+
/**
|
|
7
|
+
* 单元格样式
|
|
8
|
+
*/
|
|
9
|
+
tcStyle?: CSSStyle;
|
|
10
|
+
}
|
|
11
|
+
export declare class Tr {
|
|
12
|
+
properties: TrPr;
|
|
13
|
+
tcs: Tc[];
|
|
14
|
+
static parseTrPr(word: Word, element: Element): TrPr;
|
|
15
|
+
static fromXML(word: Word, element: Element, rowSpanMap: {
|
|
16
|
+
[key: string]: Tc;
|
|
17
|
+
}): Tr;
|
|
18
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { getVal, getValBoolean } from '../../../OpenXML.js';
|
|
3
|
+
import { parseTblCellSpacing, Tc } from './Tc.js';
|
|
4
|
+
import { parseTrHeight } from '../../../parse/parseTrHeight.js';
|
|
5
|
+
import { jcToTextAlign } from '../../../parse/jcToTextAlign.js';
|
|
6
|
+
import { Table } from '../Table.js';
|
|
7
|
+
|
|
8
|
+
var Tr = /** @class */ (function () {
|
|
9
|
+
function Tr() {
|
|
10
|
+
this.properties = {};
|
|
11
|
+
this.tcs = [];
|
|
12
|
+
}
|
|
13
|
+
Tr.parseTrPr = function (word, element) {
|
|
14
|
+
var e_1, _a;
|
|
15
|
+
var cssStyle = {};
|
|
16
|
+
var tcStyle = {};
|
|
17
|
+
try {
|
|
18
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19
|
+
var child = _c.value;
|
|
20
|
+
var tagName = child.tagName;
|
|
21
|
+
switch (tagName) {
|
|
22
|
+
case 'w:hidden':
|
|
23
|
+
if (getValBoolean(child)) {
|
|
24
|
+
cssStyle.display = 'none';
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case 'w:trHeight':
|
|
28
|
+
parseTrHeight(child, cssStyle);
|
|
29
|
+
break;
|
|
30
|
+
case 'w:jc':
|
|
31
|
+
cssStyle['text-align'] = jcToTextAlign(getVal(child));
|
|
32
|
+
break;
|
|
33
|
+
case 'w:cantSplit':
|
|
34
|
+
// 目前也不支持分页
|
|
35
|
+
break;
|
|
36
|
+
case 'w:tblPrEx':
|
|
37
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
38
|
+
var tablePr = Table.parseTablePr(word, child);
|
|
39
|
+
Object.assign(cssStyle, tablePr.cssStyle);
|
|
40
|
+
break;
|
|
41
|
+
case 'w:tblCellSpacing':
|
|
42
|
+
parseTblCellSpacing(child, tcStyle);
|
|
43
|
+
break;
|
|
44
|
+
case 'w:cnfStyle':
|
|
45
|
+
// 目前是自动计算的,所以不需要这个了
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
console.warn("Tr: Unknown tag ", tagName, child);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
56
|
+
}
|
|
57
|
+
finally { if (e_1) throw e_1.error; }
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
cssStyle: cssStyle
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
Tr.fromXML = function (word, element, rowSpanMap) {
|
|
64
|
+
var e_2, _a;
|
|
65
|
+
var tr = new Tr();
|
|
66
|
+
// 做成对象是为了传递引用来修改
|
|
67
|
+
var currentCol = {
|
|
68
|
+
index: 0
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
72
|
+
var child = _c.value;
|
|
73
|
+
var tagName = child.tagName;
|
|
74
|
+
switch (tagName) {
|
|
75
|
+
case 'w:tc':
|
|
76
|
+
var tc = Tc.fromXML(word, child, currentCol, rowSpanMap);
|
|
77
|
+
if (tc) {
|
|
78
|
+
tr.tcs.push(tc);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'w:trPr':
|
|
82
|
+
tr.properties = Tr.parseTrPr(word, child);
|
|
83
|
+
break;
|
|
84
|
+
case 'w:tblPrEx':
|
|
85
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
86
|
+
var tablePr = Table.parseTablePr(word, child);
|
|
87
|
+
Object.assign(tr.properties.cssStyle || {}, tablePr.cssStyle);
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
console.warn("Tr: Unknown tag ", tagName, child);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
98
|
+
}
|
|
99
|
+
finally { if (e_2) throw e_2.error; }
|
|
100
|
+
}
|
|
101
|
+
return tr;
|
|
102
|
+
};
|
|
103
|
+
return Tr;
|
|
104
|
+
}());
|
|
105
|
+
|
|
106
|
+
export { Tr };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件加载器默认是直接读取 zip,如果要对文件做特殊加密处理,可以实现这个接口
|
|
3
|
+
*/
|
|
4
|
+
export interface PackageParser {
|
|
5
|
+
load(docxFile: ArrayBuffer | string): void;
|
|
6
|
+
/**
|
|
7
|
+
* 读取 xml 文件,转成 json 对象
|
|
8
|
+
* @param filePath 文件路径
|
|
9
|
+
* @returns 转成 json 的结果
|
|
10
|
+
*/
|
|
11
|
+
getXML(filePath: string): Document;
|
|
12
|
+
/**
|
|
13
|
+
* 根据类型读取文件
|
|
14
|
+
*/
|
|
15
|
+
getFileByType(filePath: string, type: 'string' | 'blob'): string | Blob;
|
|
16
|
+
/**
|
|
17
|
+
* 文件是否存在
|
|
18
|
+
*/
|
|
19
|
+
fileExists(filePath: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 生成新的 zip 文件
|
|
22
|
+
*
|
|
23
|
+
* @param docContent 新的 word/document.xml 文件内容
|
|
24
|
+
*/
|
|
25
|
+
generateZip(docContent: string): Blob;
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* openxml 默认是 zip 格式,导致构造比较麻烦,所以增加了这种单一格式,所有内容都放在一个 xml 文件里
|
|
3
|
+
*/
|
|
4
|
+
import { PackageParser } from './PackageParser';
|
|
5
|
+
export default class XMLPackageParser implements PackageParser {
|
|
6
|
+
private xml;
|
|
7
|
+
private files;
|
|
8
|
+
private contentTypesDoc;
|
|
9
|
+
/**
|
|
10
|
+
* 加载 zip 文件
|
|
11
|
+
*/
|
|
12
|
+
load(fileContent: ArrayBuffer | string): void;
|
|
13
|
+
/**
|
|
14
|
+
* 读取 xml 文件,转成 json 对象
|
|
15
|
+
* @param filePath 文件路径
|
|
16
|
+
* @returns 转成 json 的结果
|
|
17
|
+
*/
|
|
18
|
+
getXML(filePath: string): Document;
|
|
19
|
+
/**
|
|
20
|
+
* 在 xml 下基本不用这个
|
|
21
|
+
*/
|
|
22
|
+
getFileByType(filePath: string, type: 'string' | 'blob'): string;
|
|
23
|
+
/**
|
|
24
|
+
* 判断文件是否存在
|
|
25
|
+
*/
|
|
26
|
+
fileExists(filePath: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 生成 zip 文件
|
|
29
|
+
*/
|
|
30
|
+
generateZip(docContent: string): Blob;
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zip 文件解析
|
|
3
|
+
*/
|
|
4
|
+
import { PackageParser } from './PackageParser';
|
|
5
|
+
export default class ZipPackageParser implements PackageParser {
|
|
6
|
+
private zip;
|
|
7
|
+
/**
|
|
8
|
+
* 加载 zip 文件
|
|
9
|
+
*/
|
|
10
|
+
load(docxFile: ArrayBuffer): void;
|
|
11
|
+
/**
|
|
12
|
+
* 读取 xml 文件,转成 json 对象
|
|
13
|
+
* @param filePath 文件路径
|
|
14
|
+
* @returns 转成 json 的结果
|
|
15
|
+
*/
|
|
16
|
+
getXML(filePath: string): Document;
|
|
17
|
+
/**
|
|
18
|
+
* 根据类型读取文件
|
|
19
|
+
*/
|
|
20
|
+
getFileByType(filePath: string, type: 'string' | 'blob'): string | Blob;
|
|
21
|
+
/**
|
|
22
|
+
* 判断文件是否存在
|
|
23
|
+
*/
|
|
24
|
+
fileExists(filePath: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 生成新的 zip 文件
|
|
27
|
+
*/
|
|
28
|
+
generateZip(docContent: string): Blob;
|
|
29
|
+
}
|