mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-18 11:04:03 +01:00
feat: split pdf
This commit is contained in:
165
.idea/workspace.xml
generated
165
.idea/workspace.xml
generated
@@ -4,18 +4,13 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: background removal">
|
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: split pdf">
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/index.ts" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/components/input/ToolPdfInput.tsx" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/meta.ts" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.test.ts" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.ts" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/BaseFileInput.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/result/ToolFileResult.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/components/ToolContent.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolContent.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/index.tsx" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/tools/defineTool.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/tools/defineTool.tsx" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.ts" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/tools/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/tools/index.ts" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -115,54 +110,55 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"Docker.Dockerfile build.executor": "Run",
|
"Docker.Dockerfile build.executor": "Run",
|
||||||
"Docker.Dockerfile.executor": "Run",
|
"Docker.Dockerfile.executor": "Run",
|
||||||
"Playwright.Create transparent PNG.should make png color transparent.executor": "Run",
|
"Playwright.Create transparent PNG.should make png color transparent.executor": "Run",
|
||||||
"Playwright.JoinText Component.executor": "Run",
|
"Playwright.JoinText Component.executor": "Run",
|
||||||
"Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
|
"Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"Vitest.compute function (1).executor": "Run",
|
"Vitest.compute function (1).executor": "Run",
|
||||||
"Vitest.compute function.executor": "Run",
|
"Vitest.compute function.executor": "Run",
|
||||||
"Vitest.mergeText.executor": "Run",
|
"Vitest.mergeText.executor": "Run",
|
||||||
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
|
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
|
||||||
"Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
|
"Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
|
||||||
"Vitest.removeDuplicateLines function.executor": "Run",
|
"Vitest.parsePageRanges.executor": "Run",
|
||||||
"Vitest.removeDuplicateLines function.newlines option.executor": "Run",
|
"Vitest.removeDuplicateLines function.executor": "Run",
|
||||||
"Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
|
"Vitest.removeDuplicateLines function.newlines option.executor": "Run",
|
||||||
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
"Vitest.removeDuplicateLines function.newlines option.should filter newlines when newlines is set to filter.executor": "Run",
|
||||||
"Vitest.replaceText function.executor": "Run",
|
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
|
||||||
"git-widget-placeholder": "main",
|
"Vitest.replaceText function.executor": "Run",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"git-widget-placeholder": "split-pdf",
|
||||||
"kotlin-language-version-configured": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/pages/tools/list/duplicate/index.tsx",
|
"kotlin-language-version-configured": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/components/input",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"npm.build.executor": "Run",
|
"nodejs_package_manager_path": "npm",
|
||||||
"npm.dev.executor": "Run",
|
"npm.build.executor": "Run",
|
||||||
"npm.lint.executor": "Run",
|
"npm.dev.executor": "Run",
|
||||||
"npm.prebuild.executor": "Run",
|
"npm.lint.executor": "Run",
|
||||||
"npm.script:create:tool.executor": "Run",
|
"npm.prebuild.executor": "Run",
|
||||||
"npm.test.executor": "Run",
|
"npm.script:create:tool.executor": "Run",
|
||||||
"npm.test:e2e.executor": "Run",
|
"npm.test.executor": "Run",
|
||||||
"npm.test:e2e:run.executor": "Run",
|
"npm.test:e2e.executor": "Run",
|
||||||
"prettierjs.PrettierConfiguration.Package": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\prettier",
|
"npm.test:e2e:run.executor": "Run",
|
||||||
"project.structure.last.edited": "Problems",
|
"prettierjs.PrettierConfiguration.Package": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\prettier",
|
||||||
"project.structure.proportion": "0.0",
|
"project.structure.last.edited": "Problems",
|
||||||
"project.structure.side.proportion": "0.2",
|
"project.structure.proportion": "0.0",
|
||||||
"settings.editor.selected.configurable": "refactai_advanced_settings",
|
"project.structure.side.proportion": "0.2",
|
||||||
"ts.external.directory.path": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
|
"settings.editor.selected.configurable": "refactai_advanced_settings",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"ts.external.directory.path": "C:\\Users\\Ibrahima\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="ReactDesignerToolWindowState">
|
<component name="ReactDesignerToolWindowState">
|
||||||
<option name="myId2Visible">
|
<option name="myId2Visible">
|
||||||
<map>
|
<map>
|
||||||
@@ -174,11 +170,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\components\input" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.husky" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.husky" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\assets" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\src\assets" />
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.github" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\.github" />
|
||||||
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" />
|
|
||||||
</key>
|
</key>
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
<recent name="C:\Users\Ibrahima\IdeaProjects\omni-tools\public\assets" />
|
||||||
@@ -188,7 +184,7 @@
|
|||||||
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" />
|
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\components\options" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="npm.dev">
|
<component name="RunManager" selected="Vitest.parsePageRanges">
|
||||||
<configuration name="Create transparent PNG.should make png color transparent" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true">
|
<configuration name="Create transparent PNG.should make png color transparent" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true">
|
||||||
<node-interpreter value="project" />
|
<node-interpreter value="project" />
|
||||||
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
|
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
|
||||||
@@ -202,6 +198,19 @@
|
|||||||
</test-names>
|
</test-names>
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="parsePageRanges" type="JavaScriptTestRunnerVitest" temporary="true" nameIsGenerated="true">
|
||||||
|
<node-interpreter value="project" />
|
||||||
|
<vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
|
||||||
|
<working-dir value="$PROJECT_DIR$" />
|
||||||
|
<vitest-options value="--run" />
|
||||||
|
<envs />
|
||||||
|
<scope-kind value="SUITE" />
|
||||||
|
<test-file value="$PROJECT_DIR$/src/pages/tools/pdf/split-pdf/service.test.ts" />
|
||||||
|
<test-names>
|
||||||
|
<test-name value="parsePageRanges" />
|
||||||
|
</test-names>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
<configuration name="replaceText function (regexp mode).should return the original text when passed an invalid regexp" type="JavaScriptTestRunnerVitest" temporary="true" nameIsGenerated="true">
|
<configuration name="replaceText function (regexp mode).should return the original text when passed an invalid regexp" type="JavaScriptTestRunnerVitest" temporary="true" nameIsGenerated="true">
|
||||||
<node-interpreter value="project" />
|
<node-interpreter value="project" />
|
||||||
<vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
|
<vitest-package value="$PROJECT_DIR$/node_modules/vitest" />
|
||||||
@@ -232,16 +241,6 @@
|
|||||||
<envs />
|
<envs />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="test" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
|
||||||
<package-json value="$PROJECT_DIR$/package.json" />
|
|
||||||
<command value="run" />
|
|
||||||
<scripts>
|
|
||||||
<script value="test" />
|
|
||||||
</scripts>
|
|
||||||
<node-interpreter value="project" />
|
|
||||||
<envs />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="test:e2e" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
<configuration name="test:e2e" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
||||||
<package-json value="$PROJECT_DIR$/package.json" />
|
<package-json value="$PROJECT_DIR$/package.json" />
|
||||||
<command value="run" />
|
<command value="run" />
|
||||||
@@ -253,19 +252,19 @@
|
|||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="npm.test" />
|
|
||||||
<item itemvalue="npm.test:e2e" />
|
<item itemvalue="npm.test:e2e" />
|
||||||
<item itemvalue="npm.dev" />
|
<item itemvalue="npm.dev" />
|
||||||
<item itemvalue="Playwright.Create transparent PNG.should make png color transparent" />
|
<item itemvalue="Playwright.Create transparent PNG.should make png color transparent" />
|
||||||
|
<item itemvalue="Vitest.parsePageRanges" />
|
||||||
<item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" />
|
<item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" />
|
||||||
</list>
|
</list>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
|
<item itemvalue="Vitest.parsePageRanges" />
|
||||||
<item itemvalue="npm.dev" />
|
<item itemvalue="npm.dev" />
|
||||||
<item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" />
|
<item itemvalue="Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp" />
|
||||||
<item itemvalue="Playwright.Create transparent PNG.should make png color transparent" />
|
<item itemvalue="Playwright.Create transparent PNG.should make png color transparent" />
|
||||||
<item itemvalue="npm.test:e2e" />
|
<item itemvalue="npm.test:e2e" />
|
||||||
<item itemvalue="npm.test" />
|
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
@@ -350,14 +349,6 @@
|
|||||||
<workItem from="1741567442768" duration="14127000" />
|
<workItem from="1741567442768" duration="14127000" />
|
||||||
<workItem from="1741971589699" duration="371000" />
|
<workItem from="1741971589699" duration="371000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00117" summary="chore: style">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1740491274739</created>
|
|
||||||
<option name="number" value="00117" />
|
|
||||||
<option name="presentableId" value="LOCAL-00117" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1740491274739</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00118" summary="style: background svg">
|
<task id="LOCAL-00118" summary="style: background svg">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1740491737480</created>
|
<created>1740491737480</created>
|
||||||
@@ -742,7 +733,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1742961898820</updated>
|
<updated>1742961898820</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="166" />
|
<task id="LOCAL-00166" summary="feat: split pdf">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1742967844908</created>
|
||||||
|
<option name="number" value="00166" />
|
||||||
|
<option name="presentableId" value="LOCAL-00166" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1742967844908</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="167" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -789,7 +788,6 @@
|
|||||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||||
<option name="CHECK_NEW_TODO" value="false" />
|
<option name="CHECK_NEW_TODO" value="false" />
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
<MESSAGE value="chore: img" />
|
|
||||||
<MESSAGE value="docs: readme" />
|
<MESSAGE value="docs: readme" />
|
||||||
<MESSAGE value="feat: remove duplicate lines" />
|
<MESSAGE value="feat: remove duplicate lines" />
|
||||||
<MESSAGE value="fix: tsc" />
|
<MESSAGE value="fix: tsc" />
|
||||||
@@ -814,7 +812,8 @@
|
|||||||
<MESSAGE value="feat: trim video" />
|
<MESSAGE value="feat: trim video" />
|
||||||
<MESSAGE value="refactor: file inputs" />
|
<MESSAGE value="refactor: file inputs" />
|
||||||
<MESSAGE value="feat: background removal" />
|
<MESSAGE value="feat: background removal" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="feat: background removal" />
|
<MESSAGE value="feat: split pdf" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="feat: split pdf" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import greyPattern from '@assets/grey-pattern.png';
|
|||||||
|
|
||||||
interface BaseFileInputComponentProps extends BaseFileInputProps {
|
interface BaseFileInputComponentProps extends BaseFileInputProps {
|
||||||
children: (props: { preview: string | undefined }) => ReactNode;
|
children: (props: { preview: string | undefined }) => ReactNode;
|
||||||
type: 'image' | 'video' | 'audio';
|
type: 'image' | 'video' | 'audio' | 'pdf';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BaseFileInput({
|
export default function BaseFileInput({
|
||||||
|
|||||||
23
src/components/input/ToolPdfInput.tsx
Normal file
23
src/components/input/ToolPdfInput.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import React, { useRef } from 'react';
|
||||||
|
import BaseFileInput from './BaseFileInput';
|
||||||
|
import { BaseFileInputProps } from './file-input-utils';
|
||||||
|
|
||||||
|
interface PdfFileInputProps extends BaseFileInputProps {}
|
||||||
|
|
||||||
|
export default function ToolPdfInput({ ...props }: PdfFileInputProps) {
|
||||||
|
const pdfRef = useRef<HTMLIFrameElement>(null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseFileInput {...props} type={'pdf'}>
|
||||||
|
{({ preview }) => (
|
||||||
|
<iframe
|
||||||
|
ref={pdfRef}
|
||||||
|
src={preview}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
style={{ maxWidth: '500px' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</BaseFileInput>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -63,12 +63,14 @@ export default function ToolFileResult({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type SupportedFileType = 'image' | 'video' | 'audio' | 'pdf' | 'unknown';
|
||||||
// Determine the file type based on MIME type
|
// Determine the file type based on MIME type
|
||||||
const getFileType = () => {
|
const getFileType = (): SupportedFileType => {
|
||||||
if (!value) return 'unknown';
|
if (!value) return 'unknown';
|
||||||
if (value.type.startsWith('image/')) return 'image';
|
if (value.type.startsWith('image/')) return 'image';
|
||||||
if (value.type.startsWith('video/')) return 'video';
|
if (value.type.startsWith('video/')) return 'video';
|
||||||
if (value.type.startsWith('audio/')) return 'audio';
|
if (value.type.startsWith('audio/')) return 'audio';
|
||||||
|
if (value.type.startsWith('application/pdf')) return 'pdf';
|
||||||
return 'unknown';
|
return 'unknown';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -135,6 +137,14 @@ export default function ToolFileResult({
|
|||||||
style={{ width: '100%', maxWidth: '500px' }}
|
style={{ width: '100%', maxWidth: '500px' }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{fileType === 'pdf' && (
|
||||||
|
<iframe
|
||||||
|
src={preview}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
style={{ maxWidth: '500px' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{fileType === 'unknown' && (
|
{fileType === 'unknown' && (
|
||||||
<Box sx={{ padding: 2, textAlign: 'center' }}>
|
<Box sx={{ padding: 2, textAlign: 'center' }}>
|
||||||
File processed successfully. Click download to save the
|
File processed successfully. Click download to save the
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { parsePageRanges, splitPdf } from './service';
|
|||||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||||
import { PDFDocument } from 'pdf-lib';
|
import { PDFDocument } from 'pdf-lib';
|
||||||
import { FormikProps } from 'formik';
|
import { FormikProps } from 'formik';
|
||||||
|
import ToolPdfInput from '@components/input/ToolPdfInput';
|
||||||
|
|
||||||
type InitialValuesType = {
|
type InitialValuesType = {
|
||||||
pageRanges: string;
|
pageRanges: string;
|
||||||
@@ -115,7 +116,7 @@ export default function SplitPdf({ title }: ToolComponentProps) {
|
|||||||
compute={compute}
|
compute={compute}
|
||||||
exampleCards={exampleCards}
|
exampleCards={exampleCards}
|
||||||
inputComponent={
|
inputComponent={
|
||||||
<ToolFileInput
|
<ToolPdfInput
|
||||||
value={input}
|
value={input}
|
||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
accept={['application/pdf']}
|
accept={['application/pdf']}
|
||||||
|
|||||||
@@ -23,7 +23,15 @@ export function parsePageRanges(
|
|||||||
if (trimmedRange.includes('-')) {
|
if (trimmedRange.includes('-')) {
|
||||||
const [start, end] = trimmedRange.split('-').map(Number);
|
const [start, end] = trimmedRange.split('-').map(Number);
|
||||||
if (!isNaN(start) && !isNaN(end)) {
|
if (!isNaN(start) && !isNaN(end)) {
|
||||||
for (let i = Math.max(1, start); i <= Math.min(totalPages, end); i++) {
|
// Handle both forward and reversed ranges
|
||||||
|
const normalizedStart = Math.min(start, end);
|
||||||
|
const normalizedEnd = Math.max(start, end);
|
||||||
|
|
||||||
|
for (
|
||||||
|
let i = Math.max(1, normalizedStart);
|
||||||
|
i <= Math.min(totalPages, normalizedEnd);
|
||||||
|
i++
|
||||||
|
) {
|
||||||
pageNumbers.add(i);
|
pageNumbers.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user