mirror of https://github.com/fantasticit/think.git
improve text-bubble-menu
This commit is contained in:
parent
1d32808335
commit
210adf583b
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue