1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Desktop: PDF scroll persistence (#6747)

This commit is contained in:
asrient
2022-08-27 18:02:20 +05:30
committed by GitHub
parent ed2a328616
commit 3ec3a37603
21 changed files with 494 additions and 234 deletions

View File

@@ -0,0 +1,31 @@
import React from 'react';
import shim from '@joplin/lib/shim';
shim.setReact(React);
import { render } from 'react-dom';
import * as pdfjsLib from 'pdfjs-dist';
import MiniViewerApp from './miniViewer';
require('./viewer.css');
// Setting worker path to worker bundle.
pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdf.worker.js';
const url = window.frameElement.getAttribute('x-url');
const type = window.frameElement.getAttribute('x-type');
const appearance = window.frameElement.getAttribute('x-appearance');
const anchorPage = window.frameElement.getAttribute('x-anchorPage');
const pdfId = window.frameElement.getAttribute('id');
document.documentElement.setAttribute('data-theme', appearance);
function App() {
if (type === 'mini') {
return <MiniViewerApp pdfPath={url} isDarkTheme={appearance === 'dark'} anchorPage={anchorPage ? Number(anchorPage) : null} pdfId={pdfId} />;
}
return <div>Error: Unknown app type "{type}"</div>;
}
render(
<App/>,
document.getElementById('pdf-root')
);