Skip to content

fix: migrate to @nextcloud/viewer 2 and Vue 3 - #6142

Merged
juliusknorr merged 15 commits into
mainfrom
fix/6060-nextcloud-viewer-v2
Oct 8, 2026
Merged

juliusknorr merged 15 commits into
mainfrom
fix/6060-nextcloud-viewer-v2

Conversation

@juliusknorr

@juliusknorr juliusknorr commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Port off the removed OCA.Viewer global (nextcloud/server#63954):

  • Bump to Vue 3, @nextcloud/vue 9, @nextcloud/dialogs 7 and @nextcloud/viewer 2 (beta)
  • Register the viewer handler as a richdocuments-viewer custom element with enabled(nodes)
  • Open files via getViewer().open() (file actions, public share, "continue editing online")
  • Load the handler on BeforeTemplateRenderedEvent instead of LoadViewer

Known limitation: no "Compare to current version" for office files

On server master the versions tab only offers compare for images, see FilesVersionsSidebarTab.vue#L120-L127, because @nextcloud/viewer had no canCompare handler flag. The comparison itself works with this PR (getViewer().compare() shows current and old version side by side).

To fix, once nextcloud-libraries/nextcloud-viewer#94 is released (after 2.0.0-beta.14):

  • server: replace the mime check with canCompare(node) from @nextcloud/viewer
  • here: bump @nextcloud/viewer and set canCompare: true in registerHandler() in src/init-viewer.js

TODO

  • Opening a document from Files, closing it
  • Opening an old version (read-only), comparing via getViewer().compare()
  • Public link share: guest name dialog, then editing
  • Admin settings (toggles, allow list, group select) and personal settings (template folder picker)
  • Reference picker: file picker, section list, generated link opens the document. Tested by mounting the picker element directly, as Text on server master does not open files with the new viewer yet
  • Set canCompare once the viewer release is out (see above)

The new viewer remounts a handler on every files:node:updated for the file it shows, which reloaded the document on each save. The editor now holds that event back until it closes, so the files list updates its modification time on close. A handler flag in @nextcloud/viewer to opt out of the reload would be the cleaner fix.

Expected CI failures from other apps on server master, not this PR:

  • talk.spec.js: Talk still calls OCA.Viewer.registerHandler
  • open.spec.js "Open PDF with files PDF viewer": files_pdfviewer registers no viewer handler on master yet

share-link.js now reopens the folder instead of reloading, as server master does not serve the /s/{token}/{fileid} URLs the files app navigates to on public shares.

Not changed here: src/public.js reads hidden inputs (#mimetype, #hideDownload) that public share pages no longer render, so its PDF special case does nothing on current servers. Documents on shares still open through the Files app.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

@elzody

elzody commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Scared me at first when I saw the line diff. Luckily, most of it is from updating package-lock.json. Otherwise, looks good. Started looking into the problems with viewer in the failing Cypress tests, and it led me here. :)

Was going to suggest a more logical separation in terms of migrating to Vue 3 and then doing the migration to @nextcloud/viewer, accepting failures on main until then (as we do now), but I guess why not do them both at once.

@juliusknorr
juliusknorr force-pushed the fix/6060-nextcloud-viewer-v2 branch from 62a5621 to 470c964 Compare October 5, 2026 09:58
juliusknorr added a commit to nextcloud/office that referenced this pull request Oct 5, 2026
Server master dropped the bundled Viewer app, so released richdocuments no
longer opens files. Build nextcloud/richdocuments#6142 until it is released.
Revert once a release supports @nextcloud/viewer.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr
juliusknorr marked this pull request as ready for review October 5, 2026 14:51
@juliusknorr
juliusknorr requested a review from elzody as a code owner October 5, 2026 14:51
@juliusknorr juliusknorr added 3. to review Ready to be reviewed technical debt labels Oct 5, 2026
@juliusknorr

Copy link
Copy Markdown
Member Author

Was going to suggest a more logical separation in terms of migrating to Vue 3 and then doing the migration to @nextcloud/viewer, accepting failures on main until then (as we do now), but I guess why not do them both at once.

The problem is that then we would build vue 3 compatible version that we could not test without an older server commit or only against stable33. I feel reasonably comfortable with doing both changes also considering CI is mostly happy (except for the mentioned cases).

juliusknorr added a commit to nextcloud/office that referenced this pull request Oct 5, 2026
Server master dropped the bundled Viewer app, so released richdocuments no
longer opens files. Build nextcloud/richdocuments#6142, pinned to a commit,
until it is released. Revert once a release supports @nextcloud/viewer.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Julius Knorr <jus@bitgrid.net>
juliusknorr added a commit to nextcloud/office that referenced this pull request Oct 5, 2026
Server master dropped the bundled Viewer app, so released richdocuments no
longer opens files. Build nextcloud/richdocuments#6142, pinned to a commit,
until it is released. Revert once a release supports @nextcloud/viewer.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Julius Knorr <jus@bitgrid.net>

@elzody elzody left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good after taking a look through things manually. A review with Claude revealed the following that might be interesting to double check.

The viewer keeps richdocument's component hidden until it emits loaded, which is only emitted after Collabora's iframe reports back; so if an error were to occur before that then it's possible the viewer will be stuck loading while the failure is hidden and the viewer keeps spinning. I don't have a good answer for that, but maybe we could do something with the viewer's errored event.

A smaller nitpick would be to guard BeforeTemplateRenderedEvent against loading the viewer on an error page rendering since documents can't be opened there. Other apps do this too:

if ($event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_ERROR) {
    return;
}

@juliusknorr

Copy link
Copy Markdown
Member Author

Thanks, I'll check on those

@juliusknorr
juliusknorr force-pushed the fix/6060-nextcloud-viewer-v2 branch from 77bb9da to 7464a24 Compare October 5, 2026 19:04
@juliusknorr

Copy link
Copy Markdown
Member Author

@elzody Thanks, both fixed: any loading failure, now including a failed token request, reports the editor as loaded so the viewer shows our error screen instead of spinning (loaded rather than errored keeps our more detailed error message), and the listener now skips error pages.

@juliusknorr
juliusknorr force-pushed the fix/6060-nextcloud-viewer-v2 branch from 76b0c89 to ffc1f20 Compare October 7, 2026 10:54
Register the viewer handler as a custom element and open files through
getViewer() instead of the removed OCA.Viewer global. Load the handler
on BeforeTemplateRenderedEvent since LoadViewer is gone with the viewer app.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
…ding on save

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
…ding

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Bumps @nextcloud/viewer to 2.0.0-beta.15 for the canCompare handler flag.

Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5

Signed-off-by: Julius Knorr <jus@bitgrid.net>
@juliusknorr
juliusknorr force-pushed the fix/6060-nextcloud-viewer-v2 branch from 38bb958 to 1738455 Compare October 8, 2026 07:52
@juliusknorr
juliusknorr merged commit 106fcca into main Oct 8, 2026
82 of 90 checks passed
@juliusknorr
juliusknorr deleted the fix/6060-nextcloud-viewer-v2 branch October 8, 2026 08:54
@elzody elzody mentioned this pull request Oct 8, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Ready to be reviewed technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate off the OCA.Viewer global before Nextcloud 36

2 participants