fix: show FloatingMenu by default only if focused (#2275)

This commit is contained in:
Julian Hundeloh
2021-12-15 09:04:41 +01:00
committed by GitHub
parent 0e0cdc053f
commit 809af3b6c6

View File

@@ -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
}