1.0.0 • Published 9 years ago

draw-selection v1.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

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