mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 20:51:20 +02:00
add more reference docs
This commit is contained in:
16
Readme.md
16
Readme.md
@@ -82,16 +82,16 @@ If you're using Slate for the first time, check out the [Getting Started](./docs
|
|||||||
- [Editor](docs/reference/components/editor.md)
|
- [Editor](docs/reference/components/editor.md)
|
||||||
- [Placeholder](docs/reference/components/placeholder.md)
|
- [Placeholder](docs/reference/components/placeholder.md)
|
||||||
- Models
|
- Models
|
||||||
- Block
|
- [Block](docs/reference/models/block.md)
|
||||||
- Character
|
- [Character](docs/reference/models/character.md)
|
||||||
- Data
|
- [Data](docs/reference/data.md)
|
||||||
- Document
|
- [Document](docs/reference/models/document.md)
|
||||||
- Inline
|
- [Inline](docs/reference/models/inline.md)
|
||||||
- Mark
|
- [Mark](docs/reference/mark.md)
|
||||||
- Node
|
- [Node](docs/reference/models/node.md)
|
||||||
- [Selection](docs/reference/models/selection.md)
|
- [Selection](docs/reference/models/selection.md)
|
||||||
- State
|
- State
|
||||||
- Text
|
- [Text](docs/reference/text.md)
|
||||||
- Transform
|
- Transform
|
||||||
- Plugins
|
- Plugins
|
||||||
- [Plugins](docs/reference/plugins/plugins.md)
|
- [Plugins](docs/reference/plugins/plugins.md)
|
||||||
|
@@ -19,6 +19,9 @@ Block nodes may contain nested block nodes, inline nodes, and text nodes—just
|
|||||||
- [`kind`](#kind)
|
- [`kind`](#kind)
|
||||||
- [`length`](#length)
|
- [`length`](#length)
|
||||||
- [`text`](#text)
|
- [`text`](#text)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Block.create`](#block-create)
|
||||||
|
- [`Block.createList`](#block-createlist)
|
||||||
- [Node Methods](#node-methods)
|
- [Node Methods](#node-methods)
|
||||||
|
|
||||||
|
|
||||||
@@ -26,10 +29,10 @@ Block nodes may contain nested block nodes, inline nodes, and text nodes—just
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
Block({
|
Block({
|
||||||
data: Immutable.Map,
|
data: Data,
|
||||||
isVoid: Boolean,
|
isVoid: Boolean,
|
||||||
key: String,
|
key: String,
|
||||||
nodes: Immutable.List,
|
nodes: Immutable.List<Node>,
|
||||||
type: String
|
type: String
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -80,6 +83,19 @@ The sum of the lengths of all of the descendant [`Text`](./text.md) nodes of thi
|
|||||||
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Block.create`
|
||||||
|
`Block.create(properties: Object) => Block`
|
||||||
|
|
||||||
|
Create a block from a plain Javascript object of `properties`.
|
||||||
|
|
||||||
|
### `Block.createList`
|
||||||
|
`Block.createList(array: Array) => List`
|
||||||
|
|
||||||
|
Create a list of block nodes from a plain Javascript `array`.
|
||||||
|
|
||||||
|
|
||||||
## Node Methods
|
## Node Methods
|
||||||
|
|
||||||
Blocks implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
Blocks implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
||||||
|
50
docs/reference/models/character.md
Normal file
50
docs/reference/models/character.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
# `Character`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Character } from 'slate'
|
||||||
|
```
|
||||||
|
|
||||||
|
A character in a [`Text`](./text.md) node.
|
||||||
|
|
||||||
|
Characters are how Slate associates [`Marks`](./mark.md) with a range of text, for formatting.
|
||||||
|
|
||||||
|
- [Properties](#properties)
|
||||||
|
- [`marks`](#marks)
|
||||||
|
- [`text`](#text)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Character.create`](#character-create)
|
||||||
|
- [`Character.createList`](#character-createlist)
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
```js
|
||||||
|
Character({
|
||||||
|
marks: Immutable.Set<Mark>,
|
||||||
|
text: String
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### `marks`
|
||||||
|
`Immutable.Set`
|
||||||
|
|
||||||
|
A set of [`Marks`](./mark.md) attached to the character.
|
||||||
|
|
||||||
|
### `text`
|
||||||
|
`String`
|
||||||
|
|
||||||
|
The text string of the character.
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Character.create`
|
||||||
|
`Character.create(properties: Object) => Character`
|
||||||
|
|
||||||
|
Create a character from a plain Javascript object of `properties`.
|
||||||
|
|
||||||
|
### `Character.createList`
|
||||||
|
`Character.createList(array: Array) => List`
|
||||||
|
|
||||||
|
Create a list of characters from a plain Javascript `array`.
|
21
docs/reference/models/data.md
Normal file
21
docs/reference/models/data.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
# `Data`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Data } from 'slate'
|
||||||
|
```
|
||||||
|
|
||||||
|
Data is simply a thin wrapper around [`Immutable.Map`](https://facebook.github.io/immutable-js/docs/#/Map), so that you don't need to ever depend on Immutable directly, and for future compatibility.
|
||||||
|
|
||||||
|
A data object can have any properties associated with it.
|
||||||
|
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Data.create`](#data-create)
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Data.create`
|
||||||
|
`Data.create(properties: Object) => Data`
|
||||||
|
|
||||||
|
Create a data object from a plain Javascript object of `properties`.
|
@@ -15,6 +15,8 @@ Documents are made up of block nodes, inline nodes, and text nodes—just like i
|
|||||||
- [`kind`](#kind)
|
- [`kind`](#kind)
|
||||||
- [`length`](#length)
|
- [`length`](#length)
|
||||||
- [`text`](#text)
|
- [`text`](#text)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Document.create`](#document-create)
|
||||||
- [Node Methods](#node-methods)
|
- [Node Methods](#node-methods)
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ Documents are made up of block nodes, inline nodes, and text nodes—just like i
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
Document({
|
Document({
|
||||||
nodes: Immutable.List,
|
nodes: Immutable.List<Node>,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -50,6 +52,14 @@ The sum of the lengths of all of the descendant [`Text`](./text.md) nodes of thi
|
|||||||
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Document.create`
|
||||||
|
`Document.create(properties: Object) => Document`
|
||||||
|
|
||||||
|
Create a block from a plain Javascript object of `properties`.
|
||||||
|
|
||||||
|
|
||||||
## Node Methods
|
## Node Methods
|
||||||
|
|
||||||
Documents implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
Documents implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
||||||
|
@@ -19,6 +19,9 @@ Inline nodes may contain nested inline nodes and text nodes—just like in the D
|
|||||||
- [`kind`](#kind)
|
- [`kind`](#kind)
|
||||||
- [`length`](#length)
|
- [`length`](#length)
|
||||||
- [`text`](#text)
|
- [`text`](#text)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Inline.create`](#inline-create)
|
||||||
|
- [`Inline.createList`](#inline-createlist)
|
||||||
- [Node Methods](#node-methods)
|
- [Node Methods](#node-methods)
|
||||||
|
|
||||||
|
|
||||||
@@ -26,10 +29,10 @@ Inline nodes may contain nested inline nodes and text nodes—just like in the D
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
Inline({
|
Inline({
|
||||||
data: Immutable.Map,
|
data: Data,
|
||||||
isVoid: Boolean,
|
isVoid: Boolean,
|
||||||
key: String,
|
key: String,
|
||||||
nodes: Immutable.List,
|
nodes: Immutable.List<Node>,
|
||||||
type: String
|
type: String
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -80,6 +83,19 @@ The sum of the lengths of all of the descendant [`Text`](./text.md) nodes of thi
|
|||||||
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Block.create`
|
||||||
|
`Block.create(properties: Object) => Block`
|
||||||
|
|
||||||
|
Create a block from a plain Javascript object of `properties`.
|
||||||
|
|
||||||
|
### `Block.createList`
|
||||||
|
`Block.createList(array: Array) => List`
|
||||||
|
|
||||||
|
Create a list of block nodes from a plain Javascript `array`.
|
||||||
|
|
||||||
|
|
||||||
## Node Methods
|
## Node Methods
|
||||||
|
|
||||||
Inlines implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
Inlines implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
||||||
|
48
docs/reference/models/mark.md
Normal file
48
docs/reference/models/mark.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
# `Mark`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Mark } from 'slate'
|
||||||
|
```
|
||||||
|
|
||||||
|
A formatting mark that can be associated with [`Characters`](./character.md). Marks are how Slate represents rich formatting like **bold** or _italic_.
|
||||||
|
|
||||||
|
- [Properties](#properties)
|
||||||
|
- [`data`](#data)
|
||||||
|
- [`type`](#type)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Mark.create`](#mark-create)
|
||||||
|
- [`Mark.createSet`](#mark-createset)
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
```js
|
||||||
|
Mark({
|
||||||
|
data: Data,
|
||||||
|
type: String
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### `data`
|
||||||
|
`Data`
|
||||||
|
|
||||||
|
A map of [`Data`](./data.md).
|
||||||
|
|
||||||
|
### `type`
|
||||||
|
`String`
|
||||||
|
|
||||||
|
The custom type of the mark (eg. `bold` or `italic`).
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Mark.create`
|
||||||
|
`Mark.create(properties: Object) => Mark`
|
||||||
|
|
||||||
|
Create a mark from a plain Javascript object of `properties`.
|
||||||
|
|
||||||
|
### `Mark.createSet`
|
||||||
|
`Mark.createSet(array: Array) => Set`
|
||||||
|
|
||||||
|
Create a set of marks from a plain Javascript `array`.
|
63
docs/reference/models/text.md
Normal file
63
docs/reference/models/text.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
# `Text`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Text } from 'slate'
|
||||||
|
```
|
||||||
|
|
||||||
|
A text node in a Slate [`Document`](./document.md). Text nodes are always the bottom-most leaves in the document, just like in the DOM.
|
||||||
|
|
||||||
|
- [Properties](#properties)
|
||||||
|
- [`characters`](#characters)
|
||||||
|
- [`key`](#key)
|
||||||
|
- [Computed Properties](#computed-properties)
|
||||||
|
- [`kind`](#kind)
|
||||||
|
- [`length`](#length)
|
||||||
|
- [`text`](#text)
|
||||||
|
- [Static Methods](#static-methods)
|
||||||
|
- [`Text.create`](#text-create)
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
```js
|
||||||
|
Text({
|
||||||
|
characters: Immutable.List<Character>,
|
||||||
|
key: String
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### `characters`
|
||||||
|
|
||||||
|
A list of [`Characters`](./character.md) with associated [`Marks`](./mark.md) that make up the text node's content.
|
||||||
|
|
||||||
|
### `key`
|
||||||
|
`String`
|
||||||
|
|
||||||
|
A unique identifier for the node.
|
||||||
|
|
||||||
|
|
||||||
|
## Computed Properties
|
||||||
|
|
||||||
|
### `kind`
|
||||||
|
`String`
|
||||||
|
|
||||||
|
An immutable string value of `'text'` for easily separating this node from [`Inline`](./inline.md) or [`Block`](./block.md) nodes.
|
||||||
|
|
||||||
|
### `length`
|
||||||
|
`Number`
|
||||||
|
|
||||||
|
The length of all of the characters in the text node.
|
||||||
|
|
||||||
|
### `text`
|
||||||
|
`String`
|
||||||
|
|
||||||
|
A concatenated string of all of the characters in the text node.
|
||||||
|
|
||||||
|
|
||||||
|
## Static Methods
|
||||||
|
|
||||||
|
### `Text.create`
|
||||||
|
`Text.create(properties: Object) => Text`
|
||||||
|
|
||||||
|
Create a text from a plain Javascript object of `properties`.
|
Reference in New Issue
Block a user