1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 04:04:06 +02:00

Fix several errors in the deprecated getEventRange (#2847)

This version of the method has drifted from `editor.findEventRange`,
and now crashes when it's being used. This commit fixes an import and
changes some code to match the new code in `editor.findEventRange`.
This commit is contained in:
Justin Weiss
2019-06-07 10:57:08 -07:00
committed by Ian Storm Taylor
parent 5f26890ff9
commit af8a0baafe

View File

@@ -3,7 +3,7 @@ import invariant from 'tiny-invariant'
import warning from 'tiny-warning'
import { Value } from 'slate'
import findPath from './find-node'
import findPath from './find-path'
import findRange from './find-range'
/**
@@ -50,13 +50,11 @@ function getEventRange(event, editor) {
: y - rect.top < rect.top + rect.height - y
const range = document.createRange()
const iterable = isPrevious ? 'previousTexts' : 'nextTexts'
const move = isPrevious ? 'moveToEndOfNode' : 'moveToStartOfNode'
const entry = document[iterable](path)
const entry = document[isPrevious ? 'getPreviousText' : 'getNextText'](path)
if (entry) {
const [n] = entry
return range[move](n)
return range[move](entry)
}
return null