Skip to content

feat: open whiteboards in the viewer of Nextcloud 36 - #1374

Merged
hweihwang merged 4 commits into
mainfrom
feature/migrate-new-viewer-api
Oct 19, 2026
Merged

hweihwang merged 4 commits into
mainfrom
feature/migrate-new-viewer-api

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

In Nextcloud 36 the viewer is part of the server as @nextcloud/viewer. It takes handlers as custom elements, and nothing dispatches LoadViewer or offers OCA.Viewer.registerHandler any more, so whiteboards no longer open in the viewer on master. The end-to-end setup also failed on master, because it read the viewer app's checkout, so no Playwright test ran against master.

On 36, an init script registers a <whiteboard-viewer> element on every page. The element renders the board and is defined the first time a board opens. Servers up to 35 keep the viewer app path.

  • @nextcloud/viewer 2.0.0-beta.18, which needs canCompare to be a function.
  • The comparison mode comes from the element's comparison property. When comparing, both boards read their own source, so the current file shows read-only next to the older version.
  • Only the viewer modal renders the element on 36, so it is not embedded yet. The link preview in Text, Talk and the Smart Picker needs feat(viewer): show a file anywhere with <nc-viewer-file> nextcloud-libraries/nextcloud-viewer#97 and a server change first; embed.spec.ts is skipped on master until then.
  • The CommonJS helper gets its own chunk, so the init script no longer loads React on every page: its static imports go from 311.9 KiB to 175.6 KiB.
  • On 36, Text's editor loader for tables loads on every page, as any app can open a board in the viewer.
  • PHP test mocks return IUserFolder on 36 (from test: prepare unit and e2e tests for Nextcloud 36 #1385, which this replaces).

Tested with unit tests for both listeners, a build test that the viewer init script loads no React, and a Playwright test on master that compares a version with the current file. Manually on a Nextcloud 36 instance: opening a board from Files, comparing the initial version with the current one in the Versions tab (both boards render read-only), and a public link while logged out. Escape inside the board closes the viewer because of a @nextcloud/vue hotkey bug.

  • Prepared with AI assistance.

@hweihwang hweihwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks John, nice work! A few things before this can go in:

  • Server master moved to @nextcloud/viewer beta.18 on Oct 12, where canCompare has to be a function, so Compare disappears for whiteboards right now.
  • The whiteboard-viewer init script runs on every page and pulls in React (~312 KiB), and Text's editor now loads on every page too. Could both load only where a board can open?
  • WhiteboardViewerElement.ts detects embedded and comparison mode from the viewer's class names, while beta.18 already passes comparison as a prop.

#1385 fixes the IUserFolder mocks and skips the embed test on master, so CI here can go green once that is in.

@skjnldsv

Copy link
Copy Markdown
Member Author

Hey! I've made this PR as a nice starting point, but ultimately, devs should take over as I can't realistically migrate all repositories to my new viewer library 😉

@hweihwang hweihwang self-assigned this Oct 19, 2026
mejo- added a commit to nextcloud/collectives that referenced this pull request Oct 19, 2026
Requires nextcloud/whiteboard#1374 to succeed with
latest Text.

Signed-off-by: Jonas <jonas@freesources.org>
skjnldsv and others added 3 commits October 19, 2026 21:15
The viewer is part of the server from 36: the setup installed the app anyway and then failed reading its checkout, so no end-to-end test ran against master.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
The viewer moved into the server as @nextcloud/viewer, which takes handlers
as custom elements and no longer dispatches LoadViewer or offers
OCA.Viewer.registerHandler. On 36 and up, a small init script now registers
a <whiteboard-viewer> element on every page, defined the first time a
board opens. It renders the board as before: read-only outside the viewer
(the preview of a link to the file) and side by side with another version,
and an older version from its own source.

Servers up to 35 keep the viewer app's LoadViewer path. The main script
skips its legacy registration on 36, where it still runs as the board
shares chunks with it.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
On Nextcloud 36, IRootFolder::getUserFolder() returns IUserFolder, so the
Folder mocks fail with IncompatibleReturnValueException. Mock IUserFolder
when it exists.

Skip the embed e2e test on master: the Files smart picker and the file
reference widget do not work with the Nextcloud 36 viewer yet.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
@hweihwang
hweihwang force-pushed the feature/migrate-new-viewer-api branch from 492863e to d2d8e03 Compare October 19, 2026 14:32
…ct out of its init script

@nextcloud/viewer 2.0.0-beta.18 rejects a handler whose canCompare is
not a function, so it is one now.

The comparison mode comes from the comparison property the viewer sets,
instead of the CSS classes around the element. When comparing, both
boards read their own source: the current file is compared with a
version and is read-only there too, instead of failing without a source.
On Nextcloud 36 only the viewer modal renders the element, so it is not
embedded for now.

The CommonJS helper gets its own chunk. In vendor, it made the viewer
init script, which runs on every page, load React: its static imports
go from 311.9 KiB to 175.6 KiB.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
@hweihwang
hweihwang force-pushed the feature/migrate-new-viewer-api branch from d2d8e03 to 3615c25 Compare October 19, 2026 14:44

@hweihwang hweihwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks John, I took it from here: beta.18, comparison and a lighter init script are in, together with #1385.

@hweihwang
hweihwang merged commit b602a82 into main Oct 19, 2026
36 checks passed
@hweihwang
hweihwang deleted the feature/migrate-new-viewer-api branch October 19, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants