{ "version": 3, "sources": ["../../../../src/lib/shapes/shared/getTextLabelSvgElement.ts"], "sourcesContent": ["import { Box2d, Editor, TLGeoShape, TLNoteShape } from '@tldraw/editor'\nimport { createTextSvgElementFromSpans } from './createTextSvgElementFromSpans'\nimport { LABEL_FONT_SIZES, TEXT_PROPS } from './default-shape-constants'\nimport { getLegacyOffsetX } from './legacyProps'\n\nexport function getTextLabelSvgElement({\n\tbounds,\n\teditor,\n\tfont,\n\tshape,\n}: {\n\tbounds: Box2d\n\teditor: Editor\n\tfont: string\n\tshape: TLGeoShape | TLNoteShape\n}) {\n\tconst padding = 16\n\n\tconst opts = {\n\t\tfontSize: LABEL_FONT_SIZES[shape.props.size],\n\t\tfontFamily: font,\n\t\ttextAlign: shape.props.align,\n\t\tverticalTextAlign: shape.props.verticalAlign,\n\t\twidth: Math.ceil(bounds.width),\n\t\theight: Math.ceil(bounds.height),\n\t\tpadding: 16,\n\t\tlineHeight: TEXT_PROPS.lineHeight,\n\t\tfontStyle: 'normal',\n\t\tfontWeight: 'normal',\n\t\toverflow: 'wrap' as const,\n\t\toffsetX: 0,\n\t}\n\n\tconst spans = editor.textMeasure.measureTextSpans(shape.props.text, opts)\n\tconst offsetX = getLegacyOffsetX(shape.props.align, padding, spans, bounds.width)\n\tif (offsetX) {\n\t\topts.offsetX = offsetX\n\t}\n\n\tconst textElm = createTextSvgElementFromSpans(editor, spans, opts)\n\treturn textElm\n}\n"], "mappings": "AACA,SAAS,qCAAqC;AAC9C,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,wBAAwB;AAE1B,SAAS,uBAAuB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAKG;AACF,QAAM,UAAU;AAEhB,QAAM,OAAO;AAAA,IACZ,UAAU,iBAAiB,MAAM,MAAM,IAAI;AAAA,IAC3C,YAAY;AAAA,IACZ,WAAW,MAAM,MAAM;AAAA,IACvB,mBAAmB,MAAM,MAAM;AAAA,IAC/B,OAAO,KAAK,KAAK,OAAO,KAAK;AAAA,IAC7B,QAAQ,KAAK,KAAK,OAAO,MAAM;AAAA,IAC/B,SAAS;AAAA,IACT,YAAY,WAAW;AAAA,IACvB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,EACV;AAEA,QAAM,QAAQ,OAAO,YAAY,iBAAiB,MAAM,MAAM,MAAM,IAAI;AACxE,QAAM,UAAU,iBAAiB,MAAM,MAAM,OAAO,SAAS,OAAO,OAAO,KAAK;AAChF,MAAI,SAAS;AACZ,SAAK,UAAU;AAAA,EAChB;AAEA,QAAM,UAAU,8BAA8B,QAAQ,OAAO,IAAI;AACjE,SAAO;AACR;", "names": [] }