0.0.2 • Published 10 years ago

split-at-cursor v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

split-at-cursor

split element blocks at the cursor. useful for inserting elements in between content.

Installation

Install with component(1):

$ component install component/split-at-cursor

Example

var editor = document.getElementById('editor');
var parent = editor.parentNode;

btn.onclick = function() {
  var el = split(editor);
  var hr = document.createElement('hr');

  parent.appendChild(hr);
  parent.appendChild(el);
}

API

split(el)

Split the DOM tree of el at the cursor. Returns a clone of el containing the right half of the DOM tree.

Test

npm install
make test

License

MIT

0.0.2

10 years ago