Merge remote-tracking branch 'origin/master' into aakansha-baseline

This commit is contained in:
Aakansha Doshi
2023-03-29 14:16:22 +05:30
10 changed files with 463 additions and 49 deletions

View File

@@ -35,6 +35,7 @@ import {
getMaxContainerHeight,
getMaxContainerWidth,
measureBaseline,
computeContainerDimensionForBoundText,
} from "./textElement";
import {
actionDecreaseFontSize,
@@ -209,11 +210,12 @@ export const textWysiwyg = ({
// autogrow container height if text exceeds
if (!isArrowElement(container) && textElementHeight > maxHeight) {
const diff = Math.min(
textElementHeight - maxHeight,
element.lineHeight,
const targetContainerHeight = computeContainerDimensionForBoundText(
textElementHeight,
container.type,
);
mutateElement(container, { height: containerDims.height + diff });
mutateElement(container, { height: targetContainerHeight });
return;
} else if (
// autoshrink container height until original container height
@@ -222,11 +224,11 @@ export const textWysiwyg = ({
containerDims.height > originalContainerData.height &&
textElementHeight < maxHeight
) {
const diff = Math.min(
maxHeight - textElementHeight,
element.lineHeight,
const targetContainerHeight = computeContainerDimensionForBoundText(
textElementHeight,
container.type,
);
mutateElement(container, { height: containerDims.height - diff });
mutateElement(container, { height: targetContainerHeight });
}
// Start pushing text upward until a diff of 30px (padding)
// is reached