17 lines
418 B
TypeScript
17 lines
418 B
TypeScript
import { MarkType } from "prosemirror-model";
|
|
import { EditorState } from "prosemirror-state";
|
|
|
|
const isMarkActive = (type: MarkType) => (state: EditorState): boolean => {
|
|
if (!type) {
|
|
return false;
|
|
}
|
|
|
|
const { from, $from, to, empty } = state.selection;
|
|
|
|
return !!(empty
|
|
? type.isInSet(state.storedMarks || $from.marks())
|
|
: state.doc.rangeHasMark(from, to, type));
|
|
};
|
|
|
|
export default isMarkActive;
|