fix nodeIsActive()
this fixes isActive.image() mentioned in #225 nodeIsActive was only checking parent nodes and missed the node currently selected.
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
import { findParentNode } from 'prosemirror-utils'
|
import {
|
||||||
|
findParentNode,
|
||||||
|
findSelectedNodeOfType,
|
||||||
|
} from 'prosemirror-utils'
|
||||||
|
|
||||||
export default function (state, type, attrs = {}) {
|
export default function (state, type, attrs = {}) {
|
||||||
const predicate = node => node.type === type
|
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) {
|
if (!Object.keys(attrs).length || !node) {
|
||||||
return !!parent
|
return !!node
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent.node.hasMarkup(type, attrs)
|
return node.node.hasMarkup(type, attrs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user