@file-viewer/core 2.2.2 → 2.2.4
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 +2 -2
- package/README.md +2 -2
- package/dist/browser/controller.d.ts +137 -0
- package/dist/browser/controller.js +967 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/contracts/types.d.ts +5 -4
- package/dist/features/printMaskDesigner.js +9 -4
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/i18n/messages.d.ts +4 -2
- package/dist/i18n/messages.ja.d.ts +7 -0
- package/dist/i18n/messages.ja.js +429 -0
- package/dist/i18n/messages.js +41 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lifecycle/operations.d.ts +6 -4
- package/dist/lifecycle/operations.js +12 -5
- package/dist/platform/assets.d.ts +8 -5
- package/dist/platform/assets.js +67 -13
- package/dist/rendering/handler.js +12 -5
- package/dist/viewer/state.js +19 -7
- package/package.json +4 -4
|
@@ -76,7 +76,8 @@ export interface ResolveFileViewerOperationAvailabilityInput {
|
|
|
76
76
|
}
|
|
77
77
|
export interface ResolveFileViewerToolbarStateInput extends ResolveFileViewerOperationAvailabilityInput {
|
|
78
78
|
toolbar: FileViewerToolbarOptions;
|
|
79
|
-
options?: Pick<FileViewerOptions, 'toolbar'>;
|
|
79
|
+
options?: Pick<FileViewerOptions, 'toolbar' | 'search'>;
|
|
80
|
+
searchAvailable?: boolean;
|
|
80
81
|
loading?: boolean;
|
|
81
82
|
}
|
|
82
83
|
export interface FileViewerToolbarState {
|
|
@@ -196,6 +197,7 @@ export interface CreateFileViewerToolbarControllerActionHandlersInput {
|
|
|
196
197
|
getHasError?: () => boolean;
|
|
197
198
|
getLoading?: () => boolean;
|
|
198
199
|
getOptions?: () => FileViewerOptions | undefined;
|
|
200
|
+
getSearchAvailable?: () => boolean;
|
|
199
201
|
getSourceUrl?: () => string | null | undefined;
|
|
200
202
|
getToolbar: () => FileViewerToolbarOptions;
|
|
201
203
|
getRenderedReady: () => boolean;
|
|
@@ -274,11 +276,11 @@ export declare const createFileViewerPublicApi: ({ getOperationAvailability, ...
|
|
|
274
276
|
export declare const createFileViewerToolbarZoomSyncSnapshot: (state: FileViewerZoomState) => FileViewerToolbarZoomSyncSnapshot;
|
|
275
277
|
export declare const runFileViewerToolbarAvailabilitySync: ({ toolbarActions, availability, }: RunFileViewerToolbarAvailabilitySyncInput) => boolean;
|
|
276
278
|
export declare const runFileViewerToolbarZoomSync: ({ toolbarActions, state, }: RunFileViewerToolbarZoomSyncInput) => boolean;
|
|
277
|
-
export declare const createFileViewerToolbarControllerActionHandlers: ({ getAdapter, getBuffer, getExtension, getFile, getHasError, getLoading, getOptions, getSourceUrl, getToolbar, getRenderedReady, getZoomState, zoomSyncState, onOperationAvailabilityChange, onZoomChange, }: CreateFileViewerToolbarControllerActionHandlersInput) => FileViewerToolbarControllerActionHandlers;
|
|
279
|
+
export declare const createFileViewerToolbarControllerActionHandlers: ({ getAdapter, getBuffer, getExtension, getFile, getHasError, getLoading, getOptions, getSearchAvailable, getSourceUrl, getToolbar, getRenderedReady, getZoomState, zoomSyncState, onOperationAvailabilityChange, onZoomChange, }: CreateFileViewerToolbarControllerActionHandlersInput) => FileViewerToolbarControllerActionHandlers;
|
|
278
280
|
export declare const normalizeFileViewerToolbar: (options: Pick<FileViewerOptions, "toolbar"> | undefined) => FileViewerToolbarOptions;
|
|
279
281
|
export declare const resolveFileViewerOperationAvailability: ({ extension, hasOriginalSource, renderedReady, hasError, adapter, source, zoomState, }: ResolveFileViewerOperationAvailabilityInput) => FileViewerOperationAvailability;
|
|
280
282
|
export declare const cloneFileViewerOperationAvailability: (availability: FileViewerOperationAvailability) => FileViewerOperationAvailability;
|
|
281
|
-
export declare const resolveVisibleFileViewerToolbar: (toolbar: FileViewerToolbarOptions, availability: FileViewerOperationAvailability) => FileViewerToolbarOptions;
|
|
283
|
+
export declare const resolveVisibleFileViewerToolbar: (toolbar: FileViewerToolbarOptions, availability: FileViewerOperationAvailability, searchEnabled?: boolean) => FileViewerToolbarOptions;
|
|
282
284
|
export declare const hasVisibleFileViewerToolbarActions: (toolbar: FileViewerToolbarOptions) => boolean;
|
|
283
285
|
export declare const isFileViewerZoomButtonDisabled: ({ toolbarDisabled, availability, zoomState, action, }: {
|
|
284
286
|
toolbarDisabled?: boolean;
|
|
@@ -290,5 +292,5 @@ export declare const isFileViewerToolbarDisabled: ({ loading, hasError, }: {
|
|
|
290
292
|
loading?: boolean;
|
|
291
293
|
hasError?: boolean;
|
|
292
294
|
}) => boolean;
|
|
293
|
-
export declare const resolveFileViewerToolbarState: ({ toolbar, options, loading, ...availabilityInput }: ResolveFileViewerToolbarStateInput) => FileViewerToolbarState;
|
|
295
|
+
export declare const resolveFileViewerToolbarState: ({ toolbar, options, searchAvailable, loading, ...availabilityInput }: ResolveFileViewerToolbarStateInput) => FileViewerToolbarState;
|
|
294
296
|
export declare const resolveFileViewerToolbarPosition: (options: Pick<FileViewerOptions, "toolbar"> | undefined, extension: string) => FileViewerToolbarPosition;
|
|
@@ -450,7 +450,7 @@ export const runFileViewerToolbarAvailabilitySync = ({ toolbarActions, availabil
|
|
|
450
450
|
export const runFileViewerToolbarZoomSync = ({ toolbarActions, state, }) => {
|
|
451
451
|
return toolbarActions.notifyZoomChange(state);
|
|
452
452
|
};
|
|
453
|
-
export const createFileViewerToolbarControllerActionHandlers = ({ getAdapter = () => null, getBuffer = () => null, getExtension, getFile = () => null, getHasError = () => false, getLoading = () => false, getOptions, getSourceUrl = () => null, getToolbar, getRenderedReady, getZoomState, zoomSyncState, onOperationAvailabilityChange, onZoomChange, }) => {
|
|
453
|
+
export const createFileViewerToolbarControllerActionHandlers = ({ getAdapter = () => null, getBuffer = () => null, getExtension, getFile = () => null, getHasError = () => false, getLoading = () => false, getOptions, getSearchAvailable = () => true, getSourceUrl = () => null, getToolbar, getRenderedReady, getZoomState, zoomSyncState, onOperationAvailabilityChange, onZoomChange, }) => {
|
|
454
454
|
let currentToolbarState = null;
|
|
455
455
|
const resolveToolbarState = () => {
|
|
456
456
|
var _a, _b, _c, _d;
|
|
@@ -467,6 +467,7 @@ export const createFileViewerToolbarControllerActionHandlers = ({ getAdapter = (
|
|
|
467
467
|
zoomState: getZoomState(),
|
|
468
468
|
toolbar: getToolbar(),
|
|
469
469
|
options: getOptions === null || getOptions === void 0 ? void 0 : getOptions(),
|
|
470
|
+
searchAvailable: getSearchAvailable(),
|
|
470
471
|
loading: getLoading(),
|
|
471
472
|
});
|
|
472
473
|
return currentToolbarState;
|
|
@@ -557,17 +558,23 @@ export const cloneFileViewerOperationAvailability = (availability) => ({
|
|
|
557
558
|
zoomOut: availability.zoomOut,
|
|
558
559
|
zoomReset: availability.zoomReset,
|
|
559
560
|
});
|
|
560
|
-
export const resolveVisibleFileViewerToolbar = (toolbar, availability) => {
|
|
561
|
+
export const resolveVisibleFileViewerToolbar = (toolbar, availability, searchEnabled = true) => {
|
|
561
562
|
return {
|
|
562
563
|
download: toolbar.download && availability.download,
|
|
563
564
|
print: toolbar.print && availability.print,
|
|
564
565
|
exportHtml: toolbar.exportHtml && availability.exportHtml,
|
|
565
566
|
zoom: toolbar.zoom && availability.zoom,
|
|
567
|
+
search: toolbar.search !== false && searchEnabled,
|
|
566
568
|
theme: toolbar.theme !== false,
|
|
567
569
|
};
|
|
568
570
|
};
|
|
569
571
|
export const hasVisibleFileViewerToolbarActions = (toolbar) => {
|
|
570
|
-
return !!(toolbar.download ||
|
|
572
|
+
return !!(toolbar.download ||
|
|
573
|
+
toolbar.print ||
|
|
574
|
+
toolbar.exportHtml ||
|
|
575
|
+
toolbar.zoom ||
|
|
576
|
+
toolbar.search ||
|
|
577
|
+
toolbar.theme);
|
|
571
578
|
};
|
|
572
579
|
export const isFileViewerZoomButtonDisabled = ({ toolbarDisabled = false, availability, zoomState, action, }) => {
|
|
573
580
|
const operation = FILE_VIEWER_ZOOM_BUTTON_OPERATIONS[action];
|
|
@@ -581,9 +588,9 @@ export const isFileViewerZoomButtonDisabled = ({ toolbarDisabled = false, availa
|
|
|
581
588
|
export const isFileViewerToolbarDisabled = ({ loading = false, hasError = false, }) => {
|
|
582
589
|
return !!(loading || hasError);
|
|
583
590
|
};
|
|
584
|
-
export const resolveFileViewerToolbarState = ({ toolbar, options, loading = false, ...availabilityInput }) => {
|
|
591
|
+
export const resolveFileViewerToolbarState = ({ toolbar, options, searchAvailable = true, loading = false, ...availabilityInput }) => {
|
|
585
592
|
const operationAvailability = applyToolbarPermissionsToAvailability(resolveFileViewerOperationAvailability(availabilityInput), options === null || options === void 0 ? void 0 : options.toolbar);
|
|
586
|
-
const visibleToolbar = resolveVisibleFileViewerToolbar(toolbar, operationAvailability);
|
|
593
|
+
const visibleToolbar = resolveVisibleFileViewerToolbar(toolbar, operationAvailability, (options === null || options === void 0 ? void 0 : options.search) !== false && searchAvailable);
|
|
587
594
|
return {
|
|
588
595
|
operationAvailability,
|
|
589
596
|
visibleToolbar,
|
|
@@ -3,8 +3,10 @@ export declare const DEFAULT_FILE_VIEWER_ARCHIVE_WORKER_PATH = "vendor/libarchiv
|
|
|
3
3
|
export declare const DEFAULT_FILE_VIEWER_ARCHIVE_WASM_PATH = "vendor/libarchive/libarchive.wasm";
|
|
4
4
|
export declare const DEFAULT_FILE_VIEWER_DOCX_WORKER_PATH = "vendor/docx/docx.worker.js";
|
|
5
5
|
export declare const DEFAULT_FILE_VIEWER_DOCX_WORKER_JSZIP_PATH = "vendor/docx/jszip.min.js";
|
|
6
|
+
export declare const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = "0.3.26";
|
|
6
7
|
export declare const DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH = "vendor/pptx/pptx.worker.js";
|
|
7
8
|
export declare const DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH = "vendor/ppt";
|
|
9
|
+
export declare const DEFAULT_FILE_VIEWER_PPT_RUNTIME_VERSION = "0.3.2";
|
|
8
10
|
export declare const DEFAULT_FILE_VIEWER_PPT_MODULE_PATH = "vendor/ppt/index.mjs";
|
|
9
11
|
export declare const DEFAULT_FILE_VIEWER_PPT_WORKER_PATH = "vendor/ppt/worker.mjs";
|
|
10
12
|
export declare const DEFAULT_FILE_VIEWER_PPT_FRAME_CACHE_PATH = "vendor/ppt/frame-cache.mjs";
|
|
@@ -18,11 +20,12 @@ export declare const DEFAULT_FILE_VIEWER_PDF_STANDARD_FONT_PATH = "vendor/pdf/st
|
|
|
18
20
|
export declare const DEFAULT_FILE_VIEWER_PDF_CJK_FONT_FALLBACK_PATH = "vendor/pdf/fonts/";
|
|
19
21
|
export declare const DEFAULT_FILE_VIEWER_DRAWIO_VIEWER_SCRIPT_PATH = "vendor/drawio/viewer-static.min.js";
|
|
20
22
|
export declare const DEFAULT_FILE_VIEWER_DRAWIO_ASSET_PATH = "vendor/drawio/";
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
23
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_RUNTIME_VERSION = "0.8.0";
|
|
24
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_WASM_PATH = "wasm/cad/0.8.0/";
|
|
25
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_WORKER_PATH = "wasm/cad/0.8.0/dwg-worker.js";
|
|
26
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_DWF_WASM_PATH = "wasm/cad/0.8.0/dwfv-render.wasm";
|
|
27
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_LIBREDWG_SCRIPT_PATH = "wasm/cad/0.8.0/libredwg-web.js";
|
|
28
|
+
export declare const DEFAULT_FILE_VIEWER_CAD_LIBREDWG_WASM_PATH = "wasm/cad/0.8.0/libredwg-web.wasm";
|
|
26
29
|
export declare const DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_URL = "wasm/typst/typst_ts_web_compiler_bg.wasm";
|
|
27
30
|
export declare const DEFAULT_FILE_VIEWER_TYPST_RENDERER_WASM_URL = "wasm/typst/typst_ts_renderer_bg.wasm";
|
|
28
31
|
export declare const DEFAULT_FILE_VIEWER_TYPST_FONT_ASSETS_URL = "wasm/typst/fonts/";
|
package/dist/platform/assets.js
CHANGED
|
@@ -2,8 +2,10 @@ export const DEFAULT_FILE_VIEWER_ARCHIVE_WORKER_PATH = 'vendor/libarchive/worker
|
|
|
2
2
|
export const DEFAULT_FILE_VIEWER_ARCHIVE_WASM_PATH = 'vendor/libarchive/libarchive.wasm';
|
|
3
3
|
export const DEFAULT_FILE_VIEWER_DOCX_WORKER_PATH = 'vendor/docx/docx.worker.js';
|
|
4
4
|
export const DEFAULT_FILE_VIEWER_DOCX_WORKER_JSZIP_PATH = 'vendor/docx/jszip.min.js';
|
|
5
|
+
export const DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION = '0.3.26';
|
|
5
6
|
export const DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH = 'vendor/pptx/pptx.worker.js';
|
|
6
7
|
export const DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH = 'vendor/ppt';
|
|
8
|
+
export const DEFAULT_FILE_VIEWER_PPT_RUNTIME_VERSION = '0.3.2';
|
|
7
9
|
export const DEFAULT_FILE_VIEWER_PPT_MODULE_PATH = `${DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH}/index.mjs`;
|
|
8
10
|
export const DEFAULT_FILE_VIEWER_PPT_WORKER_PATH = `${DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH}/worker.mjs`;
|
|
9
11
|
export const DEFAULT_FILE_VIEWER_PPT_FRAME_CACHE_PATH = `${DEFAULT_FILE_VIEWER_PPT_RUNTIME_PATH}/frame-cache.mjs`;
|
|
@@ -17,11 +19,12 @@ export const DEFAULT_FILE_VIEWER_PDF_STANDARD_FONT_PATH = 'vendor/pdf/standard_f
|
|
|
17
19
|
export const DEFAULT_FILE_VIEWER_PDF_CJK_FONT_FALLBACK_PATH = 'vendor/pdf/fonts/';
|
|
18
20
|
export const DEFAULT_FILE_VIEWER_DRAWIO_VIEWER_SCRIPT_PATH = 'vendor/drawio/viewer-static.min.js';
|
|
19
21
|
export const DEFAULT_FILE_VIEWER_DRAWIO_ASSET_PATH = 'vendor/drawio/';
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
22
|
+
export const DEFAULT_FILE_VIEWER_CAD_RUNTIME_VERSION = '0.8.0';
|
|
23
|
+
export const DEFAULT_FILE_VIEWER_CAD_WASM_PATH = `wasm/cad/${DEFAULT_FILE_VIEWER_CAD_RUNTIME_VERSION}/`;
|
|
24
|
+
export const DEFAULT_FILE_VIEWER_CAD_WORKER_PATH = `${DEFAULT_FILE_VIEWER_CAD_WASM_PATH}dwg-worker.js`;
|
|
25
|
+
export const DEFAULT_FILE_VIEWER_CAD_DWF_WASM_PATH = `${DEFAULT_FILE_VIEWER_CAD_WASM_PATH}dwfv-render.wasm`;
|
|
26
|
+
export const DEFAULT_FILE_VIEWER_CAD_LIBREDWG_SCRIPT_PATH = `${DEFAULT_FILE_VIEWER_CAD_WASM_PATH}libredwg-web.js`;
|
|
27
|
+
export const DEFAULT_FILE_VIEWER_CAD_LIBREDWG_WASM_PATH = `${DEFAULT_FILE_VIEWER_CAD_WASM_PATH}libredwg-web.wasm`;
|
|
25
28
|
export const DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_URL = 'wasm/typst/typst_ts_web_compiler_bg.wasm';
|
|
26
29
|
export const DEFAULT_FILE_VIEWER_TYPST_RENDERER_WASM_URL = 'wasm/typst/typst_ts_renderer_bg.wasm';
|
|
27
30
|
export const DEFAULT_FILE_VIEWER_TYPST_FONT_ASSETS_URL = 'wasm/typst/fonts/';
|
|
@@ -402,6 +405,42 @@ export const DEFAULT_FILE_VIEWER_RENDERER_ASSET_MANIFESTS = [
|
|
|
402
405
|
defaultPath: DEFAULT_FILE_VIEWER_CAD_LIBREDWG_WASM_PATH,
|
|
403
406
|
description: 'LibreDWG WebAssembly runtime loaded by the CAD DWG worker for offline parsing.',
|
|
404
407
|
},
|
|
408
|
+
{
|
|
409
|
+
id: 'cad-legacy-dwg-worker',
|
|
410
|
+
rendererId: 'cad',
|
|
411
|
+
kind: 'worker',
|
|
412
|
+
target: 'public',
|
|
413
|
+
required: false,
|
|
414
|
+
defaultPath: 'wasm/cad/dwg-worker.js',
|
|
415
|
+
description: 'Unversioned compatibility alias for deployments that explicitly configured the former DWG worker path.',
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
id: 'cad-legacy-dwf-wasm',
|
|
419
|
+
rendererId: 'cad',
|
|
420
|
+
kind: 'wasm',
|
|
421
|
+
target: 'public',
|
|
422
|
+
required: false,
|
|
423
|
+
defaultPath: 'wasm/cad/dwfv-render.wasm',
|
|
424
|
+
description: 'Unversioned compatibility alias for deployments that explicitly configured the former DWF runtime path.',
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: 'cad-legacy-libredwg-script',
|
|
428
|
+
rendererId: 'cad',
|
|
429
|
+
kind: 'script',
|
|
430
|
+
target: 'public',
|
|
431
|
+
required: false,
|
|
432
|
+
defaultPath: 'wasm/cad/libredwg-web.js',
|
|
433
|
+
description: 'Unversioned compatibility alias for the former LibreDWG JavaScript runtime path.',
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: 'cad-legacy-libredwg-wasm',
|
|
437
|
+
rendererId: 'cad',
|
|
438
|
+
kind: 'wasm',
|
|
439
|
+
target: 'public',
|
|
440
|
+
required: false,
|
|
441
|
+
defaultPath: 'wasm/cad/libredwg-web.wasm',
|
|
442
|
+
description: 'Unversioned compatibility alias for the former LibreDWG WebAssembly runtime path.',
|
|
443
|
+
},
|
|
405
444
|
],
|
|
406
445
|
},
|
|
407
446
|
{
|
|
@@ -632,17 +671,22 @@ export const resolveFileViewerArchiveWasmUrl = (options, fallback = '', document
|
|
|
632
671
|
});
|
|
633
672
|
};
|
|
634
673
|
export const resolveFileViewerCadAssetUrls = (options, documentBaseUrl) => {
|
|
674
|
+
const workerUrl = resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.workerUrl, DEFAULT_FILE_VIEWER_CAD_WORKER_PATH, { documentBaseUrl });
|
|
675
|
+
const dwfWasmUrl = resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.dwfWasmUrl, DEFAULT_FILE_VIEWER_CAD_DWF_WASM_PATH, { documentBaseUrl });
|
|
676
|
+
const versionDefaultRuntimeAsset = (url, overridden) => {
|
|
677
|
+
if (overridden) {
|
|
678
|
+
return url;
|
|
679
|
+
}
|
|
680
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
681
|
+
return `${url}${separator}file-viewer-cad=${encodeURIComponent(DEFAULT_FILE_VIEWER_CAD_RUNTIME_VERSION)}`;
|
|
682
|
+
};
|
|
635
683
|
return {
|
|
636
684
|
wasmPath: resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.wasmPath, DEFAULT_FILE_VIEWER_CAD_WASM_PATH, {
|
|
637
685
|
documentBaseUrl,
|
|
638
686
|
trimTrailingSlash: true,
|
|
639
687
|
}),
|
|
640
|
-
workerUrl:
|
|
641
|
-
|
|
642
|
-
}),
|
|
643
|
-
dwfWasmUrl: resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.dwfWasmUrl, DEFAULT_FILE_VIEWER_CAD_DWF_WASM_PATH, {
|
|
644
|
-
documentBaseUrl,
|
|
645
|
-
}),
|
|
688
|
+
workerUrl: versionDefaultRuntimeAsset(workerUrl, Boolean(options === null || options === void 0 ? void 0 : options.workerUrl)),
|
|
689
|
+
dwfWasmUrl: versionDefaultRuntimeAsset(dwfWasmUrl, Boolean(options === null || options === void 0 ? void 0 : options.dwfWasmUrl)),
|
|
646
690
|
};
|
|
647
691
|
};
|
|
648
692
|
export const resolveFileViewerPdfAssetUrls = (options, documentBaseUrl) => {
|
|
@@ -668,12 +712,22 @@ export const resolveFileViewerDrawioViewerScriptUrl = (options, documentBaseUrl)
|
|
|
668
712
|
return resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.viewerScriptUrl, DEFAULT_FILE_VIEWER_DRAWIO_VIEWER_SCRIPT_PATH, { documentBaseUrl });
|
|
669
713
|
};
|
|
670
714
|
export const resolveFileViewerDocxWorkerUrl = (options, documentBaseUrl) => {
|
|
671
|
-
|
|
715
|
+
const resolved = resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.workerUrl, DEFAULT_FILE_VIEWER_DOCX_WORKER_PATH, {
|
|
672
716
|
documentBaseUrl,
|
|
673
717
|
});
|
|
718
|
+
if (options === null || options === void 0 ? void 0 : options.workerUrl) {
|
|
719
|
+
return resolved;
|
|
720
|
+
}
|
|
721
|
+
const separator = resolved.includes('?') ? '&' : '?';
|
|
722
|
+
return `${resolved}${separator}file-viewer-docx=${encodeURIComponent(DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION)}`;
|
|
674
723
|
};
|
|
675
724
|
export const resolveFileViewerDocxWorkerJsZipUrl = (options, documentBaseUrl) => {
|
|
676
|
-
|
|
725
|
+
const resolved = resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.workerJsZipUrl, DEFAULT_FILE_VIEWER_DOCX_WORKER_JSZIP_PATH, { documentBaseUrl });
|
|
726
|
+
if (options === null || options === void 0 ? void 0 : options.workerJsZipUrl) {
|
|
727
|
+
return resolved;
|
|
728
|
+
}
|
|
729
|
+
const separator = resolved.includes('?') ? '&' : '?';
|
|
730
|
+
return `${resolved}${separator}file-viewer-docx=${encodeURIComponent(DEFAULT_FILE_VIEWER_DOCX_RUNTIME_VERSION)}`;
|
|
677
731
|
};
|
|
678
732
|
export const resolveFileViewerSpreadsheetWorkerUrl = (options, documentBaseUrl) => {
|
|
679
733
|
return resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.workerUrl, DEFAULT_FILE_VIEWER_SPREADSHEET_WORKER_PATH, {
|
|
@@ -147,15 +147,22 @@ const appendStyleElement = (target, css) => {
|
|
|
147
147
|
target.appendChild(style);
|
|
148
148
|
return style;
|
|
149
149
|
};
|
|
150
|
-
const
|
|
150
|
+
const getConstructableStyleSheet = (root) => {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
const constructor = (_b = (_a = root.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.CSSStyleSheet) !== null && _b !== void 0 ? _b : (typeof CSSStyleSheet !== 'undefined' ? CSSStyleSheet : undefined);
|
|
151
153
|
return 'adoptedStyleSheets' in root &&
|
|
152
|
-
|
|
153
|
-
typeof
|
|
154
|
+
constructor &&
|
|
155
|
+
typeof constructor.prototype.replaceSync === 'function'
|
|
156
|
+
? constructor
|
|
157
|
+
: null;
|
|
154
158
|
};
|
|
155
159
|
export const appendFileViewerStyle = (target, css, options = {}) => {
|
|
156
160
|
const shadowRoot = getFileViewerShadowRootForNode(target);
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
const StyleSheet = shadowRoot ? getConstructableStyleSheet(shadowRoot) : null;
|
|
162
|
+
if (options.adoptedStyleSheet && shadowRoot && StyleSheet) {
|
|
163
|
+
// Use the target document's constructor. A stylesheet constructed in the
|
|
164
|
+
// parent window cannot be adopted by a ShadowRoot owned by an iframe.
|
|
165
|
+
const sheet = new StyleSheet();
|
|
159
166
|
sheet.replaceSync(css);
|
|
160
167
|
shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, sheet];
|
|
161
168
|
return {
|
package/dist/viewer/state.js
CHANGED
|
@@ -19,9 +19,19 @@ export const DEFAULT_FILE_VIEWER_STATE_THEME = Object.freeze({
|
|
|
19
19
|
hint: '正在整理内容结构并生成预览。',
|
|
20
20
|
});
|
|
21
21
|
export const DEFAULT_FILE_VIEWER_UNSUPPORTED_DESCRIPTION = '支持 Office、PDF、OFD、Typst、压缩包、邮件、OLB/DRA、CAD、地理数据、3D 模型、Excalidraw、draw.io、EPUB、UMD、Markdown、代码/文本、图片、音视频、字体和数据资产的在线预览';
|
|
22
|
-
const extensionLabel = (extension) => {
|
|
22
|
+
const extensionLabel = (extension, i18n) => {
|
|
23
23
|
const normalized = normalizeFileExtension(extension);
|
|
24
|
-
|
|
24
|
+
if (normalized) {
|
|
25
|
+
return `.${normalized}`;
|
|
26
|
+
}
|
|
27
|
+
const locale = resolveFileViewerLocale(i18n);
|
|
28
|
+
if (locale === 'zh-CN') {
|
|
29
|
+
return '当前文件';
|
|
30
|
+
}
|
|
31
|
+
if (locale === 'ja-JP') {
|
|
32
|
+
return '現在のファイル';
|
|
33
|
+
}
|
|
34
|
+
return 'current file';
|
|
25
35
|
};
|
|
26
36
|
const rendererPackageById = {
|
|
27
37
|
'office-word-openxml': '@file-viewer/renderer-word',
|
|
@@ -159,14 +169,16 @@ export const createFileViewerEmptyState = (extension = '', theme = DEFAULT_FILE_
|
|
|
159
169
|
recoverable: true,
|
|
160
170
|
});
|
|
161
171
|
export const createFileViewerUnsupportedState = (extension = '', theme = DEFAULT_FILE_VIEWER_STATE_THEME, i18n) => {
|
|
162
|
-
const label = extensionLabel(extension);
|
|
172
|
+
const label = extensionLabel(extension, i18n);
|
|
163
173
|
const installHint = resolveFileViewerRendererInstallHint(extension);
|
|
164
174
|
if (installHint) {
|
|
165
175
|
const locale = resolveFileViewerLocale(i18n);
|
|
166
176
|
const localeRendererTip = installHint.rendererPackage
|
|
167
177
|
? locale === 'zh-CN'
|
|
168
178
|
? `;如果需要极致裁剪,也可以只安装 ${installHint.rendererPackage}`
|
|
169
|
-
:
|
|
179
|
+
: locale === 'ja-JP'
|
|
180
|
+
? `;厳密に最小構成へ絞る場合は ${installHint.rendererPackage} のみをインストールすることもできます`
|
|
181
|
+
: `; for a strict custom cut, install only ${installHint.rendererPackage}`
|
|
170
182
|
: '';
|
|
171
183
|
return createFileViewerStateDescriptor({
|
|
172
184
|
state: 'unsupported',
|
|
@@ -258,9 +270,9 @@ export const formatFileViewerErrorMessage = (prefix, error, i18n) => {
|
|
|
258
270
|
if (!detail) {
|
|
259
271
|
return prefix;
|
|
260
272
|
}
|
|
261
|
-
return resolveFileViewerLocale(i18n) === '
|
|
262
|
-
? `${prefix}
|
|
263
|
-
: `${prefix}
|
|
273
|
+
return resolveFileViewerLocale(i18n) === 'en-US'
|
|
274
|
+
? `${prefix}: ${detail}`
|
|
275
|
+
: `${prefix}:${detail}`;
|
|
264
276
|
};
|
|
265
277
|
export const createFileViewerErrorState = (extension = '', error = undefined, theme = DEFAULT_FILE_VIEWER_STATE_THEME, i18n) => createFileViewerStateDescriptor({
|
|
266
278
|
state: 'error',
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Framework-neutral modular TypeScript core for
|
|
6
|
+
"description": "Framework-neutral modular TypeScript core for File Viewer renderer orchestration, lifecycle APIs, search, zoom, print, and export",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"file-viewer",
|
|
9
9
|
"document-preview",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"registry": "https://registry.npmjs.org/"
|
|
23
23
|
},
|
|
24
24
|
"author": {
|
|
25
|
-
"name": "
|
|
26
|
-
"email": "
|
|
25
|
+
"name": "Yu Wang",
|
|
26
|
+
"email": "admin@flyfish.dev"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|