Lexical: Added media resize support via drag handles

This commit is contained in:
Dan Brown
2024-09-08 13:37:13 +01:00
parent e5b6d28bca
commit bed2c29a33
8 changed files with 133 additions and 43 deletions

View File

@ -31,6 +31,22 @@ export function formatSizeValue(size: number | string, defaultSuffix: string = '
return size;
}
export function sizeToPixels(size: string): number {
if (/^-?\d+$/.test(size)) {
return Number(size);
}
if (/^-?\d+\.\d+$/.test(size)) {
return Math.round(Number(size));
}
if (/^-?\d+px\s*$/.test(size)) {
return Number(size.trim().replace('px', ''));
}
return 0;
}
export type StyleMap = Map<string, string>;
/**