https://github.com/davidfig/easyedit
inline editing of a single HTMLElement
https://github.com/davidfig/easyedit
edit html inline-editing
Last synced: 12 months ago
JSON representation
inline editing of a single HTMLElement
- Host: GitHub
- URL: https://github.com/davidfig/easyedit
- Owner: davidfig
- License: mit
- Created: 2017-06-13T01:57:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T10:23:47.000Z (about 8 years ago)
- Last Synced: 2025-02-17T07:36:13.616Z (about 1 year ago)
- Topics: edit, html, inline-editing
- Language: JavaScript
- Homepage:
- Size: 518 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# easyedit
inline editing of a single HTMLElement
## rationale
Make any element editable with a click. The input element uses the same font and font-size as the original element. Pressing enter or changing focus saves the new value. Pressing escape returns it to its original value.
## simple example
const easyedit = require('easyedit')
const div = document.createElement('div')
document.body.appendChild(div)
div.innerHTML = 'Please edit me.'
new easyedit(div, { onsuccess: (value) => console.log('div changed to: ' + value) })
## live example
https://davidfig.github.io/easyedit/
## API
```js
/**
*
* @param {HTMLElement} object
* @param {object} options
* @param {object} options.styles - additional styles to apply to the inputElement
* @param {function} options.onedit - editing starts: callback(element, inputElement)
* @param {function} options.onsuccess - value changed and user pressed enter: callback(value, element, originalValue)
* @param {function} options.oncancel - editing canceled with escape: callback(element)
* @param {function} options.onchange - value was changed (but editing is not done): callback(value, element, originalValue)
*/
constructor(object, options)
```
## license
MIT License
(c) 2017 [YOPEY YOPEY LLC](https://yopeyopey.com/) by [David Figatner](https://twitter.com/yopey_yopey/)