canvas-editor-engine 2.1.28 → 2.1.30

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/config.d.ts CHANGED
@@ -9,7 +9,9 @@ export declare class ConfigFabric {
9
9
  protected _ZOOM: number;
10
10
  }
11
11
  export default class AppConfig extends ConfigFabric {
12
+ private _canvas;
12
13
  constructor();
14
+ bindCanvas(canvasElement: HTMLDivElement): void;
13
15
  get CANVAS_SIZE(): ICanvasSize;
14
16
  set CANVAS_SIZE(value: ICanvasSize | undefined);
15
17
  get LAYERS(): ILayer[];
package/dist/index.mjs CHANGED
@@ -69,6 +69,7 @@ var AppConfig = function(_super) {
69
69
  __extends(AppConfig, _super);
70
70
  function AppConfig() {
71
71
  var _this = _super.call(this) || this;
72
+ _this._canvas = null;
72
73
  _this._CANVAS_SIZE = {
73
74
  width: 300,
74
75
  height: 150
@@ -86,6 +87,10 @@ var AppConfig = function(_super) {
86
87
  _this._ZOOM = 1;
87
88
  return _this;
88
89
  }
90
+ AppConfig.prototype.bindCanvas = function(canvasElement) {
91
+ var canvas = canvasElement.querySelector("canvas");
92
+ this._canvas = canvas;
93
+ };
89
94
  Object.defineProperty(AppConfig.prototype, "CANVAS_SIZE", {
90
95
  get: function() {
91
96
  return this._CANVAS_SIZE;
@@ -93,6 +98,10 @@ var AppConfig = function(_super) {
93
98
  set: function(value) {
94
99
  if (!!value && !!(value === null || value === void 0 ? void 0 : value.width) && !!(value === null || value === void 0 ? void 0 : value.height)) {
95
100
  this._CANVAS_SIZE = value;
101
+ if (!!this._canvas) {
102
+ this._canvas.width = value.width;
103
+ this._canvas.height = value.height;
104
+ }
96
105
  } else {
97
106
  console.warn("CANVAS_SIZE denied");
98
107
  }
@@ -2072,6 +2081,24 @@ var DownloadService = function() {
2072
2081
  return DownloadService;
2073
2082
  }();
2074
2083
 
2084
+ var ResizeService = function() {
2085
+ function ResizeService(appConfig, throughHistoryService) {
2086
+ this.appConfig = appConfig;
2087
+ this.throughHistoryService = throughHistoryService;
2088
+ }
2089
+ ResizeService.prototype.resize = function(ctx, size) {
2090
+ var currentRender = this.throughHistoryService.current();
2091
+ var state = currentRender.stateValue;
2092
+ this.appConfig.CANVAS_SIZE = size;
2093
+ this.updateCanvas(ctx, state);
2094
+ };
2095
+ ResizeService.prototype.updateCanvas = function(ctx, stateValue) {
2096
+ var filter = new Filter(this.appConfig, ctx);
2097
+ filter.update(stateValue.tempImageData, stateValue.position);
2098
+ };
2099
+ return ResizeService;
2100
+ }();
2101
+
2075
2102
  reflect();
2076
2103
 
2077
2104
  var WebComponentWrapper = function() {
@@ -2173,6 +2200,7 @@ var WebComponent = function(_super) {
2173
2200
  this.toolService = new ToolService(this.canvasComponent);
2174
2201
  this.appStoreRepository = new AppStoreRepository;
2175
2202
  this.throughHistoryService = new ThroughHistoryService(this.appConfig, this.appStoreRepository);
2203
+ this.resizeService = new ResizeService(this.appConfig, this.throughHistoryService);
2176
2204
  this.appStore = new AppStore(this.throughHistoryService, this.appStoreRepository);
2177
2205
  this.pullProjectService = new PullProjectService(this.throughHistoryService, this.appStoreRepository);
2178
2206
  this.drawService = new DrawService(this.appConfig, this.appStoreRepository, this.eventService);
@@ -2197,6 +2225,7 @@ var WebComponent = function(_super) {
2197
2225
  return this.initial();
2198
2226
  };
2199
2227
  WebComponent.prototype.initial = function() {
2228
+ this.appConfig.bindCanvas(this.canvasElement);
2200
2229
  return {
2201
2230
  editorElement: this.canvasElement,
2202
2231
  canvasSelector: this.canvasComponent.getCanvasSelector()
@@ -0,0 +1,10 @@
1
+ import AppConfig from "../config";
2
+ import { ISize } from "../types/general";
3
+ import ThroughHistoryService from "./through-history.service";
4
+ export default class ResizeService {
5
+ private appConfig;
6
+ private throughHistoryService;
7
+ constructor(appConfig: AppConfig, throughHistoryService: ThroughHistoryService);
8
+ resize(ctx: CanvasRenderingContext2D, size: ISize): void;
9
+ private updateCanvas;
10
+ }
@@ -17,6 +17,7 @@ import ProjectsService from "./services/projects.service";
17
17
  import PullProjectService from "./services/pull-project.service";
18
18
  import DrawService from "./services/draw.service";
19
19
  import DownloadService from "./services/download.service";
20
+ import ResizeService from "./services/serize.service";
20
21
  export declare class WebComponentWrapper {
21
22
  baseElement: HTMLDivElement;
22
23
  editorWrapElement: HTMLDivElement;
@@ -60,6 +61,7 @@ export default class WebComponent extends HTMLElement {
60
61
  loggerService: LoggerService;
61
62
  drawService: DrawService;
62
63
  downloadService: DownloadService;
64
+ resizeService: ResizeService;
63
65
  constructor();
64
66
  init(appConfig: AppConfig): {
65
67
  editorElement: HTMLDivElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.1.28",
3
+ "version": "2.1.30",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",