1
0
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:
Ian Storm Taylor
2016-06-21 14:49:08 -07:00
parent d742d109a5
commit dbdf3760e9
12 changed files with 252 additions and 358 deletions

View File

@@ -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 />

View File

@@ -0,0 +1 @@
"This is editable plain text, just like a <textarea>!"