mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix: only show bubble to textContent
This commit is contained in:
1 parent
8ee564e952
commit
e9a8539305
2 files changed
+17
-29
No files matched your search
@@ -1,24 +1,16 @@
|
||||
import * as React from "react"
|
||||
import { Editor } from "@tiptap/react"
|
||||
import { ShouldShowProps } from "../types"
|
||||
import { isCustomNodeSelected, isTextSelected } from "../lib/utils"
|
||||
import { isTextSelected } from "../lib/utils"
|
||||
|
||||
export const useTextmenuStates = (editor: Editor) => {
|
||||
const shouldShow = React.useCallback(
|
||||
({ view, from }: ShouldShowProps) => {
|
||||
({ view }: ShouldShowProps) => {
|
||||
if (!view) {
|
||||
return false
|
||||
}
|
||||
|
||||
const domAtPos = view.domAtPos(from || 0).node as HTMLElement
|
||||
const nodeDOM = view.nodeDOM(from || 0) as HTMLElement
|
||||
const node = nodeDOM || domAtPos
|
||||
|
||||
if (isCustomNodeSelected(editor, node)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isTextSelected({ editor })
|
||||
return isTextSelected(editor)
|
||||
},
|
||||
[editor],
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user