Fix edit-pdf-page.ts and revert fileHandler.ts

This commit is contained in:
Connor Smith
2025-12-15 17:11:38 -05:00
parent 9f99a29d83
commit 71aac226ed
2 changed files with 10 additions and 48 deletions

View File

@@ -3,6 +3,11 @@ import { createIcons, icons } from 'lucide';
import { showAlert, showLoader, hideLoader } from '../ui.js';
import { formatBytes } from '../utils/helpers.js';
const embedPdfWasmUrl = new URL(
'embedpdf-snippet/dist/pdfium.wasm',
import.meta.url
).href;
let currentPdfUrl: string | null = null;
if (document.readyState === 'loading') {
@@ -130,18 +135,14 @@ async function handleFiles(files: FileList) {
const fileURL = URL.createObjectURL(file);
currentPdfUrl = fileURL;
// Dynamically load EmbedPDF script
const script = document.createElement('script');
script.type = 'module';
script.textContent = `
import EmbedPDF from 'https://snippet.embedpdf.com/embedpdf.js';
const { default: EmbedPDF } = await import('embedpdf-snippet');
EmbedPDF.init({
type: 'container',
target: document.getElementById('embed-pdf-container'),
src: '${fileURL}',
target: pdfContainer,
src: fileURL,
worker: true,
wasmUrl: embedPdfWasmUrl,
});
`;
document.head.appendChild(script);
// Update back button to reset state
const backBtn = document.getElementById('back-to-tools');