import { TLArrowShape, TLShapeId, VecLike, stopEventPropagation } from '@tldraw/editor' import * as React from 'react' import { TextHelpers } from '../../shared/TextHelpers' import { ARROW_LABEL_FONT_SIZES, TEXT_PROPS } from '../../shared/default-shape-constants' import { useEditableText } from '../../shared/useEditableText' export const ArrowTextLabel = React.memo(function ArrowTextLabel({ id, text, size, font, position, width, labelColor, }: { id: TLShapeId; position: VecLike; width?: number; labelColor: string } & Pick< TLArrowShape['props'], 'text' | 'size' | 'font' >) { const { rInput, isEditing, handleFocus, handleBlur, handleKeyDown, handleChange, isEmpty, handleInputPointerDown, handleDoubleClick, } = useEditableText(id, 'arrow', text) const finalText = TextHelpers.normalizeTextForDom(text) const hasText = finalText.trim().length > 0 if (!isEditing && !hasText) { return null } return (

{text ? TextHelpers.normalizeTextForDom(text) : ' '}

{isEditing && ( // Consider replacing with content-editable