react-design-editor 0.0.38 → 0.0.39

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.
@@ -141,7 +141,9 @@ class Handler {
141
141
  return;
142
142
  }
143
143
  if ((activeObject.type === 'svg' && key === 'fill') || key === 'stroke') {
144
+ activeObject.set(key, value);
144
145
  activeObject._objects.forEach(obj => obj.set(key, value));
146
+ activeObject.setCoords();
145
147
  }
146
148
  else {
147
149
  activeObject.set(key, value);
@@ -5,20 +5,25 @@ const utils_1 = require("../utils");
5
5
  const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
6
6
  type: 'svg',
7
7
  initialize(option = {}) {
8
- const { svg, loadType } = option;
9
8
  this.callSuper('initialize', [], option);
10
- this.loadSvg(svg, loadType);
9
+ this.loadSvg(option);
11
10
  },
12
11
  addSvgElements(objects, options, path) {
13
12
  const createdObj = fabric_1.fabric.util.groupSVGElements(objects, options, path);
14
13
  this.set(options);
15
14
  if (createdObj.getObjects) {
16
- createdObj.getObjects().forEach(obj => this.add(obj));
15
+ createdObj.getObjects().forEach(obj => {
16
+ this.add(obj);
17
+ obj.set('fill', options.fill);
18
+ obj.set('stroke', options.stroke);
19
+ });
17
20
  }
18
21
  else {
19
22
  createdObj.set({
20
23
  originX: 'center',
21
24
  originY: 'center',
25
+ fill: options.fill,
26
+ stroke: options.stroke,
22
27
  });
23
28
  this.add(createdObj);
24
29
  }
@@ -27,16 +32,17 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
27
32
  this.canvas.requestRenderAll();
28
33
  }
29
34
  },
30
- loadSvg(svg, loadType) {
35
+ loadSvg(option) {
36
+ const { svg, loadType, fill, stroke } = option;
31
37
  return new Promise(resolve => {
32
38
  if (loadType === 'svg') {
33
39
  fabric_1.fabric.loadSVGFromString(svg, (objects, options) => {
34
- resolve(this.addSvgElements(objects, options, svg));
40
+ resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
35
41
  });
36
42
  }
37
43
  else {
38
44
  fabric_1.fabric.loadSVGFromURL(svg, (objects, options) => {
39
- resolve(this.addSvgElements(objects, options, svg));
45
+ resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
40
46
  });
41
47
  }
42
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-design-editor",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
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",