react-design-editor 0.0.33 → 0.0.37

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 (95) hide show
  1. package/README.md +37 -33
  2. package/dist/react-design-editor.js +20849 -11309
  3. package/dist/react-design-editor.min.js +1 -1
  4. package/dist/react-design-editor.min.js.LICENSE.txt +3 -10
  5. package/package.json +35 -31
  6. package/lib/Canvas.d.ts +0 -32
  7. package/lib/Canvas.js +0 -162
  8. package/lib/CanvasObject.d.ts +0 -10
  9. package/lib/CanvasObject.js +0 -96
  10. package/lib/constants/defaults.d.ts +0 -37
  11. package/lib/constants/defaults.js +0 -68
  12. package/lib/constants/index.d.ts +0 -2
  13. package/lib/constants/index.js +0 -24
  14. package/lib/handlers/AlignmentHandler.d.ts +0 -18
  15. package/lib/handlers/AlignmentHandler.js +0 -58
  16. package/lib/handlers/AnimationHandler.d.ts +0 -50
  17. package/lib/handlers/AnimationHandler.js +0 -320
  18. package/lib/handlers/ChartHandler.d.ts +0 -8
  19. package/lib/handlers/ChartHandler.js +0 -8
  20. package/lib/handlers/ContextmenuHandler.d.ts +0 -28
  21. package/lib/handlers/ContextmenuHandler.js +0 -65
  22. package/lib/handlers/CropHandler.d.ts +0 -43
  23. package/lib/handlers/CropHandler.js +0 -261
  24. package/lib/handlers/DrawingHandler.d.ts +0 -28
  25. package/lib/handlers/DrawingHandler.js +0 -318
  26. package/lib/handlers/ElementHandler.d.ts +0 -80
  27. package/lib/handlers/ElementHandler.js +0 -154
  28. package/lib/handlers/EventHandler.d.ts +0 -170
  29. package/lib/handlers/EventHandler.js +0 -877
  30. package/lib/handlers/GridHandler.d.ts +0 -19
  31. package/lib/handlers/GridHandler.js +0 -77
  32. package/lib/handlers/GuidelineHandler.d.ts +0 -61
  33. package/lib/handlers/GuidelineHandler.js +0 -314
  34. package/lib/handlers/Handler.d.ts +0 -603
  35. package/lib/handlers/Handler.js +0 -1612
  36. package/lib/handlers/ImageHandler.d.ts +0 -307
  37. package/lib/handlers/ImageHandler.js +0 -529
  38. package/lib/handlers/InteractionHandler.d.ts +0 -45
  39. package/lib/handlers/InteractionHandler.js +0 -159
  40. package/lib/handlers/LinkHandler.d.ts +0 -115
  41. package/lib/handlers/LinkHandler.js +0 -247
  42. package/lib/handlers/NodeHandler.d.ts +0 -50
  43. package/lib/handlers/NodeHandler.js +0 -274
  44. package/lib/handlers/PortHandler.d.ts +0 -22
  45. package/lib/handlers/PortHandler.js +0 -179
  46. package/lib/handlers/ShortcutHandler.d.ts +0 -119
  47. package/lib/handlers/ShortcutHandler.js +0 -150
  48. package/lib/handlers/TooltipHandler.d.ts +0 -33
  49. package/lib/handlers/TooltipHandler.js +0 -91
  50. package/lib/handlers/TransactionHandler.d.ts +0 -59
  51. package/lib/handlers/TransactionHandler.js +0 -139
  52. package/lib/handlers/WorkareaHandler.d.ts +0 -43
  53. package/lib/handlers/WorkareaHandler.js +0 -354
  54. package/lib/handlers/ZoomHandler.d.ts +0 -48
  55. package/lib/handlers/ZoomHandler.js +0 -143
  56. package/lib/handlers/index.d.ts +0 -21
  57. package/lib/handlers/index.js +0 -44
  58. package/lib/index.d.ts +0 -5
  59. package/lib/index.js +0 -19
  60. package/lib/objects/Arrow.d.ts +0 -2
  61. package/lib/objects/Arrow.js +0 -39
  62. package/lib/objects/Chart.d.ts +0 -10
  63. package/lib/objects/Chart.js +0 -123
  64. package/lib/objects/CirclePort.d.ts +0 -2
  65. package/lib/objects/CirclePort.js +0 -28
  66. package/lib/objects/Cube.d.ts +0 -5
  67. package/lib/objects/Cube.js +0 -71
  68. package/lib/objects/CurvedLink.d.ts +0 -2
  69. package/lib/objects/CurvedLink.js +0 -49
  70. package/lib/objects/Element.d.ts +0 -13
  71. package/lib/objects/Element.js +0 -83
  72. package/lib/objects/Gif.d.ts +0 -3
  73. package/lib/objects/Gif.js +0 -38
  74. package/lib/objects/Iframe.d.ts +0 -9
  75. package/lib/objects/Iframe.js +0 -69
  76. package/lib/objects/Line.d.ts +0 -2
  77. package/lib/objects/Line.js +0 -24
  78. package/lib/objects/Link.d.ts +0 -15
  79. package/lib/objects/Link.js +0 -104
  80. package/lib/objects/Node.d.ts +0 -59
  81. package/lib/objects/Node.js +0 -271
  82. package/lib/objects/OrthogonalLink.d.ts +0 -2
  83. package/lib/objects/OrthogonalLink.js +0 -52
  84. package/lib/objects/Port.d.ts +0 -12
  85. package/lib/objects/Port.js +0 -28
  86. package/lib/objects/Svg.d.ts +0 -8
  87. package/lib/objects/Svg.js +0 -59
  88. package/lib/objects/Video.d.ts +0 -14
  89. package/lib/objects/Video.js +0 -119
  90. package/lib/objects/index.d.ts +0 -15
  91. package/lib/objects/index.js +0 -32
  92. package/lib/utils/ObjectUtil.d.ts +0 -400
  93. package/lib/utils/ObjectUtil.js +0 -13
  94. package/lib/utils/index.d.ts +0 -1
  95. package/lib/utils/index.js +0 -13
