better math to position lines in between text

pull/3245/head
Mime Čuvalo 2024-04-03 21:28:27 +01:00
rodzic 01bc144250
commit 24fca167ad
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: BA84499022AC984D
1 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ import {
Rectangle2d,
ShapeUtil,
SvgExportContext,
TLDefaultSizeStyle,
TLHandle,
TLNoteShape,
TLOnEditEndHandler,
@ -36,6 +37,13 @@ import {
startEditingNoteShape,
} from './noteHelpers'
const FONT_SIZE_TO_LINE_HEIGHT: Record<TLDefaultSizeStyle, number> = {
s: 1.46,
m: 1.375,
l: 1.36,
xl: 1.35,
}
/** @public */
export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
static override type = 'note' as const
@ -177,12 +185,13 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
type={type}
font={font}
fontSize={fontSizeAdjustment || LABEL_FONT_SIZES[size]}
lineHeight={TEXT_PROPS.lineHeight}
lineHeight={FONT_SIZE_TO_LINE_HEIGHT[size]}
align={align}
verticalAlign={shape.props.growY > 0 ? 'start' : verticalAlign}
text={text}
isNote
labelColor={color}
padding={getPadding(shape)}
wrap
onKeyDown={handleKeyDown}
/>
@ -273,7 +282,7 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
}
function getPadding(shape: TLNoteShape) {
return (TEXT_PROPS.lineHeight * LABEL_FONT_SIZES[shape.props.size]) / 2 / 1.5
return (FONT_SIZE_TO_LINE_HEIGHT[shape.props.size] * LABEL_FONT_SIZES[shape.props.size]) / 2 / 1.5
}
function getOffsetForPosition(shape: TLNoteShape, i: number) {