From 7baf503d603d8511dfd3ed7e139ff8b2d304dcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Sz=C3=BCcs?= <127139797+balazs-szucs@users.noreply.github.com> Date: Mon, 22 Dec 2025 20:28:00 +0100 Subject: [PATCH] [V2] feat(split): add split mode options and custom page selection to section split (#5277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description of Changes This pull request adds a new "Split Mode" feature to the "Split by Sections" tool, allowing users to customize how pages are split, including options to exclude the first/last pages or specify custom pages. The changes include updates to the UI, form data handling, parameter definitions, and validation logic to support these new options. **Split by Sections: New Split Mode Feature** *UI Enhancements:* - Added a `Radio.Group` in `SplitSettings.tsx` to let users choose the split mode (split all, exclude first/last, or custom pages), and a conditional `TextInput` for custom page numbers when "Custom" is selected. *Localization:* - Updated `translation.toml` with new labels and descriptions for the split mode options and custom page numbers. *Parameter Handling:* - Extended the `SplitParameters` interface to include `splitMode` and `customPages`, and set their default values. *Form Submission:* - Modified `buildSplitFormData` to include the selected split mode and custom page numbers (if applicable) in the form data sent to the backend. *Validation Logic:* - Updated the validation logic in `useSplitParameters` to require custom page numbers when the custom split mode is selected. image --- ## Checklist ### General - [X] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [X] 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) - [X] I have performed a self-review of my own code - [X] 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) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [X] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [X] 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. --------- Signed-off-by: Balázs Szücs --- .../public/locales/en-GB/translation.toml | 13 ++++++++++ .../components/tools/split/SplitSettings.tsx | 25 ++++++++++++++++++- .../hooks/tools/split/useSplitOperation.ts | 4 +++ .../hooks/tools/split/useSplitParameters.ts | 10 +++++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/frontend/public/locales/en-GB/translation.toml b/frontend/public/locales/en-GB/translation.toml index 51accb2a9..f3bd4c5d6 100644 --- a/frontend/public/locales/en-GB/translation.toml +++ b/frontend/public/locales/en-GB/translation.toml @@ -3375,6 +3375,19 @@ placeholder = "Enter number of horizontal divisions" label = "Vertical Divisions" placeholder = "Enter number of vertical divisions" +[split-by-sections.splitMode] +label = "Split Mode" +description = "Choose how to split the pages" +splitAll = "Split all pages" +splitAllExceptFirst = "Split all except first" +splitAllExceptLast = "Split all except last" +splitAllExceptFirstAndLast = "Split all except first and last" +custom = "Custom pages" + +[split-by-sections.customPages] +label = "Custom Page Numbers" +placeholder = "e.g. 2,4,6" + [AddStampRequest] tags = "Stamp, Add image, center image, Watermark, PDF, Embed, Customize,Customise" header = "Stamp PDF" diff --git a/frontend/src/core/components/tools/split/SplitSettings.tsx b/frontend/src/core/components/tools/split/SplitSettings.tsx index e2349ac88..b0eafae2f 100644 --- a/frontend/src/core/components/tools/split/SplitSettings.tsx +++ b/frontend/src/core/components/tools/split/SplitSettings.tsx @@ -1,4 +1,4 @@ -import { Stack, TextInput, Checkbox, Anchor, Text } from '@mantine/core'; +import { Stack, TextInput, Checkbox, Anchor, Text, Select } from '@mantine/core'; import LocalIcon from '@app/components/shared/LocalIcon'; import { useTranslation } from 'react-i18next'; import { SPLIT_METHODS } from '@app/constants/splitConstants'; @@ -49,6 +49,29 @@ const SplitSettings = ({ placeholder={t("split-by-sections.vertical.placeholder", "Enter number of vertical divisions")} disabled={disabled} /> +