3

Does anyone have any luck adapting Draft.js for Reagent? There's pretty heavy editing issues if Draft.js is imported right away via reagent/adapt-react-class. Cursor jumps, disappearing symbols when you're typing, onChange calls with incorrect EditorState, you name it.

People are reporting problems like this in clojurians/reagent Slack channel, but it seems there's no solution so far.

Any help would be greatly appreciated.

4

2 回答 2

4

好的,多亏了tosky,我得到了答案。试剂/朗姆酒正在使用延迟渲染requestAnimationFrame,但Draft.Editor应在editorState设置后立即重新渲染。

我们只需要在调用forceUpdate编辑器时调用编辑器父组件onChange

:editorState @editor-state-atom
:onChange    (fn [new-state]
               (reset! editor-state-atom new-state)
               (.forceUpdate @wrapper-state))

代码示例适用于试剂,朗姆酒的解决方案相同

于 2016-06-21T18:01:36.073 回答
0

只是一个想法(更多的评论,但我还不能提供评论),因为 - 如果我没记错的话 - :content-editable 属性在 Reagent 中以特殊方式处理:

由于从 Reagent 调用 Draftjs 编辑器时似乎会出现问题,因此将 Reagent-component 转换为 React-component(使用 reagent/reactify-component),然后使用此“反应”组件作为反应是否无济于事- 试剂中的组件,使用试剂/创建元素?我会假设 Reagent 然后避免干预 Draftjs 编辑器。

于 2016-06-09T17:50:54.830 回答