onInput
This commit is contained in:
parent
da06e8ad27
commit
cfb9f8d8c7
@ -350,7 +350,26 @@ export const textWysiwyg = ({
|
|||||||
overflowWrap: "break-word",
|
overflowWrap: "break-word",
|
||||||
boxSizing: "content-box",
|
boxSizing: "content-box",
|
||||||
});
|
});
|
||||||
|
const onEditableInput = () => {
|
||||||
|
const updatedTextElement = Scene.getScene(element)?.getElement(
|
||||||
|
id,
|
||||||
|
) as ExcalidrawTextElement;
|
||||||
|
const font = getFontString(updatedTextElement);
|
||||||
|
if (isBoundToContainer(element)) {
|
||||||
|
const container = getContainerElement(element);
|
||||||
|
const wrappedText = wrapText(
|
||||||
|
normalizeText(editable.value),
|
||||||
|
font,
|
||||||
|
getMaxContainerWidth(container!),
|
||||||
|
);
|
||||||
|
const { width, height } = measureText(wrappedText, font);
|
||||||
|
editable.style.width = `${width}px`;
|
||||||
|
editable.style.height = `${height}px`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
updateWysiwygStyle();
|
updateWysiwygStyle();
|
||||||
|
onEditableInput();
|
||||||
|
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
editable.onpaste = async (event) => {
|
editable.onpaste = async (event) => {
|
||||||
@ -380,21 +399,7 @@ export const textWysiwyg = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
editable.oninput = () => {
|
editable.oninput = () => {
|
||||||
const updatedTextElement = Scene.getScene(element)?.getElement(
|
onEditableInput();
|
||||||
id,
|
|
||||||
) as ExcalidrawTextElement;
|
|
||||||
const font = getFontString(updatedTextElement);
|
|
||||||
if (isBoundToContainer(element)) {
|
|
||||||
const container = getContainerElement(element);
|
|
||||||
const wrappedText = wrapText(
|
|
||||||
normalizeText(editable.value),
|
|
||||||
font,
|
|
||||||
getMaxContainerWidth(container!),
|
|
||||||
);
|
|
||||||
const { width, height } = measureText(wrappedText, font);
|
|
||||||
editable.style.width = `${width}px`;
|
|
||||||
editable.style.height = `${height}px`;
|
|
||||||
}
|
|
||||||
onChange(normalizeText(editable.value));
|
onChange(normalizeText(editable.value));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user