You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A powerful and simple javascript library provides a history for undo/redo functionality. Just like a time machine! 🕐
4
+
A powerful and simple Javascript library provides a history for undo/redo functionality. Just like a time machine! 🕐
5
5
***
6
6
## Install:
7
7
**Node.js**:
@@ -12,7 +12,7 @@ npm install undoredo.js --save
12
12
```
13
13
Then simply require it:
14
14
```js
15
-
constUndoRedojs=require("undoredo.js");
15
+
constUndoRedojs=require("undoredo.js")
16
16
```
17
17
18
18
**Browser**:
@@ -38,58 +38,61 @@ By the same way you can use `UndoRedo.min.js` instead, which is a minified versi
38
38
39
39
The main function will be declared as `window.UndoRedojs`:
40
40
```js
41
-
constUndoRedojs=window.UndoRedojs;
41
+
constUndoRedojs=window.UndoRedojs
42
42
```
43
43
44
+
You can also bundle it info your project using [Webpack](https://webpack.js.org/guides/getting-started/). You can use it in anyway you want, it's just another npm packege after all! 😅
45
+
44
46
## Usage:
45
-
This package is useful for any step-by-step tasks, for example:
47
+
This package is useful for any step-by-step task, for example:
46
48
47
49
- Undo/Redo functionality for a text input.
48
50
- Something like a browser history.
49
51
- A settings page.
52
+
- A files explorer.
50
53
- And more...
51
54
52
55
**Basic usage**:
53
56
54
57
>Lets setup our history:
55
58
```js
56
-
constmyHistory=UndoRedojs(5);
59
+
constmyHistory=newUndoRedojs(5)
57
60
```
58
-
>This function will return an object with the methods and the properties that we will use later.
61
+
>This will return a class object with the methods and the properties that we will use later.
59
62
>
60
63
>As you can see, we added the number **5** as a parameter, this will be used for cooldowns, keep reading for more details.
61
64
>
62
65
>To push new elements to the history, use the `record` method:
63
66
```js
64
-
myHistory.record('1');
65
-
myHistory.record('12');
66
-
myHistory.record('123');
67
-
myHistory.record('1234');
68
-
myHistory.record('12345');
69
-
myHistory.record('123456');
70
-
myHistory.record('1234567', true);
67
+
myHistory.record('1')
68
+
myHistory.record('12')
69
+
myHistory.record('123')
70
+
myHistory.record('1234')
71
+
myHistory.record('12345')
72
+
myHistory.record('123456')
73
+
myHistory.record('1234567', true)
71
74
```
72
75
>To get the history array, use the `stack` property:
0 commit comments