@@ -18,6 +18,39 @@ import {
1818
1919import { BlueButton } from "./BlueButton" ;
2020
21+ const CustomFormattingToolbar = ( ) => (
22+ < FormattingToolbar >
23+ < BlockTypeSelect key = { "blockTypeSelect" } />
24+
25+ { /* Extra button to toggle blue text & background */ }
26+ < BlueButton key = { "customButton" } />
27+
28+ < FileCaptionButton key = { "fileCaptionButton" } />
29+ < FileReplaceButton key = { "replaceFileButton" } />
30+
31+ < BasicTextStyleButton basicTextStyle = { "bold" } key = { "boldStyleButton" } />
32+ < BasicTextStyleButton basicTextStyle = { "italic" } key = { "italicStyleButton" } />
33+ < BasicTextStyleButton
34+ basicTextStyle = { "underline" }
35+ key = { "underlineStyleButton" }
36+ />
37+ < BasicTextStyleButton basicTextStyle = { "strike" } key = { "strikeStyleButton" } />
38+ { /* Extra button to toggle code styles */ }
39+ < BasicTextStyleButton key = { "codeStyleButton" } basicTextStyle = { "code" } />
40+
41+ < TextAlignButton textAlignment = { "left" } key = { "textAlignLeftButton" } />
42+ < TextAlignButton textAlignment = { "center" } key = { "textAlignCenterButton" } />
43+ < TextAlignButton textAlignment = { "right" } key = { "textAlignRightButton" } />
44+
45+ < ColorStyleButton key = { "colorStyleButton" } />
46+
47+ < NestBlockButton key = { "nestBlockButton" } />
48+ < UnnestBlockButton key = { "unnestBlockButton" } />
49+
50+ < CreateLinkButton key = { "createLinkButton" } />
51+ </ FormattingToolbar >
52+ ) ;
53+
2154export default function App ( ) {
2255 // Creates a new editor instance.
2356 const editor = useCreateBlockNote ( {
@@ -77,61 +110,7 @@ export default function App() {
77110 // Renders the editor instance.
78111 return (
79112 < BlockNoteView editor = { editor } formattingToolbar = { false } >
80- < FormattingToolbarController
81- formattingToolbar = { ( ) => (
82- < FormattingToolbar >
83- < BlockTypeSelect key = { "blockTypeSelect" } />
84-
85- { /* Extra button to toggle blue text & background */ }
86- < BlueButton key = { "customButton" } />
87-
88- < FileCaptionButton key = { "fileCaptionButton" } />
89- < FileReplaceButton key = { "replaceFileButton" } />
90-
91- < BasicTextStyleButton
92- basicTextStyle = { "bold" }
93- key = { "boldStyleButton" }
94- />
95- < BasicTextStyleButton
96- basicTextStyle = { "italic" }
97- key = { "italicStyleButton" }
98- />
99- < BasicTextStyleButton
100- basicTextStyle = { "underline" }
101- key = { "underlineStyleButton" }
102- />
103- < BasicTextStyleButton
104- basicTextStyle = { "strike" }
105- key = { "strikeStyleButton" }
106- />
107- { /* Extra button to toggle code styles */ }
108- < BasicTextStyleButton
109- key = { "codeStyleButton" }
110- basicTextStyle = { "code" }
111- />
112-
113- < TextAlignButton
114- textAlignment = { "left" }
115- key = { "textAlignLeftButton" }
116- />
117- < TextAlignButton
118- textAlignment = { "center" }
119- key = { "textAlignCenterButton" }
120- />
121- < TextAlignButton
122- textAlignment = { "right" }
123- key = { "textAlignRightButton" }
124- />
125-
126- < ColorStyleButton key = { "colorStyleButton" } />
127-
128- < NestBlockButton key = { "nestBlockButton" } />
129- < UnnestBlockButton key = { "unnestBlockButton" } />
130-
131- < CreateLinkButton key = { "createLinkButton" } />
132- </ FormattingToolbar >
133- ) }
134- />
113+ < FormattingToolbarController formattingToolbar = { CustomFormattingToolbar } />
135114 </ BlockNoteView >
136115 ) ;
137116}
0 commit comments