Files
outline/shared/editor/queries/isInList.ts
Tom Moor bf45e97641 chore: Enforce type import consistency (#10968)
* Update types

* fix circular dep

* type imports

* lint type imports and --fix
2025-12-19 23:07:02 -05:00

24 lines
588 B
TypeScript

import type { EditorState } from "prosemirror-state";
/**
* Check if the current selection is in a list
*
* @param state - The current editor state
* @param options - Optionally check for specific list types
*/
export function isInList(state: EditorState, options?: { types: string[] }) {
const $head = state.selection.$head;
for (let d = $head.depth; d > 0; d--) {
if (
(options?.types
? options.types
: ["ordered_list", "bullet_list", "checkbox_list"]
).includes($head.node(d).type.name)
) {
return true;
}
}
return false;
}