Embed
A media widget for images, video, audio, or files — local upload or a remote URL. A pure widget block: no runs at all, contentIds is always empty.
{
"id": "e1",
"type": "embed",
"contentIds": [],
"props": {
"kind": "image",
"src": "https://example.com/photo.jpg",
"name": "photo.jpg",
"mimeType": "image/jpeg",
"align": "center",
"width": 100
}
}| Prop | Type | Notes |
|---|---|---|
kind | 'image' | 'video' | 'audio' | 'file' | Default 'file'. |
src | string | An external URL, or a data: URL for a locally-uploaded file. |
name | string | Original filename or the URL — used as alt text / download name / link text. |
mimeType | string | Set on local uploads. |
align | 'left' | 'center' | 'right' | Positions the widget within the line. |
width | number (20–100) | Percentage width — image/video only, adjustable via a resize handle. |
Without an uploadFile option (see below), a locally-uploaded file is stored as a data: URL directly in the document — fine for a demo or a small note, but it bloats the document (and any live-collaboration broadcast of it) for large files. This is still the zero-config default and it's what you get from all three entry points — the slash-command dropzone, dragging a file onto the block, and (since 0.3.3) pasting a file straight from the OS clipboard — since all three go through the same resolution path.
Uploading somewhere real
Added in 0.3.3. Pass uploadFile to EditorProvider/useEditor() to send a picked/dropped/pasted file to your own server, S3, or any other storage instead of inlining it — the block shows an "Uploading…" state while your promise is pending, and a dismissible error (nothing written to the document) if it rejects.
import { useEditor, NoteloomEditor } from 'noteloom';
function Editor() {
const editor = useEditor({
uploadFile: async (file, { kind }) => {
// kind is 'image' | 'video' | 'audio' | 'file' -- whatever the embed block resolved
const body = new FormData();
body.append('file', file);
const res = await fetch('/api/upload', { method: 'POST', body });
const { url } = await res.json();
return { src: url, name: file.name, mimeType: file.type };
},
});
return <NoteloomEditor editor={editor} />;
}Small/medium/large handling is entirely your uploadFile's own business off file.size — nothing is hardcoded in the package, since what counts as "large" varies per app. A new useFileUpload() hook exposes the same { uploadFile, maxFileSize } for building your own upload UI outside EmbedBlock entirely.
uploadFile configured, the new maxFileSize option (bytes) caps the data: URL fallback — an oversized file is rejected with a clear error instead of silently bloating the document. It has no effect once uploadFile is set, since your own function/backend owns that decision at that point.Slash command
Embed (or Image/Video/File) — keywords: image, video, audio, file, embed, upload.
Styling
.be-embed (wrapper), .be-embed-image/.be-embed-video/.be-embed-frame/.be-embed-file-link per kind, .be-embed-dropzone for the empty/upload state, and a .be-embed-toolbar for align/resize controls.
Using it in your editor
useEditor() registers every built-in block by default, embed included. To register only the blocks you use instead:
import { useEditor, NoteloomEditor, paragraphBlockType, embedBlockType } from 'noteloom';
function Editor() {
const editor = useEditor({
extensions: [paragraphBlockType, embedBlockType],
});
return <NoteloomEditor editor={editor} />;
}See Picking only the blocks you want for combining this with other types.