diff --git a/packages/core/src/toolmenu/index.tsx b/packages/core/src/toolmenu/index.tsx index 4a24cf9..0a3a53e 100644 --- a/packages/core/src/toolmenu/index.tsx +++ b/packages/core/src/toolmenu/index.tsx @@ -1,5 +1,5 @@ import { useCallback } from 'react'; -import { Path } from 'slate'; +import { Path, last } from 'slate'; import { useSlate } from 'slate-react'; import { CopyIcon } from '../components/icons/copy'; import { DustboxIcon } from '../components/icons/dustbox'; @@ -39,6 +39,10 @@ export const Toolmenu: React.FC = ({ path, onDone }) => { return; } const lastOffset = lastTextNode.text.length; + if (!lastOffset) { + onDone(); + return; + } editor.selection = { anchor: { path: [...path, 0],