@@ -21,102 +21,130 @@ import { Codepen } from "react-feather";
2121const EditorMenubar = ( { editor } : { editor : Editor } ) => {
2222 const MenuBarFunctions = [
2323 {
24+ id : 1 ,
2425 title : "bold" ,
2526 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleBold ( ) . run ( ) ,
2627 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleBold ( ) . run ( ) ,
2728 icon : Bold ,
2829 } ,
2930 {
31+ id : 2 ,
3032 title : "italic" ,
3133 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleItalic ( ) . run ( ) ,
3234 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleItalic ( ) . run ( ) ,
3335 icon : Italic ,
3436 } ,
3537 {
38+ id : 3 ,
3639 title : "strike" ,
3740 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleStrike ( ) . run ( ) ,
3841 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleStrike ( ) . run ( ) ,
3942 icon : Strikethrough ,
4043 } ,
4144 {
45+ id : 4 ,
46+
4247 title : "code" ,
4348 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleCode ( ) . run ( ) ,
4449 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleCode ( ) . run ( ) ,
4550 icon : Code ,
4651 } ,
4752 {
53+ id : 5 ,
54+
4855 title : `heading` ,
4956 attribute : { level : 1 } ,
5057 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 1 } ) . run ( ) ,
5158 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 1 } ) . run ( ) ,
5259 icon : Heading1 ,
5360 } ,
5461 {
62+ id : 6 ,
63+
5564 title : "heading" ,
5665 attribute : { level : 2 } || null ,
5766 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 2 } ) . run ( ) ,
5867 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 2 } ) . run ( ) ,
5968 icon : Heading2 ,
6069 } ,
6170 {
71+ id : 7 ,
72+
6273 title : "heading" ,
6374 attribute : { level : 3 } || null ,
6475 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 3 } ) . run ( ) ,
6576 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 3 } ) . run ( ) ,
6677 icon : Heading3 ,
6778 } ,
6879 {
80+ id : 8 ,
81+
6982 title : "heading" ,
7083 attribute : { level : 4 } || null ,
7184 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 4 } ) . run ( ) ,
7285 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 4 } ) . run ( ) ,
7386 icon : Heading4 ,
7487 } ,
7588 {
89+ id : 9 ,
7690 title : "heading" ,
7791 attribute : { level : 5 } || null ,
7892 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 5 } ) . run ( ) ,
7993 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 5 } ) . run ( ) ,
8094 icon : Heading5 ,
8195 } ,
8296 {
97+ id : 10 ,
98+
8399 title : "heading" ,
84100 attribute : { level : 6 } || null ,
85101 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleHeading ( { level : 6 } ) . run ( ) ,
86102 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleHeading ( { level : 6 } ) . run ( ) ,
87103 icon : Heading6 ,
88104 } ,
89105 {
106+ id : 11 ,
107+
90108 title : "bulletList" ,
91109 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleBulletList ( ) . run ( ) ,
92110 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleBulletList ( ) . run ( ) ,
93111 icon : List ,
94112 } ,
95113 {
114+ id : 12 ,
115+
96116 title : "orderedList" ,
97117 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleOrderedList ( ) . run ( ) ,
98118 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleOrderedList ( ) . run ( ) ,
99119 icon : ListOrdered ,
100120 } ,
101121 {
122+ id : 13 ,
123+
102124 title : "codeBlock" ,
103125 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleCodeBlock ( ) . run ( ) ,
104126 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleCodeBlock ( ) . run ( ) ,
105127 icon : Codepen ,
106128 } ,
107129 {
130+ id : 14 ,
131+
108132 title : "blockquote" ,
109133 onFunction : ( ) => editor . chain ( ) . focus ( ) . toggleBlockquote ( ) . run ( ) ,
110134 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . toggleBlockquote ( ) . run ( ) ,
111135 icon : Quote ,
112136 } ,
113137 {
138+ id : 15 ,
139+
114140 title : "undo" ,
115141 onFunction : ( ) => editor . chain ( ) . focus ( ) . undo ( ) . run ( ) ,
116142 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . undo ( ) . run ( ) ,
117143 icon : Undo ,
118144 } ,
119145 {
146+ id : 16 ,
147+
120148 title : "redo" ,
121149 onFunction : ( ) => editor . chain ( ) . focus ( ) . redo ( ) . run ( ) ,
122150 offFunction : ( ) => ! editor . can ( ) . chain ( ) . focus ( ) . redo ( ) . run ( ) ,
@@ -130,7 +158,7 @@ const EditorMenubar = ({ editor }: { editor: Editor }) => {
130158 { MenuBarFunctions . length > 0 &&
131159 MenuBarFunctions . map ( ( menu ) => (
132160 < button
133- key = { menu . title }
161+ key = { menu . id }
134162 role = "button"
135163 onClick = { ( e ) => {
136164 e . preventDefault ( ) ;
0 commit comments