Download Latest Version openpublisher5g_amd64-windows.exe (81.1 MB)
Home / 5.9.0
Name Modified Size InfoDownloads / Week
Parent folder
OpenPublisher5-i386-windowsXP.exe 2026-10-17 56.5 MB
openpublisher5_amd64-windows-portable.exe 2026-10-17 183.2 MB
openpublisher5_amd64-windows.exe 2026-10-17 165.2 MB
openpublisher5_amd64-macos.dmg 2026-10-17 233.1 MB
5.9.0_ Seamless Highlight Override on Pasted CSS-Styled Text source code.tar.gz 2026-10-17 23.3 MB
5.9.0_ Seamless Highlight Override on Pasted CSS-Styled Text source code.zip 2026-10-17 23.6 MB
README.md 2026-10-17 9.9 kB
openpublisher5_amd64-linux.run 2026-10-17 193.4 MB
openpublisher5_amd64-linux.rpm 2026-10-17 215.4 MB
openpublisher5_amd64-linux.flatpak 2026-10-17 153.6 MB
openpublisher5_amd64-linux.deb 2026-10-17 156.2 MB
openpublisher5_amd64-linux.AppImage 2026-10-17 166.4 MB
openpublisher5_amd64-freebsd.pkg 2026-10-17 185.5 MB
Totals: 13 Items   1.8 GB 0

πŸš€ Summary

Version 5.9.0 addresses an important usability and styling interaction in Open Publisher: when users copy and paste rich text from external websites or dark-themed applications into text boxes or tables, the pasted HTML preserves its inline and block CSS background styling (such as solid black backgrounds around the text). While preserving this pasted styling upon initial paste is intended and desired, users frequently mistake that background styling for Open Publisher's native text highlight feature, becoming confused when attempting to change the highlight color with the Highlight Color tool because the external CSS styling overrides and conflicts with browser highlight formatting.

To eliminate this confusion without losing any capabilities, Open Publisher v5.9.0 implements a seamless highlight override architecture:

  1. Initial Paste Preservation: Rich HTML/CSS text pasted from external applications continues to retain its full visual styling, including original background colors, padding, and font styling upon paste.
  2. Seamless Highlight Override Engine: When the user subsequently activates the Highlight Color tool (execCmd('hiliteColor', val) or execCmd('backColor', val)), the text engine automatically strips conflicting pasted CSS background styles from the editable root, block wrappers (<div>, <p>, <pre>, <blockquote>, headings, lists, etc.), and pasted inline elements, applying the newly chosen highlight color cleanly.
  3. Pasted Background vs. Native Highlight Distinction: Native Open Publisher highlights are explicitly tagged with data-opub-hilite="true". A capture-phase paste listener clears this attribute on newly pasted foreign DOM nodes, allowing the engine to distinguish between foreign CSS backgrounds and intentional user highlights.
  4. Collapsed Caret & Quick Highlight Support: When a user pastes CSS-styled text and immediately clicks the Highlight tool without first drag-selecting (or when clicking into a styled text box with a collapsed caret), the engine automatically selects all contents of the active editable container and applies the highlight seamlessly across the text.
  5. Color Picker Text Selection Preservation: Fixed an issue in extensions/ui-interactions.js where clicking swatches, switching tabs, or dragging on the custom HSV color picker canvas cleared the active text selection and blurred the editable container. Added #custom-color-picker, .ribbon-container, and .custom-dropdown to the toolbar exclusion whitelist.
  6. Instant Selection Range Snapshotting: In core/boot.js and CustomColorPicker.open, state.lastRange is now snapshotted immediately upon selection changes rather than waiting for UI debounce timers, ensuring live HSV canvas dragging and rapid swatch clicking always execute against the exact text range.

πŸ” Architecture & Technical Implementation

1. Pasted CSS Background Override & Native Highlight Engine

  • The Issue: When rich text is copied from external sites (such as dark-mode documentation, Discord, ChatGPT, Notion, or code editors), browsers serialize computed styles into block containers (<p style="background-color: rgb(0,0,0)">, <div style="background: #000">, <pre>), inline spans (<span style="background-color: ...">), <mark> tags, and <style> blocks. When document.execCommand('hiliteColor', false, val) runs:
  • Block-level elements retain their CSS background color, painting a black rectangular block behind the text.
  • Inner child spans and code elements retain their own inline background colors, painting over any outer highlight span.
  • User-agent default styling on <mark> tags overrides inline highlight spans.
  • Calling document.execCommand('backColor', false, val) can set block-level backgrounds rather than inline text highlights.
  • The Solution in elements/text/text.js:
  • Implemented stripCssBackgroundProps(el, isRootEditable) to remove background, background-color, background-image, background-clip, -webkit-background-clip, box-shadow, and bgcolor attributes.
  • Implemented isElementTextFullyInRange(el, range) using DOM TreeWalker to accurately identify whether an element's text content is completely covered by the active selection range.
  • Implemented applySeamlessHighlight(editableRoot, val):
    • Removes any foreign <style> tags pasted inside the editable container.
    • Strips CSS background styling from the editable root (preserving .element-content and table cells).
    • If the current selection is collapsed or outside the editable, selects all contents of editableRoot so pasted text can be highlighted in a single click.
    • Strips CSS background styling from all block elements and non-highlight elements, as well as any existing highlight spans fully contained within the selection range.
    • Neutralizes user-agent yellow backgrounds on <mark> tags by defaulting unstyled marks to transparent.
    • Applies the highlight color via document.execCommand('hiliteColor', false, val) (with backColor fallback).
    • Performs a post-pass DOM TreeWalker scan to tag highlight spans with data-opub-hilite="true" and wraps any missed text nodes (such as inside <pre>/<code> or display: inline-block containers) in <span style="background-color: ${val}" data-opub-hilite="true">.
  • Added a capture-phase paste listener on document that strips any foreign data-opub-hilite attributes from newly pasted elements while preserving pre-existing user highlights.

