Type Editor / @type-editor/selection-util / caret-from-point
caret-from-point
Functions
| Function | Description |
|---|---|
Gets the caret position from a point in the document. This function tries browser-specific methods to determine the DOM position (node and offset) at the given screen coordinates. It handles both Firefox's The offset is clipped to the node size to handle edge cases where browsers might return invalid offsets (e.g., text offsets into <input> nodes). Example typescript |