fix: show text properties button states correctly for bounded text (#4542)

* fix: show text properties button states correctly for bounded text

* rename
This commit is contained in:
Aakansha Doshi
2022-01-05 17:58:03 +05:30
committed by GitHub
parent cec92c1d17
commit 5f1616f2c5
2 changed files with 45 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import {
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawTextElement,
ExcalidrawTextElementWithContainer,
FontString,
NonDeletedExcalidrawElement,
} from "./types";
@ -408,3 +409,16 @@ export const getApproxCharsToFitInWidth = (font: FontString, width: number) => {
export const getBoundTextElementId = (container: ExcalidrawElement | null) => {
return container?.boundElements?.filter((ele) => ele.type === "text")[0]?.id;
};
export const getBoundTextElement = (element: ExcalidrawElement | null) => {
if (!element) {
return null;
}
const boundTextElementId = getBoundTextElementId(element);
if (boundTextElementId) {
return Scene.getScene(element)!.getElement(
boundTextElementId,
) as ExcalidrawTextElementWithContainer;
}
return null;
};