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

58 lines
1.6 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>
2023-05-07 13:16:03 +00:00
<button
type="button"
class={clsx(styles.bubbleMenuButton)}
onClick={() => {
props.editor.chain().focus().setFloat(null).run()
}}
>
<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} />
2023-05-07 13:16:03 +00:00
<button
type="button"
class={clsx(styles.bubbleMenuButton)}
onClick={() => {
props.editor.chain().focus().imageToFigure().run()
}}
>
<span style={{ color: 'white' }}>Добавить подпись</span>
</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>
)
}