1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-10 17:24:02 +02:00

Fix firefox newline crash (#5549)

This commit is contained in:
Joe Anderson
2023-11-09 13:02:46 +00:00
committed by GitHub
parent 47498cf8ea
commit f9cca97f00
2 changed files with 16 additions and 0 deletions

View File

@@ -943,6 +943,17 @@ export const ReactEditor: ReactEditorInterface = {
)
}
// COMPAT: Firefox sometimes includes an extra \n (rendered by TextString
// when isTrailing is true) in the focusOffset, resulting in an invalid
// Slate point. (2023/11/01)
if (
IS_FIREFOX &&
focusNode.textContent?.endsWith('\n\n') &&
focusOffset === focusNode.textContent.length
) {
focusOffset--
}
// COMPAT: Triple-clicking a word in chrome will sometimes place the focus
// inside a `contenteditable="false"` DOM node following the word, which
// will cause `toSlatePoint` to throw an error. (2023/03/07)