draw-selection

1.0.0 • Public • Published

draw-selection

A node module for drawing boxes around a DOM selection.

Install

npm install draw-selection

Run

drawSelection([containerEl [, styles]])

args

  • containerEl - (optional) Element to insert the boxes (assumes the selection is relative to that container)
  • styles - (optional) object that contains CSS properties and values to apply to the boxes (default { outline: '1px solid red', 'pointer-events': 'none' })

returns

  • els - an array of Elements that were created
<html>
<body>
<p>hello, world!</p>
</body>
</html>
 
var drawSelection = require('draw-selection')
var sel = window.getSelection()
sel.removeAllRanges()
 
var range = document.createRange()
range.selectNode(document.querySelector('p'))
sel.addRange(range)
 
drawSelection({
  outline: '1px inset blue'
})

License

(The MIT License)

Copyright 2015 Cameron Lakenen

Readme

Keywords

Package Sidebar

Install

npm i draw-selection

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • lakenen