Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/component/split-at-cursor
split element blocks at the cursor
https://github.com/component/split-at-cursor
Last synced: 13 days ago
JSON representation
split element blocks at the cursor
- Host: GitHub
- URL: https://github.com/component/split-at-cursor
- Owner: component
- Created: 2014-01-10T15:55:05.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-01T06:55:59.000Z (over 10 years ago)
- Last Synced: 2024-12-08T10:36:52.572Z (20 days ago)
- Language: JavaScript
- Homepage:
- Size: 202 KB
- Stars: 6
- Watchers: 8
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# split-at-cursor
split element blocks at the cursor. useful for inserting elements in between content.
## Installation
Install with [component(1)](http://component.io):
$ component install component/split-at-cursor
## Example
```js
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