mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-10 22:45:40 +00:00

# Description of Changes <!-- File context for managing files between tools and views Optimisation for large files Updated Split to work with new file system and match Matts stepped design closer --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/**
|
|
* React hooks for tool parameter management (URL logic removed)
|
|
*/
|
|
|
|
import { useCallback, useMemo } from 'react';
|
|
|
|
type ToolParameterValues = Record<string, any>;
|
|
|
|
/**
|
|
* Register tool parameters and get current values
|
|
*/
|
|
export function useToolParameters(
|
|
toolName: string,
|
|
parameters: Record<string, any>
|
|
): [ToolParameterValues, (updates: Partial<ToolParameterValues>) => void] {
|
|
|
|
// Return empty values and noop updater
|
|
const currentValues = useMemo(() => ({}), []);
|
|
const updateParameters = useCallback(() => {}, []);
|
|
|
|
return [currentValues, updateParameters];
|
|
}
|
|
|
|
/**
|
|
* Hook for managing a single tool parameter
|
|
*/
|
|
export function useToolParameter<T = any>(
|
|
toolName: string,
|
|
paramName: string,
|
|
definition: any
|
|
): [T, (value: T) => void] {
|
|
const [allParams, updateParams] = useToolParameters(toolName, { [paramName]: definition });
|
|
|
|
const value = allParams[paramName] as T;
|
|
|
|
const setValue = useCallback((newValue: T) => {
|
|
updateParams({ [paramName]: newValue });
|
|
}, [paramName, updateParams]);
|
|
|
|
return [value, setValue];
|
|
}
|
|
|
|
/**
|
|
* Hook for getting/setting global parameters (zoom, page, etc.)
|
|
*/
|
|
export function useGlobalParameters() {
|
|
const currentValues = useMemo(() => ({}), []);
|
|
const updateParameters = useCallback(() => {}, []);
|
|
|
|
return [currentValues, updateParameters];
|
|
} |