react-design-editor 0.0.40 → 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.
- package/dist/react-design-editor.js +841 -1261
- package/dist/react-design-editor.min.js +1 -1
- package/dist/react-design-editor.min.js.LICENSE.txt +0 -24
- package/lib/handlers/AnimationHandler.js +9 -3
- package/lib/handlers/Handler.js +27 -16
- package/lib/handlers/TooltipHandler.d.ts +1 -1
- package/lib/handlers/TooltipHandler.js +2 -2
- package/lib/objects/Svg.d.ts +5 -1
- package/lib/objects/Svg.js +16 -1
- package/package.json +1 -1
|
@@ -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.
|
|
211
|
-
|
|
212
|
-
|
|
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;
|
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.d.ts
CHANGED
|
@@ -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';
|
package/lib/objects/Svg.js
CHANGED
|
@@ -37,16 +37,23 @@ 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;
|
|
49
|
-
console.log(option);
|
|
50
57
|
return new Promise(resolve => {
|
|
51
58
|
if (loadType === 'svg') {
|
|
52
59
|
fabric_1.fabric.loadSVGFromString(svg, (objects, options) => {
|
|
@@ -60,6 +67,14 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
|
60
67
|
}
|
|
61
68
|
});
|
|
62
69
|
},
|
|
70
|
+
setFill(value) {
|
|
71
|
+
this.getObjects().forEach((obj) => obj.set('fill', value));
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
setStroke(value) {
|
|
75
|
+
this.getObjects().forEach((obj) => obj.set('stroke', value));
|
|
76
|
+
return this;
|
|
77
|
+
},
|
|
63
78
|
toObject(propertiesToInclude) {
|
|
64
79
|
return utils_1.toObject(this, propertiesToInclude, {
|
|
65
80
|
svg: this.get('svg'),
|