@@ -73,7 +73,7 @@ const insertChatBlockItem = (editor: BlockNoteEditor<any, any, any>) => ({
7373 ) ;
7474 } ,
7575 aliases : [ "chat" , "message" , "discussion" , "conversation" ] ,
76- group : "Other " ,
76+ group : "Advanced " ,
7777 icon : "💬" as any ,
7878 subtext : "Start a collaborative chat discussion" ,
7979} ) ;
@@ -98,17 +98,55 @@ const insertMermaidBlockItem = (editor: BlockNoteEditor<any, any, any>) => ({
9898 ) ;
9999 } ,
100100 aliases : [ "mermaid" , "diagram" , "flowchart" , "chart" , "graph" ] ,
101- group : "Other " ,
101+ group : "Advanced " ,
102102 icon : "📊" as any ,
103103 subtext : "Create a Mermaid flowchart or diagram" ,
104104} ) ;
105105
106+ // Custom slash menu item for embed block (YouTube, Vimeo, Spotify, etc.)
107+ const insertEmbedBlockItem = ( editor : BlockNoteEditor < any , any , any > ) => ( {
108+ title : "Embed" ,
109+ onItemClick : ( ) => {
110+ const currentBlock = editor . getTextCursorPosition ( ) . block ;
111+ editor . insertBlocks (
112+ [ {
113+ type : "embed" as any ,
114+ props : {
115+ url : "" ,
116+ width : 640 ,
117+ height : 360 ,
118+ caption : "" ,
119+ }
120+ } ] ,
121+ currentBlock . id ,
122+ "after"
123+ ) ;
124+ } ,
125+ aliases : [ "embed" , "youtube" , "video" , "vimeo" , "spotify" , "twitch" , "loom" , "figma" ] ,
126+ group : "Media" ,
127+ icon : "🔗" as any ,
128+ subtext : "Embed YouTube, Vimeo, Spotify, and more" ,
129+ } ) ;
130+
106131// Get all slash menu items including custom blocks
107- const getCustomSlashMenuItems = ( editor : BlockNoteEditor < any , any , any > ) => [
108- ...getDefaultReactSlashMenuItems ( editor ) ,
109- insertChatBlockItem ( editor ) ,
110- insertMermaidBlockItem ( editor ) ,
111- ] ;
132+ const getCustomSlashMenuItems = ( editor : BlockNoteEditor < any , any , any > ) => {
133+ const defaultItems = getDefaultReactSlashMenuItems ( editor ) ;
134+
135+ // Find index of Table (last item in Advanced group) to insert Chat and Mermaid after it
136+ const tableIndex = defaultItems . findIndex ( item => item . title === "Table" ) ;
137+ if ( tableIndex !== - 1 ) {
138+ defaultItems . splice ( tableIndex + 1 , 0 , insertChatBlockItem ( editor ) , insertMermaidBlockItem ( editor ) ) ;
139+ }
140+
141+ // Find index of File (last item in Media group) to insert Embed after it
142+ // Note: indices shifted after previous splice, so we search again
143+ const fileIndex = defaultItems . findIndex ( item => item . title === "File" ) ;
144+ if ( fileIndex !== - 1 ) {
145+ defaultItems . splice ( fileIndex + 1 , 0 , insertEmbedBlockItem ( editor ) ) ;
146+ }
147+
148+ return defaultItems ;
149+ } ;
112150
113151// Filter slash menu items based on query
114152const filterSlashMenuItems = (
@@ -176,13 +214,13 @@ export function Editor({ docId }: EditorProps) {
176214 schema, // Custom schema with syntax highlighting
177215 collaboration : provider
178216 ? {
179- fragment : doc . getXmlFragment ( "document" ) ,
180- user : {
181- name : userInfo ?. name || "Anonymous" ,
182- color : userColor ,
183- } ,
184- provider,
185- }
217+ fragment : doc . getXmlFragment ( "document" ) ,
218+ user : {
219+ name : userInfo ?. name || "Anonymous" ,
220+ color : userColor ,
221+ } ,
222+ provider,
223+ }
186224 : undefined ,
187225 } ,
188226 [ provider , mode ] // Recreate editor when provider or mode changes
@@ -313,12 +351,12 @@ export function Editor({ docId }: EditorProps) {
313351 try {
314352 // Convert markdown to BlockNote blocks
315353 const blocks = await editor . tryParseMarkdownToBlocks ( markdown ) ;
316-
354+
317355 // Replace the default empty paragraph with imported content
318356 editor . replaceBlocks ( editor . document , blocks ) ;
319-
357+
320358 console . log ( '✓ Successfully imported content' ) ;
321-
359+
322360 // Clean up URL parameter
323361 window . history . replaceState ( { } , '' , `/${ docId } ` ) ;
324362 } catch ( error ) {
@@ -424,9 +462,9 @@ export function Editor({ docId }: EditorProps) {
424462 color : "var(--page-text)" ,
425463 } }
426464 >
427- < span className = "mobile-logo-bracket" style = { { fontWeight : 800 , fontSize :"28px" , color : "#646cff" } } > [</ span >
465+ < span className = "mobile-logo-bracket" style = { { fontWeight : 800 , fontSize : "28px" , color : "#646cff" } } > [</ span >
428466 < span > MarkDoc </ span >
429- < span className = "mobile-logo-bracket" style = { { fontWeight : 800 , fontSize :"28px" , color : "#646cff" } } > ]</ span >
467+ < span className = "mobile-logo-bracket" style = { { fontWeight : 800 , fontSize : "28px" , color : "#646cff" } } > ]</ span >
430468 </ h1 >
431469 < p
432470 style = { {
0 commit comments