From aa8e295a2d07db84ea0a175ff657e7aa4a98d73b Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Fri, 1 Jul 2016 13:03:22 -0700 Subject: [PATCH] fix void selection behavior --- examples/images/index.js | 2 +- lib/components/content.js | 2 -- lib/components/void.js | 33 ++++++++++++++++++--------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/examples/images/index.js b/examples/images/index.js index b3e93b364..a021eeaa0 100644 --- a/examples/images/index.js +++ b/examples/images/index.js @@ -139,7 +139,7 @@ class Images extends React.Component { return (props) => { const { node, state } = props const { data } = node - const isActive = state.blocks.includes(node) + const isActive = state.selection.isFocused && state.blocks.includes(node) const src = data.get('src') return } diff --git a/lib/components/content.js b/lib/components/content.js index a8046caa7..0e9f588c3 100644 --- a/lib/components/content.js +++ b/lib/components/content.js @@ -1,7 +1,6 @@ import OffsetKey from '../utils/offset-key' import React from 'react' -import ReactDOM from 'react-dom' import Text from './text' import Void from './void' import keycode from 'keycode' @@ -303,7 +302,6 @@ class Content extends React.Component { return } - const el = ReactDOM.findDOMNode(this) const { anchorNode, anchorOffset, focusNode, focusOffset } = native const anchor = OffsetKey.findPoint(anchorNode, anchorOffset) const focus = OffsetKey.findPoint(focusNode, focusOffset) diff --git a/lib/components/void.js b/lib/components/void.js index 09b30a835..799ac54bf 100644 --- a/lib/components/void.js +++ b/lib/components/void.js @@ -19,19 +19,19 @@ class Void extends React.Component { state: React.PropTypes.object.isRequired }; - onClick(e) { - e.preventDefault() - let { editor, node, state } = this.props - let text = node.getTextNodes().first() + // onClick(e) { + // e.preventDefault() + // let { editor, node, state } = this.props + // let text = node.getTextNodes().first() - state = state - .transform() - .moveToStartOf(text) - .focus() - .apply() + // state = state + // .transform() + // .moveToStartOf(text) + // .focus() + // .apply() - editor.onChange(state) - } + // editor.onChange(state) + // } render() { const { children, node } = this.props @@ -41,9 +41,9 @@ class Void extends React.Component { } return ( - this.onClick(e)}> + {this.renderSpacer()} - {children} +
{children}
) } @@ -51,8 +51,11 @@ class Void extends React.Component { renderSpacer() { const style = { position: 'absolute', - top: '0px', // vertically the same, to not scroll the window - left: '-10000px' + top: '0px', + right: '0px', + bottom: '0px', + left: '0px', + textIndent: '-9999px' } return (