react-design-editor 0.0.43 → 0.0.47
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 +1033 -1446
- 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/objects/Svg.d.ts +5 -1
- package/lib/objects/Svg.js +10 -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/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;
|
|
@@ -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, {
|
|
@@ -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}
|