1+ import {
2+ BlockNoteEditor ,
3+ BlockSchema ,
4+ DefaultBlockSchema ,
5+ } from "@blocknote/core" ;
16import { useEffect , useState } from "react" ;
2- import { BlockNoteEditor , BlockSchema , PartialBlock } from "@blocknote/core " ;
7+ import { IconType } from "react-icons " ;
38import {
49 RiH1 ,
510 RiH2 ,
@@ -9,7 +14,6 @@ import {
914 RiText ,
1015} from "react-icons/ri" ;
1116import { ToolbarDropdown } from "../../../SharedComponents/Toolbar/components/ToolbarDropdown" ;
12- import { IconType } from "react-icons" ;
1317
1418type HeadingLevels = "1" | "2" | "3" ;
1519
@@ -44,20 +48,24 @@ export const BlockTypeDropdown = <BSchema extends BlockSchema>(props: {
4448 return null ;
4549 }
4650
47- const headingItems = (
48- props . editor . schema . heading . propSchema . level . values ! as HeadingLevels [ ]
49- ) . map ( ( level ) => ( {
50- onClick : ( ) => {
51- props . editor . focus ( ) ;
52- props . editor . updateBlock ( block , {
53- type : "heading" ,
54- props : { level : level } ,
55- } as PartialBlock < BSchema > ) ;
56- } ,
57- text : "Heading " + level ,
58- icon : headingIcons [ level ] ,
59- isSelected : block . type === "heading" && block . props . level === level ,
60- } ) ) ;
51+ // let's cast the editor because "shouldShow" has given us the confidence
52+ // the default block schema is being used
53+ let editor = props . editor as any as BlockNoteEditor < DefaultBlockSchema > ;
54+
55+ const headingItems = editor . schema . heading . propSchema . level . values . map (
56+ ( level ) => ( {
57+ onClick : ( ) => {
58+ editor . focus ( ) ;
59+ editor . updateBlock ( block , {
60+ type : "heading" ,
61+ props : { level : level } ,
62+ } ) ;
63+ } ,
64+ text : "Heading " + level ,
65+ icon : headingIcons [ level ] ,
66+ isSelected : block . type === "heading" && block . props . level === level ,
67+ } )
68+ ) ;
6169
6270 return (
6371 < ToolbarDropdown
0 commit comments