fix: use word-break break-word only and update text editor height only when binded to container (#4410)
This commit is contained in:
parent
98b5c37e45
commit
ff1d7728a0
@ -6,7 +6,7 @@ import {
|
|||||||
getFontFamilyString,
|
getFontFamilyString,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import Scene from "../scene/Scene";
|
import Scene from "../scene/Scene";
|
||||||
import { isTextElement } from "./typeChecks";
|
import { isBoundToContainer, isTextElement } from "./typeChecks";
|
||||||
import { CLASSES, PADDING } from "../constants";
|
import { CLASSES, PADDING } from "../constants";
|
||||||
import {
|
import {
|
||||||
ExcalidrawBindableElement,
|
ExcalidrawBindableElement,
|
||||||
@ -225,8 +225,11 @@ export const textWysiwyg = ({
|
|||||||
editable.classList.add("excalidraw-wysiwyg");
|
editable.classList.add("excalidraw-wysiwyg");
|
||||||
|
|
||||||
let whiteSpace = "pre";
|
let whiteSpace = "pre";
|
||||||
if (isTextElement(element)) {
|
let wordBreak = "normal";
|
||||||
whiteSpace = element.containerId ? "pre-wrap" : "pre";
|
|
||||||
|
if (isBoundToContainer(element)) {
|
||||||
|
whiteSpace = "pre-wrap";
|
||||||
|
wordBreak = "break-word";
|
||||||
}
|
}
|
||||||
Object.assign(editable.style, {
|
Object.assign(editable.style, {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
@ -242,7 +245,7 @@ export const textWysiwyg = ({
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
// must be specified because in dark mode canvas creates a stacking context
|
// must be specified because in dark mode canvas creates a stacking context
|
||||||
zIndex: "var(--zIndex-wysiwyg)",
|
zIndex: "var(--zIndex-wysiwyg)",
|
||||||
wordBreak: "break-word",
|
wordBreak,
|
||||||
// prevent line wrapping (`whitespace: nowrap` doesn't work on FF)
|
// prevent line wrapping (`whitespace: nowrap` doesn't work on FF)
|
||||||
whiteSpace,
|
whiteSpace,
|
||||||
overflowWrap: "break-word",
|
overflowWrap: "break-word",
|
||||||
@ -251,8 +254,10 @@ export const textWysiwyg = ({
|
|||||||
|
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
editable.oninput = () => {
|
editable.oninput = () => {
|
||||||
editable.style.height = "auto";
|
if (isBoundToContainer(element)) {
|
||||||
editable.style.height = `${editable.scrollHeight}px`;
|
editable.style.height = "auto";
|
||||||
|
editable.style.height = `${editable.scrollHeight}px`;
|
||||||
|
}
|
||||||
onChange(normalizeText(editable.value));
|
onChange(normalizeText(editable.value));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user