Stirling-PDF
Stirling-PDF copied to clipboard
feat(multitool): Add duplicate page action with undo/redo and harden command stack #4322
Description of Changes
- Introduced Duplicate Page action in the MultiTool UI:
- New
DuplicatePageCommandwith full undo/redo support - Button added next to Delete, with tooltip text wired via i18n (
multiTool.duplicate) PdfContainer.duplicatePage()clones page image, rotation, and adapter state; inserts after source; refreshes numbering
- New
- Hooked duplication into the actions pipeline:
PdfActionsManagernow receivesduplicatePageviasetActions(...)- Added
duplicatePageButtonCallbackand control markup creation
- Refactored command architecture for robust undo/redo:
- Added
CommandWithAnchorsfor capturing positions and deterministic reinsertion (used by add/duplicate/page-break) - Modernized
AddFilesCommand,PageBreakCommandto use anchors, avoid DOM state on nodes, and handle arrays consistently - Improved
RemoveSelectedCommand,DeletePageCommand,MovePageCommand,Rotate*andSplit*commands:- Safer null checks for filename/export controls
- Clearer semantics and documentation
- Consistent redo mirroring execute
- Added
- Minor UI/UX fix:
- Corrected tooltip wiring for the Add File button (
insertFileButton.setAttribute('title', ...))
- Corrected tooltip wiring for the Add File button (
- Internationalization:
- Added
multiTool.duplicate=Duplicatetomessages_en_GB.properties - Exposed
translations.duplicateinmulti-tool.html
- Added
Why: Adds a commonly requested workflow improvement (duplicate a single page quickly) and makes the command stack more resilient (especially redo after complex DOM mutations), improving reliability and maintainability.
before:
after:
Closes #4322
Checklist
General
- [x] I have read the Contribution Guidelines
- [x] I have read the Stirling-PDF Developer Guide (if applicable)
- [ ] I have read the How to add new languages to Stirling-PDF (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 (if functionality has heavily changed)
- [ ] I have read the section Add New Translation Tags (for new translation tags only)
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)
- [ ] I have tested my changes locally. Refer to the Testing Guide for more details.
🚀 Translation Verification Summary
🔄 Reference Branch: pr-branch-messages_en_GB.properties
📃 File Check: messages_en_GB.properties
- Test Status: ✅ Passed
- Test Status: ✅ Passed
- Test Status: ✅ Passed
✅ Overall Check Status: Success
Thanks @Ludy87 for your help in keeping the translations up to date.
/prdeploy
/prdeploy
/prdeploy