Download Latest Version openpublisher5g_amd64-windows.exe (81.1 MB)
Home / 5.1.7
Name Modified Size InfoDownloads / Week
Parent folder
openpublisher5_amd64-windows-portable.exe 2026-09-27 183.2 MB
openpublisher5_amd64-windows.exe 2026-09-27 165.2 MB
openpublisher5_amd64-macos.dmg 2026-09-27 233.1 MB
openpublisher5_amd64-linux.run 2026-09-27 193.4 MB
openpublisher5_amd64-linux.rpm 2026-09-27 215.4 MB
openpublisher5_amd64-linux.flatpak 2026-09-27 153.6 MB
5.1.7_ Document Load Page Focusing, Viewport Auto-Centering, Focus Outline Removal _ Smooth Horizontal Scrolling source code.tar.gz 2026-09-27 21.5 MB
5.1.7_ Document Load Page Focusing, Viewport Auto-Centering, Focus Outline Removal _ Smooth Horizontal Scrolling source code.zip 2026-09-27 21.7 MB
README.md 2026-09-27 14.8 kB
openpublisher5_amd64-linux.deb 2026-09-27 156.2 MB
openpublisher5_amd64-linux.AppImage 2026-09-27 176.6 MB
openpublisher5_amd64-freebsd.pkg 2026-09-27 185.5 MB
Totals: 12 Items   1.7 GB 0

πŸš€ Summary

Version 5.1.7 resolves an issue where loading an .opub document, template, or recent publication caused the page canvas to spawn off-screen or at distant viewport scroll offsets, forcing users to manually drag scrollbars to locate their document. This problem was especially noticeable when switching between publications with differing dimensions or resolutions (such as moving from a 96 DPI screen format to a 300 DPI high-resolution print sheet).

Additionally, this release eliminates the black border outline that previously appeared around documents and resolves the horizontal scrolling limitation where side-to-side scrolling was unavailable unless using the pan tool.

With version 5.1.7, Open Publisher introduces a centralized window.focusPage() engine and a dedicated window.updateCanvasScrollBounds() layout coordinator:

  1. Multi-page spread or overview modes are cleanly exited.
  2. Selection outlines and floating toolbars are dismissed.
  3. Viewport scroll positions (scrollTop and scrollLeft) are reset to 0.
  4. An enhanced, robust fitToPage() automatically calculates the optical zoom level so the full document is visible within the viewport.
  5. The black focus outline around documents is completely eliminated by removing tabindex manipulation and enforcing outline: none !important; in CSS.
  6. Native horizontal scrolling (scrollbars, mouse wheel, Shift + Wheel, trackpads) works smoothly across all zoom levels without cutting off the left or right edges of the publication.

[!IMPORTANT] Note for Existing Publications: When working on existing publications, be sure to set the page size and DPI for the publication you are working on and then re-save it. The saved version will successfully remember the set DPI and page size.


πŸ” Root Cause Analysis

Investigation identified the technical factors behind each reported issue:

  1. Persistent Viewport Scroll Offsets on Document Load:
  2. The main #viewport container uses overflow: auto with flex alignment.
  3. When a user scrolled through a large publication or zoomed in during a session, the viewport retained its prior scrollTop and scrollLeft values in memory.
  4. When a new document was loaded (especially a high-DPI document such as A4 at 300 DPI measuring 2480px x 3508px), the canvas rendered into the scrolled viewport, resulting in negative relative bounding coordinates (for example, paperRect.top = -524px). The canvas appeared completely off-screen above or to the left of the visible workspace.

  5. Black Line Around Pages:

  6. In earlier iterations, window.focusPage() assigned paperEl.setAttribute('tabindex', '-1') and invoked paperEl.focus().
  7. Chromium and Firefox automatically render a default 1px dark focus rectangle (outline: auto 1px) around elements with a tabindex when focused.
  8. In style.css, #paper did not have an explicit outline: none !important; rule, allowing the browser's default focus ring to show around the entire page.

  9. Loss of Native Horizontal Scrolling (Side-to-Side):

  10. The .viewport flex container uses justify-content: center to center the unscaled #paper element.
  11. #paper transforms using transform: scale(z) with transform-origin: top center;.
  12. When zoomed in (e.g., 1.5x, 2.0x, 3.0x or high-DPI documents), the scaled paper expands symmetrically left and right from the center.
  13. Because justify-content: center centers the unscaled layout footprint (794px), the scaled expansion to the left extends into negative coordinates (paperRect.left < viewportRect.left).
  14. Standard CSS scroll containers (overflow: auto) cannot scroll into negative coordinate space in left-to-right (LTR) mode (scrollLeft minimum is 0). As a result, the left side of the scaled page was cut off and completely inaccessible via scrollbars or mouse wheels.
  15. Furthermore, CSS transforms do not expand layout scrollWidth, so the viewport's scrollWidth remained identical to clientWidth, preventing native horizontal scrollbars from appearing.
  16. The pan hand tool was the only mechanism able to reach off-screen content because it directly manipulated paper.style.left and paper.style.top in extensions/system-patches.js.
  17. False positive tests: Earlier automated tests reported maxScroll values of ~629px, but these measured scrollWidth in the same JavaScript evaluation frame as layout changes, before Chromium's layout engine recalculated. The real browser constraint was that at fit-to-page zoom (~0.44x), scrollWidth = clientWidth + 1 (1px of scroll), which persisted after any document load or zoom reset.

