react-design-editor 0.0.37 → 0.0.41

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.
Files changed (99) hide show
  1. package/dist/react-design-editor.js +773 -726
  2. package/dist/react-design-editor.min.js +1 -1
  3. package/lib/Canvas.d.ts +18 -0
  4. package/lib/Canvas.js +172 -0
  5. package/lib/CanvasObject.d.ts +10 -0
  6. package/lib/CanvasObject.js +96 -0
  7. package/lib/constants/code.d.ts +19 -0
  8. package/lib/constants/code.js +22 -0
  9. package/lib/constants/defaults.d.ts +38 -0
  10. package/lib/constants/defaults.js +69 -0
  11. package/lib/constants/index.d.ts +3 -0
  12. package/lib/constants/index.js +26 -0
  13. package/lib/handlers/AlignmentHandler.d.ts +18 -0
  14. package/lib/handlers/AlignmentHandler.js +58 -0
  15. package/lib/handlers/AnimationHandler.d.ts +50 -0
  16. package/lib/handlers/AnimationHandler.js +323 -0
  17. package/lib/handlers/ChartHandler.d.ts +8 -0
  18. package/lib/handlers/ChartHandler.js +8 -0
  19. package/lib/handlers/ContextmenuHandler.d.ts +28 -0
  20. package/lib/handlers/ContextmenuHandler.js +65 -0
  21. package/lib/handlers/CropHandler.d.ts +43 -0
  22. package/lib/handlers/CropHandler.js +261 -0
  23. package/lib/handlers/CustomHandler.d.ts +7 -0
  24. package/lib/handlers/CustomHandler.js +10 -0
  25. package/lib/handlers/DrawingHandler.d.ts +28 -0
  26. package/lib/handlers/DrawingHandler.js +318 -0
  27. package/lib/handlers/ElementHandler.d.ts +80 -0
  28. package/lib/handlers/ElementHandler.js +154 -0
  29. package/lib/handlers/EventHandler.d.ts +170 -0
  30. package/lib/handlers/EventHandler.js +880 -0
  31. package/lib/handlers/FiberHandler.d.ts +6 -0
  32. package/lib/handlers/FiberHandler.js +23 -0
  33. package/lib/handlers/GridHandler.d.ts +19 -0
  34. package/lib/handlers/GridHandler.js +77 -0
  35. package/lib/handlers/GuidelineHandler.d.ts +61 -0
  36. package/lib/handlers/GuidelineHandler.js +315 -0
  37. package/lib/handlers/Handler.d.ts +622 -0
  38. package/lib/handlers/Handler.js +1640 -0
  39. package/lib/handlers/ImageHandler.d.ts +307 -0
  40. package/lib/handlers/ImageHandler.js +529 -0
  41. package/lib/handlers/InteractionHandler.d.ts +45 -0
  42. package/lib/handlers/InteractionHandler.js +164 -0
  43. package/lib/handlers/LinkHandler.d.ts +115 -0
  44. package/lib/handlers/LinkHandler.js +247 -0
  45. package/lib/handlers/NodeHandler.d.ts +50 -0
  46. package/lib/handlers/NodeHandler.js +274 -0
  47. package/lib/handlers/PortHandler.d.ts +22 -0
  48. package/lib/handlers/PortHandler.js +179 -0
  49. package/lib/handlers/ShortcutHandler.d.ts +119 -0
  50. package/lib/handlers/ShortcutHandler.js +151 -0
  51. package/lib/handlers/TooltipHandler.d.ts +33 -0
  52. package/lib/handlers/TooltipHandler.js +91 -0
  53. package/lib/handlers/TransactionHandler.d.ts +59 -0
  54. package/lib/handlers/TransactionHandler.js +137 -0
  55. package/lib/handlers/WorkareaHandler.d.ts +43 -0
  56. package/lib/handlers/WorkareaHandler.js +354 -0
  57. package/lib/handlers/ZoomHandler.d.ts +48 -0
  58. package/lib/handlers/ZoomHandler.js +143 -0
  59. package/lib/handlers/index.d.ts +23 -0
  60. package/lib/handlers/index.js +48 -0
  61. package/lib/index.d.ts +6 -0
  62. package/lib/index.js +20 -0
  63. package/lib/objects/Arrow.d.ts +2 -0
  64. package/lib/objects/Arrow.js +40 -0
  65. package/lib/objects/Chart.d.ts +10 -0
  66. package/lib/objects/Chart.js +124 -0
  67. package/lib/objects/CirclePort.d.ts +2 -0
  68. package/lib/objects/CirclePort.js +28 -0
  69. package/lib/objects/Cube.d.ts +5 -0
  70. package/lib/objects/Cube.js +71 -0
  71. package/lib/objects/CurvedLink.d.ts +2 -0
  72. package/lib/objects/CurvedLink.js +51 -0
  73. package/lib/objects/Element.d.ts +13 -0
  74. package/lib/objects/Element.js +84 -0
  75. package/lib/objects/Gif.d.ts +3 -0
  76. package/lib/objects/Gif.js +41 -0
  77. package/lib/objects/Iframe.d.ts +9 -0
  78. package/lib/objects/Iframe.js +70 -0
  79. package/lib/objects/Line.d.ts +2 -0
  80. package/lib/objects/Line.js +24 -0
  81. package/lib/objects/Link.d.ts +15 -0
  82. package/lib/objects/Link.js +106 -0
  83. package/lib/objects/Node.d.ts +59 -0
  84. package/lib/objects/Node.js +271 -0
  85. package/lib/objects/OrthogonalLink.d.ts +2 -0
  86. package/lib/objects/OrthogonalLink.js +54 -0
  87. package/lib/objects/Port.d.ts +12 -0
  88. package/lib/objects/Port.js +28 -0
  89. package/lib/objects/Svg.d.ts +8 -0
  90. package/lib/objects/Svg.js +77 -0
  91. package/lib/objects/Video.d.ts +14 -0
  92. package/lib/objects/Video.js +120 -0
  93. package/lib/objects/index.d.ts +15 -0
  94. package/lib/objects/index.js +32 -0
  95. package/lib/utils/ObjectUtil.d.ts +407 -0
  96. package/lib/utils/ObjectUtil.js +13 -0
  97. package/lib/utils/index.d.ts +1 -0
  98. package/lib/utils/index.js +13 -0
  99. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fabric_1 = require("fabric");
