react-design-editor 0.0.56 → 0.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Canvas.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface CanvasInstance {
10
10
  canvas: FabricCanvas;
11
11
  container: HTMLDivElement;
12
12
  }
13
- export declare type CanvasProps = HandlerOptions & {
13
+ export type CanvasProps = HandlerOptions & {
14
14
  responsive?: boolean;
15
15
  style?: React.CSSProperties;
16
16
  };
package/lib/Canvas.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -37,7 +41,7 @@ class InternalCanvas extends react_1.Component {
37
41
  super(...arguments);
38
42
  this.containerRef = react_1.default.createRef();
39
43
  this.state = {
40
- id: uuidv4_1.uuid(),
44
+ id: (0, uuidv4_1.uuid)(),
41
45
  loaded: false,
42
46
  };
43
47
  this.createObserver = () => {
@@ -66,6 +70,16 @@ class InternalCanvas extends react_1.Component {
66
70
  });
67
71
  };
68
72
  }
73
+ static { this.defaultProps = {
74
+ id: (0, uuidv4_1.uuid)(),
75
+ editable: true,
76
+ zoomEnabled: true,
77
+ minZoom: 30,
78
+ maxZoom: 300,
79
+ responsive: true,
80
+ width: 0,
81
+ height: 0,
82
+ }; }
69
83
  componentDidMount() {
70
84
  const { editable, canvasOption, width, height, responsive, ...other } = this.props;
71
85
  const { id } = this.state;
@@ -150,23 +164,13 @@ class InternalCanvas extends react_1.Component {
150
164
  react_1.default.createElement("canvas", { id: `canvas_${id}` })));
151
165
  }
152
166
  }
153
- InternalCanvas.defaultProps = {
154
- id: uuidv4_1.uuid(),
155
- editable: true,
156
- zoomEnabled: true,
157
- minZoom: 30,
158
- maxZoom: 300,
159
- responsive: true,
160
- width: 0,
161
- height: 0,
162
- };
163
167
  const Canvas = react_1.default.forwardRef((props, ref) => {
164
- const canvasRef = react_1.useRef();
168
+ const canvasRef = (0, react_1.useRef)();
165
169
  react_1.default.useImperativeHandle(ref, () => ({
166
170
  handler: canvasRef.current.handler,
167
171
  canvas: canvasRef.current.canvas,
168
172
  container: canvasRef.current.container,
169
173
  }));
170
- return react_1.default.createElement(InternalCanvas, Object.assign({ ref: canvasRef }, props));
174
+ return react_1.default.createElement(InternalCanvas, { ref: canvasRef, ...props });
171
175
  });
172
176
  exports.default = Canvas;
@@ -7,7 +7,8 @@ exports.createCanvasObject = void 0;
7
7
  const fabric_1 = require("fabric");
8
8
  const objects_1 = require("./objects");
9
9
  const Svg_1 = __importDefault(require("./objects/Svg"));
