From ee8fff8e8b8c4609da48aa6d6b3badee6151eff7 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 22 Mar 2023 14:55:51 +0530 Subject: [PATCH] rename getApproxMinLineWidth -> getApproxMinContainerWidth and getApproxMinLineHeight -> getApproxMinContainerHeight --- src/components/App.tsx | 8 ++++---- src/element/resizeElements.ts | 8 ++++---- src/element/textMeasurements.ts | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 39791a8af..26769e086 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -268,8 +268,8 @@ import { isValidTextContainer, } from "../element/textElement"; import { - getApproxMinLineHeight, - getApproxMinLineWidth, + getApproxMinContainerHeight, + getApproxMinContainerWidth, isMeasureTextSupported, getLineHeightInPx, getDefaultLineHeight, @@ -2624,11 +2624,11 @@ class App extends React.Component { fontSize, fontFamily, }; - const minWidth = getApproxMinLineWidth( + const minWidth = getApproxMinContainerWidth( getFontString(fontString), lineHeight, ); - const minHeight = getApproxMinLineHeight(fontSize, lineHeight); + const minHeight = getApproxMinContainerHeight(fontSize, lineHeight); const containerDims = getContainerDims(container); const newHeight = Math.max(containerDims.height, minHeight); const newWidth = Math.max(containerDims.width, minWidth); diff --git a/src/element/resizeElements.ts b/src/element/resizeElements.ts index 3d05a4746..6d60cc3f7 100644 --- a/src/element/resizeElements.ts +++ b/src/element/resizeElements.ts @@ -46,8 +46,8 @@ import { getBoundTextMaxWidth, } from "./textElement"; import { - getApproxMinLineHeight, - getApproxMinLineWidth, + getApproxMinContainerHeight, + getApproxMinContainerWidth, } from "./textMeasurements"; export const normalizeAngle = (angle: number): number => { if (angle >= 2 * Math.PI) { @@ -429,11 +429,11 @@ export const resizeSingleElement = ( } boundTextFontSize = nextFontSize; } else { - const minWidth = getApproxMinLineWidth( + const minWidth = getApproxMinContainerWidth( getFontString(boundTextElement), boundTextElement.lineHeight, ); - const minHeight = getApproxMinLineHeight( + const minHeight = getApproxMinContainerHeight( boundTextElement.fontSize, boundTextElement.lineHeight, ); diff --git a/src/element/textMeasurements.ts b/src/element/textMeasurements.ts index 30161a645..c9d3724bf 100644 --- a/src/element/textMeasurements.ts +++ b/src/element/textMeasurements.ts @@ -83,7 +83,7 @@ export const measureText = ( return { width, height }; }; -export const getApproxMinLineWidth = ( +export const getApproxMinContainerWidth = ( font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], ) => { @@ -97,8 +97,7 @@ export const getApproxMinLineWidth = ( return maxCharWidth + BOUND_TEXT_PADDING * 2; }; -// FIXME rename to getApproxMinContainerHeight -export const getApproxMinLineHeight = ( +export const getApproxMinContainerHeight = ( fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"], ) => {