Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

feat(multitool): Add duplicate page action with undo/redo and harden command stack #4322

Open Ludy87 opened this issue 3 months ago • 7 comments

Description of Changes

  • Introduced Duplicate Page action in the MultiTool UI:
    • New DuplicatePageCommand with 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
  • Hooked duplication into the actions pipeline:
    • PdfActionsManager now receives duplicatePage via setActions(...)
    • Added duplicatePageButtonCallback and control markup creation
  • Refactored command architecture for robust undo/redo:
    • Added CommandWithAnchors for capturing positions and deterministic reinsertion (used by add/duplicate/page-break)
    • Modernized AddFilesCommand, PageBreakCommand to use anchors, avoid DOM state on nodes, and handle arrays consistently
    • Improved RemoveSelectedCommand, DeletePageCommand, MovePageCommand, Rotate* and Split* commands:
      • Safer null checks for filename/export controls
      • Clearer semantics and documentation
      • Consistent redo mirroring execute
  • Minor UI/UX fix:
    • Corrected tooltip wiring for the Add File button (insertFileButton.setAttribute('title', ...))
  • Internationalization:
    • Added multiTool.duplicate=Duplicate to messages_en_GB.properties
    • Exposed translations.duplicate in multi-tool.html

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: image

after: image

Closes #4322


Checklist

General

Documentation

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.

Ludy87 avatar Aug 30 '25 18:08 Ludy87

🚀 Translation Verification Summary

🔄 Reference Branch: pr-branch-messages_en_GB.properties

📃 File Check: messages_en_GB.properties

  1. Test Status:Passed
  2. Test Status:Passed
  3. Test Status:Passed

✅ Overall Check Status: Success

Thanks @Ludy87 for your help in keeping the translations up to date.

stirlingbot[bot] avatar Aug 30 '25 18:08 stirlingbot[bot]

/prdeploy

Ludy87 avatar Aug 30 '25 19:08 Ludy87

/prdeploy

Ludy87 avatar Aug 31 '25 08:08 Ludy87

/prdeploy

Frooodle avatar Sep 04 '25 12:09 Frooodle