
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
selection-ranges
Advanced tools
Manipulate selection ranges on contenteditable
elements.
/**
* Return the selection on the given element as {start, end}.
*
* @param {Element} el
*
* @return {Object} selection range or null if element is not selected
*/
getRange(el);
/**
* Selects the given range on the specified element.
*
* @param {Element} el
* @param {Object} range {start, end}
*/
setRange(el, range);
/**
* Return true if element is part of window selection.
*
* @param {Element} el
* @return {Boolean}
*/
isSelected(el);
import {
getRange,
setRange
} from 'selection-ranges';
var node = <div contenteditable />;
let range = getRange(node);
// a range such as { start: 5, end: 10 }
// or null if node is currently not selected
setRange(node, { start: 0, end: 30 });
// sets selection range to child nodes; does not focus node
<br/>
and paragraph elementsMIT
4.0.3
DEPS
: update to dom-iterator@1.0.2
(#7)FAQs
Selection range manipulation for contenteditable elements
We found that selection-ranges demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.