1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-26 16:44:22 +02:00

Add properties hasUndo and hasRedo to State (#193)

* Add properties hasUndo and hasRedo to State

* Fix description fo hadRedo
This commit is contained in:
Samy Pessé
2016-07-28 20:11:42 +02:00
committed by Ian Storm Taylor
parent dca2efca0f
commit b2c1b844af
2 changed files with 33 additions and 2 deletions

View File

@@ -22,6 +22,8 @@ For convenience, in addition to transforms, many of the [`Selection`](./selectio
- [`fragment`](#fragment)
- [`inlines`](#inlines)
- [`texts`](#texts)
- [`hasUndo`](#hasundo)
- [`hasRedo`](#hasredo)
- [Selection-like Properties](#selection-like-properties)
- [`{edge}Key`](#edgekey)
- [`{edge}Offset`](#edgeoffset)
@@ -32,7 +34,7 @@ For convenience, in addition to transforms, many of the [`Selection`](./selectio
- [`isFocused`](#isfocused)
- [`isForward`](#isForward)
- [Static Methods](#static-methods)
- [`State.create`](#statecreate)
- [`State.create`](#statecreate)
- [Methods](#methods)
- [`transform`](#transform)
@@ -42,7 +44,7 @@ For convenience, in addition to transforms, many of the [`Selection`](./selectio
```js
State({
document: Document,
selection: Selection
selection: Selection
})
```
@@ -97,6 +99,15 @@ Get a list of the lowest-depth [`Inline`](./inline.md) nodes in the current sele
Get a list of the [`Text`](./text.md) nodes in the current selection.
### `hasUndo`
`Boolean`
Whether there are undoable events.
### `hasRedo`
`Boolean`
Whether there are redoable events.
## Selection-like Properties

View File

@@ -58,6 +58,26 @@ class State extends new Record(DEFAULTS) {
return 'state'
}
/**
* Is there undoable events?
*
* @return {Boolean} hasUndo
*/
get hasUndo() {
return this.history.undos.size > 0
}
/**
* Is there redoable events?
*
* @return {Boolean} hasRedo
*/
get hasRedo() {
return this.history.redos.size > 0
}
/**
* Is the current selection blurred?
*