mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-26 01:19:33 +02:00
feat: pdf editor
This commit is contained in:
59
src/pages/tools/pdf/editor/index.tsx
Normal file
59
src/pages/tools/pdf/editor/index.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Box } from '@mui/material';
|
||||
import ToolPdfInput from '@components/input/ToolPdfInput';
|
||||
import ToolContent from '@components/ToolContent';
|
||||
import { ToolComponentProps } from '@tools/defineTool';
|
||||
import { EmbedPDF } from '@simplepdf/react-embed-pdf';
|
||||
|
||||
export default function PdfEditor({ title }: ToolComponentProps) {
|
||||
const [input, setInput] = useState<File | null>(null);
|
||||
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
|
||||
|
||||
const onFileChange = (file: File | null) => {
|
||||
if (file) {
|
||||
setInput(file);
|
||||
const url = URL.createObjectURL(file);
|
||||
setPdfUrl(url);
|
||||
} else {
|
||||
setInput(null);
|
||||
setPdfUrl(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ToolContent
|
||||
title={title}
|
||||
initialValues={{}}
|
||||
getGroups={null}
|
||||
input={input}
|
||||
inputComponent={
|
||||
<>
|
||||
{pdfUrl ? (
|
||||
<Box sx={{ width: '100%', height: '80vh' }}>
|
||||
<EmbedPDF
|
||||
mode="inline"
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
documentURL={pdfUrl}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<ToolPdfInput
|
||||
value={input}
|
||||
onChange={onFileChange}
|
||||
accept={['application/pdf']}
|
||||
title="Upload a PDF to edit"
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
toolInfo={{
|
||||
title: 'PDF Editor',
|
||||
description:
|
||||
'Edit, annotate, highlight, fill forms, and export your PDFs entirely in the browser. Add text, drawings, signatures, and more to your PDF documents with this powerful online editor.'
|
||||
}}
|
||||
compute={() => {
|
||||
/* no background compute required */
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
27
src/pages/tools/pdf/editor/meta.ts
Normal file
27
src/pages/tools/pdf/editor/meta.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { defineTool } from '@tools/defineTool';
|
||||
import { lazy } from 'react';
|
||||
|
||||
export const tool = defineTool('pdf', {
|
||||
name: 'PDF Editor',
|
||||
path: 'editor',
|
||||
icon: 'mdi:file-document-edit',
|
||||
description:
|
||||
'Advanced PDF editor with annotation, form-fill, highlight, and export capabilities. Edit your PDFs directly in the browser with professional-grade tools including text insertion, drawing, highlighting, signing and form filling.',
|
||||
shortDescription: 'Edit PDFs with advanced annotation and editing tools',
|
||||
keywords: [
|
||||
'pdf',
|
||||
'editor',
|
||||
'edit',
|
||||
'annotate',
|
||||
'highlight',
|
||||
'form',
|
||||
'fill',
|
||||
'text',
|
||||
'drawing',
|
||||
'signature',
|
||||
'export',
|
||||
'annotation',
|
||||
'markup'
|
||||
],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
@@ -9,12 +9,12 @@ import { meta as pdfToEpub } from './pdf-to-epub/meta';
|
||||
import { tool as pdfEditor } from './editor/meta';
|
||||
|
||||
export const pdfTools: DefinedTool[] = [
|
||||
pdfEditor,
|
||||
splitPdfMeta,
|
||||
pdfRotatePdf,
|
||||
compressPdfTool,
|
||||
protectPdfTool,
|
||||
mergePdf,
|
||||
pdfToEpub,
|
||||
pdfPdfToPng,
|
||||
pdfEditor
|
||||
pdfPdfToPng
|
||||
];
|
||||
|
Reference in New Issue
Block a user