@file-viewer/renderer-word 2.1.26 → 2.1.28
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/dist/openDocument.js +12 -3
- package/dist/wordDoc.js +6 -2
- package/dist/wordDocx.js +7 -3
- package/package.json +4 -4
package/dist/openDocument.js
CHANGED
|
@@ -84,8 +84,8 @@ const resolveRtfJs = async () => {
|
|
|
84
84
|
const rtfModule = await import('rtf.js/dist/RTFJS.bundle.js');
|
|
85
85
|
return rtfModule.RTFJS || rtfModule.default || rtfModule;
|
|
86
86
|
};
|
|
87
|
-
const renderRtf = async (buffer, target, t) => {
|
|
88
|
-
var _a, _b;
|
|
87
|
+
const renderRtf = async (buffer, target, t, context) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
89
|
const RTFJS = await resolveRtfJs();
|
|
90
90
|
(_a = RTFJS.loggingEnabled) === null || _a === void 0 ? void 0 : _a.call(RTFJS, false);
|
|
91
91
|
const doc = new RTFJS.Document(buffer, {});
|
|
@@ -102,27 +102,36 @@ const renderRtf = async (buffer, target, t) => {
|
|
|
102
102
|
elements.forEach((element) => paper.appendChild(element));
|
|
103
103
|
stage.append(header, paper);
|
|
104
104
|
target.replaceChildren(createStyle(), stage);
|
|
105
|
+
(_c = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _c === void 0 ? void 0 : _c.call(context, { getTarget: () => paper });
|
|
105
106
|
return {
|
|
106
107
|
$el: target,
|
|
107
108
|
unmount() {
|
|
109
|
+
var _a;
|
|
110
|
+
(_a = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
108
111
|
target.replaceChildren();
|
|
109
112
|
},
|
|
110
113
|
};
|
|
111
114
|
};
|
|
112
115
|
export default async function renderOpenDocument(buffer, target, type, context) {
|
|
116
|
+
var _a;
|
|
113
117
|
const t = createFileViewerTranslator(context === null || context === void 0 ? void 0 : context.options);
|
|
114
118
|
const normalizedType = (type || 'odt').toLowerCase();
|
|
115
119
|
if (normalizedType === 'rtf') {
|
|
116
|
-
return renderRtf(buffer, target, t);
|
|
120
|
+
return renderRtf(buffer, target, t, context);
|
|
117
121
|
}
|
|
118
122
|
const pages = await parseOdf(buffer, normalizedType, t);
|
|
119
123
|
const title = normalizedType === 'odp'
|
|
120
124
|
? t('word.title.openDocumentPresentation')
|
|
121
125
|
: t('word.title.openDocumentText');
|
|
122
126
|
target.replaceChildren(createStyle(), renderOdfPages(normalizedType, title, pages));
|
|
127
|
+
(_a = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _a === void 0 ? void 0 : _a.call(context, {
|
|
128
|
+
getTarget: () => target.querySelector('.odf-page') || target
|
|
129
|
+
});
|
|
123
130
|
return {
|
|
124
131
|
$el: target,
|
|
125
132
|
unmount() {
|
|
133
|
+
var _a;
|
|
134
|
+
(_a = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
126
135
|
target.replaceChildren();
|
|
127
136
|
},
|
|
128
137
|
};
|
package/dist/wordDoc.js
CHANGED
|
@@ -343,7 +343,7 @@ function makeMsDocResponsive(target) {
|
|
|
343
343
|
* 渲染 doc 文件
|
|
344
344
|
*/
|
|
345
345
|
export default async function render(buffer, target, context) {
|
|
346
|
-
var _a;
|
|
346
|
+
var _a, _b;
|
|
347
347
|
const rendered = await parseMsDocToHtml(buffer, {
|
|
348
348
|
renderOptions: {
|
|
349
349
|
css: `${defaultMsDocCss()}\n${WORD_PAGE_CSS}`
|
|
@@ -356,11 +356,15 @@ export default async function render(buffer, target, context) {
|
|
|
356
356
|
printStyle: buildMsDocPrintStyle,
|
|
357
357
|
toHtml: () => prepareMsDocCloneForExport(target)
|
|
358
358
|
});
|
|
359
|
+
(_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, {
|
|
360
|
+
getTarget: () => target.querySelector('.msdoc-page') || target
|
|
361
|
+
});
|
|
359
362
|
return {
|
|
360
363
|
$el: target,
|
|
361
364
|
unmount() {
|
|
362
|
-
var _a;
|
|
365
|
+
var _a, _b;
|
|
363
366
|
(_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
367
|
+
(_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, null);
|
|
364
368
|
disposeResponsive();
|
|
365
369
|
target.innerHTML = '';
|
|
366
370
|
}
|
package/dist/wordDocx.js
CHANGED
|
@@ -8,7 +8,7 @@ const DOCX_WORKER_UNSAFE_PROTOCOLS = new Set(['file:', 'about:', 'data:']);
|
|
|
8
8
|
const DOCX_MIN_SCALE = 0.24;
|
|
9
9
|
const DOCX_MAX_SCALE = 3;
|
|
10
10
|
const DOCX_ZOOM_STEP = 0.15;
|
|
11
|
-
const DOCX_VENDOR_ASSET_VERSION = '0.3.
|
|
11
|
+
const DOCX_VENDOR_ASSET_VERSION = '0.3.20';
|
|
12
12
|
const ZIP_SIGNATURE_PK = 0x504b;
|
|
13
13
|
const loadLibrary = (() => {
|
|
14
14
|
const loader = {
|
|
@@ -495,7 +495,7 @@ function prepareDocxCloneForExport(target) {
|
|
|
495
495
|
* 渲染docx文件
|
|
496
496
|
*/
|
|
497
497
|
export default async function (buffer, target, context) {
|
|
498
|
-
var _a;
|
|
498
|
+
var _a, _b;
|
|
499
499
|
assertValidDocxPackage(buffer, context);
|
|
500
500
|
target.innerHTML = '';
|
|
501
501
|
let hasNotifiedProgressiveRender = false;
|
|
@@ -528,11 +528,15 @@ export default async function (buffer, target, context) {
|
|
|
528
528
|
printStyle: () => buildDocxPrintStyle(target),
|
|
529
529
|
toHtml: () => prepareDocxCloneForExport(target)
|
|
530
530
|
});
|
|
531
|
+
(_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, {
|
|
532
|
+
getTarget: () => target.querySelector('.docx-page-frame, .docx-flow-frame') || target
|
|
533
|
+
});
|
|
531
534
|
return {
|
|
532
535
|
$el: target,
|
|
533
536
|
unmount() {
|
|
534
|
-
var _a;
|
|
537
|
+
var _a, _b;
|
|
535
538
|
(_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
539
|
+
(_b = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _b === void 0 ? void 0 : _b.call(context, null);
|
|
536
540
|
disposeResponsive();
|
|
537
541
|
delete target.dataset.docxWorker;
|
|
538
542
|
delete target.dataset.docxDarkMode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-word",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.28",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone Word and compatible document renderer plugin for Flyfish File Viewer powered by @file-viewer/docx, @file-viewer/doc, and RTF/ODF parsing.",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"LICENSE"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@file-viewer/core": "2.1.
|
|
61
|
-
"@file-viewer/doc": "2.1.
|
|
62
|
-
"@file-viewer/docx": "^0.3.
|
|
60
|
+
"@file-viewer/core": "2.1.28",
|
|
61
|
+
"@file-viewer/doc": "2.1.28",
|
|
62
|
+
"@file-viewer/docx": "^0.3.20",
|
|
63
63
|
"jszip": "^3.10.1",
|
|
64
64
|
"rtf.js": "^3.0.9"
|
|
65
65
|
},
|