fix: video not rendering — add TipTap Video extension, allow HTTP src

TipTap didn't recognize <video> tags without a custom node extension,
serializing them as escaped text. Also revert video src to allow HTTP
since request.base_url returns http:// behind reverse proxy.
This commit is contained in:
Fringg
2026-03-23 12:11:51 +03:00
parent 74080004e8
commit 25f3602aea
3 changed files with 39 additions and 6 deletions

30
src/lib/tiptap-video.ts Normal file
View File

@@ -0,0 +1,30 @@
import { Node, mergeAttributes } from '@tiptap/core';
/**
* TipTap extension for inline <video> elements.
*
* Without this extension, TipTap does not recognize <video> tags and
* serializes them as escaped text when calling editor.getHTML().
*/
export const VideoExtension = Node.create({
name: 'video',
group: 'block',
atom: true,
addAttributes() {
return {
src: { default: null },
controls: { default: true },
class: { default: null },
preload: { default: 'metadata' },
};
},
parseHTML() {
return [{ tag: 'video' }];
},
renderHTML({ HTMLAttributes }) {
return ['video', mergeAttributes(HTMLAttributes, { controls: '' })];
},
});