canvas-editor-engine 1.0.94 → 1.0.96
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,6 +2,7 @@ import { IHistoryLine } from "../types/history";
|
|
|
2
2
|
export default class ThroughHistoryService {
|
|
3
3
|
static cache: IHistoryLine[];
|
|
4
4
|
static current(): IHistoryLine;
|
|
5
|
+
static prev(): IHistoryLine;
|
|
5
6
|
static undo(ctx: CanvasRenderingContext2D): void;
|
|
6
7
|
static redo(ctx: CanvasRenderingContext2D): void;
|
|
7
8
|
static clearCache(): void;
|
|
@@ -9,12 +9,20 @@ class ThroughHistoryService {
|
|
|
9
9
|
const lastIndex = history.length - 1;
|
|
10
10
|
return history[lastIndex];
|
|
11
11
|
}
|
|
12
|
+
static prev() {
|
|
13
|
+
const history = store_1.default.store.historyState.historyLines;
|
|
14
|
+
const prevIndex = history.length - 2;
|
|
15
|
+
return history[prevIndex];
|
|
16
|
+
}
|
|
12
17
|
static undo(ctx) {
|
|
13
18
|
const current = ThroughHistoryService.current();
|
|
19
|
+
const prev = ThroughHistoryService.prev();
|
|
14
20
|
if (!!current?.stateValue) {
|
|
15
21
|
ThroughHistoryService.cache.push(current);
|
|
16
22
|
store_1.default.store.historyState.reduce('UNDO');
|
|
17
|
-
|
|
23
|
+
if (prev?.stateValue) {
|
|
24
|
+
ThroughHistoryService.updateCanvas(ctx, prev.stateValue);
|
|
25
|
+
}
|
|
18
26
|
}
|
|
19
27
|
}
|
|
20
28
|
;
|
|
@@ -55,6 +55,7 @@ class Reducer {
|
|
|
55
55
|
state._historyLines.push(payload);
|
|
56
56
|
isUpdate = true;
|
|
57
57
|
}
|
|
58
|
+
console.log('isUpdate && !!state._emergeCompleteIt', isUpdate && !!state._emergeCompleteIt);
|
|
58
59
|
if (isUpdate && !!state._emergeCompleteIt) {
|
|
59
60
|
state._emergeCompleteIt(state._historyLines);
|
|
60
61
|
}
|