selection-ranges

WebJar for selection-ranges

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

selection-ranges
Последняя версия

Последняя версия

3.0.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

selection-ranges
WebJar for selection-ranges
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/nikku/selection-ranges

Скачать selection-ranges

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/selection-ranges/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>selection-ranges</artifactId>
    <version>3.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/selection-ranges/
implementation 'org.webjars.npm:selection-ranges:3.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/selection-ranges/
implementation ("org.webjars.npm:selection-ranges:3.0.3")
'org.webjars.npm:selection-ranges:jar:3.0.3'
<dependency org="org.webjars.npm" name="selection-ranges" rev="3.0.3">
  <artifact name="selection-ranges" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='selection-ranges', version='3.0.3')
)
libraryDependencies += "org.webjars.npm" % "selection-ranges" % "3.0.3"
[org.webjars.npm/selection-ranges "3.0.3"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : dom-iterator jar [1.0.0,2)

Модули Проекта

Данный проект не имеет модулей.

selection-ranges

Build Status

Manipulate selection ranges on contenteditable elements.

API

/**
 * 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);

Usage

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

Features

  • Works around browser issues and correctly handles <br/> and paragraph elements
  • Correctly handles out-of-bounds selections

Related

  • selection-update - compute input selection updates on external content changes

License

MIT

Версии библиотеки

Версия
3.0.3