[fix] text export placement (#1066)
* Fix text export placement * remove console.log * Update getTextSvgElement.ts
This commit is contained in:
parent
da0d617f0c
commit
cfa7f6e357
2 changed files with 4 additions and 4 deletions
|
@ -398,7 +398,7 @@ export class TextUtil extends TDShapeUtil<T, E> {
|
|||
|
||||
const fontSize = getFontSize(shape.style.size, shape.style.font) * (shape.style.scale ?? 1)
|
||||
const fontFamily = getFontFace(shape.style.font).slice(1, -1)
|
||||
const textAlign = shape.style.textAlign ?? AlignStyle.Start
|
||||
const textAlign = shape.style.textAlign ?? AlignStyle.Middle
|
||||
|
||||
const textElm = getTextSvgElement(
|
||||
shape.text,
|
||||
|
|
|
@ -58,19 +58,19 @@ export function getTextSvgElement(
|
|||
case AlignStyle.Middle: {
|
||||
textElm.setAttribute('text-align', 'center')
|
||||
textElm.setAttribute('text-anchor', 'middle')
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', 4 + width / 2 + ''))
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', width / 2 + ''))
|
||||
break
|
||||
}
|
||||
case AlignStyle.End: {
|
||||
textElm.setAttribute('text-align', 'right')
|
||||
textElm.setAttribute('text-anchor', 'end')
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', 4 + width + ''))
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', -4 + width + ''))
|
||||
break
|
||||
}
|
||||
default: {
|
||||
textElm.setAttribute('text-align', 'left')
|
||||
textElm.setAttribute('text-anchor', 'start')
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', '4'))
|
||||
textLines.forEach((textElm) => textElm.setAttribute('x', 4 + ''))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue