mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 01:12:56 +08:00
fix: show FloatingMenu by default only if focused (#2275)
This commit is contained in:
parent
0e0cdc053f
commit
809af3b6c6
@ -33,7 +33,7 @@ export class FloatingMenuView {
|
||||
|
||||
public tippyOptions?: Partial<Props>
|
||||
|
||||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state }) => {
|
||||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state, view }) => {
|
||||
const { selection } = state
|
||||
const { $anchor, empty } = selection
|
||||
const isRootDepth = $anchor.depth === 1
|
||||
@ -41,6 +41,10 @@ export class FloatingMenuView {
|
||||
&& !$anchor.parent.type.spec.code
|
||||
&& !$anchor.parent.textContent
|
||||
|
||||
if (!view.hasFocus()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!empty || !isRootDepth || !isEmptyTextBlock) {
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user