mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00
All tools working
This commit is contained in:
parent
def603a367
commit
61e2e56b08
@ -14,6 +14,7 @@ import CheckIcon from '@mui/icons-material/Check';
|
|||||||
import CloseIcon from '@mui/icons-material/Close';
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
import WarningIcon from '@mui/icons-material/Warning';
|
import WarningIcon from '@mui/icons-material/Warning';
|
||||||
import { ToolRegistry } from '../../../data/toolsTaxonomy';
|
import { ToolRegistry } from '../../../data/toolsTaxonomy';
|
||||||
|
import { getAvailableToExtensions } from '../../../utils/convertUtils';
|
||||||
interface ToolConfigurationModalProps {
|
interface ToolConfigurationModalProps {
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
tool: {
|
tool: {
|
||||||
@ -59,6 +60,21 @@ export default function ToolConfigurationModal({ opened, tool, onSave, onCancel,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special handling for ConvertSettings which needs additional props
|
||||||
|
if (tool.operation === 'convert') {
|
||||||
|
return (
|
||||||
|
<SettingsComponent
|
||||||
|
parameters={parameters}
|
||||||
|
onParameterChange={(key: string, value: any) => {
|
||||||
|
setParameters((prev: any) => ({ ...prev, [key]: value }));
|
||||||
|
}}
|
||||||
|
getAvailableToExtensions={getAvailableToExtensions}
|
||||||
|
selectedFiles={[]}
|
||||||
|
disabled={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsComponent
|
<SettingsComponent
|
||||||
parameters={parameters}
|
parameters={parameters}
|
||||||
|
@ -622,7 +622,8 @@ export function useFlatToolRegistry(): ToolRegistry {
|
|||||||
// Other
|
// Other
|
||||||
"dbf", "fods", "vsd", "vor", "vor3", "vor4", "uop", "pct", "ps", "pdf"
|
"dbf", "fods", "vsd", "vor", "vor3", "vor4", "uop", "pct", "ps", "pdf"
|
||||||
],
|
],
|
||||||
operationConfig: convertOperationConfig
|
operationConfig: convertOperationConfig,
|
||||||
|
settingsComponent: ConvertSettings
|
||||||
},
|
},
|
||||||
"mergePdfs": {
|
"mergePdfs": {
|
||||||
icon: <span className="material-symbols-rounded">library_add</span>,
|
icon: <span className="material-symbols-rounded">library_add</span>,
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
type OutputOption,
|
type OutputOption,
|
||||||
type FitOption
|
type FitOption
|
||||||
} from '../../../constants/convertConstants';
|
} from '../../../constants/convertConstants';
|
||||||
import { getEndpointName as getEndpointNameUtil, getEndpointUrl, isImageFormat, isWebFormat } from '../../../utils/convertUtils';
|
import { getEndpointName as getEndpointNameUtil, getEndpointUrl, isImageFormat, isWebFormat, getAvailableToExtensions as getAvailableToExtensionsUtil } from '../../../utils/convertUtils';
|
||||||
import { detectFileExtension as detectFileExtensionUtil } from '../../../utils/fileUtils';
|
import { detectFileExtension as detectFileExtensionUtil } from '../../../utils/fileUtils';
|
||||||
import { BaseParameters } from '../../../types/parameters';
|
import { BaseParameters } from '../../../types/parameters';
|
||||||
import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters';
|
import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters';
|
||||||
@ -152,30 +152,7 @@ export const useConvertParameters = (): ConvertParametersHook => {
|
|||||||
return getEndpointUrl(fromExtension, toExtension);
|
return getEndpointUrl(fromExtension, toExtension);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAvailableToExtensions = (fromExtension: string) => {
|
const getAvailableToExtensions = getAvailableToExtensionsUtil;
|
||||||
if (!fromExtension) return [];
|
|
||||||
|
|
||||||
// Handle dynamic format identifiers (file-<extension>)
|
|
||||||
if (fromExtension.startsWith('file-')) {
|
|
||||||
// Dynamic format - use 'any' conversion options (file-to-pdf)
|
|
||||||
const supportedExtensions = CONVERSION_MATRIX['any'] || [];
|
|
||||||
return TO_FORMAT_OPTIONS.filter(option =>
|
|
||||||
supportedExtensions.includes(option.value)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let supportedExtensions = CONVERSION_MATRIX[fromExtension] || [];
|
|
||||||
|
|
||||||
// If no explicit conversion exists, but file-to-pdf might be available,
|
|
||||||
// fall back to 'any' conversion (which converts unknown files to PDF via file-to-pdf)
|
|
||||||
if (supportedExtensions.length === 0 && fromExtension !== 'any') {
|
|
||||||
supportedExtensions = CONVERSION_MATRIX['any'] || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return TO_FORMAT_OPTIONS.filter(option =>
|
|
||||||
supportedExtensions.includes(option.value)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const analyzeFileTypes = (files: Array<{name: string}>) => {
|
const analyzeFileTypes = (files: Array<{name: string}>) => {
|
||||||
|
@ -48,6 +48,14 @@ export const executeToolOperation = async (
|
|||||||
console.log(`📋 Using config:`, config);
|
console.log(`📋 Using config:`, config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check if tool uses custom processor (like Convert tool)
|
||||||
|
if (config.customProcessor) {
|
||||||
|
console.log(`🎯 Using custom processor for ${config.operationType}`);
|
||||||
|
const resultFiles = await config.customProcessor(parameters, files);
|
||||||
|
console.log(`✅ Custom processor returned ${resultFiles.length} files`);
|
||||||
|
return resultFiles;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.multiFileEndpoint) {
|
if (config.multiFileEndpoint) {
|
||||||
// Multi-file processing - single API call with all files
|
// Multi-file processing - single API call with all files
|
||||||
const endpoint = typeof config.endpoint === 'function'
|
const endpoint = typeof config.endpoint === 'function'
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
CONVERSION_ENDPOINTS,
|
CONVERSION_ENDPOINTS,
|
||||||
ENDPOINT_NAMES,
|
ENDPOINT_NAMES,
|
||||||
EXTENSION_TO_ENDPOINT
|
EXTENSION_TO_ENDPOINT,
|
||||||
|
CONVERSION_MATRIX,
|
||||||
|
TO_FORMAT_OPTIONS
|
||||||
} from '../constants/convertConstants';
|
} from '../constants/convertConstants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,4 +58,33 @@ export const isImageFormat = (extension: string): boolean => {
|
|||||||
*/
|
*/
|
||||||
export const isWebFormat = (extension: string): boolean => {
|
export const isWebFormat = (extension: string): boolean => {
|
||||||
return ['html', 'zip'].includes(extension.toLowerCase());
|
return ['html', 'zip'].includes(extension.toLowerCase());
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets available target extensions for a given source extension
|
||||||
|
* Extracted from useConvertParameters to be reusable in automation settings
|
||||||
|
*/
|
||||||
|
export const getAvailableToExtensions = (fromExtension: string): Array<{value: string, label: string, group: string}> => {
|
||||||
|
if (!fromExtension) return [];
|
||||||
|
|
||||||
|
// Handle dynamic format identifiers (file-<extension>)
|
||||||
|
if (fromExtension.startsWith('file-')) {
|
||||||
|
// Dynamic format - use 'any' conversion options (file-to-pdf)
|
||||||
|
const supportedExtensions = CONVERSION_MATRIX['any'] || [];
|
||||||
|
return TO_FORMAT_OPTIONS.filter(option =>
|
||||||
|
supportedExtensions.includes(option.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let supportedExtensions = CONVERSION_MATRIX[fromExtension] || [];
|
||||||
|
|
||||||
|
// If no explicit conversion exists, but file-to-pdf might be available,
|
||||||
|
// fall back to 'any' conversion (which converts unknown files to PDF via file-to-pdf)
|
||||||
|
if (supportedExtensions.length === 0 && fromExtension !== 'any') {
|
||||||
|
supportedExtensions = CONVERSION_MATRIX['any'] || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return TO_FORMAT_OPTIONS.filter(option =>
|
||||||
|
supportedExtensions.includes(option.value)
|
||||||
|
);
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user