mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: set height correctly when text properties updated while editing in container until first submit (#4469)
* fix: set height correctly when text properties updated while editing in container * rename PADDING to BOUND_TEXT_PADDING
This commit is contained in:
parent
bf2bca221e
commit
ef62390841
6 changed files with 62 additions and 31 deletions
|
@ -61,6 +61,7 @@ import {
|
|||
isSomeElementSelected,
|
||||
} from "../scene";
|
||||
import { hasStrokeColor } from "../scene/comparisons";
|
||||
import Scene from "../scene/Scene";
|
||||
import { register } from "./register";
|
||||
|
||||
const changeProperty = (
|
||||
|
@ -431,7 +432,11 @@ export const actionChangeFontSize = register({
|
|||
const element: ExcalidrawTextElement = newElementWith(el, {
|
||||
fontSize: value,
|
||||
});
|
||||
redrawTextBoundingBox(element);
|
||||
let container = null;
|
||||
if (el.containerId) {
|
||||
container = Scene.getScene(el)!.getElement(el.containerId);
|
||||
}
|
||||
redrawTextBoundingBox(element, container);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -492,7 +497,11 @@ export const actionChangeFontFamily = register({
|
|||
const element: ExcalidrawTextElement = newElementWith(el, {
|
||||
fontFamily: value,
|
||||
});
|
||||
redrawTextBoundingBox(element);
|
||||
let container = null;
|
||||
if (el.containerId) {
|
||||
container = Scene.getScene(el)!.getElement(el.containerId);
|
||||
}
|
||||
redrawTextBoundingBox(element, container);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -556,7 +565,11 @@ export const actionChangeTextAlign = register({
|
|||
const element: ExcalidrawTextElement = newElementWith(el, {
|
||||
textAlign: value,
|
||||
});
|
||||
redrawTextBoundingBox(element);
|
||||
let container = null;
|
||||
if (el.containerId) {
|
||||
container = Scene.getScene(el)!.getElement(el.containerId);
|
||||
}
|
||||
redrawTextBoundingBox(element, container);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ import {
|
|||
DEFAULT_FONT_FAMILY,
|
||||
DEFAULT_TEXT_ALIGN,
|
||||
} from "../constants";
|
||||
import Scene from "../scene/Scene";
|
||||
import { isBoundToContainer } from "../element/typeChecks";
|
||||
import { ExcalidrawTextElement } from "../element/types";
|
||||
|
||||
// `copiedStyles` is exported only for tests.
|
||||
export let copiedStyles: string = "{}";
|
||||
|
@ -61,7 +64,14 @@ export const actionPasteStyles = register({
|
|||
fontFamily: pastedElement?.fontFamily || DEFAULT_FONT_FAMILY,
|
||||
textAlign: pastedElement?.textAlign || DEFAULT_TEXT_ALIGN,
|
||||
});
|
||||
redrawTextBoundingBox(newElement);
|
||||
let container = null;
|
||||
|
||||
if (isBoundToContainer(element)) {
|
||||
container = Scene.getScene(element)!.getElement(
|
||||
element.containerId,
|
||||
);
|
||||
}
|
||||
redrawTextBoundingBox(element as ExcalidrawTextElement, container);
|
||||
}
|
||||
return newElement;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue