Install a shortcut to append selected text to a as a Markdown quote.</body></html>
Перейти к файлу
Mu-An ✌️ Chiou 1501ab0a14 quoteSelection 2018-07-05 22:34:24 -04:00
examples quoteSelection 2018-07-05 22:34:24 -04:00
test quoteSelection 2018-07-05 22:34:24 -04:00
.babelrc quoteSelection 2018-07-05 22:34:24 -04:00
.eslintrc.json quoteSelection 2018-07-05 22:34:24 -04:00
.flowconfig quoteSelection 2018-07-05 22:34:24 -04:00
.gitignore quoteSelection 2018-07-05 22:34:24 -04:00
.travis.yml quoteSelection 2018-07-05 22:34:24 -04:00
LICENSE quoteSelection 2018-07-05 22:34:24 -04:00
README.md quoteSelection 2018-07-05 22:34:24 -04:00
package-lock.json quoteSelection 2018-07-05 22:34:24 -04:00
package.json quoteSelection 2018-07-05 22:34:24 -04:00
prettier.config.js quoteSelection 2018-07-05 22:34:24 -04:00
quote-selection.js quoteSelection 2018-07-05 22:34:24 -04:00

README.md

quoteSelection

Add selected text to a text area as a markdown quote.

Installation

$ npm install @github/quote-selection

Usage

import quoteSelection from '@github/quote-selection'
quoteSelection(quotableContainer, textarea)

HTML

<div class="js-quote-selection"><p>Text to quote</p></div>
<textarea class="js-textarea"></textarea>

JS

import quoteSelection from '@github/quote-selection'

document.addEventListener('keydown', function(event) {
  if (event.key === 'r' && !event.metaKey && !event.ctrlKey && !event.altKey) {
    const quoted = quoteSelection(
      document.querySelector('.js-quote-selection'),
      document.querySelector('.js-textarea')
    )
    if (quoted) event.preventDefault()
  }
})

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.