chore: Move editor into codebase (#2930)
This commit is contained in:
14
shared/editor/queries/getParentListItem.ts
Normal file
14
shared/editor/queries/getParentListItem.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Node } from "prosemirror-model";
|
||||
import { EditorState } from "prosemirror-state";
|
||||
|
||||
export default function getParentListItem(
|
||||
state: EditorState
|
||||
): [Node, number] | void {
|
||||
const $head = state.selection.$head;
|
||||
for (let d = $head.depth; d > 0; d--) {
|
||||
const node = $head.node(d);
|
||||
if (["list_item", "checkbox_item"].includes(node.type.name)) {
|
||||
return [node, $head.before(d)];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user