@markarenin/get-selection-more
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Get Selection More npm-version Build Status Coverage Status

Get Selection More

APIs

/**
 * Returns the selected text
 */
function getText(win?: Window): string
function getTextFromSelection(selection: Selection | null, win?: Window): string
/**
 * Returns the paragraph containing the selection text.
 */
function getParagraph(win?: Window): string
function getParagraphFromSelection(selection: Selection | null): string
/**
 * Returns the sentence containing the selection text.
 */
function getSentence(win?: Window): string
function getSentenceFromSelection(selection: Selection | null): string

Optionally pass window of other frame to get selection within that frame.

Usage

import { getText, getParagraph, getSentence } from 'get-selection-more'

document.addEventListener('selectionchange', () => {
  console.log(getText(), getParagraph(), getSentence())
})

Or load the UMD module directly which exposes getSelectionMore global.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.2
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.2
    4
  • 1.1.1
    0
  • 1.1.0
    0

Package Sidebar

Install

npm i @markarenin/get-selection-more

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

48.8 kB

Total Files

10

Last publish

Collaborators

  • markarenin