mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-01-18 05:59:13 +01:00
docs: updated concepts so Editor Interface matches API reference
This commit is contained in:
parent
528d92553b
commit
8a81b0ea3d
@ -4,10 +4,12 @@ All of the behaviors, content and state of a Slate editor is rolled up into a si
|
||||
|
||||
```typescript
|
||||
interface Editor {
|
||||
// Current editor state
|
||||
children: Node[]
|
||||
selection: Range | null
|
||||
operations: Operation[]
|
||||
marks: Record<string, any> | null
|
||||
|
||||
// Schema-specific node behaviors.
|
||||
isInline: (element: Element) => boolean
|
||||
isVoid: (element: Element) => boolean
|
||||
@ -47,7 +49,7 @@ For example, if you want to define link elements that are inline nodes:
|
||||
```javascript
|
||||
const { isInline } = editor
|
||||
|
||||
editor.isInline = element => {
|
||||
editor.isInline = (element) => {
|
||||
return element.type === 'link' ? true : isInline(element)
|
||||
}
|
||||
```
|
||||
@ -57,7 +59,7 @@ Or maybe you want to override the `insertText` behavior to "linkify" URLs:
|
||||
```javascript
|
||||
const { insertText } = editor
|
||||
|
||||
editor.insertText = text => {
|
||||
editor.insertText = (text) => {
|
||||
if (isUrl(text)) {
|
||||
// ...
|
||||
return
|
||||
@ -72,7 +74,7 @@ Or you can even define custom "normalizations" that take place to ensure that li
|
||||
```javascript
|
||||
const { normalizeNode } = editor
|
||||
|
||||
editor.normalizeNode = entry => {
|
||||
editor.normalizeNode = (entry) => {
|
||||
const [node, path] = entry
|
||||
|
||||
if (Element.isElement(node) && node.type === 'link') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user