10
- exports.createCanvasObject = (objectSchema) => objectSchema;
10
+ const createCanvasObject = (objectSchema) => objectSchema;
11
+ exports.createCanvasObject = createCanvasObject;
11
12
  const CanvasObject = {
12
13
  group: {
13
14
  create: ({ objects, ...option }) => new fabric_1.fabric.Group(objects, option),
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -214,8 +214,8 @@ class AnimationHandler {
214
214
  update: (instance) => {
215
215
  if (type === 'flash') {
216
216
  // I don't know why it works. Magic code...
217
- warning_1.default(instance.animations[0], 'instance.animations[0] undefined.');
218
- warning_1.default(instance.animations[1], 'instance.animations[1] undefined.');
217
+ (0, warning_1.default)(instance.animations[0], 'instance.animations[0] undefined.');
218
+ (0, warning_1.default)(instance.animations[1], 'instance.animations[1] undefined.');
219
219
  const fill = instance.animations[0]?.currentValue;
220
220
  const stroke = instance.animations[1]?.currentValue;
221
221
  if (obj.type === 'svg') {
@@ -338,7 +338,7 @@ class AnimationHandler {
338
338
  console.warn('Not supported type.');
339
339
  return null;
340
340
  }
341
- return animejs_1.default(option);
341
+ return (0, animejs_1.default)(option);
342
342
  };
343
343
  this.handler = handler;
344
344
  }
@@ -11,7 +11,7 @@ class ContextmenuHandler {
11
11
  * Show context menu
12
12
  *
13
13
  */
14
- this.show = debounce_1.default(async (e, target) => {
14
+ this.show = (0, debounce_1.default)(async (e, target) => {
15
15
  const { onContext } = this.handler;
16
16
  while (this.contextmenuEl.hasChildNodes()) {
17
17
  this.contextmenuEl.removeChild(this.contextmenuEl.firstChild);
@@ -34,7 +34,7 @@ class ContextmenuHandler {
34
34
  * Hide context menu
35
35
  *
36
36
  */
37
- this.hide = debounce_1.default(() => {
37
+ this.hide = (0, debounce_1.default)(() => {
38
38
  if (this.contextmenuEl) {
39
39
  this.contextmenuEl.classList.add('contextmenu-hidden');
40
40
  }
@@ -47,7 +47,7 @@ class DrawingHandler {
47
47
  hoverCursor: 'pointer',
48
48
  });
49
49
  circle.set({
50
- id: uuidv4_1.uuid(),
50
+ id: (0, uuidv4_1.uuid)(),
51
51
  });
52
52
  if (!this.handler.pointArray.length) {
53
53
  circle.set({
@@ -114,7 +114,7 @@ class DrawingHandler {
114
114
  },
115
115
  generate: (pointArray) => {
116
116
  const points = [];
117
- const id = uuidv4_1.uuid();
117
+ const id = (0, uuidv4_1.uuid)();
118
118
  pointArray.forEach(point => {
119
119
  points.push({
120
120
  x: point.left,
@@ -144,6 +144,52 @@ class DrawingHandler {
144
144
  this.handler.activeShape = null;
145
145
  this.handler.interactionHandler.selection();
146
146
  },
147
+ // TODO... polygon resize
148
+ // createResize: (target, points) => {
149
+ // points.forEach((point, index) => {
150
+ // const { x, y } = point;
151
+ // const circle = new fabric.Circle({
152
+ // name: index,
153
+ // radius: 3,
154
+ // fill: '#ffffff',
155
+ // stroke: '#333333',
156
+ // strokeWidth: 0.5,
157
+ // left: x,
158
+ // top: y,
159
+ // hasBorders: false,
160
+ // hasControls: false,
161
+ // originX: 'center',
162
+ // originY: 'center',
163
+ // hoverCursor: 'pointer',
164
+ // parentId: target.id,
165
+ // });
166
+ // this.handler.pointArray.push(circle);
167
+ // });
168
+ // const group = [target].concat(this.pointArray);
169
+ // this.handler.canvas.add(new fabric.Group(group, { type: 'polygon', id: uuid() }));
170
+ // },
171
+ // removeResize: () => {
172
+ // if (this.handler.pointArray) {
173
+ // this.handler.pointArray.forEach((point) => {
174
+ // this.handler.canvas.remove(point);
175
+ // });
176
+ // this.handler.pointArray = [];
177
+ // }
178
+ // },
179
+ // movingResize: (target, e) => {
180
+ // const points = target.diffPoints || target.points;
181
+ // const diffPoints = [];
182
+ // points.forEach((point) => {
183
+ // diffPoints.push({
184
+ // x: point.x + e.movementX,
185
+ // y: point.y + e.movementY,
186
+ // });
187
+ // });
188
+ // target.set({
189
+ // diffPoints,
190
+ // });
191
+ // this.handler.canvas.renderAll();
192
+ // },
147
193
  };
148
194
  this.line = {
149
195
  init: () => {
@@ -206,7 +252,7 @@ class DrawingHandler {
206
252
  const { absolutePointer } = opt;
207
253
  const { x, y } = absolutePointer;
208
254
  let points = [];
209
- const id = uuidv4_1.uuid();
255
+ const id = (0, uuidv4_1.uuid)();
210
256
  this.handler.pointArray.forEach(point => {
211
257
  points = points.concat(point.left, point.top, x, y);
212
258
  this.handler.canvas.remove(point);
@@ -294,7 +340,7 @@ class DrawingHandler {
294
340
  });
295
341
  this.handler.canvas.remove(this.handler.activeLine);
296
342
  const option = {
297
- id: uuidv4_1.uuid(),
343
+ id: (0, uuidv4_1.uuid)(),
298
344
  points,
299
345
  type: 'arrow',
300
346
  stroke: 'rgba(0, 0, 0, 1)',
@@ -4,8 +4,8 @@ import { VideoObject } from '../objects/Video';
4
4
  import { ChartObject } from '../objects/Chart';
5
5
  import { IframeObject } from '../objects/Iframe';
6
6
  import { ElementObject } from '../objects/Element';
7
- export declare type ElementType = 'container' | 'script' | 'style';
8
- export declare type ElementObjectType = VideoObject | ChartObject | IframeObject | ElementObject;
7
+ export type ElementType = 'container' | 'script' | 'style';
8
+ export type ElementObjectType = VideoObject | ChartObject | IframeObject | ElementObject;
9
9
  export interface ElementCode {
10
10
  html?: string;
11
11
  css?: string;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
+ /// <reference types="animejs" />
2
3
  import { fabric } from 'fabric';
3
4
  import { AlignmentHandler, AnimationHandler, ChartHandler, ContextmenuHandler, CropHandler, CustomHandler, DrawingHandler, ElementHandler, EventHandler, GridHandler, GuidelineHandler, ImageHandler, InteractionHandler, LinkHandler, NodeHandler, PortHandler, ShortcutHandler, TooltipHandler, TransactionHandler, WorkareaHandler, ZoomHandler } from '.';
5
+ import { SvgObject } from '../objects/Svg';
4
6
  import { CanvasOption, FabricCanvas, FabricGroup, FabricImage, FabricObject, FabricObjectOption, FabricObjects, GridOption, GuidelineOption, InteractionMode, KeyEvent, WorkareaObject, WorkareaOption } from '../utils';
5
7
  import { TransactionEvent } from './TransactionHandler';
6
8
  export interface HandlerCallback {
@@ -169,7 +171,7 @@ export interface HandlerOption {
169
171
  };
170
172
  [key: string]: any;
171
173
  }
172
- export declare type HandlerOptions = HandlerOption & HandlerCallback;
174
+ export type HandlerOptions = HandlerOption & HandlerCallback;
173
175
  /**
174
176
  * Main handler for Canvas
175
177
  * @class Handler
@@ -324,16 +326,59 @@ declare class Handler implements HandlerOptions {
324
326
  * Set the image
325
327
  * @param {FabricImage} obj
326
328
  * @param {(File | string)} [source]
329
+ * @param {boolean} [keepSize]
327
330
  * @returns
328
331
  */
329
- setImage: (obj: FabricImage, source?: File | string) => Promise<FabricImage>;
332
+ setImage: (obj: FabricImage, source?: File | string, keepSize?: boolean, options?: fabric.IImageOptions) => Promise<FabricImage>;
330
333
  /**
331
334
  * Set image by id
332
335
  * @param {string} id
333
336
  * @param {*} source
334
337
  * @returns
335
338
  */
336
- setImageById: (id: string, source: any) => Promise<FabricImage>;
339
+ setImageById: (id: string, source: any, keepSize?: boolean) => Promise<fabric.Object & fabric.IObjectOptions & {
340
+ [key: string]: any;
341
+ id?: string;
342
+ parentId?: string;
343
+ originOpacity?: number;
344
+ originTop?: number;
345
+ originLeft?: number;
346
+ originScaleX?: number;
347
+ originScaleY?: number;
348
+ originAngle?: number;
349
+ originFill?: string | fabric.Pattern | fabric.Gradient;
350
+ originStroke?: string;
351
+ originRotation?: number;
352
+ editable?: boolean;
353
+ superType?: string;
354
+ description?: string;
355
+ animation?: import("../utils").AnimationProperty;
356
+ anime?: import("animejs").AnimeInstance;
357
+ tooltip?: import("../utils").TooltipProperty;
358
+ link?: import("../utils").LinkProperty;
359
+ animating?: boolean;
360
+ class?: string;
361
+ deletable?: boolean;
362
+ dblclick?: boolean;
363
+ cloneable?: boolean;
364
+ locked?: boolean;
365
+ rotation?: number;
366
+ clickable?: boolean;
367
+ } & fabric.Image & {
368
+ src?: string;
369
+ file?: File;
370
+ filters?: import("./ImageHandler").IFilter[];
371
+ _element?: any;
372
+ }>;
373
+ /**
374
+ * Set Svg
375
+ *
376
+ * @param {SvgObject} obj
377
+ * @param {(File | string)} [source]
378
+ * @param {boolean} [setSvg]
379
+ * @param {boolean} [keepSize]
380
+ */
381
+ setSvg: (obj: SvgObject, source?: File | string, isPath?: boolean, keepSize?: boolean) => Promise<SvgObject>;
337
382
  /**
338
383
  * Set visible
339
384
  * @param {boolean} [visible]
@@ -331,15 +331,25 @@ class Handler {
331
331
  * Set the image
332
332
  * @param {FabricImage} obj
333
333
  * @param {(File | string)} [source]
334
+ * @param {boolean} [keepSize]
334
335
  * @returns
335
336
  */
336
- this.setImage = (obj, source) => {
337
+ this.setImage = (obj, source, keepSize, options) => {
338
+ const { height, scaleY } = obj;
339
+ const renderCallbaack = (imgObj, src) => {
340
+ if (keepSize) {
341
+ const scale = (height * scaleY) / imgObj.height;
342
+ imgObj.set({ scaleY: scale, scaleX: scale, src });
343
+ }
344
+ this.canvas.requestRenderAll();
345
+ };
337
346
  return new Promise(resolve => {
338
347
  if (!source) {
339
348
  obj.set('file', null);
340
349
  obj.set('src', null);
341
- resolve(obj.setSrc('./images/sample/transparentBg.png', () => this.canvas.renderAll(), {
350
+ resolve(obj.setSrc('./images/sample/transparentBg.png', (imgObj) => renderCallbaack(imgObj, null), {
342
351
  dirty: true,
352
+ ...options,
343
353
  }));
344
354
  }
345
355
  if (source instanceof File) {
@@ -347,8 +357,9 @@ class Handler {
347
357
  reader.onload = () => {
348
358
  obj.set('file', source);
349
359
  obj.set('src', null);
350
- resolve(obj.setSrc(reader.result, () => this.canvas.renderAll(), {
360
+ resolve(obj.setSrc(reader.result, (imgObj) => renderCallbaack(imgObj, reader.result), {
351
361
  dirty: true,
362
+ ...options,
352
363
  }));
353
364
  };
354
365
  reader.readAsDataURL(source);
@@ -356,9 +367,10 @@ class Handler {
356
367
  else {
357
368
  obj.set('file', null);
358
369
  obj.set('src', source);
359
- resolve(obj.setSrc(source, () => this.canvas.renderAll(), {
370
+ resolve(obj.setSrc(source, (imgObj) => renderCallbaack(imgObj, source), {
360
371
  dirty: true,
361
372
  crossOrigin: 'anonymous',
373
+ ...options,
362
374
  }));
363
375
  }
364
376
  });
@@ -369,9 +381,32 @@ class Handler {
369
381
  * @param {*} source
370
382
  * @returns
371
383
  */
372
- this.setImageById = (id, source) => {
384
+ this.setImageById = (id, source, keepSize) => {
373
385
  const findObject = this.findById(id);
374
- return Promise.resolve(this.setImage(findObject, source));
386
+ return Promise.resolve(this.setImage(findObject, source, keepSize));
387
+ };
388
+ /**
389
+ * Set Svg
390
+ *
391
+ * @param {SvgObject} obj
392
+ * @param {(File | string)} [source]
393
+ * @param {boolean} [setSvg]
394
+ * @param {boolean} [keepSize]
395
+ */
396
+ this.setSvg = (obj, source, isPath, keepSize) => {
397
+ return new Promise(resolve => {
398
+ if (!source) {
399
+ resolve(obj.loadSvg({ src: './images/sample/chiller.svg', loadType: 'file', keepSize }));
400
+ }
401
+ if (source instanceof File) {
402
+ const reader = new FileReader();
403
+ reader.readAsDataURL(source);
404
+ reader.onload = () => resolve(obj.loadSvg({ src: reader.result, loadType: 'file', keepSize }));
405
+ }
406
+ else {
407
+ resolve(obj.loadSvg({ src: source, loadType: isPath ? 'svg' : 'file', keepSize }));
408
+ }
409
+ });
375
410
  };
376
411
  /**
377
412
  * Set visible
@@ -682,7 +717,7 @@ class Handler {
682
717
  const activeSelection = clonedObj;
683
718
  activeSelection.canvas = this.canvas;
684
719
  activeSelection.forEachObject((obj) => {
685
- obj.set('id', uuidv4_1.uuid());
720
+ obj.set('id', (0, uuidv4_1.uuid)());
686
721
  if (obj.superType === 'node') {
687
722
  obj.set('shadow', {
688
723
  color: obj.stroke,
@@ -701,7 +736,7 @@ class Handler {
701
736
  }
702
737
  else {
703
738
  if (activeObject.id === clonedObj.id) {
704
- clonedObj.set('id', uuidv4_1.uuid());
739
+ clonedObj.set('id', (0, uuidv4_1.uuid)());
705
740
  }
706
741
  if (clonedObj.superType === 'node') {
707
742
  clonedObj.set('shadow', {
@@ -738,7 +773,7 @@ class Handler {
738
773
  cloned.set({
739
774
  left: cloned.left + grid,
740
775
  top: cloned.top + grid,
741
- id: uuidv4_1.uuid(),
776
+ id: (0, uuidv4_1.uuid)(),
742
777
  evented: true,
743
778
  });
744
779
  this.canvas.add(cloned);
@@ -976,13 +1011,13 @@ class Handler {
976
1011
  clonedObj.set({
977
1012
  left: clonedObj.left + padding,
978
1013
  top: clonedObj.top + padding,
979
- id: isCut ? clipboard.id : uuidv4_1.uuid(),
1014
+ id: isCut ? clipboard.id : (0, uuidv4_1.uuid)(),
980
1015
  evented: true,
981
1016
  });
982
1017
  if (clonedObj.type === 'activeSelection') {
983
1018
  clonedObj.canvas = this.canvas;
984
1019
  clonedObj.forEachObject((obj) => {
985
- obj.set('id', isCut ? obj.id : uuidv4_1.uuid());
1020
+ obj.set('id', isCut ? obj.id : (0, uuidv4_1.uuid)());
986
1021
  this.canvas.add(obj);
987
1022
  if (obj.dblclick) {
988
1023
  obj.on('mousedblclick', this.eventHandler.object.mousedblclick);
@@ -1046,7 +1081,7 @@ class Handler {
1046
1081
  return false;
1047
1082
  });
1048
1083
  if (!exist) {
1049
- warning_1.default(true, 'Not found object by id.');
1084
+ (0, warning_1.default)(true, 'Not found object by id.');
1050
1085
  return null;
1051
1086
  }
1052
1087
  return findObject;
@@ -1252,7 +1287,7 @@ class Handler {
1252
1287
  obj.top += diffTop;
1253
1288
  }
1254
1289
  if (obj.superType === 'element') {
1255
- obj.id = uuidv4_1.uuid();
1290
+ obj.id = (0, uuidv4_1.uuid)();
1256
1291
  }
1257
1292
  this.add(obj, false, true);
1258
1293
  this.canvas.renderAll();
@@ -1281,7 +1316,7 @@ class Handler {
1281
1316
  }
1282
1317
  const group = activeObject.toGroup();
1283
1318
  group.set({
1284
- id: uuidv4_1.uuid(),
1319
+ id: (0, uuidv4_1.uuid)(),
1285
1320
  name: 'New group',
1286
1321
  type: 'group',
1287
1322
  ...this.objectOption,
@@ -1626,7 +1661,7 @@ class Handler {
1626
1661
  * @param {string[]} propertiesToInclude
1627
1662
  */
1628
1663
  this.setPropertiesToInclude = (propertiesToInclude) => {
1629
- this.propertiesToInclude = lodash_1.union(propertiesToInclude, this.propertiesToInclude);
1664
+ this.propertiesToInclude = (0, lodash_1.union)(propertiesToInclude, this.propertiesToInclude);
1630
1665
  };
1631
1666
  /**
1632
1667
  * Register custom handler
@@ -1,6 +1,6 @@
1
1
  import { fabric } from 'fabric';
2
2
  import Handler from './Handler';
3
- export declare type GrayscaleModeType = 'average' | 'luminosity' | 'lightness';
3
+ export type GrayscaleModeType = 'average' | 'luminosity' | 'lightness';
4
4
  export interface RemoveColorFilter {
5
5
  color?: string;
6
6
  distance?: number;
@@ -23,7 +23,7 @@ export interface BlendImageFilter {
23
23
  export interface HueRotationFilter {
24
24
  rotation?: number;
25
25
  }
26
- export declare type ResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';
26
+ export type ResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';
27
27
  export interface ResizeFilter {
28
28
  resizeType?: ResizeType;
29
29
  scaleX?: number;
@@ -63,7 +63,7 @@ export interface RemoveWhiteFilter {
63
63
  /** @default 20 */
64
64
  distance?: number;
65
65
  }
66
- export declare type ValuesOf<T extends any[]> = T[number];
66
+ export type ValuesOf<T extends any[]> = T[number];
67
67
  export interface IFilter {
68
68
  type: typeof FILTER_TYPES[number];
69
69
  [key: string]: any;
@@ -35,7 +35,8 @@ exports.FILTER_TYPES = [
35
35
  'multiply',
36
36
  'sepia2',
37
37
  ];
38
- exports.capitalize = (str) => (str ? str.charAt(0).toUpperCase() + str.slice(1) : false);
38
+ const capitalize = (str) => (str ? str.charAt(0).toUpperCase() + str.slice(1) : false);
39
+ exports.capitalize = capitalize;
39
40
  const SHARPEN_MATRIX = [0, -1, 0, -1, 5, -1, 0, -1, 0];
40
41
  const EMBOSS_MATRIX = [1, 1, 1, 1, 0.7, -1, -1, -1, -1];
41
42
  /**
@@ -143,10 +144,10 @@ class ImageHandler {
143
144
  this.createFilters = (filters) => {
144
145
  return filters.reduce((prev, filter) => {
145
146
  let type = filter.type;
146
- if (type.toLowerCase() === 'convolute' && isEqual_1.default(filter.matrix, SHARPEN_MATRIX)) {
147
+ if (type.toLowerCase() === 'convolute' && (0, isEqual_1.default)(filter.matrix, SHARPEN_MATRIX)) {
147
148
  type = 'sharpen';
148
149
  }
149
- else if (type.toLowerCase() === 'convolute' && isEqual_1.default(filter.matrix, EMBOSS_MATRIX)) {
150
+ else if (type.toLowerCase() === 'convolute' && (0, isEqual_1.default)(filter.matrix, EMBOSS_MATRIX)) {
150
151
  type = 'emboss';
151
152
  }
152
153
  const findIndex = exports.FILTER_TYPES.findIndex(filterType => type.toLowerCase() === filterType);
@@ -1,6 +1,6 @@
1
1
  import { FabricObject, InteractionMode } from '../utils';
2
2
  import Handler from './Handler';
3
- declare type IReturnType = {
3
+ type IReturnType = {
4
4
  selectable?: boolean;
5
5
  evented?: boolean;
6
6
  } | boolean;
@@ -67,7 +67,7 @@ class LinkHandler {
67
67
  */
68
68
  this.generate = (port) => {
69
69
  if (!port) {
70
- warning_1.default(!port, 'Does not exist target port.');
70
+ (0, warning_1.default)(!port, 'Does not exist target port.');
71
71
  return;
72
72
  }
73
73
  if (this.isDuplicate(port)) {
@@ -209,7 +209,7 @@ class LinkHandler {
209
209
  * @returns
210
210
  */
211
211
  this.isConnected = (port) => {
212
- warning_1.default(port.enabled, 'A connected node already exists.');
212
+ (0, warning_1.default)(port.enabled, 'A connected node already exists.');
213
213
  return !port.enabled;
214
214
  };
215
215
  /**
@@ -219,7 +219,7 @@ class LinkHandler {
219
219
  */
220
220
  this.isSameNode = (port) => {
221
221
  const validate = port.nodeId === this.handler.activeLine.fromNode.id;
222
- warning_1.default(!validate, 'Cannot select the same node.');
222
+ (0, warning_1.default)(!validate, 'Cannot select the same node.');
223
223
  return validate;
224
224
  };
225
225
  /**
@@ -229,7 +229,7 @@ class LinkHandler {
229
229
  */
230
230
  this.isDuplicate = (port) => {
231
231
  const validate = port.links.some(link => link.fromNode.id === this.handler.activeLine.fromNode.id);
232
- warning_1.default(!validate, 'Duplicate connections cannot be made.');
232
+ (0, warning_1.default)(!validate, 'Duplicate connections cannot be made.');
233
233
  return validate;
234
234
  };
235
235
  /**
@@ -238,7 +238,7 @@ class LinkHandler {
238
238
  */
239
239
  this.isDrawing = () => {
240
240
  const validate = this.handler.interactionMode === 'link' && this.handler.activeLine;
241
- warning_1.default(!validate, 'Already drawing links.');
241
+ (0, warning_1.default)(!validate, 'Already drawing links.');
242
242
  return validate;
243
243
  };
244
244
  this.handler = handler;
@@ -12,7 +12,7 @@ class TooltipHandler {
12
12
  *
13
13
  * @param {FabricObject} [target]
14
14
  */
15
- this.show = debounce_1.default(async (target) => {
15
+ this.show = (0, debounce_1.default)(async (target) => {
16
16
  if (target.tooltip && target.tooltip.enabled) {
17
17
  while (this.tooltipEl.hasChildNodes()) {
18
18
  this.tooltipEl.removeChild(this.tooltipEl.firstChild);
@@ -55,7 +55,7 @@ class TooltipHandler {
55
55
  * Hide tooltip
56
56
  * @param {fabric.Object} [_target]
57
57
  */
58
- this.hide = debounce_1.default((_target) => {
58
+ this.hide = (0, debounce_1.default)((_target) => {
59
59
  this.handler.target = null;
60
60
  if (this.tooltipEl) {
61
61
  this.tooltipEl.classList.add('tooltip-hidden');
@@ -1,7 +1,7 @@
1
1
  /// <reference types="lodash" />
2
2
  import { FabricObject } from '../utils';
3
3
  import Handler from './Handler';
4
- export declare type TransactionType = 'add' | 'remove' | 'modified' | 'moved' | 'scaled' | 'rotated' | 'skewed' | 'group' | 'ungroup' | 'paste' | 'bringForward' | 'bringToFront' | 'sendBackwards' | 'sendToBack' | 'redo' | 'undo';
4
+ export type TransactionType = 'add' | 'remove' | 'modified' | 'moved' | 'scaled' | 'rotated' | 'skewed' | 'group' | 'ungroup' | 'paste' | 'bringForward' | 'bringToFront' | 'sendBackwards' | 'sendToBack' | 'redo' | 'undo';
5
5
  export interface TransactionTransform {
6
6
  scaleX?: number;
7
7
  scaleY?: number;
@@ -61,7 +61,7 @@ class TransactionHandler {
61
61
  * Undo transaction
62
62
  *
63
63
  */
64
- this.undo = throttle_1.default(() => {
64
+ this.undo = (0, throttle_1.default)(() => {
65
65
  const undo = this.undos.pop();
66
66
  if (!undo) {
67
67
  return;
@@ -76,7 +76,7 @@ class TransactionHandler {
76
76
  * Redo transaction
77
77
  *
78
78
  */
79
- this.redo = throttle_1.default(() => {
79
+ this.redo = (0, throttle_1.default)(() => {
80
80
  const redo = this.redos.pop();
81
81
  if (!redo) {
82
82
  return;