1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-12 02:03:59 +02:00

docs: updated concepts so Editor Interface matches API reference

This commit is contained in:
Sunny Hirai
2021-10-10 15:27:36 -07:00
parent 528d92553b
commit 8a81b0ea3d

View File

@@ -4,10 +4,12 @@ All of the behaviors, content and state of a Slate editor is rolled up into a si
```typescript ```typescript
interface Editor { interface Editor {
// Current editor state
children: Node[] children: Node[]
selection: Range | null selection: Range | null
operations: Operation[] operations: Operation[]
marks: Record<string, any> | null marks: Record<string, any> | null
// Schema-specific node behaviors. // Schema-specific node behaviors.
isInline: (element: Element) => boolean isInline: (element: Element) => boolean
isVoid: (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 ```javascript
const { isInline } = editor const { isInline } = editor
editor.isInline = element => { editor.isInline = (element) => {
return element.type === 'link' ? true : 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 ```javascript
const { insertText } = editor const { insertText } = editor
editor.insertText = text => { editor.insertText = (text) => {
if (isUrl(text)) { if (isUrl(text)) {
// ... // ...
return return
@@ -72,7 +74,7 @@ Or you can even define custom "normalizations" that take place to ensure that li
```javascript ```javascript
const { normalizeNode } = editor const { normalizeNode } = editor
editor.normalizeNode = entry => { editor.normalizeNode = (entry) => {
const [node, path] = entry const [node, path] = entry
if (Element.isElement(node) && node.type === 'link') { if (Element.isElement(node) && node.type === 'link') {