react-design-editor 0.0.49 → 0.0.51
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 +9762 -9139
- package/dist/react-design-editor.min.js +1 -1
- package/dist/react-design-editor.min.js.LICENSE.txt +2 -0
- package/lib/Canvas.d.ts +18 -18
- package/lib/Canvas.js +172 -172
- package/lib/CanvasObject.d.ts +10 -10
- package/lib/CanvasObject.js +96 -96
- package/lib/constants/code.d.ts +19 -19
- package/lib/constants/code.js +22 -22
- package/lib/constants/defaults.d.ts +38 -38
- package/lib/constants/defaults.js +69 -69
- package/lib/constants/index.d.ts +3 -3
- package/lib/constants/index.js +26 -26
- package/lib/handlers/AlignmentHandler.d.ts +18 -18
- package/lib/handlers/AlignmentHandler.js +58 -58
- package/lib/handlers/AnimationHandler.d.ts +50 -50
- package/lib/handlers/AnimationHandler.js +346 -346
- package/lib/handlers/ChartHandler.d.ts +8 -8
- package/lib/handlers/ChartHandler.js +8 -8
- package/lib/handlers/ContextmenuHandler.d.ts +28 -28
- package/lib/handlers/ContextmenuHandler.js +65 -65
- package/lib/handlers/CropHandler.d.ts +43 -43
- package/lib/handlers/CropHandler.js +261 -261
- package/lib/handlers/CustomHandler.d.ts +7 -7
- package/lib/handlers/CustomHandler.js +10 -10
- package/lib/handlers/DrawingHandler.d.ts +28 -28
- package/lib/handlers/DrawingHandler.js +318 -318
- package/lib/handlers/ElementHandler.d.ts +80 -80
- package/lib/handlers/ElementHandler.js +154 -154
- package/lib/handlers/EventHandler.d.ts +170 -170
- package/lib/handlers/EventHandler.js +880 -880
- package/lib/handlers/FiberHandler.d.ts +6 -6
- package/lib/handlers/FiberHandler.js +23 -23
- package/lib/handlers/GridHandler.d.ts +19 -19
- package/lib/handlers/GridHandler.js +77 -77
- package/lib/handlers/GuidelineHandler.d.ts +61 -61
- package/lib/handlers/GuidelineHandler.js +315 -315
- package/lib/handlers/Handler.d.ts +618 -622
- package/lib/handlers/Handler.js +1645 -1651
- package/lib/handlers/ImageHandler.d.ts +307 -307
- package/lib/handlers/ImageHandler.js +528 -529
- package/lib/handlers/InteractionHandler.d.ts +45 -45
- package/lib/handlers/InteractionHandler.js +168 -164
- package/lib/handlers/LinkHandler.d.ts +115 -115
- package/lib/handlers/LinkHandler.js +247 -247
- package/lib/handlers/NodeHandler.d.ts +50 -50
- package/lib/handlers/NodeHandler.js +274 -274
- package/lib/handlers/PortHandler.d.ts +22 -22
- package/lib/handlers/PortHandler.js +179 -179
- package/lib/handlers/ShortcutHandler.d.ts +119 -119
- package/lib/handlers/ShortcutHandler.js +151 -151
- package/lib/handlers/TooltipHandler.d.ts +33 -33
- package/lib/handlers/TooltipHandler.js +91 -91
- package/lib/handlers/TransactionHandler.d.ts +59 -59
- package/lib/handlers/TransactionHandler.js +137 -137
- package/lib/handlers/WorkareaHandler.d.ts +43 -43
- package/lib/handlers/WorkareaHandler.js +354 -354
- package/lib/handlers/ZoomHandler.d.ts +48 -48
- package/lib/handlers/ZoomHandler.js +143 -143
- package/lib/handlers/index.d.ts +23 -23
- package/lib/handlers/index.js +48 -48
- package/lib/index.d.ts +6 -6
- package/lib/index.js +20 -20
- package/lib/objects/Arrow.d.ts +2 -2
- package/lib/objects/Arrow.js +40 -40
- package/lib/objects/Chart.d.ts +10 -10
- package/lib/objects/Chart.js +117 -117
- package/lib/objects/CirclePort.d.ts +2 -2
- package/lib/objects/CirclePort.js +28 -28
- package/lib/objects/Cube.d.ts +5 -5
- package/lib/objects/Cube.js +71 -71
- package/lib/objects/CurvedLink.d.ts +2 -2
- package/lib/objects/CurvedLink.js +51 -51
- package/lib/objects/Element.d.ts +13 -13
- package/lib/objects/Element.js +77 -77
- package/lib/objects/Gif.d.ts +3 -3
- package/lib/objects/Gif.js +41 -41
- package/lib/objects/Iframe.d.ts +9 -9
- package/lib/objects/Iframe.js +63 -63
- package/lib/objects/Line.d.ts +2 -2
- package/lib/objects/Line.js +24 -24
- package/lib/objects/Link.d.ts +15 -15
- package/lib/objects/Link.js +107 -107
- package/lib/objects/Node.d.ts +59 -59
- package/lib/objects/Node.js +271 -271
- package/lib/objects/OrthogonalLink.d.ts +2 -2
- package/lib/objects/OrthogonalLink.js +54 -54
- package/lib/objects/Port.d.ts +12 -12
- package/lib/objects/Port.js +28 -28
- package/lib/objects/Svg.d.ts +12 -12
- package/lib/objects/Svg.js +93 -93
- package/lib/objects/Video.d.ts +14 -14
- package/lib/objects/Video.js +113 -113
- package/lib/objects/index.d.ts +15 -15
- package/lib/objects/index.js +32 -32
- package/lib/utils/ObjectUtil.d.ts +408 -408
- package/lib/utils/ObjectUtil.js +13 -13
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +13 -13
- package/package.json +1 -1
package/lib/objects/Port.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { fabric } from 'fabric';
|
|
2
|
-
import { FabricObject } from '../utils';
|
|
3
|
-
import { LinkObject } from './Link';
|
|
4
|
-
export interface PortObject extends FabricObject<fabric.Rect> {
|
|
5
|
-
links?: LinkObject[];
|
|
6
|
-
nodeId?: string;
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
hoverFill?: string;
|
|
9
|
-
selectFill?: string;
|
|
10
|
-
}
|
|
11
|
-
declare const Port: any;
|
|
12
|
-
export default Port;
|
|
1
|
+
import { fabric } from 'fabric';
|
|
2
|
+
import { FabricObject } from '../utils';
|
|
3
|
+
import { LinkObject } from './Link';
|
|
4
|
+
export interface PortObject extends FabricObject<fabric.Rect> {
|
|
5
|
+
links?: LinkObject[];
|
|
6
|
+
nodeId?: string;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
hoverFill?: string;
|
|
9
|
+
selectFill?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const Port: any;
|
|
12
|
+
export default Port;
|
package/lib/objects/Port.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
const Port = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
5
|
-
type: 'port',
|
|
6
|
-
superType: 'port',
|
|
7
|
-
initialize(options) {
|
|
8
|
-
options = options || {};
|
|
9
|
-
this.callSuper('initialize', options);
|
|
10
|
-
},
|
|
11
|
-
toObject() {
|
|
12
|
-
return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
|
|
13
|
-
id: this.get('id'),
|
|
14
|
-
superType: this.get('superType'),
|
|
15
|
-
enabled: this.get('enabled'),
|
|
16
|
-
nodeId: this.get('nodeId'),
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
_render(ctx) {
|
|
20
|
-
this.callSuper('_render', ctx);
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
Port.fromObject = (options, callback) => {
|
|
24
|
-
return callback(new Port(options));
|
|
25
|
-
};
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
window.fabric.Port = Port;
|
|
28
|
-
exports.default = Port;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const Port = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
5
|
+
type: 'port',
|
|
6
|
+
superType: 'port',
|
|
7
|
+
initialize(options) {
|
|
8
|
+
options = options || {};
|
|
9
|
+
this.callSuper('initialize', options);
|
|
10
|
+
},
|
|
11
|
+
toObject() {
|
|
12
|
+
return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
|
|
13
|
+
id: this.get('id'),
|
|
14
|
+
superType: this.get('superType'),
|
|
15
|
+
enabled: this.get('enabled'),
|
|
16
|
+
nodeId: this.get('nodeId'),
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
_render(ctx) {
|
|
20
|
+
this.callSuper('_render', ctx);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
Port.fromObject = (options, callback) => {
|
|
24
|
+
return callback(new Port(options));
|
|
25
|
+
};
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
window.fabric.Port = Port;
|
|
28
|
+
exports.default = Port;
|
package/lib/objects/Svg.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { FabricGroup, FabricObject, FabricObjectOption } from '../utils';
|
|
2
|
-
export declare type SvgObject = (FabricGroup | FabricObject) & {
|
|
3
|
-
loadSvg(option: SvgOption): Promise<SvgObject>;
|
|
4
|
-
setFill(value: string): SvgObject;
|
|
5
|
-
setStroke(value: string): SvgObject;
|
|
6
|
-
};
|
|
7
|
-
export interface SvgOption extends FabricObjectOption {
|
|
8
|
-
svg?: string;
|
|
9
|
-
loadType?: 'file' | 'svg';
|
|
10
|
-
}
|
|
11
|
-
declare const Svg: any;
|
|
12
|
-
export default Svg;
|
|
1
|
+
import { FabricGroup, FabricObject, FabricObjectOption } from '../utils';
|
|
2
|
+
export declare type SvgObject = (FabricGroup | FabricObject) & {
|
|
3
|
+
loadSvg(option: SvgOption): Promise<SvgObject>;
|
|
4
|
+
setFill(value: string): SvgObject;
|
|
5
|
+
setStroke(value: string): SvgObject;
|
|
6
|
+
};
|
|
7
|
+
export interface SvgOption extends FabricObjectOption {
|
|
8
|
+
svg?: string;
|
|
9
|
+
loadType?: 'file' | 'svg';
|
|
10
|
+
}
|
|
11
|
+
declare const Svg: any;
|
|
12
|
+
export default Svg;
|
package/lib/objects/Svg.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
6
|
-
type: 'svg',
|
|
7
|
-
initialize(option = {}) {
|
|
8
|
-
this.callSuper('initialize', [], option);
|
|
9
|
-
this.loadSvg(option);
|
|
10
|
-
},
|
|
11
|
-
addSvgElements(objects, options, path) {
|
|
12
|
-
const createdObj = fabric_1.fabric.util.groupSVGElements(objects, options, path);
|
|
13
|
-
this.set(options);
|
|
14
|
-
if (createdObj.getObjects) {
|
|
15
|
-
createdObj.getObjects().forEach(obj => {
|
|
16
|
-
this.add(obj);
|
|
17
|
-
if (options.fill) {
|
|
18
|
-
obj.set('fill', options.fill);
|
|
19
|
-
}
|
|
20
|
-
if (options.stroke) {
|
|
21
|
-
obj.set('stroke', options.stroke);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
createdObj.set({
|
|
27
|
-
originX: 'center',
|
|
28
|
-
originY: 'center',
|
|
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
|
-
}
|
|
40
|
-
if (this._objects?.length) {
|
|
41
|
-
this._objects.forEach(obj => this.remove(obj));
|
|
42
|
-
}
|
|
43
|
-
this.add(createdObj);
|
|
44
|
-
}
|
|
45
|
-
this.set({
|
|
46
|
-
fill: options.fill || 'rgba(0, 0, 0, 1)',
|
|
47
|
-
stroke: options.stroke || 'rgba(255, 255, 255, 0)',
|
|
48
|
-
});
|
|
49
|
-
this.setCoords();
|
|
50
|
-
if (this.canvas) {
|
|
51
|
-
this.canvas.requestRenderAll();
|
|
52
|
-
}
|
|
53
|
-
return this;
|
|
54
|
-
},
|
|
55
|
-
loadSvg(option) {
|
|
56
|
-
const { svg, loadType, fill, stroke } = option;
|
|
57
|
-
return new Promise(resolve => {
|
|
58
|
-
if (loadType === 'svg') {
|
|
59
|
-
fabric_1.fabric.loadSVGFromString(svg, (objects, options) => {
|
|
60
|
-
resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
fabric_1.fabric.loadSVGFromURL(svg, (objects, options) => {
|
|
65
|
-
resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
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
|
-
},
|
|
78
|
-
toObject(propertiesToInclude) {
|
|
79
|
-
return utils_1.toObject(this, propertiesToInclude, {
|
|
80
|
-
svg: this.get('svg'),
|
|
81
|
-
loadType: this.get('loadType'),
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
_render(ctx) {
|
|
85
|
-
this.callSuper('_render', ctx);
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
Svg.fromObject = (option, callback) => {
|
|
89
|
-
return callback(new Svg(option));
|
|
90
|
-
};
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
window.fabric.Svg = Svg;
|
|
93
|
-
exports.default = Svg;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
6
|
+
type: 'svg',
|
|
7
|
+
initialize(option = {}) {
|
|
8
|
+
this.callSuper('initialize', [], option);
|
|
9
|
+
this.loadSvg(option);
|
|
10
|
+
},
|
|
11
|
+
addSvgElements(objects, options, path) {
|
|
12
|
+
const createdObj = fabric_1.fabric.util.groupSVGElements(objects, options, path);
|
|
13
|
+
this.set(options);
|
|
14
|
+
if (createdObj.getObjects) {
|
|
15
|
+
createdObj.getObjects().forEach(obj => {
|
|
16
|
+
this.add(obj);
|
|
17
|
+
if (options.fill) {
|
|
18
|
+
obj.set('fill', options.fill);
|
|
19
|
+
}
|
|
20
|
+
if (options.stroke) {
|
|
21
|
+
obj.set('stroke', options.stroke);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
createdObj.set({
|
|
27
|
+
originX: 'center',
|
|
28
|
+
originY: 'center',
|
|
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
|
+
}
|
|
40
|
+
if (this._objects?.length) {
|
|
41
|
+
this._objects.forEach(obj => this.remove(obj));
|
|
42
|
+
}
|
|
43
|
+
this.add(createdObj);
|
|
44
|
+
}
|
|
45
|
+
this.set({
|
|
46
|
+
fill: options.fill || 'rgba(0, 0, 0, 1)',
|
|
47
|
+
stroke: options.stroke || 'rgba(255, 255, 255, 0)',
|
|
48
|
+
});
|
|
49
|
+
this.setCoords();
|
|
50
|
+
if (this.canvas) {
|
|
51
|
+
this.canvas.requestRenderAll();
|
|
52
|
+
}
|
|
53
|
+
return this;
|
|
54
|
+
},
|
|
55
|
+
loadSvg(option) {
|
|
56
|
+
const { svg, loadType, fill, stroke } = option;
|
|
57
|
+
return new Promise(resolve => {
|
|
58
|
+
if (loadType === 'svg') {
|
|
59
|
+
fabric_1.fabric.loadSVGFromString(svg, (objects, options) => {
|
|
60
|
+
resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
fabric_1.fabric.loadSVGFromURL(svg, (objects, options) => {
|
|
65
|
+
resolve(this.addSvgElements(objects, { ...options, fill, stroke }, svg));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
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
|
+
},
|
|
78
|
+
toObject(propertiesToInclude) {
|
|
79
|
+
return utils_1.toObject(this, propertiesToInclude, {
|
|
80
|
+
svg: this.get('svg'),
|
|
81
|
+
loadType: this.get('loadType'),
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
_render(ctx) {
|
|
85
|
+
this.callSuper('_render', ctx);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
Svg.fromObject = (option, callback) => {
|
|
89
|
+
return callback(new Svg(option));
|
|
90
|
+
};
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
window.fabric.Svg = Svg;
|
|
93
|
+
exports.default = Svg;
|
package/lib/objects/Video.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import 'mediaelement';
|
|
2
|
-
import 'mediaelement/build/mediaelementplayer.min.css';
|
|
3
|
-
import { FabricElement } from '../utils';
|
|
4
|
-
export interface VideoObject extends FabricElement {
|
|
5
|
-
setSource: (source: string | File) => void;
|
|
6
|
-
setFile: (file: File) => void;
|
|
7
|
-
setSrc: (src: string) => void;
|
|
8
|
-
file?: File;
|
|
9
|
-
src?: string;
|
|
10
|
-
videoElement?: HTMLVideoElement;
|
|
11
|
-
player?: any;
|
|
12
|
-
}
|
|
13
|
-
declare const Video: any;
|
|
14
|
-
export default Video;
|
|
1
|
+
import 'mediaelement';
|
|
2
|
+
import 'mediaelement/build/mediaelementplayer.min.css';
|
|
3
|
+
import { FabricElement } from '../utils';
|
|
4
|
+
export interface VideoObject extends FabricElement {
|
|
5
|
+
setSource: (source: string | File) => void;
|
|
6
|
+
setFile: (file: File) => void;
|
|
7
|
+
setSrc: (src: string) => void;
|
|
8
|
+
file?: File;
|
|
9
|
+
src?: string;
|
|
10
|
+
videoElement?: HTMLVideoElement;
|
|
11
|
+
player?: any;
|
|
12
|
+
}
|
|
13
|
+
declare const Video: any;
|
|
14
|
+
export default Video;
|
package/lib/objects/Video.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
require("mediaelement");
|
|
5
|
-
require("mediaelement/build/mediaelementplayer.min.css");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const Video = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
8
|
-
type: 'video',
|
|
9
|
-
superType: 'element',
|
|
10
|
-
hasRotatingPoint: false,
|
|
11
|
-
initialize(source, options) {
|
|
12
|
-
options = options || {};
|
|
13
|
-
this.callSuper('initialize', options);
|
|
14
|
-
if (source instanceof File) {
|
|
15
|
-
this.set({
|
|
16
|
-
file: source,
|
|
17
|
-
src: null,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
this.set({
|
|
22
|
-
file: null,
|
|
23
|
-
src: source,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
this.set({
|
|
27
|
-
fill: 'rgba(255, 255, 255, 0)',
|
|
28
|
-
stroke: 'rgba(255, 255, 255, 0)',
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
setSource(source) {
|
|
32
|
-
if (source instanceof File) {
|
|
33
|
-
this.setFile(source);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.setSrc(source);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
setFile(file) {
|
|
40
|
-
this.set({
|
|
41
|
-
file,
|
|
42
|
-
src: null,
|
|
43
|
-
});
|
|
44
|
-
const reader = new FileReader();
|
|
45
|
-
reader.onload = () => {
|
|
46
|
-
this.player.setSrc(reader.result);
|
|
47
|
-
};
|
|
48
|
-
reader.readAsDataURL(file);
|
|
49
|
-
},
|
|
50
|
-
setSrc(src) {
|
|
51
|
-
this.set({
|
|
52
|
-
file: null,
|
|
53
|
-
src,
|
|
54
|
-
});
|
|
55
|
-
this.player.setSrc(src);
|
|
56
|
-
},
|
|
57
|
-
toObject(propertiesToInclude) {
|
|
58
|
-
return utils_1.toObject(this, propertiesToInclude, {
|
|
59
|
-
src: this.get('src'),
|
|
60
|
-
file: this.get('file'),
|
|
61
|
-
container: this.get('container'),
|
|
62
|
-
editable: this.get('editable'),
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
_render(ctx) {
|
|
66
|
-
this.callSuper('_render', ctx);
|
|
67
|
-
if (!this.element) {
|
|
68
|
-
const { id, scaleX, scaleY, width, height, angle, editable, src, file, autoplay, muted, loop } = this;
|
|
69
|
-
const zoom = this.canvas.getZoom();
|
|
70
|
-
const left = this.calcCoords().tl.x;
|
|
71
|
-
const top = this.calcCoords().tl.y;
|
|
72
|
-
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
73
|
-
const padTop = (height * scaleY * zoom - height) / 2;
|
|
74
|
-
this.videoElement = fabric_1.fabric.util.makeElement('video', {
|
|
75
|
-
id,
|
|
76
|
-
autoplay: editable ? false : autoplay,
|
|
77
|
-
muted: editable ? false : muted,
|
|
78
|
-
loop: editable ? false : loop,
|
|
79
|
-
preload: 'none',
|
|
80
|
-
controls: false,
|
|
81
|
-
});
|
|
82
|
-
this.element = fabric_1.fabric.util.wrapElement(this.videoElement, 'div', {
|
|
83
|
-
id: `${id}_container`,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
require("mediaelement");
|
|
5
|
+
require("mediaelement/build/mediaelementplayer.min.css");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const Video = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
8
|
+
type: 'video',
|
|
9
|
+
superType: 'element',
|
|
10
|
+
hasRotatingPoint: false,
|
|
11
|
+
initialize(source, options) {
|
|
12
|
+
options = options || {};
|
|
13
|
+
this.callSuper('initialize', options);
|
|
14
|
+
if (source instanceof File) {
|
|
15
|
+
this.set({
|
|
16
|
+
file: source,
|
|
17
|
+
src: null,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.set({
|
|
22
|
+
file: null,
|
|
23
|
+
src: source,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
this.set({
|
|
27
|
+
fill: 'rgba(255, 255, 255, 0)',
|
|
28
|
+
stroke: 'rgba(255, 255, 255, 0)',
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
setSource(source) {
|
|
32
|
+
if (source instanceof File) {
|
|
33
|
+
this.setFile(source);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.setSrc(source);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setFile(file) {
|
|
40
|
+
this.set({
|
|
41
|
+
file,
|
|
42
|
+
src: null,
|
|
43
|
+
});
|
|
44
|
+
const reader = new FileReader();
|
|
45
|
+
reader.onload = () => {
|
|
46
|
+
this.player.setSrc(reader.result);
|
|
47
|
+
};
|
|
48
|
+
reader.readAsDataURL(file);
|
|
49
|
+
},
|
|
50
|
+
setSrc(src) {
|
|
51
|
+
this.set({
|
|
52
|
+
file: null,
|
|
53
|
+
src,
|
|
54
|
+
});
|
|
55
|
+
this.player.setSrc(src);
|
|
56
|
+
},
|
|
57
|
+
toObject(propertiesToInclude) {
|
|
58
|
+
return utils_1.toObject(this, propertiesToInclude, {
|
|
59
|
+
src: this.get('src'),
|
|
60
|
+
file: this.get('file'),
|
|
61
|
+
container: this.get('container'),
|
|
62
|
+
editable: this.get('editable'),
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
_render(ctx) {
|
|
66
|
+
this.callSuper('_render', ctx);
|
|
67
|
+
if (!this.element) {
|
|
68
|
+
const { id, scaleX, scaleY, width, height, angle, editable, src, file, autoplay, muted, loop } = this;
|
|
69
|
+
const zoom = this.canvas.getZoom();
|
|
70
|
+
const left = this.calcCoords().tl.x;
|
|
71
|
+
const top = this.calcCoords().tl.y;
|
|
72
|
+
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
73
|
+
const padTop = (height * scaleY * zoom - height) / 2;
|
|
74
|
+
this.videoElement = fabric_1.fabric.util.makeElement('video', {
|
|
75
|
+
id,
|
|
76
|
+
autoplay: editable ? false : autoplay,
|
|
77
|
+
muted: editable ? false : muted,
|
|
78
|
+
loop: editable ? false : loop,
|
|
79
|
+
preload: 'none',
|
|
80
|
+
controls: false,
|
|
81
|
+
});
|
|
82
|
+
this.element = fabric_1.fabric.util.wrapElement(this.videoElement, 'div', {
|
|
83
|
+
id: `${id}_container`,
|
|
84
84
|
style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
|
|
85
85
|
width: ${width}px;
|
|
86
86
|
height: ${height}px;
|
|
@@ -88,33 +88,33 @@ const Video = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
|
88
88
|
top: ${top + padTop}px;
|
|
89
89
|
position: absolute;
|
|
90
90
|
user-select: ${editable ? 'none' : 'auto'};
|
|
91
|
-
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
92
|
-
});
|
|
93
|
-
const container = document.getElementById(this.container);
|
|
94
|
-
container.appendChild(this.element);
|
|
95
|
-
this.player = new MediaElementPlayer(id, {
|
|
96
|
-
pauseOtherPlayers: false,
|
|
97
|
-
videoWidth: '100%',
|
|
98
|
-
videoHeight: '100%',
|
|
99
|
-
success: (_mediaeElement, _originalNode, instance) => {
|
|
100
|
-
if (editable) {
|
|
101
|
-
instance.pause();
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
this.player.setPlayerSize(width, height);
|
|
106
|
-
if (src) {
|
|
107
|
-
this.setSrc(src);
|
|
108
|
-
}
|
|
109
|
-
else if (file) {
|
|
110
|
-
this.setFile(file);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
Video.fromObject = (options, callback) => {
|
|
116
|
-
return callback(new Video(options.src || options.file, options));
|
|
117
|
-
};
|
|
118
|
-
// @ts-ignore
|
|
119
|
-
window.fabric.Video = Video;
|
|
120
|
-
exports.default = Video;
|
|
91
|
+
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
92
|
+
});
|
|
93
|
+
const container = document.getElementById(this.container);
|
|
94
|
+
container.appendChild(this.element);
|
|
95
|
+
this.player = new MediaElementPlayer(id, {
|
|
96
|
+
pauseOtherPlayers: false,
|
|
97
|
+
videoWidth: '100%',
|
|
98
|
+
videoHeight: '100%',
|
|
99
|
+
success: (_mediaeElement, _originalNode, instance) => {
|
|
100
|
+
if (editable) {
|
|
101
|
+
instance.pause();
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
this.player.setPlayerSize(width, height);
|
|
106
|
+
if (src) {
|
|
107
|
+
this.setSrc(src);
|
|
108
|
+
}
|
|
109
|
+
else if (file) {
|
|
110
|
+
this.setFile(file);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
Video.fromObject = (options, callback) => {
|
|
116
|
+
return callback(new Video(options.src || options.file, options));
|
|
117
|
+
};
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
window.fabric.Video = Video;
|
|
120
|
+
exports.default = Video;
|
package/lib/objects/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export { default as
|
|
13
|
-
export { default as
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
1
|
+
export { default as Arrow } from './Arrow';
|
|
2
|
+
export { default as Chart } from './Chart';
|
|
3
|
+
export { default as CirclePort } from './CirclePort';
|
|
4
|
+
export { default as Cube } from './Cube';
|
|
5
|
+
export { default as CurvedLink } from './CurvedLink';
|
|
6
|
+
export { default as Element } from './Element';
|
|
7
|
+
export { default as Gif } from './Gif';
|
|
8
|
+
export { default as Iframe } from './Iframe';
|
|
9
|
+
export { default as Line } from './Line';
|
|
10
|
+
export { default as Link } from './Link';
|
|
11
|
+
export { default as Node } from './Node';
|
|
12
|
+
export { default as OrthogonalLink } from './OrthogonalLink';
|
|
13
|
+
export { default as Port } from './Port';
|
|
14
|
+
export { default as Svg } from './Svg';
|
|
15
|
+
export { default as Video } from './Video';
|
package/lib/objects/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var
|
|
4
|
-
Object.defineProperty(exports, "
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(exports, "
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
var
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
var
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
var
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
var
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
var
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
-
var
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
var
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
-
var
|
|
32
|
-
Object.defineProperty(exports, "
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Arrow_1 = require("./Arrow");
|
|
4
|
+
Object.defineProperty(exports, "Arrow", { enumerable: true, get: function () { return Arrow_1.default; } });
|
|
5
|
+
var Chart_1 = require("./Chart");
|
|
6
|
+
Object.defineProperty(exports, "Chart", { enumerable: true, get: function () { return Chart_1.default; } });
|
|
7
|
+
var CirclePort_1 = require("./CirclePort");
|
|
8
|
+
Object.defineProperty(exports, "CirclePort", { enumerable: true, get: function () { return CirclePort_1.default; } });
|
|
9
|
+
var Cube_1 = require("./Cube");
|
|
10
|
+
Object.defineProperty(exports, "Cube", { enumerable: true, get: function () { return Cube_1.default; } });
|
|
11
|
+
var CurvedLink_1 = require("./CurvedLink");
|
|
12
|
+
Object.defineProperty(exports, "CurvedLink", { enumerable: true, get: function () { return CurvedLink_1.default; } });
|
|
13
|
+
var Element_1 = require("./Element");
|
|
14
|
+
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return Element_1.default; } });
|
|
15
|
+
var Gif_1 = require("./Gif");
|
|
16
|
+
Object.defineProperty(exports, "Gif", { enumerable: true, get: function () { return Gif_1.default; } });
|
|
17
|
+
var Iframe_1 = require("./Iframe");
|
|
18
|
+
Object.defineProperty(exports, "Iframe", { enumerable: true, get: function () { return Iframe_1.default; } });
|
|
19
|
+
var Line_1 = require("./Line");
|
|
20
|
+
Object.defineProperty(exports, "Line", { enumerable: true, get: function () { return Line_1.default; } });
|
|
21
|
+
var Link_1 = require("./Link");
|
|
22
|
+
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.default; } });
|
|
23
|
+
var Node_1 = require("./Node");
|
|
24
|
+
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return Node_1.default; } });
|
|
25
|
+
var OrthogonalLink_1 = require("./OrthogonalLink");
|
|
26
|
+
Object.defineProperty(exports, "OrthogonalLink", { enumerable: true, get: function () { return OrthogonalLink_1.default; } });
|
|
27
|
+
var Port_1 = require("./Port");
|
|
28
|
+
Object.defineProperty(exports, "Port", { enumerable: true, get: function () { return Port_1.default; } });
|
|
29
|
+
var Svg_1 = require("./Svg");
|
|
30
|
+
Object.defineProperty(exports, "Svg", { enumerable: true, get: function () { return Svg_1.default; } });
|
|
31
|
+
var Video_1 = require("./Video");
|
|
32
|
+
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return Video_1.default; } });
|