Repository navigation
feat(viewer): show a file anywhere with <nc-viewer-file> - #97
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #97 +/- ##
==========================================
- Coverage 92.71% 91.99% -0.73%
==========================================
Files 51 54 +3
Lines 4270 4572 +302
Branches 951 989 +38
==========================================
+ Hits 3959 4206 +247
- Misses 288 342 +54
- Partials 23 24 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ced4471 to
c007bac
Compare
5734f60 to
c8d32ec
Compare
c8d32ec to
1a89b0a
Compare
| /** | ||
| * Whether the file is shown inline, outside the viewer, as the preview | ||
| * of a link to it (see `getViewer().elementFor()`). Handlers should then | ||
| * show it without taking over: no autoplay, read-only where editing is |
There was a problem hiding this comment.
Current reference widgets allow switching to write mode and inline editing for some file types. At least Text (for Markdown/plaintext) and Richdocuments (for office documents) support it as far as I know. I'm not sure though whether we want to keep it as it often is very bad UX. Personally I'd prefer a button to open the previewed file full-screen in a overlay modal, read-write where supported.
There was a problem hiding this comment.
I reworded it so embedded is only a hint and Richdocuments can still decide for itself. For the files widget I'd do what you suggest: read-only inline, plus a button to open it in the viewer.
7401f98 to
bc938cc
Compare
c983dbd to
6a30ebf
Compare
The preview of a file link (the files reference widget, in Talk, Text and the like) used to render the viewer handler's component inline, found through OCA.Viewer.availableHandlers. Handlers are custom elements now, and the registry is not something a page should dig through, so getViewer().elementFor(file) names the element of the handler that would open the file, defined and ready to render, without loading the viewer. `embedded` on ViewerProps tells the handler it is shown inline, which the old widget said with `isEmbedded` and `active`. A hint not to take over the page: videos and sounds wait to be played, and editing is better left to the viewer. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
elementFor() named the elements of the images, video, audio and sheet music handlers before anything defined them: only the viewer did, as it mounted. They are defined from onInit now, like any handler's. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
It had a width of its own, wider than a file shown outside the viewer. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
6a30ebf to
50fc451
Compare
Give it a file and a size: it shows the file with the handler the viewer would use, fitted to its box, its blurhash while it loads, and a strip naming it with a menu to open it in the viewer or download it. A video waits behind its poster until played. When nothing can show the file, or it fails to, it says so and offers the download, or shows what the page put inside it. Its view is only fetched once one is on the page. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
50fc451 to
52ac863
Compare
Read-only to start and not taking over the page, with any switch to editing inline left to the handler, as Text has. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
It is defined on every page, and the default handlers now define their elements when first needed: 0.8 kB gzipped. Its view stays lazy, and the check now says so. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
Give
<nc-viewer-file>a file and a size, and it shows the file the way the viewer would, right where it's mentioned, like a file link previewed in Talk or Text. Before, the Files reference widget could only fall back to a static card.On hover, a strip names the file with a menu to open it in the viewer or download it. A video waits behind its poster until played. When nothing can show the file, it says so and offers the download, or shows what the page put inside the element.
getViewer().elementFor(file)stays available for rendering a handler's element yourself.Also fixes the default handlers' elements never being defined outside the viewer, and the audio player overflowing a small box. Not tried in Talk or the Files widget yet.
👾 This pull request was assisted by Claude Code, commits carry an
Assisted-bytrailer.