4
+ const Arrow = fabric_1.fabric.util.createClass(fabric_1.fabric.Line, {
5
+ type: 'arrow',
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
+ ctx.save();
18
+ const xDiff = this.x2 - this.x1;
19
+ const yDiff = this.y2 - this.y1;
20
+ const angle = Math.atan2(yDiff, xDiff);
21
+ ctx.translate((this.x2 - this.x1) / 2, (this.y2 - this.y1) / 2);
22
+ ctx.rotate(angle);
23
+ ctx.beginPath();
24
+ // Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
25
+ ctx.moveTo(5, 0);
26
+ ctx.lineTo(-5, 5);
27
+ ctx.lineTo(-5, -5);
28
+ ctx.closePath();
29
+ ctx.fillStyle = this.stroke;
30
+ ctx.fill();
31
+ ctx.restore();
32
+ },
33
+ });
34
+ Arrow.fromObject = (options, callback) => {
35
+ const { x1, x2, y1, y2 } = options;
36
+ return callback(new Arrow([x1, y1, x2, y2], options));
37
+ };
38
+ // @ts-ignore
39
+ window.fabric.Arrow = Arrow;
40
+ exports.default = Arrow;
@@ -0,0 +1,10 @@
1
+ import * as echarts from 'echarts';
2
+ import { FabricElement } from '../utils';
3
+ export interface ChartObject extends FabricElement {
4
+ setSource: (source: echarts.EChartOption) => void;
5
+ setChartOption: (chartOption: echarts.EChartOption) => void;
6
+ chartOption: echarts.EChartOption;
7
+ instance: echarts.ECharts;
8
+ }
9
+ declare const Chart: any;
10
+ export default Chart;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const echarts = __importStar(require("echarts"));
23
+ const fabric_1 = require("fabric");
24
+ const utils_1 = require("../utils");
25
+ const Chart = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
26
+ type: 'chart',
27
+ superType: 'element',
28
+ hasRotatingPoint: false,
29
+ initialize(chartOption, options) {
30
+ options = options || {};
31
+ this.callSuper('initialize', options);
32
+ this.set({
33
+ chartOption,
34
+ fill: 'rgba(255, 255, 255, 0)',
35
+ stroke: 'rgba(255, 255, 255, 0)',
36
+ });
37
+ },
38
+ setSource(source) {
39
+ if (typeof source === 'string') {
40
+ this.setChartOptionStr(source);
41
+ }
42
+ else {
43
+ this.setChartOption(source);
44
+ }
45
+ },
46
+ setChartOptionStr(chartOptionStr) {
47
+ this.set({
48
+ chartOptionStr,
49
+ });
50
+ },
51
+ setChartOption(chartOption) {
52
+ this.set({
53
+ chartOption,
54
+ });
55
+ this.distroyChart();
56
+ this.createChart(chartOption);
57
+ },
58
+ createChart(chartOption) {
59
+ this.instance = echarts.init(this.element);
60
+ if (!chartOption) {
61
+ this.instance.setOption({
62
+ xAxis: {},
63
+ yAxis: {},
64
+ series: [
65
+ {
66
+ type: 'line',
67
+ data: [
68
+ [0, 1],
69
+ [1, 2],
70
+ [2, 3],
71
+ [3, 4],
72
+ ],
73
+ },
74
+ ],
75
+ });
76
+ }
77
+ else {
78
+ this.instance.setOption(chartOption);
79
+ }
80
+ },
81
+ distroyChart() {
82
+ if (this.instance) {
83
+ this.instance.dispose();
84
+ }
85
+ },
86
+ toObject(propertiesToInclude) {
87
+ return utils_1.toObject(this, propertiesToInclude, {
88
+ chartOption: this.get('chartOption'),
89
+ container: this.get('container'),
90
+ editable: this.get('editable'),
91
+ });
92
+ },
93
+ _render(ctx) {
94
+ this.callSuper('_render', ctx);
95
+ if (!this.instance) {
96
+ const { id, scaleX, scaleY, width, height, angle, editable, chartOption } = this;
97
+ const zoom = this.canvas.getZoom();
98
+ const left = this.calcCoords().tl.x;
99
+ const top = this.calcCoords().tl.y;
100
+ const padLeft = (width * scaleX * zoom - width) / 2;
101
+ const padTop = (height * scaleY * zoom - height) / 2;
102
+ this.element = fabric_1.fabric.util.makeElement('div', {
103
+ id: `${id}_container`,
104
+ style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
105
+ width: ${width}px;
106
+ height: ${height}px;
107
+ left: ${left + padLeft}px;
108
+ top: ${top + padTop}px;
109
+ position: absolute;
110
+ user-select: ${editable ? 'none' : 'auto'};
111
+ pointer-events: ${editable ? 'none' : 'auto'};`,
112
+ });
113
+ this.createChart(chartOption);
114
+ const container = document.getElementById(this.container);
115
+ container.appendChild(this.element);
116
+ }
117
+ },
118
+ });
119
+ Chart.fromObject = (options, callback) => {
120
+ return callback(new Chart(options.chartOption, options));
121
+ };
122
+ // @ts-ignore
123
+ window.fabric.Chart = Chart;
124
+ exports.default = Chart;
@@ -0,0 +1,2 @@
1
+ declare const CirclePort: any;
2
+ export default CirclePort;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fabric_1 = require("fabric");
4
+ const CirclePort = fabric_1.fabric.util.createClass(fabric_1.fabric.Circle, {
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
+ CirclePort.fromObject = (options, callback) => {
24
+ return callback(new CirclePort(options));
25
+ };
26
+ // @ts-ignore
27
+ window.fabric.CirclePort = CirclePort;
28
+ exports.default = CirclePort;
@@ -0,0 +1,5 @@
1
+ import { FabricObject } from '../utils';
2
+ export interface CubeObject extends FabricObject {
3
+ }
4
+ declare const Cube: any;
5
+ export default Cube;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fabric_1 = require("fabric");
4
+ const Cube = fabric_1.fabric.util.createClass(fabric_1.fabric.Object, {
5
+ type: 'cube',
6
+ superType: 'shape',
7
+ initialize(options) {
8
+ options = options || {};
9
+ this.callSuper('initialize', options);
10
+ },
11
+ shadeColor(color, percent) {
12
+ color = color.substr(1);
13
+ const num = parseInt(color, 16);
14
+ const amt = Math.round(2.55 * percent);
15
+ const R = (num >> 16) + amt;
16
+ const G = ((num >> 8) & 0x00ff) + amt;
17
+ const B = (num & 0x0000ff) + amt;
18
+ return ('#' +
19
+ (0x1000000 +
20
+ (R < 255 ? (R < 1 ? 0 : R) : 255) * 0x10000 +
21
+ (G < 255 ? (G < 1 ? 0 : G) : 255) * 0x100 +
22
+ (B < 255 ? (B < 1 ? 0 : B) : 255))
23
+ .toString(16)
24
+ .slice(1));
25
+ },
26
+ _render(ctx) {
27
+ const { width, height, fill } = this;
28
+ const wx = width / 2;
29
+ const wy = width / 2;
30
+ const h = height / 2;
31
+ const x = 0;
32
+ const y = wy;
33
+ ctx.beginPath();
34
+ ctx.moveTo(x, y);
35
+ ctx.lineTo(x - wx, y - wx * 0.5);
36
+ ctx.lineTo(x - wx, y - h - wx * 0.5);
37
+ ctx.lineTo(x, y - h * 1);
38
+ ctx.closePath();
39
+ ctx.fillStyle = this.shadeColor(fill, -10);
40
+ ctx.strokeStyle = fill;
41
+ ctx.stroke();
42
+ ctx.fill();
43
+ ctx.beginPath();
44
+ ctx.moveTo(x, y);
45
+ ctx.lineTo(x + wy, y - wy * 0.5);
46
+ ctx.lineTo(x + wy, y - h - wy * 0.5);
47
+ ctx.lineTo(x, y - h * 1);
48
+ ctx.closePath();
49
+ ctx.fillStyle = this.shadeColor(fill, 10);
50
+ ctx.strokeStyle = this.shadeColor(fill, 50);
51
+ ctx.stroke();
52
+ ctx.fill();
53
+ ctx.beginPath();
54
+ ctx.moveTo(x, y - h);
55
+ ctx.lineTo(x - wx, y - h - wx * 0.5);
56
+ ctx.lineTo(x - wx + wy, y - h - (wx * 0.5 + wy * 0.5));
57
+ ctx.lineTo(x + wy, y - h - wy * 0.5);
58
+ ctx.closePath();
59
+ ctx.fillStyle = this.shadeColor(fill, 20);
60
+ ctx.strokeStyle = this.shadeColor(fill, 60);
61
+ ctx.stroke();
62
+ ctx.fill();
63
+ ctx.restore();
64
+ },
65
+ });
66
+ Cube.fromObject = (options, callback) => {
67
+ return callback(new Cube(options));
68
+ };
69
+ // @ts-ignore
70
+ window.fabric.Cube = Cube;
71
+ exports.default = Cube;
@@ -0,0 +1,2 @@
1
+ declare const CurvedLink: any;
2
+ export default CurvedLink;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +1,84 @@
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
+ style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
54
+ width: ${width}px;
55
+ height: ${height}px;
56
+ left: ${left + padLeft}px;
57
+ top: ${top + padTop}px;
58
+ position: absolute;
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;
@@ -0,0 +1,3 @@
1
+ import 'gifler';
2
+ declare const Gif: any;
3
+ export default Gif;
@@ -0,0 +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;
@@ -0,0 +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;
@@ -0,0 +1,70 @@
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
+ style: `transform: rotate(${angle}deg) scale(${scaleX * zoom}, ${scaleY * zoom});
52
+ width: ${width}px;
53
+ height: ${height}px;
54
+ left: ${left + padLeft}px;
55
+ top: ${top + padTop}px;
56
+ position: absolute;
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;
@@ -0,0 +1,2 @@
1
+ declare const Line: any;
2
+ export default Line;
@@ -0,0 +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;
@@ -0,0 +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;