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,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 中英文间自动加空格,基于下面代码改的,去掉了 lodash 依赖
|
|
3
|
+
* https://gist.github.com/wyl8899/e0f31068681023480e20c34f6b19a275
|
|
4
|
+
*/
|
|
5
|
+
/* Partial implementation from https://zhuanlan.zhihu.com/p/33612593 */
|
|
6
|
+
/* 标点 */
|
|
7
|
+
var punctuationRegex = /\p{Punctuation}/u;
|
|
8
|
+
/* 空格 */
|
|
9
|
+
var spaceRegex = /\p{Separator}/u;
|
|
10
|
+
/* CJK 字符,中日韩 */
|
|
11
|
+
var cjkRegex = /\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}|\p{Script=Hangul}/u;
|
|
12
|
+
var shouldSpace = function (a, b) {
|
|
13
|
+
if (cjkRegex.test(a)) {
|
|
14
|
+
return !(punctuationRegex.test(b) ||
|
|
15
|
+
spaceRegex.test(b) ||
|
|
16
|
+
cjkRegex.test(b));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return cjkRegex.test(b) && !punctuationRegex.test(a) && !spaceRegex.test(a);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var join = function (parts, sepFunc) {
|
|
23
|
+
return parts.reduce(function (r, p, i) {
|
|
24
|
+
var sep = i !== 0 ? sepFunc(p, parts[i - 1]) : '';
|
|
25
|
+
return r + sep + p;
|
|
26
|
+
}, '');
|
|
27
|
+
};
|
|
28
|
+
var cjkspace = function (strings) {
|
|
29
|
+
var filtered = strings.filter(function (c) { return c !== undefined && c !== ''; });
|
|
30
|
+
return join(filtered, function (a, b) { return (shouldSpace(a, b) ? ' ' : ''); });
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { cjkspace };
|
package/esm/util/blob.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 blob 转成 data url
|
|
3
|
+
*/
|
|
4
|
+
function blobToDataURL(blob) {
|
|
5
|
+
return new Promise(function (resolve, reject) {
|
|
6
|
+
var reader = new FileReader();
|
|
7
|
+
reader.onload = function (_e) { return resolve(reader.result); };
|
|
8
|
+
reader.onerror = function (_e) { return reject(reader.error); };
|
|
9
|
+
reader.onabort = function (_e) { return reject(new Error('Read aborted')); };
|
|
10
|
+
reader.readAsDataURL(blob);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 下载 blob
|
|
15
|
+
* https://dev.to/nombrekeff/download-file-from-blob-21ho
|
|
16
|
+
*/
|
|
17
|
+
function downloadBlob(blob, name) {
|
|
18
|
+
if (name === void 0) { name = 'file.txt'; }
|
|
19
|
+
// Convert your blob into a Blob URL (a special url that points to an object in the browser's memory)
|
|
20
|
+
var blobUrl = URL.createObjectURL(blob);
|
|
21
|
+
// Create a link element
|
|
22
|
+
var link = document.createElement('a');
|
|
23
|
+
// Set link's href to point to the Blob URL
|
|
24
|
+
link.href = blobUrl;
|
|
25
|
+
link.download = name;
|
|
26
|
+
// Append link to the body
|
|
27
|
+
document.body.appendChild(link);
|
|
28
|
+
// Dispatch click event on the link
|
|
29
|
+
// This is necessary as link.click() does not work on the latest firefox
|
|
30
|
+
link.dispatchEvent(new MouseEvent('click', {
|
|
31
|
+
bubbles: true,
|
|
32
|
+
cancelable: true,
|
|
33
|
+
view: window
|
|
34
|
+
}));
|
|
35
|
+
// Remove link from body
|
|
36
|
+
document.body.removeChild(link);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { blobToDataURL, downloadBlob };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dom 相关的操作
|
|
3
|
+
*/
|
|
4
|
+
import { CSSStyle } from '../openxml/Style';
|
|
5
|
+
/**
|
|
6
|
+
* 样式对象转成 css 文本
|
|
7
|
+
*/
|
|
8
|
+
export declare function styleToText(style?: CSSStyle): string;
|
|
9
|
+
/**
|
|
10
|
+
* 设置元素样式
|
|
11
|
+
*/
|
|
12
|
+
export declare function setStyle(el: HTMLElement, style: CSSStyle): void;
|
|
13
|
+
/**
|
|
14
|
+
* 创建元素
|
|
15
|
+
*/
|
|
16
|
+
export declare function createElement(tagName: string): HTMLElement;
|
|
17
|
+
/**
|
|
18
|
+
* 创建片段
|
|
19
|
+
*/
|
|
20
|
+
export declare function createDocumentFragment(): DocumentFragment;
|
|
21
|
+
/**
|
|
22
|
+
* 添加子节点,会做一些判断避免报错
|
|
23
|
+
*/
|
|
24
|
+
export declare function appendChild(parent: HTMLElement, child: HTMLElement | null): void;
|
|
25
|
+
/**
|
|
26
|
+
* 添加注释节点
|
|
27
|
+
*/
|
|
28
|
+
export declare function appendComment(parent: HTMLElement, comment: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 添加 css 类
|
|
31
|
+
*/
|
|
32
|
+
export declare function addClassName(el: HTMLElement, className: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* 批量添加 css 类
|
|
35
|
+
*/
|
|
36
|
+
export declare function addClassNames(el: HTMLElement, classNames: string[]): void;
|
package/esm/util/dom.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __spreadArray, __read } from '../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* dom 相关的操作
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 样式对象转成 css 文本
|
|
8
|
+
*/
|
|
9
|
+
function styleToText(style) {
|
|
10
|
+
if (style === void 0) { style = {}; }
|
|
11
|
+
var text = '';
|
|
12
|
+
for (var key in style) {
|
|
13
|
+
var value = style[key];
|
|
14
|
+
if (value != null && value !== '') {
|
|
15
|
+
text += "".concat(key, ": ").concat(value, ";\n");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 设置元素样式
|
|
22
|
+
*/
|
|
23
|
+
function setStyle(el, style) {
|
|
24
|
+
for (var key in style) {
|
|
25
|
+
var value = style[key];
|
|
26
|
+
if (value != null && value !== '') {
|
|
27
|
+
el.style.setProperty(key, style[key]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 创建元素
|
|
33
|
+
*/
|
|
34
|
+
function createElement(tagName) {
|
|
35
|
+
return document.createElement(tagName);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 添加子节点,会做一些判断避免报错
|
|
39
|
+
*/
|
|
40
|
+
function appendChild(parent, child) {
|
|
41
|
+
if (parent && child) {
|
|
42
|
+
parent.appendChild(child);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 添加 css 类
|
|
47
|
+
*/
|
|
48
|
+
function addClassName(el, className) {
|
|
49
|
+
if (el && className) {
|
|
50
|
+
el.classList.add(className);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 批量添加 css 类
|
|
55
|
+
*/
|
|
56
|
+
function addClassNames(el, classNames) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (el && classNames) {
|
|
59
|
+
(_a = el.classList).add.apply(_a, __spreadArray([], __read(classNames), false));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { addClassName, addClassNames, appendChild, createElement, setStyle, styleToText };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 合并 p 下相同的文本,主要是为了方便替换变量
|
|
3
|
+
*/
|
|
4
|
+
import Word from '../Word';
|
|
5
|
+
/**
|
|
6
|
+
* 只支持处理 w:r 下有 w:t 的情况
|
|
7
|
+
*/
|
|
8
|
+
export declare function canMerge(element: Element): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 合并 p 下相同的文本
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeRunInP(word: Word, p: Element): void;
|
|
13
|
+
/**
|
|
14
|
+
* 合并
|
|
15
|
+
* @param document
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergeRun(word: Word, doc: Document): void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __values } from '../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { parsePr } from '../parse/parsePr.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 合并 p 下相同的文本,主要是为了方便替换变量
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 是否具有相同样式
|
|
9
|
+
*/
|
|
10
|
+
function hasSomeStyle(word, first, second) {
|
|
11
|
+
var firstStyle = first ? parsePr(word, first) : {};
|
|
12
|
+
var secondStyle = second ? parsePr(word, second) : {};
|
|
13
|
+
return JSON.stringify(firstStyle) === JSON.stringify(secondStyle);
|
|
14
|
+
}
|
|
15
|
+
function mergeText(first, second) {
|
|
16
|
+
var firstT = first.getElementsByTagName('w:t')[0];
|
|
17
|
+
var secondT = second.getElementsByTagName('w:t')[0];
|
|
18
|
+
if (firstT && secondT) {
|
|
19
|
+
var secondText = secondT.textContent || '';
|
|
20
|
+
firstT.textContent += secondText || '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 只支持处理 w:r 下有 w:t 的情况
|
|
25
|
+
*/
|
|
26
|
+
function canMerge(element) {
|
|
27
|
+
var e_1, _a;
|
|
28
|
+
var tagName = element.tagName;
|
|
29
|
+
var childChildren = element.children;
|
|
30
|
+
var hasText = false;
|
|
31
|
+
var textHasSpace = false;
|
|
32
|
+
try {
|
|
33
|
+
for (var childChildren_1 = __values(childChildren), childChildren_1_1 = childChildren_1.next(); !childChildren_1_1.done; childChildren_1_1 = childChildren_1.next()) {
|
|
34
|
+
var childChild = childChildren_1_1.value;
|
|
35
|
+
if (childChild.tagName === 'w:t') {
|
|
36
|
+
hasText = true;
|
|
37
|
+
textHasSpace = childChild.getAttribute('xml:space') === 'preserve';
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
43
|
+
finally {
|
|
44
|
+
try {
|
|
45
|
+
if (childChildren_1_1 && !childChildren_1_1.done && (_a = childChildren_1.return)) _a.call(childChildren_1);
|
|
46
|
+
}
|
|
47
|
+
finally { if (e_1) throw e_1.error; }
|
|
48
|
+
}
|
|
49
|
+
return tagName === 'w:r' && hasText && !textHasSpace;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 合并 p 下相同的文本
|
|
53
|
+
*/
|
|
54
|
+
function mergeRunInP(word, p) {
|
|
55
|
+
var e_2, _a, e_3, _b;
|
|
56
|
+
var newElements = [];
|
|
57
|
+
var lastRun = null;
|
|
58
|
+
try {
|
|
59
|
+
for (var _c = __values(p.children), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
60
|
+
var child = _d.value;
|
|
61
|
+
var tagName = child.tagName;
|
|
62
|
+
// 避免图片和空格被合并了
|
|
63
|
+
if (canMerge(child)) {
|
|
64
|
+
if (lastRun) {
|
|
65
|
+
var lastRunProps = lastRun.getElementsByTagName('w:rPr')[0];
|
|
66
|
+
var thisProps = child.getElementsByTagName('w:rPr')[0];
|
|
67
|
+
if (hasSomeStyle(word, lastRunProps, thisProps)) {
|
|
68
|
+
mergeText(lastRun, child);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
lastRun = child;
|
|
72
|
+
newElements.push(child);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// 说明是第一次运行
|
|
77
|
+
lastRun = child;
|
|
78
|
+
newElements.push(child);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// 忽略这个标签
|
|
83
|
+
if (tagName !== 'w:proofErr') {
|
|
84
|
+
lastRun = null;
|
|
85
|
+
newElements.push(child);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_2) throw e_2.error; }
|
|
96
|
+
}
|
|
97
|
+
p.innerHTML = '';
|
|
98
|
+
try {
|
|
99
|
+
for (var newElements_1 = __values(newElements), newElements_1_1 = newElements_1.next(); !newElements_1_1.done; newElements_1_1 = newElements_1.next()) {
|
|
100
|
+
var newElement = newElements_1_1.value;
|
|
101
|
+
p.appendChild(newElement);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
105
|
+
finally {
|
|
106
|
+
try {
|
|
107
|
+
if (newElements_1_1 && !newElements_1_1.done && (_b = newElements_1.return)) _b.call(newElements_1);
|
|
108
|
+
}
|
|
109
|
+
finally { if (e_3) throw e_3.error; }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 合并
|
|
114
|
+
* @param document
|
|
115
|
+
*/
|
|
116
|
+
function mergeRun(word, doc) {
|
|
117
|
+
var e_4, _a;
|
|
118
|
+
var ps = doc.getElementsByTagName('w:p');
|
|
119
|
+
try {
|
|
120
|
+
for (var ps_1 = __values(ps), ps_1_1 = ps_1.next(); !ps_1_1.done; ps_1_1 = ps_1.next()) {
|
|
121
|
+
var p = ps_1_1.value;
|
|
122
|
+
mergeRunInP(word, p);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
126
|
+
finally {
|
|
127
|
+
try {
|
|
128
|
+
if (ps_1_1 && !ps_1_1.done && (_a = ps_1.return)) _a.call(ps_1);
|
|
129
|
+
}
|
|
130
|
+
finally { if (e_4) throw e_4.error; }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { canMerge, mergeRun, mergeRunInP };
|
package/esm/util/xml.js
ADDED
package/lib/OpenXML.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* openxml 一些辅助函数
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 获取 w:val 的值
|
|
6
|
+
*/
|
|
7
|
+
export declare function getVal(element: Element): string;
|
|
8
|
+
/**
|
|
9
|
+
* 获取 w:val 的值,转成 number 类型
|
|
10
|
+
*/
|
|
11
|
+
export declare function getValNumber(element: Element): number;
|
|
12
|
+
/**
|
|
13
|
+
* 有可能是 on 或 off 之类的值,都归一化为 boolean
|
|
14
|
+
* @param value
|
|
15
|
+
* @param defaultValue 默认值
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeBoolean(value: string | boolean | null, defaultValue?: boolean): boolean;
|
|
19
|
+
export declare function getValBoolean(element: Element, defaultValue?: boolean): boolean;
|
|
20
|
+
export declare function getAttrBoolean(element: Element, attr: string, defaultValue?: boolean): boolean;
|
|
21
|
+
export declare function getValHex(element: Element): number;
|
package/lib/OpenXML.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* openxml 一些辅助函数
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 获取 w:val 的值
|
|
10
|
+
*/
|
|
11
|
+
function getVal(element) {
|
|
12
|
+
return element.getAttribute('w:val') || '';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 获取 w:val 的值,转成 number 类型
|
|
16
|
+
*/
|
|
17
|
+
function getValNumber(element) {
|
|
18
|
+
return parseInt(getVal(element), 10);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 有可能是 on 或 off 之类的值,都归一化为 boolean
|
|
22
|
+
* @param value
|
|
23
|
+
* @param defaultValue 默认值
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function normalizeBoolean(value, defaultValue) {
|
|
27
|
+
if (defaultValue === void 0) { defaultValue = false; }
|
|
28
|
+
if (typeof value === 'boolean') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === 'string') {
|
|
32
|
+
switch (value) {
|
|
33
|
+
case '1':
|
|
34
|
+
return true;
|
|
35
|
+
case '0':
|
|
36
|
+
return false;
|
|
37
|
+
case 'on':
|
|
38
|
+
return true;
|
|
39
|
+
case 'off':
|
|
40
|
+
return false;
|
|
41
|
+
case 'true':
|
|
42
|
+
return true;
|
|
43
|
+
case 'false':
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === 'number') {
|
|
47
|
+
return value !== 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return defaultValue;
|
|
51
|
+
}
|
|
52
|
+
function getValBoolean(element, defaultValue) {
|
|
53
|
+
if (defaultValue === void 0) { defaultValue = true; }
|
|
54
|
+
return normalizeBoolean(getVal(element), defaultValue);
|
|
55
|
+
}
|
|
56
|
+
function getAttrBoolean(element, attr, defaultValue) {
|
|
57
|
+
if (defaultValue === void 0) { defaultValue = true; }
|
|
58
|
+
return normalizeBoolean(element.getAttribute(attr), defaultValue);
|
|
59
|
+
}
|
|
60
|
+
function getValHex(element) {
|
|
61
|
+
return parseInt(getVal(element) || '0', 16);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.getAttrBoolean = getAttrBoolean;
|
|
65
|
+
exports.getVal = getVal;
|
|
66
|
+
exports.getValBoolean = getValBoolean;
|
|
67
|
+
exports.getValHex = getValHex;
|
|
68
|
+
exports.getValNumber = getValNumber;
|
|
69
|
+
exports.normalizeBoolean = normalizeBoolean;
|
package/lib/Word.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 总入口,它将包括所有 word 文档信息,后续渲染的时候依赖它来获取关联信息
|
|
3
|
+
*/
|
|
4
|
+
import { Relationship } from './parse/parseRelationship';
|
|
5
|
+
import { ContentTypes } from './openxml/ContentType';
|
|
6
|
+
import { Styles } from './openxml/Style';
|
|
7
|
+
import { Theme } from './openxml/Theme';
|
|
8
|
+
import { Numbering } from './openxml/word/numbering/Numbering';
|
|
9
|
+
import { PackageParser } from './package/PackageParser';
|
|
10
|
+
import { Paragraph } from './openxml/word/Paragraph';
|
|
11
|
+
/**
|
|
12
|
+
* 渲染配置
|
|
13
|
+
*/
|
|
14
|
+
export interface WordRenderOptions {
|
|
15
|
+
/**
|
|
16
|
+
* css 类前缀
|
|
17
|
+
*/
|
|
18
|
+
classPrefix: string;
|
|
19
|
+
/** 图片是否使用 data url */
|
|
20
|
+
imageDataURL: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 列表使用字体渲染,需要自行引入 Windings 字体
|
|
23
|
+
*/
|
|
24
|
+
bulletUseFont: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 是否包裹出页面效果
|
|
27
|
+
*/
|
|
28
|
+
inWrap: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 是否忽略文档宽度设置
|
|
31
|
+
*/
|
|
32
|
+
ignoreWidth?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 是否忽略文档高度设置
|
|
35
|
+
*/
|
|
36
|
+
ignoreHeight?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 强制文档内边距设置
|
|
39
|
+
*/
|
|
40
|
+
padding?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 最小行高
|
|
43
|
+
*/
|
|
44
|
+
minLineHeight?: number;
|
|
45
|
+
/**
|
|
46
|
+
* 是否开启变量替换功能
|
|
47
|
+
*/
|
|
48
|
+
enableVar?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 进行模板替换的函数
|
|
51
|
+
*/
|
|
52
|
+
replaceText?: (text: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* 是否开启调试模式
|
|
55
|
+
*/
|
|
56
|
+
debug?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 字体映射,用于替换文档中的字体
|
|
59
|
+
*/
|
|
60
|
+
fontMapping?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* 强制行高,设置之后所有文本都使用这个行高,可以优化排版效果
|
|
63
|
+
*/
|
|
64
|
+
forceLineHeight?: string;
|
|
65
|
+
}
|
|
66
|
+
export default class Word {
|
|
67
|
+
/**
|
|
68
|
+
* 全局 id,用于一个页面渲染多个 word 文档
|
|
69
|
+
*/
|
|
70
|
+
static globalId: number;
|
|
71
|
+
/**
|
|
72
|
+
* 当前渲染 id
|
|
73
|
+
*/
|
|
74
|
+
id: number;
|
|
75
|
+
/**
|
|
76
|
+
* openxml 包
|
|
77
|
+
*/
|
|
78
|
+
parser: PackageParser;
|
|
79
|
+
/**
|
|
80
|
+
* 解析 [Content_Types].xml 里的数据
|
|
81
|
+
*/
|
|
82
|
+
conentTypes: ContentTypes;
|
|
83
|
+
/**
|
|
84
|
+
* 解析 theme 目录里的数据
|
|
85
|
+
*/
|
|
86
|
+
themes: Theme[];
|
|
87
|
+
/**
|
|
88
|
+
* 解析 numbering.xml 里的数据
|
|
89
|
+
*/
|
|
90
|
+
numbering: Numbering;
|
|
91
|
+
/**
|
|
92
|
+
* 解析 styles.xml 里的数据
|
|
93
|
+
*/
|
|
94
|
+
styles: Styles;
|
|
95
|
+
renderOptions: WordRenderOptions;
|
|
96
|
+
relationships: Record<string, Relationship>;
|
|
97
|
+
/**
|
|
98
|
+
* 样式名映射,因为自定义样式名有可能不符合 css 命名规范,因此实际使用这个名字
|
|
99
|
+
*/
|
|
100
|
+
styleIdMap: Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* 用于自动生成样式名时的计数,保证每次都是唯一的
|
|
103
|
+
*/
|
|
104
|
+
styleIdNum: number;
|
|
105
|
+
/**
|
|
106
|
+
* 渲染根节点
|
|
107
|
+
*/
|
|
108
|
+
rootElement: HTMLElement;
|
|
109
|
+
wrapClassName: string;
|
|
110
|
+
/**
|
|
111
|
+
* 当前渲染的段落,主要用于获取 fldSimple
|
|
112
|
+
*/
|
|
113
|
+
currentParagraph: Paragraph;
|
|
114
|
+
/**
|
|
115
|
+
* 构建 word
|
|
116
|
+
*
|
|
117
|
+
* @param docxFile docx 文件
|
|
118
|
+
* @param options 渲染配置
|
|
119
|
+
* @param packaParser 包解析器
|
|
120
|
+
*/
|
|
121
|
+
constructor(docFile: ArrayBuffer | string, renderOptions?: Partial<WordRenderOptions>, parser?: PackageParser);
|
|
122
|
+
inited: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 初始化一些公共资源,比如
|
|
125
|
+
*/
|
|
126
|
+
init(): void;
|
|
127
|
+
/**
|
|
128
|
+
* 解析全局主题配置
|
|
129
|
+
*/
|
|
130
|
+
initTheme(): void;
|
|
131
|
+
/**
|
|
132
|
+
* 解析全局样式
|
|
133
|
+
*/
|
|
134
|
+
initStyle(): void;
|
|
135
|
+
/**
|
|
136
|
+
* 解析关系
|
|
137
|
+
*/
|
|
138
|
+
initRelation(): void;
|
|
139
|
+
/**
|
|
140
|
+
* 解析全局配置
|
|
141
|
+
*/
|
|
142
|
+
initContentType(): void;
|
|
143
|
+
/**
|
|
144
|
+
* 解析 numbering
|
|
145
|
+
*/
|
|
146
|
+
initNumbering(): void;
|
|
147
|
+
/**
|
|
148
|
+
* 根据 id 获取关系
|
|
149
|
+
*/
|
|
150
|
+
getRelationship(id?: string): Relationship | null;
|
|
151
|
+
/**
|
|
152
|
+
* 进行文本替换
|
|
153
|
+
*/
|
|
154
|
+
replaceText(text: string): string;
|
|
155
|
+
/**
|
|
156
|
+
* 加载图片
|
|
157
|
+
*/
|
|
158
|
+
loadImage(relation: Relationship): Promise<string> | null;
|
|
159
|
+
/**
|
|
160
|
+
* 解析 html
|
|
161
|
+
*/
|
|
162
|
+
getXML(filePath: string): Document;
|
|
163
|
+
/**
|
|
164
|
+
* 获取 styleId 的显示名称,因为这里可以自定义,理论上会出现 css 不支持的语法
|
|
165
|
+
*/
|
|
166
|
+
getStyleIdDisplayName(styleId: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* 生成个新的唯一的 class 名称
|
|
169
|
+
*/
|
|
170
|
+
genClassName(): string;
|
|
171
|
+
/**
|
|
172
|
+
* 添加新样式,主要用于表格的单元格样式
|
|
173
|
+
*/
|
|
174
|
+
appendStyle(style: string): void;
|
|
175
|
+
/**
|
|
176
|
+
* 返回样式表名及它的父级样式表名
|
|
177
|
+
* @param styleId 样式表里的 style 名称
|
|
178
|
+
* @returns 返回 className 数组
|
|
179
|
+
*/
|
|
180
|
+
getStyleClassName(stylId: string): string[];
|
|
181
|
+
/**
|
|
182
|
+
* 渲染时的 css 类前缀
|
|
183
|
+
*/
|
|
184
|
+
getClassPrefix(): string;
|
|
185
|
+
/**
|
|
186
|
+
* 获取主题色,目前基于 css 变量实现,方便动态修改
|
|
187
|
+
*/
|
|
188
|
+
getThemeColor(name: string): string;
|
|
189
|
+
addClass(element: HTMLElement, className: string): void;
|
|
190
|
+
/**
|
|
191
|
+
* 更新页面中的变量,这个要在 render 后运行
|
|
192
|
+
*/
|
|
193
|
+
updateVariable(): void;
|
|
194
|
+
/**
|
|
195
|
+
* 下载生成的文档,会对 word/document.xml 进行处理,替换文本
|
|
196
|
+
*/
|
|
197
|
+
download(fileName?: string): void;
|
|
198
|
+
/**
|
|
199
|
+
* 打印功能
|
|
200
|
+
*/
|
|
201
|
+
print(): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* 渲染文档入口
|
|
204
|
+
*
|
|
205
|
+
* @param root 渲染的根节点
|
|
206
|
+
*/
|
|
207
|
+
render(root: HTMLElement): Promise<void>;
|
|
208
|
+
}
|