File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
examples/01-basic/02-block-objects/src Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import "@blocknote/core/fonts/inter.css";
3
3
import { BlockNoteView } from "@blocknote/mantine" ;
4
4
import "@blocknote/mantine/style.css" ;
5
5
import { useCreateBlockNote } from "@blocknote/react" ;
6
- import { useState } from "react" ;
6
+ import { useEffect , useState } from "react" ;
7
7
8
8
import "./styles.css" ;
9
9
@@ -32,6 +32,9 @@ export default function App() {
32
32
] ,
33
33
} ) ;
34
34
35
+ // Sets the initial document JSON
36
+ useEffect ( ( ) => setBlocks ( editor . document ) , [ ] ) ;
37
+
35
38
// Renders the editor instance and its document JSON.
36
39
return (
37
40
< div className = { "wrapper" } >
@@ -40,15 +43,15 @@ export default function App() {
40
43
< BlockNoteView
41
44
editor = { editor }
42
45
onChange = { ( ) => {
43
- // Saves the document JSON to state .
46
+ // Sets the document JSON whenever the editor content changes .
44
47
setBlocks ( editor . document ) ;
45
48
} }
46
49
/>
47
50
</ div >
48
51
< div > Document JSON:</ div >
49
52
< div className = { "item bordered" } >
50
53
< pre >
51
- < code > { JSON . stringify ( editor . document , null , 2 ) } </ code >
54
+ < code > { JSON . stringify ( blocks , null , 2 ) } </ code >
52
55
</ pre >
53
56
</ div >
54
57
</ div >
You can’t perform that action at this time.
0 commit comments