mirror of
https://github.com/zadam/trilium.git
synced 2026-01-07 15:14:24 +01:00
chore(pdfjs): set proper target origin when posting messages
This commit is contained in:
parent
7182d32d9c
commit
bf3a2b768e
@ -50,7 +50,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
|||||||
iframeRef.current?.contentWindow?.postMessage({
|
iframeRef.current?.contentWindow?.postMessage({
|
||||||
type: "trilium-scroll-to-heading",
|
type: "trilium-scroll-to-heading",
|
||||||
headingId: heading.id
|
headingId: heading.id
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -81,13 +81,13 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
|||||||
iframeRef.current?.contentWindow?.postMessage({
|
iframeRef.current?.contentWindow?.postMessage({
|
||||||
type: "trilium-scroll-to-page",
|
type: "trilium-scroll-to-page",
|
||||||
pageNumber: page
|
pageNumber: page
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
},
|
},
|
||||||
requestThumbnail: (page: number) => {
|
requestThumbnail: (page: number) => {
|
||||||
iframeRef.current?.contentWindow?.postMessage({
|
iframeRef.current?.contentWindow?.postMessage({
|
||||||
type: "trilium-request-thumbnail",
|
type: "trilium-request-thumbnail",
|
||||||
pageNumber: page
|
pageNumber: page
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
|||||||
iframeRef.current?.contentWindow?.postMessage({
|
iframeRef.current?.contentWindow?.postMessage({
|
||||||
type: "trilium-download-attachment",
|
type: "trilium-download-attachment",
|
||||||
filename
|
filename
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
|||||||
type: "trilium-toggle-layer",
|
type: "trilium-toggle-layer",
|
||||||
layerId,
|
layerId,
|
||||||
visible
|
visible
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ async function extractAndSendAttachments() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-attachments",
|
type: "pdfjs-viewer-attachments",
|
||||||
attachments: []
|
attachments: []
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,13 +42,13 @@ async function extractAndSendAttachments() {
|
|||||||
filename: att.filename,
|
filename: att.filename,
|
||||||
size: att.size
|
size: att.size
|
||||||
}))
|
}))
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error extracting attachments:", error);
|
console.error("Error extracting attachments:", error);
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-attachments",
|
type: "pdfjs-viewer-attachments",
|
||||||
attachments: []
|
attachments: []
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ async function extractAndSendLayers() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-layers",
|
type: "pdfjs-viewer-layers",
|
||||||
layers: []
|
layers: []
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ async function extractAndSendLayers() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-layers",
|
type: "pdfjs-viewer-layers",
|
||||||
layers: []
|
layers: []
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,13 +77,13 @@ async function extractAndSendLayers() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-layers",
|
type: "pdfjs-viewer-layers",
|
||||||
layers
|
layers
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error extracting layers:", error);
|
console.error("Error extracting layers:", error);
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-layers",
|
type: "pdfjs-viewer-layers",
|
||||||
layers: []
|
layers: []
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export function setupPdfPages() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-current-page",
|
type: "pdfjs-viewer-current-page",
|
||||||
currentPage: evt.pageNumber
|
currentPage: evt.pageNumber
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen for scroll-to-page requests
|
// Listen for scroll-to-page requests
|
||||||
@ -43,7 +43,7 @@ function sendPageInfo() {
|
|||||||
type: "pdfjs-viewer-page-info",
|
type: "pdfjs-viewer-page-info",
|
||||||
totalPages: app.pdfDocument.numPages,
|
totalPages: app.pdfDocument.numPages,
|
||||||
currentPage: app.pdfViewer.currentPageNumber
|
currentPage: app.pdfViewer.currentPageNumber
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateThumbnail(pageNumber: number) {
|
async function generateThumbnail(pageNumber: number) {
|
||||||
@ -76,7 +76,7 @@ async function generateThumbnail(pageNumber: number) {
|
|||||||
type: "pdfjs-viewer-thumbnail",
|
type: "pdfjs-viewer-thumbnail",
|
||||||
pageNumber,
|
pageNumber,
|
||||||
dataUrl
|
dataUrl
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error generating thumbnail for page ${pageNumber}:`, error);
|
console.error(`Error generating thumbnail for page ${pageNumber}:`, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export async function extractAndSendToc() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-toc",
|
type: "pdfjs-viewer-toc",
|
||||||
data: null
|
data: null
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,12 +26,12 @@ export async function extractAndSendToc() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-toc",
|
type: "pdfjs-viewer-toc",
|
||||||
data: toc
|
data: toc
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-toc",
|
type: "pdfjs-viewer-toc",
|
||||||
data: null
|
data: null
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ export function setupActiveHeadingTracking() {
|
|||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-active-heading",
|
type: "pdfjs-viewer-active-heading",
|
||||||
headingId: activeHeadingId
|
headingId: activeHeadingId
|
||||||
}, "*");
|
}, window.location.origin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user