feat: wrap long text when pasting (#8026)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Ryan Di 2024-05-21 22:56:09 +08:00 committed by GitHub
parent eddbe55f50
commit c540bd68aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 11 deletions

View file

@ -215,6 +215,7 @@ const getTextElementPositionOffsets = (
export const newTextElement = (
opts: {
text: string;
originalText?: string;
fontSize?: number;
fontFamily?: FontFamilyValues;
textAlign?: TextAlign;
@ -222,6 +223,7 @@ export const newTextElement = (
containerId?: ExcalidrawTextContainer["id"] | null;
lineHeight?: ExcalidrawTextElement["lineHeight"];
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
autoResize?: ExcalidrawTextElement["autoResize"];
} & ElementConstructorOpts,
): NonDeleted<ExcalidrawTextElement> => {
const fontFamily = opts.fontFamily || DEFAULT_FONT_FAMILY;
@ -252,8 +254,8 @@ export const newTextElement = (
width: metrics.width,
height: metrics.height,
containerId: opts.containerId || null,
originalText: text,
autoResize: true,
originalText: opts.originalText ?? text,
autoResize: opts.autoResize ?? true,
lineHeight,
};