Repository navigation
feat(viewer): register the pdf handler with @nextcloud/viewer - #1586
Merged
Merged
Conversation
skjnldsv
force-pushed
the
feature/nextcloud-viewer-package
branch
from
September 30, 2026 01:29
deaf8ff to
09695e7
Compare
Member
|
Tried this branch in the richdocuments Cypress run (nextcloud/richdocuments#6142): clicking a PDF downloads it instead of opening the viewer. The branch bundles Failing run: https://github.com/nextcloud/richdocuments/actions/runs/37293538070 |
Member
Author
|
@juliusknorr yes, we've have a bump pr for this on server: nextcloud/server#65000 |
The viewer app went away with nextcloud/server#63954, and with it OCA.Viewer.registerHandler and the LoadViewer event this app hung off, so PDFs stopped opening in the viewer on 36. The handler names a custom element, defined from PDFView in onInit, so the view only loads the first time a PDF is opened. The registration goes out as an init script on every page but the error page and the pdf.js page itself. PDFView gets the node the viewer hands over, uploads annotations to it, and hands a restricted file to richdocuments by id when richdocuments has a viewer handler to take it. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
pdf.js decodes its file parameter once, so with the unencoded source a file named "my file #1.pdf" loaded "my file " and nothing else. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
skjnldsv
force-pushed
the
feature/nextcloud-viewer-package
branch
from
October 9, 2026 08:20
09695e7 to
1812b9b
Compare
skjnldsv
marked this pull request as ready for review
October 9, 2026 08:24
4 tasks done
juliusknorr
approved these changes
Oct 12, 2026
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.
The viewer app goes away with nextcloud/server#63954, and with it
OCA.Viewer.registerHandlerand theLoadViewerevent this app hangs off, so PDFs stop opening in the viewer on 36. This registers the handler through the@nextcloud/viewerpackage instead.Fixes #1572
Depends on nextcloud/server#63954
The handler is a custom element,
files-pdfviewer-view, wrapping PDFView, which is still only loaded once a PDF is opened.LoadViewerListenerlistens toBeforeTemplateRenderedEventnow and adds the registration as an init script, skipping the error page and the pdf.js page the viewer frames. PDFView gets the node the viewer hands over instead offileListandfileid, and uploads annotations to itsencodedSource. The handler id stayspdf, since files_emailviewer looks it up by id.The richdocuments fallback for a share that hides or forbids the download works as before, but through
getViewer().open(files, file, undefined, 'richdocuments'). It only kicks in once richdocuments has a viewer handler, which needs nextcloud/richdocuments#6060: until then it is as if richdocuments were not installed. Reopening like that drops the opener'sonClose, nextcloud-libraries/nextcloud-viewer#66 keeps it.pdf.js decodes its
fileparameter once, so the iframe gets the encoded dav URL now. With the unencoded one,my file #1.pdfloadedmy fileand nothing else. That is its own commit; the old code passedsourcethe same way, so it was probably broken before too.The assets commit adds 467 files and removes 387, most of the new ones being the viewer's own lazy chunks, which every app bundling the package ships.
Checked in a browser against server#63954: opening from Files and from a public link share, saving annotations on
test.pdfandmy file #1.pdf, and a link share with hidden download, where pdf.js comes up with printing and text selection off. Not checked: the richdocuments handoff, since no richdocuments has a v2 handler yet, and the versions compare view.👾 This pull request was assisted by Claude Code, commits carry an
Assisted-bytrailer.