|
@@ -65,7 +65,7 @@ export const redrawTextBoundingBox = (
|
|
boundTextUpdates.text = textElement.text;
|
|
boundTextUpdates.text = textElement.text;
|
|
|
|
|
|
if (container) {
|
|
if (container) {
|
|
- maxWidth = getMaxContainerWidth(container);
|
|
|
|
|
|
+ maxWidth = getBoundTextMaxWidth(container);
|
|
boundTextUpdates.text = wrapText(
|
|
boundTextUpdates.text = wrapText(
|
|
textElement.originalText,
|
|
textElement.originalText,
|
|
getFontString(textElement),
|
|
getFontString(textElement),
|
|
@@ -84,7 +84,10 @@ export const redrawTextBoundingBox = (
|
|
|
|
|
|
if (container) {
|
|
if (container) {
|
|
const containerDims = getContainerDims(container);
|
|
const containerDims = getContainerDims(container);
|
|
- const maxContainerHeight = getMaxContainerHeight(container);
|
|
|
|
|
|
+ const maxContainerHeight = getBoundTextMaxHeight(
|
|
|
|
+ container,
|
|
|
|
+ textElement as ExcalidrawTextElementWithContainer,
|
|
|
|
+ );
|
|
|
|
|
|
let nextHeight = containerDims.height;
|
|
let nextHeight = containerDims.height;
|
|
if (metrics.height > maxContainerHeight) {
|
|
if (metrics.height > maxContainerHeight) {
|
|
@@ -173,8 +176,11 @@ export const handleBindTextResize = (
|
|
let nextHeight = textElement.height;
|
|
let nextHeight = textElement.height;
|
|
let nextWidth = textElement.width;
|
|
let nextWidth = textElement.width;
|
|
const containerDims = getContainerDims(container);
|
|
const containerDims = getContainerDims(container);
|
|
- const maxWidth = getMaxContainerWidth(container);
|
|
|
|
- const maxHeight = getMaxContainerHeight(container);
|
|
|
|
|
|
+ const maxWidth = getBoundTextMaxWidth(container);
|
|
|
|
+ const maxHeight = getBoundTextMaxHeight(
|
|
|
|
+ container,
|
|
|
|
+ textElement as ExcalidrawTextElementWithContainer,
|
|
|
|
+ );
|
|
let containerHeight = containerDims.height;
|
|
let containerHeight = containerDims.height;
|
|
let nextBaseLine = textElement.baseline;
|
|
let nextBaseLine = textElement.baseline;
|
|
if (transformHandleType !== "n" && transformHandleType !== "s") {
|
|
if (transformHandleType !== "n" && transformHandleType !== "s") {
|
|
@@ -246,8 +252,8 @@ export const computeBoundTextPosition = (
|
|
);
|
|
);
|
|
}
|
|
}
|
|
const containerCoords = getContainerCoords(container);
|
|
const containerCoords = getContainerCoords(container);
|
|
- const maxContainerHeight = getMaxContainerHeight(container);
|
|
|
|
- const maxContainerWidth = getMaxContainerWidth(container);
|
|
|
|
|
|
+ const maxContainerHeight = getBoundTextMaxHeight(container, boundTextElement);
|
|
|
|
+ const maxContainerWidth = getBoundTextMaxWidth(container);
|
|
|
|
|
|
let x;
|
|
let x;
|
|
let y;
|
|
let y;
|
|
@@ -880,18 +886,10 @@ export const computeContainerDimensionForBoundText = (
|
|
return dimension + padding;
|
|
return dimension + padding;
|
|
};
|
|
};
|
|
|
|
|
|
-export const getMaxContainerWidth = (container: ExcalidrawElement) => {
|
|
|
|
|
|
+export const getBoundTextMaxWidth = (container: ExcalidrawElement) => {
|
|
const width = getContainerDims(container).width;
|
|
const width = getContainerDims(container).width;
|
|
if (isArrowElement(container)) {
|
|
if (isArrowElement(container)) {
|
|
- const containerWidth = width - BOUND_TEXT_PADDING * 8 * 2;
|
|
|
|
- if (containerWidth <= 0) {
|
|
|
|
- const boundText = getBoundTextElement(container);
|
|
|
|
- if (boundText) {
|
|
|
|
- return boundText.width;
|
|
|
|
- }
|
|
|
|
- return BOUND_TEXT_PADDING * 8 * 2;
|
|
|
|
- }
|
|
|
|
- return containerWidth;
|
|
|
|
|
|
+ return width - BOUND_TEXT_PADDING * 8 * 2;
|
|
}
|
|
}
|
|
|
|
|
|
if (container.type === "ellipse") {
|
|
if (container.type === "ellipse") {
|
|
@@ -908,16 +906,15 @@ export const getMaxContainerWidth = (container: ExcalidrawElement) => {
|
|
return width - BOUND_TEXT_PADDING * 2;
|
|
return width - BOUND_TEXT_PADDING * 2;
|
|
};
|
|
};
|
|
|
|
|
|
-export const getMaxContainerHeight = (container: ExcalidrawElement) => {
|
|
|
|
|
|
+export const getBoundTextMaxHeight = (
|
|
|
|
+ container: ExcalidrawElement,
|
|
|
|
+ boundTextElement: ExcalidrawTextElementWithContainer,
|
|
|
|
+) => {
|
|
const height = getContainerDims(container).height;
|
|
const height = getContainerDims(container).height;
|
|
if (isArrowElement(container)) {
|
|
if (isArrowElement(container)) {
|
|
const containerHeight = height - BOUND_TEXT_PADDING * 8 * 2;
|
|
const containerHeight = height - BOUND_TEXT_PADDING * 8 * 2;
|
|
if (containerHeight <= 0) {
|
|
if (containerHeight <= 0) {
|
|
- const boundText = getBoundTextElement(container);
|
|
|
|
- if (boundText) {
|
|
|
|
- return boundText.height;
|
|
|
|
- }
|
|
|
|
- return BOUND_TEXT_PADDING * 8 * 2;
|
|
|
|
|
|
+ return boundTextElement.height;
|
|
}
|
|
}
|
|
return height;
|
|
return height;
|
|
}
|
|
}
|