Skip to content
Merged
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
9 changes: 6 additions & 3 deletions examples/01-basic/02-block-objects/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { useState } from "react";
import { useEffect, useState } from "react";

import "./styles.css";

Expand Down Expand Up @@ -32,6 +32,9 @@ export default function App() {
],
});

// Sets the initial document JSON
useEffect(() => setBlocks(editor.document), []);

// Renders the editor instance and its document JSON.
return (
<div className={"wrapper"}>
Expand All @@ -40,15 +43,15 @@ export default function App() {
<BlockNoteView
editor={editor}
onChange={() => {
// Saves the document JSON to state.
// Sets the document JSON whenever the editor content changes.
setBlocks(editor.document);
}}
/>
</div>
<div>Document JSON:</div>
<div className={"item bordered"}>
<pre>
<code>{JSON.stringify(editor.document, null, 2)}</code>
<code>{JSON.stringify(blocks, null, 2)}</code>
</pre>
</div>
</div>
Expand Down
Loading