This commit is contained in:
Untone 2024-10-11 13:58:39 +03:00
parent d485314b11
commit a1ca2251a5
5 changed files with 7 additions and 11 deletions

View File

@ -183,13 +183,14 @@ export const EditorComponent = (props: EditorComponentProps) => {
const isEmptyTextBlock = doc.textBetween(from, to).length === 0 && isTextSelection(selection) const isEmptyTextBlock = doc.textBetween(from, to).length === 0 && isTextSelection(selection)
if (isEmptyTextBlock) { if (isEmptyTextBlock) {
e?.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run() e?.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run()
return false
} }
const hasSelection = !selection.empty && from !== to const hasSelection = !selection.empty && from !== to
const isFootnoteOrFigcaption = const isFootnoteOrFigcaption =
e.isActive('footnote') || (e.isActive('figcaption') && hasSelection) e.isActive('footnote') || (e.isActive('figcaption') && hasSelection)
const result = const result =
e.isFocused && e.view.hasFocus() &&
hasSelection && hasSelection &&
!e.isActive('image') && !e.isActive('image') &&
!e.isActive('figure') && !e.isActive('figure') &&

View File

@ -2,7 +2,7 @@ import BubbleMenu from '@tiptap/extension-bubble-menu'
import Placeholder from '@tiptap/extension-placeholder' import Placeholder from '@tiptap/extension-placeholder'
import clsx from 'clsx' import clsx from 'clsx'
import { type JSX, createEffect, createSignal, on, onCleanup, onMount } from 'solid-js' import { type JSX, createEffect, createSignal, on, onCleanup, onMount } from 'solid-js'
import { createEditorTransaction, createTiptapEditor, useEditorHTML } from 'solid-tiptap' import { createTiptapEditor, useEditorHTML } from 'solid-tiptap'
import { minimal } from '~/lib/editorExtensions' import { minimal } from '~/lib/editorExtensions'
import { MicroBubbleMenu } from './Toolbar/MicroBubbleMenu' import { MicroBubbleMenu } from './Toolbar/MicroBubbleMenu'
@ -47,10 +47,6 @@ export const MicroEditor = (props: MicroEditorProps): JSX.Element => {
const html = useEditorHTML(editor) const html = useEditorHTML(editor)
createEffect(on(html, (c?: string) => c && props.onChange?.(c))) createEffect(on(html, (c?: string) => c && props.onChange?.(c)))
const lostFocusEmpty = createEditorTransaction(
editor,
(e) => e && !e.isFocused && e?.view.state.doc.textContent.trim() === ''
)
createEffect( createEffect(
on( on(
isBlurred, isBlurred,

View File

@ -26,7 +26,6 @@
} }
.delimiter { .delimiter {
background: #fff;
opacity: 0.5; opacity: 0.5;
display: inline-block; display: inline-block;
height: 1.4em; height: 1.4em;
@ -48,9 +47,9 @@
top: calc(100% + 8px); top: calc(100% + 8px);
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
box-shadow: 0 4px 10px rgb(0 0 0 / 25%); box-shadow: 0 4px 10px var(--shadow-color-medium);
background: #000; background: var(--black-500);
color: #898c94; color: var(--text-color-secondary);
& > header { & > header {
font-size: 10px; font-size: 10px;

View File

@ -14,7 +14,6 @@
} }
.menuHolder { .menuHolder {
background: #fff;
left: 24px; left: 24px;
position: absolute; position: absolute;
top: -4px; top: -4px;

View File

@ -342,6 +342,7 @@ export const EditView = (props: Props) => {
</Show> </Show>
<Show when={isLeadVisible()}> <Show when={isLeadVisible()}>
<MicroEditor <MicroEditor
focusOnMount={true}
shownAsLead={isLeadVisible()} shownAsLead={isLeadVisible()}
placeholder={t('A short introduction to keep the reader interested')} placeholder={t('A short introduction to keep the reader interested')}
content={form.lead} content={form.lead}