feat: implement PDF attachment editing functionality with web worker support
- Added a new worker script to handle editing of embedded attachments in PDF files. - Created TypeScript definitions for message structures and response types related to attachment editing. - Updated the main logic to utilize the worker for improved performance and responsiveness during attachment management. - Integrated the editing feature into the UI, allowing users to view, remove, or replace attachments in their PDFs. - Enhanced error handling and user feedback during the editing process.
This commit is contained in:
42
public/workers/edit-attachments.worker.d.ts
vendored
Normal file
42
public/workers/edit-attachments.worker.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
declare const coherentpdf: typeof import('../../src/types/coherentpdf.global').coherentpdf;
|
||||
|
||||
interface GetAttachmentsMessage {
|
||||
command: 'get-attachments';
|
||||
fileBuffer: ArrayBuffer;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
interface EditAttachmentsMessage {
|
||||
command: 'edit-attachments';
|
||||
fileBuffer: ArrayBuffer;
|
||||
fileName: string;
|
||||
attachmentsToRemove: number[];
|
||||
}
|
||||
|
||||
type EditAttachmentsWorkerMessage = GetAttachmentsMessage | EditAttachmentsMessage;
|
||||
|
||||
interface GetAttachmentsSuccessResponse {
|
||||
status: 'success';
|
||||
attachments: Array<{ index: number; name: string; page: number; data: ArrayBuffer }>;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
interface GetAttachmentsErrorResponse {
|
||||
status: 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface EditAttachmentsSuccessResponse {
|
||||
status: 'success';
|
||||
modifiedPDF: ArrayBuffer;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
interface EditAttachmentsErrorResponse {
|
||||
status: 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
type GetAttachmentsResponse = GetAttachmentsSuccessResponse | GetAttachmentsErrorResponse;
|
||||
type EditAttachmentsResponse = EditAttachmentsSuccessResponse | EditAttachmentsErrorResponse;
|
||||
type EditAttachmentsWorkerResponse = GetAttachmentsResponse | EditAttachmentsResponse;
|
||||
Reference in New Issue
Block a user