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(sheets-ui): fix the pasted black background does not take effect (#6090)
wpxp1234568bda175dd48d
diff --git a/packages/sheets-ui/src/services/clipboard/html-to-usm/parse-node-style.ts b/packages/sheets-ui/src/services/clipboard/html-to-usm/parse-node-style.tsindex d1b7292de4..b808e476b3 100644--- a/packages/sheets-ui/src/services/clipboard/html-to-usm/parse-node-style.ts+++ b/packages/sheets-ui/src/services/clipboard/html-to-usm/parse-node-style.ts@@ -16,7 +16,6 @@import type { ITextStyle } from '@univerjs/core';import { BaselineOffset, BooleanNumber, ColorKit } from '@univerjs/core';-import { DEFAULT_BACKGROUND_COLOR_RGB, DEFAULT_BACKGROUND_COLOR_RGBA } from '@univerjs/ui';export function extractNodeStyle(node: HTMLElement, predefinedStyles?: Record<string, string>): ITextStyle {const styles = predefinedStyles ?? node.style;@@ -76,7 +75,6 @@ function parseStyleByProperty(styles: CSSStyleDeclaration | Record<string, strin}}-// eslint-disable-next-line complexityfunction handleStyle(cssRule: string, cssValue: string, docStyles: ITextStyle) {switch (cssRule) {case 'font-family':@@ -132,9 +130,11 @@ function handleStyle(cssRule: string, cssValue: string, docStyles: ITextStyle) {}case 'background-color': {const color = new ColorKit(cssValue);- const bgColor = color.isValid ? color.toRgbString() : '';- if (bgColor !== DEFAULT_BACKGROUND_COLOR_RGB && bgColor !== DEFAULT_BACKGROUND_COLOR_RGBA) {- docStyles.bg = { rgb: bgColor };++ if (color.isValid) {+ docStyles.bg = {+ rgb: color.toRgbString(),+ };}break;}diff --git a/packages/ui/src/utils/cell.ts b/packages/ui/src/utils/cell.tsindex cb97a97fb7..6b5272c0ce 100644--- a/packages/ui/src/utils/cell.ts+++ b/packages/ui/src/utils/cell.ts@@ -32,8 +32,6 @@ import { textTrim } from './util';const PX_TO_PT_RATIO = 0.75;const MAX_FONT_SIZE = 78;const MIN_FONT_SIZE = 9;-export const DEFAULT_BACKGROUND_COLOR_RGBA = 'rgba(0,0,0,0)';-export const DEFAULT_BACKGROUND_COLOR_RGB = 'rgb(0,0,0)';// TODO: move to Utils/**@@ -210,14 +208,11 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {}// fill color / backgroundelse if (key === 'background' || key === 'background-color') {- const backgroundColor = new ColorKit(value);- if (backgroundColor) {- const backgroundStr = backgroundColor.toRgbString();- if (backgroundStr !== DEFAULT_BACKGROUND_COLOR_RGBA && backgroundStr !== DEFAULT_BACKGROUND_COLOR_RGB) {- styleList.bg = {- rgb: backgroundColor.toRgbString(),- };- }+ const colorKit = new ColorKit(value);+ if (colorKit.isValid) {+ styleList.bg = {+ rgb: colorKit.toRgbString(),+ };}}