Skip to content

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.

fix: no need to set background to linebreak (#2335)

Ran Luo4140cb72de81
diff --git a/packages/engine-render/src/components/docs/extensions/background.ts b/packages/engine-render/src/components/docs/extensions/background.ts
index 90c0d31a83..01054b41f4 100644
--- a/packages/engine-render/src/components/docs/extensions/background.ts
+++ b/packages/engine-render/src/components/docs/extensions/background.ts
@@ -36,29 +36,25 @@ export class Background extends docExtension {
override draw(ctx: UniverRenderingContext, parentScale: IScale, span: IDocumentSkeletonGlyph) {
const line = span.parent?.parent;
- if (!line) {
+ if (line == null) {
return;
}
const { contentHeight = 0 } = line;
- const { ts: textStyle, width } = span;
- if (!textStyle) {
+ const { ts: textStyle, width, content } = span;
+ if (textStyle?.bg == null) {
return;
}
const { bg } = textStyle;
- if (!bg) {
- return;
- }
-
const background = getColorStyle(bg);
const { spanStartPoint = Vector2.create(0, 0) } = this.extensionOffset;
const DELTA = 1.5;
- if (background) {
+ if (background && content !== '\r') {
ctx.fillStyle = background;
ctx.fillRectByPrecision(spanStartPoint.x - 0.5, spanStartPoint.y - 1, width + 1, contentHeight + 2 * DELTA);
}
diff --git a/packages/engine-render/src/components/docs/extensions/line.ts b/packages/engine-render/src/components/docs/extensions/line.ts
index 76f365dea8..027c14ba25 100644
--- a/packages/engine-render/src/components/docs/extensions/line.ts
+++ b/packages/engine-render/src/components/docs/extensions/line.ts
@@ -39,20 +39,16 @@ export class Line extends docExtension {
override draw(ctx: UniverRenderingContext, parentScale: IScale, glyph: IDocumentSkeletonGlyph) {
const line = glyph.parent?.parent;
- const { ts: textStyle, bBox } = glyph;
+ const { ts: textStyle, bBox, content } = glyph;
- if (line == null || textStyle == null) {
+ if (line == null || textStyle == null || content === '\r') {
return;
}
const { asc, dsc } = line;
-
const { sp: strikeoutPosition, spo, sbo, bd } = bBox;
-
const scale = getScale(parentScale);
-
const DELTA = 0.5;
-
const { ul: underline, st: strikethrough, ol: overline, va: baselineOffset } = textStyle;
if (underline) {
diff --git a/packages/engine-render/src/components/sheets/extensions/background.ts b/packages/engine-render/src/components/sheets/extensions/background.ts
index 9fdad10dec..accba36e48 100644
--- a/packages/engine-render/src/components/sheets/extensions/background.ts
+++ b/packages/engine-render/src/components/sheets/extensions/background.ts
@@ -27,8 +27,8 @@ import { SheetExtension } from './sheet-extension';
const UNIQUE_KEY = 'DefaultBackgroundExtension';
/**
- * in prev version background ext is higer than font ext. now turing back lower than font ext.
- * font ext zindex is 30.
+ * in prev version background ext is higher than font ext. now turing back lower than font ext.
+ * font ext z-index is 30.
*/
const DOC_EXTENSION_Z_INDEX = 21;
const PRINTING_Z_INDEX = 21;