mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-12 18:24:03 +02:00
merge
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
Transforms are helper functions operating on the document. They can be used in defining your own commands.
|
||||
|
||||
- [Node options](#node-options)
|
||||
- [Static methods](#static-methods)
|
||||
- [Node transforms](#node-transforms)
|
||||
- [Selection transforms](#selection-transforms)
|
||||
- [Text transforms](#text-transforms)
|
||||
- [Editor transforms](#editor-transforms)
|
||||
- [Node options](transforms.md#node-options)
|
||||
- [Static methods](transforms.md#static-methods)
|
||||
- [Node transforms](transforms.md#node-transforms)
|
||||
- [Selection transforms](transforms.md#selection-transforms)
|
||||
- [Text transforms](transforms.md#text-transforms)
|
||||
- [Editor transforms](transforms.md#editor-transforms)
|
||||
|
||||
## Node options
|
||||
|
||||
@@ -28,67 +28,67 @@ interface NodeOptions {
|
||||
|
||||
Transforms that operate on nodes.
|
||||
|
||||
###### `Transforms.insertFragment(editor: Editor, fragment: Node[], options?)`
|
||||
#### `Transforms.insertFragment(editor: Editor, fragment: Node[], options?)`
|
||||
|
||||
Insert of fragment of nodes at the specified location in the document. If no location is specified, insert at the current selection.
|
||||
|
||||
Options: `{at?: Location, hanging?: boolean, voids?: boolean}`
|
||||
|
||||
###### `Transforms.insertNodes(editor: Editor, nodes: Node | Node[], options?)`
|
||||
#### `Transforms.insertNodes(editor: Editor, nodes: Node | Node[], options?)`
|
||||
|
||||
Insert `nodes` at the specified location in the document. If no location is specified, insert at the current selection. If there is no selection, insert at the end of the document.
|
||||
|
||||
Options supported: `NodeOptions & {hanging?: boolean, select?: boolean}`.
|
||||
|
||||
###### `Transforms.removeNodes(editor: Editor, options?)`
|
||||
#### `Transforms.removeNodes(editor: Editor, options?)`
|
||||
|
||||
Remove nodes at the specified location in the document. If no location is specified, remove the nodes in the selection.
|
||||
|
||||
Options supported: `NodeOptions & {hanging?: boolean}`
|
||||
|
||||
###### `Transforms.mergeNodes(editor: Editor, options?)`
|
||||
#### `Transforms.mergeNodes(editor: Editor, options?)`
|
||||
|
||||
Merge a node at the specified location with the previous node at the same depth. If no location is specified, use the selection. Resulting empty container nodes are removed.
|
||||
|
||||
Options supported: `NodeOptions & {hanging?: boolean}`
|
||||
|
||||
###### `Transforms.splitNodes(editor: Editor, options?)`
|
||||
#### `Transforms.splitNodes(editor: Editor, options?)`
|
||||
|
||||
Split nodes at the specified location. If no location is specified, split the selection.
|
||||
|
||||
Options supported: `NodeOptions & {height?: number, always?: boolean}`
|
||||
|
||||
###### `Transforms.wrapNodes(editor: Editor, element: Element, options?)`
|
||||
#### `Transforms.wrapNodes(editor: Editor, element: Element, options?)`
|
||||
|
||||
Wrap nodes at the specified location in the `element` container. If no location is specified, wrap the selection.
|
||||
|
||||
Options supported: `NodeOptions & {split?: boolean}`. For `options.mode`, `'all'` is also supported.
|
||||
|
||||
###### `Transforms.unwrapNodes(editor: Editor, options?)`
|
||||
#### `Transforms.unwrapNodes(editor: Editor, options?)`
|
||||
|
||||
Unwrap nodes at the specified location. If necessary, the parent node is split. If no location is specified, use the selection.
|
||||
|
||||
Options supported: `NodeOptions & {split?: boolean}`. For `options.mode`, `'all'` is also supported.
|
||||
|
||||
###### `Transforms.setNodes(editor: Editor, props: Partial<Node>, options?)`
|
||||
#### `Transforms.setNodes(editor: Editor, props: Partial<Node>, options?)`
|
||||
|
||||
Set properties of nodes at the specified location. If no location is specified, use the selection.
|
||||
|
||||
Options supported: `NodeOptions & {hanging?: boolean, split?: boolean}`. For `options.mode`, `'all'` is also supported.
|
||||
|
||||
###### `Transforms.unsetNodes(editor: Editor, props: string | string[], options?)`
|
||||
#### `Transforms.unsetNodes(editor: Editor, props: string | string[], options?)`
|
||||
|
||||
Unset properties of nodes at the specified location. If no location is specified, use the selection.
|
||||
|
||||
Options supported: `NodeOptions & {split?: boolean}`. For `options.mode`, `'all'` is also supported.
|
||||
|
||||
###### `Transforms.liftNodes(editor: Editor, options?)`
|
||||
#### `Transforms.liftNodes(editor: Editor, options?)`
|
||||
|
||||
Lift nodes at the specified location upwards in the document tree. If necessary, the parent node is split. If no location is specified, use the selection.
|
||||
|
||||
Options supported: `NodeOptions`. For `options.mode`, `'all'` is also supported.
|
||||
|
||||
###### `Transforms.moveNodes(editor: Editor, options)`
|
||||
#### `Transforms.moveNodes(editor: Editor, options)`
|
||||
|
||||
Move the nodes from an origin to a destination. A destination must be specified in the `options`. If no origin is specified, move the selection.
|
||||
|
||||
@@ -98,33 +98,33 @@ Options supported: `NodeOptions & {to: Path}`. For `options.mode`, `'all'` is al
|
||||
|
||||
Transforms that operate on the document's selection.
|
||||
|
||||
###### `Transforms.collapse(editor: Editor, options?)`
|
||||
#### `Transforms.collapse(editor: Editor, options?)`
|
||||
|
||||
Collapse the selection to a single point.
|
||||
|
||||
Options: `{edge?: 'anchor' | 'focus' | 'start' | 'end'}`
|
||||
|
||||
###### `Transforms.select(editor: Editor, target: Location)`
|
||||
#### `Transforms.select(editor: Editor, target: Location)`
|
||||
|
||||
Set the selection to a new value specified by `target`.
|
||||
|
||||
###### `Transforms.deselect(editor: Editor)`
|
||||
#### `Transforms.deselect(editor: Editor)`
|
||||
|
||||
Unset the selection.
|
||||
|
||||
###### `Transforms.move(editor: Editor, options?)`
|
||||
#### `Transforms.move(editor: Editor, options?)`
|
||||
|
||||
Move the selection's point forward or backward.
|
||||
|
||||
Options: `{distance?: number, unit?: 'offset' | 'character' | 'word' | 'line', reverse?: boolean, edge?: 'anchor' | 'focus' | 'start' | 'end'}`
|
||||
|
||||
###### `Transforms.setPoint(editor: Editor, props: Partial<Point>, options?)`
|
||||
#### `Transforms.setPoint(editor: Editor, props: Partial<Point>, options?)`
|
||||
|
||||
Set new properties on one of the selection's points.
|
||||
|
||||
Options: `{edge?: 'anchor' | 'focus' | 'start' | 'end'}`
|
||||
|
||||
###### `Transforms.setSelection(editor: Editor, props: Partial<Range>)`
|
||||
#### `Transforms.setSelection(editor: Editor, props: Partial<Range>)`
|
||||
|
||||
Set new properties on the selection.
|
||||
|
||||
@@ -132,13 +132,13 @@ Set new properties on the selection.
|
||||
|
||||
Transforms that operate on text.
|
||||
|
||||
###### `Transforms.delete(editor: Editor, options?)`
|
||||
#### `Transforms.delete(editor: Editor, options?)`
|
||||
|
||||
Delete text in the document.
|
||||
|
||||
Options: `{at?: Location, distance?: number, unit?: 'character' | 'word' | 'line' | 'block', reverse?: boolean, hanging?: boolean, voids?: boolean}`
|
||||
|
||||
###### `Transforms.insertText(editor: Editor, text: string, options?)`
|
||||
#### `Transforms.insertText(editor: Editor, text: string, options?)`
|
||||
|
||||
Insert a string of text at the specified location in the document. If no location is specified, insert at the current selection.
|
||||
|
||||
@@ -146,6 +146,6 @@ Options: `{at?: Location, voids?: boolean}`
|
||||
|
||||
### Editor transforms
|
||||
|
||||
###### `Transforms.transform(editor: Editor, transform: Transform)`
|
||||
#### `Transforms.transform(editor: Editor, transform: Transform)`
|
||||
|
||||
Transform the `editor` by an `operation`.
|
||||
|
Reference in New Issue
Block a user