1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-20 14:11:35 +02:00

update import declaration in walkthrough (#1174)

This commit is contained in:
Yifeng Wang
2017-09-25 10:43:18 -05:00
committed by Ian Storm Taylor
parent 4652f96d8d
commit f34a716ee7
3 changed files with 15 additions and 11 deletions

View File

@@ -1,16 +1,16 @@
# Installing Slate # Installing Slate
Slate is an npm module, so to install it you do: Slate is a monorepo divided up into multi npm packages, so to install it you do:
``` ```
npm install slate npm install slate slate-react
``` ```
You'll also need to be sure to install Slate's peer dependencies for React: You'll also need to be sure to install Slate's peer dependencies:
``` ```
npm install react react-dom npm install react react-dom immutable
``` ```
_Note, if you'd rather use a pre-bundled version of Slate, you can `npm install slate` and retrieve the bundled `dist/slate.js` file! Check out the [Using the Bundled Source](./using-the-bundled-source.md) guide for more information._ _Note, if you'd rather use a pre-bundled version of Slate, you can `npm install slate` and retrieve the bundled `dist/slate.js` file! Check out the [Using the Bundled Source](./using-the-bundled-source.md) guide for more information._
@@ -21,14 +21,15 @@ Slate exposes a set of modules that you'll use to build your editor. The most im
```js ```js
// Import the Slate editor. // Import the Slate editor.
import { Editor } from 'slate' import { Editor } from 'slate-react'
``` ```
In addition to rendering the editor, you need to give Slate a "initial state" to render as content. We'll use the `State` model that ships with Slate to create a new initial state that just contains a single paragraph block with some text in it: In addition to rendering the editor, you need to give Slate a "initial state" to render as content. We'll use the `State` model that ships with Slate to create a new initial state that just contains a single paragraph block with some text in it:
```js ```js
// Import the `State` model. // Import the `State` model.
import { Editor, State } from 'slate' import { Editor } from 'slate-react'
import { State } from 'slate'
// Create our initial state... // Create our initial state...
const initialState = State.fromJSON({ const initialState = State.fromJSON({
@@ -58,7 +59,8 @@ And now that we've our initial state, we define our `App` and pass it into Slate
```js ```js
// Import React! // Import React!
import React from 'react' import React from 'react'
import { Editor, State } from 'slate' import { Editor } from 'slate-react'
import { State } from 'slate'
const initialState = State.fromJSON({ const initialState = State.fromJSON({
document: { document: {

View File

@@ -10,7 +10,7 @@ In the previous guide, we looked at how to serialize the Slate editor's content
Let's start with a basic editor: Let's start with a basic editor:
```js ```js
import { Editor } from 'slate' import { Editor } from 'slate-react'
class App extends React.Component { class App extends React.Component {
@@ -200,7 +200,7 @@ const rules = [
Great, that's all of the rules we need! Now let's create a new `Html` serializer and pass in those rules: Great, that's all of the rules we need! Now let's create a new `Html` serializer and pass in those rules:
```js ```js
import { Html } from 'slate' import Html from 'slate-html-serializer'
// Create a new serializer instance with our `rules` from above. // Create a new serializer instance with our `rules` from above.
const html = new Html({ rules }) const html = new Html({ rules })

View File

@@ -12,7 +12,8 @@ In this guide, we'll show you how to add logic to save your Slate content to a d
Let's start with a basic editor: Let's start with a basic editor:
```js ```js
import { Editor, State } from 'slate' import { Editor } from 'slate-react'
import { State } from 'slate'
const initialState = State.fromJSON({ const initialState = State.fromJSON({
document: { document: {
@@ -227,7 +228,8 @@ But what if you want something other than JSON? Well, you'd need to serialize yo
```js ```js
// Switch to using the Plain serializer. // Switch to using the Plain serializer.
import { Editor, Plain } from 'slate' import { Editor } from 'slate-react'
import Plain from 'slate-plain-serializer'
const existingState = localStorage.getItem('content') const existingState = localStorage.getItem('content')
const initialState = Plain.deserialize(existingState || 'A string of plain text.') const initialState = Plain.deserialize(existingState || 'A string of plain text.')