diff --git a/.changeset/2026-07-29-static-renderer-audio-video.md b/.changeset/2026-07-29-static-renderer-audio-video.md new file mode 100644 index 0000000000..e93e2c629a --- /dev/null +++ b/.changeset/2026-07-29-static-renderer-audio-video.md @@ -0,0 +1,5 @@ +--- +'@tiptap/static-renderer': patch +--- + +Render `audio` and `video` elements with a closing tag instead of as self-closing, so browsers no longer nest following content inside them. diff --git a/packages/static-renderer/__tests__/pm-self-closing-tags.spec.ts b/packages/static-renderer/__tests__/pm-self-closing-tags.spec.ts new file mode 100644 index 0000000000..4f27effb87 --- /dev/null +++ b/packages/static-renderer/__tests__/pm-self-closing-tags.spec.ts @@ -0,0 +1,76 @@ +import { Node } from '@tiptap/core' +import Document from '@tiptap/extension-document' +import Paragraph from '@tiptap/extension-paragraph' +import Text from '@tiptap/extension-text' +import { renderToHTMLString } from '@tiptap/static-renderer/pm/html-string' +import { describe, expect, it } from 'vitest' + +const Audio = Node.create({ + name: 'audio', + group: 'block', + atom: true, + addAttributes() { + return { src: { default: null } } + }, + renderHTML({ HTMLAttributes }) { + return ['audio', HTMLAttributes] + }, +}) + +const Video = Node.create({ + name: 'video', + group: 'block', + atom: true, + addAttributes() { + return { src: { default: null } } + }, + renderHTML({ HTMLAttributes }) { + return ['video', HTMLAttributes] + }, +}) + +const extensions = [Document, Paragraph, Text, Audio, Video] + +describe('static renderer: non-void elements get a closing tag', () => { + it('renders