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 `initialContent` editor option and basic docs
* Changed `initialContent` type to `PartialBlock`
* Changed `initialContent` type to `PartialBlock` in docs
* Added editor content saving/restoring demo
Copy file name to clipboardExpand all lines: packages/website/docs/docs/editor.md
+45-1
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,14 @@
1
1
# Customizing the Editor
2
2
3
+
While you can get started with BlockNote in minutes, it's likely that you'll want to customize its features and functionality to better suit your app.
4
+
5
+
## Editor Options
6
+
3
7
There are a number of options that you can pass to `useBlockNote()`, which you can use to customize the editor. You can find the full list of these below:
@@ -13,6 +18,8 @@ export type BlockNoteEditorOptions = {
13
18
};
14
19
```
15
20
21
+
`initialContent:` The content that should be in the editor when it's created, represented as an array of [partial block objects](/docs/manipulating-blocks#partial-blocks).
22
+
16
23
`editorDOMAttributes:` An object containing attributes that should be added to the editor's HTML element.
17
24
18
25
`onEditorReady:` A callback function that runs when the editor is ready to be used.
@@ -23,4 +30,41 @@ export type BlockNoteEditorOptions = {
23
30
24
31
`slashMenuItems:` The commands that are listed in the editor's [Slash Menu](/docs/slash-menu). If this option isn't defined, a default list of commands is loaded.
25
32
26
-
`uiFactories:` Factories used to create a custom UI for BlockNote, which you can find out more about in [Creating Your Own UI Elements](/docs/vanilla-js#creating-your-own-ui-elements).
33
+
`uiFactories:` Factories used to create a custom UI for BlockNote, which you can find out more about in [Creating Your Own UI Elements](/docs/vanilla-js#creating-your-own-ui-elements).
34
+
35
+
## Demo: Saving & Restoring Editor Contents
36
+
37
+
By default, BlockNote doesn't preserve the editor contents when your app is reopened or refreshed. However, using the editor options, you can change this by using the editor options.
38
+
39
+
In the example below, we use the `onEditorContentChange` option to save the editor contents in local storage whenever they change, then pass them to `initialContent` whenever the page is reloaded.
0 commit comments