margox / braft-editor

美观易用的React富文本编辑器,基于draft-js开发
MIT License
4.6k stars 592 forks source link

关于自定义block回显问题 #894

Open wooktao opened 3 years ago

wooktao commented 3 years ago

大佬,近期在开发时遇到的问题。自定义block插入后。调用toHTML()格式化后,接口保存 再次进入回显的时候就会有问题(样式丢失。格式混乱)

useEffect(() => { editorRef.current.setValue(BraftEditor.createEditorState(content, { blockImportFn,blockExportFn })); }, [currentId]); //content 为请求到的html字符串 但是我如果直接在别的dom元素中解析这段html字符串 ,是正常的。样式 格式 内容都是正常的。

wooktao commented 3 years ago

找到问题了 使用RAW格式存储的话 样式丢失的问题就解决了

wooktao commented 3 years ago

有没有html直接转Raw的方法