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

only apply Firefox toSlatePoint offset fix if ending in \n\n (#4552)

This commit is contained in:
Claudéric Demers
2021-09-27 13:14:07 -04:00
committed by GitHub
parent ffac781086
commit 37d60c58b8
2 changed files with 6 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
Only apply Firefox `toSlatePoint()` offset fix when the cloned contents end in `\n\n` instead of just `\n`.

View File

@@ -515,7 +515,7 @@ export const ReactEditor = {
// COMPAT: In Firefox, `range.cloneContents()` returns an extra trailing '\n' // COMPAT: In Firefox, `range.cloneContents()` returns an extra trailing '\n'
// when the document ends with a new-line character. This results in the offset // when the document ends with a new-line character. This results in the offset
// length being off by one, so we need to subtract one to account for this. // length being off by one, so we need to subtract one to account for this.
(IS_FIREFOX && domNode.textContent?.endsWith('\n'))) (IS_FIREFOX && domNode.textContent?.endsWith('\n\n')))
) { ) {
offset-- offset--
} }