react-design-editor 0.0.34 → 0.0.38

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 (44) hide show
  1. package/README.md +37 -33
  2. package/dist/react-design-editor.js +18164 -10291
  3. package/dist/react-design-editor.min.js +1 -1
  4. package/dist/react-design-editor.min.js.LICENSE.txt +0 -9
  5. package/lib/Canvas.d.ts +11 -25
  6. package/lib/Canvas.js +25 -15
  7. package/lib/constants/defaults.d.ts +2 -1
  8. package/lib/constants/defaults.js +1 -0
  9. package/lib/handlers/AnimationHandler.js +8 -5
  10. package/lib/handlers/CustomHandler.d.ts +7 -0
  11. package/lib/handlers/CustomHandler.js +10 -0
  12. package/lib/handlers/DrawingHandler.d.ts +1 -1
  13. package/lib/handlers/DrawingHandler.js +8 -8
  14. package/lib/handlers/EventHandler.d.ts +1 -1
  15. package/lib/handlers/EventHandler.js +7 -5
  16. package/lib/handlers/FiberHandler.d.ts +6 -0
  17. package/lib/handlers/FiberHandler.js +23 -0
  18. package/lib/handlers/GuidelineHandler.d.ts +1 -1
  19. package/lib/handlers/GuidelineHandler.js +1 -0
  20. package/lib/handlers/Handler.d.ts +15 -2
  21. package/lib/handlers/Handler.js +41 -15
  22. package/lib/handlers/InteractionHandler.d.ts +1 -1
  23. package/lib/handlers/InteractionHandler.js +6 -1
  24. package/lib/handlers/LinkHandler.d.ts +2 -2
  25. package/lib/handlers/LinkHandler.js +1 -1
  26. package/lib/handlers/NodeHandler.js +14 -14
  27. package/lib/handlers/TransactionHandler.js +1 -3
  28. package/lib/handlers/index.d.ts +2 -0
  29. package/lib/handlers/index.js +4 -0
  30. package/lib/index.d.ts +2 -1
  31. package/lib/index.js +2 -1
  32. package/lib/objects/Arrow.js +1 -0
  33. package/lib/objects/Chart.js +2 -1
  34. package/lib/objects/CurvedLink.js +2 -0
  35. package/lib/objects/Element.js +1 -0
  36. package/lib/objects/Gif.js +4 -1
  37. package/lib/objects/Iframe.js +1 -0
  38. package/lib/objects/Link.js +4 -2
  39. package/lib/objects/Node.js +3 -3
  40. package/lib/objects/OrthogonalLink.js +2 -0
  41. package/lib/objects/Svg.d.ts +1 -1
  42. package/lib/objects/Video.js +1 -0
  43. package/lib/utils/ObjectUtil.d.ts +8 -1
  44. package/package.json +35 -31
@@ -53,12 +53,3 @@ object-assign
53
53
  * This source code is licensed under the MIT license found in the
54
54
  * LICENSE file in the root directory of this source tree.
55
55
  */
56
-
57
- /** @license React v16.14.0
58
- * react.production.min.js
59
- *
60
- * Copyright (c) Facebook, Inc. and its affiliates.
61
- *
62
- * This source code is licensed under the MIT license found in the
63
- * LICENSE file in the root directory of this source tree.
64
- */
package/lib/Canvas.d.ts CHANGED
@@ -1,32 +1,18 @@
1
- import React, { Component } from 'react';
1
+ import React from 'react';
2
2
  import Handler, { HandlerOptions } from './handlers/Handler';
3
+ import './styles/canvas.less';
4
+ import './styles/contextmenu.less';
5
+ import './styles/fabricjs.less';
6
+ import './styles/tooltip.less';
3
7
  import { FabricCanvas } from './utils';
4
- import '../../styles/core/canvas.less';
5
- import '../../styles/core/tooltip.less';
6
- import '../../styles/core/contextmenu.less';
7
- import '../../styles/fabricjs/fabricjs.less';
8
+ export interface CanvasInstance {
9
+ handler: Handler;
10
+ canvas: FabricCanvas;
11
+ container: HTMLDivElement;
12
+ }
8
13
  export declare type CanvasProps = HandlerOptions & {
9
14
  responsive?: boolean;
10
15
  style?: React.CSSProperties;
11
- ref?: React.RefAttributes<Handler>;
12
16
  };
