nathanfaucett / svelte-slate

slate svelte view layer
https://nathanfaucett.github.io/svelte-slate/
Apache License 2.0
61 stars 5 forks source link

[firefox] error when selecting first character and trying to type #7

Open NickantX opened 1 year ago

NickantX commented 1 year ago

This seems to only happen in Firefox and may be caused by #5 with the additional whitespace being inserted. If the first character in the editor is highlighted, and you try to type, you get an error:

Uncaught Error: Cannot resolve a Slate point from DOM point: [object Text],0

This does not happen in Chromium. See the following GIF: https://gyazo.com/1e59a43c34826eec4ae56085839ae499

Yes, I have addons installed, but I also tested this in a clean-install of Firefox Developer Edition and can confirm the same still happens.

I modified toSlateRange in utils.js to simply log what is being passed for domRange. It seems that the starting element is an invisible empty text node whereas it is correctly the first text node in Chromium. It seems the next sibling node is the correct element so perhaps a fix for this specific issue could be an IS_FIREFOX check selecting the sibling node as the start to the range.