blob: bc0f9a5b2e88918e86e6fc8009d39585655d5988 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const findDOMNode = require('react-dom').findDOMNode
module.exports = EditableLabel
inherits(EditableLabel, Component)
function EditableLabel () {
Component.call(this)
}
EditableLabel.prototype.render = function () {
return h('div.name-label', {
contentEditable: true,
style: { outline: 'none' },
onInput: (event) => this.saveText(),
}, this.props.children)
}
EditableLabel.prototype.saveText = function () {
var text = findDOMNode(this).textContent.trim()
var truncatedText = text.substring(0, 20)
this.props.saveText(truncatedText)
this.setState({ isEditingLabel: false, textLabel: truncatedText })
}
|