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
test(base-sheets): add undo redo test, set font family, use styles cacheMap (#280)
Dushusir0775316c407b
diff --git a/packages/base-docs/src/Locale/en.ts b/packages/base-docs/src/Locale/en.tsindex f6ba473eaa..3183d58901 100644--- a/packages/base-docs/src/Locale/en.ts+++ b/packages/base-docs/src/Locale/en.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: 'Microsoft Accor black ',+ MicrosoftYaHei: 'Microsoft YaHei',SimSun: 'SimSun',SimHei: 'SimHei',Kaiti: 'Kaiti',diff --git a/packages/base-docs/src/Locale/zh.ts b/packages/base-docs/src/Locale/zh.tsindex a5feff1641..b6ba071d88 100644--- a/packages/base-docs/src/Locale/zh.ts+++ b/packages/base-docs/src/Locale/zh.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: '微软雅黑',+ MicrosoftYaHei: '微软雅黑',SimSun: '宋体',SimHei: '黑体',Kaiti: '楷体',diff --git a/packages/base-sheets/src/commands/commands/__tests__/set-style.command.spec.ts b/packages/base-sheets/src/commands/commands/__tests__/set-style.command.spec.tsindex c30d5fdbee..46b99bddba 100644--- a/packages/base-sheets/src/commands/commands/__tests__/set-style.command.spec.ts+++ b/packages/base-sheets/src/commands/commands/__tests__/set-style.command.spec.ts@@ -8,7 +8,6 @@ import {ICurrentUniverService,ITextDecoration,ITextRotation,- Nullable,RANGE_TYPE,RedoCommand,UndoCommand,@@ -110,7 +109,7 @@ describe("Test commands used for updating cells' styles", () => {// undoexpect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();expect(getFontBold()).toBe(FontWeight.BOLD);- // undo+ // redoexpect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();expect(getFontBold()).toBe(FontWeight.NORMAL);});@@ -155,19 +154,26 @@ describe("Test commands used for updating cells' styles", () => {startColumn: number,endRow: number,endColumn: number- ): boolean | undefined {- return (- get(ICurrentUniverService)- .getUniverSheetInstance('test')- ?.getSheetBySheetId('sheet1')- ?.getRange(startRow, startColumn, endRow, endColumn)- .getFontStyle() === FontItalic.ITALIC- );+ ): FontItalic | undefined {+ return get(ICurrentUniverService)+ .getUniverSheetInstance('test')+ ?.getSheetBySheetId('sheet1')+ ?.getRange(startRow, startColumn, endRow, endColumn)+ .getFontStyle();}expect(await commandService.executeCommand(SetItalicCommand.id)).toBeTruthy();- expect(getFontItalic(0, 0, 0, 0)).toBeTruthy(); // it should work for every cell in selection- expect(getFontItalic(0, 0, 0, 1)).toBeTruthy();+ expect(getFontItalic(0, 0, 0, 0)).toBe(FontItalic.ITALIC); // it should work for every cell in selection+ expect(getFontItalic(0, 0, 0, 1)).toBe(FontItalic.ITALIC);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontItalic(0, 0, 0, 0)).toBe(FontItalic.NORMAL);+ expect(getFontItalic(0, 0, 0, 1)).toBe(FontItalic.NORMAL);+ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontItalic(0, 0, 0, 0)).toBe(FontItalic.ITALIC);+ expect(getFontItalic(0, 0, 0, 1)).toBe(FontItalic.ITALIC);});});});@@ -210,6 +216,14 @@ describe("Test commands used for updating cells' styles", () => {expect(getFontUnderline()?.s).toBe(BooleanNumber.TRUE);expect(await commandService.executeCommand(SetUnderlineCommand.id)).toBeTruthy();expect(getFontUnderline()?.s).toBe(BooleanNumber.FALSE);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontUnderline()?.s).toBe(BooleanNumber.TRUE);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontUnderline()?.s).toBe(BooleanNumber.FALSE);});});@@ -259,6 +273,14 @@ describe("Test commands used for updating cells' styles", () => {expect(getFontThroughLine()?.s).toBe(BooleanNumber.TRUE);expect(await commandService.executeCommand(SetStrikeThroughCommand.id)).toBeTruthy();expect(getFontThroughLine()?.s).toBe(BooleanNumber.FALSE);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontThroughLine()?.s).toBe(BooleanNumber.TRUE);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontThroughLine()?.s).toBe(BooleanNumber.FALSE);});});@@ -297,6 +319,14 @@ describe("Test commands used for updating cells' styles", () => {expect(await commandService.executeCommand(SetFontSizeCommand.id, { value: 18 })).toBeTruthy();expect(getFontSize()).toBe(18);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontSize()).toBe(14);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontSize()).toBe(18);});});@@ -335,6 +365,14 @@ describe("Test commands used for updating cells' styles", () => {expect(await commandService.executeCommand(SetFontFamilyCommand.id, { value: 'Arial' })).toBeTruthy();expect(getFontFamily()).toBe('Arial');++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontFamily()).toBe('Times New Roman');++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontFamily()).toBe('Arial');});});@@ -372,12 +410,12 @@ describe("Test commands used for updating cells' styles", () => {},]);- function getFontColor(): Nullable<string> | undefined {+ function getFontColor(): string | undefined {return get(ICurrentUniverService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')?.getRange(0, 0, 0, 0)- .getTextStyle()?.cl?.rgb;+ .getFontColor();}function getFontThroughLine(): ITextDecoration | undefined {return get(ICurrentUniverService)@@ -417,6 +455,26 @@ describe("Test commands used for updating cells' styles", () => {expect(getFontThroughLine()?.cl?.rgb).toBe('#abcdef');expect(getFontUnderline()?.cl?.rgb).toBe('#abcdef');expect(getFontOverline()?.cl?.rgb).toBe('#abcdef');++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getFontColor()).toBe('#000');+ expect(getFontThroughLine()).toStrictEqual({+ s: BooleanNumber.TRUE,+ }); // no color+ expect(getFontUnderline()).toStrictEqual({+ s: BooleanNumber.TRUE,+ });+ expect(getFontOverline()).toStrictEqual({+ s: BooleanNumber.TRUE,+ });++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getFontColor()).toBe('#abcdef');+ expect(getFontThroughLine()?.cl?.rgb).toBe('#abcdef');+ expect(getFontUnderline()?.cl?.rgb).toBe('#abcdef');+ expect(getFontOverline()?.cl?.rgb).toBe('#abcdef');});});@@ -457,6 +515,14 @@ describe("Test commands used for updating cells' styles", () => {await commandService.executeCommand(SetBackgroundColorCommand.id, { value: '#abcdef' })).toBeTruthy();expect(getBackgroundColor()).toBe('#abcdef');++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getBackgroundColor()).toBe('#fff');++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getBackgroundColor()).toBe('#abcdef');});});@@ -497,6 +563,14 @@ describe("Test commands used for updating cells' styles", () => {await commandService.executeCommand(SetVerticalTextAlignCommand.id, { value: VerticalAlign.TOP })).toBeTruthy();expect(getVerticalAlignment()).toBe(VerticalAlign.TOP);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getVerticalAlignment()).toBe(VerticalAlign.UNSPECIFIED);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getVerticalAlignment()).toBe(VerticalAlign.TOP);});});@@ -539,6 +613,14 @@ describe("Test commands used for updating cells' styles", () => {})).toBeTruthy();expect(getHorizontalAlignment()).toBe(HorizontalAlign.RIGHT);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getHorizontalAlignment()).toBe(HorizontalAlign.UNSPECIFIED);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getHorizontalAlignment()).toBe(HorizontalAlign.RIGHT);});});@@ -581,6 +663,14 @@ describe("Test commands used for updating cells' styles", () => {})).toBeTruthy();expect(getTextWrap()).toBe(WrapStrategy.WRAP);++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getTextWrap()).toBe(WrapStrategy.UNSPECIFIED);++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getTextWrap()).toBe(WrapStrategy.WRAP);});});@@ -622,13 +712,42 @@ describe("Test commands used for updating cells' styles", () => {value: 90,})).toBeTruthy();- expect(getTextRotation()?.a).toBe(90);++ expect(getTextRotation()).toStrictEqual({+ a: 90,+ });expect(await commandService.executeCommand(SetTextRotationCommand.id, {value: 'v',})).toBeTruthy();- expect(getTextRotation()?.v).toBe(BooleanNumber.TRUE);+ expect(getTextRotation()).toStrictEqual({+ a: 0,+ v: BooleanNumber.TRUE,+ });++ // undo+ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getTextRotation()).toStrictEqual({+ a: 90,+ });++ expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();+ expect(getTextRotation()).toStrictEqual({+ a: 0,+ v: BooleanNumber.FALSE,+ }); // default value++ // redo+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getTextRotation()).toStrictEqual({+ a: 90,+ });+ expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();+ expect(getTextRotation()).toStrictEqual({+ a: 0,+ v: BooleanNumber.TRUE,+ });});});diff --git a/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/base-sheets/src/commands/mutations/set-range-values.mutation.tsindex be971e9516..8aefeac030 100644--- a/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts@@ -70,7 +70,7 @@ export const SetRangeValuesUndoMutationFactory = (const newStyle = transformStyle(oldStyle, newVal && newVal.s ? (newVal.s as Nullable<IStyleData>) : null);cell.s = newStyle;- undoData.setValue(row, col, Tools.deepClone(setNull(cell)));+ undoData.setValue(row, col, setNull(cell));});// for (let i = 0; i < params.range.length; i++) {// const { startRow, endRow, startColumn, endColumn } = params.range[i];diff --git a/packages/base-slides/src/Locale/en.ts b/packages/base-slides/src/Locale/en.tsindex f6ba473eaa..3183d58901 100644--- a/packages/base-slides/src/Locale/en.ts+++ b/packages/base-slides/src/Locale/en.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: 'Microsoft Accor black ',+ MicrosoftYaHei: 'Microsoft YaHei',SimSun: 'SimSun',SimHei: 'SimHei',Kaiti: 'Kaiti',diff --git a/packages/base-slides/src/Locale/zh.ts b/packages/base-slides/src/Locale/zh.tsindex a5feff1641..b6ba071d88 100644--- a/packages/base-slides/src/Locale/zh.ts+++ b/packages/base-slides/src/Locale/zh.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: '微软雅黑',+ MicrosoftYaHei: '微软雅黑',SimSun: '宋体',SimHei: '黑体',Kaiti: '楷体',diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsxindex b7780602aa..5b382987b9 100644--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx@@ -53,9 +53,10 @@ export function NeoCustomLabel(}if (display === DisplayTypes.FONT) {+ // According to the value, translate toolbar fontreturn (<div className={styles.fontSelect} style={{ fontFamily: value as string }}>- {getLocale(context, value as string)}+ {getLocale(context, `fontFamily.${(`${value}` || '').replace(/\s/g, '')}`)}</div>);}@@ -101,6 +102,8 @@ export function NeoCustomLabel(// eslint-disable-next-line @typescript-eslint/no-explicit-anyconst LabelComponent = icon ? (context.componentManager?.get(icon) as any) : null;++ // Process Font Family drop-down list fontreturn (<Itemselected={selected}@@ -108,6 +111,7 @@ export function NeoCustomLabel(value={value}suffix={LabelComponent ? <LabelComponent /> : null}disabled={false}+ style={{ fontFamily: title.indexOf('fontFamily.') === 0 ? `${value}` : 'inherit' }}></Item>);}diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsxindex 9770d8507c..8c8d5b1743 100644--- a/packages/base-ui/src/Components/Menu/Menu.tsx+++ b/packages/base-ui/src/Components/Menu/Menu.tsx@@ -283,7 +283,6 @@ export const Menu = (props: BaseMenuProps) => {><CustomComponentonValueChange={(v: string | number) => {- console.info('v=====', v);onOptionSelect?.({value: v,label: option.id,diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.tsindex 664ab83d66..2b5e42edcd 100644--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO.ts@@ -7229,7 +7229,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7240,7 +7240,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7257,7 +7257,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7265,7 +7265,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {},MXIg60: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7302,7 +7302,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7562,7 +7562,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7587,7 +7587,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7649,7 +7649,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7671,7 +7671,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {},WoeEm3: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7700,7 +7700,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7769,7 +7769,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7794,7 +7794,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7838,7 +7838,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7897,7 +7897,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {},jfDVFZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7926,7 +7926,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {},ky5JHZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -8003,7 +8003,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -8089,7 +8089,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 16,bl: 1,cl: {@@ -8127,7 +8127,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8266,7 +8266,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8279,7 +8279,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8299,7 +8299,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8325,7 +8325,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO7.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO7.tsindex 647d55b1ce..a9b5924c8f 100644--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO7.ts+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO7.ts@@ -7140,7 +7140,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7151,7 +7151,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7168,7 +7168,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7176,7 +7176,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {},MXIg60: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7213,7 +7213,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7473,7 +7473,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7498,7 +7498,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7560,7 +7560,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7582,7 +7582,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {},WoeEm3: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7611,7 +7611,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7680,7 +7680,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7705,7 +7705,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7749,7 +7749,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7808,7 +7808,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {},jfDVFZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7837,7 +7837,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {},ky5JHZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7914,7 +7914,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -8000,7 +8000,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 16,bl: 1,cl: {@@ -8038,7 +8038,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8177,7 +8177,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8190,7 +8190,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8210,7 +8210,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8236,7 +8236,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {diff --git a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO8.ts b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO8.tsindex 7e06f1c527..116758dc9c 100644--- a/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO8.ts+++ b/packages/common-plugin-data/src/Sheets/Demo/DEFAULT_WORKBOOK_DATA_DEMO8.ts@@ -7140,7 +7140,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7151,7 +7151,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7168,7 +7168,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7176,7 +7176,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {},MXIg60: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7213,7 +7213,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7473,7 +7473,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7498,7 +7498,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 1,cl: {rgb: 'rgb(102, 102, 102)',@@ -7560,7 +7560,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(102, 102, 102)',@@ -7582,7 +7582,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {},WoeEm3: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7611,7 +7611,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -7680,7 +7680,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7705,7 +7705,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7749,7 +7749,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',bl: 0,cl: {rgb: 'rgb(67, 67, 67)',@@ -7808,7 +7808,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {},jfDVFZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7837,7 +7837,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {},ky5JHZ: {vt: 1,- ff: 'lato',+ ff: 'Arial',bl: 0,it: 1,st: {@@ -7914,7 +7914,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 11,bl: 1,cl: {@@ -8000,7 +8000,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 16,bl: 1,cl: {@@ -8038,7 +8038,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8177,7 +8177,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8190,7 +8190,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8210,7 +8210,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {@@ -8236,7 +8236,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookConfig = {bg: {rgb: 'rgb(255, 255, 255)',},- ff: 'lato',+ ff: 'Arial',fs: 18,bl: 1,cl: {diff --git a/packages/core/src/Types/Const/CONST.ts b/packages/core/src/Types/Const/CONST.tsindex 7444956cfe..f97dbce2b2 100644--- a/packages/core/src/Types/Const/CONST.ts+++ b/packages/core/src/Types/Const/CONST.ts@@ -7,7 +7,7 @@ import {VerticalAlign,WrapStrategy,} from '../Enum';-import { IStyleData, IWorkbookConfig, IWorksheetConfig } from '../Interfaces';+import { IWorkbookConfig, IWorksheetConfig } from '../Interfaces';/*** Used as an illegal range array return value@@ -125,7 +125,7 @@ export const DEFAULT_WORKSHEET: IWorksheetConfig = {/*** Default styles*/-export const DEFAULT_STYLES: IStyleData = {+export const DEFAULT_STYLES = {/*** fontFamily*/diff --git a/packages/core/src/sheets/range.ts b/packages/core/src/sheets/range.tsindex d635131fbd..ca8923e0f8 100644--- a/packages/core/src/sheets/range.ts+++ b/packages/core/src/sheets/range.ts@@ -220,9 +220,8 @@ export class Range {const styles = this._deps.getStyles();return this.getValues().map((row) =>row.map((cell: Nullable<ICellData>) => {- let rgbColor: string = DEFAULT_STYLES.bg?.rgb!;- rgbColor = styles.getStyleByCell(cell)?.bg?.rgb!;- return rgbColor;+ const rgbColor = styles.getStyleByCell(cell);+ return rgbColor?.bg?.rgb || DEFAULT_STYLES.bg.rgb;}));}@@ -297,19 +296,19 @@ export class Range {/*** Returns the font color of the cell in the top-left corner of the range, in CSS notation*/- getFontColor(): Nullable<string> {+ getFontColor(): string {return this.getFontColors()[0][0];}/*** Returns the font colors of the cells in the range in CSS notation (such as '#ffffff' or 'white').*/- getFontColors(): Array<Array<Nullable<string>>> {+ getFontColors(): string[][] {const styles = this._deps.getStyles();return this.getValues().map((row) =>row.map((cell: Nullable<ICellData>) => {const cellStyle = styles.getStyleByCell(cell);- return cellStyle?.cl?.rgb || DEFAULT_STYLES.cl?.rgb;+ return cellStyle?.cl?.rgb || DEFAULT_STYLES.cl.rgb;}));}@@ -631,7 +630,7 @@ export class Range {return this.getValues().map((row) =>row.map((cell: Nullable<ICellData>) => {const style = styles && styles.getStyleByCell(cell);- return (style && style[arg]) || DEFAULT_STYLES[arg];+ return (style && style[arg]) || (DEFAULT_STYLES as IStyleData)[arg];}));}diff --git a/packages/core/src/sheets/styles.ts b/packages/core/src/sheets/styles.tsindex 8de6bdb0d5..41850c20ae 100644--- a/packages/core/src/sheets/styles.ts+++ b/packages/core/src/sheets/styles.ts@@ -7,8 +7,11 @@ import { ICellData, IStyleData } from '../Types/Interfaces';export class Styles {private _styles: IKeyType<Nullable<IStyleData>>;+ private _cacheMap = new Map<string, string>();+constructor(styles: IKeyType<Nullable<IStyleData>> = {}) {this._styles = styles;+ this._generateCacheMap();}each(@@ -25,10 +28,16 @@ export class Styles {search(data: IStyleData): string {const { _styles } = this;- for (const id in _styles) {- if (Tools.diffValue(_styles[id], data)) {- return id;- }+ // for (const id in _styles) {+ // if (Tools.diffValue(_styles[id], data)) {+ // return id;+ // }+ // }++ // Take from cache+ const styleObject = JSON.stringify(data);+ if (this._cacheMap.has(styleObject)) {+ return this._cacheMap.get(styleObject) as string;}return '-1';}@@ -42,6 +51,10 @@ export class Styles {add(data: IStyleData): string {const id = Tools.generateRandomId(6);this._styles[id] = data;+ // update cache+ const styleObject = JSON.stringify(data);+ this._cacheMap.set(styleObject, id);+return id;}@@ -68,4 +81,12 @@ export class Styles {return style as IStyleData;}++ private _generateCacheMap(): void {+ const { _styles } = this;+ for (const id in _styles) {+ const styleObject = JSON.stringify(_styles[id]);+ this._cacheMap.set(styleObject, id);+ }+ }}diff --git a/packages/ui-plugin-docs/src/Locale/en.ts b/packages/ui-plugin-docs/src/Locale/en.tsindex f53dc04baa..b7ea536d7f 100644--- a/packages/ui-plugin-docs/src/Locale/en.ts+++ b/packages/ui-plugin-docs/src/Locale/en.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: 'Microsoft Accor black ',+ MicrosoftYaHei: 'Microsoft YaHei',SimSun: 'SimSun',SimHei: 'SimHei',Kaiti: 'Kaiti',diff --git a/packages/ui-plugin-docs/src/Locale/zh.ts b/packages/ui-plugin-docs/src/Locale/zh.tsindex 1ba5e844b5..48c1c91c40 100644--- a/packages/ui-plugin-docs/src/Locale/zh.ts+++ b/packages/ui-plugin-docs/src/Locale/zh.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: '微软雅黑',+ MicrosoftYaHei: '微软雅黑',SimSun: '宋体',SimHei: '黑体',Kaiti: '楷体',diff --git a/packages/ui-plugin-sheets/src/Locale/en.ts b/packages/ui-plugin-sheets/src/Locale/en.tsindex 8bcd04870e..62e2b8889c 100644--- a/packages/ui-plugin-sheets/src/Locale/en.ts+++ b/packages/ui-plugin-sheets/src/Locale/en.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: 'Microsoft Accor black ',+ MicrosoftYaHei: 'Microsoft YaHei',SimSun: 'SimSun',SimHei: 'SimHei',Kaiti: 'Kaiti',diff --git a/packages/ui-plugin-sheets/src/Locale/zh.ts b/packages/ui-plugin-sheets/src/Locale/zh.tsindex d6ba5e538d..a83d38f26c 100644--- a/packages/ui-plugin-sheets/src/Locale/zh.ts+++ b/packages/ui-plugin-sheets/src/Locale/zh.ts@@ -168,7 +168,7 @@ export default {Arial: 'Arial',Tahoma: 'Tahoma',Verdana: 'Verdana',- MicrosoftAccorblack: '微软雅黑',+ MicrosoftYaHei: '微软雅黑',SimSun: '宋体',SimHei: '黑体',Kaiti: '楷体',diff --git a/packages/ui-plugin-sheets/src/controller/menu/menu.ts b/packages/ui-plugin-sheets/src/controller/menu/menu.tsindex f4d4927f02..6aa559594c 100644--- a/packages/ui-plugin-sheets/src/controller/menu/menu.ts+++ b/packages/ui-plugin-sheets/src/controller/menu/menu.ts@@ -427,49 +427,49 @@ export const FONT_FAMILY_CHILDREN = [value: 'Verdana',},{- label: 'fontFamily.MicrosoftAccorblack',+ label: 'fontFamily.MicrosoftYaHei',style: { 'font-family': '微软雅黑' },- value: '微软雅黑',+ value: 'Microsoft YaHei',},{label: 'fontFamily.SimSun',style: { 'font-family': '宋体' },- value: '宋体',+ value: 'SimSun',},{label: 'fontFamily.SimHei',style: { 'font-family': '黑体' },- value: '黑体',+ value: 'SimHei',},{label: 'fontFamily.Kaiti',style: { 'font-family': '楷体' },- value: '楷体',+ value: 'Kaiti',},{label: 'fontFamily.FangSong',style: { 'font-family': '仿宋' },- value: '仿宋',+ value: 'FangSong',},{label: 'fontFamily.NSimSun',style: { 'font-family': '新宋体' },- value: '新宋体',+ value: 'NSimSun',},{label: 'fontFamily.STXinwei',style: { 'font-family': '华文新魏' },- value: '华文新魏',+ value: 'STXinwei',},{label: 'fontFamily.STXingkai',style: { 'font-family': '华文行楷' },- value: '华文行楷',+ value: 'STXingkai',},{label: 'fontFamily.STLiti',style: { 'font-family': '华文隶书' },- value: '华文隶书',+ value: 'STLiti',},// The following 3 fonts do not work, temporarily delete// {diff --git a/packages/ui-plugin-slides/src/View/Toolbar/Const.ts b/packages/ui-plugin-slides/src/View/Toolbar/Const.tsindex db573b0f9d..28632ab6df 100644--- a/packages/ui-plugin-slides/src/View/Toolbar/Const.ts+++ b/packages/ui-plugin-slides/src/View/Toolbar/Const.ts@@ -87,7 +87,7 @@ export const FONT_FAMILY_CHILDREN = [value: 'Verdana',},{- label: 'fontFamily.MicrosoftAccorblack',+ label: 'fontFamily.MicrosoftYaHei',style: { 'font-family': '微软雅黑' },value: '微软雅黑',},