@@ -18,6 +18,7 @@ import {
1818import { ToolbarDropdown } from "../../../SharedComponents/Toolbar/components/ToolbarDropdown" ;
1919import { ToolbarDropdownItemProps } from "../../../SharedComponents/Toolbar/components/ToolbarDropdownItem" ;
2020import { useEditorChange } from "../../../hooks/useEditorChange" ;
21+ import { useSelectedBlocks } from "../../../hooks/useSelectedBlocks" ;
2122
2223export type BlockTypeDropdownItem = {
2324 name : string ;
@@ -82,6 +83,8 @@ export const BlockTypeDropdown = <BSchema extends BlockSchema>(props: {
8283 editor : BlockNoteEditor < BSchema > ;
8384 items ?: BlockTypeDropdownItem [ ] ;
8485} ) => {
86+ const selectedBlocks = useSelectedBlocks ( props . editor ) ;
87+
8588 const [ block , setBlock ] = useState (
8689 props . editor . getTextCursorPosition ( ) . block
8790 ) ;
@@ -123,10 +126,13 @@ export const BlockTypeDropdown = <BSchema extends BlockSchema>(props: {
123126 const fullItems : ToolbarDropdownItemProps [ ] = useMemo ( ( ) => {
124127 const onClick = ( item : BlockTypeDropdownItem ) => {
125128 props . editor . focus ( ) ;
126- props . editor . updateBlock ( block , {
127- type : item . type ,
128- props : item . props ,
129- } as PartialBlock < BlockSchema > ) ;
129+
130+ for ( const block of selectedBlocks ) {
131+ props . editor . updateBlock ( block , {
132+ type : item . type ,
133+ props : item . props ,
134+ } as PartialBlock < BlockSchema > ) ;
135+ }
130136 } ;
131137
132138 return filteredItems . map ( ( item ) => ( {
@@ -135,7 +141,7 @@ export const BlockTypeDropdown = <BSchema extends BlockSchema>(props: {
135141 onClick : ( ) => onClick ( item ) ,
136142 isSelected : item . isSelected ( block as Block < BlockSchema > ) ,
137143 } ) ) ;
138- } , [ block , filteredItems , props . editor ] ) ;
144+ } , [ block , filteredItems , props . editor , selectedBlocks ] ) ;
139145
140146 useEditorChange ( props . editor , ( ) => {
141147 setBlock ( props . editor . getTextCursorPosition ( ) . block ) ;
0 commit comments