diff --git a/src/common/reader.js b/src/common/reader.js index 6e2a985d..994fafd8 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -59,6 +59,7 @@ class Reader { this._onIframeTab = options.onIframeTab; // Only used on Zotero client, sets text/plain and text/html values from Note Markdown and Note HTML translators this._onSetDataTransferAnnotations = options.onSetDataTransferAnnotations; + this._onSetZoom = options.onSetZoom; this._localizedStrings = options.localizedStrings; @@ -736,6 +737,10 @@ class Reader { this._keyboardManager.handleViewKeyUp(event); }; + let onSetZoom = (iframe, zoom) => { + this._onSetZoom(iframe, zoom); + }; + let data; if (this._type === 'pdf') { data = this._data; @@ -811,7 +816,8 @@ class Reader { }); } else if (this._type === 'snapshot') { view = new SnapshotView({ - ...common + ...common, + onSetZoom }); } diff --git a/src/dom/common/dom-view.tsx b/src/dom/common/dom-view.tsx index a64deff6..07321cef 100644 --- a/src/dom/common/dom-view.tsx +++ b/src/dom/common/dom-view.tsx @@ -1205,6 +1205,7 @@ export type DOMViewOptions = { onSetAnnotationPopup: (params?: AnnotationPopupParams | null) => void; onSetOverlayPopup: (params?: OverlayPopupParams) => void; onSetFindState: (state?: FindState) => void; + onSetZoom?: (iframe: HTMLIFrameElement, zoom: number) => void; onOpenViewContextMenu: (params: { x: number, y: number }) => void; onOpenAnnotationContextMenu: (params: { ids: string[], x: number, y: number, view: boolean }) => void; onFocus: () => void; diff --git a/src/dom/snapshot/snapshot-view.ts b/src/dom/snapshot/snapshot-view.ts index f4de99c8..21417dd3 100644 --- a/src/dom/snapshot/snapshot-view.ts +++ b/src/dom/snapshot/snapshot-view.ts @@ -438,17 +438,23 @@ class SnapshotView extends DOMView { private _setScale(scale: number) { this._scale = scale; - if (scale == 1) { - this._iframeDocument.documentElement.style.fontSize = ''; - return; + + if (this._options.onSetZoom) { + this._options.onSetZoom(this._iframe, scale); } + else { + if (scale == 1) { + this._iframeDocument.documentElement.style.fontSize = ''; + return; + } - // Calculate the default root font size, then multiply by scale. - // Can't just set font-size to an em value -- the page itself might set a font-size on , and we need to - // scale relative to that. - this._iframeDocument.documentElement.style.fontSize = ''; - let defaultSize = parseFloat(getComputedStyle(this._iframeDocument.documentElement).fontSize); - this._iframeDocument.documentElement.style.fontSize = (defaultSize * scale) + 'px'; + // Calculate the default root font size, then multiply by scale. + // Can't just set font-size to an em value -- the page itself might set a font-size on , and we need to + // scale relative to that. + this._iframeDocument.documentElement.style.fontSize = ''; + let defaultSize = parseFloat(getComputedStyle(this._iframeDocument.documentElement).fontSize); + this._iframeDocument.documentElement.style.fontSize = (defaultSize * scale) + 'px'; + } } override navigate(location: NavLocation, options: NavigateOptions = {}) {