mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
092035c564
commit
a9e10886c6
3 changed files with 23 additions and 23 deletions
|
|
@ -79,7 +79,6 @@ import { ViewHistory } from './view_history.js'
|
|||
import { Constants } from '../../constants'
|
||||
import { GenericExternalServices } from './genericcom'
|
||||
import { getPdfInstance, hlPDFRect } from '../anno'
|
||||
import { getAllModels } from '../../layout/getAll'
|
||||
|
||||
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000 // ms
|
||||
const FORCE_PAGES_LOADED_TIMEOUT = 10000 // ms
|
||||
|
|
@ -1772,7 +1771,6 @@ class PDFViewerApplication {
|
|||
_boundEvents.beforePrint = this.beforePrint.bind(this)
|
||||
_boundEvents.afterPrint = this.afterPrint.bind(this)
|
||||
|
||||
eventBus._on('resize', webViewerResize)
|
||||
eventBus._on('hashchange', webViewerHashchange)
|
||||
eventBus._on('beforeprint', _boundEvents.beforePrint)
|
||||
eventBus._on('afterprint', _boundEvents.afterPrint)
|
||||
|
|
@ -1868,7 +1866,6 @@ class PDFViewerApplication {
|
|||
unbindEvents () {
|
||||
const {eventBus, _boundEvents} = this
|
||||
|
||||
eventBus._off('resize', webViewerResize)
|
||||
eventBus._off('hashchange', webViewerHashchange)
|
||||
eventBus._off('beforeprint', _boundEvents.beforePrint)
|
||||
eventBus._off('afterprint', _boundEvents.afterPrint)
|
||||
|
|
@ -2357,26 +2354,6 @@ function webViewerSpreadModeChanged (evt) {
|
|||
}
|
||||
}
|
||||
|
||||
function webViewerResize () {
|
||||
getAllModels().asset.find(item => {
|
||||
const pdfInstance = item.pdfObject
|
||||
const {pdfDocument, pdfViewer} = pdfInstance
|
||||
if (!pdfDocument) {
|
||||
return
|
||||
}
|
||||
const currentScaleValue = pdfViewer.currentScaleValue
|
||||
if (
|
||||
currentScaleValue === 'auto' ||
|
||||
currentScaleValue === 'page-fit' ||
|
||||
currentScaleValue === 'page-width'
|
||||
) {
|
||||
// Note: the scale is constant for 'page-actual'.
|
||||
pdfViewer.currentScaleValue = currentScaleValue
|
||||
}
|
||||
pdfViewer.update()
|
||||
})
|
||||
}
|
||||
|
||||
function webViewerHashchange (evt) {
|
||||
const hash = evt.hash
|
||||
if (!hash) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {Constants} from "../constants";
|
||||
import {pathPosix} from "../util/pathName";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
|
||||
export const renderAssetsPreview = (pathString: string) => {
|
||||
if (!pathString) {
|
||||
|
|
@ -16,3 +17,23 @@ export const renderAssetsPreview = (pathString: string) => {
|
|||
return pathString;
|
||||
}
|
||||
};
|
||||
|
||||
export const pdfResize = () => {
|
||||
getAllModels().asset.find(item => {
|
||||
const pdfInstance = item.pdfObject
|
||||
const {pdfDocument, pdfViewer} = pdfInstance
|
||||
if (!pdfDocument) {
|
||||
return
|
||||
}
|
||||
const currentScaleValue = pdfViewer.currentScaleValue
|
||||
if (
|
||||
currentScaleValue === 'auto' ||
|
||||
currentScaleValue === 'page-fit' ||
|
||||
currentScaleValue === 'page-width'
|
||||
) {
|
||||
// Note: the scale is constant for 'page-actual'.
|
||||
pdfViewer.currentScaleValue = currentScaleValue
|
||||
}
|
||||
pdfViewer.update()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
|
|||
import {Constants} from "../constants";
|
||||
import {openSearch} from "../search/spread";
|
||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||
import {pdfResize} from "../asset/renderAssets";
|
||||
|
||||
export const setPanelFocus = (element: Element) => {
|
||||
if (element.classList.contains("block__icons--active") || element.classList.contains("layout__wnd--active")) {
|
||||
|
|
@ -429,6 +430,7 @@ export const resizeTabs = () => {
|
|||
}, 200);
|
||||
}
|
||||
});
|
||||
pdfResize();
|
||||
};
|
||||
|
||||
export const copyTab = (tab: Tab) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue