import { Switch, Match, createSignal, Show } from 'solid-js' import type { Editor } from '@tiptap/core' import styles from './TextBubbleMenu.module.scss' import { Icon } from '../../_shared/Icon' import { clsx } from 'clsx' import { createEditorTransaction } from 'solid-tiptap' import { useLocalize } from '../../../context/localize' import { Popover } from '../../_shared/Popover' import { InsertLinkForm } from '../InsertLinkForm' type BubbleMenuProps = { editor: Editor isCommonMarkup: boolean ref: (el: HTMLDivElement) => void } export const TextBubbleMenu = (props: BubbleMenuProps) => { const { t } = useLocalize() const isActive = (name: string, attributes?: unknown) => createEditorTransaction( () => props.editor, (editor) => { return editor && editor.isActive(name, attributes) } ) const [textSizeBubbleOpen, setTextSizeBubbleOpen] = createSignal(false) const [listBubbleOpen, setListBubbleOpen] = createSignal(false) const [linkEditorOpen, setLinkEditorOpen] = createSignal(false) const isBold = isActive('bold') const isItalic = isActive('italic') const isH1 = isActive('heading', { level: 2 }) const isH2 = isActive('heading', { level: 3 }) const isH3 = isActive('heading', { level: 4 }) const isBlockQuote = isActive('blockquote') const isOrderedList = isActive('isOrderedList') const isBulletList = isActive('isBulletList') const isLink = isActive('link') const isHighlight = isActive('highlight') const toggleTextSizePopup = () => { if (listBubbleOpen()) { setListBubbleOpen(false) } setTextSizeBubbleOpen((prev) => !prev) } const toggleListPopup = () => { if (textSizeBubbleOpen()) { setTextSizeBubbleOpen(false) } setListBubbleOpen((prev) => !prev) } return (
<> <>
{t('Headers')}
{(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )}
{t('Quotes')}
{(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )}
{t('squib')}
{(triggerRef: (el) => void) => ( )}
{(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )}
{(triggerRef: (el) => void) => ( )} <> {(triggerRef: (el) => void) => ( )}
{t('Lists')}
{(triggerRef: (el) => void) => ( )} {(triggerRef: (el) => void) => ( )}
) }