webapp/src/components/Editor/ImageBubbleMenu/ImageBubbleMenu.tsx

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-05-04 12:16:39 +00:00
import type { Editor } from '@tiptap/core'
import styles from './ImageBubbleMenu.module.scss'
import { clsx } from 'clsx'
import { Icon } from '../../_shared/Icon'
2023-05-04 12:16:39 +00:00
type BubbleMenuProps = {
editor: Editor
ref: (el: HTMLDivElement) => void
}
export const ImageBubbleMenu = (props: BubbleMenuProps) => {
return (
<div ref={props.ref} class={styles.ImageBubbleMenu}>
2023-05-06 12:38:22 +00:00
<button
type="button"
class={clsx(styles.bubbleMenuButton)}
onClick={() => {
props.editor.chain().focus().setFloat('left').run()
}}
>
<Icon name="editor-image-align-left" />
</button>
<button type="button" class={clsx(styles.bubbleMenuButton)}>
<Icon name="editor-image-align-center" />
</button>
2023-05-06 12:38:22 +00:00
<button
type="button"
class={clsx(styles.bubbleMenuButton)}
onClick={() => {
props.editor.chain().focus().setFloat('right').run()
}}
>
<Icon name="editor-image-align-right" />
</button>
<div class={styles.delimiter} />
<button type="button" class={clsx(styles.bubbleMenuButton)}>
2023-05-06 12:38:22 +00:00
<Icon name="editor-image-add" />
</button>
2023-05-04 12:16:39 +00:00
</div>
)
}