Skip to content

Commit

Permalink
fix: improve isActive check for floating menu when using custom doc c…
Browse files Browse the repository at this point in the history
…ontent, fix #1205
  • Loading branch information
philippkuehn committed Apr 23, 2021
1 parent cd595b8 commit b84a56a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/extension-floating-menu/src/floating-menu-plugin.ts
Original file line number Diff line number Diff line change
@@ -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 { EditorView } from 'prosemirror-view'
import tippy, { Instance, Props } from 'tippy.js'
Expand Down Expand Up @@ -95,9 +95,8 @@ export class FloatingMenuView {
to,
} = selection
const isRootDepth = $anchor.depth === 1
const isDefaultNodeType = $anchor.parent.type === state.doc.type.contentMatch.defaultType
const isDefaultNodeEmpty = isNodeEmpty(selection.$anchor.parent)
const isActive = isRootDepth && isDefaultNodeType && isDefaultNodeEmpty
const isNodeEmpty = !selection.$anchor.parent.isLeaf && !selection.$anchor.parent.textContent
const isActive = isRootDepth && isNodeEmpty

if (!empty || !isActive) {
this.hide()
Expand Down

0 comments on commit b84a56a

Please sign in to comment.