Skip to content

feat(readonly): keep only File and View tabs in read-only mode - #300

Merged
chaxus merged 3 commits into
mainfrom
feat/readonly-hide-edit-tabs
Nov 2, 2026
Merged

chaxus merged 3 commits into
mainfrom
feat/readonly-hide-edit-tabs

Conversation

@chaxus

@chaxus chaxus commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #299 for #298 (rebased onto main after #299 merged).

Problem

#299 masked the whole toolbar in read-only mode. The buttons were disabled but still visible, and the mask also covered the View tab, so zoom and navigation in the toolbar were grayed out as well. The issue asks for editing controls to be hidden or visibly disabled while viewing tools stay usable.

Change (lib/onlyoffice/readonly.ts)

  • Tabs: keep only File and View in all four editors. Every other tab is hidden, including contextual ones (table design, header/footer, pivot, slide master). This is a CSS rule on the editor frame, not a vendor setVisible call, because the vendor re-shows contextual tabs on its own when the selection moves.
  • Active tab: switch to View on lock, and return to the previously active tab on unlock.
  • Hidden controls outside the hidden tabs (vendor #slot-* ids):
    • paste, cut and format painter (copy stays);
    • macros, record and pause;
    • xlsx new/close sheet view and freeze panes;
    • pptx slide master;
    • PDF "Edit PDF";
    • the header edit-mode switch.
  • editing:disable no longer masks the toolbar. It still locks the right panel, context menu, review, comments preview, cell editor and header undo/redo.
  • Still visible and usable: View-tab tools (zoom, fit, navigation, theme, rulers, gridlines, notes, PDF hand/select), copy, select all, left-menu search/navigation/thumbnails, and the status bar. The right-panel icon strip stays visible but disabled.

Verification

  • test/e2e/readonly-chrome.spec.ts runs once each for docx, xlsx, pptx and pdf:
    • read-only open → visible tabs are exactly ['file','view'], View is active, paste is hidden, search and zoom-in are usable;
    • unlock → Home is back and active, paste is visible;
    • relock → back to the read-only state.
  • Reverse validation:
    • with syncReadonlyTabs commented out, all 4 fail (extra home/ins/review… tabs);
    • with READONLY_HIDDEN_SLOTS emptied, all 4 fail (paste: true);
    • with both restored, all 4 pass.
  • The existing read-only cases (format-parity, embed-regression, pdf-roundtrip) plus the new spec pass: 13/13 against local vite dev.
  • Unit tests (vendor-contract, onlyoffice-editor, embed-api), tsc, oxlint and prettier pass.

Record: docs/explorations/2026-11-02-readonly-hide-edit-tabs.md

🤖 Generated with Claude Code

chaxus and others added 3 commits November 2, 2026 10:40
…them

The toolbar mask grayed out every tab, View included, so a readonly
document lost its zoom and navigation along with the editing buttons. Keep
only the File and View tabs, open on View, and hide the editing controls
that live outside the tabs: paste, cut, format painter, macros, sheet views,
freeze panes, slide master, Edit PDF and the header's edit-mode switch.
Unlocking shows them again and returns to the tab that was open.

The rule is CSS on the editor frame rather than vendor tab calls, because
the vendor shows contextual tabs on its own as the selection moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tons

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chaxus
chaxus force-pushed the feat/readonly-hide-edit-tabs branch from cd5caac to 788eab2 Compare November 2, 2026 02:40
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Deploying document with  Cloudflare Pages  Cloudflare Pages

Latest commit: 788eab2
Status: ✅  Deploy successful!
Preview URL: https://ffbe808f.document-7hm.pages.dev
Branch Preview URL: https://feat-readonly-hide-edit-tabs.document-7hm.pages.dev

View logs

@chaxus
chaxus enabled auto-merge (rebase) November 2, 2026 02:42
@chaxus
chaxus merged commit 92dfd77 into main Nov 2, 2026
20 checks passed
@chaxus
chaxus deleted the feat/readonly-hide-edit-tabs branch November 2, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant