Skip to content

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

Open
juliusknorr wants to merge 11 commits into
mainfrom
fix/6060-nextcloud-viewer-v2
Open

juliusknorr wants to merge 11 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.

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>
@juliusknorr
juliusknorr force-pushed the fix/6060-nextcloud-viewer-v2 branch from 62a5621 to 470c964 Compare October 5, 2026 09:58
…ding

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

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 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).

This branch has not been deployed

No deployments
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