Repository navigation
fix(readonly): show read-only state in the editor toolbar - #299
Merged
Merged
Conversation
asc_setRestriction blocks edits in the SDK only; no web-app listens for asc_onChangeRestrictions, so readonly documents kept a toolbar that looked live and did nothing (#298). Push the vendor's own stacked editing:disable request under a 'readonly' type when locking and pop it when unlocking, leaving search, navigation, zoom and the status bar usable. Drop the processRightsChange fallback: serviceCommand wrapped it in internalCommand so it never reached the editor, and the vendor handles it by disconnecting, which cannot be undone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…disable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying document with
|
| Latest commit: |
cfc70ff
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ddbd529b.document-7hm.pages.dev |
| Branch Preview URL: | https://fix-readonly-toolbar-state.document-7hm.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #298.
Problem
Read-only (
?readonly=1, embedreadonly: true,document:set-readonly) blocked edits throughasc_setRestriction(128), but no vendor web-app listens forasc_onChangeRestrictions. The toolbar, right panel and context menu stayed visually enabled while doing nothing.The
processRightsChangefallback inlib/onlyoffice/readonly.tsnever reached the editor (serviceCommandwraps it ininternalCommand). Had it arrived, the vendor would have handled it withasc_coAuthoringDisconnect(), which cannot be undone.Change
editing:disableevent under areadonlytype: push it on lock, pop it on unlock. This is the same mechanism the vendor uses for signature, forms and disconnect, and it re-applies whatever is left on the stack.viewModefollows the flag.DisableToolbarstores it aseditMode, so an unlock that kept ittruewould leave the mask on.onDocumentReadynow callssetReadonlyMode(true), so the restriction and the UI lock are applied together.editorSendCommand(scopedrg: zero references), plus the two unit tests that pinned it.Trade-off: the vendor masks the whole toolbar, so the PDF editor's toolbar paging and zoom are covered too. The status bar keeps zoom, fit and paging.
Verification
test/e2e/readonly-chrome.spec.tscovers docx, xlsx, pptx and pdf: open read-only → mask present, search and zoom-in usable → unlock → mask gone → relock → mask back.syncReadonlyChrome(readonly)commented out, all 4 fail (masked: false). With it restored, all 4 pass.vendor-contract.test.tsnow pinsediting:disable,stackDisableActions, andDisableToolbarstoring viewMode as editMode in all four apps.Record:
docs/explorations/2026-11-02-readonly-toolbar-state.md🤖 Generated with Claude Code