Skip to content
Get text and context (sentence, paragraph...) from window.getSelection().
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.editorconfig
.gitignore
.prettierrc
.travis.yml
LICENSE
README.md
karma.conf.js
package.json
rollup.config.js
tsconfig.json
tslint.json
yarn.lock

README.md

Get Selection More npm-version Build Status Coverage Status

APIs

/**
 * Returns the selected text
 */
export declare function getText(win?: Window): string;
/**
 * Returns the paragraph containing the selection text.
 */
export declare function getParagraph(win?: Window): string;
/**
 * Returns the sentence containing the selection text.
 */
export declare function getSentence(win?: Window): 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.

You can’t perform that action at this time.