mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 18:39:51 +02:00
Add defaultValue
prop to Editor
component (#2418)
* Add `defaultValue` prop to `Editor` component * Use `defaultValue` prop in the `Read Only` example * Use `defaultValue` prop in the `Check Lists` example * Use `defaultValue` prop in the `Code Highlighting` example * Use `defaultValue` prop in the `Embeds` example * Use `defaultValue` prop in the `Emojis` example * Use `defaultValue` prop in the `Forced Layout` example * Use `defaultValue` prop in the `Huge Document` example * Use `defaultValue` prop in the `Images` example * Use `defaultValue` prop in the `Input Tester` example * Use `defaultValue` prop in the `Markdown Preview` example * Use `defaultValue` prop in the `Markdown Shortcuts` example * Use `defaultValue` prop in the `Paste HTML` example * Use `defaultValue` prop in the `Plain Text` example * Use `defaultValue` prop in the `Plugins` example * Use `defaultValue` prop in the `RTL` example * Use `defaultValue` prop in the `Search Highlighting` example * Use `defaultValue` prop in the `Tables` example
This commit is contained in:
committed by
Ian Storm Taylor
parent
5849dcb810
commit
61be5f8881
@@ -3,6 +3,16 @@ import { Editor } from 'slate-react'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
/**
|
||||
* Deserialize the initial editor value.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
const initialValue = Plain.deserialize(
|
||||
'This is editable plain text, just like a <textarea>!'
|
||||
)
|
||||
|
||||
/**
|
||||
* The plain text example.
|
||||
*
|
||||
@@ -10,18 +20,6 @@ import React from 'react'
|
||||
*/
|
||||
|
||||
class PlainText extends React.Component {
|
||||
/**
|
||||
* Deserialize the initial editor value.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
state = {
|
||||
value: Plain.deserialize(
|
||||
'This is editable plain text, just like a <textarea>!'
|
||||
),
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the editor.
|
||||
*
|
||||
@@ -32,21 +30,10 @@ class PlainText extends React.Component {
|
||||
return (
|
||||
<Editor
|
||||
placeholder="Enter some plain text..."
|
||||
value={this.state.value}
|
||||
onChange={this.onChange}
|
||||
defaultValue={initialValue}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* On change.
|
||||
*
|
||||
* @param {Editor} editor
|
||||
*/
|
||||
|
||||
onChange = ({ value }) => {
|
||||
this.setState({ value })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user