1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-08 22:20:41 +02:00

added toRaw option to Html and Plain serializers, fixes #583 #584

This commit is contained in:
Ian Storm Taylor
2017-02-06 17:28:46 -08:00
parent 44cef94b04
commit a7f6584179
6 changed files with 106 additions and 44 deletions

View File

@@ -46,14 +46,18 @@ An array of rules to initialize the `Html` serializer with, defining your schema
## Methods
### `Html.deserialize`
`Html.deserialize(html: String) => State`
`Html.deserialize(html: String, [options: Object]) => State`
Deserialize an HTML `string` into a [`State`](../models/state.md). How the string is deserialized will be determined by the rules that the `Html` serializer was constructed with.
If you pass `toRaw: true` as an option, the return value will be a [`Raw`](./raw.md) JSON object instead of a [`State`](../models/state.md) object.
### `Html.serialize`
`Html.serialize(state: State, [options: Object]) => String || Array`
Serialize a `state` into an HTML string. How the string is serialized will be determined by the rules that the `Html` serializer was constructed with. If you pass `render: false` as an option, the return value will instead be an iterable list of the top-level React elements, to be rendered as children in your own React component.
Serialize a `state` into an HTML string. How the string is serialized will be determined by the rules that the `Html` serializer was constructed with.
If you pass `render: false` as an option, the return value will instead be an iterable list of the top-level React elements, to be rendered as children in your own React component.
## Rules

View File

@@ -25,10 +25,12 @@ Check out http://slatejs.org for examples!
## Methods
### `Plain.deserialize`
`Plain.deserialize(string: String) => State`
`Plain.deserialize(string: String, [options: Object]) => State`
Deserialize a plain text `string` into a [`State`](../models/state.md). A series of blocks will be created by splitting the input string on `\n` characters. Each block is given a type of `'line'`.
If you pass `toRaw: true` as an option, the return value will be a [`Raw`](./raw.md) JSON object instead of a [`State`](../models/state.md) object.
### `Plain.serialize`
`Plain.serialize(state: State) => String`