react-design-editor 0.0.56 → 0.0.57

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.
@@ -198494,9 +198494,7 @@ window.fabric.OrthogonalLink = OrthogonalLink;
198494
198494
  // CONCATENATED MODULE: ./src/canvas/objects/Svg.ts
198495
198495
 
198496
198496
 
198497
- function Svg_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
198498
198497
 
198499
- function Svg_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? Svg_ownKeys(Object(source), !0).forEach(function (key) { defineProperty_default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Svg_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
198500
198498
 
198501
198499
 
198502
198500
 
@@ -198508,7 +198506,9 @@ function Svg_objectSpread(target) { for (var i = 1; i < arguments.length; i++) {
198508
198506
 
198509
198507
 
198510
198508
 
198509
+ function Svg_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
198511
198510
 
198511
+ function Svg_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? Svg_ownKeys(Object(source), !0).forEach(function (key) { defineProperty_default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Svg_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
198512
198512
 
198513
198513
 
198514
198514
 
@@ -198519,11 +198519,24 @@ var Svg = fabric["fabric"].util.createClass(fabric["fabric"].Group, {
198519
198519
  this.callSuper('initialize', [], option);
198520
198520
  this.loadSvg(option);
198521
198521
  },
198522
- addSvgElements: function addSvgElements(objects, options, path) {
198523
- var _this = this;
198522
+ addSvgElements: function addSvgElements(objects, options) {
198523
+ var _this$_objects,
198524
+ _this = this;
198524
198525
 
198525
- var createdObj = fabric["fabric"].util.groupSVGElements(objects, options, path);
198526
- this.set(options);
198526
+ var createdObj = fabric["fabric"].util.groupSVGElements(objects, options);
198527
+ var height = this.height,
198528
+ scaleY = this.scaleY;
198529
+ var scale = height ? height * scaleY / createdObj.height : createdObj.scaleY;
198530
+ this.set(Svg_objectSpread(Svg_objectSpread({}, options), {}, {
198531
+ scaleX: scale,
198532
+ scaleY: scale
198533
+ }));
198534
+
198535
+ if ((_this$_objects = this._objects) !== null && _this$_objects !== void 0 && _this$_objects.length) {
198536
+ this.getObjects().forEach(function (obj) {
198537
+ _this.remove(obj);
198538
+ });
198539
+ }
198527
198540
 
198528
198541
  if (createdObj.getObjects) {
198529
198542
  createdObj.getObjects().forEach(function (obj) {
@@ -198538,7 +198551,7 @@ var Svg = fabric["fabric"].util.createClass(fabric["fabric"].Group, {
198538
198551
  }
198539
198552
  });
198540
198553
  } else {
198541
- var _this$_objects;
198554
+ var _this$_objects2;
198542
198555
 
198543
198556
  createdObj.set({
198544
198557
  originX: 'center',
@@ -198557,7 +198570,7 @@ var Svg = fabric["fabric"].util.createClass(fabric["fabric"].Group, {
198557
198570
  });
198558
198571
  }
198559
198572
 
198560
- if ((_this$_objects = this._objects) !== null && _this$_objects !== void 0 && _this$_objects.length) {
198573
+ if ((_this$_objects2 = this._objects) !== null && _this$_objects2 !== void 0 && _this$_objects2.length) {
198561
198574
  this._objects.forEach(function (obj) {
198562
198575
  return _this.remove(obj);
198563
198576
  });
@@ -198566,10 +198579,6 @@ var Svg = fabric["fabric"].util.createClass(fabric["fabric"].Group, {
198566
198579
  this.add(createdObj);
198567
198580
  }
198568
198581
 
198569
- this.set({
198570
- fill: options.fill,
198571
- stroke: options.stroke
198572
- });
198573
198582
  this.setCoords();
198574
198583
 
198575
198584
  if (this.canvas) {
@@ -198581,38 +198590,46 @@ var Svg = fabric["fabric"].util.createClass(fabric["fabric"].Group, {
198581
198590
  loadSvg: function loadSvg(option) {
198582
198591
  var _this2 = this;
198583
198592
 
198584
- var svg = option.svg,
198593
+ var src = option.src,
198585
198594
  loadType = option.loadType,
198586
198595
  fill = option.fill,
198587
198596
  stroke = option.stroke;
198588
198597
  return new Promise(function (resolve) {
198589
198598
  if (loadType === 'svg') {
198590
- fabric["fabric"].loadSVGFromString(svg, function (objects, options) {
198599
+ fabric["fabric"].loadSVGFromString(src, function (objects, options) {
198591
198600
  resolve(_this2.addSvgElements(objects, Svg_objectSpread(Svg_objectSpread({}, options), {}, {
198592
198601
  fill: fill,
198593
198602
  stroke: stroke
198594
- }), svg));
198603
+ })));
198595
198604
  });
198596
198605
  } else {
198597
- fabric["fabric"].loadSVGFromURL(svg, function (objects, options) {
198606
+ fabric["fabric"].loadSVGFromURL(src, function (objects, options) {
198598
198607
  resolve(_this2.addSvgElements(objects, Svg_objectSpread(Svg_objectSpread({}, options), {}, {
198599
198608
  fill: fill,
198600
198609
  stroke: stroke
198601
- }), svg));
198610
+ })));
198602
198611
  });
198603
198612
  }
198604
198613
  });
198605
198614
  },
198606
198615
  setFill: function setFill(value) {
198607
- this.getObjects().forEach(function (obj) {
198616
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
198617
+ return true;
198618
+ };
198619
+ this.getObjects().filter(filter).forEach(function (obj) {
198608
198620
  return obj.set('fill', value);
198609
198621
  });
198622
+ this.canvas.requestRenderAll();
198610
198623
  return this;
198611
198624
  },
198612
198625
  setStroke: function setStroke(value) {
198613
- this.getObjects().forEach(function (obj) {
198626
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
198627
+ return true;
198628
+ };
198629
+ this.getObjects().filter(filter).forEach(function (obj) {
198614
198630
  return obj.set('stroke', value);
198615
198631
  });
198632
+ this.canvas.requestRenderAll();
198616
198633
  return this;
198617
198634
  },
198618
198635
  toObject: function toObject(propertiesToInclude) {
@@ -202174,16 +202191,32 @@ var Handler_Handler = /*#__PURE__*/function () {
202174
202191
  }
202175
202192
  };
202176
202193
 
202177
- this.setImage = function (obj, source) {
202194
+ this.setImage = function (obj, source, keepSize, options) {
202195
+ var height = obj.height,
202196
+ scaleY = obj.scaleY;
202197
+
202198
+ var renderCallbaack = function renderCallbaack(imgObj, src) {
202199
+ if (keepSize) {
202200
+ var scale = height * scaleY / imgObj.height;
202201
+ imgObj.set({
202202
+ scaleY: scale,
202203
+ scaleX: scale,
202204
+ src: src
202205
+ });
202206
+ }
202207
+
202208
+ _this.canvas.requestRenderAll();
202209
+ };
202210
+
202178
202211
  return new Promise(function (resolve) {
202179
202212
  if (!source) {
202180
202213
  obj.set('file', null);
202181
202214
  obj.set('src', null);
202182
- resolve(obj.setSrc('./images/sample/transparentBg.png', function () {
202183
- return _this.canvas.renderAll();
202184
- }, {
202215
+ resolve(obj.setSrc('./images/sample/transparentBg.png', function (imgObj) {
202216
+ return renderCallbaack(imgObj, null);
202217
+ }, Handler_objectSpread({
202185
202218
  dirty: true
202186
- }));
202219
+ }, options)));
202187
202220
  }
202188
202221
 
202189
202222
  if (source instanceof File) {
@@ -202192,31 +202225,62 @@ var Handler_Handler = /*#__PURE__*/function () {
202192
202225
  reader.onload = function () {
202193
202226
  obj.set('file', source);
202194
202227
  obj.set('src', null);
202195
- resolve(obj.setSrc(reader.result, function () {
202196
- return _this.canvas.renderAll();
202197
- }, {
202228
+ resolve(obj.setSrc(reader.result, function (imgObj) {
202229
+ return renderCallbaack(imgObj, reader.result);
202230
+ }, Handler_objectSpread({
202198
202231
  dirty: true
202199
- }));
202232
+ }, options)));
202200
202233
  };
202201
202234
 
202202
202235
  reader.readAsDataURL(source);
202203
202236
  } else {
202204
202237
  obj.set('file', null);
202205
202238
  obj.set('src', source);
202206
- resolve(obj.setSrc(source, function () {
202207
- return _this.canvas.renderAll();
202208
- }, {
202239
+ resolve(obj.setSrc(source, function (imgObj) {
202240
+ return renderCallbaack(imgObj, source);
202241
+ }, Handler_objectSpread({
202209
202242
  dirty: true,
202210
202243
  crossOrigin: 'anonymous'
202211
- }));
202244
+ }, options)));
202212
202245
  }
202213
202246
  });
202214
202247
  };
202215
202248
 
202216
- this.setImageById = function (id, source) {
202249
+ this.setImageById = function (id, source, keepSize) {
202217
202250
  var findObject = _this.findById(id);
202218
202251
 
202219
- return Promise.resolve(_this.setImage(findObject, source));
202252
+ return Promise.resolve(_this.setImage(findObject, source, keepSize));
202253
+ };
202254
+
202255
+ this.setSvg = function (obj, source, isPath, keepSize) {
202256
+ return new Promise(function (resolve) {
202257
+ if (!source) {
202258
+ resolve(obj.loadSvg({
202259
+ src: './images/sample/chiller.svg',
202260
+ loadType: 'file',
202261
+ keepSize: keepSize
202262
+ }));
202263
+ }
202264
+
202265
+ if (source instanceof File) {
202266
+ var reader = new FileReader();
202267
+ reader.readAsDataURL(source);
202268
+
202269
+ reader.onload = function () {
202270
+ return resolve(obj.loadSvg({
202271
+ src: reader.result,
202272
+ loadType: 'file',
202273
+ keepSize: keepSize
202274
+ }));
202275
+ };
202276
+ } else {
202277
+ resolve(obj.loadSvg({
202278
+ src: source,
202279
+ loadType: isPath ? 'svg' : 'file',
202280
+ keepSize: keepSize
202281
+ }));
202282
+ }
202283
+ });
202220
202284
  };
202221
202285
 
202222
202286
  this.setVisible = function (visible) {