@@ -1,39 +0,0 @@
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
- window.fabric.Arrow = Arrow;
39
- exports.default = Arrow;
@@ -1,10 +0,0 @@
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;
@@ -1,123 +0,0 @@
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 fabric_1 = require("fabric");
23
- const echarts = __importStar(require("echarts"));
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
- window.fabric.Chart = Chart;
123
- exports.default = Chart;
@@ -1,2 +0,0 @@
1
- declare const CirclePort: any;
2
- export default CirclePort;
@@ -1,28 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- import { FabricObject } from '../utils';
2
- export interface CubeObject extends FabricObject {
3
- }
4
- declare const Cube: any;
5
- export default Cube;
@@ -1,71 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const CurvedLink: any;
2
- export default CurvedLink;
@@ -1,49 +0,0 @@
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.strokeStyle = this.stroke;
19
- const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
20
- const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
21
- ctx.beginPath();
22
- ctx.moveTo(fp.x, fp.y);
23
- ctx.bezierCurveTo(fp.x, sp.y, sp.x, fp.y, sp.x, sp.y);
24
- ctx.stroke();
25
- ctx.save();
26
- const xDiff = x2 - x1;
27
- const yDiff = y2 - y1;
28
- const angle = Math.atan2(yDiff, xDiff);
29
- ctx.translate((x2 - x1) / 2, (y2 - y1) / 2);
30
- ctx.rotate(angle >= 0 ? 1.57 : -1.57);
31
- ctx.beginPath();
32
- if (this.arrow) {
33
- // Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
34
- ctx.moveTo(5, 0);
35
- ctx.lineTo(-5, 5);
36
- ctx.lineTo(-5, -5);
37
- }
38
- ctx.closePath();
39
- ctx.fillStyle = this.stroke;
40
- ctx.fill();
41
- ctx.restore();
42
- },
43
- });
44
- CurvedLink.fromObject = (options, callback) => {
45
- const { fromNode, fromPort, toNode, toPort } = options;
46
- return callback(new CurvedLink(fromNode, fromPort, toNode, toPort, options));
47
- };
48
- window.fabric.CurvedLink = CurvedLink;
49
- exports.default = CurvedLink;
@@ -1,13 +0,0 @@
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,83 +0,0 @@
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
- window.fabric.Element = Element;
83
- exports.default = Element;
@@ -1,3 +0,0 @@
1
- import 'gifler';
2
- declare const Gif: any;
3
- export default Gif;
@@ -1,38 +0,0 @@
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.gifler('./images/sample/earth.gif')
27
- .frames(this.gifCanvas, (_c, frame) => {
28
- this.isStarted = true;
29
- this.drawFrame(ctx, frame);
30
- });
31
- }
32
- },
33
- });
34
- Gif.fromObject = (options, callback) => {
35
- return callback(new Gif(options));
36
- };
37
- window.fabric.Gif = Gif;
38
- exports.default = Gif;
@@ -1,9 +0,0 @@
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,69 +0,0 @@
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
- window.fabric.Iframe = Iframe;
69
- exports.default = Iframe;
@@ -1,2 +0,0 @@
1
- declare const Line: any;
2
- export default Line;
@@ -1,24 +0,0 @@
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,15 +0,0 @@
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;