Skip to content

Conversation

@dedmen
Copy link
Contributor

@dedmen dedmen commented Jan 11, 2026

File preview supported images and pdf, but not video. HTML5

  • Video preview on cdn/[id]/preview page
  • Video preview on cdn/[id] page (the file edit page)
  • Video preview inside Markdown preview

Problem:
Markdown video preview has multiple issues.

  1. When directly opening the full document, not in edit view, it doesn't show. It renders an empty

My MarkdownIt handling is a total hack.
I tried to add https://www.npmjs.com/package/markdown-it-html5-media
Installed via npm or/and bun, its in bun.lock and package json files. But still
Failed to resolve import "markdown-it-html5-media" from "app/helpers/markdown/index.ts".
I don't know what I'm doing wrong, and I don't know how to fix it.
Maybe because that module has no index.js??

I reduced the code of the markdown plugin, and put it directly into index.ts. Which mostly works.
And tbh I also prefer that over adding another NPM package. The code in index.ts is just quickly hacked together, I can optimize that down quite a bit more, we don't need to copy their code (which is probably licensing issue) and get it smaller. Probably also move it out into separate file.
But need to solve why it only works in Markdown Preview, and not in final document view?

firefox_2026-01-11_01-38-31

As a note, personally I would also like to have https://github.com/CenterForOpenScience/markdown-it-video
I often have YouTube videos in my notes, having them embed would be great. But that is a separate feature from what I'm doing in this PR.

// @ts-expect-error no types provided
import underline from 'markdown-it-underline';
import highlight from 'markdown-it-highlightjs';
//import html5Media from 'markdown-it-html5-media'; // Doesn't work, always not found
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not work, always not finding the file, even though its there in node_modules folder.

<h4>Preview</h4>
<div class="preview">
<img v-if="(resource.metadata?.filetype as string)?.startsWith('image/')" :src="resourceURL(resource)" alt="Preview" />
<img v-if="isImageFile(mimeType)" :src="resourceURL(resource)" alt="Preview" />
Copy link
Contributor Author

@dedmen dedmen Jan 11, 2026

Choose a reason for hiding this comment

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

Unified with how we do it in preview.vue, we already have a helper function to check if its an image file
Note this is also missing preview for PDF files, even though on the preview page we support it.

Its also a bit weird that we have basically the same preview functionality twice?
I don't know why we have a preview on the property edit page, can probably get rid of it?

Copy link
Owner

@Smaug6739 Smaug6739 left a comment

Choose a reason for hiding this comment

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

We should remove markdown-it-html5-media from dependencies if it's not used

@dedmen
Copy link
Contributor Author

dedmen commented Jan 11, 2026

I would once its fully working.
I don't know why the embedding doesn't work when viewing the document directly.

Either my code needs to be fixed, or the import for that package needs to be done correctly.
Neither of those I know how to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants