minor
Some checks failed
deploy / testbuild (push) Failing after 45s
deploy / Update templates on Mailgun (push) Has been skipped

This commit is contained in:
Untone 2024-10-11 04:05:34 +03:00
parent a99164b504
commit 3851d17540
3 changed files with 19 additions and 6 deletions

View File

@ -41,7 +41,7 @@ export const BlockquoteBubbleMenu = (props: Props) => {
</button>
)}
</Popover>
<Popover content={t('Alignment center')}>
<Popover content={t('Alignment right')}>
{(triggerRef: (el: HTMLElement) => void) => (
<button
ref={triggerRef}

View File

@ -125,7 +125,12 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => {
return (
<>
<div ref={props.ref} class={styles.editorFloatingMenu}>
<button ref={setPlusButtonRef} type="button" onClick={() => setMenuOpen(!menuOpen())}>
<button
class={styles.actionButton}
ref={setPlusButtonRef}
type="button"
onClick={() => setMenuOpen(!menuOpen())}
>
<Icon name="editor-plus" />
</button>
<Show when={menuOpen()}>

View File

@ -1,11 +1,12 @@
import type { Editor } from '@tiptap/core'
import { clsx } from 'clsx'
import { Accessor, Show, createSignal, onCleanup, onMount } from 'solid-js'
import { Icon } from '~/components/_shared/Icon'
import { useEditorContext } from '~/context/editor'
import { InsertLinkForm } from './InsertLinkForm'
import { ToolbarControl } from './ToolbarControl'
import clsx from 'clsx'
import styles from './MicroBubbleMenu.module.scss'
import ToolbarControl from './ToolbarControl'
type MicroBubbleMenuProps = {
editor: Accessor<Editor | undefined>
@ -15,6 +16,7 @@ type MicroBubbleMenuProps = {
export const MicroBubbleMenu = (props: MicroBubbleMenuProps) => {
const [linkEditorOpen, setLinkEditorOpen] = createSignal(false)
const { editing } = useEditorContext()
const handleOpenLinkForm = () => {
const { from, to } = props.editor()!.state.selection
@ -29,9 +31,9 @@ export const MicroBubbleMenu = (props: MicroBubbleMenuProps) => {
props.editor()?.chain().focus().setTextSelection(to).run()
}
// handle ctrl+k to insert link
const handleKeyDown = (event: KeyboardEvent) => {
if (
// handle ctrl+k to insert link
if (
event.code === 'KeyK' &&
(event.metaKey || event.ctrlKey) &&
!props.editor()?.state.selection.empty
@ -39,6 +41,12 @@ export const MicroBubbleMenu = (props: MicroBubbleMenuProps) => {
event.preventDefault()
setLinkEditorOpen((prev) => !prev)
}
// handle shift+enter to change focus
if (event.code === 'Enter' && (event.metaKey || event.shiftKey)) {
event.preventDefault()
editing()?.commands.focus()
}
}
onMount(() => {