On page load, ReactEditor.toSlateRange calls ReactEditor.toSlatePoint which throws an exception because ReactEditor.toSlatePoint does not find a valid textNode through the algorithm inside it. I do not know how to make sure this is not the same issue as https://github.com/ianstormtaylor/slate/issues/3421. The steps to reproduce are many, but if there is interest I will write them, at least so I can get help.
The starting piece of code is taken from here (yes, it is a hack to solve another Slate issue temporarily):
if (!editor.selection) {
const sel = window.getSelection();
if (sel && sel.rangeCount > 0) {
debugger;
const s = ReactEditor.toSlateRange(editor, sel);
// Maybe do a comparison of s with editor.selection through Range.equals
// before giving a new reference to the editor.selection?
editor.selection = s;
}
}
So, everything begins with this call from the above written code:
ReactEditor.toSlateRange(editor, sel);
Before this call:
editor.selection is null
editor.children is:
sel is:
These are the relevant parts of the code as I was debugging:
The final error visible to the user is Cannot resolve a Slate point from DOM point: [object Text],0.
Do you want to request a feature or report a bug?
Bug.
What's the current behavior?
On page load,
ReactEditor.toSlateRange
callsReactEditor.toSlatePoint
which throws an exception becauseReactEditor.toSlatePoint
does not find a validtextNode
through the algorithm inside it. I do not know how to make sure this is not the same issue as https://github.com/ianstormtaylor/slate/issues/3421. The steps to reproduce are many, but if there is interest I will write them, at least so I can get help.The starting piece of code is taken from here (yes, it is a hack to solve another Slate issue temporarily):
So, everything begins with this call from the above written code:
Before this call:
editor.selection
isnull
editor.children
is:sel
is:These are the relevant parts of the code as I was debugging:
The final error visible to the user is Cannot resolve a Slate point from DOM point: [object Text],0.
The sandbox
It is here but:
and usually only when you type an inoffensive character such as;
somewhere it has no practical effect usuallyThen and only then we can see the bug appear in the sandbox.
Slate: 0.58.3 Browser: Chromium 84.0.4147.125 (official version) Arch Linux (64bit) OS: Linux (Manjaro)
What's the expected behavior?
No error, no exception, the page should load well and display the editor waiting for the user to write in it.
Thank you.