1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 01:02:31 +01:00
2016-07-17 15:37:05 -07:00

2.0 KiB

Html

import { Html } from 'slate'

The Html serializer lets you parse and stringify arbitrary HTML content, based on your specific schema's use case. You must pass a series of rules to define how your Slate schema should be serialized to and from HTML.

For an example of the Html serializer in action, check out the paste-html example.

Example

The Slate editor gives you full control over the logic you can add.\n
In its simplest form, when representing plain text, Slate is a glorified <textarea>. But you can augment it to be much more than that.\n
Check out http://slatejs.org for examples!

Properties

rules

Array

An array of rules to initialize the Html serializer with, defining your schema.

Methods

Html.deserialize

Html.deserialize(html: String) => State

Deserialize an HTML string into a State. How the string is deserialized will be determined by the rules that the Html serializer was constructed with.

Html.serialize

Html.serialize(state: State) => String

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.

Rules

To initialize an Html serialize, you must pass it an array of rules, defining your schema. Each rule defines how to deserialize and serialize a node or mark, by implementing two functions.

Rule Properties

Each rule must define two properties:

rule.deserialize

rule.deserialize(el: CheerioElement, next: Function) => Object

rule.serialize

rule.serialize(object: Node || Mark) => ReactElement

To implement still...