A simple inline text editor for React with ECMAScript 6 + JSX Harmony syntax
npm install react-edit-inplace> This is a fork to the now unmaintained project react-inline-edit.
> Only minimal maintainance will be provided, and __no new features will be accepted__.

This is a simple React component for in-place text editing. It turns into an when focused, and tries to validate and save input on Enter or blur. Esc works as well for cancelling.
Watch a demo, then check out demo/index.jsx for a quick example.
npm install --save react-edit-inplace
text:string initial textparamName:string name of the parameter to be returned to change functionchange:function function to call when new text is changed and validated, it will receive {paramName: value}className:_string_ CSS class nameactiveClassName:_string_ CSS class replacement for when in edit modevalidate:_function_ boolean function for custom validation, using this overrides the two props belowminLength:_number_ minimum text length, default 1maxLength:_number_ maximum text length, default 256editingElement:_string_ element name to use when in edit mode (DOM must have value property) default inputstaticElement:_string_ element name for displaying data default spanediting:_boolean_ If true, element will be in edit modetabIndex:_number_ tab index used for focusing with TAB key default 0stopPropagation:_boolean_ If true, the event onClick will not be further propagated.javascript
import React from 'react';
import InlineEdit from 'react-edit-inplace';class MyParentComponent extends React.Component {
constructor(props){
super(props);
this.dataChanged = this.dataChanged.bind(this);
this.state = {
message: 'ReactInline demo'
}
}
dataChanged(data) {
// data = { description: "New validated text comes here" }
// Update your model from here
console.log(data)
this.setState({...data})
}
customValidateText(text) {
return (text.length > 0 && text.length < 64);
}
render() {
return (
{this.state.message}
Edit me:
validate={this.customValidateText}
activeClassName="editing"
text={this.state.message}
paramName="message"
change={this.dataChanged}
style={{
backgroundColor: 'yellow',
minWidth: 150,
display: 'inline-block',
margin: 0,
padding: 0,
fontSize: 15,
outline: 0,
border: 0
}}
/>
)
}
}
``