Skip to content

createAnchorFromSelection

Anchors a popover at the caret — used by a command invoked from the keyboard, with the cursor already at the place being edited.

Import:

import { createAnchorFromSelection } from 'obsidian-dev-utils/obsidian/popovers/popover-anchor';

Signature:

function createAnchorFromSelection(doc: Document): PopoverAnchor

Parameters:

ParameterTypeDescription
docDocumentThe document holding the selection.

Returns: PopoverAnchor — The anchor, or a centered one when there is no caret to read.