From af8a0baafef264efaf80c54183c145023fb00d13 Mon Sep 17 00:00:00 2001 From: Justin Weiss Date: Fri, 7 Jun 2019 10:57:08 -0700 Subject: [PATCH] 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`. --- packages/slate-react/src/utils/get-event-range.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/slate-react/src/utils/get-event-range.js b/packages/slate-react/src/utils/get-event-range.js index 6c6e0f01b..190c1b9d3 100644 --- a/packages/slate-react/src/utils/get-event-range.js +++ b/packages/slate-react/src/utils/get-event-range.js @@ -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