Every extension
youtube
A YouTube video, embedded.
Only the id is stored. The frame's address is built from it here, on the privacy-preserving domain, so a document can never carry a frame pointing anywhere else — an embed whose `src` is trusted from JSON is an `<iframe>` to any page an attacker likes.
Adding it
import { createEditor, document, paragraph, text, youtube } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, youtube],
element: document.querySelector('#editor'),
})
There is no separate package · youtube is already in @matrajs/core, and an extension you do not import is not in your bundle. document, paragraph and text are the floor every document needs.
Commands
-
editor.commands.insertYoutube()
Attributes
-
src -
width· defaults to640 -
height· defaults to360 -
start· defaults to0
HTML
-
Parses
div[data-youtube-video]iframe[src] -
Renders
div
Styles
This one needs a stylesheet to look right, and ships the minimum as a string rather than a file · nothing is loaded unless you load it.
import { youtubeCSS } from '@matrajs/core'
const style = document.createElement('style')
style.textContent = youtubeCSS
document.head.append(style)