chore: Move editor into codebase (#2930)
This commit is contained in:
15
shared/editor/queries/isInCode.ts
Normal file
15
shared/editor/queries/isInCode.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { EditorState } from "prosemirror-state";
|
||||
import isMarkActive from "./isMarkActive";
|
||||
|
||||
export default function isInCode(state: EditorState): boolean {
|
||||
if (state.schema.nodes.code_block) {
|
||||
const $head = state.selection.$head;
|
||||
for (let d = $head.depth; d > 0; d--) {
|
||||
if ($head.node(d).type === state.schema.nodes.code_block) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isMarkActive(state.schema.marks.code_inline)(state);
|
||||
}
|
||||
Reference in New Issue
Block a user