πŸ› οΈ Enhancements & Architectural Changes

1. Centralized Page Focus Engine (canvas/canvas.js)

  • Implemented window.focusPage(pageIndex = null):
  • Exits multi-page mode if active and sets state.viewMode = 'single'.
  • Automatically switches to the specified pageIndex if provided.
  • Clears stale selection overlays, handles, and floating formatting toolbars.
  • Resets pan offsets: paperEl.style.left = ''; paperEl.style.top = '';.
  • Removes any tabindex attribute from #paper.
  • Resets #viewport.scrollTop = 0.
  • Invokes window.fitToPage().
  • Calls window.updateCanvasScrollBounds() to ensure the paper bounds and scroll ranges are fully synchronized.
  • Synchronizes rulers, margin guide overlays, handle scaling, and minimap displays.

2. Elimination of Black Focus Outline (style.css, canvas/canvas.js)

  • In style.css:
  • Added outline: none !important; directly to the #paper ruleset.
  • Added #paper:focus, #paper:focus-visible { outline: none !important; }.
  • In canvas/canvas.js:
  • Removed tabindex and .focus() calls entirely from window.focusPage().
  • Explicitly strips tabindex if present on #paper.

3. Dynamic Canvas Scroll Bounds Engine (canvas/canvas.js)

  • Implemented window.updateCanvasScrollBounds():
  • Bypasses adjustments while the pan hand tool is actively engaged (viewport.classList.contains('panning')).
  • Calculates naturalLeft = (vpW - scaledW) / 2 - where the paper's left edge would naturally fall with flex centering.
  • Computes shiftNeeded = pad - naturalLeft to determine how much to shift the paper right so its left edge stays at least 50px from the viewport left edge at scrollLeft = 0.
  • If shiftNeeded > 0 (page overflows viewport): sets paper.style.left = shiftNeeded + 'px' and injects a #canvas-scroll-sizer div at left = pad + scaledW + pad to force scrollWidth to cover the full scaled width with equal 50px padding on each side.
  • If shiftNeeded <= 0 (page fits in viewport): clears paper.style.left and removes the sizer entirely, preventing any spurious horizontal scrollbar.
  • Hooked into window.setZoom(), window.focusPage(), and window resize events.
  • Restores full native side-to-side scrolling via scrollbar track dragging, horizontal mouse wheel (deltaX), and Shift + vertical wheel (deltaY).

4. Resilient fitToPage() and fitToWidth() Fallbacks (canvas/canvas.js)

  • Replaced fragile DOM dimension checks with multi-tier fallbacks:
  • paperW = paperEl.offsetWidth || parseInt(paperEl.style.width) || (state.pages[state.currentPageIndex] && parseInt(state.pages[state.currentPageIndex].width)) || 794
  • paperH = paperEl.offsetHeight || parseInt(paperEl.style.height) || (state.pages[state.currentPageIndex] && parseInt(state.pages[state.currentPageIndex].height)) || 1123
  • Guaranteed that optical zoom calculations succeed consistently across all page sizes and resolutions.

5. File Loader Focus Integration (io/publisher-file-loader.js)

  • In loadDocumentData():
  • Invokes window.focusPage(0) immediately following renderPage(state.pages[0]).
  • Executes a second window.focusPage(0) pass in the 100ms post-render timeout alongside syncMarginGuideOverlay().
  • Ensures .opub, .json, .pub, and .docx publications always open centered and fully visible.

6. Dashboard Start Screen & Recent Files (ui/dashboard.js)

  • In startBlank(size):
  • Invokes window.focusPage(0) after generating the initial blank canvas.
  • In recent file card clicks (card.onclick):
  • Invokes window.focusPage(state.currentPageIndex) immediately upon card activation and again at 100ms.
  • Updated template index request parameter to template-index.json?v=5.1.7.

7. Template Library Integration (elements/templates/templates.js)

  • In loadTemplate(opubData):
  • Calls window.focusPage(0) directly upon rendering the template's first page.
  • Re-triggers window.focusPage(0) in the 50ms post-render timeout to adjust for template fonts and asset layout settling.

8. Global Cachebuster Bump (index.html)

  • Bumped all script, stylesheet, and asset cachebuster query strings from ?v=5.1.6 to ?v=5.1.7 across index.html.

πŸ§ͺ Verification & Automated Testing

Two comprehensive test suites were created and executed in Playwright against the production codebase:

Suite A: Focus & Document Loading Suite (scratch/test_focus_v517_verification.py)

