mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-19 21:01:57 +02:00
add block reference
This commit is contained in:
parent
665b0e0d3a
commit
f067ffe75c
@ -5,7 +5,7 @@
|
||||
<p align="center">A <em>completely</em> customizable framework <br/>for building rich text editors in the browser.</p>
|
||||
<br/>
|
||||
|
||||
<p align="center"><a href="#principles">Principles</a> · <a href="#examples">Examples</a> · <a href="#plugins">Plugins</a> · <a href="#documentation">Documentation</a> · Contributing</p>
|
||||
<p align="center"><a href="#principles">Principles</a> · <a href="#examples">Examples</a> · <a href="#plugins">Plugins</a> · <a href="#documentation">Documentation</a> · Contributing!</p>
|
||||
<br/>
|
||||
|
||||
Slate lets you build rich, intuitive editors like those in [Medium](https://medium.com/), [Dropbox Paper](https://www.dropbox.com/paper) or [Canvas](https://usecanvas.com/)—which are becoming table stakes for applications on the web—without your codebase getting mired in complexity.
|
||||
@ -103,9 +103,9 @@ If even that's not enough, you can always [read the source itself](./lib), which
|
||||
<br/>
|
||||
### License
|
||||
|
||||
The MIT License (MIT)
|
||||
The MIT License
|
||||
|
||||
Copyright © 2016, Ian Storm Taylor
|
||||
Copyright © 2016, [Ian Storm Taylor](https://ianstormtaylor.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
84
docs/reference/models/block.md
Normal file
84
docs/reference/models/block.md
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
# `Block`
|
||||
|
||||
```js
|
||||
import { Block } from 'slate'
|
||||
```
|
||||
|
||||
A block node in a Slate [`Document`](./document.md).
|
||||
|
||||
Block nodes can contained nested block nodes, inline nodes, and text nodes—just like in the DOM. They always contain at least one text node child.
|
||||
|
||||
- [Properties](#properties)
|
||||
- [`data`](#data)
|
||||
- [`isVoid`](#isvoid)
|
||||
- [`key`](#key)
|
||||
- [`nodes`](#nodes)
|
||||
- [`type`](#type)
|
||||
- [Computed Properties](#computed-properties)
|
||||
- [`kind`](#kind)
|
||||
- [`length`](#length)
|
||||
- [`text`](#text)
|
||||
- [Node Methods](#node-methods)
|
||||
|
||||
## Properties
|
||||
|
||||
```js
|
||||
Block({
|
||||
data: Immutable.Map,
|
||||
isVoid: Boolean,
|
||||
key: String,
|
||||
nodes: Immutable.List,
|
||||
type: String
|
||||
})
|
||||
```
|
||||
|
||||
### `data`
|
||||
`Immutable.Map`
|
||||
|
||||
Arbitrary data associated with the block. Defaults to an empty `Map`.
|
||||
|
||||
### `isVoid`
|
||||
`Boolean`
|
||||
|
||||
Whether the node is a "void" node, meaning that it has no child content (eg. images, videos, etc.). Defaults to `false`.
|
||||
|
||||
Note that even though a node may be "void", it will still contain a single, empty [`Text`](./text.md) node for consistency across other operations. However, when rendered by Slate that single text node will not be visible.
|
||||
|
||||
### `key`
|
||||
`String`
|
||||
|
||||
A unique identifier for the node.
|
||||
|
||||
### `nodes`
|
||||
`Immutable.List`
|
||||
|
||||
A list of child nodes. Defaults to a list with a single text node child.
|
||||
|
||||
### `type`
|
||||
`String`
|
||||
|
||||
The custom type of the block (eg. `blockquote` or `list-item`).
|
||||
|
||||
|
||||
## Computed Properties
|
||||
|
||||
### `kind`
|
||||
`String`
|
||||
|
||||
An immutable string value of `'block'` for easily separating this node from inline or text nodes.
|
||||
|
||||
### `length`
|
||||
`Number`
|
||||
|
||||
The sum of the lengths of all of the descendant [`Text`](./text.md) nodes of this node.
|
||||
|
||||
### `text`
|
||||
`String`
|
||||
|
||||
A concatenated string of all of the descendant [`Text`](./text.md) nodes of this node.
|
||||
|
||||
|
||||
## Node Methods
|
||||
|
||||
Blocks implement the [`Node`](./node.md) interface. For information about their methods, see the [`Node` reference](./node.md).
|
@ -2,10 +2,10 @@
|
||||
# `Selection`
|
||||
|
||||
```js
|
||||
import { Selection } from 'Slate'
|
||||
import { Selection } from 'slate'
|
||||
```
|
||||
|
||||
A selection in the document. Selections in Slate are modeled after the native [DOM Selection API](https://developer.mozilla.org/en-US/docs/Web/API/Selection), using terms like "anchor", "focus" and "collapsed".
|
||||
A selection of a Slate [`Document`](./document.md). Selections in Slate are modeled after the native [DOM Selection API](https://developer.mozilla.org/en-US/docs/Web/API/Selection), using terms like "anchor", "focus" and "collapsed".
|
||||
|
||||
The "anchor" is the fixed point in a selection, and the "focus" is the non-fixed point, which may move when you move the cursor (eg. when pressing `Shift + Right Arrow`).
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user