slate-react
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -44,2 +44,3 @@ 'use strict'; | ||
function BeforePlugin() { | ||
var activeElement = null; | ||
var compositionCount = 0; | ||
@@ -87,23 +88,32 @@ var isComposing = false; | ||
var value = change.value; | ||
var relatedTarget = event.relatedTarget, | ||
target = event.target; | ||
var focusTarget = event.relatedTarget; | ||
var window = (0, _getWindow2.default)(target); | ||
// If focusTarget is null, the blur event is due to the window itself being | ||
// blurred (eg. when changing tabs) so we should ignore the event, since we | ||
// want to maintain focus when returning. | ||
if (!focusTarget) return true; | ||
// COMPAT: If the current `activeElement` is still the previous one, this is | ||
// due to the window being blurred when the tab itself becomes unfocused, so | ||
// we want to abort early to allow to editor to stay focused when the tab | ||
// becomes focused again. | ||
if (activeElement == window.document.activeElement) return true; | ||
var el = (0, _reactDom.findDOMNode)(editor); | ||
// COMPAT: The `relatedTarget` can be null when the new focus target is not | ||
// a "focusable" element (eg. a `<div>` without `tabindex` set). | ||
if (relatedTarget) { | ||
var el = (0, _reactDom.findDOMNode)(editor); | ||
// The event should also be ignored if the focus returns to the editor from | ||
// an embedded editable element (eg. an input element inside a void node), | ||
if (focusTarget == el) return true; | ||
// COMPAT: The event should be ignored if the focus is returning to the | ||
// editor from an embedded editable element (eg. an <input> element inside | ||
// a void node). | ||
if (relatedTarget == el) return true; | ||
// when the focus moved from the editor to a void node spacer... | ||
if (focusTarget.hasAttribute('data-slate-spacer')) return true; | ||
// COMPAT: The event should be ignored if the focus is moving from the | ||
// editor to inside a void node's spacer element. | ||
if (relatedTarget.hasAttribute('data-slate-spacer')) return true; | ||
// or to an editable element inside the editor but not into a void node | ||
// (eg. a list item of the check list example). | ||
if (el.contains(focusTarget) && !(0, _findNode2.default)(focusTarget, value).isVoid) { | ||
return true; | ||
// COMPAT: The event should be ignored if the focus is moving to a non- | ||
// editable section of an element that isn't a void node (eg. a list item | ||
// of the check list example). | ||
var node = (0, _findNode2.default)(relatedTarget, value); | ||
if (el.contains(relatedTarget) && node && !node.isVoid) return true; | ||
} | ||
@@ -344,2 +354,6 @@ | ||
// Save the new `activeElement`. | ||
var window = (0, _getWindow2.default)(event.target); | ||
activeElement = window.document.activeElement; | ||
// COMPAT: If the editor has nested editable elements, the focus can go to | ||
@@ -429,2 +443,6 @@ // those elements. In Firefox, this must be prevented because it results in | ||
// Save the new `activeElement`. | ||
var window = (0, _getWindow2.default)(event.target); | ||
activeElement = window.document.activeElement; | ||
debug('onSelect', { event: event }); | ||
@@ -431,0 +449,0 @@ } |
{ | ||
"name": "slate-react", | ||
"description": "A set of React components for building completely customizable rich-text editors.", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/ianstormtaylor/slate.git", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
964814
17149