Files
bedolaga-cabinet/src/lib/tiptap-video.ts
Fringg f788f1034c fix: isolated DOMPurify instance and correct video controls attribute
- Use DOMPurify(window) to avoid global hook pollution
- Fix controls default from boolean to empty string (HTML attribute semantics)
- Remove redundant non-null assertion on featured_image_url
2026-03-23 12:32:04 +03:00

31 lines
678 B
TypeScript

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: '' },
class: { default: null },
preload: { default: 'metadata' },
};
},
parseHTML() {
return [{ tag: 'video' }];
},
renderHTML({ HTMLAttributes }) {
return ['video', mergeAttributes(HTMLAttributes)];
},
});