@file-viewer/core 2.2.4 → 2.2.6
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 +17 -0
- package/README.md +17 -0
- package/dist/contracts/types.d.ts +60 -3
- package/dist/features/printMask.d.ts +3 -2
- package/dist/features/printMask.js +74 -12
- package/dist/features/printMaskDesigner.d.ts +2 -1
- package/dist/features/printMaskDesigner.js +186 -13
- package/dist/headless.d.ts +3 -1
- package/dist/headless.js +1 -0
- package/dist/i18n/messages.ja.js +15 -3
- package/dist/i18n/messages.js +30 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/output/export.js +2 -1
- package/dist/renderers/image.js +48 -12
- package/dist/source/precheck.d.ts +36 -0
- package/dist/source/precheck.js +250 -0
- package/dist/viewer/createViewer.js +2 -1
- package/dist/viewer/operations.js +4 -3
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -14,6 +14,23 @@ Current framework-neutral browser renderers still inside core are limited to the
|
|
|
14
14
|
npm install @file-viewer/core
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Preflight Before Rendering
|
|
18
|
+
|
|
19
|
+
`precheckFileViewerSource()` does not create a viewer or load a heavy renderer. It checks whether the extension is available and validates known PDF, OpenXML / OpenDocument, legacy OLE Office, and RTF signatures or package parts. `valid: null` explicitly means capability-only detection, not a full parse; the real renderer remains the final authority for malformed content.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { precheckFileViewerSource } from '@file-viewer/core/headless'
|
|
23
|
+
|
|
24
|
+
const result = await precheckFileViewerSource(file, {
|
|
25
|
+
// Restrict this to the extensions actually installed by this product.
|
|
26
|
+
supportedExtensions: ['pdf', 'docx', 'xlsx', 'pptx']
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (!result.previewable) {
|
|
30
|
+
console.warn(result.reason, result.missingParts)
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
17
34
|
## Entry points
|
|
18
35
|
|
|
19
36
|
Use `@file-viewer/core/headless` when a component package, server-side helper, or build script only needs framework-neutral contracts: format support, source normalization, renderer capability metadata, lifecycle/operation context, option normalization, state helpers, and static asset resolution. This entry intentionally does not expose the DOM viewer engine or browser renderers.
|
package/README.md
CHANGED
|
@@ -14,6 +14,23 @@ Current framework-neutral browser renderers still inside core are limited to the
|
|
|
14
14
|
npm install @file-viewer/core
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## 渲染前预检
|
|
18
|
+
|
|
19
|
+
`precheckFileViewerSource()` 不会创建 viewer,也不会加载重型 renderer。它先检查当前扩展名是否在能力范围内,并对 PDF、OpenXML / OpenDocument、旧版 OLE Office、RTF 等格式执行签名或包结构检查。`valid: null` 明确表示该格式只有能力检查、没有做完整解析;真实 renderer 仍是畸形文件的最终判断者。
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { precheckFileViewerSource } from '@file-viewer/core/headless'
|
|
23
|
+
|
|
24
|
+
const result = await precheckFileViewerSource(file, {
|
|
25
|
+
// 可传当前产品实际安装的扩展名列表,避免把未装 preset 的格式报成可预览
|
|
26
|
+
supportedExtensions: ['pdf', 'docx', 'xlsx', 'pptx']
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (!result.previewable) {
|
|
30
|
+
console.warn(result.reason, result.missingParts)
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
17
34
|
## Entry points
|
|
18
35
|
|
|
19
36
|
Use `@file-viewer/core/headless` when a component package, server-side helper or build script only needs framework-neutral contracts: format support, source normalization, renderer capability metadata, lifecycle/operation context, option normalization, state helpers and static asset resolution. This entry intentionally does not expose the DOM viewer engine or browser renderers.
|
|
@@ -3,7 +3,7 @@ export type FileViewerThemeMode = 'light' | 'dark' | 'system';
|
|
|
3
3
|
export type FileViewerResolvedThemeMode = Exclude<FileViewerThemeMode, 'system'>;
|
|
4
4
|
export type FileViewerLocale = 'auto' | 'zh-CN' | 'en-US' | 'ja-JP' | (string & {});
|
|
5
5
|
export type FileViewerStyleIsolation = 'auto' | 'shadow' | 'scoped' | 'none';
|
|
6
|
-
export type FileViewerMessageKey = 'toolbar.zoomGroup' | 'toolbar.zoomOut' | 'toolbar.zoomIn' | 'toolbar.zoomReset' | 'toolbar.download' | 'toolbar.downloadTitle' | 'toolbar.print' | 'toolbar.printTitle' | 'toolbar.printDirect' | 'toolbar.printMask' | 'toolbar.printMaskTitle' | 'toolbar.printMaskAdd' | 'toolbar.printMaskClear' | 'toolbar.printMaskCancel' | 'toolbar.printMaskConfirm' | 'toolbar.printMaskHint' | 'toolbar.exportHtml' | 'toolbar.exportHtmlTitle' | 'toolbar.search' | 'toolbar.searchPlaceholder' | 'toolbar.searchPrevious' | 'toolbar.searchNext' | 'toolbar.searchClear' | 'toolbar.theme' | 'toolbar.themeToLight' | 'toolbar.themeToDark' | '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' | 'error.unknown' | 'error.blobUnavailable' | 'error.sourceUnsupported' | 'error.fileReadArrayBuffer' | 'error.fileReadDataUrl' | 'error.fileReadText' | 'error.imageDataUrlRead' | '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' | 'word.error.invalidDocx' | 'word.error.missingOdfContent' | 'word.error.odfXmlParseFailed' | 'word.title.rtf' | 'word.title.openDocumentPresentation' | 'word.title.openDocumentText' | 'word.page.fallback' | 'word.page.empty' | 'word.body' | 'word.body.empty' | 'ofd.state.loading' | 'ofd.error.empty' | 'ofd.error.parseFailed' | 'presentation.state.loading' | 'presentation.error.title' | 'presentation.error.parseFailed' | 'presentation.ppt.state.loading' | 'presentation.ppt.error.title' | 'presentation.ppt.error.parseFailed' | 'presentation.ppt.error.assetHint' | '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.workerUnsupported' | 'archive.error.indexedDbUnavailable' | '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' | 'text.code.indexingLargeFile' | 'text.code.virtualized' | 'text.code.firstSegment' | 'text.code.previousSegment' | 'text.code.nextSegment' | 'text.code.lastSegment' | '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.layers.merged' | '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';
|
|
6
|
+
export type FileViewerMessageKey = 'toolbar.zoomGroup' | 'toolbar.zoomOut' | 'toolbar.zoomIn' | 'toolbar.zoomReset' | 'toolbar.download' | 'toolbar.downloadTitle' | 'toolbar.print' | 'toolbar.printTitle' | 'toolbar.printDirect' | 'toolbar.printMask' | 'toolbar.printMaskTitle' | 'toolbar.printMaskAdd' | 'toolbar.printMaskClear' | 'toolbar.printMaskCancel' | 'toolbar.printMaskConfirm' | 'toolbar.printMaskHint' | 'toolbar.printStampUpload' | 'toolbar.printStampRemove' | 'toolbar.printStampResize' | 'toolbar.exportHtml' | 'toolbar.exportHtmlTitle' | 'toolbar.search' | 'toolbar.searchPlaceholder' | 'toolbar.searchPrevious' | 'toolbar.searchNext' | 'toolbar.searchClear' | 'toolbar.theme' | 'toolbar.themeToLight' | 'toolbar.themeToDark' | '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' | 'error.unknown' | 'error.blobUnavailable' | 'error.sourceUnsupported' | 'error.fileReadArrayBuffer' | 'error.fileReadDataUrl' | 'error.fileReadText' | 'error.imageDataUrlRead' | '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' | 'word.error.invalidDocx' | 'word.error.missingOdfContent' | 'word.error.odfXmlParseFailed' | 'word.title.rtf' | 'word.title.openDocumentPresentation' | 'word.title.openDocumentText' | 'word.page.fallback' | 'word.page.empty' | 'word.body' | 'word.body.empty' | 'ofd.toolbar.pageNavigation' | 'ofd.toolbar.documentPages' | 'ofd.toolbar.previousPage' | 'ofd.toolbar.nextPage' | 'ofd.toolbar.pageStatus' | 'ofd.toolbar.noPages' | 'ofd.state.loading' | 'ofd.error.empty' | 'ofd.error.parseFailed' | 'presentation.state.loading' | 'presentation.error.title' | 'presentation.error.parseFailed' | 'presentation.ppt.state.loading' | 'presentation.ppt.error.title' | 'presentation.ppt.error.parseFailed' | 'presentation.ppt.error.assetHint' | '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.workerUnsupported' | 'archive.error.indexedDbUnavailable' | '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' | 'text.code.indexingLargeFile' | 'text.code.virtualized' | 'text.code.firstSegment' | 'text.code.previousSegment' | 'text.code.nextSegment' | 'text.code.lastSegment' | '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.layers.merged' | '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.toolbar.rotation' | 'image.toolbar.rotateLeft' | 'image.toolbar.rotateRight' | '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';
|
|
7
7
|
export type FileViewerMessageParams = Record<string, string | number | boolean | null | undefined>;
|
|
8
8
|
export type FileViewerMessageResolver = (key: FileViewerMessageKey, params: FileViewerMessageParams, locale: FileViewerLocale) => string | undefined;
|
|
9
9
|
export type FileViewerMessages = Partial<Record<FileViewerMessageKey, string>> | FileViewerMessageResolver;
|
|
@@ -114,6 +114,12 @@ export interface FileViewerPdfOptions {
|
|
|
114
114
|
defaultNavigationVisible?: boolean;
|
|
115
115
|
thumbnails?: boolean;
|
|
116
116
|
rotation?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Highlights and focuses one or more PDF regions after the document loads.
|
|
119
|
+
* Use `pixel` with `sourceWidth` / `sourceHeight` for OCR coordinates, or
|
|
120
|
+
* `pdf-point` for native PDF coordinates. Page numbers are one-based.
|
|
121
|
+
*/
|
|
122
|
+
bbox?: FileViewerPdfBoundingBox | readonly FileViewerPdfBoundingBox[];
|
|
117
123
|
/**
|
|
118
124
|
* Initial PDF view position. Prefer the top-level `initialViewState` when the
|
|
119
125
|
* same state should be passed through framework-neutral viewer APIs.
|
|
@@ -150,6 +156,29 @@ export interface FileViewerPdfOptions {
|
|
|
150
156
|
*/
|
|
151
157
|
cjkFontFallbackPath?: string;
|
|
152
158
|
}
|
|
159
|
+
export type FileViewerPdfBoundingBoxUnit = 'ratio' | 'percent' | 'pixel' | 'pdf-point';
|
|
160
|
+
export type FileViewerPdfBoundingBoxOrigin = 'top-left' | 'bottom-left';
|
|
161
|
+
export interface FileViewerPdfBoundingBox {
|
|
162
|
+
id?: string;
|
|
163
|
+
/** One-based PDF page number. Defaults to the current page, then page 1. */
|
|
164
|
+
page?: number;
|
|
165
|
+
x: number;
|
|
166
|
+
y: number;
|
|
167
|
+
width: number;
|
|
168
|
+
height: number;
|
|
169
|
+
/** Defaults to `pdf-point`. */
|
|
170
|
+
unit?: FileViewerPdfBoundingBoxUnit;
|
|
171
|
+
/** Defaults to `bottom-left` for PDF points and `top-left` otherwise. */
|
|
172
|
+
origin?: FileViewerPdfBoundingBoxOrigin;
|
|
173
|
+
/** Required when `unit` is `pixel`; this is the OCR/source image width. */
|
|
174
|
+
sourceWidth?: number;
|
|
175
|
+
/** Required when `unit` is `pixel`; this is the OCR/source image height. */
|
|
176
|
+
sourceHeight?: number;
|
|
177
|
+
/** CSS color used for the outline and translucent fill. */
|
|
178
|
+
color?: string;
|
|
179
|
+
/** Optional accessible description for the highlighted region. */
|
|
180
|
+
label?: string;
|
|
181
|
+
}
|
|
153
182
|
export interface FileViewerDocxOptions {
|
|
154
183
|
worker?: boolean;
|
|
155
184
|
workerUrl?: string;
|
|
@@ -168,6 +197,8 @@ export interface FileViewerDocxOptions {
|
|
|
168
197
|
updatePageReferences?: boolean;
|
|
169
198
|
hideWebHiddenContent?: boolean;
|
|
170
199
|
ignoreLastRenderedPageBreak?: boolean;
|
|
200
|
+
/** External DOCX links are blocked by default; internal bookmark links remain active. */
|
|
201
|
+
externalLinkPolicy?: 'allow' | 'block';
|
|
171
202
|
/** Overrides automatic DOCX dark rendering derived from the viewer theme. */
|
|
172
203
|
darkMode?: boolean;
|
|
173
204
|
}
|
|
@@ -316,13 +347,16 @@ export interface FileViewerModelOptions {
|
|
|
316
347
|
export interface FileViewerDataOptions {
|
|
317
348
|
sqlWasmUrl?: string;
|
|
318
349
|
}
|
|
319
|
-
export type FileViewerGeoBasemapPreset = 'none' | 'offline' | 'openfreemap' | 'openfreemap-liberty' | 'openfreemap-bright' | 'openfreemap-positron' | 'openfreemap-dark' | 'openfreemap-fiord' | 'osm-raster';
|
|
350
|
+
export type FileViewerGeoBasemapPreset = 'none' | 'offline' | 'openfreemap' | 'openfreemap-liberty' | 'openfreemap-bright' | 'openfreemap-positron' | 'openfreemap-dark' | 'openfreemap-fiord' | 'osm-raster' | 'tianditu-vector' | 'tianditu-imagery' | 'tianditu-terrain';
|
|
351
|
+
export type FileViewerTiandituMapStyle = 'vector' | 'imagery' | 'terrain';
|
|
320
352
|
export interface FileViewerGeoBasemapOptions {
|
|
321
353
|
/**
|
|
322
354
|
* `raster` uses XYZ/TMS image tiles. `vector-style` uses a MapLibre style
|
|
323
355
|
* object or URL, which is the best path for OpenFreeMap/OpenMapTiles stacks.
|
|
356
|
+
* `tianditu` builds the official base and annotation raster layers from the
|
|
357
|
+
* caller-provided Tianditu token.
|
|
324
358
|
*/
|
|
325
|
-
type?: 'raster' | 'vector-style';
|
|
359
|
+
type?: 'raster' | 'vector-style' | 'tianditu';
|
|
326
360
|
/**
|
|
327
361
|
* Raster XYZ/TMS tile template, for example `/tiles/{z}/{x}/{y}.png`.
|
|
328
362
|
*/
|
|
@@ -346,6 +380,12 @@ export interface FileViewerGeoBasemapOptions {
|
|
|
346
380
|
maxZoom?: number;
|
|
347
381
|
scheme?: 'xyz' | 'tms';
|
|
348
382
|
rasterOpacity?: number;
|
|
383
|
+
/** Tianditu API token. Required when `type` is `tianditu`. */
|
|
384
|
+
token?: string;
|
|
385
|
+
/** Tianditu map family. Defaults to `vector`. */
|
|
386
|
+
mapStyle?: FileViewerTiandituMapStyle;
|
|
387
|
+
/** Include the matching Tianditu annotation layer. Defaults to true. */
|
|
388
|
+
labels?: boolean;
|
|
349
389
|
}
|
|
350
390
|
export interface FileViewerGeoOptions {
|
|
351
391
|
/**
|
|
@@ -371,6 +411,11 @@ export interface FileViewerGeoOptions {
|
|
|
371
411
|
* self-hosted or intranet style/tile URL.
|
|
372
412
|
*/
|
|
373
413
|
basemap?: false | FileViewerGeoBasemapPreset | FileViewerGeoBasemapOptions;
|
|
414
|
+
/**
|
|
415
|
+
* Tianditu API token used by the `tianditu-*` presets. The viewer never
|
|
416
|
+
* supplies or persists a token; obtain one for the deployment's own domain.
|
|
417
|
+
*/
|
|
418
|
+
tiandituToken?: string;
|
|
374
419
|
/**
|
|
375
420
|
* Defaults to true. When no CRS is declared and coordinates exceed longitude
|
|
376
421
|
* or latitude ranges, the geo renderer treats Web Mercator-sized values as
|
|
@@ -891,9 +936,21 @@ export interface FileViewerPrintMaskRegion {
|
|
|
891
936
|
/** Zero-based rendered page index. Omitted regions retain legacy whole-document coordinates. */
|
|
892
937
|
pageIndex?: number;
|
|
893
938
|
}
|
|
939
|
+
/** Page-aware image placed above rendered content for printing, such as a seal or signature. */
|
|
940
|
+
export interface FileViewerPrintStamp extends FileViewerPrintMaskRegion {
|
|
941
|
+
/** Image URL. Uploaded stamps are converted to a local data URL by the designer. */
|
|
942
|
+
src: string;
|
|
943
|
+
/** Image opacity from 0 to 1. Defaults to 1. */
|
|
944
|
+
opacity?: number;
|
|
945
|
+
/** Clockwise rotation in degrees. Defaults to 0. */
|
|
946
|
+
rotate?: number;
|
|
947
|
+
alt?: string;
|
|
948
|
+
}
|
|
894
949
|
export interface FileViewerPrintMaskOptions {
|
|
895
950
|
/** Solid black cover blocks, matching common OFD/business redaction UX. */
|
|
896
951
|
regions?: FileViewerPrintMaskRegion[];
|
|
952
|
+
/** Image overlays, including locally uploaded seals and signatures. */
|
|
953
|
+
stamps?: FileViewerPrintStamp[];
|
|
897
954
|
/** Fill color for print masks. Defaults to opaque black. */
|
|
898
955
|
color?: string;
|
|
899
956
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion } from '../contracts/types';
|
|
1
|
+
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from '../contracts/types';
|
|
2
2
|
export declare const normalizeFileViewerPrintMaskRegion: (region: Partial<FileViewerPrintMaskRegion> | null | undefined) => FileViewerPrintMaskRegion | null;
|
|
3
|
+
export declare const normalizeFileViewerPrintStamp: (stamp: Partial<FileViewerPrintStamp> | null | undefined) => FileViewerPrintStamp | null;
|
|
3
4
|
export declare const normalizeFileViewerPrintMaskOptions: (mask?: FileViewerPrintMaskOptions | null) => FileViewerPrintMaskOptions | null;
|
|
4
5
|
export declare const buildFileViewerPrintMaskOverlayHtml: (mask?: FileViewerPrintMaskOptions | null, pageScoped?: boolean) => string;
|
|
5
|
-
export declare const FILE_VIEWER_PRINT_MASK_STYLE = "\n .viewer-export-print-mask{position:absolute;inset:0;z-index:15;pointer-events:none;print-color-adjust:exact;-webkit-print-color-adjust:exact;}\n .viewer-export-print-mask--page{z-index:2147483647;}\n .viewer-export-print-mask-block{position:absolute;box-sizing:border-box;print-color-adjust:exact;-webkit-print-color-adjust:exact;}\n [data-viewer-print-page-index]{position:relative!important;isolation:isolate;}\n";
|
|
6
|
+
export declare const FILE_VIEWER_PRINT_MASK_STYLE = "\n .viewer-export-print-mask{position:absolute;inset:0;z-index:15;pointer-events:none;print-color-adjust:exact;-webkit-print-color-adjust:exact;}\n .viewer-export-print-mask--page{z-index:2147483647;}\n .viewer-export-print-mask-block{position:absolute;box-sizing:border-box;print-color-adjust:exact;-webkit-print-color-adjust:exact;}\n .viewer-export-print-stamp{position:absolute;display:block;object-fit:contain;transform-origin:center center;print-color-adjust:exact;-webkit-print-color-adjust:exact;}\n [data-viewer-print-page-index]{position:relative!important;isolation:isolate;}\n";
|
|
6
7
|
export declare const applyFileViewerPagePrintMasksToHtml: (contentHtml: string, mask?: FileViewerPrintMaskOptions | null) => string;
|
|
@@ -23,47 +23,99 @@ export const normalizeFileViewerPrintMaskRegion = (region) => {
|
|
|
23
23
|
...(pageIndex === undefined ? {} : { pageIndex }),
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
const normalizeStampSource = (value) => {
|
|
27
|
+
if (typeof value !== 'string') {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
const source = value.trim();
|
|
31
|
+
if (/^data:image\/(?:png|jpe?g|webp|gif|svg\+xml);/i.test(source) ||
|
|
32
|
+
/^(?:blob:|https?:\/\/|\/|\.\.?\/)/i.test(source)) {
|
|
33
|
+
return source;
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
};
|
|
37
|
+
const clampOpacity = (value) => {
|
|
38
|
+
const opacity = Number(value);
|
|
39
|
+
return Number.isFinite(opacity) ? Math.max(0, Math.min(1, opacity)) : 1;
|
|
40
|
+
};
|
|
41
|
+
const normalizeRotation = (value) => {
|
|
42
|
+
const rotation = Number(value);
|
|
43
|
+
if (!Number.isFinite(rotation)) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
return ((rotation % 360) + 360) % 360;
|
|
47
|
+
};
|
|
48
|
+
export const normalizeFileViewerPrintStamp = (stamp) => {
|
|
49
|
+
const region = normalizeFileViewerPrintMaskRegion(stamp);
|
|
50
|
+
const src = normalizeStampSource(stamp === null || stamp === void 0 ? void 0 : stamp.src);
|
|
51
|
+
if (!region || !src) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...region,
|
|
56
|
+
src,
|
|
57
|
+
opacity: clampOpacity(stamp === null || stamp === void 0 ? void 0 : stamp.opacity),
|
|
58
|
+
rotate: normalizeRotation(stamp === null || stamp === void 0 ? void 0 : stamp.rotate),
|
|
59
|
+
...(typeof (stamp === null || stamp === void 0 ? void 0 : stamp.alt) === 'string' && stamp.alt.trim()
|
|
60
|
+
? { alt: stamp.alt.trim() }
|
|
61
|
+
: {}),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
26
64
|
export const normalizeFileViewerPrintMaskOptions = (mask) => {
|
|
27
|
-
if (!mask
|
|
65
|
+
if (!mask) {
|
|
28
66
|
return null;
|
|
29
67
|
}
|
|
30
|
-
const regions = mask.regions
|
|
68
|
+
const regions = (mask.regions || [])
|
|
31
69
|
.map(region => normalizeFileViewerPrintMaskRegion(region))
|
|
32
70
|
.filter((region) => !!region);
|
|
33
|
-
|
|
71
|
+
const stamps = (mask.stamps || [])
|
|
72
|
+
.map(stamp => normalizeFileViewerPrintStamp(stamp))
|
|
73
|
+
.filter((stamp) => !!stamp);
|
|
74
|
+
if (!regions.length && !stamps.length) {
|
|
34
75
|
return null;
|
|
35
76
|
}
|
|
36
77
|
return {
|
|
37
|
-
regions,
|
|
78
|
+
...(regions.length ? { regions } : {}),
|
|
79
|
+
...(stamps.length ? { stamps } : {}),
|
|
38
80
|
color: mask.color || '#000000',
|
|
39
81
|
};
|
|
40
82
|
};
|
|
83
|
+
const escapeHtmlAttribute = (value) => value
|
|
84
|
+
.replace(/&/g, '&')
|
|
85
|
+
.replace(/"/g, '"')
|
|
86
|
+
.replace(/</g, '<')
|
|
87
|
+
.replace(/>/g, '>');
|
|
41
88
|
export const buildFileViewerPrintMaskOverlayHtml = (mask, pageScoped = false) => {
|
|
42
|
-
var _a;
|
|
43
89
|
const normalized = normalizeFileViewerPrintMaskOptions(mask);
|
|
44
|
-
if (!
|
|
90
|
+
if (!normalized) {
|
|
45
91
|
return '';
|
|
46
92
|
}
|
|
47
93
|
const color = normalized.color || '#000000';
|
|
48
|
-
const blocks = normalized.regions.map(region => (`<div class="viewer-export-print-mask-block" style="left:${region.left}%;top:${region.top}%;width:${region.width}%;height:${region.height}%;background:${color};"></div>`)).join('');
|
|
94
|
+
const blocks = (normalized.regions || []).map(region => (`<div class="viewer-export-print-mask-block" style="left:${region.left}%;top:${region.top}%;width:${region.width}%;height:${region.height}%;background:${color};"></div>`)).join('');
|
|
95
|
+
const stamps = (normalized.stamps || []).map(stamp => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
return (`<img class="viewer-export-print-stamp" src="${escapeHtmlAttribute(stamp.src)}" alt="${escapeHtmlAttribute(stamp.alt || '')}" draggable="false" style="left:${stamp.left}%;top:${stamp.top}%;width:${stamp.width}%;height:${stamp.height}%;opacity:${(_a = stamp.opacity) !== null && _a !== void 0 ? _a : 1};transform:rotate(${(_b = stamp.rotate) !== null && _b !== void 0 ? _b : 0}deg);" />`);
|
|
98
|
+
}).join('');
|
|
49
99
|
const className = pageScoped
|
|
50
100
|
? 'viewer-export-print-mask viewer-export-print-mask--page'
|
|
51
101
|
: 'viewer-export-print-mask';
|
|
52
|
-
return `<div class="${className}" aria-hidden="true">${blocks}</div>`;
|
|
102
|
+
return `<div class="${className}" aria-hidden="true">${blocks}${stamps}</div>`;
|
|
53
103
|
};
|
|
54
104
|
export const FILE_VIEWER_PRINT_MASK_STYLE = `
|
|
55
105
|
.viewer-export-print-mask{position:absolute;inset:0;z-index:15;pointer-events:none;print-color-adjust:exact;-webkit-print-color-adjust:exact;}
|
|
56
106
|
.viewer-export-print-mask--page{z-index:2147483647;}
|
|
57
107
|
.viewer-export-print-mask-block{position:absolute;box-sizing:border-box;print-color-adjust:exact;-webkit-print-color-adjust:exact;}
|
|
108
|
+
.viewer-export-print-stamp{position:absolute;display:block;object-fit:contain;transform-origin:center center;print-color-adjust:exact;-webkit-print-color-adjust:exact;}
|
|
58
109
|
[data-viewer-print-page-index]{position:relative!important;isolation:isolate;}
|
|
59
110
|
`;
|
|
60
111
|
export const applyFileViewerPagePrintMasksToHtml = (contentHtml, mask) => {
|
|
61
|
-
var _a;
|
|
112
|
+
var _a, _b;
|
|
62
113
|
const normalized = normalizeFileViewerPrintMaskOptions(mask);
|
|
63
114
|
if (!normalized) {
|
|
64
115
|
return contentHtml;
|
|
65
116
|
}
|
|
66
117
|
const regionsByPage = new Map();
|
|
118
|
+
const stampsByPage = new Map();
|
|
67
119
|
(_a = normalized.regions) === null || _a === void 0 ? void 0 : _a.forEach(region => {
|
|
68
120
|
if (region.pageIndex === undefined) {
|
|
69
121
|
return;
|
|
@@ -72,16 +124,26 @@ export const applyFileViewerPagePrintMasksToHtml = (contentHtml, mask) => {
|
|
|
72
124
|
pageRegions.push(region);
|
|
73
125
|
regionsByPage.set(region.pageIndex, pageRegions);
|
|
74
126
|
});
|
|
75
|
-
|
|
127
|
+
(_b = normalized.stamps) === null || _b === void 0 ? void 0 : _b.forEach(stamp => {
|
|
128
|
+
if (stamp.pageIndex === undefined) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const pageStamps = stampsByPage.get(stamp.pageIndex) || [];
|
|
132
|
+
pageStamps.push(stamp);
|
|
133
|
+
stampsByPage.set(stamp.pageIndex, pageStamps);
|
|
134
|
+
});
|
|
135
|
+
if (!regionsByPage.size && !stampsByPage.size) {
|
|
76
136
|
return contentHtml;
|
|
77
137
|
}
|
|
78
138
|
return contentHtml.replace(/(<[A-Za-z][^>]*\sdata-viewer-print-page-index=(['"])(\d+)\2[^>]*>)/g, (match, openingTag, _quote, rawPageIndex) => {
|
|
79
139
|
const pageRegions = regionsByPage.get(Number(rawPageIndex));
|
|
80
|
-
|
|
140
|
+
const pageStamps = stampsByPage.get(Number(rawPageIndex));
|
|
141
|
+
if (!(pageRegions === null || pageRegions === void 0 ? void 0 : pageRegions.length) && !(pageStamps === null || pageStamps === void 0 ? void 0 : pageStamps.length)) {
|
|
81
142
|
return match;
|
|
82
143
|
}
|
|
83
144
|
return `${openingTag}${buildFileViewerPrintMaskOverlayHtml({
|
|
84
|
-
regions: pageRegions,
|
|
145
|
+
regions: pageRegions || [],
|
|
146
|
+
stamps: pageStamps || [],
|
|
85
147
|
color: normalized.color,
|
|
86
148
|
}, true)}`;
|
|
87
149
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion } from '../contracts/types';
|
|
1
|
+
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from '../contracts/types';
|
|
2
2
|
import { type FileViewerI18nInput } from '../i18n/messages';
|
|
3
3
|
export interface OpenFileViewerPrintMaskDesignerOptions {
|
|
4
4
|
root: HTMLElement;
|
|
@@ -6,6 +6,7 @@ export interface OpenFileViewerPrintMaskDesignerOptions {
|
|
|
6
6
|
i18n?: FileViewerI18nInput;
|
|
7
7
|
color?: string;
|
|
8
8
|
initialRegions?: FileViewerPrintMaskRegion[];
|
|
9
|
+
initialStamps?: FileViewerPrintStamp[];
|
|
9
10
|
}
|
|
10
11
|
export interface FileViewerPrintMaskDesignerResult {
|
|
11
12
|
mask: FileViewerPrintMaskOptions;
|