text-element-lines
v1.0.0
Published
An efficient library for extracting text lines from a DOM element.
Readme
text-element-lines
An efficient library for extracting text lines from a DOM element.
- Efficently tracks mutations to the DOM node and updates the in-memory state
- Uses a binary search to find wrapping points of each line
- Detects block elements and allows you to differentiate between wrapping newlines & block element induced newlines (
\r\nvs\n) - Easy to use methods exported
Usage
import { extractLines, extractTextFromLines } from "text-element-lines";
for (const line of extractLines(element)) {
console.log(line.index, line.blockParent, line.innerText);
}
console.log(extractTextFromLines(element))