react-design-editor 0.0.52 → 0.0.55

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.
@@ -193676,9 +193676,12 @@ var TransactionHandler_TransactionHandler = /*#__PURE__*/createClass_default()(f
193676
193676
  var ZoomHandler_ZoomHandler = /*#__PURE__*/createClass_default()(function ZoomHandler(handler) {
193677
193677
  var _this = this;
193678
193678
 
193679
+ var zoomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
193680
+
193679
193681
  classCallCheck_default()(this, ZoomHandler);
193680
193682
 
193681
193683
  this.handler = void 0;
193684
+ this._zoomStep = void 0;
193682
193685
 
193683
193686
  this.zoomToPoint = function (point, zoom) {
193684
193687
  var _this$handler = _this.handler,
@@ -193759,7 +193762,7 @@ var ZoomHandler_ZoomHandler = /*#__PURE__*/createClass_default()(function ZoomHa
193759
193762
  this.zoomIn = function () {
193760
193763
  var zoomRatio = _this.handler.canvas.getZoom();
193761
193764
 
193762
- zoomRatio += 0.05;
193765
+ zoomRatio += _this._zoomStep;
193763
193766
 
193764
193767
  var center = _this.handler.canvas.getCenter();
193765
193768
 
@@ -193769,7 +193772,7 @@ var ZoomHandler_ZoomHandler = /*#__PURE__*/createClass_default()(function ZoomHa
193769
193772
  this.zoomOut = function () {
193770
193773
  var zoomRatio = _this.handler.canvas.getZoom();
193771
193774
 
193772
- zoomRatio -= 0.05;
193775
+ zoomRatio -= _this._zoomStep;
193773
193776
 
193774
193777
  var center = _this.handler.canvas.getCenter();
193775
193778
 
@@ -193831,6 +193834,7 @@ var ZoomHandler_ZoomHandler = /*#__PURE__*/createClass_default()(function ZoomHa
193831
193834
  };
193832
193835
 
193833
193836
  this.handler = handler;
193837
+ this._zoomStep = zoomStep;
193834
193838
  }
193835
193839
  /**
193836
193840
  * Zoom to point
@@ -194257,6 +194261,8 @@ var WorkareaHandler_WorkareaHandler = /*#__PURE__*/function () {
194257
194261
 
194258
194262
  canvas.renderAll();
194259
194263
  resolve(workarea);
194264
+ }, {
194265
+ crossOrigin: 'anonymous'
194260
194266
  });
194261
194267
  }));
194262
194268
 
@@ -199435,6 +199441,22 @@ var AlignmentHandler_AlignmentHandler = /*#__PURE__*/createClass_default()(funct
199435
199441
  }
199436
199442
  };
199437
199443
 
199444
+ this.middle = function () {
199445
+ var activeObject = _this.handler.canvas.getActiveObject();
199446
+
199447
+ if (activeObject && activeObject.type === 'activeSelection') {
199448
+ var activeSelection = activeObject;
199449
+ activeSelection.forEachObject(function (obj) {
199450
+ obj.set({
199451
+ top: 0 - obj.width * obj.scaleX / 2
199452
+ });
199453
+ obj.setCoords();
199454
+
199455
+ _this.handler.canvas.renderAll();
199456
+ });
199457
+ }
199458
+ };
199459
+
199438
199460
  this.right = function () {
199439
199461
  var activeObject = _this.handler.canvas.getActiveObject();
199440
199462
 
@@ -200150,9 +200172,9 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200150
200172
  var zoomRatio = _this.handler.canvas.getZoom();
200151
200173
 
200152
200174
  if (delta > 0) {
200153
- zoomRatio -= 0.05;
200175
+ zoomRatio -= _this.handler.zoomStep;
200154
200176
  } else {
200155
- zoomRatio += 0.05;
200177
+ zoomRatio += _this.handler.zoomStep;
200156
200178
  }
200157
200179
 
200158
200180
  _this.handler.zoomHandler.zoomToPoint(new fabric["fabric"].Point(_this.handler.canvas.getWidth() / 2, _this.handler.canvas.getHeight() / 2), zoomRatio);
@@ -200542,6 +200564,8 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200542
200564
  });
200543
200565
 
200544
200566
  if (filteredObjects.length === 1) {
200567
+ var _this$handler$onAdd, _this$handler3;
200568
+
200545
200569
  var obj = filteredObjects[0];
200546
200570
 
200547
200571
  if (typeof obj.cloneable !== 'undefined' && !obj.cloneable) {
@@ -200556,7 +200580,11 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200556
200580
  _this.handler.canvas.setActiveObject(createdObj);
200557
200581
 
200558
200582
  _this.handler.canvas.requestRenderAll();
200583
+
200584
+ (_this$handler$onAdd = (_this$handler3 = _this.handler).onAdd) === null || _this$handler$onAdd === void 0 ? void 0 : _this$handler$onAdd.call(_this$handler3, createdObj);
200559
200585
  } else {
200586
+ var _this$handler$onAdd2, _this$handler4;
200587
+
200560
200588
  var nodes = [];
200561
200589
  var targets = [];
200562
200590
  objects.forEach(function (obj) {
@@ -200587,6 +200615,8 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200587
200615
  _this.handler.canvas.setActiveObject(activeSelection);
200588
200616
 
200589
200617
  _this.handler.canvas.requestRenderAll();
200618
+
200619
+ (_this$handler$onAdd2 = (_this$handler4 = _this.handler).onAdd) === null || _this$handler$onAdd2 === void 0 ? void 0 : _this$handler$onAdd2.call(_this$handler4, activeSelection);
200590
200620
  }
200591
200621
 
200592
200622
  if (!_this.handler.transactionHandler.active) {
@@ -200642,9 +200672,9 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200642
200672
  }();
200643
200673
 
200644
200674
  this.keydown = function (e) {
200645
- var _this$handler3 = _this.handler,
200646
- keyEvent = _this$handler3.keyEvent,
200647
- editable = _this$handler3.editable;
200675
+ var _this$handler5 = _this.handler,
200676
+ keyEvent = _this$handler5.keyEvent,
200677
+ editable = _this$handler5.editable;
200648
200678
 
200649
200679
  if (!Object.keys(keyEvent).length) {
200650
200680
  return;
@@ -200764,9 +200794,9 @@ var EventHandler_EventHandler = /*#__PURE__*/function () {
200764
200794
 
200765
200795
  this.contextmenu = function (e) {
200766
200796
  e.preventDefault();
200767
- var _this$handler4 = _this.handler,
200768
- editable = _this$handler4.editable,
200769
- onContext = _this$handler4.onContext;
200797
+ var _this$handler6 = _this.handler,
200798
+ editable = _this$handler6.editable,
200799
+ onContext = _this$handler6.onContext;
200770
200800
 
200771
200801
  if (editable && onContext) {
200772
200802
  var target = _this.handler.canvas.findTarget(e, false);
@@ -201742,6 +201772,7 @@ var Handler_Handler = /*#__PURE__*/function () {
201742
201772
  this.interactionMode = void 0;
201743
201773
  this.minZoom = void 0;
201744
201774
  this.maxZoom = void 0;
201775
+ this.zoomStep = 0.05;
201745
201776
  this.propertiesToInclude = defaults_namespaceObject.propertiesToInclude;
201746
201777
  this.workareaOption = defaults_namespaceObject.workareaOption;
201747
201778
  this.canvasOption = defaults_namespaceObject.canvasOption;
@@ -201809,6 +201840,7 @@ var Handler_Handler = /*#__PURE__*/function () {
201809
201840
  _this.interactionMode = options.interactionMode;
201810
201841
  _this.minZoom = options.minZoom;
201811
201842
  _this.maxZoom = options.maxZoom;
201843
+ _this.zoomStep = options.zoomStep || 0.05;
201812
201844
  _this.zoomEnabled = options.zoomEnabled;
201813
201845
  _this.width = options.width;
201814
201846
  _this.height = options.height;
@@ -201857,7 +201889,7 @@ var Handler_Handler = /*#__PURE__*/function () {
201857
201889
  _this.animationHandler = new handlers_AnimationHandler(_this);
201858
201890
  _this.contextmenuHandler = new handlers_ContextmenuHandler(_this);
201859
201891
  _this.tooltipHandler = new handlers_TooltipHandler(_this);
201860
- _this.zoomHandler = new handlers_ZoomHandler(_this);
201892
+ _this.zoomHandler = new handlers_ZoomHandler(_this, _this.zoomStep);
201861
201893
  _this.interactionHandler = new handlers_InteractionHandler(_this);
201862
201894
  _this.transactionHandler = new handlers_TransactionHandler(_this);
201863
201895
  _this.gridHandler = new handlers_GridHandler(_this);
@@ -202168,7 +202200,8 @@ var Handler_Handler = /*#__PURE__*/function () {
202168
202200
  resolve(obj.setSrc(source, function () {
202169
202201
  return _this.canvas.renderAll();
202170
202202
  }, {
202171
- dirty: true
202203
+ dirty: true,
202204
+ crossOrigin: "anonymous"
202172
202205
  }));
202173
202206
  }
202174
202207
  });
@@ -203449,16 +203482,21 @@ var Handler_Handler = /*#__PURE__*/function () {
203449
203482
  format: 'png',
203450
203483
  quality: 1
203451
203484
  };
203452
-
203453
203485
  // If it's zoomed out/in, the container will also include in the image
203454
203486
  // hence need to reset the zoom level.
203455
- _this.zoomHandler.zoomOneToOne();
203456
-
203457
203487
  var _this$workarea2 = _this.workarea,
203458
203488
  left = _this$workarea2.left,
203459
203489
  top = _this$workarea2.top,
203460
203490
  width = _this$workarea2.width,
203461
- height = _this$workarea2.height;
203491
+ height = _this$workarea2.height,
203492
+ scaleX = _this$workarea2.scaleX,
203493
+ scaleY = _this$workarea2.scaleY;
203494
+ width = Math.ceil(width * scaleX);
203495
+ height = Math.ceil(height * scaleY); // cachedVT is used to reset the viewportTransform after the image is saved.
203496
+
203497
+ var cachedVT = _this.canvas.viewportTransform; // reset the viewportTransform to default (no zoom)
203498
+
203499
+ _this.canvas.viewportTransform = [1, 0, 0, 1, 0, 0];
203462
203500
 
203463
203501
  var dataUrl = _this.canvas.toDataURL(Handler_objectSpread(Handler_objectSpread({}, option), {}, {
203464
203502
  left: left,
@@ -203475,7 +203513,10 @@ var Handler_Handler = /*#__PURE__*/function () {
203475
203513
  document.body.appendChild(anchorEl);
203476
203514
  anchorEl.click();
203477
203515
  anchorEl.remove();
203478
- }
203516
+ } // reset the viewportTransform to previous value.
203517
+
203518
+
203519
+ _this.canvas.viewportTransform = cachedVT;
203479
203520
  };
203480
203521
 
203481
203522
  this.rotate = function (angle) {