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: replace whitespace characters in html str (#1904)
ybzky1ff12617f33d
diff --git a/packages/core/src/shared/common.ts b/packages/core/src/shared/common.tsindex 84776b1080..192de42dc3 100644--- a/packages/core/src/shared/common.ts+++ b/packages/core/src/shared/common.ts@@ -403,11 +403,9 @@ export function handleStyleToString(style: IStyleData, isCell: boolean = false)'tb',() => {if (style.tb === WrapStrategy.CLIP) {- str += 'text-overflow: clip; ';- } else if (style.tb === WrapStrategy.OVERFLOW) {- str += 'text-break: overflow; ';+ str += 'white-space: clip; ';} else if (style.tb === WrapStrategy.WRAP) {- str += 'word-wrap: break-word;';+ str += 'white-space: normal;';}},],diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex 06dc29b96a..638faa8344 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -66,7 +66,7 @@ import {import { IClipboardInterfaceService, IMessageService, textTrim } from '@univerjs/ui';import { Inject, Injector, Optional } from '@wendellhu/redi';-import { ITextSelectionRenderManager } from '@univerjs/engine-render';+import { ITextSelectionRenderManager, ptToPx } from '@univerjs/engine-render';import { takeUntil } from 'rxjs';import {SheetCopyCommand,@@ -319,7 +319,11 @@ export class SheetClipboardController extends RxDisposable {const key = textTrim(css.substr(0, css.indexOf(':')));const value = textTrim(css.substr(css.indexOf(':') + 1));if (key === 'height') {- height = Number.parseFloat(value);+ if (value.endsWith('pt')) {+ height = ptToPx(Number.parseFloat(value));+ } else {+ height = Number.parseFloat(value);+ }return true;}return false;@@ -364,7 +368,11 @@ export class SheetClipboardController extends RxDisposable {const key = textTrim(css.substr(0, css.indexOf(':')));const value = textTrim(css.substr(css.indexOf(':') + 1));if (key === 'height') {- height = Number.parseFloat(value);+ if (value.endsWith('pt')) {+ height = ptToPx(Number.parseFloat(value));+ } else {+ height = Number.parseFloat(value);+ }return true;}return false;diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.tsindex 783ca1319d..a6feb1c0bc 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-font.spec.ts@@ -160,7 +160,7 @@ describe('Test clipboard', () => {expect(getStyles(cellData.getValue(3, 1)?.s)?.ul?.s).toBe(1);// font line-throughexpect(cellData.getValue(4, 1)?.v).toBe('S');- expect(cellData.getValue(4, 1)?.p?.body?.textRuns?.[0].ts?.st?.s).toBe(1);+ expect(getStyles(cellData.getValue(4, 1)?.s)?.st?.s).toBe(1);// font-sizeexpect(cellData.getValue(6, 1)?.v).toBe('font-size:12');diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.tsindex 6030de86a5..1363e62e29 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-form-excel.spec.ts@@ -157,7 +157,7 @@ describe('Test clipboard', () => {expect(worksheet.getMergeData().length).toBe(3);expect(getValues(2, 2, 2, 2)?.[0]?.[0]?.v).toEqual('Univer');expect(getStyles(2, 2, 2, 2)?.[0]?.[0]).toStrictEqual({- bl: 1, cl: { rgb: 'black' }, ff: '等线', fs: 12, ht: 0, it: 1, vt: 2,+ bl: 1, cl: { rgb: 'black' }, ff: '等线', fs: 12, ht: 0, it: 1, vt: 2, tb: 1,});});diff --git a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.tsindex aefc939d89..0976fcdfe2 100644--- a/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts+++ b/packages/sheets-ui/src/services/clipboard/__tests__/clipboard-paste-from-google.spec.ts@@ -176,6 +176,7 @@ describe('Test clipboard', () => {{ ed: 1, st: 0, ts: { fs: 9.75, ff: 'Arial' } },{st: 1, ed: 4, ts: {+ bl: 1,cl:{ rgb: 'rgb(217,210,233)' },ff: 'Arial', fs: 17.25, it: 1,diff --git a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.tsindex f1dcb04f5c..3167cfa4d9 100644--- a/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts+++ b/packages/sheets-ui/src/services/clipboard/html-to-usm/converter.ts@@ -51,6 +51,8 @@ const sheetStyleRules: string[] ='font-style_fontStyle','font-family_fontFamily','text-decoration_textDecoration',+ 'white-space_whiteSpace',+ 'word-wrap_wordWrap',];const borderRules: string[] =@@ -227,8 +229,24 @@ export class HtmlToUSMService {const parsedCellMatrix = parseTableByHtml(this.htmlElement, this.getCurrentSkeleton()?.skeleton);parsedCellMatrix &&parsedCellMatrix.forValue((row, col, value) => {- const style = handleStringToStyle(undefined, value.style);- const cellValue = value?.richTextParma?.p+ let style = handleStringToStyle(undefined, value.style);+ if (value?.richTextParma?.p?.body?.textRuns?.length) {+ const textLen = value?.richTextParma?.v?.length;+ for (let i = 0; i < value?.richTextParma?.p?.body?.textRuns?.length; i++) {+ const textRunItem = value?.richTextParma?.p?.body?.textRuns[i];+ if (textRunItem.st === 0 && textRunItem.ed === textLen) {+ style = { ...textRunItem.ts, ...style };+ value?.richTextParma?.p?.body?.textRuns.splice(i, 1);+ i--;+ }+ }+ if (value?.richTextParma?.p?.body?.textRuns?.length === 0) {+ value.content = value?.richTextParma?.v;+ delete value.richTextParma;+ }+ }++ const cellValue = value?.richTextParma?.p?.body?.textRuns? {v: value.richTextParma.v,p: value.richTextParma.p,@@ -387,8 +405,18 @@ function parseProperties(propertyStr: string): IClipboardPropertyItem {* @returns cols and their properties*/function parseColGroup(raw: string): IClipboardPropertyItem[] | null {+ const COLGROUP_TAG_REGEX = /<colgroup([\s\S]*?)>(.*?)<\/colgroup>/;+ const colgroupMatch = raw.match(COLGROUP_TAG_REGEX);++const COL_TAG_REGEX = /<col([\s\S]*?)>/g;- const colMatches = raw.matchAll(COL_TAG_REGEX);+ let colMatches;+ if (colgroupMatch?.[2]) {+ colMatches = colgroupMatch[2].matchAll(COL_TAG_REGEX);+ } else {+ colMatches = raw.matchAll(COL_TAG_REGEX);+ }+if (!colMatches) {return null;}@@ -459,37 +487,10 @@ function parseTableByHtml(htmlElement: HTMLIFrameElement, skeleton?: Spreadsheetfor (let colIndex = 0; colIndex < cells.length;) {const cell = cells[colIndex];let cellStyle = '';- let cellText;- let cellRichStyle;const rowSpan = Number(cell.getAttribute('rowSpan')) || 1;const colSpan = Number(cell.getAttribute('colSpan')) || 1;-// If there is a class attribute, use getComputedStyle- const hasClass = cell.getAttribute('class');- const computedStyle = getComputedStyle(cell);- if (hasClass) {- sheetStyleRules.forEach((rule) => {- const [originName, camelName] = rule.split('_');- const ruleValue = computedStyle.getPropertyValue(originName) || computedStyle[camelName as keyof typeof computedStyle];- if (ruleValue) {- cellStyle += `${originName}:${ruleValue};`;- }- });- } else {- const regex = /<\w+\s+[^>]*?style="([^"]*)"/gi;- const match = regex.exec(cell.outerHTML);- if (match?.[1]) {- cellStyle = match[1];- }- }-- borderRules.forEach((rule) => {- const [originName, camelName] = rule.split('_');- const ruleValue = computedStyle.getPropertyValue(originName) || computedStyle[camelName as keyof typeof computedStyle];- if (ruleValue) {- cellStyle += `${originName}:${ruleValue};`;- }- });+ cellStyle = getCellStyle(cell);if (rowSpan > 1 && colSpan > 1) {// compatible google sheet;The border style of merged cells in Google is set on the right and bottom sides of the merged cells@@ -506,32 +507,7 @@ function parseTableByHtml(htmlElement: HTMLIFrameElement, skeleton?: Spreadsheet}// Determine whether it is rich text based on whether there are html tags- const isRichText = /<[^>]+>/.test(cell.innerHTML);- if (isRichText && skeleton) {- const newDocBody: IDocumentBody = {- dataStream: '',- textRuns: [],- };- // Rich text parsing method, refer to the doc- parseCellHtml(null, cell.childNodes, newDocBody);- const documentModel = skeleton.getBlankCellDocumentModel()?.documentModel;- const p = documentModel?.getSnapshot();- const singleDataStream = `${newDocBody.dataStream}\r\n`;- const documentData = {- ...p, ...{- body: {- dataStream: singleDataStream,- textRuns: newDocBody.textRuns,- paragraphs: generateParagraphs(singleDataStream),- },- },- };- documentModel?.reset(documentData);- cellRichStyle = documentModel?.getSnapshot();- cellText = newDocBody.dataStream;- } else {- cellText = cell.innerHTML.replace(/[\r\n]/g, '');- }+ const { cellText, cellRichStyle } = getCellTextAndRichText(cell, skeleton);const cellValue = (rowSpan > 1 || colSpan > 1)? {@@ -559,39 +535,7 @@ function parseTableByHtml(htmlElement: HTMLIFrameElement, skeleton?: Spreadsheet} else {// Clone the style of merged cells to each individual cell; switch to cloning only border styles if there are issues later.if ((rowSpan > 1 || colSpan > 1)) {- if (rowSpan === 1) {- for (let i = colSetValueIndex; i < colSetValueIndex + colSpan; i++) {- cellMatrix.setValue(rowIndex, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom']) });- }- cellMatrix.setValue(rowIndex, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom', 'border-right']) });- cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom', 'border-left']) });- } else if (colSpan === 1) {- for (let i = rowIndex; i < rowIndex + rowSpan; i++) {- cellMatrix.setValue(i, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right']) });- }- cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right', 'border-bottom']) });- cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right', 'border-top']) });- } else {- for (let i = colSetValueIndex; i < colSetValueIndex + colSpan; i++) {- cellMatrix.setValue(rowIndex, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-top']) });- cellMatrix.setValue(rowIndex + rowSpan - 1, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-bottom']) });- }- for (let i = rowIndex; i < rowIndex + rowSpan; i++) {- cellMatrix.setValue(i, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left']) });- cellMatrix.setValue(i, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right']) });- }- cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-bottom']) });- cellMatrix.setValue(rowIndex, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right', 'border-top']) });- cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right', 'border-bottom']) });- cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-left']) });- for (let i = rowIndex; i < rowIndex + rowSpan; i++) {- for (let j = colSetValueIndex; j < colSetValueIndex + colSpan; j++) {- if (!cellMatrix.getValue(i, j)) {- cellMatrix.setValue(i, j, { style: extractBordersAndKeepOthers(cellStyle, []) });- }- }- }- }+ setMergedCellStyle(cellMatrix, cellStyle, cellValue, { colSpan, rowSpan, rowIndex, colIndex, colSetValueIndex });} else {cellMatrix.setValue(rowIndex, colSetValueIndex, cellValue);}@@ -645,3 +589,127 @@ function extractStyleProperty(styleString?: string, propertyName?: string) {}return null;}+++function getCellStyle(cell: Element) {+ let cellStyle = '';+ const hasClass = cell.getAttribute('class');+ const computedStyle = getComputedStyle(cell);+ if (hasClass) {+ sheetStyleRules.forEach((rule) => {+ const [originName, camelName] = rule.split('_');+ const ruleValue = computedStyle.getPropertyValue(originName) || computedStyle[camelName as keyof typeof computedStyle];+ if (ruleValue) {+ cellStyle += `${originName}:${ruleValue};`;+ }+ });+ } else {+ const regex = /<\w+\s+[^>]*?style="([^"]*)"/gi;+ const match = regex.exec(cell.outerHTML);+ if (match?.[1]) {+ cellStyle = match[1];+ }+ }++ borderRules.forEach((rule) => {+ const [originName, camelName] = rule.split('_');+ const ruleValue = computedStyle.getPropertyValue(originName) || computedStyle[camelName as keyof typeof computedStyle];+ if (ruleValue) {+ cellStyle += `${originName}:${ruleValue};`;+ }+ });+ return cellStyle;+}++function getCellTextAndRichText(cell: Element, skeleton?: SpreadsheetSkeleton) {+ let cellText = '';+ let cellRichStyle;+ const isRichText = /<[^>]+>/.test(cell.innerHTML);+ if (isRichText && skeleton) {+ const newDocBody: IDocumentBody = {+ dataStream: '',+ textRuns: [],+ };+ // Rich text parsing method, refer to the doc+ parseCellHtml(null, cell.childNodes, newDocBody);+ const documentModel = skeleton.getBlankCellDocumentModel()?.documentModel;+ const p = documentModel?.getSnapshot();+ const singleDataStream = `${newDocBody.dataStream}\r\n`;+ const documentData = {+ ...p, ...{+ body: {+ dataStream: singleDataStream,+ textRuns: newDocBody.textRuns,+ paragraphs: generateParagraphs(singleDataStream),+ },+ },+ };+ documentModel?.reset(documentData);+ cellRichStyle = documentModel?.getSnapshot();+ cellText = newDocBody.dataStream;+ } else {+ cellText = decodeHTMLEntities(cell.innerHTML.replace(/[\r\n]/g, ''));+ }+ return {+ cellText,+ cellRichStyle,+ };+}++function setMergedCellStyle(+ cellMatrix: ObjectMatrix<IParsedCellValueByClipboard>,+ cellStyle: string,+ cellValue:+ {+ content: string;+ style: string;+ richTextParma: {+ p?: IDocumentData;+ v: string;+ };+ rowSpan?: number;+ colSpan?: number;++ },+ indexParams: {+ colSpan: number;+ rowSpan: number;+ rowIndex: number;+ colIndex: number;+ colSetValueIndex: number;+ }) {+ const { rowSpan, colSpan, rowIndex, colSetValueIndex } = indexParams;+ if (rowSpan === 1) {+ for (let i = colSetValueIndex; i < colSetValueIndex + colSpan; i++) {+ cellMatrix.setValue(rowIndex, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom']) });+ }+ cellMatrix.setValue(rowIndex, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom', 'border-right']) });+ cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-bottom', 'border-left']) });+ } else if (colSpan === 1) {+ for (let i = rowIndex; i < rowIndex + rowSpan; i++) {+ cellMatrix.setValue(i, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right']) });+ }+ cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right', 'border-bottom']) });+ cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-right', 'border-top']) });+ } else {+ for (let i = colSetValueIndex; i < colSetValueIndex + colSpan; i++) {+ cellMatrix.setValue(rowIndex, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-top']) });+ cellMatrix.setValue(rowIndex + rowSpan - 1, i, { style: extractBordersAndKeepOthers(cellStyle, ['border-bottom']) });+ }+ for (let i = rowIndex; i < rowIndex + rowSpan; i++) {+ cellMatrix.setValue(i, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left']) });+ cellMatrix.setValue(i, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right']) });+ }+ cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex, { style: extractBordersAndKeepOthers(cellStyle, ['border-left', 'border-bottom']) });+ cellMatrix.setValue(rowIndex, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right', 'border-top']) });+ cellMatrix.setValue(rowIndex + rowSpan - 1, colSetValueIndex + colSpan - 1, { style: extractBordersAndKeepOthers(cellStyle, ['border-right', 'border-bottom']) });+ cellMatrix.setValue(rowIndex, colSetValueIndex, { ...cellValue, style: extractBordersAndKeepOthers(cellStyle, ['border-top', 'border-left']) });+ for (let i = rowIndex; i < rowIndex + rowSpan; i++) {+ for (let j = colSetValueIndex; j < colSetValueIndex + colSpan; j++) {+ if (!cellMatrix.getValue(i, j)) {+ cellMatrix.setValue(i, j, { style: extractBordersAndKeepOthers(cellStyle, []) });+ }+ }+ }+ }+}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 60e2c34dc7..5bb7fc01b1 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,6 +16,7 @@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?: CSSStyleDeclaration): ITextStyle {const styles = predefinedStyles ?? node.style;@@ -56,20 +57,23 @@ export function extractNodeStyle(node: HTMLElement, predefinedStyles?: CSSStyleD}}+ parseStyleByProperty(styles, docStyles);+ return docStyles;+}+++// eslint-disable-next-line complexity+function parseStyleByProperty(styles: CSSStyleDeclaration, docStyles: ITextStyle) {for (let i = 0; i < styles.length; i++) {const cssRule = styles[i];const cssValue = styles.getPropertyValue(cssRule);-switch (cssRule) {case 'font-family': {docStyles.ff = cssValue;-break;}-case 'font-size': {const fontSize = Number.parseInt(cssValue);-if (!Number.isNaN(fontSize)) {// TODO: @ybzky need other font size unit supportif (cssValue.endsWith('pt')) {@@ -79,28 +83,21 @@ export function extractNodeStyle(node: HTMLElement, predefinedStyles?: CSSStyleDdocStyles.fs = transformedFontSize;}}-break;}-case 'font-style': {if (cssValue === 'italic') {docStyles.it = BooleanNumber.TRUE;}-break;}-case 'font-weight': {const MIDDLE_FONT_WEIGHT = 400;-- if (Number(cssValue) > MIDDLE_FONT_WEIGHT) {+ if (Number(cssValue) > MIDDLE_FONT_WEIGHT || cssValue === 'bold') {docStyles.bl = BooleanNumber.TRUE;}-break;}-case 'text-decoration': {// TODO: @JOCS, Parse CSS values like: underline dotted;if (/underline/.test(cssValue)) {@@ -116,40 +113,31 @@ export function extractNodeStyle(node: HTMLElement, predefinedStyles?: CSSStyleDs: BooleanNumber.TRUE,};}-break;}-case 'color': {const color = new ColorKit(cssValue);-if (color.isValid) {docStyles.cl = {rgb: color.toRgbString(),};}-break;}-case 'background-color': {const color = new ColorKit(cssValue);-- if (color.isValid) {+ const bgColor = color.isValid ? color.toRgbString() : '';+ if (bgColor !== DEFAULT_BACKGROUND_COLOR_RGB && bgColor !== DEFAULT_BACKGROUND_COLOR_RGBA) {docStyles.bg = {rgb: color.toRgbString(),};}-break;}-default: {// console.log(`Unhandled css rule ${cssRule}`);break;}}}-- return docStyles;}diff --git a/packages/ui/src/utils/cell.ts b/packages/ui/src/utils/cell.tsindex 6b2c4d6292..3df90e3242 100644--- a/packages/ui/src/utils/cell.ts+++ b/packages/ui/src/utils/cell.ts@@ -32,6 +32,8 @@ 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/**@@ -209,9 +211,12 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {else if (key === 'background' || key === 'background-color') {const backgroundColor = new ColorKit(value);if (backgroundColor) {- styleList.bg = {- rgb: backgroundColor.toRgbString(),- };+ const backgroundStr = backgroundColor.toRgbString();+ if (backgroundStr !== DEFAULT_BACKGROUND_COLOR_RGBA && backgroundStr !== DEFAULT_BACKGROUND_COLOR_RGB) {+ styleList.bg = {+ rgb: backgroundColor.toRgbString(),+ };+ }}}@@ -389,6 +394,17 @@ export function handleStringToStyle($dom?: HTMLElement, cssStyle: string = '') {}}+ if (key === 'white-space') {+ if (value === 'nowrap') {+ styleList.tb = 1;+ } else if (value === 'normal') {+ styleList.tb = 3;+ } else if (value === 'clip') {+ styleList.tb = 2;+ }+ }++if (key === 'border-color') {const colors = handleBorder(value, ')');if (!styleList.bd) {