rename getContainerCoords -> computeBoundTextElementCoords
This commit is contained in:
parent
fefd377408
commit
83780b91d2
@ -2,7 +2,7 @@ import { BOUND_TEXT_PADDING } from "../constants";
|
||||
import { API } from "../tests/helpers/api";
|
||||
import {
|
||||
computeContainerHeightForBoundText,
|
||||
getContainerCoords,
|
||||
computeBoundTextElementCoords,
|
||||
getMaxContainerWidth,
|
||||
getMaxContainerHeight,
|
||||
wrapText,
|
||||
@ -177,7 +177,7 @@ break it now`,
|
||||
});
|
||||
|
||||
describe("Test measureText", () => {
|
||||
describe("Test getContainerCoords", () => {
|
||||
describe("Test computeBoundTextElementCoords", () => {
|
||||
const params = { width: 200, height: 100, x: 10, y: 20 };
|
||||
|
||||
it("should compute coords correctly when ellipse", () => {
|
||||
@ -185,7 +185,7 @@ describe("Test measureText", () => {
|
||||
type: "ellipse",
|
||||
...params,
|
||||
});
|
||||
expect(getContainerCoords(element)).toEqual({
|
||||
expect(computeBoundTextElementCoords(element)).toEqual({
|
||||
x: 44.2893218813452455,
|
||||
y: 39.64466094067262,
|
||||
});
|
||||
@ -196,7 +196,7 @@ describe("Test measureText", () => {
|
||||
type: "rectangle",
|
||||
...params,
|
||||
});
|
||||
expect(getContainerCoords(element)).toEqual({
|
||||
expect(computeBoundTextElementCoords(element)).toEqual({
|
||||
x: 15,
|
||||
y: 25,
|
||||
});
|
||||
@ -207,7 +207,7 @@ describe("Test measureText", () => {
|
||||
type: "diamond",
|
||||
...params,
|
||||
});
|
||||
expect(getContainerCoords(element)).toEqual({
|
||||
expect(computeBoundTextElementCoords(element)).toEqual({
|
||||
x: 65,
|
||||
y: 50,
|
||||
});
|
||||
|
@ -244,7 +244,7 @@ const computeBoundTextPosition = (
|
||||
container: ExcalidrawElement,
|
||||
boundTextElement: ExcalidrawTextElementWithContainer,
|
||||
) => {
|
||||
const containerCoords = getContainerCoords(container);
|
||||
const containerCoords = computeBoundTextElementCoords(container);
|
||||
const maxContainerHeight = getMaxContainerHeight(container);
|
||||
const maxContainerWidth = getMaxContainerWidth(container);
|
||||
|
||||
@ -614,7 +614,9 @@ export const getContainerCenter = (
|
||||
return { x: midSegmentMidpoint[0], y: midSegmentMidpoint[1] };
|
||||
};
|
||||
|
||||
export const getContainerCoords = (container: NonDeletedExcalidrawElement) => {
|
||||
export const computeBoundTextElementCoords = (
|
||||
container: NonDeletedExcalidrawElement,
|
||||
) => {
|
||||
let offsetX = BOUND_TEXT_PADDING;
|
||||
let offsetY = BOUND_TEXT_PADDING;
|
||||
|
||||
@ -810,9 +812,3 @@ export const getMaxContainerHeight = (container: ExcalidrawElement) => {
|
||||
}
|
||||
return height - BOUND_TEXT_PADDING * 2;
|
||||
};
|
||||
|
||||
// export const computeContainerCoordsFromBoundText = (
|
||||
// boundText: ExcalidrawTextElementWithContainer,
|
||||
// ) => {
|
||||
|
||||
// };
|
||||
|
@ -24,7 +24,7 @@ import { mutateElement } from "./mutateElement";
|
||||
import {
|
||||
getApproxLineHeight,
|
||||
getBoundTextElementId,
|
||||
getContainerCoords,
|
||||
computeBoundTextElementCoords,
|
||||
getContainerDims,
|
||||
getContainerElement,
|
||||
getTextElementAngle,
|
||||
@ -233,7 +233,7 @@ export const textWysiwyg = ({
|
||||
// Start pushing text upward until a diff of 30px (padding)
|
||||
// is reached
|
||||
else {
|
||||
const containerCoords = getContainerCoords(container);
|
||||
const containerCoords = computeBoundTextElementCoords(container);
|
||||
|
||||
// vertically center align the text
|
||||
if (verticalAlign === VERTICAL_ALIGN.MIDDLE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user