canvas-editor-engine 2.3.20 → 2.3.22
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
@@ -2467,9 +2467,45 @@ var DrawLayersService = function() {
|
|
2467
2467
|
var layer = this.layerList[layerIndex];
|
2468
2468
|
this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2469
2469
|
};
|
2470
|
+
DrawLayersService.prototype.updatePainterData = function(painter) {
|
2471
|
+
var layerIndex = this.layerList.findIndex((function(layer) {
|
2472
|
+
return layer.painters.find((function(layerPainter) {
|
2473
|
+
return layerPainter.id === painter.id;
|
2474
|
+
}));
|
2475
|
+
}));
|
2476
|
+
if (layerIndex === -1) return;
|
2477
|
+
var painterIndex = this.layerList[layerIndex].painters.findIndex((function(layerPainter) {
|
2478
|
+
return layerPainter.id === painter.id;
|
2479
|
+
}));
|
2480
|
+
this.layerList[layerIndex].painters[painterIndex] = painter;
|
2481
|
+
var layer = this.layerList[layerIndex];
|
2482
|
+
this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2483
|
+
};
|
2470
2484
|
return DrawLayersService;
|
2471
2485
|
}();
|
2472
2486
|
|
2487
|
+
var Painter = function() {
|
2488
|
+
function Painter(drawLayersService, createModel) {
|
2489
|
+
this.drawLayersService = drawLayersService;
|
2490
|
+
this.drawService = createModel.drawService;
|
2491
|
+
this.drawType = createModel.drawType;
|
2492
|
+
this.id = createModel.id;
|
2493
|
+
this.name = createModel.name;
|
2494
|
+
}
|
2495
|
+
Painter.prototype.putPainter = function(painter) {
|
2496
|
+
var isUpdated = false;
|
2497
|
+
if (painter.name) {
|
2498
|
+
this.name = painter.name;
|
2499
|
+
isUpdated = true;
|
2500
|
+
}
|
2501
|
+
if (isUpdated) {
|
2502
|
+
console.log("Painter maybe updated:", this);
|
2503
|
+
this.drawLayersService.updatePainterData(this);
|
2504
|
+
}
|
2505
|
+
};
|
2506
|
+
return Painter;
|
2507
|
+
}();
|
2508
|
+
|
2473
2509
|
var DrawAccumulatorService = function() {
|
2474
2510
|
function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService) {
|
2475
2511
|
this.appConfig = appConfig;
|
@@ -2511,11 +2547,12 @@ var DrawAccumulatorService = function() {
|
|
2511
2547
|
var id, painter;
|
2512
2548
|
return __generator(this, (function(_a) {
|
2513
2549
|
id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
2514
|
-
painter = {
|
2550
|
+
painter = new Painter(this.drawLayersService, {
|
2515
2551
|
drawService: new DrawService(this.appConfig, this.appStoreRepository, this.eventService),
|
2552
|
+
name: "Painter ".concat(id),
|
2516
2553
|
drawType,
|
2517
2554
|
id
|
2518
|
-
};
|
2555
|
+
});
|
2519
2556
|
painter.drawService.bindOptions(drawType, options);
|
2520
2557
|
painter.drawService.tempCanvas.bindOptions(initialSize);
|
2521
2558
|
this.painters.push({
|
@@ -2528,23 +2565,35 @@ var DrawAccumulatorService = function() {
|
|
2528
2565
|
}));
|
2529
2566
|
}));
|
2530
2567
|
};
|
2531
|
-
DrawAccumulatorService.prototype.removePainter = function(
|
2568
|
+
DrawAccumulatorService.prototype.removePainter = function(painterId) {
|
2532
2569
|
return __awaiter(this, void 0, void 0, (function() {
|
2533
2570
|
var painter;
|
2534
2571
|
return __generator(this, (function(_a) {
|
2535
2572
|
painter = this.painters.find((function(painter) {
|
2536
|
-
return painter.id ===
|
2573
|
+
return painter.id === painterId;
|
2537
2574
|
}));
|
2538
2575
|
if (!!painter) {
|
2539
2576
|
this.painters = this.painters.filter((function(painter) {
|
2540
|
-
return painter.id !==
|
2577
|
+
return painter.id !== painterId;
|
2541
2578
|
}));
|
2542
2579
|
}
|
2543
|
-
this.drawLayersService.removePainter(
|
2580
|
+
this.drawLayersService.removePainter(painterId);
|
2544
2581
|
return [ 2 ];
|
2545
2582
|
}));
|
2546
2583
|
}));
|
2547
2584
|
};
|
2585
|
+
DrawAccumulatorService.prototype.renamePainter = function(painterId, name) {
|
2586
|
+
var painter = this.painters.find((function(painter) {
|
2587
|
+
return painter.id === painterId;
|
2588
|
+
}));
|
2589
|
+
if (painter) {
|
2590
|
+
painter.putPainter({
|
2591
|
+
name
|
2592
|
+
});
|
2593
|
+
} else {
|
2594
|
+
console.error("Painter not found");
|
2595
|
+
}
|
2596
|
+
};
|
2548
2597
|
DrawAccumulatorService.prototype.smoothFilter = function(painterId, smoothFilterOptions) {
|
2549
2598
|
return __awaiter(this, void 0, void 0, (function() {
|
2550
2599
|
var useStore, options, filterOptions, painter;
|
@@ -3,6 +3,7 @@ import AppStoreRepository from "../store/storeRepository";
|
|
3
3
|
import { ILayer } from "../types/draw-layers";
|
4
4
|
import { IPainter, ISmoothFilterOptions, TDrawType } from "../types/draw-service";
|
5
5
|
import { ITempCanvasOptions } from "../types/temp-canvas";
|
6
|
+
import Painter from "../utils/painter";
|
6
7
|
import DrawLayersService from "./draw-layers.service";
|
7
8
|
import DrawService from "./draw.service";
|
8
9
|
import EventService from "./event.service";
|
@@ -11,10 +12,11 @@ export default class DrawAccumulatorService {
|
|
11
12
|
private appStoreRepository;
|
12
13
|
private eventService;
|
13
14
|
private drawLayersService;
|
14
|
-
painters:
|
15
|
+
painters: Painter[];
|
15
16
|
constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService, drawLayersService: DrawLayersService);
|
16
17
|
add<DrawType extends TDrawType>(layerId: ILayer['id'], drawType: DrawType, options: DrawService['options'][DrawType], initialSize: ITempCanvasOptions): Promise<void>;
|
17
|
-
removePainter(
|
18
|
+
removePainter(painterId: string): Promise<void>;
|
19
|
+
renamePainter(painterId: IPainter['id'], name: string): void;
|
18
20
|
smoothFilter(painterId: IPainter['id'], smoothFilterOptions: ISmoothFilterOptions): Promise<void>;
|
19
21
|
private update;
|
20
22
|
private get gradient();
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import AppStoreRepository from "../store/storeRepository";
|
2
2
|
import { ILayer, ILayerUpdate } from "../types/draw-layers";
|
3
3
|
import { IPainter } from "../types/draw-service";
|
4
|
+
import Painter from "../utils/painter";
|
4
5
|
export default class DrawLayersService {
|
5
6
|
private appStoreRepository;
|
6
7
|
layerList: ILayer[];
|
@@ -14,4 +15,5 @@ export default class DrawLayersService {
|
|
14
15
|
addToLayer(id: ILayer['id'], painter: IPainter): void;
|
15
16
|
updateLayer(id: ILayer['id'], updateData?: ILayerUpdate): void;
|
16
17
|
removePainter(id: IPainter['id']): void;
|
18
|
+
updatePainterData(painter: Painter): void;
|
17
19
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import DrawLayersService from "../services/draw-layers.service";
|
2
|
+
import DrawService from "../services/draw.service";
|
3
|
+
import { IPainter, IPutPainter, TDrawType } from "../types/draw-service";
|
4
|
+
export default class Painter {
|
5
|
+
private drawLayersService;
|
6
|
+
drawService: DrawService;
|
7
|
+
drawType: TDrawType;
|
8
|
+
id: string;
|
9
|
+
name: string;
|
10
|
+
constructor(drawLayersService: DrawLayersService, createModel: IPainter);
|
11
|
+
putPainter(painter: IPutPainter): void;
|
12
|
+
}
|