react-design-editor 0.0.39 → 0.0.43
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/lib/handlers/Handler.js
CHANGED
|
@@ -140,15 +140,11 @@ class Handler {
|
|
|
140
140
|
if (!activeObject) {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
if (
|
|
144
|
-
activeObject.set(key, value);
|
|
143
|
+
if (activeObject.type === 'svg' && (key === 'fill' || key === 'stroke')) {
|
|
145
144
|
activeObject._objects.forEach(obj => obj.set(key, value));
|
|
146
|
-
activeObject.setCoords();
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
activeObject.set(key, value);
|
|
150
|
-
activeObject.setCoords();
|
|
151
145
|
}
|
|
146
|
+
activeObject.set(key, value);
|
|
147
|
+
activeObject.setCoords();
|
|
152
148
|
this.canvas.requestRenderAll();
|
|
153
149
|
const { id, superType, type, player, width, height } = activeObject;
|
|
154
150
|
if (superType === 'element') {
|
|
@@ -226,6 +222,14 @@ class Handler {
|
|
|
226
222
|
if (!obj) {
|
|
227
223
|
return;
|
|
228
224
|
}
|
|
225
|
+
if (obj.type === 'svg') {
|
|
226
|
+
if (key === 'fill') {
|
|
227
|
+
obj.setFill(value);
|
|
228
|
+
}
|
|
229
|
+
else if (key === 'stroke') {
|
|
230
|
+
obj.setStroke(value);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
229
233
|
obj.set(key, value);
|
|
230
234
|
obj.setCoords();
|
|
231
235
|
this.canvas.renderAll();
|
|
@@ -273,6 +277,14 @@ class Handler {
|
|
|
273
277
|
if (!obj) {
|
|
274
278
|
return;
|
|
275
279
|
}
|
|
280
|
+
if (obj.type === 'svg') {
|
|
281
|
+
if (option.fill) {
|
|
282
|
+
obj.setFill(option.fill);
|
|
283
|
+
}
|
|
284
|
+
else if (option.stroke) {
|
|
285
|
+
obj.setStroke(option.stroke);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
276
288
|
obj.set(option);
|
|
277
289
|
obj.setCoords();
|
|
278
290
|
this.canvas.renderAll();
|
|
@@ -1215,24 +1227,23 @@ class Handler {
|
|
|
1215
1227
|
let prevLeft = 0;
|
|
1216
1228
|
let prevTop = 0;
|
|
1217
1229
|
this.canvas.setBackgroundColor(this.canvasOption.backgroundColor, this.canvas.renderAll.bind(this.canvas));
|
|
1218
|
-
const
|
|
1230
|
+
const workarea = json.find((obj) => obj.id === 'workarea');
|
|
1219
1231
|
if (!this.workarea) {
|
|
1220
1232
|
this.workareaHandler.initialize();
|
|
1221
1233
|
}
|
|
1222
|
-
if (
|
|
1223
|
-
this.canvas.centerObject(this.workarea);
|
|
1224
|
-
this.workarea.setCoords();
|
|
1225
|
-
prevLeft = this.workarea.left;
|
|
1226
|
-
prevTop = this.workarea.top;
|
|
1227
|
-
}
|
|
1228
|
-
else {
|
|
1229
|
-
const workarea = workareaExist[0];
|
|
1234
|
+
if (workarea) {
|
|
1230
1235
|
prevLeft = workarea.left;
|
|
1231
1236
|
prevTop = workarea.top;
|
|
1232
1237
|
this.workarea.set(workarea);
|
|
1233
1238
|
await this.workareaHandler.setImage(workarea.src, true);
|
|
1234
1239
|
this.workarea.setCoords();
|
|
1235
1240
|
}
|
|
1241
|
+
else {
|
|
1242
|
+
this.canvas.centerObject(this.workarea);
|
|
1243
|
+
this.workarea.setCoords();
|
|
1244
|
+
prevLeft = this.workarea.left;
|
|
1245
|
+
prevTop = this.workarea.top;
|
|
1246
|
+
}
|
|
1236
1247
|
json.forEach((obj) => {
|
|
1237
1248
|
if (obj.id === 'workarea') {
|
|
1238
1249
|
return;
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
7
6
|
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
7
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
8
8
|
class TooltipHandler {
|
|
9
9
|
constructor(handler) {
|
|
10
10
|
/**
|
|
@@ -22,7 +22,7 @@ class TooltipHandler {
|
|
|
22
22
|
let element = target.name;
|
|
23
23
|
const { onTooltip } = this.handler;
|
|
24
24
|
if (onTooltip) {
|
|
25
|
-
element = await onTooltip(
|
|
25
|
+
element = await onTooltip(tooltip, target);
|
|
26
26
|
if (!element) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
package/lib/objects/Svg.js
CHANGED
|
@@ -14,17 +14,29 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
|
14
14
|
if (createdObj.getObjects) {
|
|
15
15
|
createdObj.getObjects().forEach(obj => {
|
|
16
16
|
this.add(obj);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (options.fill) {
|
|
18
|
+
obj.set('fill', options.fill);
|
|
19
|
+
}
|
|
20
|
+
if (options.stroke) {
|
|
21
|
+
obj.set('stroke', options.stroke);
|
|
22
|
+
}
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
22
26
|
createdObj.set({
|
|
23
27
|
originX: 'center',
|
|
24
28
|
originY: 'center',
|
|
25
|
-
fill: options.fill,
|
|
26
|
-
stroke: options.stroke,
|
|
27
29
|
});
|
|
30
|
+
if (options.fill) {
|
|
31
|
+
createdObj.set({
|
|
32
|
+
fill: options.fill,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (options.stroke) {
|
|
36
|
+
createdObj.set({
|
|
37
|
+
stroke: options.stroke,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
28
40
|
this.add(createdObj);
|
|
29
41
|
}
|
|
30
42
|
this.setCoords();
|
|
@@ -47,6 +59,12 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
|
47
59
|
}
|
|
48
60
|
});
|
|
49
61
|
},
|
|
62
|
+
setFill(value) {
|
|
63
|
+
this.getObjects().forEach((obj) => obj.set('fill', value));
|
|
64
|
+
},
|
|
65
|
+
setStroke(value) {
|
|
66
|
+
this.getObjects().forEach((obj) => obj.set('stroke', value));
|
|
67
|
+
},
|
|
50
68
|
toObject(propertiesToInclude) {
|
|
51
69
|
return utils_1.toObject(this, propertiesToInclude, {
|
|
52
70
|
svg: this.get('svg'),
|