react-design-editor 0.0.31 → 0.0.35

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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/react-design-editor.js +37380 -16467
  3. package/dist/react-design-editor.min.js +1 -1
  4. package/dist/react-design-editor.min.js.LICENSE.txt +13 -2
  5. package/lib/Canvas.d.ts +18 -29
  6. package/lib/Canvas.js +172 -208
  7. package/lib/CanvasObject.d.ts +10 -10
  8. package/lib/CanvasObject.js +96 -89
  9. package/lib/constants/code.d.ts +19 -0
  10. package/lib/constants/code.js +22 -0
  11. package/lib/constants/defaults.d.ts +38 -0
  12. package/lib/constants/defaults.js +69 -0
  13. package/lib/constants/index.d.ts +3 -0
  14. package/lib/constants/index.js +26 -0
  15. package/lib/handlers/AlignmentHandler.d.ts +18 -18
  16. package/lib/handlers/AlignmentHandler.js +58 -58
  17. package/lib/handlers/AnimationHandler.d.ts +50 -48
  18. package/lib/handlers/AnimationHandler.js +323 -298
  19. package/lib/handlers/ChartHandler.d.ts +8 -8
  20. package/lib/handlers/ChartHandler.js +8 -8
  21. package/lib/handlers/ContextmenuHandler.d.ts +28 -23
  22. package/lib/handlers/ContextmenuHandler.js +65 -56
  23. package/lib/handlers/CropHandler.d.ts +43 -37
  24. package/lib/handlers/CropHandler.js +261 -243
  25. package/lib/handlers/CustomHandler.d.ts +7 -0
  26. package/lib/handlers/CustomHandler.js +10 -0
  27. package/lib/handlers/DrawingHandler.d.ts +28 -28
  28. package/lib/handlers/DrawingHandler.js +318 -318
  29. package/lib/handlers/ElementHandler.d.ts +80 -80
  30. package/lib/handlers/ElementHandler.js +154 -154
  31. package/lib/handlers/EventHandler.d.ts +170 -182
  32. package/lib/handlers/EventHandler.js +880 -914
  33. package/lib/handlers/FiberHandler.d.ts +6 -0
  34. package/lib/handlers/FiberHandler.js +23 -0
  35. package/lib/handlers/GridHandler.d.ts +19 -18
  36. package/lib/handlers/GridHandler.js +77 -75
  37. package/lib/handlers/GuidelineHandler.d.ts +61 -39
  38. package/lib/handlers/GuidelineHandler.js +315 -263
  39. package/lib/handlers/Handler.d.ts +622 -543
  40. package/lib/handlers/Handler.js +1638 -1514
  41. package/lib/handlers/ImageHandler.d.ts +307 -307
  42. package/lib/handlers/ImageHandler.js +529 -484
  43. package/lib/handlers/InteractionHandler.d.ts +45 -45
  44. package/lib/handlers/InteractionHandler.js +164 -156
  45. package/lib/handlers/LinkHandler.d.ts +115 -116
  46. package/lib/handlers/LinkHandler.js +247 -246
  47. package/lib/handlers/NodeHandler.d.ts +50 -50
  48. package/lib/handlers/NodeHandler.js +274 -274
  49. package/lib/handlers/PortHandler.d.ts +22 -22
  50. package/lib/handlers/PortHandler.js +179 -179
  51. package/lib/handlers/ShortcutHandler.d.ts +119 -119
  52. package/lib/handlers/ShortcutHandler.js +151 -150
  53. package/lib/handlers/TooltipHandler.d.ts +33 -24
  54. package/lib/handlers/TooltipHandler.js +91 -78
  55. package/lib/handlers/TransactionHandler.d.ts +59 -54
  56. package/lib/handlers/TransactionHandler.js +137 -129
  57. package/lib/handlers/WorkareaHandler.d.ts +43 -31
  58. package/lib/handlers/WorkareaHandler.js +354 -355
  59. package/lib/handlers/ZoomHandler.d.ts +48 -48
  60. package/lib/handlers/ZoomHandler.js +143 -145
  61. package/lib/handlers/index.d.ts +23 -21
  62. package/lib/handlers/index.js +48 -44
  63. package/lib/index.d.ts +5 -5
  64. package/lib/index.js +19 -19
  65. package/lib/objects/Arrow.d.ts +2 -2
  66. package/lib/objects/Arrow.js +40 -39
  67. package/lib/objects/Chart.d.ts +10 -10
  68. package/lib/objects/Chart.js +117 -116
  69. package/lib/objects/CirclePort.d.ts +2 -2
  70. package/lib/objects/CirclePort.js +28 -28
  71. package/lib/objects/Cube.d.ts +5 -5
  72. package/lib/objects/Cube.js +71 -71
  73. package/lib/objects/CurvedLink.d.ts +2 -2
  74. package/lib/objects/CurvedLink.js +51 -49
  75. package/lib/objects/Element.d.ts +13 -13
  76. package/lib/objects/Element.js +77 -76
  77. package/lib/objects/Gif.d.ts +3 -3
  78. package/lib/objects/Gif.js +41 -38
  79. package/lib/objects/Iframe.d.ts +9 -9
  80. package/lib/objects/Iframe.js +63 -62
  81. package/lib/objects/Line.d.ts +2 -2
  82. package/lib/objects/Line.js +24 -24
  83. package/lib/objects/Link.d.ts +15 -15
  84. package/lib/objects/Link.js +106 -104
  85. package/lib/objects/Node.d.ts +59 -59
  86. package/lib/objects/Node.js +271 -268
  87. package/lib/objects/OrthogonalLink.d.ts +2 -2
  88. package/lib/objects/OrthogonalLink.js +54 -52
  89. package/lib/objects/Port.d.ts +12 -12
  90. package/lib/objects/Port.js +28 -28
  91. package/lib/objects/Svg.d.ts +8 -0
  92. package/lib/objects/Svg.js +59 -0
  93. package/lib/objects/Video.d.ts +14 -14
  94. package/lib/objects/Video.js +113 -112
  95. package/lib/objects/index.d.ts +15 -14
  96. package/lib/objects/index.js +32 -30
  97. package/lib/utils/ObjectUtil.d.ts +407 -412
  98. package/lib/utils/ObjectUtil.js +13 -13
  99. package/lib/utils/index.d.ts +1 -1
  100. package/lib/utils/index.js +13 -13
  101. package/package.json +7 -6
@@ -1,49 +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.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
+ "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,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;
@@ -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,27 +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
- window.fabric.Element = Element;
83
- 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;
@@ -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;
@@ -1,38 +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.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
+ "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,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;
@@ -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,15 +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
- window.fabric.Iframe = Iframe;
69
- 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;
@@ -1,2 +1,2 @@
1
- declare const Line: any;
2
- export default Line;
1
+ declare const Line: any;
2
+ export default Line;
@@ -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;
@@ -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;