You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
When dealing with complex replacements and selection operations, it's very common to get invalid ranges, which cause the editor to crash with an error Cannot resolve a DOM point from Slate point.
Example code:
// Provide an invalid selection as the second argument.Transforms.select(editor,{anchor: {path: [55,0]offset: 0},focus: {path: [55,0],offset: 10}});
I know this would be partially the fault of an unreliable editor built on top of Slate, which could result in such invalid ranges, but I believe Slate could provide better ways to deal with these invalid ranges.
Solution
Suggested approaches:
Throw a console.warn warning if the selection is invalid, and do nothing with the command. E.g if it's a select operation, don't perform the operation and throw a descriptive warning.
Make the existing error easily catchable within a try/catch block.
Alternatives
Given Slate is still in beta, and there are some open issues around inconsistencies in ranges selecion/removal, I'd say the first option under the proposed solutions would be best - doing nothing in case there's an invalid range and throw a descriptive warning.
The text was updated successfully, but these errors were encountered:
also replacing with a different document (for example resetting to original one in a viewmodel) can result quite easily in an invalid selection, resulting in the above exception.
also replacing with a different document (for example resetting to original one in a viewmodel) can result quite easily in an invalid selection, resulting in the above exception.
We are also running into this problem a lot, especially now that you cannot set the editor value, but have to fallback to remove/add all nodes again when you want to re-initialize an editor
Problem
When dealing with complex replacements and selection operations, it's very common to get invalid ranges, which cause the editor to crash with an error
Cannot resolve a DOM point from Slate point
.Example code:
I know this would be partially the fault of an unreliable editor built on top of Slate, which could result in such invalid ranges, but I believe Slate could provide better ways to deal with these invalid ranges.
Solution
Suggested approaches:
console.warn
warning if the selection is invalid, and do nothing with the command. E.g if it's a select operation, don't perform the operation and throw a descriptive warning.Alternatives
Given Slate is still in beta, and there are some open issues around inconsistencies in ranges selecion/removal, I'd say the first option under the proposed solutions would be best - doing nothing in case there's an invalid range and throw a descriptive warning.
The text was updated successfully, but these errors were encountered: