obsidian/popovers/popover-anchor
The resolved position a popover is placed at.
A popover takes a resolved anchor rather than an element because callers know the position in different ways: a clicked element has a rect, a context menu has the pointer that opened it, and a keyboard-invoked command has the caret. Each way gets its own builder here, so the popover itself stays unaware of how the position was found.
This lives apart from the popover shell so that anything producing an anchor — most notably PointerPositionComponent — depends only on the position, not on the panel that consumes it.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| PopoverAnchor | Where a popover is placed: viewport coordinates plus the document they belong to. Carrying the document explicitly is what makes an anchor inside a pop-out window work — the popover is appended to, and clamped against, that window rather than the main one. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| createAnchorFromDocumentCenter | Anchors a popover in the middle of the document, for the cases where nothing better is known. |
| createAnchorFromElement | Anchors a popover just below an element — used for a clicked element, whose rect is exactly where the user is looking. |
| createAnchorFromPoint | Anchors a popover at a pointer position — used for a context menu, which is raised by a right-click or a long-press whose coordinates are where the user is looking. |
| createAnchorFromSelection | Anchors a popover at the caret — used by a command invoked from the keyboard, with the cursor already at the place being edited. |