Nau*_*ast 2 image insertion reactjs 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
请帮忙。
小智 6
您是否为编辑器定义了架构?在为设置isVoid为true的图像添加架构之前,我都遇到了同样的错误。您的架构中至少需要满足以下条件:
const schema = {
blocks: {
image: {
isVoid: true
}
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1514 次 |
| 最近记录: |