New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-selection-more

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-selection-more

Get text and context sentence from window.getSelection()

1.1.0
latest
Source
npm
Version published
Weekly downloads
42
68%
Maintainers
1
Weekly downloads
 
Created
Source

Get Selection More npm-version Build Status Coverage Status

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.

Keywords

getSelection

FAQs

Package last updated on 01 Sep 2019

Did you know?

Socket

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.

Install

Related posts