File tree 3 files changed +26
-11
lines changed
examples/02-ui-components/05-side-menu-drag-handle-items
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
12
12
13
13
``` typescript jsx
14
14
" use client" ; // this registers <Editor> as a Client Component
15
- import { BlockNoteView , useCreateBlockNote } from " @blocknote/react" ;
16
15
import " @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" ;
18
19
19
20
// Our <Editor> component we can reuse later
20
21
export default function Editor() {
Original file line number Diff line number Diff line change @@ -5,12 +5,13 @@ import {
5
5
RemoveBlockItem ,
6
6
SideMenu ,
7
7
SideMenuController ,
8
- useComponentsContext ,
9
8
useCreateBlockNote ,
10
9
} from "@blocknote/react" ;
11
10
import { BlockNoteView } from "@blocknote/mantine" ;
12
11
import "@blocknote/mantine/style.css" ;
13
12
13
+ import { ResetBlockTypeItem } from "./ResetBlockTypeItem" ;
14
+
14
15
export default function App ( ) {
15
16
// Creates a new editor instance.
16
17
const editor = useCreateBlockNote ( {
@@ -34,8 +35,6 @@ export default function App() {
34
35
] ,
35
36
} ) ;
36
37
37
- const Components = useComponentsContext ( ) ! ;
38
-
39
38
// Renders the editor instance.
40
39
return (
41
40
< BlockNoteView editor = { editor } sideMenu = { false } >
@@ -48,12 +47,7 @@ export default function App() {
48
47
< RemoveBlockItem { ...props } > Delete</ RemoveBlockItem >
49
48
< BlockColorsItem { ...props } > Colors</ BlockColorsItem >
50
49
{ /* 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 >
57
51
</ DragHandleMenu >
58
52
) }
59
53
/>
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