Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions docs/content/docs/features/blocks/embeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type ImageBlock = {
name: string;
url: string;
caption: string;
showPreview: boolean;
previewWidth: number | undefined;
};
content: undefined;
Expand All @@ -72,14 +71,12 @@ type ImageBlock = {

`textAlignment:` The alignment of the image. Defaults to `"left"`.

`name:` The image file name. Defaults to `""`.
`name:` The image alternative text. Defaults to `""`, in which case the editor attempts to get the file name from the URL as a fallback. This fallback is not stored in `name` or included in external HTML exports.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback is not stored in name or included in external HTML exports

obsolete


`url:` The image URL. Defaults to `""`.

`caption:` The image caption. Defaults to `""`.

`showPreview:` Whether to show the image preview or a link. Defaults to `true`.

`previewWidth:` The image preview width in pixels. Defaults to `undefined` (no fixed width).

## Video
Expand All @@ -106,7 +103,6 @@ type VideoBlock = {
name: string;
url: string;
caption: string;
showPreview: boolean;
previewWidth: number | undefined;
};
content: undefined;
Expand All @@ -124,8 +120,6 @@ type VideoBlock = {

`caption:` The video caption. Defaults to `""`.

`showPreview:` Whether to show the video player or a link. Defaults to `true`.

`previewWidth:` The video preview width in pixels. Defaults to `undefined` (no fixed width).

## Audio
Expand All @@ -151,7 +145,6 @@ type AudioBlock = {
name: string;
url: string;
caption: string;
showPreview: boolean;
};
content: undefined;
children: Block[];
Expand All @@ -165,5 +158,3 @@ type AudioBlock = {
`url:` The audio URL. Defaults to `""`.

`caption:` The audio caption. Defaults to `""`.

`showPreview:` Whether to show the audio player or a link. Defaults to `true`.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ To extend the built-in file block behavior with a new file type or preview, use

1. Set `content: "none"` and include the `name`, `url`, and `caption` props, each with `default: ""`. You can reuse these from `createFileBlockConfig().propSchema`, exported by `@blocknote/core`.
2. Set `meta.fileBlockAccept` in the block implementation, for example to `["application/pdf"]` for PDF files.
3. Render `FileBlockWrapper` from `@blocknote/react`, passing it your render props and your preview as children. It provides the add-file button, upload loading state, and caption, and displays the file name and icon when no preview is shown. Include the file name in your preview children if you also want it visible alongside the preview. Use `ResizableFileBlockWrapper` instead for a resizable preview, and add a numeric `previewWidth` prop. Add a boolean `showPreview` prop with `default: true` to let users switch between the preview and the file name and icon.
3. Render `FileBlockWrapper` from `@blocknote/react`, passing it your render props and your preview as children. It provides the add-file button, upload loading state, and caption. Include the file name in your preview children if you also want it visible alongside the preview. Use `ResizableFileBlockWrapper` instead for a resizable preview, and add a numeric `previewWidth` prop.
4. Add the block spec to your [schema](/docs/features/custom-schemas#creating-your-own-schema), after any other file blocks that accept the same files: the last matching block spec in schema order wins for dropped or pasted files. Configure [`uploadFile`](/docs/react/components/image-toolbar#file-upload) to enable uploads. Keep `defaultBlockSpecs.file` in the schema as the fallback for unmatched files. To let users insert an empty block, add a [Slash Menu item](/docs/react/components/suggestion-menus#changing-slash-menu-items).

The wrappers' current TypeScript types target the built-in `"file"` block, so custom block render props are not directly assignable. The PDF example below uses type assertions at the wrapper boundary to work around this limitation.
Expand Down
3 changes: 0 additions & 3 deletions examples/06-custom-schema/04-pdf-file-block/src/PDF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export const PDF = createReactBlockSpec(
caption: {
default: "" as const,
},
showPreview: {
default: true,
},
previewWidth: {
default: undefined,
type: "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ exports[`Test insertBlocks > Insert multiple blocks after 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1014,7 +1013,6 @@ exports[`Test insertBlocks > Insert multiple blocks before 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1609,7 +1607,6 @@ exports[`Test insertBlocks > Insert single basic block after 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -2216,7 +2213,6 @@ exports[`Test insertBlocks > Insert single basic block before (without type) 2`]
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -2811,7 +2807,6 @@ exports[`Test insertBlocks > Insert single basic block before 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -3522,7 +3517,6 @@ exports[`Test insertBlocks > Insert single complex block after 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -4233,7 +4227,6 @@ exports[`Test insertBlocks > Insert single complex block before 2`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ exports[`Test mergeBlocks > Basic 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -766,7 +765,6 @@ exports[`Test mergeBlocks > Blocks have different types 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1317,7 +1315,6 @@ exports[`Test mergeBlocks > First block has children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1867,7 +1864,6 @@ exports[`Test mergeBlocks > Second block has children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -2435,7 +2431,6 @@ exports[`Test mergeBlocks > Second block is empty 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ exports[`Test moveBlocksDown > Basic 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -800,7 +799,6 @@ exports[`Test moveBlocksDown > Explicit block argument moves the given block 1`]
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1367,7 +1365,6 @@ exports[`Test moveBlocksDown > Explicit block argument with nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -1935,7 +1932,6 @@ exports[`Test moveBlocksDown > Into children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -2503,7 +2499,6 @@ exports[`Test moveBlocksDown > Last block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -3071,7 +3066,6 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -3639,7 +3633,6 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`]
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -4207,7 +4200,6 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -4785,7 +4777,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -5342,7 +5333,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -5909,7 +5899,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -6477,7 +6466,6 @@ exports[`Test moveBlocksDown > Out of children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -7044,7 +7032,6 @@ exports[`Test moveBlocksUp > Basic 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -7612,7 +7599,6 @@ exports[`Test moveBlocksUp > Explicit block argument moves the given block 1`] =
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -8180,7 +8166,6 @@ exports[`Test moveBlocksUp > Explicit block argument with nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -8747,7 +8732,6 @@ exports[`Test moveBlocksUp > First block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -9315,7 +9299,6 @@ exports[`Test moveBlocksUp > Into children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -9883,7 +9866,6 @@ exports[`Test moveBlocksUp > Multiple blocks 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -10451,7 +10433,6 @@ exports[`Test moveBlocksUp > Multiple blocks ending in block with children 1`] =
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -11019,7 +11000,6 @@ exports[`Test moveBlocksUp > Multiple blocks ending in nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -11569,7 +11549,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting and ending in nested block
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -12154,7 +12133,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting in block with children 1`]
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -12721,7 +12699,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting in nested block 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down Expand Up @@ -13289,7 +13266,6 @@ exports[`Test moveBlocksUp > Out of children 1`] = `
"backgroundColor": "default",
"caption": "",
"name": "",
"showPreview": true,
"textAlignment": "left",
"url": "https://via.placeholder.com/150",
},
Expand Down
Loading
Loading