canvas-editor-engine 1.0.84 → 1.0.86
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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/services/through-history.service.d.ts +4 -1
- package/dist/services/through-history.service.js +6 -0
- package/dist/store/history.state.d.ts +2 -2
- package/dist/store/history.state.js +19 -17
- package/dist/types/history.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import CropService from "./services/crop.service";
|
|
|
12
12
|
import DownloadService from "./services/download.service";
|
|
13
13
|
import ToolLayerService from "./services/tool-layers.service";
|
|
14
14
|
import EventService from "./services/event.service";
|
|
15
|
+
import ThroughHistoryService from "./services/through-history.service";
|
|
15
16
|
import AppStore from "./store/store";
|
|
16
17
|
declare class CanvasEditorEngine {
|
|
17
18
|
constructor(webComponentTagName?: string);
|
|
@@ -29,4 +30,4 @@ declare class VueCanvasEditorEngine extends CanvasEditorEngine {
|
|
|
29
30
|
getContext2D(): CanvasRenderingContext2D;
|
|
30
31
|
getCanvas(): HTMLCanvasElement;
|
|
31
32
|
}
|
|
32
|
-
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, EventService, StaticCanvasEditorEngine, VueCanvasEditorEngine, AppStore, };
|
|
33
|
+
export { AppConfig, PipetteComponent, CanvasComponent, ExcretionComponent, SlotComponent, LoadingComponent, ToolService, DrawService, LoggerService, CropService, DownloadService, ToolLayerService, EventService, ThroughHistoryService, StaticCanvasEditorEngine, VueCanvasEditorEngine, AppStore, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppStore = exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.EventService = exports.ToolLayerService = exports.DownloadService = exports.CropService = exports.LoggerService = exports.DrawService = exports.ToolService = exports.LoadingComponent = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
|
|
3
|
+
exports.AppStore = exports.VueCanvasEditorEngine = exports.StaticCanvasEditorEngine = exports.ThroughHistoryService = exports.EventService = exports.ToolLayerService = exports.DownloadService = exports.CropService = exports.LoggerService = exports.DrawService = exports.ToolService = exports.LoadingComponent = exports.SlotComponent = exports.ExcretionComponent = exports.CanvasComponent = exports.PipetteComponent = exports.AppConfig = void 0;
|
|
4
4
|
const config_1 = require("./config");
|
|
5
5
|
exports.AppConfig = config_1.default;
|
|
6
6
|
const web_component_1 = require("./web-component");
|
|
@@ -28,6 +28,8 @@ const tool_layers_service_1 = require("./services/tool-layers.service");
|
|
|
28
28
|
exports.ToolLayerService = tool_layers_service_1.default;
|
|
29
29
|
const event_service_1 = require("./services/event.service");
|
|
30
30
|
exports.EventService = event_service_1.default;
|
|
31
|
+
const through_history_service_1 = require("./services/through-history.service");
|
|
32
|
+
exports.ThroughHistoryService = through_history_service_1.default;
|
|
31
33
|
const store_1 = require("./store/store");
|
|
32
34
|
exports.AppStore = store_1.default;
|
|
33
35
|
class CanvasEditorEngine {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { IHistoryLine } from "../types/history";
|
|
1
2
|
export default class ThroughHistoryService {
|
|
2
|
-
static
|
|
3
|
+
static cache: IHistoryLine[];
|
|
4
|
+
static current(): IHistoryLine;
|
|
3
5
|
static undo(): void;
|
|
4
6
|
static redo(): void;
|
|
7
|
+
static clearCache(): void;
|
|
5
8
|
}
|
|
@@ -2,16 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const store_1 = require("../store/store");
|
|
4
4
|
class ThroughHistoryService {
|
|
5
|
+
static cache = [];
|
|
5
6
|
static current() {
|
|
6
7
|
const history = store_1.default.store.historyState.historyLines;
|
|
7
8
|
const lastIndex = history.length - 1;
|
|
8
9
|
return history[lastIndex];
|
|
9
10
|
}
|
|
10
11
|
static undo() {
|
|
12
|
+
store_1.default.store.historyState.reduce('UNDO');
|
|
11
13
|
}
|
|
12
14
|
;
|
|
13
15
|
static redo() {
|
|
16
|
+
store_1.default.store.historyState.reduce('REDO', ThroughHistoryService.cache.shift());
|
|
14
17
|
}
|
|
15
18
|
;
|
|
19
|
+
static clearCache() {
|
|
20
|
+
ThroughHistoryService.cache = [];
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
exports.default = ThroughHistoryService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StateService } from "../services/store.service";
|
|
2
|
-
import { IHistoryLine } from "../types/history";
|
|
2
|
+
import { IHistoryLine, TReducerNames } from "../types/history";
|
|
3
3
|
export interface IHistoryState {
|
|
4
4
|
historyLines: IHistoryLine[];
|
|
5
5
|
}
|
|
@@ -9,7 +9,7 @@ export declare class HistoryState implements StateService {
|
|
|
9
9
|
private _historyLines;
|
|
10
10
|
get historyLines(): IHistoryState['historyLines'];
|
|
11
11
|
constructor();
|
|
12
|
-
reduce(name:
|
|
12
|
+
reduce(name: TReducerNames, payload?: IHistoryLine | IHistoryState): void;
|
|
13
13
|
emerge(completeIt: (history: IHistoryState['historyLines']) => void): void;
|
|
14
14
|
reset(): void;
|
|
15
15
|
}
|
|
@@ -14,24 +14,20 @@ class HistoryState {
|
|
|
14
14
|
this.reset();
|
|
15
15
|
}
|
|
16
16
|
reduce(name, payload) {
|
|
17
|
-
// let isUpdate = false;
|
|
18
|
-
// if (!!(payload as IHistoryState)?.historyLines) {
|
|
19
|
-
// this._historyLines = (payload as IHistoryState).historyLines;
|
|
20
|
-
// isUpdate = true;
|
|
21
|
-
// }
|
|
22
|
-
// if (!!(payload as IHistoryLine)?.view) {
|
|
23
|
-
// this._historyLines.push(payload as IHistoryLine);
|
|
24
|
-
// isUpdate = true;
|
|
25
|
-
// }
|
|
26
|
-
// if (isUpdate && !!this._emergeCompleteIt) {
|
|
27
|
-
// this._emergeCompleteIt(this._historyLines);
|
|
28
|
-
// }
|
|
29
17
|
const reducer = new Reducer();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
switch (name) {
|
|
19
|
+
case 'SET_HISTORY':
|
|
20
|
+
reducer.setHistoryLines(payload, this);
|
|
21
|
+
break;
|
|
22
|
+
case 'UPDATE_HISTORY':
|
|
23
|
+
reducer.updateHistoryLines(payload, this);
|
|
24
|
+
break;
|
|
25
|
+
case 'REDO':
|
|
26
|
+
reducer.updateHistoryLines(payload, this);
|
|
27
|
+
break;
|
|
28
|
+
case 'UNDO':
|
|
29
|
+
reducer.popHistoryLines(this);
|
|
30
|
+
break;
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
emerge(completeIt) {
|
|
@@ -63,4 +59,10 @@ class Reducer {
|
|
|
63
59
|
state._emergeCompleteIt(state._historyLines);
|
|
64
60
|
}
|
|
65
61
|
}
|
|
62
|
+
popHistoryLines(state) {
|
|
63
|
+
state._historyLines.pop();
|
|
64
|
+
if (!!state._emergeCompleteIt) {
|
|
65
|
+
state._emergeCompleteIt(state._historyLines);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
66
68
|
}
|
package/dist/types/history.d.ts
CHANGED