小编Nau*_*ast的帖子

使用slatejs在编辑器中的光标处插入图像

我正在尝试使用reactjs和slate.js实现Rich Text编辑器。到目前为止,我能够使大多数功能正常运行,但是无法在光标处向文档添加图像不起作用(但是,在文档开始处插入图像仍有效)。

当IAM尝试将其插入任何其他点时IAM收到错误。在renderpart处,即执行编辑器的onchange方法。

    const target = getEventRange(e, this.state.EditorComp.state.value)
change = this.state.EditorComp.state.value.change().call(this.insertImage, filelocation,target)
this.state.EditorComp.onChange(change);
Run Code Online (Sandbox Code Playgroud)

slate-react.es.js:1229 Uncaught Error: Unable to find a DOM node for "51". This is often because of forgetting to add `props.attributes` to a custom component.
at findDOMNode$1 (slate-react.es.js:1229)
at findDOMPoint (slate-react.es.js:1247)
at findDOMRange (slate-react.es.js:1290)
Run Code Online (Sandbox Code Playgroud)

我的代码基于链接https://github.com/ianstormtaylor/slate/blob/master/examples/images/index.js

请帮忙。

image insertion reactjs slatejs

2
推荐指数
1
解决办法
1514
查看次数

标签 统计

image ×1

insertion ×1

reactjs ×1

slatejs ×1