Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: underline position offset is wrong when has margin top (#482)
Ran Luoe990a4edcdb5
diff --git a/packages/base-render/src/components/docs/document.ts b/packages/base-render/src/components/docs/document.tsindex 67bcb96643..5eee2e4b1a 100644--- a/packages/base-render/src/components/docs/document.ts+++ b/packages/base-render/src/components/docs/document.ts@@ -350,12 +350,14 @@ export class Documents extends DocComponent {rotateTranslateXListApply && this._drawLiquid.translate(rotateTranslateXListApply[i]); // x axis offsetconst divideLength = divides.length;+for (let i = 0; i < divideLength; i++) {const divide = divides[i];const { spanGroup } = divide;this._drawLiquid.translateSave();this._drawLiquid.translateDivide(divide);+for (const span of spanGroup) {if (!span.content || span.content.length === 0) {continue;diff --git a/packages/base-render/src/components/docs/extensions/font-and-base-line.ts b/packages/base-render/src/components/docs/extensions/font-and-base-line.tsindex e404b8ef2b..a3584e8895 100644--- a/packages/base-render/src/components/docs/extensions/font-and-base-line.ts+++ b/packages/base-render/src/components/docs/extensions/font-and-base-line.ts@@ -27,6 +27,7 @@ export class FontAndBaseLine extends docExtension {const maxLineAsc = asc + lineMarginTop + linePaddingTop;const { ts: textStyle, content, fontStyle, bBox } = span;const { spanPointWithFont = Vector2.create(0, 0) } = this.extensionOffset;+if (!textStyle) {if (content != null) {ctx.fillText(content, spanPointWithFont.x, spanPointWithFont.y);diff --git a/packages/base-render/src/components/docs/extensions/line.ts b/packages/base-render/src/components/docs/extensions/line.tsindex 2611dd9125..1aa97ba9e4 100644--- a/packages/base-render/src/components/docs/extensions/line.ts+++ b/packages/base-render/src/components/docs/extensions/line.ts@@ -23,7 +23,7 @@ export class Line extends docExtension {return;}- const { asc: maxLineAsc = 0, lineHeight = 0 } = line;+ const { asc: maxLineAsc = 0, lineHeight = 0, marginTop = 0 } = line;const { ts: textStyle, left, width, bBox } = span;if (!textStyle) {return;@@ -46,13 +46,14 @@ export class Line extends docExtension {if (underline) {const { s: show, cl: colorStyle, t: lineType } = underline;+if (show === BooleanNumber.TRUE) {ctx.beginPath();const color = getColorStyle(colorStyle) || COLOR_BLACK_RGB;ctx.strokeStyle = color;this._setLineType(ctx, lineType || TextDecoration.SINGLE);- const startY = fixLineWidthByScale(lineHeight + DEFAULT_OFFSET_SPACING - 0.5, scale);+ const startY = fixLineWidthByScale(lineHeight - marginTop + DEFAULT_OFFSET_SPACING - 0.5, scale);const start = calculateRectRotate(originTranslate.addByPoint(left, startY),@@ -68,6 +69,7 @@ export class Line extends docExtension {vertexAngle,alignOffset);+ctx.moveTo(start.x, start.y);ctx.lineTo(end.x, end.y);ctx.stroke();