"Cannot resolve a Slate point from DOM point" for non-editable text rendered inside of Element
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What’s the current behavior?
When selecting (supposed to be) non-editable text that is rendered inside of an element, I am seeing an error “Cannot resolve a Slate point from DOM point”. My usecase is to have a prefix that isn’t editable, but explains the purpose of the block.
Slate: 0.57.1 Browser: Chrome 79.0.3945.117 OS: MacOS 10.15.2 (19C57)
VM469:1691 Uncaught Error: Cannot resolve a Slate point from DOM point: [object Text],7
at Object.toSlatePoint (eval at Dr (eval.js:61), <anonymous>:1691:13)
at Object.toSlateRange (eval at Dr (eval.js:61), <anonymous>:1736:30)
at HTMLDocument.eval (eval at Dr (eval.js:61), <anonymous>:800:43)
at later (eval at Dr (eval.js:61), <anonymous>:27:23)
toSlatePoint @ VM469:1691
toSlateRange @ VM469:1736
eval @ VM469:800
later @ VM474:27
setTimeout (async)
later @ VM474:23
setTimeout (async)
later @ VM474:23
setTimeout (async)
later @ VM474:23
setTimeout (async)
debounced @ VM474:38
What’s the expected behavior?
To see no error, and have Slate ignore the non-editable text.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:17 (1 by maintainers)
Top Results From Across the Web
Error: Cannot resolve a DOM point from Slate point
In my case, I was taking a populated editor with a bunch of text and tried to reset it back to it's original...
Read more >"Cannot resolve a Slate point from DOM point" for non ...
What's the current behavior? When selecting (supposed to be) non-editable text that is rendered inside of an element, I am seeing an error...
Read more >Newest 'slatejs' Questions - Stack Overflow
Slate React: cannot redefine element's text. I use Slate editor in my React app. I've created the custom inline tool called 'company'. Once...
Read more >Slate Editor Issue: Cannot resolve a DOM point from ... - Reddit
This is the code I am using to add my custom link DOM element into slate editor at current cursor position. window.addEventListener("message", ( ......
Read more >Slate React
React components for rendering Slate editors ... Get the current readOnly state of the editor. ... Find a native DOM selection point from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is kind of strange, but I think a hack solution is to use both a CSS style and an HTML attribute.
✅ For example, this works to render elements:
🛑 But oddly, this doesn’t work:
🛑 Nor does this:
I added these examples to the example code sandbox above.
I say this is a “hack solution” because ideally all you would need is
contentEditable={false}
to avoid this problem. An example usecase for this: you might want to let users select this non-editable text, anduserSelect: none
CSS prevents that.NOTE: This does not seem to stop the error from happening when doubleclicking into a child, and selecting all of the text. It seems to sometimes stop it, but not always. This specifically stops the error from happening when selecting or clicking on the non-interactive text specfically.
I ran into this problem when rendering nothing in the slate component, since the introduction tutorial starts off with nothing in the
useState([])
. So I guess it tries to render an empty array, but has nothing to put the values into at the start.To solve this, I set this as the default value: