1
1
import Bold from "@geist-ui/icons/bold"
2
2
import Italic from "@geist-ui/icons/italic"
3
3
import Link from "@geist-ui/icons/link"
4
+ import Code from "@geist-ui/icons/code"
5
+ import List from "@geist-ui/icons/list"
6
+
4
7
import ImageIcon from "@geist-ui/icons/image"
5
- import { RefObject , useCallback , useMemo } from "react"
8
+ import { RefObject , useMemo } from "react"
6
9
import styles from "../document.module.css"
7
- import { Button , ButtonGroup } from "@geist-ui/core"
10
+ import { Button , ButtonGroup , Tooltip } from "@geist-ui/core"
8
11
import { TextareaMarkdownRef } from "textarea-markdown-editor"
9
12
10
13
// TODO: clean up
@@ -19,6 +22,9 @@ const FormattingIcons = ({
19
22
const handleItalicClick = ( ) => textareaRef ?. current ?. trigger ( "italic" )
20
23
const handleLinkClick = ( ) => textareaRef ?. current ?. trigger ( "link" )
21
24
const handleImageClick = ( ) => textareaRef ?. current ?. trigger ( "image" )
25
+ const handleCodeClick = ( ) => textareaRef ?. current ?. trigger ( "code" )
26
+ const handleListClick = ( ) =>
27
+ textareaRef ?. current ?. trigger ( "unordered-list" )
22
28
return [
23
29
{
24
30
icon : < Bold /> ,
@@ -30,11 +36,6 @@ const FormattingIcons = ({
30
36
name : "italic" ,
31
37
action : handleItalicClick
32
38
} ,
33
- // {
34
- // icon: <Underline />,
35
- // name: 'underline',
36
- // action: handleUnderlineClick
37
- // },
38
39
{
39
40
icon : < Link /> ,
40
41
name : "hyperlink" ,
@@ -44,6 +45,16 @@ const FormattingIcons = ({
44
45
icon : < ImageIcon /> ,
45
46
name : "image" ,
46
47
action : handleImageClick
48
+ } ,
49
+ {
50
+ icon : < Code /> ,
51
+ name : "code" ,
52
+ action : handleCodeClick
53
+ } ,
54
+ {
55
+ icon : < List /> ,
56
+ name : "unordered-list" ,
57
+ action : handleListClick
47
58
}
48
59
]
49
60
} , [ textareaRef ] )
@@ -52,16 +63,20 @@ const FormattingIcons = ({
52
63
< div className = { styles . actionWrapper } >
53
64
< ButtonGroup className = { styles . actions } >
54
65
{ formattingActions . map ( ( { icon, name, action } ) => (
55
- < Button
56
- auto
57
- scale = { 2 / 3 }
58
- px = { 0.6 }
59
- aria-label = { name }
66
+ < Tooltip
67
+ text = { name [ 0 ] . toUpperCase ( ) + name . slice ( 1 ) . replace ( "-" , " " ) }
60
68
key = { name }
61
- icon = { icon }
62
- onMouseDown = { ( e ) => e . preventDefault ( ) }
63
- onClick = { action }
64
- />
69
+ >
70
+ < Button
71
+ auto
72
+ scale = { 2 / 3 }
73
+ px = { 0.6 }
74
+ aria-label = { name }
75
+ icon = { icon }
76
+ onMouseDown = { ( e ) => e . preventDefault ( ) }
77
+ onClick = { action }
78
+ />
79
+ </ Tooltip >
65
80
) ) }
66
81
</ ButtonGroup >
67
82
</ div >
0 commit comments