nextcloud / nextcloud/files_pdfviewer
Theme is got from the browser settings rather than from Nextcloud settings
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 108
- Forks
- 61
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 29
Description
In theory it should be possible to set a specific theme with PDFViewerApplicationOptions.set('viewerCssTheme', {THEME_ID}), so the theme could be forced based on the Nextcloud theme, but unfortunately that option does not seem to work in the current PDF.js version used in the PDF viewer, 3.11.174. Moreover, that option was removed in the following PDF.js version, 4.0.189.
But! it was restored again in PDF.js 4.0.269, and in that version it works as expected when used from the PDF viewer.
Due to that this issue will be fixable once PDF.js is updated to 4.0.269 or later.
Note, however, that forcing a specific theme is done during the initialization of PDF.js and it does not seem to be possible to update the theme afterwards. Due to that, if the theme in Nextcloud is set to follow the browser theme, and the browser theme is changed while the PDF viewer is opened, even if the option is set again the theme will not be updated in the PDF viewer.
How to test
- Open browser settings and set the light theme
- Log in Nextcloud
- Open Nextcloud "Appearance and accessibility" settings and set the dark theme
- Open the Files app
- Upload a PDF file
- Open the PDF file
Expected result
The PDF viewer is shown with a dark theme, just like the Files app
Actual result
The PDF viewer is shown with a light theme, even if the Files app is shown with a dark theme
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PDF.js dependency and the PDFViewerApplicationOptions.set('viewerCssTheme', ...) initialization call. Update to PDF.js 4.0.269 or later, then repeat the listed Nextcloud appearance and PDF-opening steps; the viewer should use the Nextcloud-selected dark theme when the browser is light.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100