From cf5ddbb5f3fb7520af1a4081824e1428b7a9d1cc Mon Sep 17 00:00:00 2001 From: vikas Date: Thu, 30 Mar 2023 21:12:36 +0530 Subject: [PATCH] Fix Draw straight line will can not be copied (#734) --- apps/image-editor/createConfigVariable.js | 1 + apps/image-editor/src/js/component/cropper.js | 1 + apps/image-editor/src/js/extension/cropzone.js | 1 + apps/image-editor/src/js/graphics.js | 17 +++++++++-------- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/image-editor/createConfigVariable.js b/apps/image-editor/createConfigVariable.js index 872835a32..6f9c190ae 100644 --- a/apps/image-editor/createConfigVariable.js +++ b/apps/image-editor/createConfigVariable.js @@ -1,3 +1,4 @@ +/* eslint-disable no-sync */ const fs = require('fs'); const path = require('path'); const config = require(path.resolve(__dirname, 'tuidoc.config.json')); diff --git a/apps/image-editor/src/js/component/cropper.js b/apps/image-editor/src/js/component/cropper.js index d0469c226..25f1374aa 100644 --- a/apps/image-editor/src/js/component/cropper.js +++ b/apps/image-editor/src/js/component/cropper.js @@ -195,6 +195,7 @@ class Cropper extends Component { * @returns {{left: number, top: number, width: number, height: number}} * @private */ + // eslint-disable-next-line complexity _calcRectDimensionFromPoint(x, y, presetRatio = null) { const canvas = this.getCanvas(); const canvasWidth = canvas.getWidth(); diff --git a/apps/image-editor/src/js/extension/cropzone.js b/apps/image-editor/src/js/extension/cropzone.js index 37ebfa263..28847461d 100644 --- a/apps/image-editor/src/js/extension/cropzone.js +++ b/apps/image-editor/src/js/extension/cropzone.js @@ -369,6 +369,7 @@ const Cropzone = fabric.util.createClass( * @returns {{width: number, height: number}} * @private */ + // eslint-disable-next-line complexity adjustRatioCropzoneSize({ width, height, leftMaker, topMaker, maxWidth, maxHeight, scaleTo }) { width = maxWidth ? clamp(width, 1, maxWidth) : width; height = maxHeight ? clamp(height, 1, maxHeight) : height; diff --git a/apps/image-editor/src/js/graphics.js b/apps/image-editor/src/js/graphics.js index 3b65096e8..6baeaae82 100644 --- a/apps/image-editor/src/js/graphics.js +++ b/apps/image-editor/src/js/graphics.js @@ -1481,15 +1481,16 @@ class Graphics { * @private */ _copyFabricObject(targetObject) { - return new Promise((resolve) => { - targetObject.clone((cloned) => { - const shapeComp = this.getComponent(components.SHAPE); - if (isShape(cloned)) { - shapeComp.processForCopiedObject(cloned, targetObject); - } + // delete __fe_id so that new created object had not conflict and create new __fe_id for that + if (targetObject.__fe_id) delete targetObject.__fe_id; - resolve(cloned); - }); + return new Promise((resolve) => { + const cloned = fabric.util.object.clone(targetObject); + const shapeComp = this.getComponent(components.SHAPE); + if (isShape(cloned)) { + shapeComp.processForCopiedObject(cloned, targetObject); + } + resolve(cloned); }); }