问题描述
我正在尝试更改内容块的块类型。我这样做的方法是复制 Notions UX 并在用户按下“/”时打开一个菜单。从那里他们可以选择列表中的一个选项,即 H1 标题。
function changeBlockType(type: string) {
const newEditorState = RichUtils.toggleBlockType(editorState,type);
if (newEditorState) {
setEditorState(newEditorState);
}
}
我正在使用功能组件,因此这会更改 editorState。
当我 console.log 当前内容块并检查时,我可以发现块类型已经改变(类型现在是“H1 heading”):
0: Array [ "key","fkj5e" ]
1: Array [ "text","/" ]
2: Array [ "type","H1 heading" ]
3: Array [ "characterList",{…} ]
但没有实际样式应用于编辑器。文本样式保持不变。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)