@file-viewer/core 2.1.15 → 2.1.17
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/contracts/types.d.ts +6 -1
- package/dist/i18n/messages.js +10 -0
- package/dist/lifecycle/operations.js +3 -0
- package/dist/output/export.js +1 -0
- package/dist/platform/assets.d.ts +4 -2
- package/dist/platform/assets.js +28 -5
- package/dist/rendering/handler.js +3 -0
- package/dist/viewer/createViewer.js +180 -17
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type FileViewerSourceKind = 'file' | 'url' | 'buffer' | 'empty';
|
|
2
2
|
export type FileViewerThemeMode = 'light' | 'dark' | 'system';
|
|
3
3
|
export type FileViewerLocale = 'auto' | 'zh-CN' | 'en-US' | (string & {});
|
|
4
|
-
export type FileViewerMessageKey = 'toolbar.zoomGroup' | 'toolbar.zoomOut' | 'toolbar.zoomIn' | 'toolbar.zoomReset' | 'toolbar.download' | 'toolbar.downloadTitle' | 'toolbar.print' | 'toolbar.printTitle' | 'toolbar.exportHtml' | 'toolbar.exportHtmlTitle' | 'state.ready.title' | 'state.ready.message' | 'state.empty.title' | 'state.empty.message' | 'state.unsupported.install.title' | 'state.unsupported.install.message' | 'state.unsupported.install.description' | 'state.unsupported.title' | 'state.unsupported.message' | 'state.unsupported.description' | 'state.error.title' | 'preview.downloading' | 'preview.streamingPdf' | 'preview.reading' | 'error.download' | 'error.print' | 'error.exportHtml' | 'error.noDownloadSource' | 'error.noExportContent' | 'error.printUnavailable' | 'error.printWindowBlocked' | 'error.remoteDownload' | 'error.localRead' | 'error.load' | 'error.stream' | 'error.beforeOperation' | 'operation.download' | 'operation.print' | 'operation.exportHtml' | 'operation.zoomIn' | 'operation.zoomOut' | 'operation.zoomReset' | 'pdf.toolbar.toggleNavigation' | 'pdf.toolbar.previousPage' | 'pdf.toolbar.nextPage' | 'pdf.toolbar.fitWidth' | 'pdf.toolbar.zoomOut' | 'pdf.toolbar.zoomIn' | 'pdf.toolbar.rotateLeft' | 'pdf.toolbar.rotateRight' | 'pdf.nav.typeLabel' | 'pdf.nav.pagesTab' | 'pdf.nav.outlineTab' | 'pdf.nav.pagesTitle' | 'pdf.nav.outlineTitle' | 'pdf.nav.pageCount' | 'pdf.nav.itemCount' | 'pdf.nav.pageLabel' | 'pdf.nav.outlineEmpty' | 'pdf.nav.outlineFallbackTitle' | 'pdf.thumbnail.alt' | 'pdf.state.loading' | 'pdf.error.browserWindow' | 'pdf.error.missingSource' | 'pdf.error.loadFailed' | 'pdf.error.notLoaded' | 'pdf.error.unloaded' | 'pdf.error.canvasUnavailable' | 'pdf.export.pageTitle' | 'spreadsheet.loading.kicker' | 'spreadsheet.loading.title' | 'spreadsheet.loading.hint' | 'spreadsheet.loading.streaming' | 'spreadsheet.tabs.ariaLabel' | 'spreadsheet.state.parsingWorkbook' | 'spreadsheet.state.preparingSheet' | 'spreadsheet.state.preparingSheetNamed' | 'spreadsheet.state.cachedRows' | 'spreadsheet.state.rows' | 'spreadsheet.state.rowsAndColumns' | 'spreadsheet.error.parseFailed' | 'spreadsheet.error.workerFailed' | 'archive.error.nestedUnsupported' | 'archive.loading.readingDirectory' | 'archive.loading.readingDirectoryHint' | 'archive.search.placeholder' | 'archive.sidebar.hide' | 'archive.sidebar.show' | 'archive.preview.title' | 'archive.preview.chooseFile' | 'archive.preview.downloadFile' | 'archive.error.title' | 'archive.stats.summary' | 'archive.warning.encrypted' | 'archive.password.title' | 'archive.password.description' | 'archive.password.placeholder' | 'archive.password.invalid' | 'archive.password.required' | 'archive.password.cancel' | 'archive.password.confirm' | 'archive.error.passwordRequired' | 'archive.error.encryptedRequiresWorker' | 'archive.empty.title' | 'archive.empty.message' | 'archive.loading.initializingCandidate' | 'archive.loading.initializingCandidateHint' | 'archive.error.candidateInitTimeout' | 'archive.error.encryptedCheckTimeout' | 'archive.loading.directoryReadyHint' | 'archive.error.candidateReadTimeout' | 'archive.loading.workerFallback' | 'archive.loading.workerFallbackHint' | 'archive.notice.workerFallback' | 'archive.error.tooLarge' | 'archive.loading.initializingWorker' | 'archive.loading.initializingWorkerHint' | 'archive.error.workerInitFailed' | 'archive.error.entryTooLarge' | 'archive.loading.extracting' | 'archive.loading.rendering' | 'archive.loading.exporting' | 'media.audio.title' | 'media.audio.description' | 'media.audio.unsupported' | 'media.video.title' | 'media.video.unsupported' | 'media.video.hlsHint' | 'media.midi.title' | 'media.midi.loading' | 'media.midi.trackHeader' | 'media.midi.instrumentHeader' | 'media.midi.channelHeader' | 'media.midi.noteCountHeader' | 'media.midi.durationHeader' | 'media.midi.durationStat' | 'media.midi.trackStat' | 'media.midi.noteStat' | 'media.midi.parseFailed' | 'email.mbox.subject' | 'email.mbox.summary' | 'email.error.title' | 'email.meta.from' | 'email.meta.to' | 'email.meta.cc' | 'email.meta.date' | 'email.tabs.text' | 'email.tabs.headers' | 'email.attachments.title' | 'email.attachments.empty' | 'email.attachments.download' | 'email.attachments.opening' | 'email.attachments.nestedUnavailable' | 'email.loading.parsing' | 'data.font.sample' | 'data.error.fontFaceUnsupported' | 'data.title.font' | 'data.title.sqlite' | 'data.title.parquet' | 'data.title.avro' | 'data.title.wasm' | 'data.title.eps' | 'data.title.ai' | 'data.title.webarchive' | 'data.title.summary' | 'data.label.format' | 'data.label.size' | 'data.label.rendering' | 'data.label.objects' | 'data.label.sampleTable' | 'data.label.rows' | 'data.label.columns' | 'data.label.sampleRows' | 'data.label.imports' | 'data.label.exports' | 'data.label.magic' | 'data.label.note' | 'data.label.container' | 'data.value.schemaRead' | 'data.value.schemaUnread' | 'data.note.aiSummary' | 'data.note.postscriptSummary' | 'data.note.webarchive' | 'data.image.alt' | 'psd.title' | 'psd.action.fit' | 'psd.action.showAll' | 'psd.action.hideAll' | 'psd.layers.title' | 'psd.layers.redrawable' | 'psd.layers.empty' | 'psd.layers.hidden' | 'drawing.error.viewerLoadFailed' | 'drawing.error.excalidrawEmpty' | 'drawing.error.excalidrawTimeout' | 'drawing.error.drawioParseFailed' | 'drawing.error.drawioNoModel' | 'drawing.error.drawioNoElements' | 'drawing.error.viewerInitFailed' | 'drawing.error.drawioTimeout' | 'drawing.error.svgParseFailed' | 'drawing.error.plantumlRenderFailed' | 'drawing.title.excalidraw' | 'drawing.title.mermaid' | 'drawing.title.plantuml' | 'drawing.title.drawio' | 'drawing.toolbar.zoomOut' | 'drawing.toolbar.zoomIn' | 'drawing.toolbar.fit' | 'drawing.toolbar.fitWidth' | 'drawing.state.loading' | 'text.code.loadingHighlight' | 'ebook.toc' | 'ebook.reading' | 'ebook.itemCount' | 'epub.title' | 'epub.previousPage' | 'epub.nextPage' | 'epub.loading' | 'epub.chapterFallback' | 'epub.renderIncomplete' | 'umd.title' | 'umd.previousChapter' | 'umd.nextChapter' | 'umd.loading' | 'umd.emptyContent' | 'umd.chapterFallback' | 'umd.galleryFallback' | 'umd.warningBodyTooShort' | 'umd.error.unexpectedEnd' | 'umd.error.invalidFile' | 'typst.summaryRenderer' | 'typst.pageSummary.empty' | 'typst.pageSummary.ready' | 'typst.status.compiling' | 'typst.status.failed' | 'typst.status.rendered' | 'typst.loading.title' | 'typst.loading.hint' | 'typst.error.title' | 'typst.error.timeout' | 'typst.error.timeoutHint' | 'typst.error.assetHint' | 'typst.error.svgParseFailed' | 'typst.error.wasmLoadFailed' | 'xmind.toolbar.zoomOut' | 'xmind.toolbar.zoomIn' | 'xmind.toolbar.fit' | 'xmind.toolbar.fitTitle' | 'xmind.state.loading' | 'xmind.stats.nodes' | 'xmind.stats.depth' | 'xmind.stats.theme' | 'xmind.stats.template' | 'xmind.badge.paused' | 'xmind.badge.collapsed' | 'xmind.badge.floating' | 'xmind.badge.summary' | 'xmind.badge.callout' | 'xmind.imageResource' | 'xmind.error.unrecognized' | 'xmind.error.noCanvas' | 'cad.toolbar.fit' | 'cad.toolbar.zoomOut' | 'cad.toolbar.zoomIn' | 'cad.layers.title' | 'cad.layers.count' | 'cad.inspector.title' | 'cad.inspector.entities' | 'cad.inspector.blocks' | 'cad.inspector.pages' | 'cad.inspector.drawn' | 'cad.state.loadingViewer' | 'cad.state.parsing' | 'cad.error.parseFailed' | 'image.alt' | 'image.lightbox.alt' | 'image.lightbox.close' | 'gitBundle.error.invalid' | 'gitBundle.error.missingPack' | 'gitBundle.notice.delta' | 'gitBundle.title.history' | 'gitBundle.title.fileTree' | 'gitBundle.file.choose' | 'gitBundle.file.noTree' | 'gitBundle.file.none' | 'gitBundle.history.empty' | 'gitBundle.toolbar.summary' | 'gitBundle.meta.bundle' | 'gitBundle.meta.refs' | 'gitBundle.meta.commits' | 'gitBundle.meta.objects' | 'gitBundle.meta.deltas' | 'gitBundle.meta.objectFormat' | 'gitBundle.meta.objectTypes' | 'geo.error.unrecognized' | 'geo.error.xmlParseFailed' | 'geo.error.unsupported' | 'geo.title' | 'geo.featureCount' | 'geo.bounds' | 'geo.geometryTypes' | 'geo.aria' | 'geo.loading' | 'geo.projection' | 'geo.engine' | 'geo.basemap' | 'geo.basemap.offline' | 'geo.basemap.custom' | 'geo.engine.maplibre' | 'geo.engine.svg' | 'geo.error.projection' | 'geo.action.fit' | 'model.toolbar.fit' | 'model.toolbar.rotate' | 'model.toolbar.wireframe' | 'model.toolbar.grid' | 'model.toolbar.axes' | 'model.state.loadingSummary' | 'model.state.loading' | 'model.state.loaded' | 'model.state.parseFailed' | 'model.summary.meshes' | 'model.summary.points' | 'model.error.daeEmpty' | 'model.error.unsupported' | 'model.error.parseFailed' | 'model.notice.signature' | 'loading.generic.label' | 'loading.generic.hint' | 'loading.word.label' | 'loading.word.hint' | 'loading.wordWorker.hint' | 'loading.sheet.label' | 'loading.sheet.hint' | 'loading.csv.label' | 'loading.csv.hint' | 'loading.presentation.label' | 'loading.presentation.hint' | 'loading.pdf.label' | 'loading.pdf.hint' | 'loading.ofd.label' | 'loading.ofd.hint' | 'loading.archive.label' | 'loading.archive.hint' | 'loading.email.label' | 'loading.email.hint' | 'loading.msg.hint' | 'loading.eda.label' | 'loading.eda.hint' | 'loading.cad.label' | 'loading.cad.hint' | 'loading.dwg.hint' | 'loading.dwf.hint' | 'loading.dwfx.hint' | 'loading.xps.hint' | 'loading.drawio.label' | 'loading.drawio.hint' | 'loading.excalidraw.label' | 'loading.excalidraw.hint' | 'loading.epub.label' | 'loading.epub.hint' | 'loading.umd.label' | 'loading.umd.hint' | 'loading.image.label' | 'loading.image.hint' | 'loading.video.label' | 'loading.video.hint' | 'loading.audio.label' | 'loading.audio.hint';
|
|
4
|
+
export type FileViewerMessageKey = 'toolbar.zoomGroup' | 'toolbar.zoomOut' | 'toolbar.zoomIn' | 'toolbar.zoomReset' | 'toolbar.download' | 'toolbar.downloadTitle' | 'toolbar.print' | 'toolbar.printTitle' | 'toolbar.exportHtml' | 'toolbar.exportHtmlTitle' | 'toolbar.search' | 'toolbar.searchPlaceholder' | 'toolbar.searchPrevious' | 'toolbar.searchNext' | 'toolbar.searchClear' | 'state.ready.title' | 'state.ready.message' | 'state.empty.title' | 'state.empty.message' | 'state.unsupported.install.title' | 'state.unsupported.install.message' | 'state.unsupported.install.description' | 'state.unsupported.title' | 'state.unsupported.message' | 'state.unsupported.description' | 'state.error.title' | 'preview.downloading' | 'preview.streamingPdf' | 'preview.reading' | 'error.download' | 'error.print' | 'error.exportHtml' | 'error.noDownloadSource' | 'error.noExportContent' | 'error.printUnavailable' | 'error.printWindowBlocked' | 'error.remoteDownload' | 'error.localRead' | 'error.load' | 'error.stream' | 'error.beforeOperation' | 'operation.download' | 'operation.print' | 'operation.exportHtml' | 'operation.zoomIn' | 'operation.zoomOut' | 'operation.zoomReset' | 'pdf.toolbar.toggleNavigation' | 'pdf.toolbar.previousPage' | 'pdf.toolbar.nextPage' | 'pdf.toolbar.fitWidth' | 'pdf.toolbar.zoomOut' | 'pdf.toolbar.zoomIn' | 'pdf.toolbar.rotateLeft' | 'pdf.toolbar.rotateRight' | 'pdf.nav.typeLabel' | 'pdf.nav.pagesTab' | 'pdf.nav.outlineTab' | 'pdf.nav.pagesTitle' | 'pdf.nav.outlineTitle' | 'pdf.nav.pageCount' | 'pdf.nav.itemCount' | 'pdf.nav.pageLabel' | 'pdf.nav.outlineEmpty' | 'pdf.nav.outlineFallbackTitle' | 'pdf.thumbnail.alt' | 'pdf.state.loading' | 'pdf.error.browserWindow' | 'pdf.error.missingSource' | 'pdf.error.loadFailed' | 'pdf.error.notLoaded' | 'pdf.error.unloaded' | 'pdf.error.canvasUnavailable' | 'pdf.export.pageTitle' | 'spreadsheet.loading.kicker' | 'spreadsheet.loading.title' | 'spreadsheet.loading.hint' | 'spreadsheet.loading.streaming' | 'spreadsheet.tabs.ariaLabel' | 'spreadsheet.state.parsingWorkbook' | 'spreadsheet.state.preparingSheet' | 'spreadsheet.state.preparingSheetNamed' | 'spreadsheet.state.cachedRows' | 'spreadsheet.state.rows' | 'spreadsheet.state.rowsAndColumns' | 'spreadsheet.error.parseFailed' | 'spreadsheet.error.workerFailed' | 'archive.error.nestedUnsupported' | 'archive.loading.readingDirectory' | 'archive.loading.readingDirectoryHint' | 'archive.search.placeholder' | 'archive.sidebar.hide' | 'archive.sidebar.show' | 'archive.preview.title' | 'archive.preview.chooseFile' | 'archive.preview.downloadFile' | 'archive.error.title' | 'archive.stats.summary' | 'archive.warning.encrypted' | 'archive.password.title' | 'archive.password.description' | 'archive.password.placeholder' | 'archive.password.invalid' | 'archive.password.required' | 'archive.password.cancel' | 'archive.password.confirm' | 'archive.error.passwordRequired' | 'archive.error.encryptedRequiresWorker' | 'archive.empty.title' | 'archive.empty.message' | 'archive.loading.initializingCandidate' | 'archive.loading.initializingCandidateHint' | 'archive.error.candidateInitTimeout' | 'archive.error.encryptedCheckTimeout' | 'archive.loading.directoryReadyHint' | 'archive.error.candidateReadTimeout' | 'archive.loading.workerFallback' | 'archive.loading.workerFallbackHint' | 'archive.notice.workerFallback' | 'archive.error.tooLarge' | 'archive.loading.initializingWorker' | 'archive.loading.initializingWorkerHint' | 'archive.error.workerInitFailed' | 'archive.error.entryTooLarge' | 'archive.loading.extracting' | 'archive.loading.rendering' | 'archive.loading.exporting' | 'media.audio.title' | 'media.audio.description' | 'media.audio.unsupported' | 'media.video.title' | 'media.video.unsupported' | 'media.video.hlsHint' | 'media.midi.title' | 'media.midi.loading' | 'media.midi.trackHeader' | 'media.midi.instrumentHeader' | 'media.midi.channelHeader' | 'media.midi.noteCountHeader' | 'media.midi.durationHeader' | 'media.midi.durationStat' | 'media.midi.trackStat' | 'media.midi.noteStat' | 'media.midi.parseFailed' | 'email.mbox.subject' | 'email.mbox.summary' | 'email.error.title' | 'email.meta.from' | 'email.meta.to' | 'email.meta.cc' | 'email.meta.date' | 'email.tabs.text' | 'email.tabs.headers' | 'email.attachments.title' | 'email.attachments.empty' | 'email.attachments.download' | 'email.attachments.opening' | 'email.attachments.nestedUnavailable' | 'email.loading.parsing' | 'data.font.sample' | 'data.error.fontFaceUnsupported' | 'data.title.font' | 'data.title.sqlite' | 'data.title.parquet' | 'data.title.avro' | 'data.title.wasm' | 'data.title.eps' | 'data.title.ai' | 'data.title.webarchive' | 'data.title.summary' | 'data.label.format' | 'data.label.size' | 'data.label.rendering' | 'data.label.objects' | 'data.label.sampleTable' | 'data.label.rows' | 'data.label.columns' | 'data.label.sampleRows' | 'data.label.imports' | 'data.label.exports' | 'data.label.magic' | 'data.label.note' | 'data.label.container' | 'data.value.schemaRead' | 'data.value.schemaUnread' | 'data.note.aiSummary' | 'data.note.postscriptSummary' | 'data.note.webarchive' | 'data.image.alt' | 'psd.title' | 'psd.action.fit' | 'psd.action.showAll' | 'psd.action.hideAll' | 'psd.layers.title' | 'psd.layers.redrawable' | 'psd.layers.empty' | 'psd.layers.hidden' | 'drawing.error.viewerLoadFailed' | 'drawing.error.excalidrawEmpty' | 'drawing.error.excalidrawTimeout' | 'drawing.error.drawioParseFailed' | 'drawing.error.drawioNoModel' | 'drawing.error.drawioNoElements' | 'drawing.error.viewerInitFailed' | 'drawing.error.drawioTimeout' | 'drawing.error.svgParseFailed' | 'drawing.error.plantumlRenderFailed' | 'drawing.title.excalidraw' | 'drawing.title.mermaid' | 'drawing.title.plantuml' | 'drawing.title.drawio' | 'drawing.toolbar.zoomOut' | 'drawing.toolbar.zoomIn' | 'drawing.toolbar.fit' | 'drawing.toolbar.fitWidth' | 'drawing.state.loading' | 'text.code.loadingHighlight' | 'ebook.toc' | 'ebook.reading' | 'ebook.itemCount' | 'epub.title' | 'epub.previousPage' | 'epub.nextPage' | 'epub.loading' | 'epub.chapterFallback' | 'epub.renderIncomplete' | 'umd.title' | 'umd.previousChapter' | 'umd.nextChapter' | 'umd.loading' | 'umd.emptyContent' | 'umd.chapterFallback' | 'umd.galleryFallback' | 'umd.warningBodyTooShort' | 'umd.error.unexpectedEnd' | 'umd.error.invalidFile' | 'typst.summaryRenderer' | 'typst.pageSummary.empty' | 'typst.pageSummary.ready' | 'typst.status.compiling' | 'typst.status.failed' | 'typst.status.rendered' | 'typst.loading.title' | 'typst.loading.hint' | 'typst.error.title' | 'typst.error.timeout' | 'typst.error.timeoutHint' | 'typst.error.assetHint' | 'typst.error.svgParseFailed' | 'typst.error.wasmLoadFailed' | 'xmind.toolbar.zoomOut' | 'xmind.toolbar.zoomIn' | 'xmind.toolbar.fit' | 'xmind.toolbar.fitTitle' | 'xmind.state.loading' | 'xmind.stats.nodes' | 'xmind.stats.depth' | 'xmind.stats.theme' | 'xmind.stats.template' | 'xmind.badge.paused' | 'xmind.badge.collapsed' | 'xmind.badge.floating' | 'xmind.badge.summary' | 'xmind.badge.callout' | 'xmind.imageResource' | 'xmind.error.unrecognized' | 'xmind.error.noCanvas' | 'cad.toolbar.fit' | 'cad.toolbar.zoomOut' | 'cad.toolbar.zoomIn' | 'cad.layers.title' | 'cad.layers.count' | 'cad.inspector.title' | 'cad.inspector.entities' | 'cad.inspector.blocks' | 'cad.inspector.pages' | 'cad.inspector.drawn' | 'cad.state.loadingViewer' | 'cad.state.parsing' | 'cad.error.parseFailed' | 'image.alt' | 'image.lightbox.alt' | 'image.lightbox.close' | 'gitBundle.error.invalid' | 'gitBundle.error.missingPack' | 'gitBundle.notice.delta' | 'gitBundle.title.history' | 'gitBundle.title.fileTree' | 'gitBundle.file.choose' | 'gitBundle.file.noTree' | 'gitBundle.file.none' | 'gitBundle.history.empty' | 'gitBundle.toolbar.summary' | 'gitBundle.meta.bundle' | 'gitBundle.meta.refs' | 'gitBundle.meta.commits' | 'gitBundle.meta.objects' | 'gitBundle.meta.deltas' | 'gitBundle.meta.objectFormat' | 'gitBundle.meta.objectTypes' | 'geo.error.unrecognized' | 'geo.error.xmlParseFailed' | 'geo.error.unsupported' | 'geo.title' | 'geo.featureCount' | 'geo.bounds' | 'geo.geometryTypes' | 'geo.aria' | 'geo.loading' | 'geo.projection' | 'geo.engine' | 'geo.basemap' | 'geo.basemap.offline' | 'geo.basemap.custom' | 'geo.engine.maplibre' | 'geo.engine.svg' | 'geo.error.projection' | 'geo.action.fit' | 'model.toolbar.fit' | 'model.toolbar.rotate' | 'model.toolbar.wireframe' | 'model.toolbar.grid' | 'model.toolbar.axes' | 'model.state.loadingSummary' | 'model.state.loading' | 'model.state.loaded' | 'model.state.parseFailed' | 'model.summary.meshes' | 'model.summary.points' | 'model.error.daeEmpty' | 'model.error.unsupported' | 'model.error.parseFailed' | 'model.notice.signature' | 'loading.generic.label' | 'loading.generic.hint' | 'loading.word.label' | 'loading.word.hint' | 'loading.wordWorker.hint' | 'loading.sheet.label' | 'loading.sheet.hint' | 'loading.csv.label' | 'loading.csv.hint' | 'loading.presentation.label' | 'loading.presentation.hint' | 'loading.pdf.label' | 'loading.pdf.hint' | 'loading.ofd.label' | 'loading.ofd.hint' | 'loading.archive.label' | 'loading.archive.hint' | 'loading.email.label' | 'loading.email.hint' | 'loading.msg.hint' | 'loading.eda.label' | 'loading.eda.hint' | 'loading.cad.label' | 'loading.cad.hint' | 'loading.dwg.hint' | 'loading.dwf.hint' | 'loading.dwfx.hint' | 'loading.xps.hint' | 'loading.drawio.label' | 'loading.drawio.hint' | 'loading.excalidraw.label' | 'loading.excalidraw.hint' | 'loading.epub.label' | 'loading.epub.hint' | 'loading.umd.label' | 'loading.umd.hint' | 'loading.image.label' | 'loading.image.hint' | 'loading.video.label' | 'loading.video.hint' | 'loading.audio.label' | 'loading.audio.hint';
|
|
5
5
|
export type FileViewerMessageParams = Record<string, string | number | boolean | null | undefined>;
|
|
6
6
|
export type FileViewerMessageResolver = (key: FileViewerMessageKey, params: FileViewerMessageParams, locale: FileViewerLocale) => string | undefined;
|
|
7
7
|
export type FileViewerMessages = Partial<Record<FileViewerMessageKey, string>> | FileViewerMessageResolver;
|
|
@@ -35,6 +35,7 @@ export interface FileViewerToolbarOptions {
|
|
|
35
35
|
print?: boolean;
|
|
36
36
|
exportHtml?: boolean;
|
|
37
37
|
zoom?: boolean;
|
|
38
|
+
search?: boolean;
|
|
38
39
|
/** Controls which built-in toolbar actions are displayed without disabling controller APIs. */
|
|
39
40
|
items?: FileViewerToolbarActionMap;
|
|
40
41
|
/** Hard operation permission map. False values block both built-in toolbar and public API calls. */
|
|
@@ -574,6 +575,10 @@ export interface FileViewerDocumentChunk {
|
|
|
574
575
|
export interface FileViewerComponentProps {
|
|
575
576
|
file?: FileViewerFileRef;
|
|
576
577
|
url?: string;
|
|
578
|
+
name?: string;
|
|
579
|
+
filename?: string;
|
|
580
|
+
type?: string;
|
|
581
|
+
size?: number;
|
|
577
582
|
options?: FileViewerOptions;
|
|
578
583
|
}
|
|
579
584
|
export interface FileViewerComponentEventMap {
|
package/dist/i18n/messages.js
CHANGED
|
@@ -11,6 +11,11 @@ const ZH_CN_MESSAGES = {
|
|
|
11
11
|
'toolbar.printTitle': '打印完整渲染内容',
|
|
12
12
|
'toolbar.exportHtml': 'HTML',
|
|
13
13
|
'toolbar.exportHtmlTitle': '导出当前渲染后的 HTML',
|
|
14
|
+
'toolbar.search': '搜索',
|
|
15
|
+
'toolbar.searchPlaceholder': '搜索文档',
|
|
16
|
+
'toolbar.searchPrevious': '上一个匹配',
|
|
17
|
+
'toolbar.searchNext': '下一个匹配',
|
|
18
|
+
'toolbar.searchClear': '清除搜索',
|
|
14
19
|
'state.ready.title': '预览完成',
|
|
15
20
|
'state.ready.message': '文件内容已完成渲染。',
|
|
16
21
|
'state.empty.title': '暂无文件',
|
|
@@ -383,6 +388,11 @@ const EN_US_MESSAGES = {
|
|
|
383
388
|
'toolbar.printTitle': 'Print the complete rendered document',
|
|
384
389
|
'toolbar.exportHtml': 'HTML',
|
|
385
390
|
'toolbar.exportHtmlTitle': 'Export the rendered HTML',
|
|
391
|
+
'toolbar.search': 'Search',
|
|
392
|
+
'toolbar.searchPlaceholder': 'Search document',
|
|
393
|
+
'toolbar.searchPrevious': 'Previous match',
|
|
394
|
+
'toolbar.searchNext': 'Next match',
|
|
395
|
+
'toolbar.searchClear': 'Clear search',
|
|
386
396
|
'state.ready.title': 'Preview ready',
|
|
387
397
|
'state.ready.message': 'The file has been rendered.',
|
|
388
398
|
'state.empty.title': 'No file selected',
|
|
@@ -464,6 +464,7 @@ export const normalizeFileViewerToolbar = (options) => {
|
|
|
464
464
|
print: false,
|
|
465
465
|
exportHtml: false,
|
|
466
466
|
zoom: false,
|
|
467
|
+
search: false,
|
|
467
468
|
};
|
|
468
469
|
}
|
|
469
470
|
if (toolbar && typeof toolbar === 'object') {
|
|
@@ -472,6 +473,7 @@ export const normalizeFileViewerToolbar = (options) => {
|
|
|
472
473
|
print: toolbar.print !== false && isFileViewerToolbarOperationVisible(toolbar, 'print'),
|
|
473
474
|
exportHtml: toolbar.exportHtml !== false && isFileViewerToolbarOperationVisible(toolbar, 'export-html'),
|
|
474
475
|
zoom: toolbar.zoom !== false && hasAnyToolbarZoomOperation(toolbar),
|
|
476
|
+
search: toolbar.search !== false,
|
|
475
477
|
items: toolbar.items,
|
|
476
478
|
permissions: toolbar.permissions,
|
|
477
479
|
position: toolbar.position,
|
|
@@ -486,6 +488,7 @@ export const normalizeFileViewerToolbar = (options) => {
|
|
|
486
488
|
print: true,
|
|
487
489
|
exportHtml: true,
|
|
488
490
|
zoom: true,
|
|
491
|
+
search: true,
|
|
489
492
|
};
|
|
490
493
|
};
|
|
491
494
|
export const resolveFileViewerOperationAvailability = ({ extension, hasOriginalSource, renderedReady, hasError = false, adapter, source, zoomState, }) => {
|
package/dist/output/export.js
CHANGED
|
@@ -455,6 +455,7 @@ export const buildFileViewerRenderedHtmlDocument = async ({ source, mode = 'expo
|
|
|
455
455
|
}
|
|
456
456
|
await prepareFileViewerRenderedContentForSnapshot(source, adapter);
|
|
457
457
|
const clone = source.cloneNode(true);
|
|
458
|
+
clone.querySelectorAll('.viewer-watermark').forEach(node => node.remove());
|
|
458
459
|
replaceFileViewerCanvasWithImages(source, clone);
|
|
459
460
|
const printStyle = await resolveFileViewerPrintStyle(adapter, exportOptions);
|
|
460
461
|
return buildExportHtmlDocument({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerDataOptions, FileViewerDocxOptions, FileViewerDrawingOptions, FileViewerOptions, FileViewerPdfOptions, FileViewerSpreadsheetOptions, FileViewerTypstOptions } from '../contracts/types';
|
|
1
|
+
import type { FileViewerArchiveOptions, FileViewerCadOptions, FileViewerDataOptions, FileViewerDocxOptions, FileViewerDrawingOptions, FileViewerOptions, FileViewerPdfOptions, FileViewerPresentationOptions, FileViewerSpreadsheetOptions, FileViewerTypstOptions } from '../contracts/types';
|
|
2
2
|
export declare const DEFAULT_FILE_VIEWER_ARCHIVE_WORKER_PATH = "vendor/libarchive/worker-bundle.js";
|
|
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_PRESENTATION_WORKER_PATH = "vendor/pptx/pptx.worker.js";
|
|
6
7
|
export declare const DEFAULT_FILE_VIEWER_SPREADSHEET_WORKER_PATH = "vendor/xlsx/sheet.worker.js";
|
|
7
8
|
export declare const DEFAULT_FILE_VIEWER_PDF_WORKER_PATH = "vendor/pdf/pdf.worker.mjs";
|
|
8
9
|
export declare const DEFAULT_FILE_VIEWER_PDF_CMAP_PATH = "vendor/pdf/cmaps/";
|
|
@@ -40,7 +41,7 @@ export interface ResolvedFileViewerPdfAssetUrls {
|
|
|
40
41
|
}
|
|
41
42
|
export type FileViewerRendererAssetKind = 'directory' | 'worker' | 'wasm' | 'wasm-directory' | 'script' | 'bundled-wasm';
|
|
42
43
|
export type FileViewerRendererAssetTarget = 'public' | 'bundled' | 'external';
|
|
43
|
-
export type FileViewerRendererAssetOptionPath = 'archive.workerUrl' | 'archive.wasmUrl' | 'cad.wasmPath' | 'cad.workerUrl' | 'cad.dwfWasmUrl' | 'data.sqlWasmUrl' | 'docx.workerJsZipUrl' | 'docx.workerUrl' | 'drawing.viewerScriptUrl' | 'pdf.workerUrl' | 'pdf.cMapUrl' | 'pdf.wasmUrl' | 'pdf.standardFontDataUrl' | 'spreadsheet.workerUrl' | 'typst.compilerWasmUrl' | 'typst.fontAssetsUrl' | 'typst.rendererWasmUrl';
|
|
44
|
+
export type FileViewerRendererAssetOptionPath = 'archive.workerUrl' | 'archive.wasmUrl' | 'cad.wasmPath' | 'cad.workerUrl' | 'cad.dwfWasmUrl' | 'data.sqlWasmUrl' | 'docx.workerJsZipUrl' | 'docx.workerUrl' | 'drawing.viewerScriptUrl' | 'pdf.workerUrl' | 'pdf.cMapUrl' | 'pdf.wasmUrl' | 'pdf.standardFontDataUrl' | 'presentation.workerUrl' | 'spreadsheet.workerUrl' | 'typst.compilerWasmUrl' | 'typst.fontAssetsUrl' | 'typst.rendererWasmUrl';
|
|
44
45
|
export interface FileViewerRendererAssetDefinition {
|
|
45
46
|
id: string;
|
|
46
47
|
rendererId: string;
|
|
@@ -75,6 +76,7 @@ export declare const resolveFileViewerDrawioViewerScriptUrl: (options?: Pick<Fil
|
|
|
75
76
|
export declare const resolveFileViewerDocxWorkerUrl: (options?: Pick<FileViewerDocxOptions, "workerUrl"> | null, documentBaseUrl?: string) => string;
|
|
76
77
|
export declare const resolveFileViewerDocxWorkerJsZipUrl: (options?: Pick<FileViewerDocxOptions, "workerJsZipUrl"> | null, documentBaseUrl?: string) => string;
|
|
77
78
|
export declare const resolveFileViewerSpreadsheetWorkerUrl: (options?: Pick<FileViewerSpreadsheetOptions, "workerUrl"> | null, documentBaseUrl?: string) => string;
|
|
79
|
+
export declare const resolveFileViewerPresentationWorkerUrl: (options?: Pick<FileViewerPresentationOptions, "workerUrl"> | null, documentBaseUrl?: string) => string;
|
|
78
80
|
export declare const resolveFileViewerTypstCompilerWasmUrl: (options?: Pick<FileViewerTypstOptions, "compilerWasmUrl"> | null, overrides?: Array<string | undefined>, documentBaseUrl?: string) => string;
|
|
79
81
|
export declare const resolveFileViewerTypstRendererWasmUrl: (options?: Pick<FileViewerTypstOptions, "rendererWasmUrl"> | null, overrides?: Array<string | undefined>, documentBaseUrl?: string) => string;
|
|
80
82
|
export declare const resolveFileViewerTypstFontAssetsUrl: (options?: Pick<FileViewerTypstOptions, "fontAssetsUrl"> | null, overrides?: Array<string | undefined>, documentBaseUrl?: string) => string;
|
package/dist/platform/assets.js
CHANGED
|
@@ -2,6 +2,7 @@ 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_PRESENTATION_WORKER_PATH = 'vendor/pptx/pptx.worker.js';
|
|
5
6
|
export const DEFAULT_FILE_VIEWER_SPREADSHEET_WORKER_PATH = 'vendor/xlsx/sheet.worker.js';
|
|
6
7
|
export const DEFAULT_FILE_VIEWER_PDF_WORKER_PATH = 'vendor/pdf/pdf.worker.mjs';
|
|
7
8
|
export const DEFAULT_FILE_VIEWER_PDF_CMAP_PATH = 'vendor/pdf/cmaps/';
|
|
@@ -178,6 +179,21 @@ export const DEFAULT_FILE_VIEWER_RENDERER_ASSET_MANIFESTS = [
|
|
|
178
179
|
},
|
|
179
180
|
],
|
|
180
181
|
},
|
|
182
|
+
{
|
|
183
|
+
rendererId: 'office-presentation',
|
|
184
|
+
assets: [
|
|
185
|
+
{
|
|
186
|
+
id: 'pptx-worker',
|
|
187
|
+
rendererId: 'office-presentation',
|
|
188
|
+
kind: 'worker',
|
|
189
|
+
target: 'public',
|
|
190
|
+
required: false,
|
|
191
|
+
defaultPath: DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH,
|
|
192
|
+
optionPath: 'presentation.workerUrl',
|
|
193
|
+
description: 'Optional @file-viewer/pptx worker for stable PPTX parsing in IIFE, CDN, and offline deployments.',
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
},
|
|
181
197
|
{
|
|
182
198
|
rendererId: 'spreadsheet-openxml',
|
|
183
199
|
assets: [
|
|
@@ -334,6 +350,11 @@ export const resolveFileViewerSpreadsheetWorkerUrl = (options, documentBaseUrl)
|
|
|
334
350
|
documentBaseUrl,
|
|
335
351
|
});
|
|
336
352
|
};
|
|
353
|
+
export const resolveFileViewerPresentationWorkerUrl = (options, documentBaseUrl) => {
|
|
354
|
+
return resolveFileViewerAssetUrl(options === null || options === void 0 ? void 0 : options.workerUrl, DEFAULT_FILE_VIEWER_PRESENTATION_WORKER_PATH, {
|
|
355
|
+
documentBaseUrl,
|
|
356
|
+
});
|
|
357
|
+
};
|
|
337
358
|
export const resolveFileViewerTypstCompilerWasmUrl = (options, overrides = [], documentBaseUrl) => {
|
|
338
359
|
return resolveFileViewerAssetUrl((options === null || options === void 0 ? void 0 : options.compilerWasmUrl) || overrides.find(Boolean), DEFAULT_FILE_VIEWER_TYPST_COMPILER_WASM_URL, { documentBaseUrl });
|
|
339
360
|
};
|
|
@@ -353,7 +374,7 @@ export const getFileViewerRendererAssetManifest = (rendererId) => {
|
|
|
353
374
|
return DEFAULT_FILE_VIEWER_RENDERER_ASSET_MANIFESTS.find(manifest => manifest.rendererId === rendererId) || null;
|
|
354
375
|
};
|
|
355
376
|
const getRendererAssetOptionValue = (options, optionPath) => {
|
|
356
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
377
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
357
378
|
switch (optionPath) {
|
|
358
379
|
case 'archive.workerUrl':
|
|
359
380
|
return (_a = options === null || options === void 0 ? void 0 : options.archive) === null || _a === void 0 ? void 0 : _a.workerUrl;
|
|
@@ -381,14 +402,16 @@ const getRendererAssetOptionValue = (options, optionPath) => {
|
|
|
381
402
|
return (_m = options === null || options === void 0 ? void 0 : options.pdf) === null || _m === void 0 ? void 0 : _m.wasmUrl;
|
|
382
403
|
case 'pdf.standardFontDataUrl':
|
|
383
404
|
return (_o = options === null || options === void 0 ? void 0 : options.pdf) === null || _o === void 0 ? void 0 : _o.standardFontDataUrl;
|
|
405
|
+
case 'presentation.workerUrl':
|
|
406
|
+
return (_p = options === null || options === void 0 ? void 0 : options.presentation) === null || _p === void 0 ? void 0 : _p.workerUrl;
|
|
384
407
|
case 'spreadsheet.workerUrl':
|
|
385
|
-
return (
|
|
408
|
+
return (_q = options === null || options === void 0 ? void 0 : options.spreadsheet) === null || _q === void 0 ? void 0 : _q.workerUrl;
|
|
386
409
|
case 'typst.compilerWasmUrl':
|
|
387
|
-
return (
|
|
410
|
+
return (_r = options === null || options === void 0 ? void 0 : options.typst) === null || _r === void 0 ? void 0 : _r.compilerWasmUrl;
|
|
388
411
|
case 'typst.fontAssetsUrl':
|
|
389
|
-
return (
|
|
412
|
+
return (_s = options === null || options === void 0 ? void 0 : options.typst) === null || _s === void 0 ? void 0 : _s.fontAssetsUrl;
|
|
390
413
|
case 'typst.rendererWasmUrl':
|
|
391
|
-
return (
|
|
414
|
+
return (_t = options === null || options === void 0 ? void 0 : options.typst) === null || _t === void 0 ? void 0 : _t.rendererWasmUrl;
|
|
392
415
|
default:
|
|
393
416
|
return undefined;
|
|
394
417
|
}
|
|
@@ -29,6 +29,9 @@ export const clearFileViewerRenderSurface = (container) => {
|
|
|
29
29
|
export const createFileViewerRenderTarget = (container, options = {}) => {
|
|
30
30
|
const target = container.ownerDocument.createElement('div');
|
|
31
31
|
target.className = options.className || DEFAULT_FILE_VIEWER_RENDER_TARGET_CLASS;
|
|
32
|
+
target.style.width = '100%';
|
|
33
|
+
target.style.minWidth = '0';
|
|
34
|
+
target.style.minHeight = '0';
|
|
32
35
|
container.appendChild(target);
|
|
33
36
|
return target;
|
|
34
37
|
};
|
|
@@ -12,7 +12,7 @@ import { DEFAULT_FILE_VIEWER_DOWNLOAD_FILENAME, DEFAULT_FILE_VIEWER_EXPORT_FILEN
|
|
|
12
12
|
import { applyFileViewerZoomAvailability, createUnsupportedAvailability, getRendererAvailability, } from '../registry/capabilities.js';
|
|
13
13
|
import { buildFileViewerLifecycleContextFromNormalizedSource, buildFileViewerOperationContext, runFileViewerBeforeOperation, runFileViewerLifecycleHook, } from '../lifecycle/operations.js';
|
|
14
14
|
import { collectFileViewerRendererPlugins, createRendererRegistry, getFileViewerAutoRendererPresetVersion, hasFileViewerRendererPresetName, installFileViewerRendererPlugins, listFileViewerAutoRendererPresets, resolveFileViewerRendererPresetInputs, } from '../registry/registry.js';
|
|
15
|
-
import { createFileRenderHandlerLoader, applyFileViewerRenderSurfaceState, createFileViewerRenderSurfaceState, } from '../rendering/handler.js';
|
|
15
|
+
import { createFileRenderHandlerLoader, applyFileViewerRenderSurfaceState, createFileViewerRenderSurfaceState, createFileViewerRenderTarget, removeFileViewerRenderTarget, } from '../rendering/handler.js';
|
|
16
16
|
import { createFileViewerCoreRendererRegistry } from '../renderers/index.js';
|
|
17
17
|
import { createFileViewerRequestScope } from '../source/loading.js';
|
|
18
18
|
import { normalizeSource } from '../source/index.js';
|
|
@@ -93,12 +93,141 @@ export const createViewer = (container, createOptions = {}) => {
|
|
|
93
93
|
let installedAutoRenderersEnabled = resolveAutoRenderersEnabled(options);
|
|
94
94
|
let installedAutoRendererVersion = -1;
|
|
95
95
|
let currentSource = null;
|
|
96
|
+
let currentRenderTarget = null;
|
|
96
97
|
const renderSurfaceState = createFileViewerRenderSurfaceState();
|
|
97
98
|
const requestScope = createFileViewerRequestScope();
|
|
98
99
|
const documentTarget = {
|
|
99
100
|
anchors: { value: [] },
|
|
100
101
|
state: createEmptyFileViewerSearchState(),
|
|
101
102
|
};
|
|
103
|
+
let watermarkEl = null;
|
|
104
|
+
let forcedWatermarkContainerPosition = false;
|
|
105
|
+
let watermarkResizeObserver = null;
|
|
106
|
+
let watermarkMutationObserver = null;
|
|
107
|
+
let watermarkFrame = null;
|
|
108
|
+
const getContainerWindow = () => container.ownerDocument.defaultView || (typeof window !== 'undefined' ? window : undefined);
|
|
109
|
+
const cancelWatermarkFrame = () => {
|
|
110
|
+
if (watermarkFrame === null) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const view = getContainerWindow();
|
|
114
|
+
if (view === null || view === void 0 ? void 0 : view.cancelAnimationFrame) {
|
|
115
|
+
view.cancelAnimationFrame(watermarkFrame);
|
|
116
|
+
}
|
|
117
|
+
watermarkFrame = null;
|
|
118
|
+
};
|
|
119
|
+
const updateWatermarkOverlaySize = () => {
|
|
120
|
+
watermarkFrame = null;
|
|
121
|
+
if (!watermarkEl || watermarkEl.parentElement !== container) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const previousDisplay = watermarkEl.style.display;
|
|
125
|
+
watermarkEl.style.display = 'none';
|
|
126
|
+
const width = Math.max(container.scrollWidth, container.clientWidth);
|
|
127
|
+
const height = Math.max(container.scrollHeight, container.clientHeight);
|
|
128
|
+
watermarkEl.style.display = previousDisplay;
|
|
129
|
+
watermarkEl.style.width = `${width}px`;
|
|
130
|
+
watermarkEl.style.height = `${height}px`;
|
|
131
|
+
};
|
|
132
|
+
const scheduleWatermarkSizeUpdate = () => {
|
|
133
|
+
if (!watermarkEl) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
cancelWatermarkFrame();
|
|
137
|
+
const view = getContainerWindow();
|
|
138
|
+
if (view === null || view === void 0 ? void 0 : view.requestAnimationFrame) {
|
|
139
|
+
watermarkFrame = view.requestAnimationFrame(updateWatermarkOverlaySize);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
updateWatermarkOverlaySize();
|
|
143
|
+
};
|
|
144
|
+
const stopWatermarkObservers = () => {
|
|
145
|
+
cancelWatermarkFrame();
|
|
146
|
+
watermarkResizeObserver === null || watermarkResizeObserver === void 0 ? void 0 : watermarkResizeObserver.disconnect();
|
|
147
|
+
watermarkResizeObserver = null;
|
|
148
|
+
watermarkMutationObserver === null || watermarkMutationObserver === void 0 ? void 0 : watermarkMutationObserver.disconnect();
|
|
149
|
+
watermarkMutationObserver = null;
|
|
150
|
+
};
|
|
151
|
+
const startWatermarkObservers = () => {
|
|
152
|
+
stopWatermarkObservers();
|
|
153
|
+
const view = getContainerWindow();
|
|
154
|
+
if (view === null || view === void 0 ? void 0 : view.ResizeObserver) {
|
|
155
|
+
watermarkResizeObserver = new view.ResizeObserver(() => scheduleWatermarkSizeUpdate());
|
|
156
|
+
watermarkResizeObserver.observe(container);
|
|
157
|
+
}
|
|
158
|
+
if (view === null || view === void 0 ? void 0 : view.MutationObserver) {
|
|
159
|
+
watermarkMutationObserver = new view.MutationObserver(mutations => {
|
|
160
|
+
const onlyWatermarkChanged = mutations.every(mutation => watermarkEl && (mutation.target === watermarkEl ||
|
|
161
|
+
watermarkEl.contains(mutation.target)));
|
|
162
|
+
if (!onlyWatermarkChanged) {
|
|
163
|
+
scheduleWatermarkSizeUpdate();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
watermarkMutationObserver.observe(container, {
|
|
167
|
+
attributes: true,
|
|
168
|
+
childList: true,
|
|
169
|
+
subtree: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
scheduleWatermarkSizeUpdate();
|
|
173
|
+
};
|
|
174
|
+
const removeWatermarkOverlay = () => {
|
|
175
|
+
stopWatermarkObservers();
|
|
176
|
+
watermarkEl === null || watermarkEl === void 0 ? void 0 : watermarkEl.remove();
|
|
177
|
+
watermarkEl = null;
|
|
178
|
+
if (forcedWatermarkContainerPosition) {
|
|
179
|
+
container.style.position = '';
|
|
180
|
+
forcedWatermarkContainerPosition = false;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const removeRenderTarget = (target = currentRenderTarget) => {
|
|
184
|
+
if (!target) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
removeFileViewerRenderTarget(container, target);
|
|
188
|
+
if (currentRenderTarget === target) {
|
|
189
|
+
currentRenderTarget = null;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const createRenderTarget = (fillHeight = true) => {
|
|
193
|
+
const target = createFileViewerRenderTarget(container);
|
|
194
|
+
if (fillHeight) {
|
|
195
|
+
target.style.height = '100%';
|
|
196
|
+
}
|
|
197
|
+
currentRenderTarget = target;
|
|
198
|
+
return target;
|
|
199
|
+
};
|
|
200
|
+
const disposeStaleSession = async (session, target) => {
|
|
201
|
+
var _a;
|
|
202
|
+
try {
|
|
203
|
+
await ((_a = session === null || session === void 0 ? void 0 : session.destroy) === null || _a === void 0 ? void 0 : _a.call(session));
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
removeRenderTarget(target);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const syncWatermarkOverlay = () => {
|
|
210
|
+
const inlineStyle = buildFileViewerWatermarkInlineStyle(options.watermark);
|
|
211
|
+
if (!inlineStyle) {
|
|
212
|
+
removeWatermarkOverlay();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (!watermarkEl || watermarkEl.ownerDocument !== container.ownerDocument) {
|
|
216
|
+
watermarkEl = container.ownerDocument.createElement('div');
|
|
217
|
+
watermarkEl.className = 'viewer-watermark';
|
|
218
|
+
watermarkEl.setAttribute('aria-hidden', 'true');
|
|
219
|
+
}
|
|
220
|
+
watermarkEl.style.cssText = inlineStyle;
|
|
221
|
+
const view = getContainerWindow();
|
|
222
|
+
if ((view === null || view === void 0 ? void 0 : view.getComputedStyle) && view.getComputedStyle(container).position === 'static' && !container.style.position) {
|
|
223
|
+
container.style.position = 'relative';
|
|
224
|
+
forcedWatermarkContainerPosition = true;
|
|
225
|
+
}
|
|
226
|
+
if (watermarkEl.parentElement !== container) {
|
|
227
|
+
container.appendChild(watermarkEl);
|
|
228
|
+
}
|
|
229
|
+
startWatermarkObservers();
|
|
230
|
+
};
|
|
102
231
|
const ensureRendererPluginsInstalled = async () => {
|
|
103
232
|
const nextMode = options.rendererMode || 'extend';
|
|
104
233
|
const nextRendererInput = options.renderers;
|
|
@@ -250,54 +379,85 @@ export const createViewer = (container, createOptions = {}) => {
|
|
|
250
379
|
zoomController.observe();
|
|
251
380
|
viewStateController.observe();
|
|
252
381
|
const destroyCurrent = async (reason = 'replace') => {
|
|
253
|
-
var _a
|
|
254
|
-
|
|
382
|
+
var _a;
|
|
383
|
+
const session = renderSurfaceState.session;
|
|
384
|
+
const target = currentRenderTarget;
|
|
385
|
+
if (!currentSource && !session && !target) {
|
|
255
386
|
return;
|
|
256
387
|
}
|
|
257
388
|
const source = currentSource;
|
|
258
389
|
const startedAt = Date.now();
|
|
259
390
|
const version = requestScope.getCurrentVersion();
|
|
260
|
-
|
|
261
|
-
|
|
391
|
+
if (source) {
|
|
392
|
+
await emitLifecycle(options, createOptions.onEvent, 'unload-start', source, version, startedAt, reason);
|
|
393
|
+
}
|
|
394
|
+
await ((_a = session === null || session === void 0 ? void 0 : session.destroy) === null || _a === void 0 ? void 0 : _a.call(session));
|
|
395
|
+
removeRenderTarget(target || undefined);
|
|
262
396
|
currentSource = null;
|
|
263
397
|
applyFileViewerRenderSurfaceState(renderSurfaceState, {
|
|
264
398
|
session: null,
|
|
265
399
|
exportAdapter: null,
|
|
266
400
|
});
|
|
401
|
+
removeWatermarkOverlay();
|
|
267
402
|
await documentActions.clearDocumentState();
|
|
268
403
|
zoomController.clearProvider();
|
|
269
404
|
viewStateController.clearProvider();
|
|
270
405
|
emitZoomAndOperationAvailabilityChange();
|
|
271
|
-
|
|
406
|
+
if (source) {
|
|
407
|
+
await emitLifecycle(options, createOptions.onEvent, 'unload-complete', source, version, startedAt, reason);
|
|
408
|
+
}
|
|
272
409
|
};
|
|
273
410
|
return {
|
|
274
411
|
container,
|
|
275
412
|
async load(source) {
|
|
413
|
+
const version = requestScope.requestController.createVersion();
|
|
276
414
|
await destroyCurrent('replace');
|
|
277
415
|
await ensureRendererPluginsInstalled();
|
|
416
|
+
if (!requestScope.isCurrentRequest(version)) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
278
419
|
const normalized = normalizeSource(source);
|
|
279
420
|
currentSource = normalized;
|
|
280
|
-
const version = requestScope.requestController.createVersion();
|
|
281
421
|
const renderer = registry.getByExtension(normalized.extension);
|
|
282
422
|
const startedAt = Date.now();
|
|
283
423
|
await emitLifecycle(options, createOptions.onEvent, 'load-start', normalized, version, startedAt);
|
|
424
|
+
const target = createRenderTarget((renderer === null || renderer === void 0 ? void 0 : renderer.id) !== 'office-presentation');
|
|
284
425
|
if (!(renderer === null || renderer === void 0 ? void 0 : renderer.load)) {
|
|
285
|
-
renderMissingRendererState(
|
|
426
|
+
renderMissingRendererState(target, normalized.extension, options);
|
|
286
427
|
applyFileViewerRenderSurfaceState(renderSurfaceState, { session: null });
|
|
428
|
+
syncWatermarkOverlay();
|
|
287
429
|
emitZoomAndOperationAvailabilityChange();
|
|
288
430
|
await emitLifecycle(options, createOptions.onEvent, 'load-complete', normalized, version, startedAt);
|
|
289
431
|
return null;
|
|
290
432
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
433
|
+
let session;
|
|
434
|
+
try {
|
|
435
|
+
session = await renderer.load({
|
|
436
|
+
source: normalized,
|
|
437
|
+
surface: { container: target },
|
|
438
|
+
options,
|
|
439
|
+
signal: createOptions.signal,
|
|
440
|
+
registerExportAdapter: adapter => {
|
|
441
|
+
if (requestScope.isCurrentRequest(version)) {
|
|
442
|
+
applyFileViewerRenderSurfaceState(renderSurfaceState, { exportAdapter: adapter });
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
if (!requestScope.isCurrentRequest(version)) {
|
|
449
|
+
removeRenderTarget(target);
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
removeRenderTarget(target);
|
|
453
|
+
throw error;
|
|
454
|
+
}
|
|
455
|
+
if (!requestScope.isCurrentRequest(version)) {
|
|
456
|
+
await disposeStaleSession(session, target);
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
300
459
|
applyFileViewerRenderSurfaceState(renderSurfaceState, { session });
|
|
460
|
+
syncWatermarkOverlay();
|
|
301
461
|
zoomController.refreshProvider();
|
|
302
462
|
viewStateController.refreshProvider();
|
|
303
463
|
await documentActions.refreshDocumentIndex({ notify: false });
|
|
@@ -306,16 +466,19 @@ export const createViewer = (container, createOptions = {}) => {
|
|
|
306
466
|
return session;
|
|
307
467
|
},
|
|
308
468
|
async destroy(reason = 'component-unmount') {
|
|
469
|
+
requestScope.requestController.createVersion();
|
|
309
470
|
await destroyCurrent(reason);
|
|
310
471
|
documentActions.destroyDocumentFeatures();
|
|
311
472
|
zoomController.destroy();
|
|
312
473
|
viewStateController.destroy();
|
|
474
|
+
removeWatermarkOverlay();
|
|
313
475
|
},
|
|
314
476
|
updateOptions(nextOptions) {
|
|
315
477
|
options = {
|
|
316
478
|
...options,
|
|
317
479
|
...nextOptions,
|
|
318
480
|
};
|
|
481
|
+
syncWatermarkOverlay();
|
|
319
482
|
},
|
|
320
483
|
getCapabilities(extension) {
|
|
321
484
|
return getCapabilitiesForExtension(extension);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Framework-neutral modular TypeScript core for Flyfish File Viewer renderer orchestration, lifecycle APIs, search, zoom, print, and export",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"funding": {
|
|
37
37
|
"type": "individual",
|
|
38
|
-
"url": "https://dev.flyfish.group/
|
|
38
|
+
"url": "https://dev.flyfish.group/donate?source=npm"
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://doc.file-viewer.app/",
|
|
41
41
|
"main": "./dist/index.js",
|