From 63ce5b82d794af4abf3d579609e457cb30578b3c Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 28 Dec 2021 16:24:44 +0530 Subject: [PATCH] fix: pending review fixes for sticky notes (#4493) --- src/components/App.tsx | 3 +-- src/element/collision.ts | 3 +-- src/element/textElement.ts | 14 -------------- src/scene/comparisons.ts | 9 +-------- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 578ed717..a6f5ce91 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2101,10 +2101,9 @@ class App extends React.Component { const container = shouldBind || parentCenterPosition ? getElementContainingPosition( - this.scene.getElements(), + this.scene.getElements().filter((ele) => !isTextElement(ele)), sceneX, sceneY, - "text", ) : null; diff --git a/src/element/collision.ts b/src/element/collision.ts index 75d3613c..8f267ea5 100644 --- a/src/element/collision.ts +++ b/src/element/collision.ts @@ -46,8 +46,7 @@ const isElementDraggableFromInside = ( return true; } const isDraggableFromInside = - !isTransparent(element.backgroundColor) || - (isTransparent(element.backgroundColor) && hasBoundTextElement(element)); + !isTransparent(element.backgroundColor) || hasBoundTextElement(element); if (element.type === "line") { return isDraggableFromInside && isPathALoop(element.points); } diff --git a/src/element/textElement.ts b/src/element/textElement.ts index e4d98941..713f87ac 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -322,25 +322,11 @@ export const charWidth = (() => { return cachedCharWidth[font][ascii]; }; - const updateCache = (char: string, font: FontString) => { - const ascii = char.charCodeAt(0); - - if (!cachedCharWidth[font][ascii]) { - cachedCharWidth[font][ascii] = calculate(char, font); - } - }; - - const clearCacheforFont = (font: FontString) => { - cachedCharWidth[font] = []; - }; - const getCache = (font: FontString) => { return cachedCharWidth[font]; }; return { calculate, - updateCache, - clearCacheforFont, getCache, }; })(); diff --git a/src/scene/comparisons.ts b/src/scene/comparisons.ts index 30f33971..618f2966 100644 --- a/src/scene/comparisons.ts +++ b/src/scene/comparisons.ts @@ -75,7 +75,6 @@ export const getElementContainingPosition = ( elements: readonly ExcalidrawElement[], x: number, y: number, - excludedType?: ExcalidrawElement["type"], ) => { let hitElement = null; // We need to to hit testing from front (end of the array) to back (beginning of the array) @@ -84,13 +83,7 @@ export const getElementContainingPosition = ( continue; } const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[index]); - if ( - x1 < x && - x < x2 && - y1 < y && - y < y2 && - elements[index].type !== excludedType - ) { + if (x1 < x && x < x2 && y1 < y && y < y2) { hitElement = elements[index]; break; }