1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 06:31:28 +02:00

Add optional id prop to the Editor component (#2402)

This commit is contained in:
Dundercover
2018-11-09 00:36:44 +01:00
committed by Ian Storm Taylor
parent eb79c3dbff
commit 13107b0c43
4 changed files with 12 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ The top-level React component that renders the Slate editor itself.
```js ```js
<Editor <Editor
id={String}
autoCorrect={Boolean} autoCorrect={Boolean}
autoFocus={Boolean} autoFocus={Boolean}
className={String} className={String}
@@ -28,6 +29,12 @@ The top-level React component that renders the Slate editor itself.
/> />
``` ```
### `id`
`String`
Id for the top-level rendered HTML element of the editor.
### `autoCorrect` ### `autoCorrect`
`Boolean` `Boolean`

View File

@@ -41,6 +41,7 @@ class Content extends React.Component {
autoCorrect: Types.bool.isRequired, autoCorrect: Types.bool.isRequired,
className: Types.string, className: Types.string,
editor: Types.object.isRequired, editor: Types.object.isRequired,
id: Types.string,
readOnly: Types.bool.isRequired, readOnly: Types.bool.isRequired,
role: Types.string, role: Types.string,
spellCheck: Types.bool.isRequired, spellCheck: Types.bool.isRequired,
@@ -421,6 +422,7 @@ class Content extends React.Component {
render() { render() {
const { props, handlers } = this const { props, handlers } = this
const { const {
id,
className, className,
readOnly, readOnly,
editor, editor,
@@ -467,6 +469,7 @@ class Content extends React.Component {
data-key={document.key} data-key={document.key}
contentEditable={readOnly ? null : true} contentEditable={readOnly ? null : true}
suppressContentEditableWarning suppressContentEditableWarning
id={id}
className={className} className={className}
autoCorrect={props.autoCorrect ? 'on' : 'off'} autoCorrect={props.autoCorrect ? 'on' : 'off'}
spellCheck={spellCheck} spellCheck={spellCheck}

View File

@@ -35,6 +35,7 @@ class Editor extends React.Component {
autoCorrect: Types.bool, autoCorrect: Types.bool,
autoFocus: Types.bool, autoFocus: Types.bool,
className: Types.string, className: Types.string,
id: Types.string,
onChange: Types.func, onChange: Types.func,
options: Types.object, options: Types.object,
placeholder: Types.any, placeholder: Types.any,

View File

@@ -60,6 +60,7 @@ function ReactPlugin(options = {}) {
autoCorrect={props.autoCorrect} autoCorrect={props.autoCorrect}
className={props.className} className={props.className}
editor={editor} editor={editor}
id={props.id}
onEvent={(handler, event) => editor.run(handler, event)} onEvent={(handler, event) => editor.run(handler, event)}
readOnly={props.readOnly} readOnly={props.readOnly}
role={props.role} role={props.role}