@file-viewer/renderer-word 3.0.2 → 3.0.3
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.en.md +9 -0
- package/README.md +4 -0
- package/dist/wordDoc.js +6 -5
- package/dist/wordDocx.js +12 -7
- package/package.json +5 -5
package/README.en.md
CHANGED
|
@@ -36,6 +36,15 @@ Use `@file-viewer/preset-all` when you want the same complete matrix as the offi
|
|
|
36
36
|
- With the RTF capability installed, RTF uses `rtf.js`; without it the viewer shows the exact CLI enablement command. ODT / ODP read `content.xml` from OpenDocument packages for safe structure previews.
|
|
37
37
|
- The renderer reuses core search, zoom, print, export, lifecycle, and operation APIs.
|
|
38
38
|
|
|
39
|
+
## Text Revisions
|
|
40
|
+
|
|
41
|
+
`options.docx.reviewMode` applies to DOC and DOCX: `all` (default) shows actual
|
|
42
|
+
insertions underlined and deletions struck through; `final` shows revised text,
|
|
43
|
+
and `original` shows text before those edits. Changing this option updates the
|
|
44
|
+
current preview without replacing the file. It does not accept/reject revisions
|
|
45
|
+
or rewrite the original bytes. Text revisions are not a claim of complete
|
|
46
|
+
Word review-history, formatting-change, or move-tracking support.
|
|
47
|
+
|
|
39
48
|
## Offline Assets
|
|
40
49
|
|
|
41
50
|
DOCX Worker defaults to viewer assets:
|
package/README.md
CHANGED
|
@@ -36,6 +36,10 @@ const options = {
|
|
|
36
36
|
- 安装 RTF capability 后才使用 `rtf.js`;未安装时会显示精确 CLI 启用命令。ODT / ODP 读取 OpenDocument 包内 `content.xml` 做安全结构预览。
|
|
37
37
|
- 继续复用 core 的统一搜索、缩放、打印、导出、生命周期和操作能力。
|
|
38
38
|
|
|
39
|
+
## 文本修订
|
|
40
|
+
|
|
41
|
+
`options.docx.reviewMode` 同时适用于 DOC 和 DOCX:`all`(默认)用下划线显示实际插入、用删除线显示实际删除;`final` 显示定稿,`original` 显示修订前文字。同一组件修改该参数后会更新预览,不需要重新选择文件,也不会接受、拒绝修订或重写原始文件。文本修订支持不等于完整支持 Word 审阅历史、格式修订或移动记录。
|
|
42
|
+
|
|
39
43
|
## 离线资产
|
|
40
44
|
|
|
41
45
|
DOCX Worker 默认读取 viewer assets 下的:
|
package/dist/wordDoc.js
CHANGED
|
@@ -368,12 +368,13 @@ function makeMsDocResponsive(target) {
|
|
|
368
368
|
* 渲染 doc 文件
|
|
369
369
|
*/
|
|
370
370
|
export default async function render(buffer, target, context) {
|
|
371
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
371
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
372
372
|
const rendered = await parseMsDocToHtml(buffer, {
|
|
373
373
|
renderOptions: {
|
|
374
|
+
reviewMode: (_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.options) === null || _a === void 0 ? void 0 : _a.docx) === null || _b === void 0 ? void 0 : _b.reviewMode) !== null && _c !== void 0 ? _c : 'all',
|
|
374
375
|
css: `${defaultMsDocCss()}\n${WORD_PAGE_CSS}`,
|
|
375
|
-
externalLinkPolicy: (
|
|
376
|
-
externalResourcePolicy: (
|
|
376
|
+
externalLinkPolicy: (_f = (_e = (_d = context === null || context === void 0 ? void 0 : context.options) === null || _d === void 0 ? void 0 : _d.docx) === null || _e === void 0 ? void 0 : _e.externalLinkPolicy) !== null && _f !== void 0 ? _f : 'block',
|
|
377
|
+
externalResourcePolicy: (_j = (_h = (_g = context === null || context === void 0 ? void 0 : context.options) === null || _g === void 0 ? void 0 : _g.docx) === null || _h === void 0 ? void 0 : _h.externalResourcePolicy) !== null && _j !== void 0 ? _j : 'block'
|
|
377
378
|
}
|
|
378
379
|
});
|
|
379
380
|
const targetWindow = target.ownerDocument.defaultView;
|
|
@@ -387,13 +388,13 @@ export default async function render(buffer, target, context) {
|
|
|
387
388
|
content.append(sanitizeMsDocHtml(wrapAsWordPages(rendered.html), targetWindow));
|
|
388
389
|
target.replaceChildren(style, ...Array.from(content.childNodes));
|
|
389
390
|
const disposeResponsive = makeMsDocResponsive(target);
|
|
390
|
-
(
|
|
391
|
+
(_k = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _k === void 0 ? void 0 : _k.call(context, {
|
|
391
392
|
includeDocumentStyles: false,
|
|
392
393
|
getPrintMaskPages: () => Array.from(target.querySelectorAll('.msdoc-page')),
|
|
393
394
|
printStyle: buildMsDocPrintStyle,
|
|
394
395
|
toHtml: () => prepareMsDocCloneForExport(target)
|
|
395
396
|
});
|
|
396
|
-
(
|
|
397
|
+
(_l = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _l === void 0 ? void 0 : _l.call(context, {
|
|
397
398
|
getTarget: () => target.querySelector('.msdoc-page') || target
|
|
398
399
|
});
|
|
399
400
|
return {
|
package/dist/wordDocx.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import JSZip from 'jszip';
|
|
2
|
-
import { resolveFileViewerDocxWorkerJsZipUrl, resolveFileViewerDocxWorkerUrl, resolveFileViewerRuntimeAssetBaseUrl, } from '@file-viewer/core/assets';
|
|
2
|
+
import { DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION, resolveFileViewerDocxWorkerJsZipUrl, resolveFileViewerDocxWorkerUrl, resolveFileViewerRuntimeAssetBaseUrl, } from '@file-viewer/core/assets';
|
|
3
3
|
import { applyPrintPageSize, buildPrintPageStyle, createFileViewerTranslator, createFileViewerZoomChangeEmitter as createZoomChangeEmitter, formatCssPixels, getElementPrintPageSize, normalizeFileViewerTheme, replaceFileViewerCanvasWithImages, registerFileViewerZoomProvider, resolveFileViewerFitScale, unregisterFileViewerZoomProvider, waitForFileViewerNextPaint, } from '@file-viewer/core';
|
|
4
4
|
const DOCX_DEFAULT_PAGE_SIZE = {
|
|
5
5
|
width: 794,
|
|
@@ -9,7 +9,6 @@ const DOCX_WORKER_UNSAFE_PROTOCOLS = new Set(['file:', 'about:', 'data:']);
|
|
|
9
9
|
const DOCX_MIN_SCALE = 0.24;
|
|
10
10
|
const DOCX_MAX_SCALE = 3;
|
|
11
11
|
const DOCX_ZOOM_STEP = 0.15;
|
|
12
|
-
const DOCX_VENDOR_ASSET_VERSION = '0.3.28';
|
|
13
12
|
const ZIP_SIGNATURE_PK = 0x504b;
|
|
14
13
|
const WORDPROCESSINGML_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
15
14
|
const OFFICE_RELATIONSHIP_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
|
|
@@ -259,9 +258,9 @@ const appendDocxVendorAssetVersion = (url, explicitUrl) => {
|
|
|
259
258
|
return url;
|
|
260
259
|
}
|
|
261
260
|
if (/[?&]file-viewer-docx=[^&#]*/.test(url)) {
|
|
262
|
-
return url.replace(/([?&])file-viewer-docx=[^&#]*/, `$1file-viewer-docx=${
|
|
261
|
+
return url.replace(/([?&])file-viewer-docx=[^&#]*/, `$1file-viewer-docx=${DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION}`);
|
|
263
262
|
}
|
|
264
|
-
return `${url}${url.includes('?') ? '&' : '?'}file-viewer-docx=${
|
|
263
|
+
return `${url}${url.includes('?') ? '&' : '?'}file-viewer-docx=${DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION}`;
|
|
265
264
|
};
|
|
266
265
|
export const applyDocxExternalLinkPolicy = (target, policy) => {
|
|
267
266
|
if (policy === 'allow') {
|
|
@@ -283,7 +282,7 @@ export const applyDocxExternalLinkPolicy = (target, policy) => {
|
|
|
283
282
|
return blocked;
|
|
284
283
|
};
|
|
285
284
|
export const createDocxOptions = (target, context, notifyProgressiveRender) => {
|
|
286
|
-
var _a, _b, _c, _d;
|
|
285
|
+
var _a, _b, _c, _d, _e;
|
|
287
286
|
const docxOptions = (_a = context === null || context === void 0 ? void 0 : context.options) === null || _a === void 0 ? void 0 : _a.docx;
|
|
288
287
|
const documentBaseUrl = resolveFileViewerRuntimeAssetBaseUrl(target.ownerDocument);
|
|
289
288
|
const useWorker = shouldUseDocxWorker(target, docxOptions);
|
|
@@ -298,8 +297,12 @@ export const createDocxOptions = (target, context, notifyProgressiveRender) => {
|
|
|
298
297
|
const externalResourcePolicy = (_c = docxOptions === null || docxOptions === void 0 ? void 0 : docxOptions.externalResourcePolicy) !== null && _c !== void 0 ? _c : 'block';
|
|
299
298
|
const options = {
|
|
300
299
|
useWorker,
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
reviewMode: (_d = docxOptions === null || docxOptions === void 0 ? void 0 : docxOptions.reviewMode) !== null && _d !== void 0 ? _d : 'all',
|
|
301
|
+
// Authored page breaks define separate anchor coordinate spaces even in
|
|
302
|
+
// flow mode. Only measured/fixed-height pagination remains opt-in.
|
|
303
|
+
breakPages: true,
|
|
304
|
+
fixedPageHeight: usePagedLayout,
|
|
305
|
+
ignoreLastRenderedPageBreak: (_e = docxOptions === null || docxOptions === void 0 ? void 0 : docxOptions.ignoreLastRenderedPageBreak) !== null && _e !== void 0 ? _e : !usePagedLayout,
|
|
303
306
|
externalLinkPolicy,
|
|
304
307
|
externalResourcePolicy,
|
|
305
308
|
darkMode,
|
|
@@ -355,6 +358,8 @@ const isTargetHTMLElement = (value, target) => {
|
|
|
355
358
|
return HTMLElementCtor ? value instanceof HTMLElementCtor : value instanceof HTMLElement;
|
|
356
359
|
};
|
|
357
360
|
const DOCX_RESPONSIVE_CSS = `
|
|
361
|
+
/* This component has no review balloon rail, so keep all-markup deletions readable inline. */
|
|
362
|
+
.docx-fit-viewer [data-docx-review-enabled="true"][data-docx-review-mode="all"] del[data-docx-change-kind]{display:inline!important;width:auto!important;max-width:none!important;height:auto!important;overflow:visible!important;line-height:inherit!important;color:var(--docx-review-color,#c2410c);text-decoration:line-through;text-decoration-color:var(--docx-review-color,#c2410c)}
|
|
358
363
|
.docx-fit-viewer {
|
|
359
364
|
box-sizing: border-box;
|
|
360
365
|
height: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-word",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone DOCX, DOC, and OpenDocument renderer for File Viewer; RTF parsing is an explicit opt-in capability.",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"LICENSE"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@file-viewer/core": "3.0.
|
|
62
|
-
"@file-viewer/doc": "3.0.
|
|
63
|
-
"@file-viewer/docx": "0.3.
|
|
64
|
-
"jszip": "
|
|
61
|
+
"@file-viewer/core": "3.0.3",
|
|
62
|
+
"@file-viewer/doc": "3.0.3",
|
|
63
|
+
"@file-viewer/docx": "0.3.31",
|
|
64
|
+
"jszip": "3.10.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"rtf.js": "^3.0.9",
|