React.JS - Manage content of contenteditable div a

2020-06-12 05:26发布

问题:

I'm looking for methods of managing elements of contenteditable as React components.

Exploring Facebook's source via React DevTools extension reveals that they wrote a contenteditable comment editor that seems to be fully managed by React.

You can see in the components tree that updating the conteneditable triggers updates to components tree that are children of contenteditable.

回答1:

Facebook just released Draft.js - https://facebook.github.io/draft-js/



回答2:

update:

Facebook has released draft-js which is meant for building text editors with react. https://github.com/facebook/draft-js

original answer which is now outdated:

Go ahead, there is nothing special for this.

here are some examples:

  • https://github.com/lovasoa/react-contenteditable
  • https://github.com/liamzebedee/reactjs-contenteditable/blob/master/ContentEditable.jsx
  • https://stackoverflow.com/a/22678516/1536309