mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 20:40:19 +02:00
refactor examples, normalize selections
This commit is contained in:
@@ -2,14 +2,7 @@
|
||||
import Editor, { Character, Document, Element, State, Text } from '../..'
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
|
||||
/**
|
||||
* The initial editor state.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
|
||||
const state = 'This is editable plain text, just like a <textarea>!'
|
||||
import state from './state.json'
|
||||
|
||||
/**
|
||||
* A helper to deserialize a string into an editor state.
|
||||
@@ -52,17 +45,29 @@ function serialize(state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The example's app.
|
||||
* The example app.
|
||||
*
|
||||
* @type {Component} App
|
||||
*/
|
||||
|
||||
class App extends React.Component {
|
||||
|
||||
/**
|
||||
* Deserialize the initial editor state.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
|
||||
state = {
|
||||
state: deserialize(state)
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the editor.
|
||||
*
|
||||
* @return {Component} component
|
||||
*/
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Editor
|
||||
@@ -82,7 +87,7 @@ class App extends React.Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach.
|
||||
* Mount the example app.
|
||||
*/
|
||||
|
||||
const app = <App />
|
||||
|
1
examples/plain-text/state.json
Normal file
1
examples/plain-text/state.json
Normal file
@@ -0,0 +1 @@
|
||||
"This is editable plain text, just like a <textarea>!"
|
Reference in New Issue
Block a user