mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-04 02:20:19 +01:00
Fix type errors
This commit is contained in:
@@ -19,6 +19,7 @@ describe('MergeSettings', () => {
|
||||
const defaultParameters: MergeParameters = {
|
||||
removeDigitalSignature: false,
|
||||
generateTableOfContents: false,
|
||||
processingMode: 'backend',
|
||||
};
|
||||
|
||||
const mockOnParameterChange = vi.fn();
|
||||
|
||||
@@ -68,7 +68,8 @@ describe('useMergeOperation', () => {
|
||||
];
|
||||
const parameters: MergeParameters = {
|
||||
removeDigitalSignature: true,
|
||||
generateTableOfContents: false
|
||||
generateTableOfContents: false,
|
||||
processingMode: 'backend'
|
||||
};
|
||||
|
||||
const formData = config.buildFormData(parameters, mockFiles);
|
||||
@@ -105,7 +106,8 @@ describe('useMergeOperation', () => {
|
||||
// Test case 1: All options disabled
|
||||
const params1: MergeParameters = {
|
||||
removeDigitalSignature: false,
|
||||
generateTableOfContents: false
|
||||
generateTableOfContents: false,
|
||||
processingMode: 'backend'
|
||||
};
|
||||
const formData1 = config.buildFormData(params1, mockFiles);
|
||||
expect(formData1.get('removeCertSign')).toBe('false');
|
||||
@@ -114,7 +116,8 @@ describe('useMergeOperation', () => {
|
||||
// Test case 2: All options enabled
|
||||
const params2: MergeParameters = {
|
||||
removeDigitalSignature: true,
|
||||
generateTableOfContents: true
|
||||
generateTableOfContents: true,
|
||||
processingMode: 'backend'
|
||||
};
|
||||
const formData2 = config.buildFormData(params2, mockFiles);
|
||||
expect(formData2.get('removeCertSign')).toBe('true');
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { ToolType, useToolOperation, ToolOperationConfig } from '../shared/useToolOperation';
|
||||
import { createStandardErrorHandler } from '../../../utils/toolErrorHandler';
|
||||
import { SplitParameters, defaultParameters } from './useSplitParameters';
|
||||
import { SPLIT_METHODS } from '../../../constants/splitConstants';
|
||||
import { SPLIT_METHODS, type SplitMethod} from '../../../constants/splitConstants';
|
||||
import { useToolResources } from '../shared/useToolResources';
|
||||
import { splitPdfClientSide } from '../../../utils/pdfOperations/split';
|
||||
import { validatePageNumbers } from '../../../utils/pageSelection';
|
||||
@@ -87,8 +87,8 @@ export const splitOperationConfig = {
|
||||
SPLIT_METHODS.BY_PAGE_COUNT,
|
||||
SPLIT_METHODS.BY_DOC_COUNT,
|
||||
SPLIT_METHODS.BY_SIZE
|
||||
];
|
||||
if (!browserMethods.includes(params.method)) return false;
|
||||
] as SplitMethod[];
|
||||
if (!params.method || !browserMethods.includes(params.method)) return false;
|
||||
|
||||
// Method-specific validation
|
||||
switch (params.method) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createFileFromApiResponse } from '../fileResponseUtils';
|
||||
const PDF_MIME_TYPE = 'application/pdf';
|
||||
|
||||
export async function mergePdfClientSide(
|
||||
params: MergeParameters,
|
||||
_params: MergeParameters, // Cant use params in browser implementation
|
||||
files: File[]
|
||||
): Promise<File[]> {
|
||||
if (files.length === 0) {
|
||||
|
||||
@@ -88,7 +88,6 @@ async function splitPdfBySize(
|
||||
|
||||
const outputs: File[] = [];
|
||||
let currentDoc = await PDFDocument.create();
|
||||
let currentPageStart = 0;
|
||||
let partIndex = 1;
|
||||
|
||||
for (let i = 0; i < totalPages; i++) {
|
||||
@@ -117,7 +116,7 @@ async function splitPdfBySize(
|
||||
currentDoc = await PDFDocument.create();
|
||||
const [pageToAdd] = await currentDoc.copyPages(sourcePdf, [i]);
|
||||
currentDoc.addPage(pageToAdd);
|
||||
currentPageStart = i;
|
||||
|
||||
partIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user