fix: misc

This commit is contained in:
Ibrahima G. Coulibaly
2025-05-13 22:48:28 +01:00
parent 8fb2656fc2
commit 93c776aa72
5 changed files with 148 additions and 157 deletions

View File

@@ -14,6 +14,7 @@ interface MultiPdfInputComponentProps {
value: MultiPdfInput[];
onChange: (file: MultiPdfInput[]) => void;
}
export interface MultiPdfInput {
file: File;
order: number;
@@ -43,20 +44,6 @@ export default function ToolMultiFileInput({
fileInputRef.current?.click();
};
const handleCopy = () => {
if (isArray(value)) {
const blob = new Blob([value[0].file], { type: value[0].file.type });
const clipboardItem = new ClipboardItem({ [value[0].file.type]: blob });
navigator.clipboard
.write([clipboardItem])
.then(() => showSnackBar('File copied', 'success'))
.catch((err) => {
showSnackBar('Failed to copy: ' + err, 'error');
});
}
};
function handleClear() {
onChange([]);
}
@@ -175,11 +162,7 @@ export default function ToolMultiFileInput({
</Box>
</Box>
<InputFooter
handleCopy={handleCopy}
handleImport={handleImportClick}
handleClear={handleClear}
/>
<InputFooter handleImport={handleImportClick} handleClear={handleClear} />
<input
ref={fileInputRef}
style={{ display: 'none' }}

View File

@@ -173,7 +173,9 @@ export default function ToolFileResult({
disabled={!value}
handleCopy={handleCopy}
handleDownload={handleDownload}
hideCopy={fileType === 'video' || fileType === 'audio'}
hideCopy={
fileType === 'video' || fileType === 'audio' || fileType === 'pdf'
}
/>
</Box>
);

View File

@@ -2,15 +2,13 @@ import { tool as pdfRotatePdf } from './rotate-pdf/meta';
import { meta as splitPdfMeta } from './split-pdf/meta';
import { meta as mergePdf } from './merge-pdf/meta';
import { DefinedTool } from '@tools/defineTool';
export const pdfTools: DefinedTool[] = [splitPdfMeta, pdfRotatePdf, mergePdf];
import { tool as compressPdfTool } from './compress-pdf/meta';
import { tool as protectPdfTool } from './protect-pdf/meta';
import { DefinedTool } from '@tools/defineTool';
export const pdfTools: DefinedTool[] = [
splitPdfMeta,
pdfRotatePdf,
compressPdfTool,
protectPdfTool
protectPdfTool,
mergePdf
];

View File

@@ -7,7 +7,7 @@ import ToolMultiPdfInput, {
MultiPdfInput
} from '@components/input/ToolMultiplePdfInput';
export default function SplitPdf({ title }: ToolComponentProps) {
export default function MergePdf({ title }: ToolComponentProps) {
const [input, setInput] = useState<MultiPdfInput[]>([]);
const [result, setResult] = useState<File | null>(null);
const [isProcessing, setIsProcessing] = useState<boolean>(false);
@@ -35,19 +35,18 @@ export default function SplitPdf({ title }: ToolComponentProps) {
setInput={setInput}
initialValues={input.map((i) => i.file)}
compute={compute}
// exampleCards={exampleCards}
inputComponent={
<ToolMultiPdfInput
value={input}
onChange={(v) => {
setInput(v);
onChange={(pdfInputs) => {
setInput(pdfInputs);
}}
accept={['application/pdf']}
title={'Input PDF'}
type="pdf"
/>
}
getGroups={({ values, updateField }) => []}
getGroups={null}
resultComponent={
<ToolFileResult
title={'Output merged PDF'}