Files
outline/shared/editor/queries/isMarkActive.ts
2024-06-08 21:51:52 -04:00

17 lines
415 B
TypeScript

import { MarkType } from "prosemirror-model";
import { EditorState } from "prosemirror-state";
export 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));
};