13
- interface IState {
14
- id: string;
15
- loaded: boolean;
16
- }
17
- declare class Canvas extends Component<CanvasProps, IState> {
18
- handler: Handler;
19
- canvas: FabricCanvas;
20
- container: React.RefObject<HTMLDivElement>;
21
- private resizeObserver;
22
- static defaultProps: CanvasProps;
23
- state: IState;
24
- componentDidMount(): void;
25
- componentDidUpdate(prevProps: CanvasProps): void;
26
- componentWillUnmount(): void;
27
- createObserver: () => void;
28
- destroyObserver: () => void;
29
- handleLoad: () => void;
30
- render(): JSX.Element;
31
- }
17
+ declare const Canvas: React.FC<CanvasProps>;
32
18
  export default Canvas;
package/lib/Canvas.js CHANGED
@@ -22,22 +22,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- const react_1 = __importStar(require("react"));
26
25
  const fabric_1 = require("fabric");
27
- const uuid_1 = require("uuid");
26
+ const react_1 = __importStar(require("react"));
28
27
  const resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
29
- const Handler_1 = __importDefault(require("./handlers/Handler"));
28
+ const uuidv4_1 = require("uuidv4");
30
29
  const constants_1 = require("./constants");
31
- require("../../styles/core/canvas.less");
32
- require("../../styles/core/tooltip.less");
33
- require("../../styles/core/contextmenu.less");
34
- require("../../styles/fabricjs/fabricjs.less");
35
- class Canvas extends react_1.Component {
30
+ const Handler_1 = __importDefault(require("./handlers/Handler"));
31
+ require("./styles/canvas.less");
32
+ require("./styles/contextmenu.less");
33
+ require("./styles/fabricjs.less");
34
+ require("./styles/tooltip.less");
35
+ class InternalCanvas extends react_1.Component {
36
36
  constructor() {
37
37
  super(...arguments);
38
- this.container = react_1.default.createRef();
38
+ this.containerRef = react_1.default.createRef();
39
39
  this.state = {
40
- id: uuid_1.v4(),
40
+ id: uuidv4_1.uuid(),
41
41
  loaded: false,
42
42
  };
43
43
  this.createObserver = () => {
@@ -48,7 +48,7 @@ class Canvas extends react_1.Component {
48
48
  this.handleLoad();
49
49
  }
50
50
  });
51
- this.resizeObserver.observe(this.container.current);
51
+ this.resizeObserver.observe(this.containerRef.current);
52
52
  };
53
53
  this.destroyObserver = () => {
54
54
  if (this.resizeObserver) {
@@ -77,13 +77,14 @@ class Canvas extends react_1.Component {
77
77
  this.canvas = new fabric_1.fabric.Canvas(`canvas_${id}`, mergedCanvasOption);
78
78
  this.canvas.setBackgroundColor(mergedCanvasOption.backgroundColor, this.canvas.renderAll.bind(this.canvas));
79
79
  this.canvas.renderAll();
80
+ this.container = this.containerRef.current;
80
81
  this.handler = new Handler_1.default({
81
82
  id,
82
83
  width,
83
84
  height,
84
85
  editable,
85
86
  canvas: this.canvas,
86
- container: this.container.current,
87
+ container: this.containerRef.current,
87
88
  canvasOption: mergedCanvasOption,
88
89
  ...other,
89
90
  });
@@ -145,12 +146,12 @@ class Canvas extends react_1.Component {
145
146
  render() {
146
147
  const { style } = this.props;
147
148
  const { id } = this.state;
148
- return (react_1.default.createElement("div", { ref: this.container, id: id, className: "rde-canvas", style: { width: '100%', height: '100%', ...style } },
149
+ return (react_1.default.createElement("div", { ref: this.containerRef, id: id, className: "rde-canvas", style: { width: '100%', height: '100%', ...style } },
149
150
  react_1.default.createElement("canvas", { id: `canvas_${id}` })));
150
151
  }
151
152
  }
152
- Canvas.defaultProps = {
153
- id: uuid_1.v4(),
153
+ InternalCanvas.defaultProps = {
154
+ id: uuidv4_1.uuid(),
154
155
  editable: true,
155
156
  zoomEnabled: true,
156
157
  minZoom: 30,
@@ -159,4 +160,13 @@ Canvas.defaultProps = {
159
160
  width: 0,
160
161
  height: 0,
161
162
  };
163
+ const Canvas = react_1.default.forwardRef((props, ref) => {
164
+ const canvasRef = react_1.useRef();
165
+ react_1.default.useImperativeHandle(ref, () => ({
166
+ handler: canvasRef.current.handler,
167
+ canvas: canvasRef.current.canvas,
168
+ container: canvasRef.current.container,
169
+ }));
170
+ return react_1.default.createElement(InternalCanvas, Object.assign({ ref: canvasRef }, props));
171
+ });
162
172
  exports.default = Canvas;
@@ -1,4 +1,4 @@
1
- import { WorkareaObject, FabricObjectOption } from '../utils';
1
+ import { FabricObjectOption, WorkareaObject } from '../utils';
2
2
  export declare const canvasOption: {
3
3
  preserveObjectStacking: boolean;
4
4
  width: number;
@@ -18,6 +18,7 @@ export declare const keyEvent: {
18
18
  transaction: boolean;
19
19
  zoom: boolean;
20
20
  cut: boolean;
21
+ grab: boolean;
21
22
  };
22
23
  export declare const gridOption: {
23
24
  enabled: boolean;
@@ -20,6 +20,7 @@ exports.keyEvent = {
20
20
  transaction: true,
21
21
  zoom: true,
22
22
  cut: true,
23
+ grab: true,
23
24
  };
24
25
  exports.gridOption = {
25
26
  enabled: false,
@@ -168,7 +168,7 @@ class AnimationHandler {
168
168
  fill: obj.originFill,
169
169
  stroke: obj.originStroke,
170
170
  originFill: null,
171
- origniStroke: null,
171
+ originStroke: null,
172
172
  });
173
173
  }
174
174
  else {
@@ -202,17 +202,20 @@ class AnimationHandler {
202
202
  });
203
203
  this.handler.canvas.requestRenderAll();
204
204
  },
205
- update: (e) => {
205
+ update: (instance) => {
206
206
  if (type === 'flash') {
207
207
  // I don't know why it works. Magic code...
208
- const fill = e.animations[0].currentValue;
209
- const stroke = e.animations[1].currentValue;
208
+ const fill = instance.animations[0].currentValue;
209
+ const stroke = instance.animations[1].currentValue;
210
210
  obj.set('fill', '');
211
211
  obj.set('fill', fill);
212
212
  obj.set('stroke', stroke);
213
213
  }
214
214
  else if (type === 'rotation') {
215
- const angle = e.animations[0].currentValue;
215
+ let angle = instance.animations[0].currentValue;
216
+ if (typeof angle === 'string') {
217
+ angle = parseInt(angle, 10);
218
+ }
216
219
  obj.rotate(angle);
217
220
  this.handler.canvas.requestRenderAll();
218
221
  return;
@@ -0,0 +1,7 @@
1
+ import { Handler } from '.';
2
+ declare class CustomHandler {
3
+ handler: Handler;
4
+ constructor(handler: Handler);
5
+ protected initialze(): void;
6
+ }
7
+ export default CustomHandler;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class CustomHandler {
4
+ constructor(handler) {
5
+ this.handler = handler;
6
+ this.initialze();
7
+ }
8
+ initialze() { }
9
+ }
10
+ exports.default = CustomHandler;
@@ -1,6 +1,6 @@
1
1
  import { fabric } from 'fabric';
2
- import Handler from './Handler';
3
2
  import { FabricEvent, FabricObject } from '../utils';
3
+ import Handler from './Handler';
4
4
  declare class DrawingHandler {
5
5
  handler: Handler;
6
6
  constructor(handler: Handler);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fabric_1 = require("fabric");
4
- const uuid_1 = require("uuid");
4
+ const uuidv4_1 = require("uuidv4");
5
5
  const objects_1 = require("../objects");
6
6
  class DrawingHandler {
7
7
  constructor(handler) {
@@ -33,7 +33,7 @@ class DrawingHandler {
33
33
  const { e, absolutePointer } = opt;
34
34
  const { x, y } = absolutePointer;
35
35
  const circle = new fabric_1.fabric.Circle({
36
- radius: 3,
36
+ radius: 1,
37
37
  fill: '#ffffff',
38
38
  stroke: '#333333',
39
39
  strokeWidth: 0.5,
@@ -47,7 +47,7 @@ class DrawingHandler {
47
47
  hoverCursor: 'pointer',
48
48
  });
49
49
  circle.set({
50
- id: uuid_1.v4(),
50
+ id: uuidv4_1.uuid(),
51
51
  });
52
52
  if (!this.handler.pointArray.length) {
53
53
  circle.set({
@@ -56,7 +56,7 @@ class DrawingHandler {
56
56
  }
57
57
  const points = [x, y, x, y];
58
58
  const line = new fabric_1.fabric.Line(points, {
59
- strokeWidth: 2,
59
+ strokeWidth: 1,
60
60
  fill: '#999999',
61
61
  stroke: '#999999',
62
62
  originX: 'center',
@@ -114,7 +114,7 @@ class DrawingHandler {
114
114
  },
115
115
  generate: (pointArray) => {
116
116
  const points = [];
117
- const id = uuid_1.v4();
117
+ const id = uuidv4_1.uuid();
118
118
  pointArray.forEach(point => {
119
119
  points.push({
120
120
  x: point.left,
@@ -131,7 +131,7 @@ class DrawingHandler {
131
131
  points,
132
132
  type: 'polygon',
133
133
  stroke: 'rgba(0, 0, 0, 1)',
134
- strokeWidth: 3,
134
+ strokeWidth: 1,
135
135
  fill: 'rgba(0, 0, 0, 0.25)',
136
136
  opacity: 1,
137
137
  objectCaching: !this.handler.editable,
@@ -206,7 +206,7 @@ class DrawingHandler {
206
206
  const { absolutePointer } = opt;
207
207
  const { x, y } = absolutePointer;
208
208
  let points = [];
209
- const id = uuid_1.v4();
209
+ const id = uuidv4_1.uuid();
210
210
  this.handler.pointArray.forEach(point => {
211
211
  points = points.concat(point.left, point.top, x, y);
212
212
  this.handler.canvas.remove(point);
@@ -294,7 +294,7 @@ class DrawingHandler {
294
294
  });
295
295
  this.handler.canvas.remove(this.handler.activeLine);
296
296
  const option = {
297
- id: uuid_1.v4(),
297
+ id: uuidv4_1.uuid(),
298
298
  points,
299
299
  type: 'arrow',
300
300
  stroke: 'rgba(0, 0, 0, 1)',
@@ -1,5 +1,5 @@
1
- import Handler from './Handler';
2
1
  import { FabricEvent } from '../utils';
2
+ import Handler from './Handler';
3
3
  /**
4
4
  * Event Handler Class
5
5
  * @author salgum1114
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fabric_1 = require("fabric");
7
6
  const animejs_1 = __importDefault(require("animejs"));
7
+ const fabric_1 = require("fabric");
8
8
  const constants_1 = require("../constants");
9
9
  /**
10
10
  * Event Handler Class
@@ -677,7 +677,7 @@ class EventHandler {
677
677
  // const { type } = file;
678
678
  // if (type === 'image/png' || type === 'image/jpeg' || type === 'image/jpg') {
679
679
  // const item = {
680
- // id: v4(),
680
+ // id: uuid(),
681
681
  // type: 'image',
682
682
  // file,
683
683
  // superType: 'image',
@@ -702,7 +702,7 @@ class EventHandler {
702
702
  if (!Object.keys(keyEvent).length) {
703
703
  return;
704
704
  }
705
- const { clipboard } = keyEvent;
705
+ const { clipboard, grab } = keyEvent;
706
706
  if (this.handler.interactionHandler.isDrawingMode()) {
707
707
  if (this.handler.shortcutHandler.isEscape(e)) {
708
708
  if (this.handler.interactionMode === 'polygon') {
@@ -720,12 +720,12 @@ class EventHandler {
720
720
  }
721
721
  return;
722
722
  }
723
- if (this.handler.shortcutHandler.isW(e)) {
723
+ if (this.handler.shortcutHandler.isW(e) && grab) {
724
724
  this.code = e.code;
725
725
  this.handler.interactionHandler.grab();
726
726
  return;
727
727
  }
728
- if (e.altKey && editable) {
728
+ if (e.altKey && editable && grab) {
729
729
  this.handler.interactionHandler.grab();
730
730
  return;
731
731
  }
@@ -839,6 +839,7 @@ class EventHandler {
839
839
  */
840
840
  initialize() {
841
841
  if (this.handler.editable) {
842
+ // @ts-ignore
842
843
  this.handler.canvas.on({
843
844
  'object:modified': this.modified,
844
845
  'object:scaling': this.scaling,
@@ -857,6 +858,7 @@ class EventHandler {
857
858
  });
858
859
  }
859
860
  else {
861
+ // @ts-ignore
860
862
  this.handler.canvas.on({
861
863
  'mouse:down': this.mousedown,
862
864
  'mouse:move': this.mousemove,
@@ -0,0 +1,6 @@
1
+ import CustomHandler from './CustomHandler';
2
+ declare class FiberHandler extends CustomHandler {
3
+ protected initialze(): void;
4
+ private mousedown;
5
+ }
6
+ export default FiberHandler;
@@ -0,0 +1,23 @@
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 CustomHandler_1 = __importDefault(require("./CustomHandler"));
7
+ class FiberHandler extends CustomHandler_1.default {
8
+ initialze() {
9
+ this.handler.canvas.on('mouse:down', this.mousedown);
10
+ }
11
+ mousedown(opt) {
12
+ const { subTargets } = opt;
13
+ if (subTargets.length) {
14
+ const target = subTargets[0];
15
+ console.log(target);
16
+ if (target.type === 'container') {
17
+ }
18
+ else if (target.type === 'coreContainer') {
19
+ }
20
+ }
21
+ }
22
+ }
23
+ exports.default = FiberHandler;
@@ -1,5 +1,5 @@
1
+ import { FabricEvent, FabricObject } from '../utils';
1
2
  import Handler from './Handler';
2
- import { FabricObject, FabricEvent } from '../utils';
3
3
  declare class GuidelineHandler {
4
4
  handler: Handler;
5
5
  verticalLines: {
@@ -278,6 +278,7 @@ class GuidelineHandler {
278
278
  */
279
279
  initialize() {
280
280
  if (this.handler.guidelineOption.enabled) {
281
+ // @ts-ignore
281
282
  this.handler.canvas.on({
282
283
  'before:render': this.beforeRender,
283
284
  'after:render': this.afterRender,
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { fabric } from 'fabric';
3
- import { ElementHandler, ImageHandler, ChartHandler, CropHandler, AnimationHandler, ContextmenuHandler, TooltipHandler, ZoomHandler, WorkareaHandler, TransactionHandler, LinkHandler, AlignmentHandler, GuidelineHandler, GridHandler, PortHandler, NodeHandler, EventHandler, DrawingHandler, InteractionHandler, ShortcutHandler } from '.';
4
- import { FabricObject, FabricImage, WorkareaObject, WorkareaOption, InteractionMode, CanvasOption, GridOption, GuidelineOption, KeyEvent, FabricObjectOption, FabricCanvas, FabricGroup, FabricObjects } from '../utils';
3
+ import { AlignmentHandler, AnimationHandler, ChartHandler, ContextmenuHandler, CropHandler, CustomHandler, DrawingHandler, ElementHandler, EventHandler, GridHandler, GuidelineHandler, ImageHandler, InteractionHandler, LinkHandler, NodeHandler, PortHandler, ShortcutHandler, TooltipHandler, TransactionHandler, WorkareaHandler, ZoomHandler } from '.';
4
+ import { CanvasOption, FabricCanvas, FabricGroup, FabricImage, FabricObject, FabricObjectOption, FabricObjects, GridOption, GuidelineOption, InteractionMode, KeyEvent, WorkareaObject, WorkareaOption } from '../utils';
5
5
  import { TransactionEvent } from './TransactionHandler';
6
6
  export interface HandlerCallback {
7
7
  /**
@@ -159,6 +159,9 @@ export interface HandlerOption {
159
159
  * @type {{ [key: string]: any }}
160
160
  */
161
161
  fabricObjects?: FabricObjects;
162
+ handlers?: {
163
+ [key: string]: CustomHandler;
164
+ };
162
165
  [key: string]: any;
163
166
  }
164
167
  export declare type HandlerOptions = HandlerOption & HandlerCallback;
@@ -220,6 +223,9 @@ declare class Handler implements HandlerOptions {
220
223
  eventHandler: EventHandler;
221
224
  drawingHandler: DrawingHandler;
222
225
  shortcutHandler: ShortcutHandler;
226
+ handlers: {
227
+ [key: string]: CustomHandler;
228
+ };
223
229
  objectMap: Record<string, FabricObject>;
224
230
  objects: FabricObject[];
225
231
  activeLine?: any;
@@ -605,5 +611,12 @@ declare class Handler implements HandlerOptions {
605
611
  * @param {string[]} propertiesToInclude
606
612
  */
607
613
  setPropertiesToInclude: (propertiesToInclude: string[]) => void;
614
+ /**
615
+ * Register custom handler
616
+ *
617
+ * @param {string} name
618
+ * @param {typeof CustomHandler} handler
619
+ */
620
+ registerHandler: (name: string, handler: typeof CustomHandler) => CustomHandler;
608
621
  }
609
622
  export default Handler;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fabric_1 = require("fabric");
7
- const warning_1 = __importDefault(require("warning"));
8
- const uuid_1 = require("uuid");
9
7
  const lodash_1 = require("lodash");
8
+ const uuidv4_1 = require("uuidv4");
9
+ const warning_1 = __importDefault(require("warning"));
10
10
  const _1 = require(".");
11
11
  const CanvasObject_1 = __importDefault(require("../CanvasObject"));
12
12
  const constants_1 = require("../constants");
@@ -26,6 +26,7 @@ class Handler {
26
26
  this.keyEvent = constants_1.defaults.keyEvent;
27
27
  this.activeSelectionOption = constants_1.defaults.activeSelectionOption;
28
28
  this.fabricObjects = CanvasObject_1.default;
29
+ this.handlers = {};
29
30
  this.objectMap = {};
30
31
  this.zoom = 1;
31
32
  this.isCut = false;
@@ -139,8 +140,13 @@ class Handler {
139
140
  if (!activeObject) {
140
141
  return;
141
142
  }
142
- activeObject.set(key, value);
143
- activeObject.setCoords();
143
+ if ((activeObject.type === 'svg' && key === 'fill') || key === 'stroke') {
144
+ activeObject._objects.forEach(obj => obj.set(key, value));
145
+ }
146
+ else {
147
+ activeObject.set(key, value);
148
+ activeObject.setCoords();
149
+ }
144
150
  this.canvas.requestRenderAll();
145
151
  const { id, superType, type, player, width, height } = activeObject;
146
152
  if (superType === 'element') {
@@ -298,7 +304,7 @@ class Handler {
298
304
  if (!activeObject) {
299
305
  return;
300
306
  }
301
- activeObject.setShadow(option);
307
+ activeObject.set('shadow', new fabric_1.fabric.Shadow(option));
302
308
  this.canvas.requestRenderAll();
303
309
  const { onModified } = this;
304
310
  if (onModified) {
@@ -464,7 +470,7 @@ class Handler {
464
470
  this.animationHandler.play(createdObj.id);
465
471
  }
466
472
  if (createdObj.superType === 'node') {
467
- createdObj.setShadow({
473
+ createdObj.set('shadow', {
468
474
  color: createdObj.stroke,
469
475
  });
470
476
  }
@@ -651,7 +657,12 @@ class Handler {
651
657
  const activeSelection = clonedObj;
652
658
  activeSelection.canvas = this.canvas;
653
659
  activeSelection.forEachObject((obj) => {
654
- obj.set('id', uuid_1.v4());
660
+ obj.set('id', uuidv4_1.uuid());
661
+ if (obj.superType === 'node') {
662
+ obj.set('shadow', {
663
+ color: obj.stroke,
664
+ });
665
+ }
655
666
  this.canvas.add(obj);
656
667
  this.objects = this.getObjects();
657
668
  if (obj.dblclick) {
@@ -665,7 +676,12 @@ class Handler {
665
676
  }
666
677
  else {
667
678
  if (activeObject.id === clonedObj.id) {
668
- clonedObj.set('id', uuid_1.v4());
679
+ clonedObj.set('id', uuidv4_1.uuid());
680
+ }
681
+ if (clonedObj.superType === 'node') {
682
+ clonedObj.set('shadow', {
683
+ color: clonedObj.stroke,
684
+ });
669
685
  }
670
686
  this.canvas.add(clonedObj);
671
687
  this.objects = this.getObjects();
@@ -697,7 +713,7 @@ class Handler {
697
713
  cloned.set({
698
714
  left: cloned.left + grid,
699
715
  top: cloned.top + grid,
700
- id: uuid_1.v4(),
716
+ id: uuidv4_1.uuid(),
701
717
  evented: true,
702
718
  });
703
719
  this.canvas.add(cloned);
@@ -935,13 +951,13 @@ class Handler {
935
951
  clonedObj.set({
936
952
  left: clonedObj.left + padding,
937
953
  top: clonedObj.top + padding,
938
- id: isCut ? clipboard.id : uuid_1.v4(),
954
+ id: isCut ? clipboard.id : uuidv4_1.uuid(),
939
955
  evented: true,
940
956
  });
941
957
  if (clonedObj.type === 'activeSelection') {
942
958
  clonedObj.canvas = this.canvas;
943
959
  clonedObj.forEachObject((obj) => {
944
- obj.set('id', isCut ? obj.id : uuid_1.v4());
960
+ obj.set('id', isCut ? obj.id : uuidv4_1.uuid());
945
961
  this.canvas.add(obj);
946
962
  if (obj.dblclick) {
947
963
  obj.on('mousedblclick', this.eventHandler.object.mousedblclick);
@@ -997,10 +1013,10 @@ class Handler {
997
1013
  }
998
1014
  fabric_1.fabric.util.loadImage(url, source => {
999
1015
  if (obj.type !== 'image') {
1000
- obj.setPatternFill({
1016
+ obj.set('fill', new fabric_1.fabric.Pattern({
1001
1017
  source,
1002
1018
  repeat: 'repeat',
1003
- }, null);
1019
+ }));
1004
1020
  obj.setCoords();
1005
1021
  this.canvas.renderAll();
1006
1022
  return;
@@ -1237,7 +1253,7 @@ class Handler {
1237
1253
  obj.top += diffTop;
1238
1254
  }
1239
1255
  if (obj.superType === 'element') {
1240
- obj.id = uuid_1.v4();
1256
+ obj.id = uuidv4_1.uuid();
1241
1257
  }
1242
1258
  this.add(obj, false, true);
1243
1259
  this.canvas.renderAll();
@@ -1266,7 +1282,7 @@ class Handler {
1266
1282
  }
1267
1283
  const group = activeObject.toGroup();
1268
1284
  group.set({
1269
- id: uuid_1.v4(),
1285
+ id: uuidv4_1.uuid(),
1270
1286
  name: 'New group',
1271
1287
  type: 'group',
1272
1288
  ...this.objectOption,
@@ -1595,6 +1611,16 @@ class Handler {
1595
1611
  this.setPropertiesToInclude = (propertiesToInclude) => {
1596
1612
  this.propertiesToInclude = lodash_1.union(propertiesToInclude, this.propertiesToInclude);
1597
1613
  };
1614
+ /**
1615
+ * Register custom handler
1616
+ *
1617
+ * @param {string} name
1618
+ * @param {typeof CustomHandler} handler
1619
+ */
1620
+ this.registerHandler = (name, handler) => {
1621
+ this.handlers[name] = new handler(this);
1622
+ return this.handlers[name];
1623
+ };
1598
1624
  this.initialize(options);
1599
1625
  }
1600
1626
  /**
@@ -1,5 +1,5 @@
1
- import Handler from './Handler';
2
1
  import { FabricObject, InteractionMode } from '../utils';
2
+ import Handler from './Handler';
3
3
  declare type IReturnType = {
4
4
  selectable?: boolean;
5
5
  evented?: boolean;
@@ -32,7 +32,12 @@ class InteractionHandler {
32
32
  obj.hoverCursor = 'pointer';
33
33
  return;
34
34
  }
35
- obj.hoverCursor = 'move';
35
+ if (this.handler.editable) {
36
+ obj.hoverCursor = 'move';
37
+ }
38
+ else {
39
+ obj.hoverCursor = 'pointer';
40
+ }
36
41
  obj.selectable = true;
37
42
  obj.evented = true;
38
43
  }
@@ -1,6 +1,6 @@
1
- import Handler from './Handler';
2
- import { PortObject } from '../objects/Port';
3
1
  import { LinkObject } from '../objects/Link';
2
+ import { PortObject } from '../objects/Port';
3
+ import Handler from './Handler';
4
4
  export interface LinkOption {
5
5
  /**
6
6
  * Link Type
@@ -34,7 +34,7 @@ class LinkHandler {
34
34
  const toPort = { left, top };
35
35
  const fromNode = this.handler.objectMap[nodeId];
36
36
  this.handler.activeLine = new objects_1.CurvedLink(fromNode, fromPort, null, toPort, {
37
- strokeWidth: 2,
37
+ strokeWidth: 4,
38
38
  fill: '#999999',
39
39
  stroke: '#999999',
40
40
  class: 'line',