canvas-editor-engine 2.3.20 → 2.3.21
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,44 @@ 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
|
+
this.drawLayersService.updatePainterData(this);
|
2503
|
+
}
|
2504
|
+
};
|
2505
|
+
return Painter;
|
2506
|
+
}();
|
2507
|
+
|
2473
2508
|
var DrawAccumulatorService = function() {
|
2474
2509
|
function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService) {
|
2475
2510
|
this.appConfig = appConfig;
|
@@ -2511,11 +2546,12 @@ var DrawAccumulatorService = function() {
|
|
2511
2546
|
var id, painter;
|
2512
2547
|
return __generator(this, (function(_a) {
|
2513
2548
|
id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
2514
|
-
painter = {
|
2549
|
+
painter = new Painter(this.drawLayersService, {
|
2515
2550
|
drawService: new DrawService(this.appConfig, this.appStoreRepository, this.eventService),
|
2551
|
+
name: "Painter ".concat(id),
|
2516
2552
|
drawType,
|
2517
2553
|
id
|
2518
|
-
};
|
2554
|
+
});
|
2519
2555
|
painter.drawService.bindOptions(drawType, options);
|
2520
2556
|
painter.drawService.tempCanvas.bindOptions(initialSize);
|
2521
2557
|
this.painters.push({
|
@@ -2528,23 +2564,35 @@ var DrawAccumulatorService = function() {
|
|
2528
2564
|
}));
|
2529
2565
|
}));
|
2530
2566
|
};
|
2531
|
-
DrawAccumulatorService.prototype.removePainter = function(
|
2567
|
+
DrawAccumulatorService.prototype.removePainter = function(painterId) {
|
2532
2568
|
return __awaiter(this, void 0, void 0, (function() {
|
2533
2569
|
var painter;
|
2534
2570
|
return __generator(this, (function(_a) {
|
2535
2571
|
painter = this.painters.find((function(painter) {
|
2536
|
-
return painter.id ===
|
2572
|
+
return painter.id === painterId;
|
2537
2573
|
}));
|
2538
2574
|
if (!!painter) {
|
2539
2575
|
this.painters = this.painters.filter((function(painter) {
|
2540
|
-
return painter.id !==
|
2576
|
+
return painter.id !== painterId;
|
2541
2577
|
}));
|
2542
2578
|
}
|
2543
|
-
this.drawLayersService.removePainter(
|
2579
|
+
this.drawLayersService.removePainter(painterId);
|
2544
2580
|
return [ 2 ];
|
2545
2581
|
}));
|
2546
2582
|
}));
|
2547
2583
|
};
|
2584
|
+
DrawAccumulatorService.prototype.renamePainter = function(painterId, name) {
|
2585
|
+
var painter = this.painters.find((function(painter) {
|
2586
|
+
return painter.id === painterId;
|
2587
|
+
}));
|
2588
|
+
if (painter) {
|
2589
|
+
painter.putPainter({
|
2590
|
+
name
|
2591
|
+
});
|
2592
|
+
} else {
|
2593
|
+
console.error("Painter not found");
|
2594
|
+
}
|
2595
|
+
};
|
2548
2596
|
DrawAccumulatorService.prototype.smoothFilter = function(painterId, smoothFilterOptions) {
|
2549
2597
|
return __awaiter(this, void 0, void 0, (function() {
|
2550
2598
|
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
|
+
}
|