diff --git a/examples/focus-blur/index.js b/examples/focus-blur/index.js
index 8ebe9b3e0..cf7848055 100644
--- a/examples/focus-blur/index.js
+++ b/examples/focus-blur/index.js
@@ -124,6 +124,7 @@ class FocusBlur extends React.Component {
return (
{
+ if (this.props.autoFocus) {
+ const el = ReactDOM.findDOMNode(this)
+ el.focus()
+ }
+ }
+
/**
* On update, if the state is blurred now, but was focused before, and the
* DOM still has a node inside the editor selected, we need to blur it.
diff --git a/src/components/editor.js b/src/components/editor.js
index 407908c90..4e3293107 100644
--- a/src/components/editor.js
+++ b/src/components/editor.js
@@ -47,6 +47,23 @@ const PLUGINS_PROPS = [
'schema',
]
+/**
+ * Pass-through properties of the editor.
+ *
+ * @type {Array}
+ */
+
+const PASS_THROUGH_PROPS = [
+ 'autoCorrect',
+ 'autoFocus',
+ 'className',
+ 'readOnly',
+ 'role',
+ 'spellCheck',
+ 'style',
+ 'tabIndex',
+]
+
/**
* Editor.
*
@@ -63,6 +80,7 @@ class Editor extends React.Component {
static propTypes = {
autoCorrect: React.PropTypes.bool,
+ autoFocus: React.PropTypes.bool,
className: React.PropTypes.string,
onBeforeChange: React.PropTypes.func,
onChange: React.PropTypes.func,
@@ -78,8 +96,8 @@ class Editor extends React.Component {
spellCheck: React.PropTypes.bool,
state: React.PropTypes.instanceOf(State).isRequired,
style: React.PropTypes.object,
- tabIndex: React.PropTypes.number
- };
+ tabIndex: React.PropTypes.number,
+ }
/**
* Default properties.
@@ -88,6 +106,7 @@ class Editor extends React.Component {
*/
static defaultProps = {
+ autoFocus: false,
autoCorrect: true,
onChange: noop,
onDocumentChange: noop,
@@ -95,8 +114,8 @@ class Editor extends React.Component {
plugins: [],
readOnly: false,
schema: {},
- spellCheck: true
- };
+ spellCheck: true,
+ }
/**
* When constructed, create a new `Stack` and run `onBeforeChange`.
@@ -241,28 +260,27 @@ class Editor extends React.Component {
const { props, state } = this
const { stack } = state
const handlers = {}
+ const passes = {}
const children = stack.render(state.state, this)
for (const property of EVENT_HANDLERS) {
handlers[property] = this[property]
}
+ for (const property of PASS_THROUGH_PROPS) {
+ passes[property] = this.props[property]
+ }
+
debug('render', { props, state })
return (
{children.map((child, i) => {child})}
diff --git a/src/components/leaf.js b/src/components/leaf.js
index 4ac8c3df0..e96fbbe0b 100644
--- a/src/components/leaf.js
+++ b/src/components/leaf.js
@@ -39,7 +39,7 @@ class Leaf extends React.Component {
schema: React.PropTypes.object.isRequired,
state: React.PropTypes.object.isRequired,
text: React.PropTypes.string.isRequired
- };
+ }
/**
* Constructor.
diff --git a/src/components/placeholder.js b/src/components/placeholder.js
index 019a01886..045250965 100644
--- a/src/components/placeholder.js
+++ b/src/components/placeholder.js
@@ -22,7 +22,7 @@ class Placeholder extends React.Component {
parent: React.PropTypes.object.isRequired,
state: React.PropTypes.object.isRequired,
style: React.PropTypes.object
- };
+ }
/**
* Should the placeholder update?
diff --git a/src/components/void.js b/src/components/void.js
index b66eda0a4..ff2f7a6c8 100644
--- a/src/components/void.js
+++ b/src/components/void.js
@@ -35,7 +35,7 @@ class Void extends React.Component {
parent: React.PropTypes.object.isRequired,
schema: React.PropTypes.object.isRequired,
state: React.PropTypes.object.isRequired,
- };
+ }
/**
* Debug.