canvas-editor-engine 2.3.42 → 2.3.44
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.mjs
CHANGED
@@ -1388,6 +1388,10 @@ var DrawLayersState = function() {
|
|
1388
1388
|
case "ADD_LAYER":
|
1389
1389
|
reducer.addLayer(payload);
|
1390
1390
|
break;
|
1391
|
+
|
1392
|
+
case "REMOVE_LAYER":
|
1393
|
+
reducer.removeLayer(payload);
|
1394
|
+
break;
|
1391
1395
|
}
|
1392
1396
|
};
|
1393
1397
|
DrawLayersState.prototype.emerge = function(completeIt) {
|
@@ -1438,6 +1442,21 @@ var Reducer$1 = function() {
|
|
1438
1442
|
this.state._emergeCompleteIt(this.state._layers);
|
1439
1443
|
}
|
1440
1444
|
};
|
1445
|
+
Reducer.prototype.removeLayer = function(payload) {
|
1446
|
+
var isUpdate = false;
|
1447
|
+
if (!!payload) {
|
1448
|
+
var targetLayerIndex = this.state._layers.findIndex((function(layer) {
|
1449
|
+
return layer.id === payload.id;
|
1450
|
+
}));
|
1451
|
+
if (targetLayerIndex != -1) {
|
1452
|
+
this.state._layers.splice(targetLayerIndex, 1);
|
1453
|
+
isUpdate = true;
|
1454
|
+
}
|
1455
|
+
}
|
1456
|
+
if (isUpdate && !!this.state._emergeCompleteIt) {
|
1457
|
+
this.state._emergeCompleteIt(this.state._layers);
|
1458
|
+
}
|
1459
|
+
};
|
1441
1460
|
Reducer.prototype.popLayer = function() {
|
1442
1461
|
this.state._layers.pop();
|
1443
1462
|
if (!!this.state._emergeCompleteIt) {
|
@@ -2448,17 +2467,27 @@ var DrawLayersService = function() {
|
|
2448
2467
|
this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2449
2468
|
};
|
2450
2469
|
DrawLayersService.prototype.updateLayer = function(id, updateData) {
|
2451
|
-
var
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2470
|
+
var _this = this;
|
2471
|
+
return new Promise((function(resolve, reject) {
|
2472
|
+
var layerIndex = _this.layerList.findIndex((function(layer) {
|
2473
|
+
return layer.id === id;
|
2474
|
+
}));
|
2475
|
+
var fields = Object.keys(updateData);
|
2476
|
+
if (!fields.length || layerIndex === -1) return reject({
|
2477
|
+
status: "error",
|
2478
|
+
message: "Layer not found"
|
2479
|
+
});
|
2480
|
+
var layer = _this.layerList[layerIndex];
|
2481
|
+
fields.forEach((function(field) {
|
2482
|
+
layer[field] = updateData[field];
|
2483
|
+
}));
|
2484
|
+
_this.layerList[layerIndex] = layer;
|
2485
|
+
_this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2486
|
+
resolve({
|
2487
|
+
status: "success",
|
2488
|
+
message: "Layer updated"
|
2489
|
+
});
|
2459
2490
|
}));
|
2460
|
-
this.layerList[layerIndex] = layer;
|
2461
|
-
this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2462
2491
|
};
|
2463
2492
|
DrawLayersService.prototype.removePainter = function(id) {
|
2464
2493
|
var layerIndex = this.layerList.findIndex((function(layer) {
|
@@ -2487,6 +2516,25 @@ var DrawLayersService = function() {
|
|
2487
2516
|
var layer = this.layerList[layerIndex];
|
2488
2517
|
this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2489
2518
|
};
|
2519
|
+
DrawLayersService.prototype.removeLayer = function(id) {
|
2520
|
+
var _this = this;
|
2521
|
+
return new Promise((function(resolve, reject) {
|
2522
|
+
var layerIndex = _this.layerList.findIndex((function(layer) {
|
2523
|
+
return layer.id === id;
|
2524
|
+
}));
|
2525
|
+
if (layerIndex === -1) return reject({
|
2526
|
+
status: "error",
|
2527
|
+
message: "Layer not found"
|
2528
|
+
});
|
2529
|
+
var layer = _this.layerList[layerIndex];
|
2530
|
+
_this.layerList.splice(layerIndex, 1);
|
2531
|
+
_this.appStoreRepository.store.drawLayersState.reduce("REMOVE_LAYER", layer);
|
2532
|
+
resolve({
|
2533
|
+
status: "success",
|
2534
|
+
message: "Layer removed"
|
2535
|
+
});
|
2536
|
+
}));
|
2537
|
+
};
|
2490
2538
|
DrawLayersService.prototype.changeLayerOrder = function(id, options) {
|
2491
2539
|
return __awaiter(this, void 0, void 0, (function() {
|
2492
2540
|
var _this = this;
|
@@ -2633,6 +2681,18 @@ var DrawAccumulatorService = function() {
|
|
2633
2681
|
}));
|
2634
2682
|
}));
|
2635
2683
|
};
|
2684
|
+
DrawAccumulatorService.prototype.getPainterById = function(painterId) {
|
2685
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2686
|
+
var painter;
|
2687
|
+
return __generator(this, (function(_a) {
|
2688
|
+
painter = this.painters.find((function(painter) {
|
2689
|
+
return painter.id === painterId;
|
2690
|
+
}));
|
2691
|
+
if (!painter) throw new Error("Painter not found");
|
2692
|
+
return [ 2, painter ];
|
2693
|
+
}));
|
2694
|
+
}));
|
2695
|
+
};
|
2636
2696
|
DrawAccumulatorService.prototype.removePainter = function(painterId) {
|
2637
2697
|
return __awaiter(this, void 0, void 0, (function() {
|
2638
2698
|
var painter, filteredPainters, len;
|
@@ -2698,6 +2758,49 @@ var DrawAccumulatorService = function() {
|
|
2698
2758
|
}));
|
2699
2759
|
}));
|
2700
2760
|
};
|
2761
|
+
DrawAccumulatorService.prototype.renameLayer = function(id, newName) {
|
2762
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2763
|
+
var updateData;
|
2764
|
+
var _this = this;
|
2765
|
+
return __generator(this, (function(_a) {
|
2766
|
+
updateData = {
|
2767
|
+
name: newName
|
2768
|
+
};
|
2769
|
+
this.drawLayersService.updateLayer(id, updateData).then((function(res) {
|
2770
|
+
if (res.status === "success") {
|
2771
|
+
_this.update();
|
2772
|
+
} else {
|
2773
|
+
console.warn(res === null || res === void 0 ? void 0 : res.message);
|
2774
|
+
}
|
2775
|
+
})).catch((function(ex) {
|
2776
|
+
console.warn("".concat(ex.status, ": ").concat(ex.message));
|
2777
|
+
}));
|
2778
|
+
return [ 2 ];
|
2779
|
+
}));
|
2780
|
+
}));
|
2781
|
+
};
|
2782
|
+
DrawAccumulatorService.prototype.removeLayer = function(layerId) {
|
2783
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2784
|
+
var layer;
|
2785
|
+
var _this = this;
|
2786
|
+
return __generator(this, (function(_a) {
|
2787
|
+
layer = this.drawLayersService.getLayerById(layerId);
|
2788
|
+
layer.painters.map((function(painter) {
|
2789
|
+
return painter.id;
|
2790
|
+
})).forEach((function(painterId) {
|
2791
|
+
_this.removePainter(painterId);
|
2792
|
+
}));
|
2793
|
+
this.drawLayersService.removeLayer(layerId).then((function(res) {
|
2794
|
+
if (res.status === "success") {
|
2795
|
+
_this.update();
|
2796
|
+
}
|
2797
|
+
})).catch((function(ex) {
|
2798
|
+
console.warn("".concat(ex.status, ": ").concat(ex.message));
|
2799
|
+
}));
|
2800
|
+
return [ 2 ];
|
2801
|
+
}));
|
2802
|
+
}));
|
2803
|
+
};
|
2701
2804
|
DrawAccumulatorService.prototype.updateLayerOrder = function(layerId, options) {
|
2702
2805
|
var _this = this;
|
2703
2806
|
this.drawLayersService.changeLayerOrder(layerId, options).then((function(res) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import AppConfig from "../config";
|
2
2
|
import AppStoreRepository from "../store/storeRepository";
|
3
|
-
import { ILayer, IUpdateLayerOptions } from "../types/draw-layers";
|
3
|
+
import { ILayer, ILayerUpdate, IUpdateLayerOptions } from "../types/draw-layers";
|
4
4
|
import { IPainter, ISmoothFilterOptions, TDrawType } from "../types/draw-service";
|
5
5
|
import { ITempCanvasOptions } from "../types/temp-canvas";
|
6
6
|
import Painter from "../utils/painter";
|
@@ -15,9 +15,12 @@ export default class DrawAccumulatorService {
|
|
15
15
|
painters: Painter[];
|
16
16
|
constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService, drawLayersService: DrawLayersService);
|
17
17
|
add<DrawType extends TDrawType>(layerId: ILayer['id'], drawType: DrawType, options: DrawService['options'][DrawType], initialSize: ITempCanvasOptions): Promise<void>;
|
18
|
+
getPainterById(painterId: string): Promise<Painter>;
|
18
19
|
removePainter(painterId: string): Promise<void>;
|
19
20
|
renamePainter(painterId: IPainter['id'], name: string): void;
|
20
21
|
smoothFilter(painterId: IPainter['id'], smoothFilterOptions: ISmoothFilterOptions): Promise<void>;
|
22
|
+
renameLayer(id: ILayer["id"], newName: ILayerUpdate['name']): Promise<void>;
|
23
|
+
removeLayer(layerId: ILayer['id']): Promise<void>;
|
21
24
|
updateLayerOrder(layerId: ILayer['id'], options: IUpdateLayerOptions): void;
|
22
25
|
private update;
|
23
26
|
private get gradient();
|
@@ -14,8 +14,9 @@ export default class DrawLayersService {
|
|
14
14
|
getLayersByOrder(order: number): ILayer[];
|
15
15
|
getLayerById(layerId: ILayer['id']): ILayer;
|
16
16
|
addToLayer(id: ILayer['id'], painter: IPainter): void;
|
17
|
-
updateLayer(id: ILayer['id'], updateData?: ILayerUpdate):
|
17
|
+
updateLayer(id: ILayer['id'], updateData?: ILayerUpdate): Promise<unknown>;
|
18
18
|
removePainter(id: IPainter['id']): void;
|
19
19
|
updatePainterData(painter: Painter): void;
|
20
|
+
removeLayer(id: ILayer['id']): Promise<unknown>;
|
20
21
|
changeLayerOrder(id: ILayer['id'], options: IUpdateLayerOptions): Promise<unknown>;
|
21
22
|
}
|
@@ -10,7 +10,7 @@ export interface ILayerUpdate {
|
|
10
10
|
order?: ILayer['order'];
|
11
11
|
name?: ILayer['name'];
|
12
12
|
}
|
13
|
-
export type TReducerNames = 'SET_LAYERS' | 'UPDATE_LAYER' | 'ADD_LAYER';
|
13
|
+
export type TReducerNames = 'SET_LAYERS' | 'UPDATE_LAYER' | 'ADD_LAYER' | 'REMOVE_LAYER';
|
14
14
|
export interface IUpdateLayerOptions {
|
15
15
|
to?: number;
|
16
16
|
direction?: 'up' | 'down';
|