@@ -2,6 +2,7 @@ import "@blocknote/core/fonts/inter.css";
22import "@blocknote/mantine/style.css" ;
33import { BlockNoteView } from "@blocknote/mantine" ;
44import { useCreateBlockNote } from "@blocknote/react" ;
5+ import { withCollaboration } from "@blocknote/core/yjs" ;
56
67import YPartyKitProvider from "y-partykit/provider" ;
78import * as Y from "yjs" ;
@@ -38,21 +39,23 @@ const ghostContent =
3839export default function App ( ) {
3940 const [ numGhostWriters , setNumGhostWriters ] = useState ( 1 ) ;
4041 const [ isPaused , setIsPaused ] = useState ( false ) ;
41- const editor = useCreateBlockNote ( {
42- collaboration : {
43- // The Yjs Provider responsible for transporting updates:
44- provider,
45- // Where to store BlockNote data in the Y.Doc:
46- fragment : doc . getXmlFragment ( "document-store" ) ,
47- // Information (name and color) for this user:
48- user : {
49- name : isGhostWriting
50- ? `Ghost Writer #${ ghostWriterIndex } `
51- : "My Username" ,
52- color : isGhostWriting ? "#CCCCCC" : "#00ff00" ,
42+ const editor = useCreateBlockNote (
43+ withCollaboration ( {
44+ collaboration : {
45+ // The Yjs Provider responsible for transporting updates:
46+ provider,
47+ // Where to store BlockNote data in the Y.Doc:
48+ fragment : doc . getXmlFragment ( "document-store" ) ,
49+ // Information (name and color) for this user:
50+ user : {
51+ name : isGhostWriting
52+ ? `Ghost Writer #${ ghostWriterIndex } `
53+ : "My Username" ,
54+ color : isGhostWriting ? "#CCCCCC" : "#00ff00" ,
55+ } ,
5356 } ,
54- } ,
55- } ) ;
57+ } ) ,
58+ ) ;
5659
5760 useEffect ( ( ) => {
5861 if ( ! isGhostWriting || isPaused ) {
@@ -101,7 +104,8 @@ export default function App() {
101104 `${ window . location . origin } ${ window . location . pathname } ?room=${ roomName } &index=-1` ,
102105 "_blank" ,
103106 ) ;
104- } } >
107+ } }
108+ >
105109 Ghost Writer in a new window
106110 </ button >
107111 </ >
0 commit comments