|
1 |
| -import "@blocknote/core/fonts/inter.css"; |
2 |
| -import { BlockNoteView } from "@blocknote/mantine"; |
3 |
| -import "@blocknote/mantine/style.css"; |
4 |
| -import { useCreateBlockNote } from "@blocknote/react"; |
5 |
| -import { createClient } from "@liveblocks/client"; |
6 |
| -import LiveblocksProvider from "@liveblocks/yjs"; |
7 |
| -import * as Y from "yjs"; |
| 1 | +// See https://liveblocks.io/docs/get-started/react-blocknote to see how this |
| 2 | +// example was created, and an explanation for all the code. |
| 3 | +import { |
| 4 | + ClientSideSuspense, |
| 5 | + LiveblocksProvider, |
| 6 | + RoomProvider, |
| 7 | +} from "@liveblocks/react/suspense"; |
| 8 | +import "@liveblocks/react-ui/styles.css"; |
| 9 | +import "@liveblocks/react-ui/styles/dark/media-query.css"; |
| 10 | +import "@liveblocks/react-tiptap/styles.css"; |
8 | 11 |
|
9 |
| -// Sets up Liveblocks client. |
10 |
| -const client = createClient({ |
11 |
| - publicApiKey: |
12 |
| - "pk_dev_lJAS4XHx3l1e0x_Gh9VMtrvo8PEB1vrNarC2YRtAOp4t6i9_QAcSX2U953GS6v7B", |
13 |
| -}); |
14 |
| -// Enters a multiplayer room. |
15 |
| -// Use a unique name as a "room" for your application. |
16 |
| -const { room } = client.enterRoom("your-project-name", { |
17 |
| - initialPresence: {}, |
18 |
| -}); |
19 |
| - |
20 |
| -// Sets up Yjs document and Liveblocks Yjs provider. |
21 |
| -const doc = new Y.Doc(); |
22 |
| -const provider = new LiveblocksProvider(room, doc); |
| 12 | +import { Editor } from "./Editor.js"; |
| 13 | +import "./globals.css"; |
| 14 | +import "./styles.css"; |
23 | 15 |
|
24 | 16 | export default function App() {
|
25 |
| - const editor = useCreateBlockNote({ |
26 |
| - collaboration: { |
27 |
| - // The Yjs Provider responsible for transporting updates: |
28 |
| - provider, |
29 |
| - // Where to store BlockNote data in the Y.Doc: |
30 |
| - fragment: doc.getXmlFragment("document-store"), |
31 |
| - // Information (name and color) for this user: |
32 |
| - user: { |
33 |
| - name: "My Username", |
34 |
| - color: "#ff0000", |
35 |
| - }, |
36 |
| - }, |
37 |
| - }); |
38 |
| - |
39 |
| - // Renders the editor instance. |
40 |
| - return <BlockNoteView editor={editor} />; |
| 17 | + return ( |
| 18 | + <LiveblocksProvider |
| 19 | + publicApiKey={ |
| 20 | + "pk_prod_6iVYNrHvG98GvWioAutXrhTkpG0iQLrzUK3nfWT4_VKWl6NIrlt112YD29to9gQH" |
| 21 | + }> |
| 22 | + <RoomProvider id="my-room"> |
| 23 | + <ClientSideSuspense fallback={<div>Loading…</div>}> |
| 24 | + <Editor /> |
| 25 | + </ClientSideSuspense> |
| 26 | + </RoomProvider> |
| 27 | + </LiveblocksProvider> |
| 28 | + ); |
41 | 29 | }
|
0 commit comments