fix: improve isActive check for floating menu when using custom doc content, fix #1205
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Editor, isNodeEmpty, posToDOMRect } from '@tiptap/core'
|
import { Editor, posToDOMRect } from '@tiptap/core'
|
||||||
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
|
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
|
||||||
import { EditorView } from 'prosemirror-view'
|
import { EditorView } from 'prosemirror-view'
|
||||||
import tippy, { Instance, Props } from 'tippy.js'
|
import tippy, { Instance, Props } from 'tippy.js'
|
||||||
@@ -95,9 +95,8 @@ export class FloatingMenuView {
|
|||||||
to,
|
to,
|
||||||
} = selection
|
} = selection
|
||||||
const isRootDepth = $anchor.depth === 1
|
const isRootDepth = $anchor.depth === 1
|
||||||
const isDefaultNodeType = $anchor.parent.type === state.doc.type.contentMatch.defaultType
|
const isNodeEmpty = !selection.$anchor.parent.isLeaf && !selection.$anchor.parent.textContent
|
||||||
const isDefaultNodeEmpty = isNodeEmpty(selection.$anchor.parent)
|
const isActive = isRootDepth && isNodeEmpty
|
||||||
const isActive = isRootDepth && isDefaultNodeType && isDefaultNodeEmpty
|
|
||||||
|
|
||||||
if (!empty || !isActive) {
|
if (!empty || !isActive) {
|
||||||
this.hide()
|
this.hide()
|
||||||
|
|||||||
Reference in New Issue
Block a user