mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
Merge pull request #283 from StickyKnow/fix-nodeIsActive
fix nodeIsActive()
This commit is contained in:
commit
7d4ec06a87
@ -1,12 +1,16 @@
|
||||
import { findParentNode } from 'prosemirror-utils'
|
||||
import {
|
||||
findParentNode,
|
||||
findSelectedNodeOfType,
|
||||
} from 'prosemirror-utils'
|
||||
|
||||
export default function (state, type, attrs = {}) {
|
||||
const predicate = node => node.type === type
|
||||
const parent = findParentNode(predicate)(state.selection)
|
||||
const node = findSelectedNodeOfType(type)(state.selection)
|
||||
|| findParentNode(predicate)(state.selection)
|
||||
|
||||
if (!Object.keys(attrs).length || !parent) {
|
||||
return !!parent
|
||||
if (!Object.keys(attrs).length || !node) {
|
||||
return !!node
|
||||
}
|
||||
|
||||
return parent.node.hasMarkup(type, attrs)
|
||||
return node.node.hasMarkup(type, attrs)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user