|
|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
import Bold from "@geist-ui/icons/bold"
|
|
|
|
|
import Italic from "@geist-ui/icons/italic"
|
|
|
|
|
import Link from "@geist-ui/icons/link"
|
|
|
|
|
import Code from "@geist-ui/icons/code"
|
|
|
|
|
import List from "@geist-ui/icons/list"
|
|
|
|
|
|
|
|
|
|
import ImageIcon from "@geist-ui/icons/image"
|
|
|
|
|
import { RefObject, useCallback, useMemo } from "react"
|
|
|
|
|
import { RefObject, useMemo } from "react"
|
|
|
|
|
import styles from "../document.module.css"
|
|
|
|
|
import { Button, ButtonGroup } from "@geist-ui/core"
|
|
|
|
|
import { Button, ButtonGroup, Tooltip } from "@geist-ui/core"
|
|
|
|
|
import { TextareaMarkdownRef } from "textarea-markdown-editor"
|
|
|
|
|
|
|
|
|
|
// TODO: clean up
|
|
|
|
|
@ -19,6 +22,9 @@ const FormattingIcons = ({
|
|
|
|
|
const handleItalicClick = () => textareaRef?.current?.trigger("italic")
|
|
|
|
|
const handleLinkClick = () => textareaRef?.current?.trigger("link")
|
|
|
|
|
const handleImageClick = () => textareaRef?.current?.trigger("image")
|
|
|
|
|
const handleCodeClick = () => textareaRef?.current?.trigger("code")
|
|
|
|
|
const handleListClick = () =>
|
|
|
|
|
textareaRef?.current?.trigger("unordered-list")
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
icon: <Bold />,
|
|
|
|
|
@ -30,11 +36,6 @@ const FormattingIcons = ({
|
|
|
|
|
name: "italic",
|
|
|
|
|
action: handleItalicClick
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// icon: <Underline />,
|
|
|
|
|
// name: 'underline',
|
|
|
|
|
// action: handleUnderlineClick
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
icon: <Link />,
|
|
|
|
|
name: "hyperlink",
|
|
|
|
|
@ -44,6 +45,16 @@ const FormattingIcons = ({
|
|
|
|
|
icon: <ImageIcon />,
|
|
|
|
|
name: "image",
|
|
|
|
|
action: handleImageClick
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: <Code />,
|
|
|
|
|
name: "code",
|
|
|
|
|
action: handleCodeClick
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: <List />,
|
|
|
|
|
name: "unordered-list",
|
|
|
|
|
action: handleListClick
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}, [textareaRef])
|
|
|
|
|
@ -52,16 +63,20 @@ const FormattingIcons = ({
|
|
|
|
|
<div className={styles.actionWrapper}>
|
|
|
|
|
<ButtonGroup className={styles.actions}>
|
|
|
|
|
{formattingActions.map(({ icon, name, action }) => (
|
|
|
|
|
<Button
|
|
|
|
|
auto
|
|
|
|
|
scale={2 / 3}
|
|
|
|
|
px={0.6}
|
|
|
|
|
aria-label={name}
|
|
|
|
|
<Tooltip
|
|
|
|
|
text={name[0].toUpperCase() + name.slice(1).replace("-", " ")}
|
|
|
|
|
key={name}
|
|
|
|
|
icon={icon}
|
|
|
|
|
onMouseDown={(e) => e.preventDefault()}
|
|
|
|
|
onClick={action}
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
auto
|
|
|
|
|
scale={2 / 3}
|
|
|
|
|
px={0.6}
|
|
|
|
|
aria-label={name}
|
|
|
|
|
icon={icon}
|
|
|
|
|
onMouseDown={(e) => e.preventDefault()}
|
|
|
|
|
onClick={action}
|
|
|
|
|
/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
))}
|
|
|
|
|
</ButtonGroup>
|
|
|
|
|
</div>
|
|
|
|
|
|