bmcmahen / react-wysiwyg

retain some control over contenteditable input
169 stars 37 forks source link

Could not edit content. Have much errors. #42

Open bvn13 opened 7 years ago

bvn13 commented 7 years ago

Uncaught Error: traverseParentPath(...): Cannot traverse from and to the same ID, ``. at invariant (invariant.js:39) at traverseParentPath (ReactInstanceHandles.js:157) at Object.traverseAncestors (ReactInstanceHandles.js:285) at findDeepestCachedAncestor (ReactMount.js:234) at Object.findComponentRoot (ReactMount.js:708) at Object.findReactNodeByID (ReactMount.js:679) at Object.getNodeFromInstance (ReactMount.js:180) at Object.findDOMNode (findDOMNode.js:43) at Constructor.setCursorToStart (index.js:155) at Constructor.onMouseDown (index.js:189)

Errors occure on every key down. Here is my rendering: ` <ContentEditable id="emailBodyEditor" tagName='div' onChange={this.onChangeEmailBody} html={this.state.data.emailBody} preventStyling noLinebreaks placeholder={this.state.emailBodyPlaceholder} placeholderText='Put text here' editing={true} />

onChangeEmailBody(textContent, setPlaceholder) { if (setPlaceholder) { this.setState({ emailBodyPlaceholder: true, }); this.setData({ emailBody : '' }); } else { this.setState({ emailBodyPlaceholder: false, }); this.setData({ emailBody : textContent }); } }

setData(newData, isChanged=true, callback=null) { var data = this.state.data; _.forEach(newData, function(val, key) { data[key] = val; }); this.setState({ data : data }, ()=>{ if (callback) { callback(); } }); this.dataIsChanged = isChanged; } `