1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: New Embedded Pdf Viewer (#6681)

This commit is contained in:
asrient
2022-08-04 14:42:22 +05:30
committed by GitHub
parent 0191de8bb4
commit 6ea40c9895
32 changed files with 2133 additions and 37 deletions

View File

@ -7,6 +7,8 @@ export interface Options {
audioPlayerEnabled: boolean;
videoPlayerEnabled: boolean;
pdfViewerEnabled: boolean;
useCustomPdfViewer: boolean;
theme: any;
}
function resourceUrl(resourceFullPath: string): string {
@ -42,6 +44,16 @@ export default function(link: Link, options: Options) {
}
if (options.pdfViewerEnabled && resource.mime === 'application/pdf') {
if (options.useCustomPdfViewer) {
let anchorPageNo = null;
if (link.href.indexOf('#') > 0) {
anchorPageNo = Number(link.href.split('#').pop());
if (anchorPageNo < 1) anchorPageNo = null;
}
return `<iframe src="../../vendor/lib/@joplin/pdf-viewer/index.html" url="${escapedResourcePath}"
appearance="${options.theme.appearance}" ${anchorPageNo ? `anchorPage="${anchorPageNo}"` : ''}
class="media-player media-pdf"></iframe>`;
}
return `<object data="${escapedResourcePath}" class="media-player media-pdf" type="${escapedMime}"></object>`;
}