2022-08-27 14:32:20 +02:00
|
|
|
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';
|
|
|
|
|
2022-09-05 13:35:38 +02:00
|
|
|
require('./common.css');
|
2022-08-27 14:32:20 +02:00
|
|
|
|
|
|
|
// 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');
|
2022-09-05 13:35:38 +02:00
|
|
|
const anchorPage = Number(window.frameElement.getAttribute('x-anchorPage')) || null;
|
2022-08-27 14:32:20 +02:00
|
|
|
const pdfId = window.frameElement.getAttribute('id');
|
|
|
|
|
|
|
|
document.documentElement.setAttribute('data-theme', appearance);
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
if (type === 'mini') {
|
2022-09-05 13:35:38 +02:00
|
|
|
return <MiniViewerApp pdfPath={url}
|
|
|
|
isDarkTheme={appearance === 'dark'}
|
|
|
|
anchorPage={anchorPage}
|
|
|
|
pdfId={pdfId} />;
|
2022-08-27 14:32:20 +02:00
|
|
|
}
|
|
|
|
return <div>Error: Unknown app type "{type}"</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
render(
|
|
|
|
<App/>,
|
|
|
|
document.getElementById('pdf-root')
|
|
|
|
);
|