All 10 verification scenarios passed with zero errors:

  1. A4 @ 300 DPI Publication Load: scrollTop = 0, scrollLeft = 0, zoom = 0.141, isEntirelyVisible = True.
  2. Letter @ 96 DPI Publication Load: scrollTop = 0, scrollLeft = 0, zoom = 0.468, isEntirelyVisible = True.
  3. Tabloid @ 150 DPI Publication Load: scrollTop = 0, scrollLeft = 0, zoom = 0.194, isEntirelyVisible = True.
  4. Business Card @ 300 DPI Publication Load: scrollTop = 0, scrollLeft = 0, zoom = 0.823, isEntirelyVisible = True.
  5. Template Library Load: scrollTop = 0, scrollLeft = 0, zoom = 0.440, isEntirelyVisible = True.
  6. Dashboard Blank Document Launch: scrollTop = 0, scrollLeft = 0, zoom = 0.440, isEntirelyVisible = True.
  7. Interactive Page Format Change (setPageSize): scrollTop = 0, scrollLeft = 0, zoom = 0.303, isEntirelyVisible = True.
  8. Manual High Zoom & Focus Recovery: Zoom set to 2.5x with viewport scrolled to (1200, 800), followed by window.focusPage(). Result: scrollTop = 0, scrollLeft = 0, isEntirelyVisible = True.
  9. New Document Dialog (handleNewDocument): scrollTop = 0, scrollLeft = 0, zoom = 0.440, isEntirelyVisible = True.
  10. Dashboard Recent Publication Card Click: Restored recent Tabloid document from op_recent_files. Result: scrollTop = 0, scrollLeft = 0, zoom = 0.194, isEntirelyVisible = True.

Suite B: Outline Elimination & Side-to-Side Scrolling Suite (scratch/test_verify_real_files.py)

All 18 verification checks passed with zero errors:

  1. Fit-to-page zoom: zero horizontal scroll - No spurious scrollbar at default zoom.
  2. scrollLeft reset on load - scrollLeft == 0 after document open.
  3. No pan offset on paper - paper.style.left is empty after load.
  4. No black outline - outline: none confirmed via computed style.
  5. scrollWidth correct at zoom 2.0 - scrollWidth = 1688 (pad + scaledW + pad).
  6. maxScroll > 100px at zoom 2.0 - maxScroll = 628px.
  7. scrollLeft stays at 200 after 200ms - Scroll is not reset asynchronously.
  8. Shift+Wheel produces scroll - scrollLeft = 120 after horizontal wheel event.
  9. Right padding at max scroll = 50px - Symmetric 50px padding on each side.
  10. Left padding at scroll-left=0 = 50px - 50px breathing room on left edge.
  11. fitToPage resets scrollLeft to 0 - Calling fitToPage() after panning resets scroll.
  12. fitToPage maxScroll <= 5px - No horizontal overflow after fit-to-page. 13-17. All zoom levels (1.0x - 3.0x) have correct maxScroll - Zero at zoom 1.0, 231 at 1.5x, 628 at 2.0x, 1025 at 2.5x, 1422 at 3.0x.
  13. Pan tool bypass - panning CSS class prevents updateCanvasScrollBounds from overriding pan offsets.

βœ… Checklist Completed

  • [x] style.css: Added outline: none !important; to #paper and #paper:focus, #paper:focus-visible to permanently eliminate the dark focus border.
  • [x] canvas/canvas.js: Created window.updateCanvasScrollBounds() with corrected sizer formula (rightEdge = pad + scaledW + pad), restoring native side-to-side scrolling without left-side clipping across all zoom levels (1.0x through 3.0x verified).
  • [x] canvas/canvas.js: Sizer is only created when content overflows the viewport; it is removed when the page fits, preventing spurious horizontal scrollbars.
  • [x] canvas/canvas.js: Hooked window.updateCanvasScrollBounds() into window.setZoom() and window resize events.
  • [x] canvas/canvas.js: Updated window.focusPage() to remove tabindex and .focus(), reset pan offsets, reset scrollTop = 0, call fitToPage(), and call updateCanvasScrollBounds().
  • [x] layout/document.js: Coordinated setPageSize() and openPageSizeModal with window.focusPage() and window.updateCanvasScrollBounds().
  • [x] io/publisher-file-loader.js: Maintained immediate and delayed window.focusPage(0) calls in loadDocumentData() to center every opened .opub, .json, .pub, and .docx file.
  • [x] ui/dashboard.js: Maintained window.focusPage(0) in startBlank() and recent file card handlers; bumped template index query parameter to ?v=5.1.7.
  • [x] elements/templates/templates.js: Maintained immediate and delayed window.focusPage(0) calls in loadTemplate().
  • [x] core/pages.js: Scoped currentPreset to handleNewDocument() outer function; maintained window.focusPage(0) upon document creation.
  • [x] index.html: Bumped all script, stylesheet, and asset cachebusters from ?v=5.1.6 to ?v=5.1.7.
  • [x] Automated Verification: Executed automated test suites (test_focus_v517_verification.py and test_verify_real_files.py), passing all 28 test cases (18 + 10).

πŸŽ‰ Version 5.1.7 - Open Publisher

Source: README.md, updated 2026-09-27