MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / getIndexedElements

Function getIndexedElements

packages/app-core/src/components/VimNav.tsx:1719–1739  ·  view source on GitHub ↗
(
    selector: string,
    datasetKey: IndexedDatasetKey
  )

Source from the content-addressed store, hash-verified

1717 }
1718
1719 function getIndexedElements(
1720 selector: string,
1721 datasetKey: IndexedDatasetKey
1722 ): HTMLElement[] {
1723 return [...document.querySelectorAll<HTMLElement>(selector)]
1724 .filter((el) => el.getClientRects().length > 0)
1725 .sort((a, b) => {
1726 const aRect = a.getBoundingClientRect()
1727 const bRect = b.getBoundingClientRect()
1728 const rowDelta = aRect.top - bRect.top
1729
1730 // Follow the actual rendered row order first, then fall back
1731 // to the assigned index for stable ordering within the same row.
1732 if (Math.abs(rowDelta) > 2) return rowDelta
1733
1734 const colDelta = aRect.left - bRect.left
1735 if (Math.abs(colDelta) > 2) return colDelta
1736
1737 return getIndexedValue(a, datasetKey) - getIndexedValue(b, datasetKey)
1738 })
1739 }
1740
1741 function getIndexedValue(
1742 el: HTMLElement | null,

Callers 6

handlerFunction · 0.85
handleSidebarKeyFunction · 0.85
handleNoteListKeyFunction · 0.85
handleConnectionsKeyFunction · 0.85
handleHoverPreviewKeyFunction · 0.85
getCommentItemsFunction · 0.85

Calls 1

getIndexedValueFunction · 0.85

Tested by

no test coverage detected