mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-16 05:50:03 +02:00
feat: fit text to bound container
This commit is contained in:
@@ -366,15 +366,14 @@ export const adjustBoundTextSize = (
|
||||
container: ExcalidrawTextContainer,
|
||||
boundText: ExcalidrawTextElementWithContainer,
|
||||
scene: Scene,
|
||||
wrapTextFirst = true,
|
||||
) => {
|
||||
const maxWidth = getBoundTextMaxWidth(container, boundText);
|
||||
const maxHeight = getBoundTextMaxHeight(container, boundText);
|
||||
|
||||
const wrappedText = wrapText(
|
||||
boundText.text,
|
||||
getFontString(boundText),
|
||||
maxWidth,
|
||||
);
|
||||
const wrappedText = wrapTextFirst
|
||||
? wrapText(boundText.text, getFontString(boundText), maxWidth)
|
||||
: boundText.originalText;
|
||||
|
||||
let metrics = measureText(
|
||||
wrappedText,
|
||||
|
@@ -62,6 +62,7 @@ import type {
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import type { MarkOptional } from "@excalidraw/common/utility-types";
|
||||
import { adjustBoundTextSize } from "../components/ConvertElementTypePopup";
|
||||
|
||||
export type ValidLinearElement = {
|
||||
type: "arrow" | "line";
|
||||
@@ -238,7 +239,7 @@ const bindTextToContainer = (
|
||||
}),
|
||||
});
|
||||
|
||||
redrawTextBoundingBox(textElement, container, scene);
|
||||
adjustBoundTextSize(container as any, textElement as any, scene, false);
|
||||
|
||||
return [container, textElement] as const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user