Every extension
embed
Anything with an embed page, in a frame.
The frame is the dangerous part of a document, so the allowlist is not optional: a `src` is checked when a command sets it, when HTML is parsed, and again when the node renders — because a document loaded from JSON skipped the first two, and that is how every real application loads documents. A frame that fails the check at render time is withheld and the wrapper stays, so the document keeps its data and fetches nothing.
Every frame is sandboxed. Scripts and same-origin are allowed because most embed pages stop working without them; navigating the top page is not.
Adding it
import { createEditor, document, paragraph, text, embed } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, embed({ … })],
element: document.querySelector('#editor'),
})
There is no separate package · embed 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.
Options
| Field | Type | |
|---|---|---|
allow | EmbedAllow | Left off, a short list of well-known players and tools applies. |
Commands
-
editor.commands.insertEmbed() -
editor.commands.setEmbedAspect()
Attributes
-
src -
title -
aspect· defaults to"16/9"
HTML
-
Parses
div[data-embed]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 { embedCSS } from '@matrajs/core'
const style = document.createElement('style')
style.textContent = embedCSS
document.head.append(style)