improve text-bubble-menu

This commit is contained in:
fantasticit 2022-11-28 23:00:22 +08:00
parent 1d32808335
commit 210adf583b
1 changed files with 8 additions and 2 deletions

View File

@ -33,7 +33,6 @@ import { Underline } from '../underline';
const OTHER_BUBBLE_MENU_TYPES = [
Title.name,
Link.name,
Attachment.name,
Countdown.name,
Image.name,
@ -55,7 +54,14 @@ const OTHER_BUBBLE_MENU_TYPES = [
export const Text = ({ editor }) => {
const shouldShow = useCallback(() => {
return !editor.state.selection.empty && OTHER_BUBBLE_MENU_TYPES.every((type) => !editor.isActive(type));
if (editor.state.selection.empty) return false;
if (OTHER_BUBBLE_MENU_TYPES.some((type) => editor.isActive(type))) return false;
const selection = editor.state.selection;
const slice = selection.content();
const text = slice.content.textBetween(0, slice.content.size);
return text && text.length;
}, [editor]);
return (