react-design-editor 0.0.50 → 0.0.52
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 +7739 -7114
- 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 -618
- package/lib/handlers/Handler.js +1645 -1645
- package/lib/handlers/ImageHandler.d.ts +307 -307
- package/lib/handlers/ImageHandler.js +528 -528
- 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
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fabric_1 = require("fabric");
|
|
7
|
-
const Link_1 = __importDefault(require("./Link"));
|
|
8
|
-
const CurvedLink = fabric_1.fabric.util.createClass(Link_1.default, {
|
|
9
|
-
type: 'curvedLink',
|
|
10
|
-
superType: 'link',
|
|
11
|
-
initialize(fromNode, fromPort, toNode, toPort, options) {
|
|
12
|
-
options = options || {};
|
|
13
|
-
this.callSuper('initialize', fromNode, fromPort, toNode, toPort, options);
|
|
14
|
-
},
|
|
15
|
-
_render(ctx) {
|
|
16
|
-
// Drawing curved link
|
|
17
|
-
const { x1, y1, x2, y2 } = this;
|
|
18
|
-
ctx.lineWidth = this.strokeWidth;
|
|
19
|
-
ctx.strokeStyle = this.stroke;
|
|
20
|
-
const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
|
|
21
|
-
const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
|
|
22
|
-
ctx.beginPath();
|
|
23
|
-
ctx.moveTo(fp.x, fp.y);
|
|
24
|
-
ctx.bezierCurveTo(fp.x, sp.y, sp.x, fp.y, sp.x, sp.y);
|
|
25
|
-
ctx.stroke();
|
|
26
|
-
ctx.save();
|
|
27
|
-
const xDiff = x2 - x1;
|
|
28
|
-
const yDiff = y2 - y1;
|
|
29
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
30
|
-
ctx.translate((x2 - x1) / 2, (y2 - y1) / 2);
|
|
31
|
-
ctx.rotate(angle >= 0 ? 1.57 : -1.57);
|
|
32
|
-
ctx.beginPath();
|
|
33
|
-
if (this.arrow) {
|
|
34
|
-
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
35
|
-
ctx.moveTo(5, 0);
|
|
36
|
-
ctx.lineTo(-5, 5);
|
|
37
|
-
ctx.lineTo(-5, -5);
|
|
38
|
-
}
|
|
39
|
-
ctx.closePath();
|
|
40
|
-
ctx.fillStyle = this.stroke;
|
|
41
|
-
ctx.fill();
|
|
42
|
-
ctx.restore();
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
CurvedLink.fromObject = (options, callback) => {
|
|
46
|
-
const { fromNode, fromPort, toNode, toPort } = options;
|
|
47
|
-
return callback(new CurvedLink(fromNode, fromPort, toNode, toPort, options));
|
|
48
|
-
};
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
window.fabric.CurvedLink = CurvedLink;
|
|
51
|
-
exports.default = CurvedLink;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fabric_1 = require("fabric");
|
|
7
|
+
const Link_1 = __importDefault(require("./Link"));
|
|
8
|
+
const CurvedLink = fabric_1.fabric.util.createClass(Link_1.default, {
|
|
9
|
+
type: 'curvedLink',
|
|
10
|
+
superType: 'link',
|
|
11
|
+
initialize(fromNode, fromPort, toNode, toPort, options) {
|
|
12
|
+
options = options || {};
|
|
13
|
+
this.callSuper('initialize', fromNode, fromPort, toNode, toPort, options);
|
|
14
|
+
},
|
|
15
|
+
_render(ctx) {
|
|
16
|
+
// Drawing curved link
|
|
17
|
+
const { x1, y1, x2, y2 } = this;
|
|
18
|
+
ctx.lineWidth = this.strokeWidth;
|
|
19
|
+
ctx.strokeStyle = this.stroke;
|
|
20
|
+
const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
|
|
21
|
+
const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
|
|
22
|
+
ctx.beginPath();
|
|
23
|
+
ctx.moveTo(fp.x, fp.y);
|
|
24
|
+
ctx.bezierCurveTo(fp.x, sp.y, sp.x, fp.y, sp.x, sp.y);
|
|
25
|
+
ctx.stroke();
|
|
26
|
+
ctx.save();
|
|
27
|
+
const xDiff = x2 - x1;
|
|
28
|
+
const yDiff = y2 - y1;
|
|
29
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
30
|
+
ctx.translate((x2 - x1) / 2, (y2 - y1) / 2);
|
|
31
|
+
ctx.rotate(angle >= 0 ? 1.57 : -1.57);
|
|
32
|
+
ctx.beginPath();
|
|
33
|
+
if (this.arrow) {
|
|
34
|
+
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
35
|
+
ctx.moveTo(5, 0);
|
|
36
|
+
ctx.lineTo(-5, 5);
|
|
37
|
+
ctx.lineTo(-5, -5);
|
|
38
|
+
}
|
|
39
|
+
ctx.closePath();
|
|
40
|
+
ctx.fillStyle = this.stroke;
|
|
41
|
+
ctx.fill();
|
|
42
|
+
ctx.restore();
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
CurvedLink.fromObject = (options, callback) => {
|
|
46
|
+
const { fromNode, fromPort, toNode, toPort } = options;
|
|
47
|
+
return callback(new CurvedLink(fromNode, fromPort, toNode, toPort, options));
|
|
48
|
+
};
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
window.fabric.CurvedLink = CurvedLink;
|
|
51
|
+
exports.default = CurvedLink;
|
package/lib/objects/Element.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { FabricElement } from '../utils';
|
|
2
|
-
export interface Code {
|
|
3
|
-
html: string;
|
|
4
|
-
css: string;
|
|
5
|
-
js: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ElementObject extends FabricElement {
|
|
8
|
-
setSource: (source: Code) => void;
|
|
9
|
-
setCode: (code: Code) => void;
|
|
10
|
-
code: Code;
|
|
11
|
-
}
|
|
12
|
-
declare const Element: any;
|
|
13
|
-
export default Element;
|
|
1
|
+
import { FabricElement } from '../utils';
|
|
2
|
+
export interface Code {
|
|
3
|
+
html: string;
|
|
4
|
+
css: string;
|
|
5
|
+
js: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ElementObject extends FabricElement {
|
|
8
|
+
setSource: (source: Code) => void;
|
|
9
|
+
setCode: (code: Code) => void;
|
|
10
|
+
code: Code;
|
|
11
|
+
}
|
|
12
|
+
declare const Element: any;
|
|
13
|
+
export default Element;
|
package/lib/objects/Element.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const initialCode = {
|
|
6
|
-
html: '',
|
|
7
|
-
css: '',
|
|
8
|
-
js: '',
|
|
9
|
-
};
|
|
10
|
-
const Element = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
11
|
-
type: 'element',
|
|
12
|
-
superType: 'element',
|
|
13
|
-
hasRotatingPoint: false,
|
|
14
|
-
initialize(code = initialCode, options) {
|
|
15
|
-
options = options || {};
|
|
16
|
-
this.callSuper('initialize', options);
|
|
17
|
-
this.set({
|
|
18
|
-
code,
|
|
19
|
-
fill: 'rgba(255, 255, 255, 0)',
|
|
20
|
-
stroke: 'rgba(255, 255, 255, 0)',
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
setSource(source) {
|
|
24
|
-
this.setCode(source);
|
|
25
|
-
},
|
|
26
|
-
setCode(code = initialCode) {
|
|
27
|
-
this.set({
|
|
28
|
-
code,
|
|
29
|
-
});
|
|
30
|
-
const { css, js, html } = code;
|
|
31
|
-
this.styleEl.innerHTML = css;
|
|
32
|
-
this.scriptEl.innerHTML = js;
|
|
33
|
-
this.element.innerHTML = html;
|
|
34
|
-
},
|
|
35
|
-
toObject(propertiesToInclude) {
|
|
36
|
-
return utils_1.toObject(this, propertiesToInclude, {
|
|
37
|
-
code: this.get('code'),
|
|
38
|
-
container: this.get('container'),
|
|
39
|
-
editable: this.get('editable'),
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
_render(ctx) {
|
|
43
|
-
this.callSuper('_render', ctx);
|
|
44
|
-
if (!this.element) {
|
|
45
|
-
const { id, scaleX, scaleY, width, height, angle, editable, code } = this;
|
|
46
|
-
const zoom = this.canvas.getZoom();
|
|
47
|
-
const left = this.calcCoords().tl.x;
|
|
48
|
-
const top = this.calcCoords().tl.y;
|
|
49
|
-
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
50
|
-
const padTop = (height * scaleY * zoom - height) / 2;
|
|
51
|
-
this.element = fabric_1.fabric.util.makeElement('div', {
|
|
52
|
-
id: `${id}_container`,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const initialCode = {
|
|
6
|
+
html: '',
|
|
7
|
+
css: '',
|
|
8
|
+
js: '',
|
|
9
|
+
};
|
|
10
|
+
const Element = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
11
|
+
type: 'element',
|
|
12
|
+
superType: 'element',
|
|
13
|
+
hasRotatingPoint: false,
|
|
14
|
+
initialize(code = initialCode, options) {
|
|
15
|
+
options = options || {};
|
|
16
|
+
this.callSuper('initialize', options);
|
|
17
|
+
this.set({
|
|
18
|
+
code,
|
|
19
|
+
fill: 'rgba(255, 255, 255, 0)',
|
|
20
|
+
stroke: 'rgba(255, 255, 255, 0)',
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
setSource(source) {
|
|
24
|
+
this.setCode(source);
|
|
25
|
+
},
|
|
26
|
+
setCode(code = initialCode) {
|
|
27
|
+
this.set({
|
|
28
|
+
code,
|
|
29
|
+
});
|
|
30
|
+
const { css, js, html } = code;
|
|
31
|
+
this.styleEl.innerHTML = css;
|
|
32
|
+
this.scriptEl.innerHTML = js;
|
|
33
|
+
this.element.innerHTML = html;
|
|
34
|
+
},
|
|
35
|
+
toObject(propertiesToInclude) {
|
|
36
|
+
return utils_1.toObject(this, propertiesToInclude, {
|
|
37
|
+
code: this.get('code'),
|
|
38
|
+
container: this.get('container'),
|
|
39
|
+
editable: this.get('editable'),
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
_render(ctx) {
|
|
43
|
+
this.callSuper('_render', ctx);
|
|
44
|
+
if (!this.element) {
|
|
45
|
+
const { id, scaleX, scaleY, width, height, angle, editable, code } = this;
|
|
46
|
+
const zoom = this.canvas.getZoom();
|
|
47
|
+
const left = this.calcCoords().tl.x;
|
|
48
|
+
const top = this.calcCoords().tl.y;
|
|
49
|
+
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
50
|
+
const padTop = (height * scaleY * zoom - height) / 2;
|
|
51
|
+
this.element = fabric_1.fabric.util.makeElement('div', {
|
|
52
|
+
id: `${id}_container`,
|
|
53
53
|
style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
|
|
54
54
|
width: ${width}px;
|
|
55
55
|
height: ${height}px;
|
|
@@ -57,28 +57,28 @@ const Element = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
|
57
57
|
top: ${top + padTop}px;
|
|
58
58
|
position: absolute;
|
|
59
59
|
user-select: ${editable ? 'none' : 'auto'};
|
|
60
|
-
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
61
|
-
});
|
|
62
|
-
const { html, css, js } = code;
|
|
63
|
-
this.styleEl = document.createElement('style');
|
|
64
|
-
this.styleEl.id = `${id}_style`;
|
|
65
|
-
this.styleEl.type = 'text/css';
|
|
66
|
-
this.styleEl.innerHTML = css;
|
|
67
|
-
document.head.appendChild(this.styleEl);
|
|
68
|
-
this.scriptEl = document.createElement('script');
|
|
69
|
-
this.scriptEl.id = `${id}_script`;
|
|
70
|
-
this.scriptEl.type = 'text/javascript';
|
|
71
|
-
this.scriptEl.innerHTML = js;
|
|
72
|
-
document.head.appendChild(this.scriptEl);
|
|
73
|
-
const container = document.getElementById(this.container);
|
|
74
|
-
container.appendChild(this.element);
|
|
75
|
-
this.element.innerHTML = html;
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
Element.fromObject = (options, callback) => {
|
|
80
|
-
return callback(new Element(options.code, options));
|
|
81
|
-
};
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
window.fabric.Element = Element;
|
|
84
|
-
exports.default = Element;
|
|
60
|
+
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
61
|
+
});
|
|
62
|
+
const { html, css, js } = code;
|
|
63
|
+
this.styleEl = document.createElement('style');
|
|
64
|
+
this.styleEl.id = `${id}_style`;
|
|
65
|
+
this.styleEl.type = 'text/css';
|
|
66
|
+
this.styleEl.innerHTML = css;
|
|
67
|
+
document.head.appendChild(this.styleEl);
|
|
68
|
+
this.scriptEl = document.createElement('script');
|
|
69
|
+
this.scriptEl.id = `${id}_script`;
|
|
70
|
+
this.scriptEl.type = 'text/javascript';
|
|
71
|
+
this.scriptEl.innerHTML = js;
|
|
72
|
+
document.head.appendChild(this.scriptEl);
|
|
73
|
+
const container = document.getElementById(this.container);
|
|
74
|
+
container.appendChild(this.element);
|
|
75
|
+
this.element.innerHTML = html;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
Element.fromObject = (options, callback) => {
|
|
80
|
+
return callback(new Element(options.code, options));
|
|
81
|
+
};
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
window.fabric.Element = Element;
|
|
84
|
+
exports.default = Element;
|
package/lib/objects/Gif.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import 'gifler';
|
|
2
|
-
declare const Gif: any;
|
|
3
|
-
export default Gif;
|
|
1
|
+
import 'gifler';
|
|
2
|
+
declare const Gif: any;
|
|
3
|
+
export default Gif;
|
package/lib/objects/Gif.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
require("gifler");
|
|
5
|
-
const Gif = fabric_1.fabric.util.createClass(fabric_1.fabric.Object, {
|
|
6
|
-
type: 'gif',
|
|
7
|
-
superType: 'image',
|
|
8
|
-
gifCanvas: null,
|
|
9
|
-
isStarted: false,
|
|
10
|
-
initialize(options) {
|
|
11
|
-
options = options || {};
|
|
12
|
-
this.callSuper('initialize', options);
|
|
13
|
-
this.gifCanvas = document.createElement('canvas');
|
|
14
|
-
},
|
|
15
|
-
drawFrame(ctx, frame) {
|
|
16
|
-
// update canvas size
|
|
17
|
-
this.gifCanvas.width = frame.width;
|
|
18
|
-
this.gifCanvas.height = frame.height;
|
|
19
|
-
// update canvas that we are using for fabric.js
|
|
20
|
-
ctx.drawImage(frame.buffer, -frame.width / 2, -frame.height / 2, frame.width, frame.height);
|
|
21
|
-
},
|
|
22
|
-
_render(ctx) {
|
|
23
|
-
this.callSuper('_render', ctx);
|
|
24
|
-
if (!this.isStarted) {
|
|
25
|
-
this.isStarted = true;
|
|
26
|
-
window
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
.gifler('./images/sample/earth.gif')
|
|
29
|
-
.frames(this.gifCanvas, (_c, frame) => {
|
|
30
|
-
this.isStarted = true;
|
|
31
|
-
this.drawFrame(ctx, frame);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
Gif.fromObject = (options, callback) => {
|
|
37
|
-
return callback(new Gif(options));
|
|
38
|
-
};
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
window.fabric.Gif = Gif;
|
|
41
|
-
exports.default = Gif;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
require("gifler");
|
|
5
|
+
const Gif = fabric_1.fabric.util.createClass(fabric_1.fabric.Object, {
|
|
6
|
+
type: 'gif',
|
|
7
|
+
superType: 'image',
|
|
8
|
+
gifCanvas: null,
|
|
9
|
+
isStarted: false,
|
|
10
|
+
initialize(options) {
|
|
11
|
+
options = options || {};
|
|
12
|
+
this.callSuper('initialize', options);
|
|
13
|
+
this.gifCanvas = document.createElement('canvas');
|
|
14
|
+
},
|
|
15
|
+
drawFrame(ctx, frame) {
|
|
16
|
+
// update canvas size
|
|
17
|
+
this.gifCanvas.width = frame.width;
|
|
18
|
+
this.gifCanvas.height = frame.height;
|
|
19
|
+
// update canvas that we are using for fabric.js
|
|
20
|
+
ctx.drawImage(frame.buffer, -frame.width / 2, -frame.height / 2, frame.width, frame.height);
|
|
21
|
+
},
|
|
22
|
+
_render(ctx) {
|
|
23
|
+
this.callSuper('_render', ctx);
|
|
24
|
+
if (!this.isStarted) {
|
|
25
|
+
this.isStarted = true;
|
|
26
|
+
window
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
.gifler('./images/sample/earth.gif')
|
|
29
|
+
.frames(this.gifCanvas, (_c, frame) => {
|
|
30
|
+
this.isStarted = true;
|
|
31
|
+
this.drawFrame(ctx, frame);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
Gif.fromObject = (options, callback) => {
|
|
37
|
+
return callback(new Gif(options));
|
|
38
|
+
};
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
window.fabric.Gif = Gif;
|
|
41
|
+
exports.default = Gif;
|
package/lib/objects/Iframe.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FabricElement } from '../utils';
|
|
2
|
-
export interface IframeObject extends FabricElement {
|
|
3
|
-
setSource: (source: string) => void;
|
|
4
|
-
setSrc: (src: string) => void;
|
|
5
|
-
src: string;
|
|
6
|
-
iframeElement: HTMLIFrameElement;
|
|
7
|
-
}
|
|
8
|
-
declare const Iframe: any;
|
|
9
|
-
export default Iframe;
|
|
1
|
+
import { FabricElement } from '../utils';
|
|
2
|
+
export interface IframeObject extends FabricElement {
|
|
3
|
+
setSource: (source: string) => void;
|
|
4
|
+
setSrc: (src: string) => void;
|
|
5
|
+
src: string;
|
|
6
|
+
iframeElement: HTMLIFrameElement;
|
|
7
|
+
}
|
|
8
|
+
declare const Iframe: any;
|
|
9
|
+
export default Iframe;
|
package/lib/objects/Iframe.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const Iframe = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
6
|
-
type: 'iframe',
|
|
7
|
-
superType: 'element',
|
|
8
|
-
hasRotatingPoint: false,
|
|
9
|
-
initialize(src = '', options) {
|
|
10
|
-
options = options || {};
|
|
11
|
-
this.callSuper('initialize', options);
|
|
12
|
-
this.set({
|
|
13
|
-
src,
|
|
14
|
-
fill: 'rgba(255, 255, 255, 0)',
|
|
15
|
-
stroke: 'rgba(255, 255, 255, 0)',
|
|
16
|
-
});
|
|
17
|
-
},
|
|
18
|
-
setSource(source) {
|
|
19
|
-
this.setSrc(source);
|
|
20
|
-
},
|
|
21
|
-
setSrc(src) {
|
|
22
|
-
this.set({
|
|
23
|
-
src,
|
|
24
|
-
});
|
|
25
|
-
this.iframeElement.src = src;
|
|
26
|
-
},
|
|
27
|
-
toObject(propertiesToInclude) {
|
|
28
|
-
return utils_1.toObject(this, propertiesToInclude, {
|
|
29
|
-
src: this.get('src'),
|
|
30
|
-
container: this.get('container'),
|
|
31
|
-
editable: this.get('editable'),
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
_render(ctx) {
|
|
35
|
-
this.callSuper('_render', ctx);
|
|
36
|
-
if (!this.element) {
|
|
37
|
-
const { id, scaleX, scaleY, width, height, angle, editable, src } = this;
|
|
38
|
-
const zoom = this.canvas.getZoom();
|
|
39
|
-
const left = this.calcCoords().tl.x;
|
|
40
|
-
const top = this.calcCoords().tl.y;
|
|
41
|
-
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
42
|
-
const padTop = (height * scaleY * zoom - height) / 2;
|
|
43
|
-
this.iframeElement = fabric_1.fabric.util.makeElement('iframe', {
|
|
44
|
-
id,
|
|
45
|
-
src,
|
|
46
|
-
width: '100%',
|
|
47
|
-
height: '100%',
|
|
48
|
-
});
|
|
49
|
-
this.element = fabric_1.fabric.util.wrapElement(this.iframeElement, 'div', {
|
|
50
|
-
id: `${id}_container`,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const Iframe = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
6
|
+
type: 'iframe',
|
|
7
|
+
superType: 'element',
|
|
8
|
+
hasRotatingPoint: false,
|
|
9
|
+
initialize(src = '', options) {
|
|
10
|
+
options = options || {};
|
|
11
|
+
this.callSuper('initialize', options);
|
|
12
|
+
this.set({
|
|
13
|
+
src,
|
|
14
|
+
fill: 'rgba(255, 255, 255, 0)',
|
|
15
|
+
stroke: 'rgba(255, 255, 255, 0)',
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
setSource(source) {
|
|
19
|
+
this.setSrc(source);
|
|
20
|
+
},
|
|
21
|
+
setSrc(src) {
|
|
22
|
+
this.set({
|
|
23
|
+
src,
|
|
24
|
+
});
|
|
25
|
+
this.iframeElement.src = src;
|
|
26
|
+
},
|
|
27
|
+
toObject(propertiesToInclude) {
|
|
28
|
+
return utils_1.toObject(this, propertiesToInclude, {
|
|
29
|
+
src: this.get('src'),
|
|
30
|
+
container: this.get('container'),
|
|
31
|
+
editable: this.get('editable'),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
_render(ctx) {
|
|
35
|
+
this.callSuper('_render', ctx);
|
|
36
|
+
if (!this.element) {
|
|
37
|
+
const { id, scaleX, scaleY, width, height, angle, editable, src } = this;
|
|
38
|
+
const zoom = this.canvas.getZoom();
|
|
39
|
+
const left = this.calcCoords().tl.x;
|
|
40
|
+
const top = this.calcCoords().tl.y;
|
|
41
|
+
const padLeft = (width * scaleX * zoom - width) / 2;
|
|
42
|
+
const padTop = (height * scaleY * zoom - height) / 2;
|
|
43
|
+
this.iframeElement = fabric_1.fabric.util.makeElement('iframe', {
|
|
44
|
+
id,
|
|
45
|
+
src,
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: '100%',
|
|
48
|
+
});
|
|
49
|
+
this.element = fabric_1.fabric.util.wrapElement(this.iframeElement, 'div', {
|
|
50
|
+
id: `${id}_container`,
|
|
51
51
|
style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
|
|
52
52
|
width: ${width}px;
|
|
53
53
|
height: ${height}px;
|
|
@@ -55,16 +55,16 @@ const Iframe = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
|
|
|
55
55
|
top: ${top + padTop}px;
|
|
56
56
|
position: absolute;
|
|
57
57
|
user-select: ${editable ? 'none' : 'auto'};
|
|
58
|
-
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
59
|
-
});
|
|
60
|
-
const container = document.getElementById(this.container);
|
|
61
|
-
container.appendChild(this.element);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
Iframe.fromObject = (options, callback) => {
|
|
66
|
-
return callback(new Iframe(options.src, options));
|
|
67
|
-
};
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
window.fabric.Iframe = Iframe;
|
|
70
|
-
exports.default = Iframe;
|
|
58
|
+
pointer-events: ${editable ? 'none' : 'auto'};`,
|
|
59
|
+
});
|
|
60
|
+
const container = document.getElementById(this.container);
|
|
61
|
+
container.appendChild(this.element);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
Iframe.fromObject = (options, callback) => {
|
|
66
|
+
return callback(new Iframe(options.src, options));
|
|
67
|
+
};
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
window.fabric.Iframe = Iframe;
|
|
70
|
+
exports.default = Iframe;
|
package/lib/objects/Line.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const Line: any;
|
|
2
|
-
export default Line;
|
|
1
|
+
declare const Line: any;
|
|
2
|
+
export default Line;
|
package/lib/objects/Line.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fabric_1 = require("fabric");
|
|
4
|
-
const Line = fabric_1.fabric.util.createClass(fabric_1.fabric.Line, {
|
|
5
|
-
type: 'line',
|
|
6
|
-
superType: 'drawing',
|
|
7
|
-
initialize(points, options) {
|
|
8
|
-
if (!points) {
|
|
9
|
-
const { x1, x2, y1, y2 } = options;
|
|
10
|
-
points = [x1, y1, x2, y2];
|
|
11
|
-
}
|
|
12
|
-
options = options || {};
|
|
13
|
-
this.callSuper('initialize', points, options);
|
|
14
|
-
},
|
|
15
|
-
_render(ctx) {
|
|
16
|
-
this.callSuper('_render', ctx);
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
Line.fromObject = (options, callback) => {
|
|
20
|
-
const { x1, x2, y1, y2 } = options;
|
|
21
|
-
return callback(new Line([x1, y1, x2, y2], options));
|
|
22
|
-
};
|
|
23
|
-
window.fabric.Line = Line;
|
|
24
|
-
exports.default = Line;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const Line = fabric_1.fabric.util.createClass(fabric_1.fabric.Line, {
|
|
5
|
+
type: 'line',
|
|
6
|
+
superType: 'drawing',
|
|
7
|
+
initialize(points, options) {
|
|
8
|
+
if (!points) {
|
|
9
|
+
const { x1, x2, y1, y2 } = options;
|
|
10
|
+
points = [x1, y1, x2, y2];
|
|
11
|
+
}
|
|
12
|
+
options = options || {};
|
|
13
|
+
this.callSuper('initialize', points, options);
|
|
14
|
+
},
|
|
15
|
+
_render(ctx) {
|
|
16
|
+
this.callSuper('_render', ctx);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
Line.fromObject = (options, callback) => {
|
|
20
|
+
const { x1, x2, y1, y2 } = options;
|
|
21
|
+
return callback(new Line([x1, y1, x2, y2], options));
|
|
22
|
+
};
|
|
23
|
+
window.fabric.Line = Line;
|
|
24
|
+
exports.default = Line;
|
package/lib/objects/Link.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { fabric } from 'fabric';
|
|
2
|
-
import { FabricObject } from '../utils';
|
|
3
|
-
import { NodeObject } from './Node';
|
|
4
|
-
import { PortObject } from './Port';
|
|
5
|
-
export interface LinkObject extends FabricObject<fabric.Line> {
|
|
6
|
-
fromNode?: NodeObject;
|
|
7
|
-
toNode?: NodeObject;
|
|
8
|
-
fromPort?: PortObject;
|
|
9
|
-
toPort?: PortObject;
|
|
10
|
-
fromPortIndex?: number;
|
|
11
|
-
setPort?: (fromNode: NodeObject, fromPort: PortObject, toNode: NodeObject, toPort: PortObject) => void;
|
|
12
|
-
setPortEnabled?: (node: NodeObject, port: PortObject, enabled: boolean) => void;
|
|
13
|
-
}
|
|
14
|
-
declare const Link: any;
|
|
15
|
-
export default Link;
|
|
1
|
+
import { fabric } from 'fabric';
|
|
2
|
+
import { FabricObject } from '../utils';
|
|
3
|
+
import { NodeObject } from './Node';
|
|
4
|
+
import { PortObject } from './Port';
|
|
5
|
+
export interface LinkObject extends FabricObject<fabric.Line> {
|
|
6
|
+
fromNode?: NodeObject;
|
|
7
|
+
toNode?: NodeObject;
|
|
8
|
+
fromPort?: PortObject;
|
|
9
|
+
toPort?: PortObject;
|
|
10
|
+
fromPortIndex?: number;
|
|
11
|
+
setPort?: (fromNode: NodeObject, fromPort: PortObject, toNode: NodeObject, toPort: PortObject) => void;
|
|
12
|
+
setPortEnabled?: (node: NodeObject, port: PortObject, enabled: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const Link: any;
|
|
15
|
+
export default Link;
|