2023-05-29 10:09:44 +00:00
|
|
|
import type { Editor } from '@tiptap/core'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-05-29 10:09:44 +00:00
|
|
|
import { useLocalize } from '../../../context/localize'
|
2023-11-14 15:10:00 +00:00
|
|
|
import { Icon } from '../../_shared/Icon'
|
2023-05-29 17:14:58 +00:00
|
|
|
import { Popover } from '../../_shared/Popover'
|
2023-05-29 10:09:44 +00:00
|
|
|
|
2023-11-14 15:10:00 +00:00
|
|
|
import styles from './BubbleMenu.module.scss'
|
|
|
|
|
2023-05-29 10:09:44 +00:00
|
|
|
type Props = {
|
|
|
|
editor: Editor
|
|
|
|
ref: (el: HTMLElement) => void
|
|
|
|
}
|
|
|
|
|
|
|
|
export const BlockquoteBubbleMenu = (props: Props) => {
|
2023-05-29 17:14:58 +00:00
|
|
|
const { t } = useLocalize()
|
2023-05-29 10:09:44 +00:00
|
|
|
return (
|
2023-05-29 17:14:58 +00:00
|
|
|
<div ref={props.ref} class={styles.BubbleMenu}>
|
|
|
|
<Popover content={t('Alignment left')}>
|
|
|
|
{(triggerRef: (el) => void) => (
|
|
|
|
<button
|
|
|
|
ref={triggerRef}
|
|
|
|
type="button"
|
2023-06-10 14:10:05 +00:00
|
|
|
class={styles.bubbleMenuButton}
|
2023-05-29 17:14:58 +00:00
|
|
|
onClick={() => {
|
|
|
|
props.editor.chain().focus().setBlockQuoteFloat('left').run()
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Icon name="editor-image-align-left" />
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
<Popover content={t('Alignment center')}>
|
|
|
|
{(triggerRef: (el) => void) => (
|
|
|
|
<button
|
|
|
|
ref={triggerRef}
|
|
|
|
type="button"
|
2023-06-10 14:10:05 +00:00
|
|
|
class={styles.bubbleMenuButton}
|
2023-05-29 17:14:58 +00:00
|
|
|
onClick={() => props.editor.chain().focus().setBlockQuoteFloat(null).run()}
|
|
|
|
>
|
|
|
|
<Icon name="editor-image-align-center" />
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
<Popover content={t('Alignment center')}>
|
|
|
|
{(triggerRef: (el) => void) => (
|
|
|
|
<button
|
|
|
|
ref={triggerRef}
|
|
|
|
type="button"
|
2023-06-10 14:10:05 +00:00
|
|
|
class={styles.bubbleMenuButton}
|
2023-05-29 17:14:58 +00:00
|
|
|
onClick={() => props.editor.chain().focus().setBlockQuoteFloat('right').run()}
|
|
|
|
>
|
|
|
|
<Icon name="editor-image-align-right" />
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</Popover>
|
2023-05-29 10:09:44 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|