2023-05-04 12:16:39 +00:00
|
|
|
import type { Editor } from '@tiptap/core'
|
2023-05-29 10:09:44 +00:00
|
|
|
import styles from './FigureBubbleMenu.module.scss'
|
2023-05-04 13:36:53 +00:00
|
|
|
import { clsx } from 'clsx'
|
|
|
|
import { Icon } from '../../_shared/Icon'
|
2023-05-29 10:09:44 +00:00
|
|
|
import { useLocalize } from '../../../context/localize'
|
2023-05-04 12:16:39 +00:00
|
|
|
|
2023-05-29 10:09:44 +00:00
|
|
|
type Props = {
|
2023-05-04 12:16:39 +00:00
|
|
|
editor: Editor
|
2023-05-29 10:09:44 +00:00
|
|
|
ref: (el: HTMLElement) => void
|
2023-05-04 12:16:39 +00:00
|
|
|
}
|
|
|
|
|
2023-05-29 10:09:44 +00:00
|
|
|
export const FigureBubbleMenu = (props: Props) => {
|
|
|
|
const { t } = useLocalize()
|
2023-05-04 12:16:39 +00:00
|
|
|
return (
|
2023-05-29 10:09:44 +00:00
|
|
|
<div ref={props.ref} class={styles.FigureBubbleMenu}>
|
2023-05-06 12:38:22 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class={clsx(styles.bubbleMenuButton)}
|
2023-05-29 10:09:44 +00:00
|
|
|
onClick={() => props.editor.chain().focus().setImageFloat('left').run()}
|
2023-05-06 12:38:22 +00:00
|
|
|
>
|
2023-05-04 13:36:53 +00:00
|
|
|
<Icon name="editor-image-align-left" />
|
|
|
|
</button>
|
2023-05-07 13:16:03 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class={clsx(styles.bubbleMenuButton)}
|
2023-05-29 10:09:44 +00:00
|
|
|
onClick={() => props.editor.chain().focus().setImageFloat(null).run()}
|
2023-05-07 13:16:03 +00:00
|
|
|
>
|
2023-05-04 13:36:53 +00:00
|
|
|
<Icon name="editor-image-align-center" />
|
|
|
|
</button>
|
2023-05-06 12:38:22 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class={clsx(styles.bubbleMenuButton)}
|
2023-05-29 10:09:44 +00:00
|
|
|
onClick={() => props.editor.chain().focus().setImageFloat('right').run()}
|
2023-05-06 12:38:22 +00:00
|
|
|
>
|
2023-05-04 13:36:53 +00:00
|
|
|
<Icon name="editor-image-align-right" />
|
|
|
|
</button>
|
2023-05-29 10:09:44 +00:00
|
|
|
|
2023-05-04 13:36:53 +00:00
|
|
|
<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()
|
|
|
|
}}
|
|
|
|
>
|
2023-05-29 10:09:44 +00:00
|
|
|
<span style={{ color: 'white' }}>{t('Add signature')}</span>
|
2023-05-07 13:16:03 +00:00
|
|
|
</button>
|
|
|
|
<div class={styles.delimiter} />
|
2023-05-04 13:36:53 +00:00
|
|
|
<button type="button" class={clsx(styles.bubbleMenuButton)}>
|
2023-05-06 12:38:22 +00:00
|
|
|
<Icon name="editor-image-add" />
|
2023-05-04 13:36:53 +00:00
|
|
|
</button>
|
2023-05-04 12:16:39 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|