mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 17:07:49 +08:00
18 lines
376 B
TypeScript
18 lines
376 B
TypeScript
|
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)
|
||
|
}
|