mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
add markIsActive
This commit is contained in:
parent
adfa7f0243
commit
b26bb4b276
17
packages/tiptap-core/src/utils/markIsActive.ts
Normal file
17
packages/tiptap-core/src/utils/markIsActive.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { EditorState } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
|
||||
export default function markIsActive(state: EditorState, type: MarkType) {
|
||||
const {
|
||||
from,
|
||||
$from,
|
||||
to,
|
||||
empty,
|
||||
} = state.selection
|
||||
|
||||
if (empty) {
|
||||
return !!type.isInSet(state.storedMarks || $from.marks())
|
||||
}
|
||||
|
||||
return !!state.doc.rangeHasMark(from, to, type)
|
||||
}
|
Loading…
Reference in New Issue
Block a user