Skip to content

Commit

Permalink
Merge pull request #35 from ksavenkov/master
Browse files Browse the repository at this point in the history
modify for react 0.14
  • Loading branch information
bmcmahen committed Nov 9, 2015
2 parents 257e760 + 4c3c636 commit c4cd0fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

var React = require('react')
var ReactDOM = require('react-dom')
var classNames = require('classnames')
var escapeHTML = require('escape-html')
var isServer = typeof window === 'undefined'
Expand Down Expand Up @@ -56,7 +57,7 @@ var ContentEditable = React.createClass({
},

shouldComponentUpdate: function(nextProps) {
var el = React.findDOMNode(this)
var el = ReactDOM.findDOMNode(this)
if (nextProps.html !== el.innerHTML) {
if (nextProps.html && document.activeElement === el) {
this._range = selectionRange(el)
Expand Down Expand Up @@ -89,13 +90,13 @@ var ContentEditable = React.createClass({
}

if (this._range) {
selectionRange(React.findDOMNode(this), this._range)
selectionRange(ReactDOM.findDOMNode(this), this._range)
delete this._range
}
},

autofocus: function(){
React.findDOMNode(this).focus();
ReactDOM.findDOMNode(this).focus();
},

render: function() {
Expand Down Expand Up @@ -126,6 +127,7 @@ var ContentEditable = React.createClass({
// return our newly created element
return React.createElement(tagName, {
tabIndex: 0,
key: '0',
className: classNames(classes),
contentEditable: editing,
onBlur: this.onBlur,
Expand All @@ -150,10 +152,10 @@ var ContentEditable = React.createClass({
},

setCursorToStart: function(){
React.findDOMNode(this).focus();
ReactDOM.findDOMNode(this).focus();
var sel = window.getSelection();
var range = document.createRange();
range.setStart(React.findDOMNode(this), 0);
range.setStart(ReactDOM.findDOMNode(this), 0);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
Expand Down Expand Up @@ -289,7 +291,7 @@ var ContentEditable = React.createClass({
e.preventDefault();
var data = e.clipboardData.getData('text/plain')
this._replaceCurrentSelection(data);
var target = React.findDOMNode(this)
var target = ReactDOM.findDOMNode(this)
this.props.onChange(target.textContent, false, target.innerHTML)
},

Expand All @@ -304,7 +306,7 @@ var ContentEditable = React.createClass({
return
}

var target = React.findDOMNode(this)
var target = ReactDOM.findDOMNode(this)
var self = this

if (!target.textContent.trim().length) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-wysiwyg",
"version": "2.2.0",
"version": "2.2.1",
"description": "enable limited interaction with a content editable element, useful for in-place, wysiwyg editing",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -45,6 +45,8 @@
"dependencies": {
"classnames": "^2.1.1",
"escape-html": "^1.0.2",
"react": "^0.14.2",
"react-dom": "^0.14.2",
"selection-range": "^1.0.1"
},
"jest": {
Expand Down

0 comments on commit c4cd0fe

Please sign in to comment.