@@ -76,10 +76,37 @@ const insertChatBlockItem = (editor: BlockNoteEditor<any, any, any>) => ({
7676 subtext : "Start a collaborative chat discussion" ,
7777} ) ;
7878
79- // Get all slash menu items including chat block
79+ // Custom slash menu item for Mermaid block
80+ const insertMermaidBlockItem = ( editor : BlockNoteEditor < any , any , any > ) => ( {
81+ title : "Mermaid Diagram" ,
82+ onItemClick : ( ) => {
83+ const currentBlock = editor . getTextCursorPosition ( ) . block ;
84+ editor . insertBlocks (
85+ [ {
86+ type : "mermaid" as any ,
87+ props : {
88+ diagramId : nanoid ( ) ,
89+ title : "Mermaid Diagram" ,
90+ minimized : false ,
91+ height : 400 ,
92+ width : 600 ,
93+ }
94+ } ] ,
95+ currentBlock . id ,
96+ "after"
97+ ) ;
98+ } ,
99+ aliases : [ "mermaid" , "diagram" , "flowchart" , "chart" , "graph" ] ,
100+ group : "Other" ,
101+ icon : "📊" as any ,
102+ subtext : "Create a Mermaid flowchart or diagram" ,
103+ } ) ;
104+
105+ // Get all slash menu items including custom blocks
80106const getCustomSlashMenuItems = ( editor : BlockNoteEditor < any , any , any > ) => [
81107 ...getDefaultReactSlashMenuItems ( editor ) ,
82108 insertChatBlockItem ( editor ) ,
109+ insertMermaidBlockItem ( editor ) ,
83110] ;
84111
85112// Filter slash menu items based on query
@@ -401,6 +428,7 @@ export function Editor({ docId }: EditorProps) {
401428 editor = { editor }
402429 docId = { docId }
403430 onNewDocument = { handleNewDocument }
431+ yDoc = { doc }
404432 />
405433 ) }
406434 </ div >
0 commit comments