diff --git a/docs/reference/plugins/plugins.md b/docs/reference/plugins/plugins.md index 0b720607d..d6958cd4f 100644 --- a/docs/reference/plugins/plugins.md +++ b/docs/reference/plugins/plugins.md @@ -184,7 +184,7 @@ If no other plugin handles this event, it will be handled by the [Core plugin](. This handler is called whenever the native selection changes. -The `data` object contains a State [`Selection`](../models/selection.md) object representing the new selection, and an `isNative` boolean connoting whether the editor needs to be re-rendered for the selection to be updated or correctly placed or not. +The `data` object contains a State [`Selection`](../models/selection.md) object representing the new selection. If no other plugin handles this event, it will be handled by the [Core plugin](./core.md). diff --git a/lib/components/content.js b/lib/components/content.js index 4204c0b3b..eb8f41ece 100644 --- a/lib/components/content.js +++ b/lib/components/content.js @@ -599,9 +599,10 @@ class Content extends React.Component { const anchor = this.getPoint(anchorNode, anchorOffset) const focus = this.getPoint(focusNode, focusOffset) - // COMPAT: In Firefox, and potentially other browsers, sometimes a select - // event will fire that resolves to the same location as the current - // selection, so we can ignore it. + // There are valid situations where a select event will fire when we're + // already at that position (for example when entering a character), since + // our `insertText` transform already updates the selection. In those + // cases we can safely ignore the event. if ( anchor.key == selection.anchorKey && anchor.offset == selection.anchorOffset && @@ -611,23 +612,18 @@ class Content extends React.Component { return } - // If the native selection is inside text nodes, we can trust the native - // state and not need to re-render. - data.isNative = ( - anchorNode.nodeType == 3 && - focusNode.nodeType == 3 - ) - - selection = selection.merge({ + const properties = { anchorKey: anchor.key, anchorOffset: anchor.offset, focusKey: focus.key, focusOffset: focus.offset, isFocused: true, isBackward: null - }) + } - data.selection = selection.normalize(document) + data.selection = selection + .merge(properties) + .normalize(document) } this.props.onSelect(e, data) diff --git a/lib/plugins/core.js b/lib/plugins/core.js index 024e9027c..fd1278e5a 100644 --- a/lib/plugins/core.js +++ b/lib/plugins/core.js @@ -538,12 +538,12 @@ function Plugin(options = {}) { */ function onSelect(e, data, state) { - const { selection, isNative } = data + const { selection } = data return state .transform() .moveTo(selection) .focus() - .apply({ isNative }) + .apply() } /**