Package Exports
- @wordpress/dom
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wordpress/dom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DOM
DOM utilities module for WordPress.
Installation
Install the module
npm install @wordpress/dom --saveAPI
# computeCaretRect
Get the rectangle for the selection in a container.
Parameters
- win
Window: The window of the selection.
Returns
?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.
Parameters
- doc
Document: The document to check.
Returns
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
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
Parameters
- doc
Document: The document to check.
Returns
boolean: True if there is selection, false if not.
# documentHasUncollapsedSelection
Check whether the current document has any sort of selection. This includes ranges of text across elements and any selection inside and