File tree Expand file tree Collapse file tree 3 files changed +26
-11
lines changed
examples/02-ui-components/05-side-menu-drag-handle-items Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,10 @@ Make sure to use BlockNote in a [Client Component](https://nextjs.org/docs/getti
1212
1313``` typescript jsx
1414" use client" ; // this registers <Editor> as a Client Component
15- import { BlockNoteView , useCreateBlockNote } from " @blocknote/react" ;
1615import " @blocknote/core/fonts/inter.css" ;
17- import " @blocknote/react/style.css" ;
16+ import { useCreateBlockNote } from " @blocknote/react" ;
17+ import { BlockNoteView } from " @blocknote/mantine" ;
18+ import " @blocknote/mantine/style.css" ;
1819
1920// Our <Editor> component we can reuse later
2021export default function Editor() {
Original file line number Diff line number Diff line change @@ -5,12 +5,13 @@ import {
55 RemoveBlockItem ,
66 SideMenu ,
77 SideMenuController ,
8- useComponentsContext ,
98 useCreateBlockNote ,
109} from "@blocknote/react" ;
1110import { BlockNoteView } from "@blocknote/mantine" ;
1211import "@blocknote/mantine/style.css" ;
1312
13+ import { ResetBlockTypeItem } from "./ResetBlockTypeItem" ;
14+
1415export default function App ( ) {
1516 // Creates a new editor instance.
1617 const editor = useCreateBlockNote ( {
@@ -34,8 +35,6 @@ export default function App() {
3435 ] ,
3536 } ) ;
3637
37- const Components = useComponentsContext ( ) ! ;
38-
3938 // Renders the editor instance.
4039 return (
4140 < BlockNoteView editor = { editor } sideMenu = { false } >
@@ -48,12 +47,7 @@ export default function App() {
4847 < RemoveBlockItem { ...props } > Delete</ RemoveBlockItem >
4948 < BlockColorsItem { ...props } > Colors</ BlockColorsItem >
5049 { /* Item which resets the hovered block's type. */ }
51- < Components . Generic . Menu . Item
52- onClick = { ( ) => {
53- editor . updateBlock ( props . block , { type : "paragraph" } ) ;
54- } } >
55- Reset Type
56- </ Components . Generic . Menu . Item >
50+ < ResetBlockTypeItem { ...props } > Reset Type</ ResetBlockTypeItem >
5751 </ DragHandleMenu >
5852 ) }
5953 />
Original file line number Diff line number Diff line change 1+ import {
2+ DragHandleMenuProps ,
3+ useBlockNoteEditor ,
4+ useComponentsContext ,
5+ } from "@blocknote/react" ;
6+
7+ export function ResetBlockTypeItem ( props : DragHandleMenuProps ) {
8+ const editor = useBlockNoteEditor ( ) ;
9+
10+ const Components = useComponentsContext ( ) ! ;
11+
12+ return (
13+ < Components . Generic . Menu . Item
14+ onClick = { ( ) => {
15+ editor . updateBlock ( props . block , { type : "paragraph" } ) ;
16+ } } >
17+ Reset Type
18+ </ Components . Generic . Menu . Item >
19+ ) ;
20+ }
You can’t perform that action at this time.
0 commit comments