question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot resolve a Slate point from DOM point:

See original GitHub issue

error info

Uncaught Error: Cannot resolve a Slate point from DOM point: [object Text],3 at Object.toSlatePoint (index.es.js:618) at Object.toSlateRange (index.es.js:663) at index.es.js:1554 at commitHookEffectListMount (react-dom.development.js:19731) at commitLifeCycles (react-dom.development.js:19787) at commitLayoutEffects (react-dom.development.js:22803) at HTMLUnknownElement.callCallback (react-dom.development.js:188) at Object.invokeGuardedCallbackDev (react-dom.development.js:237) at invokeGuardedCallback (react-dom.development.js:292) at commitRootImpl (react-dom.development.js:22541) at unstable_runWithPriority (scheduler.development.js:653) at runWithPriority$1 (react-dom.development.js:11039) at commitRoot (react-dom.development.js:22381) at finishSyncRender (react-dom.development.js:21807) at performSyncWorkOnRoot (react-dom.development.js:21793) at react-dom.development.js:11089 at unstable_runWithPriority (scheduler.development.js:653) at runWithPriority$1 (react-dom.development.js:11039) at flushSyncCallbackQueueImpl (react-dom.development.js:11084) at flushSyncCallbackQueue (react-dom.development.js:11072) at Object.batchedUpdates$1 [as unstable_batchedUpdates] (react-dom.development.js:21862) at Object.e.onChange (index.es.js:964) at index.es.js:5321

##code demo

const [value, setValue] = useState<Node[]>(initialValue)
  const editor = useMemo(() => withHistory(withReact(createEditor())), [])
  return (
    <Slate editor={editor} value={value} onChange={value => setValue(value)}>
      <Editable placeholder="Enter some plain text..." />
    </Slate>
  )

I use placeholder in Editable, and when I input, I first input in English mode, then delete all characters, and then switch to Chinese input, this time an error will occur.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:18
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
Silvercastcommented, Mar 18, 2021

It would break if the initial empty value is like this [] . I found the trick to set empty value as below, it’s weird that we have no official documentation or fix on such issue.

const EMPTY_VALUE = [{ type: "paragraph", children: [{ text: "" }] }];
const [value, setValue] = useState<Node[]>(EMPTY_VALUE);
1reaction
AndrejGajdoscommented, Jan 19, 2022

@Silvercast it breaks ExitBreakPlugin and when I use this it works correctly:

const EMPTY_VALUE = [
    {
        children: [
            {
                type: 'paragraph',
                children: [{ text: '' }]
            }
        ]
    }
];
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot resolve a Slate point from DOM point" for non ...
When selecting (supposed to be) non-editable text that is rendered inside of an element, I am seeing an error "Cannot resolve a Slate...
Read more >
Error: Cannot resolve a DOM point from Slate point
So the underlying issue that causes the aforementioned error is that the new value being sent to the editor is significantly different, and...
Read more >
Slate Editor Issue: Cannot resolve a DOM point from ... - Reddit
The above error is thrown when I add a custom link into a slate editor at current cursor position and use tab or...
Read more >
Slate Editor Issue: Cannot resolve a DOM point from Slate ...
Description: The error is thrown when I add a custom link into a slate editor at current cursor position and use tab or...
Read more >
Point - Slate
A point in a Slate Document . Points in Slate are inspired by the DOM Range API, with terms like "offset".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found