react-design-editor 0.0.41 → 0.0.45
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 +1161 -1551
- 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 +28 -5
- 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 -0
- package/lib/utils/ObjectUtil.d.ts +3 -2
- 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
|
-
*/
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const animejs_1 = __importDefault(require("animejs"));
|
|
7
|
+
const warning_1 = __importDefault(require("warning"));
|
|
7
8
|
class AnimationHandler {
|
|
8
9
|
constructor(handler) {
|
|
9
10
|
/**
|
|
@@ -164,6 +165,14 @@ class AnimationHandler {
|
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
167
|
else if (type === 'flash') {
|
|
168
|
+
if (obj.type === 'svg') {
|
|
169
|
+
obj._objects.forEach(child => this.handler.setByPartial(child, {
|
|
170
|
+
fill: child.originFill,
|
|
171
|
+
stroke: child.originStroke,
|
|
172
|
+
originFill: null,
|
|
173
|
+
originStroke: null,
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
167
176
|
Object.assign(option, {
|
|
168
177
|
fill: obj.originFill,
|
|
169
178
|
stroke: obj.originStroke,
|
|
@@ -205,11 +214,19 @@ class AnimationHandler {
|
|
|
205
214
|
update: (instance) => {
|
|
206
215
|
if (type === 'flash') {
|
|
207
216
|
// I don't know why it works. Magic code...
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
obj.
|
|
217
|
+
warning_1.default(instance.animations[0], 'instance.animations[0] undefined.');
|
|
218
|
+
warning_1.default(instance.animations[1], 'instance.animations[1] undefined.');
|
|
219
|
+
const fill = instance.animations[0]?.currentValue;
|
|
220
|
+
const stroke = instance.animations[1]?.currentValue;
|
|
221
|
+
if (obj.type === 'svg') {
|
|
222
|
+
obj.setFill(fill);
|
|
223
|
+
obj.setStroke(stroke);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
obj.set('fill', '');
|
|
227
|
+
obj.set('fill', fill);
|
|
228
|
+
obj.set('stroke', stroke);
|
|
229
|
+
}
|
|
213
230
|
}
|
|
214
231
|
else if (type === 'rotation') {
|
|
215
232
|
let angle = instance.animations[0].currentValue;
|
|
@@ -303,6 +320,12 @@ class AnimationHandler {
|
|
|
303
320
|
}
|
|
304
321
|
else if (type === 'flash') {
|
|
305
322
|
const { fill = obj.fill, stroke = obj.stroke } = other;
|
|
323
|
+
if (obj.type === 'svg') {
|
|
324
|
+
obj._objects.forEach(child => this.handler.setByPartial(child, {
|
|
325
|
+
originFill: child.fill,
|
|
326
|
+
originStroke: child.stroke,
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
306
329
|
obj.set('originFill', obj.fill);
|
|
307
330
|
obj.set('originStroke', obj.stroke);
|
|
308
331
|
Object.assign(option, {
|
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,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;
|
|
@@ -59,6 +67,14 @@ const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
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
|
+
},
|
|
62
78
|
toObject(propertiesToInclude) {
|
|
63
79
|
return utils_1.toObject(this, propertiesToInclude, {
|
|
64
80
|
svg: this.get('svg'),
|
|
@@ -81,9 +81,10 @@ export declare type FabricObjectOption<T extends any = fabric.IObjectOptions> =
|
|
|
81
81
|
originAngle?: number;
|
|
82
82
|
/**
|
|
83
83
|
* Original fill color
|
|
84
|
-
*
|
|
84
|
+
*
|
|
85
|
+
* @type {(string | fabric.Pattern | fabric.Gradient)}
|
|
85
86
|
*/
|
|
86
|
-
originFill?: string | fabric.Pattern;
|
|
87
|
+
originFill?: string | fabric.Pattern | fabric.Gradient;
|
|
87
88
|
/**
|
|
88
89
|
* Original stroke color
|
|
89
90
|
* @type {string}
|