canvas-editor-engine 1.0.86 → 1.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,8 @@ import { IHistoryLine } from "../types/history";
|
|
|
2
2
|
export default class ThroughHistoryService {
|
|
3
3
|
static cache: IHistoryLine[];
|
|
4
4
|
static current(): IHistoryLine;
|
|
5
|
-
static undo(): void;
|
|
6
|
-
static redo(): void;
|
|
5
|
+
static undo(ctx: CanvasRenderingContext2D): void;
|
|
6
|
+
static redo(ctx: CanvasRenderingContext2D): void;
|
|
7
7
|
static clearCache(): void;
|
|
8
|
+
private static updateCanvas;
|
|
8
9
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const store_1 = require("../store/store");
|
|
4
|
+
const filter_1 = require("../utils/filter");
|
|
4
5
|
class ThroughHistoryService {
|
|
5
6
|
static cache = [];
|
|
6
7
|
static current() {
|
|
@@ -8,16 +9,25 @@ class ThroughHistoryService {
|
|
|
8
9
|
const lastIndex = history.length - 1;
|
|
9
10
|
return history[lastIndex];
|
|
10
11
|
}
|
|
11
|
-
static undo() {
|
|
12
|
+
static undo(ctx) {
|
|
13
|
+
const current = ThroughHistoryService.current();
|
|
14
|
+
ThroughHistoryService.updateCanvas(ctx, current.stateValue);
|
|
15
|
+
ThroughHistoryService.cache.push(current);
|
|
12
16
|
store_1.default.store.historyState.reduce('UNDO');
|
|
13
17
|
}
|
|
14
18
|
;
|
|
15
|
-
static redo() {
|
|
16
|
-
|
|
19
|
+
static redo(ctx) {
|
|
20
|
+
const firstInCache = ThroughHistoryService.cache.shift();
|
|
21
|
+
ThroughHistoryService.updateCanvas(ctx, firstInCache.stateValue);
|
|
22
|
+
store_1.default.store.historyState.reduce('REDO', firstInCache);
|
|
17
23
|
}
|
|
18
24
|
;
|
|
19
25
|
static clearCache() {
|
|
20
26
|
ThroughHistoryService.cache = [];
|
|
21
27
|
}
|
|
28
|
+
static updateCanvas(ctx, stateValue) {
|
|
29
|
+
const filter = new filter_1.Filter(ctx);
|
|
30
|
+
filter.update(stateValue.tempImageData, stateValue.position);
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
exports.default = ThroughHistoryService;
|