canvas-editor-engine 2.3.70 → 2.3.72
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
@@ -2629,7 +2629,7 @@ var DrawLayersService = function() {
|
|
2629
2629
|
}));
|
2630
2630
|
} else {
|
2631
2631
|
_this.layerList = _this.layerList.map((function(item, idx) {
|
2632
|
-
if (idx
|
2632
|
+
if (idx >= replaceableIdx_1 && idx < layerIdx_1) {
|
2633
2633
|
item.order += 1;
|
2634
2634
|
}
|
2635
2635
|
return item;
|
@@ -2659,7 +2659,8 @@ var DrawLayersService = function() {
|
|
2659
2659
|
}();
|
2660
2660
|
|
2661
2661
|
var Painter = function() {
|
2662
|
-
function Painter(drawLayersService, createModel) {
|
2662
|
+
function Painter(canvasComponent, drawLayersService, createModel) {
|
2663
|
+
this.canvasComponent = canvasComponent;
|
2663
2664
|
this.drawLayersService = drawLayersService;
|
2664
2665
|
this.drawService = createModel.drawService;
|
2665
2666
|
this.drawType = createModel.drawType;
|
@@ -2670,7 +2671,56 @@ var Painter = function() {
|
|
2670
2671
|
view: new Date,
|
2671
2672
|
digital: Date.now()
|
2672
2673
|
};
|
2674
|
+
this.subscribeOnCanvas();
|
2673
2675
|
}
|
2676
|
+
Painter.prototype.subscribeOnCanvas = function() {
|
2677
|
+
var _this = this;
|
2678
|
+
this.canvasComponent.subscribe("mousedown", (function() {
|
2679
|
+
_this.focusTimer = setTimeout((function() {
|
2680
|
+
_this.focusPainter();
|
2681
|
+
}), 800);
|
2682
|
+
}));
|
2683
|
+
this.canvasComponent.subscribe("mouseup", (function() {
|
2684
|
+
_this.blurPainter();
|
2685
|
+
_this.focusTimer = null;
|
2686
|
+
}));
|
2687
|
+
this.canvasComponent.subscribe("mousemove", (function(event, cursorPosition) {
|
2688
|
+
if (!_this.isFocused) return;
|
2689
|
+
var x = cursorPosition.x, y = cursorPosition.y;
|
2690
|
+
var size = _this.drawService.options.image.drawImageArgs.size;
|
2691
|
+
var condition = size && size !== "initial";
|
2692
|
+
var position = {
|
2693
|
+
x: condition ? x - size.width / 2 : x,
|
2694
|
+
y: condition ? y - size.height / 2 : y
|
2695
|
+
};
|
2696
|
+
_this.changePainterPosition(position);
|
2697
|
+
}));
|
2698
|
+
};
|
2699
|
+
Painter.prototype.focusPainter = function() {
|
2700
|
+
this.isFocused = true;
|
2701
|
+
};
|
2702
|
+
Painter.prototype.blurPainter = function() {
|
2703
|
+
this.isFocused = false;
|
2704
|
+
};
|
2705
|
+
Painter.prototype.selectPainter = function() {
|
2706
|
+
this.isSelected = true;
|
2707
|
+
};
|
2708
|
+
Painter.prototype.unselectPainter = function() {
|
2709
|
+
this.isSelected = false;
|
2710
|
+
};
|
2711
|
+
Painter.prototype.changePainterPosition = function(position) {
|
2712
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2713
|
+
var _this = this;
|
2714
|
+
return __generator(this, (function(_a) {
|
2715
|
+
return [ 2, new Promise((function(resolve, reject) {
|
2716
|
+
if (!position) return reject(false);
|
2717
|
+
_this.drawService.options.image.drawImageArgs.position = position;
|
2718
|
+
_this.drawLayersService.updatePainterData(_this);
|
2719
|
+
resolve(true);
|
2720
|
+
})) ];
|
2721
|
+
}));
|
2722
|
+
}));
|
2723
|
+
};
|
2674
2724
|
Painter.prototype.putPainter = function(painter) {
|
2675
2725
|
return __awaiter(this, void 0, void 0, (function() {
|
2676
2726
|
var _this = this;
|
@@ -2740,11 +2790,12 @@ function createDynamicPainterStore() {
|
|
2740
2790
|
}
|
2741
2791
|
|
2742
2792
|
var DrawAccumulatorService = function() {
|
2743
|
-
function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService) {
|
2793
|
+
function DrawAccumulatorService(appConfig, appStoreRepository, eventService, drawLayersService, canvasComponent) {
|
2744
2794
|
this.appConfig = appConfig;
|
2745
2795
|
this.appStoreRepository = appStoreRepository;
|
2746
2796
|
this.eventService = eventService;
|
2747
2797
|
this.drawLayersService = drawLayersService;
|
2798
|
+
this.canvasComponent = canvasComponent;
|
2748
2799
|
this.painters = createDynamicPainterStore();
|
2749
2800
|
}
|
2750
2801
|
DrawAccumulatorService.prototype.add = function(layerId, drawType, options, initialSize) {
|
@@ -2752,7 +2803,7 @@ var DrawAccumulatorService = function() {
|
|
2752
2803
|
var id, painter;
|
2753
2804
|
return __generator(this, (function(_a) {
|
2754
2805
|
id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
2755
|
-
painter = new Painter(this.drawLayersService, {
|
2806
|
+
painter = new Painter(this.canvasComponent, this.drawLayersService, {
|
2756
2807
|
drawService: new DrawService(this.appConfig, this.appStoreRepository, this.eventService),
|
2757
2808
|
name: "Painter ".concat(id),
|
2758
2809
|
drawType,
|
@@ -3112,7 +3163,7 @@ var WebComponent = function(_super) {
|
|
3112
3163
|
this.pullProjectService = new PullProjectService(this.throughHistoryService, this.appStoreRepository);
|
3113
3164
|
this.drawService = new DrawService(this.appConfig, this.appStoreRepository, this.eventService);
|
3114
3165
|
this.drawLayersService = new DrawLayersService(this.appStoreRepository);
|
3115
|
-
this.drawAccumulatorService = new DrawAccumulatorService(this.appConfig, this.appStoreRepository, this.eventService, this.drawLayersService);
|
3166
|
+
this.drawAccumulatorService = new DrawAccumulatorService(this.appConfig, this.appStoreRepository, this.eventService, this.drawLayersService, this.canvasComponent);
|
3116
3167
|
this.downloadService = new DownloadService(this.canvasComponent);
|
3117
3168
|
var _a = this.canvasComponent.getComponent(), canvasTemplate = _a.canvasTemplate, canvasStyle = _a.canvasStyle;
|
3118
3169
|
this.canvasElement = this.webComponentWrapper.editorWrap.add(canvasTemplate, canvasStyle);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import CanvasComponent from "../components/canvas.component";
|
1
2
|
import AppConfig from "../config";
|
2
3
|
import AppStoreRepository from "../store/storeRepository";
|
3
4
|
import { ILayer, ILayerUpdate, IUpdateLayerOptions } from "../types/draw-layers";
|
@@ -12,8 +13,9 @@ export default class DrawAccumulatorService {
|
|
12
13
|
private appStoreRepository;
|
13
14
|
private eventService;
|
14
15
|
private drawLayersService;
|
16
|
+
private canvasComponent;
|
15
17
|
painters: Painter[];
|
16
|
-
constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService, drawLayersService: DrawLayersService);
|
18
|
+
constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService, drawLayersService: DrawLayersService, canvasComponent: CanvasComponent);
|
17
19
|
add<DrawType extends TDrawType>(layerId: ILayer['id'], drawType: DrawType, options: DrawService['options'][DrawType], initialSize: ITempCanvasOptions): Promise<void>;
|
18
20
|
getPainterById(painterId: string): Painter;
|
19
21
|
removePainter(painterId: string): Promise<void>;
|
package/dist/utils/painter.d.ts
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
import CanvasComponent from "../components/canvas.component";
|
1
2
|
import DrawLayersService from "../services/draw-layers.service";
|
2
3
|
import DrawService from "../services/draw.service";
|
3
4
|
import { IPainter, IPutPainter, TDrawType } from "../types/draw-service";
|
5
|
+
import { IPosition } from "../types/general";
|
4
6
|
export default class Painter {
|
7
|
+
private canvasComponent;
|
5
8
|
private drawLayersService;
|
6
9
|
drawService: DrawService;
|
7
10
|
drawType: TDrawType;
|
@@ -12,6 +15,15 @@ export default class Painter {
|
|
12
15
|
view: Date;
|
13
16
|
digital: number;
|
14
17
|
};
|
15
|
-
|
18
|
+
isFocused: boolean;
|
19
|
+
isSelected: boolean;
|
20
|
+
private focusTimer;
|
21
|
+
constructor(canvasComponent: CanvasComponent, drawLayersService: DrawLayersService, createModel: IPainter);
|
22
|
+
private subscribeOnCanvas;
|
23
|
+
focusPainter(): void;
|
24
|
+
blurPainter(): void;
|
25
|
+
selectPainter(): void;
|
26
|
+
unselectPainter(): void;
|
27
|
+
changePainterPosition(position: IPosition): Promise<unknown>;
|
16
28
|
putPainter(painter: IPutPainter): Promise<unknown>;
|
17
29
|
}
|