import { TLAlignType, TLFillType, TLFontType, TLShape, TLSizeType, TLVerticalAlignType, } from '@tldraw/tlschema' import React from 'react' import { LABEL_FONT_SIZES, TEXT_PROPS } from '../../../constants' import { stopEventPropagation } from '../../../utils/dom' import { TextHelpers } from '../TLTextUtil/TextHelpers' import { useEditableText } from './useEditableText' export const TextLabel = React.memo(function TextLabel< T extends Extract >({ id, type, text, size, labelColor, font, align, verticalAlign, wrap, }: { id: T['id'] type: T['type'] size: TLSizeType font: TLFontType fill?: TLFillType align: TLAlignType verticalAlign: TLVerticalAlignType wrap?: boolean text: string labelColor: string }) { const { rInput, isEmpty, isEditing, isEditableFromHover, handleFocus, handleChange, handleKeyDown, handleBlur, } = useEditableText(id, type, text) const isInteractive = isEditing || isEditableFromHover return (
{TextHelpers.normalizeTextForDom(text)}
{isInteractive ? ( // Consider replacing with content-editable