mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 20:08:59 +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 tippyOptions?: Partial<Props>
|
||||||
|
|
||||||
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state }) => {
|
public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state, view }) => {
|
||||||
const { selection } = state
|
const { selection } = state
|
||||||
const { $anchor, empty } = selection
|
const { $anchor, empty } = selection
|
||||||
const isRootDepth = $anchor.depth === 1
|
const isRootDepth = $anchor.depth === 1
|
||||||
@ -41,6 +41,10 @@ export class FloatingMenuView {
|
|||||||
&& !$anchor.parent.type.spec.code
|
&& !$anchor.parent.type.spec.code
|
||||||
&& !$anchor.parent.textContent
|
&& !$anchor.parent.textContent
|
||||||
|
|
||||||
|
if (!view.hasFocus()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty || !isRootDepth || !isEmptyTextBlock) {
|
if (!empty || !isRootDepth || !isEmptyTextBlock) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user