2. Color Picker Selection Preservation & Selection Synchronization

  • The Issue: In extensions/ui-interactions.js, the installSmartTextInteraction global mouseup listener checked whether e.target was inside a toolbar. Because #custom-color-picker is appended directly to <body>, clicking any swatch, tab, or dragging on the custom HSV canvas triggered the !clickedToolbar branch, clearing window.getSelection() and blurring the active text box. Furthermore, core/boot.js updated state.lastRange inside a 150ms debounce timer, causing rapid color picker interactions to lose range context.
  • The Solution in extensions/ui-interactions.js, ui/components/color-picker.js, and core/boot.js:
  • In extensions/ui-interactions.js, added e.target.closest('#custom-color-picker'), e.target.closest('.ribbon-container'), and e.target.closest('.custom-dropdown') to clickedToolbar.
  • In ui/components/color-picker.js, updated CustomColorPicker.open to immediately snapshot the active selection range inside #paper into state.lastRange.
  • In core/boot.js, updated the selectionchange listener to update state.lastRange synchronously on every change before running the debounced toolbar UI updates.

πŸ“ Files Modified in 5.9.0

File Changes
elements/text/text.js Implemented stripCssBackgroundProps, isElementTextFullyInRange, and applySeamlessHighlight. Added capture-phase paste listener for highlight tagging. Integrated seamless highlight overrides into execCmd for both standard text boxes and multi-cell tables. Header bumped to (v5.9.0).
ui/components/color-picker.js Snapshotted active selection range inside #paper into state.lastRange in CustomColorPicker.open.
extensions/ui-interactions.js Whitelisted #custom-color-picker, .ribbon-container, and .custom-dropdown in clickedToolbar to prevent text selection clearing on swatch and canvas clicks. Header and console log bumped to (v5.9.0).
core/boot.js Updated selectionchange listener to capture state.lastRange immediately. Header bumped to (v5.9.0).
core/core.js Bumped header comment to (v5.9.0).
index.html Bumped all script and style cachebusters to ?v=5.9.0.
sw.js Updated Service Worker cache namespace to open-publisher-v5-9-0 and header to (v5.9.0).
ui/menus.js Bumped header comment to (v5.9.0).
ui/sidebar-context.js Bumped header comment to (v5.9.0).
ui/modals/card-sheet-modal.js Bumped header comment to (v5.9.0).
ui/modals/options-modal.js Bumped header comment to (v5.9.0).
tools/proofing/spellcheck-engine.js Bumped header comment to (v5.9.0).
extensions/legacy-fixes.js Bumped header comment to (v5.9.0).
extensions/print-engine.js Bumped header comment to (v5.9.0).
extensions/pwa-install.js Bumped header comment to (v5.9.0).

wrapper.html was not modified.


βœ… v5.9.0 Verification Checklist

  • [x] Initial Paste Styling Preserved: Pasting CSS-styled text from dark-themed sites retains its original background color and styling on initial paste.
  • [x] Conflicting CSS Background Stripping: Attempting to change highlight color on pasted text removes block and inline CSS background styling and applies the new highlight cleanly.
  • [x] Collapsed Caret Support: Clicking the Highlight tool with a collapsed caret immediately after pasting highlights all text in the target box.
  • [x] Multi-Highlight Coexistence: Changing highlight color on one word does not strip or corrupt existing Open Publisher highlights on neighboring words.
  • [x] Color Picker Interaction: Clicking swatches, switching tabs, or dragging the HSV canvas in #custom-color-picker preserves active text selection and range.
  • [x] Service Worker & Cachebuster Sync: Verified sw.js cache name is open-publisher-v5-9-0 and all asset query strings in index.html reference ?v=5.9.0.
  • [x] Subsystem Version Consistency: Confirmed all modified subsystems and modules reflect version 5.9.0.

πŸŽ‰ Version 5.9.0: Open Publisher

Source: README.md, updated 2026-10-17