Text Box Context Menu Cut Command & Clipboard Suite

Text Box Context Menu Cut Command & Clipboard Suite

Right-click context menus are fundamental to efficient desktop publishing, providing instant access to clipboard operations directly at the cursor. In earlier versions of Open Publisher, right-clicking a text box displayed Copy, Paste, and Delete, but the standard Cut command was missing. Users were forced to remember keyboard shortcuts (Ctrl + X) or perform multi-step copy-and-delete workarounds. Version 5.4.4 introduced the Cut command to the universal context menu with intelligent range preservation.

✂️
[Screenshot: Right-Click Context Menu with Complete Clipboard Suite (700 x 360)]

The context menu features a complete clipboard group with Cut, Copy, Paste, and Paste Without Formatting.

The Complete Universal Clipboard Suite

Version 5.4.4 brought full clipboard parity to the right-click menu in ui/menus.js and ui/ui.js:

  • Cut (Scissors Icon): Placed directly at the head of the clipboard group, allowing instant removal and copying of selected content.

  • Copy: Duplicates highlighted text or element properties onto the clipboard.

  • Paste & Paste Without Formatting: Inserts clipboard text with original styles intact, or strips font styling to inherit local formatting.

  • Delete: Removes selected text or elements cleanly without altering the system clipboard buffer.

Dual-Mode Contextual Intelligence

The Cut command intelligently adapts to what the user has selected:

  • Highlighted Text Selection: If characters, words, or paragraphs are highlighted inside a text box, selecting Cut removes only the highlighted text and places both plain text and rich HTML onto the clipboard.

  • Element-Level Selection: If the text box itself is selected as an object without an active text cursor, selecting Cut removes the entire text element from the page and places it on the element clipboard, ready to be pasted on another page.

Selection Range Preservation

In web browsers, right-clicking traditionally blurs active contenteditable fields, which can collapse text selections before a menu item is clicked. Open Publisher solves this with selection caching:

  • Range Cloning: On mousedown, handleRightClick() clones the active selection range into window._contextTargetRange.

  • Pre-Execution Restoration: When Cut is clicked, ContextMenuActions.cut() re-focuses the text box and restores the exact text range before executing the cut operation, preventing accidental element deletion.

  • History Snapshot Integration: Pushes an immediate undo snapshot to the history stack, enabling instant recovery with Ctrl + Z.

Tip: You can use the standard Ctrl + X (or Cmd + X on macOS) shortcut or right-click to access the Cut command interchangeably.