mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 13:11:17 +02:00
committed by
Ian Storm Taylor
parent
4346ad0e3f
commit
a325696339
@@ -263,6 +263,7 @@ class RichTextExample extends React.Component {
|
|||||||
renderNode={this.renderNode}
|
renderNode={this.renderNode}
|
||||||
renderMark={this.renderMark}
|
renderMark={this.renderMark}
|
||||||
spellCheck
|
spellCheck
|
||||||
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@@ -40,7 +40,6 @@ class Content extends React.Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
autoCorrect: Types.bool.isRequired,
|
autoCorrect: Types.bool.isRequired,
|
||||||
autoFocus: Types.bool.isRequired,
|
|
||||||
children: Types.any.isRequired,
|
children: Types.any.isRequired,
|
||||||
className: Types.string,
|
className: Types.string,
|
||||||
editor: Types.object.isRequired,
|
editor: Types.object.isRequired,
|
||||||
@@ -87,11 +86,9 @@ class Content extends React.Component {
|
|||||||
*
|
*
|
||||||
* - Add native DOM event listeners.
|
* - Add native DOM event listeners.
|
||||||
* - Update the selection, in case it starts focused.
|
* - Update the selection, in case it starts focused.
|
||||||
* - Focus the editor if `autoFocus` is set.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
const { editor } = this.props
|
|
||||||
const window = getWindow(this.element)
|
const window = getWindow(this.element)
|
||||||
|
|
||||||
window.document.addEventListener(
|
window.document.addEventListener(
|
||||||
@@ -105,10 +102,6 @@ class Content extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateSelection()
|
this.updateSelection()
|
||||||
|
|
||||||
if (this.props.autoFocus) {
|
|
||||||
editor.focus()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -145,11 +145,16 @@ class Editor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the component first mounts, flush any temporary changes.
|
* When the component first mounts, flush any temporary changes,
|
||||||
|
* and then, focus the editor if `autoFocus` is set.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
this.flushChange()
|
this.flushChange()
|
||||||
|
|
||||||
|
if (this.props.autoFocus) {
|
||||||
|
this.focus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -602,7 +602,6 @@ function AfterPlugin() {
|
|||||||
<Content
|
<Content
|
||||||
{...handlers}
|
{...handlers}
|
||||||
autoCorrect={props.autoCorrect}
|
autoCorrect={props.autoCorrect}
|
||||||
autoFocus={props.autoFocus}
|
|
||||||
className={props.className}
|
className={props.className}
|
||||||
children={props.children}
|
children={props.children}
|
||||||
editor={editor}
|
editor={editor}
|
||||||
|
Reference in New Issue
Block a user