From accba53f56edbe0e8193a7322c751041683b183f Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Wed, 22 May 2019 11:26:11 -0700 Subject: [PATCH] Add div to editor as editor.el (#2820) --- packages/slate-react/src/components/content.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/slate-react/src/components/content.js b/packages/slate-react/src/components/content.js index 2d150f4c9..3de94d87c 100644 --- a/packages/slate-react/src/components/content.js +++ b/packages/slate-react/src/components/content.js @@ -111,6 +111,17 @@ class Content extends React.Component { ref = React.createRef() + /** + * Set both `this.ref` and `editor.el` + * + * @type {DOMElement} + */ + + setRef = el => { + this.ref.current = el + this.props.editor.el = el + } + /** * Create a set of bound event handlers. * @@ -506,7 +517,7 @@ class Content extends React.Component { key={this.props.contentKey} {...handlers} {...data} - ref={this.ref} + ref={this.setRef} contentEditable={readOnly ? null : true} suppressContentEditableWarning id={id}