react-design-editor 0.0.43 → 0.0.44

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.
@@ -1,9 +1,3 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
1
  /*!
8
2
  * MediaElement.js
9
3
  * http://www.mediaelementjs.com/
@@ -35,21 +29,3 @@ object-assign
35
29
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
36
30
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
37
31
  */
38
-
39
- /** @license React v0.19.1
40
- * scheduler.production.min.js
41
- *
42
- * Copyright (c) Facebook, Inc. and its affiliates.
43
- *
44
- * This source code is licensed under the MIT license found in the
45
- * LICENSE file in the root directory of this source tree.
46
- */
47
-
48
- /** @license React v16.14.0
49
- * react-dom.production.min.js
50
- *
51
- * Copyright (c) Facebook, Inc. and its affiliates.
52
- *
53
- * This source code is licensed under the MIT license found in the
54
- * LICENSE file in the root directory of this source tree.
55
- */
@@ -207,9 +207,15 @@ class AnimationHandler {
207
207
  // I don't know why it works. Magic code...
208
208
  const fill = instance.animations[0].currentValue;
209
209
  const stroke = instance.animations[1].currentValue;
210
- obj.set('fill', '');
211
- obj.set('fill', fill);
212
- obj.set('stroke', stroke);
210
+ if (obj.type === 'svg') {
211
+ obj.setFill(fill);
212
+ obj.setStroke(stroke);
213
+ }
214
+ else {
215
+ obj.set('fill', '');
216
+ obj.set('fill', fill);
217
+ obj.set('stroke', stroke);
218
+ }
213
219
  }
214
220
  else if (type === 'rotation') {
215
221
  let angle = instance.animations[0].currentValue;
@@ -1,5 +1,9 @@
1
1
  import { FabricGroup, FabricObject, FabricObjectOption } from '../utils';
2
- export declare type SvgObject = FabricGroup | FabricObject;
2
+ export declare type SvgObject = (FabricGroup | FabricObject) & {
3
+ loadSvg(option: SvgOption): Promise<SvgObject>;
4
+ setFill(value: string): SvgObject;
5
+ setStroke(value: string): SvgObject;
6
+ };
3
7
  export interface SvgOption extends FabricObjectOption {
4
8
  svg?: string;
5
9
  loadType?: 'file' | 'svg';
@@ -37,12 +37,20 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
37
37
  stroke: options.stroke,
38
38
  });
39
39
  }
40
+ if (this._objects?.length) {
41
+ this._objects.forEach(obj => this.remove(obj));
42
+ }
40
43
  this.add(createdObj);
41
44
  }
45
+ this.set({
46
+ fill: options.fill || 'rgba(0, 0, 0, 1)',
47
+ stroke: options.stroke || 'rgba(255, 255, 255, 0)',
48
+ });
42
49
  this.setCoords();
43
50
  if (this.canvas) {
44
51
  this.canvas.requestRenderAll();
45
52
  }
53
+ return this;
46
54
  },
47
55
  loadSvg(option) {
48
56
  const { svg, loadType, fill, stroke } = option;
@@ -61,9 +69,11 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
61
69
  },
62
70
  setFill(value) {
63
71
  this.getObjects().forEach((obj) => obj.set('fill', value));
72
+ return this;
64
73
  },
65
74
  setStroke(value) {
66
75
  this.getObjects().forEach((obj) => obj.set('stroke', value));
76
+ return this;
67
77
  },
68
78
  toObject(propertiesToInclude) {
69
79
  return utils_1.toObject(this, propertiesToInclude, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-design-editor",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "Design Editor Tools with React.js + ant.design + fabric.js",
5
5
  "main": "dist/react-design-editor.min.js",
6
6
  "typings": "lib/index.d.ts",