@file-viewer/core 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets.d.ts +2 -2
- package/dist/assets.js +1 -5
- package/dist/browser/controller.d.ts +1 -2
- package/dist/browser/controller.js +8 -39
- package/dist/browser/source-feedback.d.ts +1 -2
- package/dist/browser/source-feedback.js +2 -3
- package/dist/browser/toolbar-focus.d.ts +0 -1
- package/dist/browser/toolbar-focus.js +0 -3
- package/dist/browser/toolbar-keyboard.d.ts +1 -0
- package/dist/browser/toolbar-keyboard.js +63 -0
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/config/options.d.ts +1 -1
- package/dist/contracts/types.d.ts +1 -470
- package/dist/contracts/xml.d.ts +0 -11
- package/dist/export.d.ts +3 -10
- package/dist/export.js +2 -9
- package/dist/exportDocument.d.ts +1 -12
- package/dist/exportDocument.js +2 -31
- package/dist/features/document/dom/anchors.d.ts +1 -1
- package/dist/features/document/dom/index.d.ts +5 -5
- package/dist/features/document/dom/index.js +3 -3
- package/dist/features/document/dom/providers.d.ts +1 -1
- package/dist/features/document/events.d.ts +2 -2
- package/dist/features/document/events.js +3 -3
- package/dist/features/document/fit.d.ts +1 -1
- package/dist/features/document/fit.js +1 -1
- package/dist/features/document/imageHandTool.d.ts +0 -2
- package/dist/features/document/imageHandTool.js +1 -5
- package/dist/features/document/model.d.ts +1 -1
- package/dist/features/document/search.d.ts +1 -1
- package/dist/features/document/search.js +2 -2
- package/dist/features/document/viewState.d.ts +1 -1
- package/dist/features/document/viewState.js +2 -2
- package/dist/features/document/zoom.d.ts +1 -1
- package/dist/features/document/zoom.js +3 -3
- package/dist/features/document/zoomGestures.d.ts +2 -2
- package/dist/features/document/zoomGestures.js +0 -2
- package/dist/features/printMask.d.ts +1 -1
- package/dist/features/printMaskDesigner.d.ts +2 -6
- package/dist/features/printMaskDesigner.js +2 -11
- package/dist/features/printMaskLoader.d.ts +1 -7
- package/dist/features/printMaskLoader.js +1 -7
- package/dist/features/watermark.d.ts +1 -1
- package/dist/headless.d.ts +29 -29
- package/dist/headless.js +16 -21
- package/dist/i18n/messages.d.ts +1 -1
- package/dist/i18n/messages.de.d.ts +1 -5
- package/dist/i18n/messages.de.js +1 -5
- package/dist/i18n/messages.ja.d.ts +1 -6
- package/dist/i18n/messages.ja.js +1 -6
- package/dist/i18n/messages.js +4 -4
- package/dist/index.d.ts +77 -77
- package/dist/index.js +39 -39
- package/dist/lifecycle/facade.d.ts +4 -4
- package/dist/lifecycle/facade.js +2 -2
- package/dist/lifecycle/operations.d.ts +4 -5
- package/dist/lifecycle/operations.js +4 -10
- package/dist/output/canvasImage.d.ts +1 -2
- package/dist/output/canvasImage.js +1 -4
- package/dist/output/export.d.ts +1 -3
- package/dist/output/export.js +0 -12
- package/dist/output/printLayout.d.ts +0 -5
- package/dist/output/printLayout.js +0 -4
- package/dist/output/snapshotDownload.d.ts +1 -2
- package/dist/output/snapshotDownload.js +2 -3
- package/dist/platform/assets.d.ts +4 -11
- package/dist/platform/assets.js +20 -45
- package/dist/platform/copiedAssets.d.ts +0 -1
- package/dist/platform/copiedAssets.js +1 -2
- package/dist/presentation/colorScheme.d.ts +1 -2
- package/dist/presentation/colorScheme.js +1 -2
- package/dist/presentation/state.d.ts +1 -1
- package/dist/presentation/state.js +3 -3
- package/dist/print-mask.d.ts +2 -2
- package/dist/print-mask.js +1 -1
- package/dist/registry/capabilities.d.ts +1 -14
- package/dist/registry/capabilities.js +2 -15
- package/dist/registry/formats.d.ts +1 -1
- package/dist/registry/formats.generated.d.ts +2 -3
- package/dist/registry/formats.generated.js +2 -3
- package/dist/registry/formats.js +2 -2
- package/dist/registry/registry.d.ts +1 -15
- package/dist/registry/registry.js +2 -10
- package/dist/renderers/image.d.ts +1 -1
- package/dist/renderers/image.js +5 -7
- package/dist/renderers/index.d.ts +3 -3
- package/dist/renderers/index.js +5 -11
- package/dist/rendering/dispatcher.d.ts +1 -6
- package/dist/rendering/dispatcher.js +3 -3
- package/dist/rendering/handler.d.ts +3 -13
- package/dist/rendering/handler.js +9 -21
- package/dist/security/svgResources.d.ts +0 -10
- package/dist/security/svgResources.js +0 -12
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +1 -1
- package/dist/source/loading.d.ts +4 -4
- package/dist/source/loading.js +4 -7
- package/dist/source/precheck.d.ts +1 -13
- package/dist/source/precheck.js +2 -9
- package/dist/source/textEncoding.d.ts +0 -18
- package/dist/source/textEncoding.js +0 -15
- package/dist/viewer/createViewer.d.ts +1 -1
- package/dist/viewer/createViewer.js +17 -28
- package/dist/viewer/loading.d.ts +2 -6
- package/dist/viewer/loading.js +1 -9
- package/dist/viewer/operations.d.ts +3 -3
- package/dist/viewer/operations.js +6 -14
- package/dist/viewer/state.d.ts +2 -6
- package/dist/viewer/state.js +3 -8
- package/package.json +3 -1
package/dist/contracts/xml.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Optional, self-hosted XML Schema 1.0 / XSLT 1.0 profiles. */
|
|
2
1
|
export interface FileViewerXmlProfile {
|
|
3
2
|
id: string;
|
|
4
3
|
match: {
|
|
@@ -11,7 +10,6 @@ export interface FileViewerXmlProfile {
|
|
|
11
10
|
enabled: boolean;
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
/** Relative to the manifest URL (or baseUrl for inline profiles). */
|
|
15
13
|
xsd?: string;
|
|
16
14
|
xslt: string;
|
|
17
15
|
}
|
|
@@ -25,21 +23,14 @@ export interface FileViewerXmlDiagnostic {
|
|
|
25
23
|
profileId?: string;
|
|
26
24
|
}
|
|
27
25
|
export interface FileViewerXmlOptions {
|
|
28
|
-
/** Opt in with a same-origin HTTP(S) manifest. Redirects are rejected. */
|
|
29
26
|
profilesUrl?: string;
|
|
30
|
-
/** Alternative to profilesUrl. Supplying both is a configuration error. */
|
|
31
27
|
profiles?: FileViewerXmlProfile[];
|
|
32
|
-
/** Base for inline profiles' resource paths; defaults to the document URL. */
|
|
33
28
|
baseUrl?: string;
|
|
34
29
|
runtime?: {
|
|
35
|
-
/** xmllint-wasm@5.3.0 browser worker; xmllint.wasm must be beside it. */
|
|
36
30
|
xsdWorkerUrl?: string;
|
|
37
|
-
/** xslt-polyfill@1.0.29 dist/xslt-wasm.js, containing embedded WASM. */
|
|
38
31
|
xsltModuleUrl?: string;
|
|
39
32
|
};
|
|
40
|
-
/** Whole profile operation, including downloads; default 15s, ceiling 60s. */
|
|
41
33
|
timeoutMs?: number;
|
|
42
|
-
/** Limits may lower the hard ceilings but cannot disable them. */
|
|
43
34
|
limits?: {
|
|
44
35
|
maxXmlBytes?: number;
|
|
45
36
|
maxResourceBytes?: number;
|
|
@@ -48,12 +39,10 @@ export interface FileViewerXmlOptions {
|
|
|
48
39
|
maxTotalResourceBytes?: number;
|
|
49
40
|
};
|
|
50
41
|
initialView?: 'source' | 'rendered';
|
|
51
|
-
/** Labels can be localized without replacing the source renderer. */
|
|
52
42
|
labels?: {
|
|
53
43
|
viewSource?: string;
|
|
54
44
|
viewRendered?: string;
|
|
55
45
|
diagnostics?: string;
|
|
56
46
|
};
|
|
57
|
-
/** Also available on the rendered instance; never contains generated HTML. */
|
|
58
47
|
onDiagnostic?: (diagnostic: FileViewerXmlDiagnostic) => void;
|
|
59
48
|
}
|
package/dist/export.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* This subpath owns the DOM sanitizer and is intentionally excluded from the
|
|
5
|
-
* normal viewer/headless graph. Viewer operations load it only when the user
|
|
6
|
-
* starts an HTML export or print operation.
|
|
7
|
-
*/
|
|
8
|
-
export { buildFileViewerRenderedDomDocument, buildFileViewerRenderedHtmlDocument, buildExportDomDocument, buildExportHtmlDocument, collectDocumentStyles, sanitizeFileViewerExportDocumentDom, sanitizeFileViewerExportDocumentHtml, } from './exportDocument.js';
|
|
9
|
-
export type { BuildExportHtmlDocumentOptions, BuildFileViewerRenderedHtmlDocumentOptions, } from './exportDocument.js';
|
|
10
|
-
export { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerImages, waitForFileViewerNextPaint, waitForFileViewerPrintWindowReady, } from './output/export.js';
|
|
1
|
+
export { buildFileViewerRenderedDomDocument, buildFileViewerRenderedHtmlDocument, buildExportDomDocument, buildExportHtmlDocument, collectDocumentStyles, sanitizeFileViewerExportDocumentDom, sanitizeFileViewerExportDocumentHtml, } from "./exportDocument.js";
|
|
2
|
+
export type { BuildExportHtmlDocumentOptions, BuildFileViewerRenderedHtmlDocumentOptions, } from "./exportDocument.js";
|
|
3
|
+
export { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerImages, waitForFileViewerNextPaint, waitForFileViewerPrintWindowReady, } from "./output/export.js";
|
package/dist/export.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This subpath owns the DOM sanitizer and is intentionally excluded from the
|
|
5
|
-
* normal viewer/headless graph. Viewer operations load it only when the user
|
|
6
|
-
* starts an HTML export or print operation.
|
|
7
|
-
*/
|
|
8
|
-
export { buildFileViewerRenderedDomDocument, buildFileViewerRenderedHtmlDocument, buildExportDomDocument, buildExportHtmlDocument, collectDocumentStyles, sanitizeFileViewerExportDocumentDom, sanitizeFileViewerExportDocumentHtml, } from './exportDocument.js';
|
|
9
|
-
export { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerImages, waitForFileViewerNextPaint, waitForFileViewerPrintWindowReady, } from './output/export.js';
|
|
1
|
+
export { buildFileViewerRenderedDomDocument, buildFileViewerRenderedHtmlDocument, buildExportDomDocument, buildExportHtmlDocument, collectDocumentStyles, sanitizeFileViewerExportDocumentDom, sanitizeFileViewerExportDocumentHtml, } from "./exportDocument.js";
|
|
2
|
+
export { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerImages, waitForFileViewerNextPaint, waitForFileViewerPrintWindowReady, } from "./output/export.js";
|
package/dist/exportDocument.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type { FileRenderExportAdapter, FileRenderExportMode, FileViewerPrintMaskOptions } from
|
|
2
|
-
/**
|
|
3
|
-
* Sanitize the complete standalone export document before it is downloaded or
|
|
4
|
-
* mounted into a print window. This is deliberately enforced in core because
|
|
5
|
-
* third-party render adapters and watermark overrides are library inputs.
|
|
6
|
-
*/
|
|
1
|
+
import type { FileRenderExportAdapter, FileRenderExportMode, FileViewerPrintMaskOptions } from "./contracts/types.js";
|
|
7
2
|
export declare const sanitizeFileViewerExportDocumentHtml: (html: string, documentRef?: Document) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Produce a sanitized, inert document tree for the print-window mount path.
|
|
10
|
-
* Returning DOM here avoids reinterpreting the sanitized string through a
|
|
11
|
-
* second HTML sink such as document.write or innerHTML.
|
|
12
|
-
*/
|
|
13
3
|
export declare const sanitizeFileViewerExportDocumentDom: (html: string, documentRef?: Document) => HTMLHtmlElement;
|
|
14
4
|
export interface BuildExportHtmlDocumentOptions {
|
|
15
5
|
contentHtml: string;
|
|
@@ -18,7 +8,6 @@ export interface BuildExportHtmlDocumentOptions {
|
|
|
18
8
|
title: string;
|
|
19
9
|
watermarkInlineStyle?: string;
|
|
20
10
|
mask?: FileViewerPrintMaskOptions | null;
|
|
21
|
-
/** Document whose Window owns the sanitizer. Defaults to the active document. */
|
|
22
11
|
documentRef?: Document;
|
|
23
12
|
}
|
|
24
13
|
export declare const collectDocumentStyles: (documentRef?: Document) => string;
|
package/dist/exportDocument.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import createDOMPurify from 'dompurify';
|
|
2
|
-
import { applyFileViewerPagePrintMasksToHtml, buildFileViewerPrintMaskOverlayHtml, FILE_VIEWER_PRINT_MASK_STYLE, normalizeFileViewerPrintMaskOptions, } from
|
|
3
|
-
import { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, } from
|
|
2
|
+
import { applyFileViewerPagePrintMasksToHtml, buildFileViewerPrintMaskOverlayHtml, FILE_VIEWER_PRINT_MASK_STYLE, normalizeFileViewerPrintMaskOptions, } from "./features/printMask.js";
|
|
3
|
+
import { inlineFileViewerBlobUrlsInHtml, prepareFileViewerRenderedContentForSnapshot, replaceFileViewerCanvasWithImages, resolveFileViewerPrintStyle, } from "./output/export.js";
|
|
4
4
|
const escapeHtmlAttribute = (value) => value
|
|
5
5
|
.replace(/&/g, '&')
|
|
6
6
|
.replace(/"/g, '"')
|
|
@@ -47,11 +47,6 @@ const decodeCssEscape = (value, slashIndex) => {
|
|
|
47
47
|
}
|
|
48
48
|
return { value: first, nextIndex: cursor + 1 };
|
|
49
49
|
};
|
|
50
|
-
/**
|
|
51
|
-
* Remove CSS comments and decode identifier escapes before looking for URL
|
|
52
|
-
* functions. CSS comments and escapes may otherwise split security-sensitive
|
|
53
|
-
* tokens such as `url` or `@import` while the browser still accepts them.
|
|
54
|
-
*/
|
|
55
50
|
const canonicalizeCssForSecurity = (css) => {
|
|
56
51
|
let output = '';
|
|
57
52
|
let quote = '';
|
|
@@ -246,12 +241,6 @@ const inspectCssNetworkTokens = (css) => {
|
|
|
246
241
|
}
|
|
247
242
|
return { hasImport, hasUrl };
|
|
248
243
|
};
|
|
249
|
-
/**
|
|
250
|
-
* Keep ordinary CSS and local embedded resources, but remove every construct
|
|
251
|
-
* that can make an exported document initiate a new network request. Imported
|
|
252
|
-
* stylesheets fail closed; unsafe url() values become `none` so the rest of a
|
|
253
|
-
* declaration can still render.
|
|
254
|
-
*/
|
|
255
244
|
const sanitizeExportCss = (css) => {
|
|
256
245
|
const canonical = canonicalizeCssForSecurity(css);
|
|
257
246
|
const canonicalTokens = inspectCssNetworkTokens(canonical);
|
|
@@ -353,13 +342,9 @@ const getExportPurifier = (documentRef) => {
|
|
|
353
342
|
element.setAttribute('rel', 'noopener noreferrer');
|
|
354
343
|
}
|
|
355
344
|
if (localName === 'a' || localName === 'area') {
|
|
356
|
-
// Keep ordinary links, but never preserve document-controlled beacons.
|
|
357
345
|
element.removeAttribute('ping');
|
|
358
346
|
}
|
|
359
347
|
if (element.hasAttribute('srcset')) {
|
|
360
|
-
// Candidate lists have their own comma/descriptor grammar. The export
|
|
361
|
-
// keeps the materialized src and drops candidates that could select a
|
|
362
|
-
// remote resource after the standalone document is opened.
|
|
363
348
|
element.removeAttribute('srcset');
|
|
364
349
|
}
|
|
365
350
|
if (['img', 'audio', 'video', 'source', 'track', 'input'].includes(localName || '')) {
|
|
@@ -392,19 +377,12 @@ const EXPORT_STATIC_META = [
|
|
|
392
377
|
'<meta charset="utf-8" />',
|
|
393
378
|
'<meta name="viewport" content="width=device-width,initial-scale=1" />',
|
|
394
379
|
].join('\n ');
|
|
395
|
-
/**
|
|
396
|
-
* Sanitize the complete standalone export document before it is downloaded or
|
|
397
|
-
* mounted into a print window. This is deliberately enforced in core because
|
|
398
|
-
* third-party render adapters and watermark overrides are library inputs.
|
|
399
|
-
*/
|
|
400
380
|
export const sanitizeFileViewerExportDocumentHtml = (html, documentRef) => {
|
|
401
381
|
const currentDocument = resolveExportDocument(documentRef);
|
|
402
382
|
const purifier = currentDocument
|
|
403
383
|
? getExportPurifier(currentDocument)
|
|
404
384
|
: null;
|
|
405
385
|
if (!purifier) {
|
|
406
|
-
// Export is a browser feature. Fail closed rather than return executable
|
|
407
|
-
// markup when called without a usable DOM implementation.
|
|
408
386
|
return '<!doctype html>\n<html lang="en"><head><meta charset="utf-8" /></head><body></body></html>';
|
|
409
387
|
}
|
|
410
388
|
const sanitized = String(purifier.sanitize(html, EXPORT_SANITIZER_OPTIONS));
|
|
@@ -439,11 +417,6 @@ const ensureFileViewerExportDocumentMeta = (root) => {
|
|
|
439
417
|
}
|
|
440
418
|
return root;
|
|
441
419
|
};
|
|
442
|
-
/**
|
|
443
|
-
* Produce a sanitized, inert document tree for the print-window mount path.
|
|
444
|
-
* Returning DOM here avoids reinterpreting the sanitized string through a
|
|
445
|
-
* second HTML sink such as document.write or innerHTML.
|
|
446
|
-
*/
|
|
447
420
|
export const sanitizeFileViewerExportDocumentDom = (html, documentRef) => {
|
|
448
421
|
const currentDocument = resolveExportDocument(documentRef);
|
|
449
422
|
if (!currentDocument) {
|
|
@@ -806,8 +779,6 @@ export const collectDocumentStyles = (documentRef) => {
|
|
|
806
779
|
: '';
|
|
807
780
|
}
|
|
808
781
|
catch {
|
|
809
|
-
// Cross-origin and unreadable stylesheets fail closed. Keeping their
|
|
810
|
-
// link would make a standalone export initiate a second request.
|
|
811
782
|
return '';
|
|
812
783
|
}
|
|
813
784
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerDocumentAnchor } from
|
|
1
|
+
import type { FileViewerDocumentAnchor } from "../../../contracts/types.js";
|
|
2
2
|
export declare const DEFAULT_FILE_VIEWER_ANCHOR_SELECTOR: string;
|
|
3
3
|
export declare const DEFAULT_FILE_VIEWER_ANCHOR_EXCLUDE_SELECTOR: string;
|
|
4
4
|
export declare const collectFileViewerDocumentAnchors: (root: HTMLElement | null) => FileViewerDocumentAnchor[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DEFAULT_FILE_VIEWER_ANCHOR_EXCLUDE_SELECTOR, DEFAULT_FILE_VIEWER_ANCHOR_SELECTOR, collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, getCurrentFileViewerDocumentAnchor, scrollToFileViewerDocumentAnchor, } from
|
|
2
|
-
export { findFileViewerSearchProvider, findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerSearchProvider, registerFileViewerViewStateProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerViewStateProvider, unregisterFileViewerZoomProvider, } from
|
|
3
|
-
export type { FileViewerSearchProviderHost, FileViewerViewStateProviderHost, FileViewerZoomProviderHost, } from
|
|
4
|
-
export { DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_CANDIDATE_SELECTOR, DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_SELECTOR, DEFAULT_FILE_VIEWER_SCROLLABLE_OVERFLOW_VALUES, getFileViewerScrollableRange, isFileViewerScrollableElement, resolveFileViewerScrollContainer, } from
|
|
5
|
-
export type { ResolveFileViewerScrollContainerOptions, } from
|
|
1
|
+
export { DEFAULT_FILE_VIEWER_ANCHOR_EXCLUDE_SELECTOR, DEFAULT_FILE_VIEWER_ANCHOR_SELECTOR, collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, getCurrentFileViewerDocumentAnchor, scrollToFileViewerDocumentAnchor, } from "./anchors.js";
|
|
2
|
+
export { findFileViewerSearchProvider, findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerSearchProvider, registerFileViewerViewStateProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerViewStateProvider, unregisterFileViewerZoomProvider, } from "./providers.js";
|
|
3
|
+
export type { FileViewerSearchProviderHost, FileViewerViewStateProviderHost, FileViewerZoomProviderHost, } from "./providers.js";
|
|
4
|
+
export { DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_CANDIDATE_SELECTOR, DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_SELECTOR, DEFAULT_FILE_VIEWER_SCROLLABLE_OVERFLOW_VALUES, getFileViewerScrollableRange, isFileViewerScrollableElement, resolveFileViewerScrollContainer, } from "./scroll.js";
|
|
5
|
+
export type { ResolveFileViewerScrollContainerOptions, } from "./scroll.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DEFAULT_FILE_VIEWER_ANCHOR_EXCLUDE_SELECTOR, DEFAULT_FILE_VIEWER_ANCHOR_SELECTOR, collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, getCurrentFileViewerDocumentAnchor, scrollToFileViewerDocumentAnchor, } from
|
|
2
|
-
export { findFileViewerSearchProvider, findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerSearchProvider, registerFileViewerViewStateProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerViewStateProvider, unregisterFileViewerZoomProvider, } from
|
|
3
|
-
export { DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_CANDIDATE_SELECTOR, DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_SELECTOR, DEFAULT_FILE_VIEWER_SCROLLABLE_OVERFLOW_VALUES, getFileViewerScrollableRange, isFileViewerScrollableElement, resolveFileViewerScrollContainer, } from
|
|
1
|
+
export { DEFAULT_FILE_VIEWER_ANCHOR_EXCLUDE_SELECTOR, DEFAULT_FILE_VIEWER_ANCHOR_SELECTOR, collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, getCurrentFileViewerDocumentAnchor, scrollToFileViewerDocumentAnchor, } from "./anchors.js";
|
|
2
|
+
export { findFileViewerSearchProvider, findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerSearchProvider, registerFileViewerViewStateProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerViewStateProvider, unregisterFileViewerZoomProvider, } from "./providers.js";
|
|
3
|
+
export { DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_CANDIDATE_SELECTOR, DEFAULT_FILE_VIEWER_SCROLL_CONTAINER_SELECTOR, DEFAULT_FILE_VIEWER_SCROLLABLE_OVERFLOW_VALUES, getFileViewerScrollableRange, isFileViewerScrollableElement, resolveFileViewerScrollContainer, } from "./scroll.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerSearchProvider, FileViewerViewStateProvider, FileViewerZoomProvider } from
|
|
1
|
+
import type { FileViewerSearchProvider, FileViewerViewStateProvider, FileViewerZoomProvider } from "../../../contracts/types.js";
|
|
2
2
|
export interface FileViewerSearchProviderHost extends HTMLElement {
|
|
3
3
|
__flyfishViewerSearchProvider?: FileViewerSearchProvider;
|
|
4
4
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FileViewerDomSearchControllerStateTarget } from
|
|
2
|
-
import type { FileViewerAiOptions, FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerSearchOptions, FileViewerSearchState } from
|
|
1
|
+
import { type FileViewerDomSearchControllerStateTarget } from "./search.js";
|
|
2
|
+
import type { FileViewerAiOptions, FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerSearchOptions, FileViewerSearchState } from "../../contracts/types.js";
|
|
3
3
|
export interface ResolveFileViewerLocationChangeAnchorInput {
|
|
4
4
|
root: HTMLElement | null | undefined;
|
|
5
5
|
anchors: FileViewerDocumentAnchor[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buildFileViewerDocumentTextChunks } from
|
|
2
|
-
import { getCurrentFileViewerDocumentAnchor, resolveFileViewerScrollContainer, scrollToFileViewerDocumentAnchor, } from
|
|
3
|
-
import { cloneFileViewerSearchState, createFileViewerDomSearchController, createFileViewerDomSearchControllerActionHandlers, } from
|
|
1
|
+
import { buildFileViewerDocumentTextChunks } from "./model.js";
|
|
2
|
+
import { getCurrentFileViewerDocumentAnchor, resolveFileViewerScrollContainer, scrollToFileViewerDocumentAnchor, } from "./dom/index.js";
|
|
3
|
+
import { cloneFileViewerSearchState, createFileViewerDomSearchController, createFileViewerDomSearchControllerActionHandlers, } from "./search.js";
|
|
4
4
|
export const createFileViewerSearchChangeState = (state) => {
|
|
5
5
|
return cloneFileViewerSearchState(state);
|
|
6
6
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerFitMode, FileViewerFitOptions, FileViewerFitRequest, FileViewerFitResize, FileViewerFitResult, FileViewerViewState, FileViewerViewStateChangeSource } from
|
|
1
|
+
import type { FileViewerFitMode, FileViewerFitOptions, FileViewerFitRequest, FileViewerFitResize, FileViewerFitResult, FileViewerViewState, FileViewerViewStateChangeSource } from "../../contracts/types.js";
|
|
2
2
|
export declare const FILE_VIEWER_FIT_MODES: readonly ["auto", "contain", "cover", "width", "height", "actual", "scale-down"];
|
|
3
3
|
export declare const FILE_VIEWER_FIT_RESIZE_MODES: readonly ["until-interaction", "always", "initial"];
|
|
4
4
|
export interface NormalizedFileViewerFitOptions extends Required<Pick<FileViewerFitOptions, 'mode' | 'resize' | 'padding'>> {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Optional mouse panning for image previews. Touch/pinch, keyboard activation,
|
|
2
|
-
* controls and native scrollbars retain their normal browser behavior. */
|
|
3
1
|
export function installFileViewerImageHandTool(container, signal) {
|
|
4
2
|
const view = container.ownerDocument.defaultView;
|
|
5
3
|
if (!view || (signal === null || signal === void 0 ? void 0 : signal.aborted))
|
|
@@ -62,12 +60,10 @@ export function installFileViewerImageHandTool(container, signal) {
|
|
|
62
60
|
container.setAttribute('data-viewer-image-panning', 'true');
|
|
63
61
|
container.style.cursor = 'grabbing';
|
|
64
62
|
container.style.setProperty('user-select', 'none');
|
|
65
|
-
// Delay capture until a drag starts so an ordinary click still reaches
|
|
66
|
-
// the image's lightbox handler instead of being retargeted to its parent.
|
|
67
63
|
try {
|
|
68
64
|
(_a = container.setPointerCapture) === null || _a === void 0 ? void 0 : _a.call(container, event.pointerId);
|
|
69
65
|
}
|
|
70
|
-
catch {
|
|
66
|
+
catch { }
|
|
71
67
|
}
|
|
72
68
|
container.scrollLeft = drag.left - dx;
|
|
73
69
|
container.scrollTop = drag.top - dy;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerAiOptions, FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerSearchOptions, FileViewerSearchState, FileViewerZoomState } from
|
|
1
|
+
import type { FileViewerAiOptions, FileViewerDocumentAnchor, FileViewerDocumentChunk, FileViewerSearchOptions, FileViewerSearchState, FileViewerZoomState } from "../../contracts/types.js";
|
|
2
2
|
export declare const DEFAULT_FILE_VIEWER_ZOOM_SCALE = 1;
|
|
3
3
|
export declare const DEFAULT_FILE_VIEWER_TEXT_CHUNK_SIZE = 1200;
|
|
4
4
|
export declare const DEFAULT_FILE_VIEWER_TEXT_CHUNK_OVERLAP = 160;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerDocumentAnchor, FileViewerSearchMatch, FileViewerSearchOptions, FileViewerSearchState } from
|
|
1
|
+
import type { FileViewerDocumentAnchor, FileViewerSearchMatch, FileViewerSearchOptions, FileViewerSearchState } from "../../contracts/types.js";
|
|
2
2
|
export interface CreateFileViewerDomSearchControllerOptions {
|
|
3
3
|
root: () => HTMLElement | null | undefined;
|
|
4
4
|
options?: () => boolean | FileViewerSearchOptions | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, findFileViewerSearchProvider, } from
|
|
2
|
-
import { createEmptyFileViewerSearchState, normalizeFileViewerSearchOptions, } from
|
|
1
|
+
import { collectFileViewerDocumentAnchors, findFileViewerAnchorForElement, findFileViewerSearchProvider, } from "./dom/index.js";
|
|
2
|
+
import { createEmptyFileViewerSearchState, normalizeFileViewerSearchOptions, } from "./model.js";
|
|
3
3
|
export const DEFAULT_FILE_VIEWER_SEARCH_MATCH_CLASS = 'flyfish-search-match';
|
|
4
4
|
export const DEFAULT_FILE_VIEWER_SEARCH_ACTIVE_CLASS = 'flyfish-search-match--active';
|
|
5
5
|
export const DEFAULT_FILE_VIEWER_SEARCH_MAX_MATCHES = 1000;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerApplyViewStateOptions, FileViewerViewState, FileViewerViewStateChange, FileViewerViewStateProvider } from
|
|
1
|
+
import type { FileViewerApplyViewStateOptions, FileViewerViewState, FileViewerViewStateChange, FileViewerViewStateProvider } from "../../contracts/types.js";
|
|
2
2
|
export interface RegisterFileViewerGenericViewStateProviderOptions {
|
|
3
3
|
host: HTMLElement;
|
|
4
4
|
renderer?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerViewStateProvider, resolveFileViewerScrollContainer, unregisterFileViewerViewStateProvider, } from
|
|
2
|
-
import { resolveFileViewerFitScale } from
|
|
1
|
+
import { findFileViewerViewStateProvider, findFileViewerZoomProvider, registerFileViewerViewStateProvider, resolveFileViewerScrollContainer, unregisterFileViewerViewStateProvider, } from "./dom/index.js";
|
|
2
|
+
import { resolveFileViewerFitScale } from "./fit.js";
|
|
3
3
|
export const cloneFileViewerViewState = (state) => {
|
|
4
4
|
if (!state) {
|
|
5
5
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerOptions, FileViewerOperationType, FileViewerZoomProvider, FileViewerZoomState } from
|
|
1
|
+
import type { FileViewerOptions, FileViewerOperationType, FileViewerZoomProvider, FileViewerZoomState } from "../../contracts/types.js";
|
|
2
2
|
export type FileViewerZoomOperation = Extract<FileViewerOperationType, 'zoom-in' | 'zoom-out' | 'zoom-reset'>;
|
|
3
3
|
export interface CreateFileViewerZoomControllerOptions {
|
|
4
4
|
root: () => HTMLElement | null | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createFileViewerZoomState } from
|
|
2
|
-
import { findFileViewerZoomProvider } from
|
|
3
|
-
import { installFileViewerZoomGestures } from
|
|
1
|
+
import { createFileViewerZoomState } from "./model.js";
|
|
2
|
+
import { findFileViewerZoomProvider } from "./dom/index.js";
|
|
3
|
+
import { installFileViewerZoomGestures } from "./zoomGestures.js";
|
|
4
4
|
export const cloneFileViewerZoomState = (state) => ({
|
|
5
5
|
scale: state.scale,
|
|
6
6
|
label: state.label,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FileViewerOptions, FileViewerZoomProvider } from
|
|
2
|
-
import type { FileViewerZoomOperation } from
|
|
1
|
+
import type { FileViewerOptions, FileViewerZoomProvider } from "../../contracts/types.js";
|
|
2
|
+
import type { FileViewerZoomOperation } from "./zoom.js";
|
|
3
3
|
interface ZoomGestureOptions {
|
|
4
4
|
provider: () => FileViewerZoomProvider | null;
|
|
5
5
|
enabled: () => boolean;
|
|
@@ -43,8 +43,6 @@ export function installFileViewerZoomGestures(container, options) {
|
|
|
43
43
|
options.onZoom();
|
|
44
44
|
}
|
|
45
45
|
catch {
|
|
46
|
-
// Operation hooks report their errors. Native events have no caller to
|
|
47
|
-
// receive a rejected promise, so do not leak an unhandled rejection.
|
|
48
46
|
}
|
|
49
47
|
finally {
|
|
50
48
|
busy = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from
|
|
1
|
+
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from "../contracts/types.js";
|
|
2
2
|
export declare const normalizeFileViewerPrintMaskRegion: (region: Partial<FileViewerPrintMaskRegion> | null | undefined) => FileViewerPrintMaskRegion | null;
|
|
3
3
|
export declare const normalizeFileViewerPrintStamp: (stamp: Partial<FileViewerPrintStamp> | null | undefined) => FileViewerPrintStamp | null;
|
|
4
4
|
export declare const normalizeFileViewerPrintMaskOptions: (mask?: FileViewerPrintMaskOptions | null) => FileViewerPrintMaskOptions | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from
|
|
2
|
-
import { type FileViewerI18nInput } from
|
|
1
|
+
import type { FileViewerPrintMaskOptions, FileViewerPrintMaskRegion, FileViewerPrintStamp } from "../contracts/types.js";
|
|
2
|
+
import { type FileViewerI18nInput } from "../i18n/messages.js";
|
|
3
3
|
export interface OpenFileViewerPrintMaskDesignerOptions {
|
|
4
4
|
root: HTMLElement;
|
|
5
5
|
pages?: readonly HTMLElement[];
|
|
@@ -11,8 +11,4 @@ export interface OpenFileViewerPrintMaskDesignerOptions {
|
|
|
11
11
|
export interface FileViewerPrintMaskDesignerResult {
|
|
12
12
|
mask: FileViewerPrintMaskOptions;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Opens a page-aware print-mask designer. Browsing remains the default mode;
|
|
16
|
-
* drawing is armed for the currently visible page only and disarms after one block.
|
|
17
|
-
*/
|
|
18
14
|
export declare const openFileViewerPrintMaskDesigner: (options: OpenFileViewerPrintMaskDesignerOptions) => Promise<FileViewerPrintMaskDesignerResult | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createFileViewerTranslator } from
|
|
2
|
-
import { normalizeFileViewerPrintMaskRegion, normalizeFileViewerPrintStamp, } from
|
|
1
|
+
import { createFileViewerTranslator } from "../i18n/messages.js";
|
|
2
|
+
import { normalizeFileViewerPrintMaskRegion, normalizeFileViewerPrintStamp, } from "./printMask.js";
|
|
3
3
|
const DESIGNER_STYLE = `
|
|
4
4
|
.fv-print-mask-layer{position:absolute;inset:0;z-index:2147483000;pointer-events:none;}
|
|
5
5
|
.fv-print-mask-canvas{position:absolute;inset:0;z-index:2147483000;pointer-events:none;cursor:default;}
|
|
@@ -74,10 +74,6 @@ const readStampFileAsDataUrl = (file, windowRef) => new Promise((resolve, reject
|
|
|
74
74
|
reader.addEventListener('error', () => reject(reader.error || new Error('Failed to read print stamp image')));
|
|
75
75
|
reader.readAsDataURL(file);
|
|
76
76
|
});
|
|
77
|
-
/**
|
|
78
|
-
* Opens a page-aware print-mask designer. Browsing remains the default mode;
|
|
79
|
-
* drawing is armed for the currently visible page only and disarms after one block.
|
|
80
|
-
*/
|
|
81
77
|
export const openFileViewerPrintMaskDesigner = (options) => {
|
|
82
78
|
const root = options.root;
|
|
83
79
|
const documentRef = root.ownerDocument;
|
|
@@ -105,8 +101,6 @@ export const openFileViewerPrintMaskDesigner = (options) => {
|
|
|
105
101
|
}
|
|
106
102
|
return previousPosition;
|
|
107
103
|
};
|
|
108
|
-
// The toolbar layer is positioned against the viewer root even when page
|
|
109
|
-
// canvases live on child page elements.
|
|
110
104
|
const previousRootPosition = ensureOverlayContainingBlock(root);
|
|
111
105
|
return new Promise(resolve => {
|
|
112
106
|
let settled = false;
|
|
@@ -316,7 +310,6 @@ export const openFileViewerPrintMaskDesigner = (options) => {
|
|
|
316
310
|
(_a = stampElement.releasePointerCapture) === null || _a === void 0 ? void 0 : _a.call(stampElement, interaction.pointerId);
|
|
317
311
|
}
|
|
318
312
|
catch {
|
|
319
|
-
// Pointer capture may already be released by the browser.
|
|
320
313
|
}
|
|
321
314
|
interaction = null;
|
|
322
315
|
};
|
|
@@ -371,7 +364,6 @@ export const openFileViewerPrintMaskDesigner = (options) => {
|
|
|
371
364
|
surface.canvas.releasePointerCapture(drawing.pointerId);
|
|
372
365
|
}
|
|
373
366
|
catch {
|
|
374
|
-
// Pointer capture may already be released by the browser.
|
|
375
367
|
}
|
|
376
368
|
drawing = null;
|
|
377
369
|
disarm();
|
|
@@ -435,7 +427,6 @@ export const openFileViewerPrintMaskDesigner = (options) => {
|
|
|
435
427
|
}
|
|
436
428
|
}
|
|
437
429
|
catch {
|
|
438
|
-
// Unsupported or unreadable images are ignored; the document stays untouched.
|
|
439
430
|
}
|
|
440
431
|
});
|
|
441
432
|
clearButton.addEventListener('click', () => {
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import type { FileViewerPrintMaskDesignerResult, OpenFileViewerPrintMaskDesignerOptions } from
|
|
2
|
-
/**
|
|
3
|
-
* Lazily opens the print-mask designer.
|
|
4
|
-
* Kept as a dynamic import so the designer stays out of the main core graph,
|
|
5
|
-
* while remaining reachable through the primary `@file-viewer/core` entry
|
|
6
|
-
* (no consumer alias / subpath setup required).
|
|
7
|
-
*/
|
|
1
|
+
import type { FileViewerPrintMaskDesignerResult, OpenFileViewerPrintMaskDesignerOptions } from "./printMaskDesigner.js";
|
|
8
2
|
export declare const openFileViewerPrintMaskDesignerAsync: (options: OpenFileViewerPrintMaskDesignerOptions) => Promise<FileViewerPrintMaskDesignerResult | null>;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazily opens the print-mask designer.
|
|
3
|
-
* Kept as a dynamic import so the designer stays out of the main core graph,
|
|
4
|
-
* while remaining reachable through the primary `@file-viewer/core` entry
|
|
5
|
-
* (no consumer alias / subpath setup required).
|
|
6
|
-
*/
|
|
7
1
|
export const openFileViewerPrintMaskDesignerAsync = async (options) => {
|
|
8
|
-
const { openFileViewerPrintMaskDesigner } = await import(
|
|
2
|
+
const { openFileViewerPrintMaskDesigner } = await import("../print-mask.js");
|
|
9
3
|
return openFileViewerPrintMaskDesigner(options);
|
|
10
4
|
};
|