mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-04-22 23:08:53 +02:00
Initial working Crop
This commit is contained in:
71
frontend/src/tools/Crop.tsx
Normal file
71
frontend/src/tools/Crop.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||
import CropSettings from "../components/tools/crop/CropSettings";
|
||||
import { useCropParameters } from "../hooks/tools/crop/useCropParameters";
|
||||
import { useCropOperation } from "../hooks/tools/crop/useCropOperation";
|
||||
import { useBaseTool } from "../hooks/tools/shared/useBaseTool";
|
||||
import { BaseToolProps, ToolComponent } from "../types/tool";
|
||||
|
||||
const Crop = (props: BaseToolProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const base = useBaseTool(
|
||||
'crop',
|
||||
useCropParameters,
|
||||
useCropOperation,
|
||||
props
|
||||
);
|
||||
|
||||
return createToolFlow({
|
||||
files: {
|
||||
selectedFiles: base.selectedFiles,
|
||||
isCollapsed: base.hasResults,
|
||||
minFiles: 1,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
title: t("crop.steps.selectArea", "Select Crop Area"),
|
||||
isCollapsed: !base.hasFiles, // Collapsed until files selected
|
||||
onCollapsedClick: base.hasResults ? base.handleSettingsReset : undefined,
|
||||
tooltip: {
|
||||
content: (
|
||||
<div>
|
||||
<p>{t("crop.tooltip.description", "Select the area to crop from your PDF by dragging and resizing the red overlay on the thumbnail.")}</p>
|
||||
</div>
|
||||
),
|
||||
tips: [
|
||||
t("crop.tooltip.drag", "Drag the overlay to move the crop area"),
|
||||
t("crop.tooltip.resize", "Drag the corner and edge handles to resize"),
|
||||
t("crop.tooltip.precision", "Use coordinate inputs for precise positioning"),
|
||||
t("crop.tooltip.constraints", "Crop area is automatically constrained to PDF bounds")
|
||||
],
|
||||
header: {
|
||||
title: t("crop.tooltip.title", "How to Crop PDFs"),
|
||||
}
|
||||
},
|
||||
content: (
|
||||
<CropSettings
|
||||
parameters={base.params}
|
||||
disabled={base.endpointLoading}
|
||||
/>
|
||||
),
|
||||
},
|
||||
],
|
||||
executeButton: {
|
||||
text: t("crop.submit", "Crop PDF"),
|
||||
loadingText: t("loading"),
|
||||
onClick: base.handleExecute,
|
||||
isVisible: !base.hasResults,
|
||||
disabled: !base.params.validateParameters() || !base.hasFiles || !base.endpointEnabled,
|
||||
},
|
||||
review: {
|
||||
isVisible: base.hasResults,
|
||||
operation: base.operation,
|
||||
title: t("crop.results.title", "Crop Results"),
|
||||
onFileClick: base.handleThumbnailClick,
|
||||
onUndo: base.handleUndo,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default Crop as ToolComponent;
|
||||
Reference in New Issue
Block a user