diff --git a/server/src/workflow-management/selector.ts b/server/src/workflow-management/selector.ts index 94b6269a..d1c5c17d 100644 --- a/server/src/workflow-management/selector.ts +++ b/server/src/workflow-management/selector.ts @@ -361,6 +361,33 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => { }; } + function index(input: Element): number | null { + const parent = input.parentNode; + if (!parent) { + return null; + } + + let child = parent.firstChild; + if (!child) { + return null; + } + + let i = 0; + while (child) { + if (child.nodeType === Node.ELEMENT_NODE) { + i++; + } + + if (child === input) { + break; + } + + child = child.nextSibling; + } + + return i; + } + };