1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-21 13:51:59 +02:00

Add getFragment to the API docs

This commit is contained in:
Sunny Hirai 2021-05-14 21:29:34 -07:00
parent 7632d4d0e5
commit cb1db7fca9

@ -369,16 +369,22 @@ Check if a value is a void `Element` object.
Called when there is a change in the editor.
### Override mark methods
### Mark methods
#### `addMark(key: string, value: any)`
Add a custom property to the leaf text nodes in the current selection. If the selection is currently collapsed, the marks will be added to the `editor.marks` property instead, and applied when text is inserted next.
Add a custom property to the leaf text nodes in the currentk selection. If the selection is currently collapsed, the marks will be added to the `editor.marks` property instead, and applied when text is inserted next.
#### `removeMark(key: string)`
Remove a custom property from the leaf text nodes in the current selection.
### getFragment method
#### `getFragment(): Descendant`
Returns the fragment at the current selection. Used when cutting or copying, as an example, to get the fragment at the current selection.
### Delete methods
When a user presses backspace or delete, it invokes the method based on the selection. For example, if the selection is expanded over some text and the user presses the backspace key, `deleteFragment` will be called but if the selecttion is collapsed, `deleteBackward` will be called.