Browse Source

rename getApproxMinLineWidth -> getApproxMinContainerWidth and getApproxMinLineHeight -> getApproxMinContainerHeight

Aakansha Doshi 2 years ago
parent
commit
ee8fff8e8b
3 changed files with 10 additions and 11 deletions
  1. 4 4
      src/components/App.tsx
  2. 4 4
      src/element/resizeElements.ts
  3. 2 3
      src/element/textMeasurements.ts

+ 4 - 4
src/components/App.tsx

@@ -268,8 +268,8 @@ import {
   isValidTextContainer,
   isValidTextContainer,
 } from "../element/textElement";
 } from "../element/textElement";
 import {
 import {
-  getApproxMinLineHeight,
-  getApproxMinLineWidth,
+  getApproxMinContainerHeight,
+  getApproxMinContainerWidth,
   isMeasureTextSupported,
   isMeasureTextSupported,
   getLineHeightInPx,
   getLineHeightInPx,
   getDefaultLineHeight,
   getDefaultLineHeight,
@@ -2624,11 +2624,11 @@ class App extends React.Component<AppProps, AppState> {
         fontSize,
         fontSize,
         fontFamily,
         fontFamily,
       };
       };
-      const minWidth = getApproxMinLineWidth(
+      const minWidth = getApproxMinContainerWidth(
         getFontString(fontString),
         getFontString(fontString),
         lineHeight,
         lineHeight,
       );
       );
-      const minHeight = getApproxMinLineHeight(fontSize, lineHeight);
+      const minHeight = getApproxMinContainerHeight(fontSize, lineHeight);
       const containerDims = getContainerDims(container);
       const containerDims = getContainerDims(container);
       const newHeight = Math.max(containerDims.height, minHeight);
       const newHeight = Math.max(containerDims.height, minHeight);
       const newWidth = Math.max(containerDims.width, minWidth);
       const newWidth = Math.max(containerDims.width, minWidth);

+ 4 - 4
src/element/resizeElements.ts

@@ -46,8 +46,8 @@ import {
   getBoundTextMaxWidth,
   getBoundTextMaxWidth,
 } from "./textElement";
 } from "./textElement";
 import {
 import {
-  getApproxMinLineHeight,
-  getApproxMinLineWidth,
+  getApproxMinContainerHeight,
+  getApproxMinContainerWidth,
 } from "./textMeasurements";
 } from "./textMeasurements";
 export const normalizeAngle = (angle: number): number => {
 export const normalizeAngle = (angle: number): number => {
   if (angle >= 2 * Math.PI) {
   if (angle >= 2 * Math.PI) {
@@ -429,11 +429,11 @@ export const resizeSingleElement = (
       }
       }
       boundTextFontSize = nextFontSize;
       boundTextFontSize = nextFontSize;
     } else {
     } else {
-      const minWidth = getApproxMinLineWidth(
+      const minWidth = getApproxMinContainerWidth(
         getFontString(boundTextElement),
         getFontString(boundTextElement),
         boundTextElement.lineHeight,
         boundTextElement.lineHeight,
       );
       );
-      const minHeight = getApproxMinLineHeight(
+      const minHeight = getApproxMinContainerHeight(
         boundTextElement.fontSize,
         boundTextElement.fontSize,
         boundTextElement.lineHeight,
         boundTextElement.lineHeight,
       );
       );

+ 2 - 3
src/element/textMeasurements.ts

@@ -83,7 +83,7 @@ export const measureText = (
   return { width, height };
   return { width, height };
 };
 };
 
 
-export const getApproxMinLineWidth = (
+export const getApproxMinContainerWidth = (
   font: FontString,
   font: FontString,
   lineHeight: ExcalidrawTextElement["lineHeight"],
   lineHeight: ExcalidrawTextElement["lineHeight"],
 ) => {
 ) => {
@@ -97,8 +97,7 @@ export const getApproxMinLineWidth = (
   return maxCharWidth + BOUND_TEXT_PADDING * 2;
   return maxCharWidth + BOUND_TEXT_PADDING * 2;
 };
 };
 
 
-// FIXME rename to getApproxMinContainerHeight
-export const getApproxMinLineHeight = (
+export const getApproxMinContainerHeight = (
   fontSize: ExcalidrawTextElement["fontSize"],
   fontSize: ExcalidrawTextElement["fontSize"],
   lineHeight: ExcalidrawTextElement["lineHeight"],
   lineHeight: ExcalidrawTextElement["lineHeight"],
 ) => {
 ) => {