You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: docs/content/docs/features/blocks/embeds.mdx
+23-15Lines changed: 23 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,52 +8,60 @@ imageTitle: Embeds
8
8
9
9
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.
Copy file name to clipboardExpand all lines: docs/content/docs/features/blocks/list-types.mdx
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,7 @@ imageTitle: List Types
6
6
7
7
# List Item Blocks
8
8
9
-
BlockNote supports several built-in list types:
10
-
11
-
- Numbered List
12
-
- Bullet List
13
-
- Check List
14
-
- Toggle List
15
-
16
-
<Examplename="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.
17
10
18
11
### Bullet List Item
19
12
@@ -41,12 +34,16 @@ A numbered list item is a list item that is numbered.
41
34
typeNumberedListItemBlock= {
42
35
id:string;
43
36
type:"numberedListItem";
44
-
props:DefaultProps;
37
+
props:DefaultProps& {
38
+
start?:number;
39
+
};
45
40
content:InlineContent[];
46
41
children:Block[];
47
42
};
48
43
```
49
44
45
+
`start:` The number of this list item. If not provided, it defaults to `1`, or is incremented from the previous item.
46
+
50
47
### Check List Item
51
48
52
49
A check list item is a list item that can be checked or unchecked.
@@ -65,6 +62,8 @@ type CheckListItemBlock = {
65
62
};
66
63
```
67
64
65
+
`checked:` Whether the list item is checked or not.
66
+
68
67
### Toggle List Item
69
68
70
69
A toggle list item is a list item that can show or hide it's children.
Copy file name to clipboardExpand all lines: docs/content/docs/features/blocks/typography.mdx
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,6 @@ imageTitle: Typography
8
8
9
9
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.
Copy file name to clipboardExpand all lines: docs/content/docs/features/custom-schemas/custom-blocks.mdx
+45-36Lines changed: 45 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,45 +59,56 @@ type BlockConfig = {
59
59
};
60
60
```
61
61
62
-
**`type`**
62
+
`type:` Defines the identifier of the custom block.
63
63
64
-
Defines the identifier of the custom block.
64
+
`content:``inline` if your custom block should support rich text content, `none` if not.
65
65
66
-
**`content`**
66
+
<Callouttype="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>
67
70
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.
`[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:
87
89
88
-
-`default`: Specifies the prop's default value
90
+
-`default:` Specifies the prop's default value, from which `PrimitiveType` is inferred.
89
91
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`.
91
93
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:
93
95
94
-
**`isSelectable`**
96
+
-`default:` Left `undefined`, as there is no default value.
95
97
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.
97
99
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`.
99
101
100
-
Defines which keyboard shortcut should be used to insert a hard break into the block's inline content. Defaults to `"shift+enter"`.
102
+
<Callouttype="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
`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"`.
101
112
102
113
#### File Block Config
103
114
@@ -121,27 +132,25 @@ type ReactCustomBlockImplementation = {
121
132
};
122
133
```
123
134
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:
131
136
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.
133
138
134
-
**`toExternalHTML`** (optional)
139
+
-`editor:` The BlockNote editor instance that the block is in.
135
140
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"`.
137
142
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`.
139
144
140
-
**`parse`** (optional)
145
+
<Callouttype="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>
141
150
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:
Copy file name to clipboardExpand all lines: docs/content/docs/features/custom-schemas/custom-inline-content.mdx
+41-25Lines changed: 41 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,37 +55,52 @@ type CustomInlineContentConfig = {
55
55
};
56
56
```
57
57
58
-
**`type`**
58
+
`type:` Defines the identifier of the custom inline content.
59
59
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.
61
61
62
-
**`content`**
62
+
<Callouttype="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>
63
66
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.
`[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.
83
87
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`.
85
89
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:
87
91
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
+
<Callouttype="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.
@@ -101,17 +116,18 @@ type ReactCustomInlineContentImplementation = {
101
116
};
102
117
```
103
118
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:
107
120
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.
109
122
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"`.
111
124
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.
113
126
114
-
_Note that since inline content is, by definition, inline, your component should also return an HTML inline element._
127
+
<Callouttype="info">
128
+
_Note that since inline content is, by definition, inline, your component
0 commit comments