@wordpress/dom Edit

DOM utilities module for WordPress.

Installation Installation

Install the module

npm install @wordpress/dom --save

Top ↑


# computeCaretRect

Get the rectangle for the selection in a container.


  • ?DOMRect: The rectangle.

# documentHasSelection

Check whether the current document has a selection. This checks for both
focus in an input field and general text selection.


  • boolean: True if there is selection, false if not.

# documentHasTextSelection

Check whether the current document has selected text. This applies to ranges
of text in the document, and not selection inside and