最近在用slatejs开发table,在给表格添加按钮时遇到如下问题:
Cannot resolve a Slate point from DOM point: [object Text],10
查了issue找到了解决方案,需要在table周围的controller最外层加上 contentEditable={false}
,这样就不会报这个错误了。
case 'table':
return (
<div style={{ position: 'relative' }}>
<div>
<table>
<tbody {...attributes}>{children}</tbody>
</table>
</div>
<div contentEditable={false} style={{ position: 'absolute' }}>
<button
onClick={() => {}}
>
insert row
</button>
</div>
</div>
);