Skip to content

Commit 6bd08b4

Browse files
docs: Fixes after fumadocs migration (#1888)
* Added comment * Added TODOs for docs * Fixed TODOs * Updated package lock * docs: Add docs for props without default values (#1895) * Added docs for props without default values * Small rewording
1 parent 6380cc6 commit 6bd08b4

File tree

36 files changed

+255
-276
lines changed

36 files changed

+255
-276
lines changed

docs/app/layout.config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ export const baseOptions: Partial<DocsLayoutProps & HomeLayoutProps> = {
9696
tabs: [
9797
{
9898
icon: (
99-
<FaBook className="border-fd-primary text-fd-primary bg-fd-primary/10 h-5 w-5 rounded-sm border p-0.5" />
99+
<FaBook className="border-fd-primary text-fd-primary bg-fd-primary/10 h-full w-full rounded-sm border p-2 md:p-0.5" />
100100
),
101101
title: "Documentation",
102102
description: "Learn how to use BlockNote",
103103
url: "/docs",
104104
},
105105
{
106106
icon: (
107-
<FaCode className="border-fd-primary text-fd-primary bg-fd-primary/10 h-5 w-5 rounded-sm border p-0.5" />
107+
<FaCode className="border-fd-primary text-fd-primary bg-fd-primary/10 h-full w-full rounded-sm border p-2 md:p-0.5" />
108108
),
109109
title: "Examples",
110110
description: "See BlockNote in action",

docs/app/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ body {
6464
padding-block: 1rem;
6565
}
6666

67-
.demo-contents a {
67+
.demo .bn-editor a {
6868
color: revert;
6969
text-decoration: revert;
7070
}

docs/components/CustomDocsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function CustomDocsLayout({
100100
<Sidebar
101101
{...sidebarProps}
102102
collapsible={sidebarCollapsible}
103-
className="md:sticky md:top-[calc(var(--fd-sidebar-top)+32px)] md:h-[calc(100vh-var(--fd-sidebar-top))]"
103+
className="md:sticky md:top-[calc(var(--fd-sidebar-top)+32px)] md:h-[calc(100vh-var(--fd-sidebar-top)-32px)]"
104104
>
105105
<HideIfEmpty>
106106
<SidebarHeader className="data-[empty=true]:hidden">

docs/content/docs/features/blocks/code-blocks.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ imageTitle: Code Blocks
88

99
Code blocks are a simple way to display formatted code with syntax highlighting.
1010

11-
<Example name="theming/code-block" />
12-
1311
Code blocks by default are a simple way to display code. But, BlockNote also supports more advanced features like:
1412

1513
- Syntax highlighting

docs/content/docs/features/blocks/embeds.mdx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,60 @@ imageTitle: Embeds
88

99
Embeds are a way to display content from external sources in your documents. BlockNote supports various embeds to help you structure and format your content effectively.
1010

11-
## Image
11+
## File
1212

13-
An image block is a block that displays an image.
13+
A file block is a block that displays a file.
1414

1515
**Type & Props**
1616

17-
```typescript
18-
type ImageBlock = {
17+
```ts
18+
type FileBlock = {
1919
id: string;
20-
type: "image";
20+
type: "file";
2121
props: {
22+
name: string = "";
2223
url: string = "";
2324
caption: string = "";
24-
previewWidth: number = 512;
2525
} & DefaultProps;
2626
content: undefined;
2727
children: Block[];
2828
};
2929
```
3030

31-
`url:` The image URL.
31+
`name:` The file name.
3232

33-
`caption:` The image caption.
33+
`url:` The file URL.
3434

35-
`previewWidth:` The image previewWidth in pixels.
35+
`caption:` The file caption.
3636

37-
## File
37+
## Image
3838

39-
A file block is a block that displays a file.
39+
An image block is a block that displays an image.
4040

4141
**Type & Props**
4242

43-
```ts
44-
type FileBlock = {
43+
```typescript
44+
type ImageBlock = {
4545
id: string;
46-
type: "file";
46+
type: "image";
4747
props: {
48-
name: string = "";
4948
url: string = "";
5049
caption: string = "";
50+
previewWidth: number = 512;
5151
} & DefaultProps;
5252
content: undefined;
5353
children: Block[];
5454
};
5555
```
5656

57+
`name:` The image name.
58+
59+
`url:` The image URL.
60+
61+
`caption:` The image caption.
62+
63+
`previewWidth:` The image previewWidth in pixels.
64+
5765
## Video
5866

5967
A video block is a block that displays a video.

docs/content/docs/features/blocks/list-types.mdx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ imageTitle: List Types
66

77
# List Item Blocks
88

9-
BlockNote supports several built-in list types:
10-
11-
- Numbered List
12-
- Bullet List
13-
- Check List
14-
- Toggle List
15-
16-
<Example name="basic/default-blocks" />
9+
List item blocks are used to create different types of lists in your documents. BlockNote supports various list item blocks to help you structure and format your content effectively.
1710

1811
### Bullet List Item
1912

@@ -41,12 +34,16 @@ A numbered list item is a list item that is numbered.
4134
type NumberedListItemBlock = {
4235
id: string;
4336
type: "numberedListItem";
44-
props: DefaultProps;
37+
props: DefaultProps & {
38+
start?: number;
39+
};
4540
content: InlineContent[];
4641
children: Block[];
4742
};
4843
```
4944

45+
`start:` The number of this list item. If not provided, it defaults to `1`, or is incremented from the previous item.
46+
5047
### Check List Item
5148

5249
A check list item is a list item that can be checked or unchecked.
@@ -65,6 +62,8 @@ type CheckListItemBlock = {
6562
};
6663
```
6764

65+
`checked:` Whether the list item is checked or not.
66+
6867
### Toggle List Item
6968

7069
A toggle list item is a list item that can show or hide it's children.

docs/content/docs/features/blocks/tables.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ imageTitle: Tables
88

99
Tables are a simple way to display data in a grid.
1010

11-
<Example name="ui-components/advanced-tables" />
12-
1311
Tables by default are a simple way to display data in a grid. But, BlockNote also supports more advanced features like:
1412

1513
- Split cells

docs/content/docs/features/blocks/typography.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ imageTitle: Typography
88

99
Typography blocks are fundamental elements for displaying text content in your documents. BlockNote supports various typography blocks to help you structure and format your content effectively.
1010

11-
<Example name="basic/default-blocks" />
12-
1311
## Paragraph
1412

1513
**Type & Props**

docs/content/docs/features/custom-schemas/custom-blocks.mdx

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,56 @@ type BlockConfig = {
5959
};
6060
```
6161

62-
**`type`**
62+
`type:` Defines the identifier of the custom block.
6363

64-
Defines the identifier of the custom block.
64+
`content:` `inline` if your custom block should support rich text content, `none` if not.
6565

66-
**`content`**
66+
<Callout type="info">
67+
_In the alert demo, we want the user to be able to type text in our alert, so
68+
we set `content` to `"inline"`._
69+
</Callout>
6770

68-
`inline` if your custom block should support rich text content, `none` if not.
69-
70-
_In the alert demo, we want the user to be able to type text in our alert, so we set it to `"inline"`._
71-
72-
**`propSchema`**
73-
74-
The `PropSchema` specifies the props that the block supports. Block props (properties) are data stored with your Block in the document, and can be used to customize its appearance or behavior.
71+
`propSchema:` The `PropSchema` specifies the props that the block supports. Block props (properties) are data stored with your Block in the document, and can be used to customize its appearance or behavior.
7572

7673
```typescript
7774
type PropSchema<PrimitiveType extends "boolean" | "number" | "string"> = Record<
7875
string,
79-
{
80-
default: PrimitiveType;
81-
values?: PrimitiveType[];
82-
}
76+
| {
77+
default: PrimitiveType;
78+
values?: PrimitiveType[];
79+
}
80+
| {
81+
default: undefined;
82+
type: PrimitiveType;
83+
values?: PrimitiveType[];
84+
}
8385
>;
8486
```
8587

86-
`[key: string]` is the name of the prop, and the value is an object with two fields:
88+
`[key: string]` is the name of the prop. If you want it to have a default value, it should be defined as an object with the following properties:
8789

88-
- `default`: Specifies the prop's default value
90+
- `default:` Specifies the prop's default value, from which `PrimitiveType` is inferred.
8991

90-
- `values` (optional): Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`
92+
- `values?:` Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`.
9193

92-
_In the alert demo, we add a `type` prop for the type of alert that we want (warning / error / info / success). We also want basic styling options, so we add text alignment and text color from the [Default Block Properties](/docs/features/blocks#default-block-properties)._
94+
If you do not want the prop to have a default value, you can define it as an object with the following properties:
9395

94-
**`isSelectable`**
96+
- `default:` Left `undefined`, as there is no default value.
9597

96-
Can be set to false in order to make the block non-selectable, both using the mouse and keyboard. This also helps with being able to select non-editable content within the block. Should only be set to false when `content` is `none` and defaults to true.
98+
- `type:` Specifies `PrimitiveType` that the prop can be set to, since the default value is `undefined` and cannot be inferred from.
9799

98-
**`hardBreakShortcut`**
100+
- `values?:` Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`.
99101

100-
Defines which keyboard shortcut should be used to insert a hard break into the block's inline content. Defaults to `"shift+enter"`.
102+
<Callout type="info">
103+
_In the alert demo, we add a `type` prop for the type of alert that we want
104+
(warning / error / info / success). We also want basic styling options, so we
105+
add text alignment and text color from the [Default Block
106+
Properties](/docs/features/blocks#default-block-properties)._
107+
</Callout>
108+
109+
`isSelectable?:` Can be set to false in order to make the block non-selectable, both using the mouse and keyboard. This also helps with being able to select non-editable content within the block. Should only be set to false when `content` is `none` and defaults to true.
110+
111+
`hardBreakShortcut?:` Defines which keyboard shortcut should be used to insert a hard break into the block's inline content. Defaults to `"shift+enter"`.
101112

102113
#### File Block Config
103114

@@ -121,27 +132,25 @@ type ReactCustomBlockImplementation = {
121132
};
122133
```
123134

124-
**`render`**
125-
126-
This is your React component which defines how your custom block should be rendered in the editor, and takes three React props:
127-
128-
`block:` The block that should be rendered. Its type and props will match the type and PropSchema defined in the Block Config.
129-
130-
`editor:` The BlockNote editor instance that the block is in.
135+
`render:` This is your React component which defines how your custom block should be rendered in the editor, and takes three React props:
131136

132-
`contentRef:` A React `ref` you can use to mark which element in your block is editable, this is only available if your block config contains `content: "inline"`.
137+
- `block:` The block that should be rendered. Its type and props will match the type and PropSchema defined in the Block Config.
133138

134-
**`toExternalHTML`** (optional)
139+
- `editor:` The BlockNote editor instance that the block is in.
135140

136-
This component is used whenever the block is being exported to HTML for use outside BlockNote, for example when copying it to the clipboard. If it's not defined, BlockNote will just use `render` for the HTML conversion.
141+
- `contentRef:` A React `ref` you can use to mark which element in your block is editable, this is only available if your block config contains `content: "inline"`.
137142

138-
_Note that your component passed to `toExternalHTML` is rendered and serialized in a separate React root, which means you can't use hooks that rely on React Contexts._
143+
`toExternalHTML?:` This component is used whenever the block is being exported to HTML for use outside BlockNote, for example when copying it to the clipboard. If it's not defined, BlockNote will just use `render` for the HTML conversion. Takes the same props as `render`.
139144

140-
**`parse`** (optional)
145+
<Callout type="info">
146+
_Note that your component passed to `toExternalHTML` is rendered and
147+
serialized in a separate React root, which means you can't use hooks that rely
148+
on React Contexts._
149+
</Callout>
141150

142-
The `parse` function defines how to parse HTML content into your block, for example when pasting contents from the clipboard. If the element should be parsed into your custom block, you return the props that the block should be given. Otherwise, return `undefined`.
151+
`parse?:` The `parse` function defines how to parse HTML content into your block, for example when pasting contents from the clipboard. If the element should be parsed into your custom block, you return the props that the block should be given. Otherwise, return `undefined`. Takes a single argument:
143152

144-
`element`: The HTML element that's being parsed.
153+
- `element`: The HTML element that's being parsed.
145154

146155
## Adding Custom Blocks to the Editor
147156

docs/content/docs/features/custom-schemas/custom-inline-content.mdx

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,52 @@ type CustomInlineContentConfig = {
5555
};
5656
```
5757

58-
**`type`**
58+
`type:` Defines the identifier of the custom inline content.
5959

60-
Defines the identifier of the custom inline content.
60+
`content:` `styled` if your custom inline content should contain [`StyledText`](/docs/foundations/document-structure#inline-content-objects), `none` if not.
6161

62-
**`content`**
62+
<Callout type="info">
63+
_In the mentions demo, we want each mention to be a single, non-editable
64+
element, so we set `content` to `"none"`._
65+
</Callout>
6366

64-
`styled` if your custom inline content should contain [`StyledText`](/docs/foundations/document-structure#inline-content-objects), `none` if not.
65-
66-
_In the mentions demo, we want each mention to be a single, non-editable element, so we set it to `"none"`._
67-
68-
**`propSchema`**
69-
70-
The `PropSchema` specifies the props that the inline content supports. Inline content props (properties) are data stored with your inline content in the document, and can be used to customize its appearance or behavior.
67+
`propSchema:` The `PropSchema` specifies the props that the inline content supports. Inline content props (properties) are data stored with your inline content in the document, and can be used to customize its appearance or behavior.
7168

7269
```typescript
7370
type PropSchema<PrimitiveType extends "boolean" | "number" | "string"> = Record<
7471
string,
75-
{
76-
default: PrimitiveType;
77-
values?: PrimitiveType[];
78-
}
72+
| {
73+
default: PrimitiveType;
74+
values?: PrimitiveType[];
75+
}
76+
| {
77+
default: undefined;
78+
type: PrimitiveType;
79+
values?: PrimitiveType[];
80+
}
7981
>;
8082
```
8183

82-
`[key: string]` is the name of the prop, and the value is an object with two fields:
84+
`[key: string]` is the name of the prop. If you want it to have a default value, it should be defined as an object with the following properties:
85+
86+
- `default:` Specifies the prop's default value, from which `PrimitiveType` is inferred.
8387

84-
- `default`: Specifies the prop's default value
88+
- `values?:` Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`.
8589

86-
- `values` (optional): Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`
90+
If you do not want the prop to have a default value, you can define it as an object with the following properties:
8791

88-
_In the mentions demo, we add a `user` prop for the user that's being mentioned._
92+
- `default:` Left `undefined`, as there is no default value.
93+
94+
- `type:` Specifies `PrimitiveType` that the prop can be set to, since the default value is `undefined` and cannot be inferred from.
95+
96+
- `values?:` Specifies an array of values that the prop can take, for example, to limit the value to a list of pre-defined strings. If `values` is not defined, BlockNote assumes the prop can be any value of `PrimitiveType`.
97+
98+
<Callout type="info">
99+
_In the mentions demo, we add a `user` prop for the user that's being
100+
mentioned._
101+
</Callout>
102+
103+
`draggable?:` Whether the inline content should be draggable.
89104

90105
### Inline Content Implementation (`ReactCustomInlineContentImplementation`)
91106

@@ -101,17 +116,18 @@ type ReactCustomInlineContentImplementation = {
101116
};
102117
```
103118

104-
**`render`**
105-
106-
This is your React component which defines how your custom inline content should be rendered, and takes three React props:
119+
`render:` This is your React component which defines how your custom inline content should be rendered, and takes three React props:
107120

108-
`inlineContent:` The inline content that should be rendered. Its type and props will match the type and PropSchema defined in the Inline Content Config.
121+
- `inlineContent:` The inline content that should be rendered. Its type and props will match the type and PropSchema defined in the Inline Content Config.
109122

110-
`contentRef:` A React `ref` you can use to mark which element in your inline content is editable, this is only available if your inline content config contains `content: "styled"`.
123+
- `contentRef:` A React `ref` you can use to mark which element in your inline content is editable, this is only available if your inline content config contains `content: "styled"`.
111124

112-
`draggable:` Specifies whether the inline content can be dragged within the editor. If set to `true`, the inline content will be draggable. Defaults to `false` if not specified. If this is true, you should add `data-drag-handle` to the DOM element that should function as the drag handle.
125+
- `draggable:` Specifies whether the inline content can be dragged within the editor. If set to `true`, the inline content will be draggable. Defaults to `false` if not specified. If this is true, you should add `data-drag-handle` to the DOM element that should function as the drag handle.
113126

114-
_Note that since inline content is, by definition, inline, your component should also return an HTML inline element._
127+
<Callout type="info">
128+
_Note that since inline content is, by definition, inline, your component
129+
should also return an HTML inline element._
130+
</Callout>
115131

116132
## Adding Custom Inline Content to the Editor
117133

0 commit comments

Comments
 (0)