Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom.moor@gmail.com>
19 lines
438 B
TypeScript
19 lines
438 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;
|