mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 17:43:49 +08:00
13 lines
304 B
JavaScript
13 lines
304 B
JavaScript
import { findParentNode } from 'prosemirror-utils'
|
|
|
|
export default function (state, type, attrs) {
|
|
const predicate = node => node.type === type
|
|
const parent = findParentNode(predicate)(state.selection)
|
|
|
|
if (attrs === {} || !parent) {
|
|
return !!parent
|
|
}
|
|
|
|
return parent.node.hasMarkup(type, attrs)
|
|
}
|