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(sheet): add test for selection feature and BISU (#184)
Wenzhao Hua513fdf68fa4
diff --git a/.eslintrc.cjs b/.eslintrc.cjsindex c4f0907aa0..2600788565 100644--- a/.eslintrc.cjs+++ b/.eslintrc.cjs@@ -98,7 +98,7 @@ module.exports = {// '@typescript-eslint/member-ordering': 'error','@typescript-eslint/no-explicit-any': 'warn','@typescript-eslint/no-redeclare': 'off', // dependency interface and dependency token share the same name- '@typescript-eslint/no-unused-vars': 'off',+ '@typescript-eslint/no-unused-vars': 'warn','grouped-accessor-pairs': 'off','no-magic-numbers': ['warn', { ignore: [0, 1, -1, 2] }],'no-unsafe-optional-chaining': 'off',diff --git a/packages/base-sheets/src/Controller/header-menu.controller.ts b/packages/base-sheets/src/Controller/header-menu.controller.tsindex aebf8156be..5299c1fd77 100644--- a/packages/base-sheets/src/Controller/header-menu.controller.ts+++ b/packages/base-sheets/src/Controller/header-menu.controller.ts@@ -22,7 +22,7 @@ import { getCoordByOffset, getSheetObject, ISheetObjectParam } from '../Basics/cimport { SHEET_COMPONENT_HEADER_LAYER_INDEX } from '../Basics/Const/DEFAULT_SPREADSHEET_VIEW';import { SelectionManagerService } from '../services/selection-manager.service';import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';-import { HEADER_MENU_SHAPE_TYPE, HeaderMenuShape } from '../View/headerMenuShape';+import { HEADER_MENU_SHAPE_TYPE, HeaderMenuShape } from '../View/HeaderMenuShape';const HEADER_MENU_CONTROLLER_SHAPE = '__SpreadsheetHeaderMenuSHAPEControllerShape__';diff --git a/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.tsindex 894da88b52..47450a238a 100644--- a/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/base-sheets/src/commands/commands/__tests__/create-command-test-bed.ts@@ -14,6 +14,9 @@ const TEST_WORKBOOK_DATA_DEMO: IWorkbookConfig = {'0': {v: 'A1',},+ '1': {+ v: 'A2',+ },},},},@@ -31,10 +34,10 @@ const TEST_WORKBOOK_DATA_DEMO: IWorkbookConfig = {timeZone: '',};-export function createCommandTestBed() {+export function createCommandTestBed(workbookConfig?: IWorkbookConfig) {const univer = new Univer();- let get: Injector['get'] | null = null;+ let get: Injector['get'] | undefined;/*** This plugin hooks into Sheet's DI system to expose API to test scripts@@ -42,7 +45,7 @@ export function createCommandTestBed() {class TestPlugin extends Plugin {static override type = PluginType.Sheet;- constructor(@Inject(Injector) _injector: Injector) {+ constructor(_config: undefined, @Inject(Injector) _injector: Injector) {super('test-plugin');this._injector = _injector;@@ -54,19 +57,18 @@ export function createCommandTestBed() {}override onDestroy(): void {- get = null;+ get = undefined;}}univer.registerPlugin(TestPlugin);- const sheet = univer.createUniverSheet(TEST_WORKBOOK_DATA_DEMO);+ const sheet = univer.createUniverSheet(workbookConfig || TEST_WORKBOOK_DATA_DEMO);- if (!get) {+ if (get === undefined) {throw new Error('[TestPlugin]: not hooked on!');}- // focus, used in undo- const currentUniverService = (get as Injector['get'])(ICurrentUniverService);+ const currentUniverService = get(ICurrentUniverService);currentUniverService.focusUniverInstance('test');return {diff --git a/packages/base-sheets/src/commands/commands/__tests__/create-selection-command-test-bed.ts b/packages/base-sheets/src/commands/commands/__tests__/create-selection-command-test-bed.tsnew file mode 100644index 0000000000..0a9c8944df--- /dev/null+++ b/packages/base-sheets/src/commands/commands/__tests__/create-selection-command-test-bed.ts@@ -0,0 +1,85 @@+import { ICommandService, IWorkbookConfig, LocaleType } from '@univerjs/core';++import { SetSelectionsOperation } from '../../operations/selection.operation';+import { ChangeSelectionCommand, ExpandSelectionCommand, SelectAllCommand } from '../set-selections.command';+import { createCommandTestBed } from './create-command-test-bed';++const SELECTION_COMMAND_TEST_WORKBOOK_DATA: IWorkbookConfig = {+ id: 'test',+ appVersion: '3.0.0-alpha',+ sheets: {+ sheet1: {+ id: 'sheet1',+ cellData: {+ '0': {+ '0': {+ v: 'A1',+ },+ '1': {+ v: 'A2',+ },+ },+ '1': {+ '0': {+ v: 'B1',+ },+ '1': {+ v: 'B2',+ },+ },++ '3': {+ '3': {+ v: 'D4',+ },+ '4': {+ v: 'E4',+ },+ '5': {+ v: 'F4',+ },+ },+ '4': {+ '3': {+ v: 'D5',+ },+ '4': {+ v: 'E5',+ },+ '5': {+ v: 'F5',+ },+ },+ },+ mergeData: [{ startRow: 3, startColumn: 4, endRow: 4, endColumn: 4 }],+ rowCount: 20,+ columnCount: 20,+ },+ },+ createdTime: '',+ creator: '',+ extensions: [],+ lastModifiedBy: '',+ locale: LocaleType.EN,+ modifiedTime: '',+ name: '',+ namedRanges: [],+ sheetOrder: [],+ styles: {},+ timeZone: '',+};++export function createSelectionCommandTestBed(workbookConfig?: IWorkbookConfig) {+ const { univer, get, sheet } = createCommandTestBed(workbookConfig || SELECTION_COMMAND_TEST_WORKBOOK_DATA);++ const commandService = get(ICommandService);+ [ChangeSelectionCommand, ExpandSelectionCommand, SelectAllCommand, SetSelectionsOperation].forEach((c) => {+ commandService.registerCommand(c);+ });++ return {+ univer,+ get,+ sheet,+ };+}diff --git a/packages/base-sheets/src/commands/commands/__tests__/set-selections.command.spec.ts b/packages/base-sheets/src/commands/commands/__tests__/set-selections.command.spec.tsindex 8f28ac5c46..b3392a00b4 100644--- a/packages/base-sheets/src/commands/commands/__tests__/set-selections.command.spec.ts+++ b/packages/base-sheets/src/commands/commands/__tests__/set-selections.command.spec.ts@@ -1,23 +1,246 @@-import { describe, expect, it } from 'vitest';+import { Direction, ICommandService, SELECTION_TYPE, Univer } from '@univerjs/core';+import { Injector } from '@wendellhu/redi';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';-// This spec file also tests selection-util.ts+import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../../services/selection-manager.service';+import {+ ChangeSelectionCommand,+ IChangeSelectionCommandParams,+ ISelectAllCommandParams,+ SelectAllCommand,+} from '../set-selections.command';+import { createSelectionCommandTestBed } from './create-selection-command-test-bed';describe('Test commands used for change selections', () => {+ let univer: Univer;+ let get: Injector['get'];+ let commandService: ICommandService;+ let selectionManagerService: SelectionManagerService;++ beforeEach(() => {+ const testBed = createSelectionCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ selectionManagerService = get(SelectionManagerService);+ });++ function select00() {+ selectionManagerService.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });++ selectionManagerService.add([+ {+ rangeData: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 },+ cellRange: {+ startRow: 0,+ startColumn: 0,+ endRow: 0,+ endColumn: 0,+ row: 0,+ column: 0,+ isMerged: false,+ isMergedMainCell: false,+ },+ selectionType: SELECTION_TYPE.NORMAL,+ style: null,+ },+ ]);+ }++ function select(startRow: number, startColumn: number, endRow: number, endColumn: number) {+ selectionManagerService.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });++ selectionManagerService.add([+ {+ rangeData: { startRow, startColumn, endRow, endColumn },+ cellRange: {+ startRow,+ startColumn,+ endRow,+ endColumn,+ row: startRow,+ column: startColumn,+ isMerged: false,+ isMergedMainCell: false,+ },+ selectionType: SELECTION_TYPE.NORMAL,+ style: null,+ },+ ]);+ }++ function expectSelectionToBe(startRow: number, startColumn: number, endRow: number, endColumn: number) {+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow,+ startColumn,+ endRow,+ endColumn,+ });+ }++ afterEach(() => {+ univer.dispose();+ });+describe('Simple movement', () => {+ it('Should move selection with command', async () => {+ select00();++ await commandService.executeCommand<IChangeSelectionCommandParams>(ChangeSelectionCommand.id, {+ direction: Direction.LEFT,+ });+ expectSelectionToBe(0, 0, 0, 0);++ await commandService.executeCommand<IChangeSelectionCommandParams>(ChangeSelectionCommand.id, {+ direction: Direction.RIGHT,+ });+ expectSelectionToBe(0, 1, 0, 1);++ await commandService.executeCommand<IChangeSelectionCommandParams>(ChangeSelectionCommand.id, {+ direction: Direction.DOWN,+ });+ expectSelectionToBe(1, 1, 1, 1);++ await commandService.executeCommand<IChangeSelectionCommandParams>(ChangeSelectionCommand.id, {+ direction: Direction.LEFT,+ });+ expectSelectionToBe(1, 0, 1, 0);++ await commandService.executeCommand<IChangeSelectionCommandParams>(ChangeSelectionCommand.id, {+ direction: Direction.UP,+ });+ expectSelectionToBe(0, 0, 0, 0);+ });++ describe('With merged cells', () => {+ it('Should select merged cell and move to next cell', async () => {+ // FIXME: 在跨越选区的时候,需要考虑选区的合并单元格,特别是这样的情形+ // D4 | E4 | F4+ // ---| |---+ // D5 | E5 | F5+ // 从 F5 向左移动两次,应该选中 D5 而非 D4+ // 所以一个选区信息可能有三个部分,选区的范围,选区的单元格范围,选区的合并单元格范围+ // Google Sheet 和腾讯文档 Sheet 的行为都是这样+ expect(true).toBeTruthy();+ });+ });+ });++ describe('Move to next gap cell', () => {+ it('placeholder', () => {+ expect(true).toBeTruthy();+ });+ });++ describe('Expand to next selection or shrink', () => {+ it('placeholder', () => {+ expect(true).toBeTruthy();+ });+ });++ describe('Expand to next gap position or shrink', () => {it('placeholder', () => {expect(true).toBeTruthy();});});- // describe('Move to next gap cell', () => {- // expect(true).toBeTruthy();- // });+ describe('Expand selection', () => {+ it('Should first select all neighbor cells, and then the whole sheet', async () => {+ select00();- // describe('Expand to next selection or shrink', () => {- // expect(true).toBeTruthy();- // });+ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: true,+ expandToGapFirst: true,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 1,+ endColumn: 1,+ });- // describe('Expand to next gap position or shrink', () => {- // expect(true).toBeTruthy();- // });+ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: true,+ expandToGapFirst: true,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 19,+ endColumn: 19,+ });++ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: true,+ expandToGapFirst: true,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 0,+ endColumn: 0,+ });+ });++ it('Should directly select all if `expandToGapFirst` is false', async () => {+ select00();++ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: true,+ expandToGapFirst: false,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 19,+ endColumn: 19,+ });++ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: true,+ expandToGapFirst: false,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 0,+ endColumn: 0,+ });+ });++ it('Should not loop selection when `loop` is false', async () => {+ select00();++ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: false,+ expandToGapFirst: false,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 19,+ endColumn: 19,+ });++ await commandService.executeCommand<ISelectAllCommandParams>(SelectAllCommand.id, {+ loop: false,+ expandToGapFirst: false,+ });+ expect(selectionManagerService.getLast()!.rangeData).toEqual({+ startRow: 0,+ startColumn: 0,+ endRow: 19,+ endColumn: 19,+ });+ });+ });});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 3f9315ccb9..975293417c 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@@ -1,4 +1,5 @@import {+ FontItalic,FontWeight,ICommandService,ICurrentUniverService,@@ -12,10 +13,16 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../../services/selection-manager.service';import { SetRangeStyleMutation } from '../../mutations/set-range-styles.mutation';-import { SetBoldCommand, SetStyleCommand } from '../set-style.command';+import {+ SetBoldCommand,+ SetItalicCommand,+ SetStrikeThroughCommand,+ SetStyleCommand,+ SetUnderlineCommand,+} from '../set-style.command';import { createCommandTestBed } from './create-command-test-bed';-describe('Test style commands', () => {+describe("Test commands used for updating cells' styles", () => {let univer: Univer;let get: Injector['get'];let commandService: ICommandService;@@ -36,18 +43,38 @@ describe('Test style commands', () => {});describe('bold', () => {+ beforeEach(() => {+ const testBed = createCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ commandService.registerCommand(SetBoldCommand);+ commandService.registerCommand(SetStyleCommand);+ commandService.registerCommand(SetRangeStyleMutation);+ });+describe('correct situations', () => {it('will toggle bold style when there is a selected range', async () => {- const selectionManager = get(SelectionManagerService);- selectionManager.setCurrentSelection({+ const selectionManagerService = get(SelectionManagerService);+ selectionManagerService.setCurrentSelection({pluginName: NORMAL_SELECTION_PLUGIN_NAME,unitId: 'test',sheetId: 'sheet1',});- selectionManager.add([+ selectionManagerService.add([{rangeData: { startRow: 0, startColumn: 0, endColumn: 0, endRow: 0 },- cellRange: null,+ cellRange: {+ startRow: 0,+ startColumn: 0,+ endColumn: 0,+ endRow: 0,+ column: 0,+ row: 0,+ isMerged: false,+ isMergedMainCell: false,+ },selectionType: SELECTION_TYPE.NORMAL,style: null,},@@ -82,4 +109,183 @@ describe('Test style commands', () => {});});});++ describe('italic', () => {+ beforeEach(() => {+ const testBed = createCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ commandService.registerCommand(SetItalicCommand);+ commandService.registerCommand(SetStyleCommand);+ commandService.registerCommand(SetRangeStyleMutation);+ });++ describe('correct situations', () => {+ it('will toggle italic style when there is a selected range', async () => {+ const selectionManager = get(SelectionManagerService);+ selectionManager.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });+ selectionManager.add([+ {+ rangeData: { startRow: 0, startColumn: 0, endColumn: 1, endRow: 0 },+ cellRange: {+ startRow: 0,+ startColumn: 0,+ endColumn: 0,+ endRow: 0,+ column: 0,+ row: 0,+ isMerged: false,+ isMergedMainCell: false,+ },+ selectionType: SELECTION_TYPE.NORMAL,+ style: null,+ },+ ]);++ function getFontItalic(+ startRow: number,+ startColumn: number,+ endRow: number,+ endColumn: number+ ): boolean | undefined {+ return (+ get(ICurrentUniverService)+ .getUniverSheetInstance('test')+ ?.getWorkBook()+ .getSheetBySheetId('sheet1')+ ?.getRange(startRow, startColumn, endRow, endColumn)+ .getFontStyle() === FontItalic.ITALIC+ );+ }++ 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();+ });+ });+ });++ describe('stroke-through', () => {+ beforeEach(() => {+ const testBed = createCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ commandService.registerCommand(SetStrikeThroughCommand);+ commandService.registerCommand(SetStyleCommand);+ commandService.registerCommand(SetRangeStyleMutation);+ });++ describe('correct situations', () => {+ it('will toggle italic style when there is a selected range', async () => {+ const selectionManager = get(SelectionManagerService);+ selectionManager.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });+ selectionManager.add([+ {+ rangeData: { startRow: 0, startColumn: 0, endColumn: 1, endRow: 0 },+ cellRange: {+ startRow: 0,+ startColumn: 0,+ endColumn: 0,+ endRow: 0,+ column: 0,+ row: 0,+ isMerged: false,+ isMergedMainCell: false,+ },+ selectionType: SELECTION_TYPE.NORMAL,+ style: null,+ },+ ]);++ function getStrokeThrough(+ startRow: number,+ startColumn: number,+ endRow: number,+ endColumn: number+ ): boolean | undefined {+ return !!get(ICurrentUniverService)+ .getUniverSheetInstance('test')+ ?.getWorkBook()+ .getSheetBySheetId('sheet1')+ ?.getRange(startRow, startColumn, endRow, endColumn)+ .getStrikeThrough().s;+ }++ expect(await commandService.executeCommand(SetStrikeThroughCommand.id)).toBeTruthy();+ expect(getStrokeThrough(0, 0, 0, 0)).toBeTruthy(); // it should work for every cell in selection+ expect(getStrokeThrough(0, 0, 0, 1)).toBeTruthy();+ });+ });+ });++ describe('underlined', () => {+ beforeEach(() => {+ const testBed = createCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ commandService.registerCommand(SetUnderlineCommand);+ commandService.registerCommand(SetStyleCommand);+ commandService.registerCommand(SetRangeStyleMutation);+ });++ describe('correct situations', () => {+ it('will toggle italic style when there is a selected range', async () => {+ const selectionManager = get(SelectionManagerService);+ selectionManager.setCurrentSelection({+ pluginName: NORMAL_SELECTION_PLUGIN_NAME,+ unitId: 'test',+ sheetId: 'sheet1',+ });+ selectionManager.add([+ {+ rangeData: { startRow: 0, startColumn: 0, endColumn: 1, endRow: 0 },+ cellRange: {+ startRow: 0,+ startColumn: 0,+ endColumn: 0,+ endRow: 0,+ column: 0,+ row: 0,+ isMerged: false,+ isMergedMainCell: false,+ },+ selectionType: SELECTION_TYPE.NORMAL,+ style: null,+ },+ ]);++ function getUnderlined(+ startRow: number,+ startColumn: number,+ endRow: number,+ endColumn: number+ ): boolean | undefined {+ return !!get(ICurrentUniverService)+ .getUniverSheetInstance('test')+ ?.getWorkBook()+ .getSheetBySheetId('sheet1')+ ?.getRange(startRow, startColumn, endRow, endColumn)+ .getUnderline().s;+ }++ expect(await commandService.executeCommand(SetUnderlineCommand.id)).toBeTruthy();+ expect(getUnderlined(0, 0, 0, 0)).toBeTruthy(); // it should work for every cell in selection+ expect(getUnderlined(0, 0, 0, 1)).toBeTruthy();+ });+ });+ });});diff --git a/packages/base-sheets/src/commands/commands/set-selections.command.ts b/packages/base-sheets/src/commands/commands/set-selections.command.tsindex 33181719ec..5870285dd0 100644--- a/packages/base-sheets/src/commands/commands/set-selections.command.ts+++ b/packages/base-sheets/src/commands/commands/set-selections.command.ts@@ -4,7 +4,6 @@ import {ICommand,ICommandService,ICurrentUniverService,- ILogService,ISelectionRange,Rectangle,} from '@univerjs/core';@@ -27,9 +26,7 @@ import {export interface IChangeSelectionCommandParams {direction: Direction;-jumpOver?: boolean;- expand?: boolean;}export const ChangeSelectionCommand: ICommand<IChangeSelectionCommandParams> = {@@ -65,7 +62,7 @@ export const ChangeSelectionCommand: ICommand<IChangeSelectionCommandParams> = {pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{- rangeData: destRange,+ rangeData: Rectangle.clone(destRange),cellRange: getRangeAtPosition(destRange.startRow, destRange.startColumn, currentWorksheet),},],@@ -172,7 +169,6 @@ export const SelectAllCommand: ICommand<ISelectAllCommandParams> = {handler: async (accessor, params = { expandToGapFirst: true, loop: false }) => {const selectionManager = accessor.get(SelectionManagerService);const currentUniverService = accessor.get(ICurrentUniverService);- const logService = accessor.get(ILogService);const currentSelection = selectionManager.getLast();const currentWorkbook = currentUniverService.getCurrentUniverSheetInstance()?.getWorkBook();diff --git a/packages/base-sheets/src/commands/commands/set-style.command.ts b/packages/base-sheets/src/commands/commands/set-style.command.tsindex 72e4502490..7719604a30 100644--- a/packages/base-sheets/src/commands/commands/set-style.command.ts+++ b/packages/base-sheets/src/commands/commands/set-style.command.ts@@ -126,19 +126,19 @@ export const SetBoldCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-bold',handler: async (accessor) => {- const commandService = accessor.get(ICommandService);- const selectionManagerService = accessor.get(SelectionManagerService);- const selectedRange = selectionManagerService.getLast()?.rangeData;- const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();-- let currentlyBold = true;- if (selectedRange) {- currentlyBold =- worksheet.getRange(selectedRange.startRow, selectedRange.startColumn).getFontWeight() ===- FontWeight.BOLD;+ const selection = accessor.get(SelectionManagerService).getLast();+ if (!selection) {+ return false;}+ const worksheet = accessor+ .get(ICurrentUniverService)+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet();+ const currentlyBold =+ worksheet.getRange(selection.cellRange.row, selection.cellRange.column).getFontWeight() === FontWeight.BOLD;+const setStyleParams: ISetStyleParams<BooleanNumber> = {style: {type: 'bl',@@ -146,7 +146,7 @@ export const SetBoldCommand: ICommand = {},};- return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ return accessor.get(ICommandService).executeCommand(SetStyleCommand.id, setStyleParams);},};@@ -157,17 +157,20 @@ export const SetItalicCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-italic',handler: async (accessor) => {- const commandService = accessor.get(ICommandService);- const selectionManagerService = accessor.get(SelectionManagerService);- const cellRange = selectionManagerService.getLast()?.cellRange;- const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();-- let currentlyItalic = true;- if (cellRange) {- currentlyItalic = worksheet.getRange(cellRange.row, cellRange.column).getFontStyle() === FontItalic.ITALIC;+ const selection = accessor.get(SelectionManagerService).getLast();+ if (!selection) {+ return false;}+ const worksheet = accessor+ .get(ICurrentUniverService)+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet();+ const currentlyItalic =+ worksheet.getRange(selection.cellRange.row, selection.cellRange.column).getFontStyle() ===+ FontItalic.ITALIC;+const setStyleParams: ISetStyleParams<BooleanNumber> = {style: {type: 'it',@@ -175,7 +178,7 @@ export const SetItalicCommand: ICommand = {},};- return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ return accessor.get(ICommandService).executeCommand(SetStyleCommand.id, setStyleParams);},};@@ -185,18 +188,21 @@ export const SetItalicCommand: ICommand = {export const SetUnderlineCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-underline',- handler: async (accessor, params) => {- const commandService = accessor.get(ICommandService);- const selectionManagerService = accessor.get(SelectionManagerService);- const cellRange = selectionManagerService.getLast()?.cellRange;- const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();-- let currentlyUnderline = true;- if (cellRange) {- currentlyUnderline = !!worksheet.getRange(cellRange.row, cellRange.column).getUnderline().s;+ handler: async (accessor) => {+ const selection = accessor.get(SelectionManagerService).getLast();+ if (!selection) {+ return false;}+ const worksheet = accessor+ .get(ICurrentUniverService)+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet();+ const currentlyUnderline = !!worksheet+ .getRange(selection.cellRange.row, selection.cellRange.column)+ .getUnderline().s;+const setStyleParams: ISetStyleParams<{ s: number }> = {style: {type: 'ul',@@ -206,7 +212,7 @@ export const SetUnderlineCommand: ICommand = {},};- return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ return accessor.get(ICommandService).executeCommand(SetStyleCommand.id, setStyleParams);},};@@ -216,19 +222,21 @@ export const SetUnderlineCommand: ICommand = {export const SetStrikeThroughCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-stroke',- handler: async (accessor, params) => {- const commandService = accessor.get(ICommandService);-- const selectionManagerService = accessor.get(SelectionManagerService);- const cellRange = selectionManagerService.getLast()?.cellRange;- const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();-- let currentlyStrokeThrough = true;- if (cellRange) {- currentlyStrokeThrough = !!worksheet.getRange(cellRange.row, cellRange.column).getStrikeThrough().s;+ handler: async (accessor) => {+ const selection = accessor.get(SelectionManagerService).getLast();+ if (!selection) {+ return false;}+ const worksheet = accessor+ .get(ICurrentUniverService)+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet();+ const currentlyStrokeThrough = !!worksheet+ .getRange(selection.cellRange.row, selection.cellRange.column)+ .getStrikeThrough().s;+const setStyleParams: ISetStyleParams<{ s: number }> = {style: {type: 'st',@@ -236,7 +244,7 @@ export const SetStrikeThroughCommand: ICommand = {},};- return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ return accessor.get(ICommandService).executeCommand(SetStyleCommand.id, setStyleParams);},};@@ -262,8 +270,6 @@ export const SetFontFamilyCommand: ICommand<ISetFontFamilyCommandParams> = {return commandService.executeCommand(SetStyleCommand.id, setStyleParams);},- // all subsequent mutations should succeed inorder to make the whole process succeed- // Promise.all([]).then(() => true),};export interface ISetFontSizeCommandParams {diff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.tsindex 1f7fa1b818..121267677f 100644--- a/packages/base-sheets/src/index.ts+++ b/packages/base-sheets/src/index.ts@@ -12,62 +12,51 @@ export { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from './service// #region commands-// mutationsexport {- InsertColMutation,- InsertColMutationFactory,- InsertRowMutation,- InsertRowMutationFactory,-} from './commands/mutations/insert-row-col.mutation';-export { InsertSheetMutation, InsertSheetUndoMutationFactory } from './commands/mutations/insert-sheet.mutation';-export { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from './commands/mutations/remove-sheet.mutation';-export { ISetRangeStyleMutationParams, SetRangeStyleMutation } from './commands/mutations/set-range-styles.mutation';-export { ISetRangeValuesMutationParams, SetRangeValuesMutation } from './commands/mutations/set-range-values.mutation';-export { SetTabColorMutation } from './commands/mutations/set-tab-color.mutation';-export { SetWorksheetActivateMutation } from './commands/mutations/set-worksheet-activate.mutation';-export {- SetWorksheetColWidthMutation,- SetWorksheetColWidthMutationFactory,-} from './commands/mutations/set-worksheet-col-width.mutation';-export { SetWorksheetHideMutation } from './commands/mutations/set-worksheet-hide.mutation';-export { SetWorksheetNameMutation } from './commands/mutations/set-worksheet-name.mutation';-export { SetWorksheetOrderMutation } from './commands/mutations/set-worksheet-order.mutation';--// operations-export { SetSelectionsOperation } from './commands/operations/selection.operation';--// commands+ AddWorksheetMergeAllCommand,+ AddWorksheetMergeCommand,+ AddWorksheetMergeHorizontalCommand,+ AddWorksheetMergeVerticalCommand,+} from './commands/commands/add-worksheet-merge.command';export { ClearSelectionContentCommand } from './commands/commands/clear-selection-content.command';+export { CopySheetCommand } from './commands/commands/copy-worksheet.command';export { DeleteRangeMoveLeftCommand } from './commands/commands/delete-range-move-left.command';export { DeleteRangeMoveUpCommand } from './commands/commands/delete-range-move-up.command';+export type { InsertColCommandParams, InsertRowCommandParams } from './commands/commands/insert-row-col.command';export {InsertColAfterCommand,InsertColBeforeCommand,InsertColCommand,- InsertColCommandParams,InsertRowAfterCommand,InsertRowBeforeCommand,InsertRowCommand,- InsertRowCommandParams,} from './commands/commands/insert-row-col.command';export { InsertSheetCommand } from './commands/commands/insert-sheet.command';export { RemoveColCommand, RemoveRowCommand } from './commands/commands/remove-row-col.command';-export {+export { RemoveSheetCommand } from './commands/commands/remove-sheet.command';+export { RemoveWorksheetMergeCommand } from './commands/commands/remove-worksheet-merge.command';+export type {ISetBorderColorCommandParams,ISetBorderCommandParams,ISetBorderPositionCommandParams,ISetBorderStyleCommandParams,+} from './commands/commands/set-border-command';+export {SetBorderColorCommand,SetBorderCommand,SetBorderPositionCommand,SetBorderStyleCommand,} from './commands/commands/set-border-command';-export {- ChangeSelectionCommand,- ExpandSelectionCommand,+export type { ISetRangeValuesCommandParams } from './commands/commands/set-range-values.command';+export { SetRangeValuesCommand } from './commands/commands/set-range-values.command';+export type {IChangeSelectionCommandParams,IExpandSelectionCommandParams,ISelectAllCommandParams,+} from './commands/commands/set-selections.command';+export {+ ChangeSelectionCommand,+ ExpandSelectionCommand,SelectAllCommand,} from './commands/commands/set-selections.command';export {@@ -87,26 +76,38 @@ export {SetUnderlineCommand,SetVerticalTextAlignCommand,} from './commands/commands/set-style.command';+export { SetTabColorCommand } from './commands/commands/set-tab-color.command';export { SetWorksheetActivateCommand } from './commands/commands/set-worksheet-activate.command';export { SetWorksheetColWidthCommand } from './commands/commands/set-worksheet-col-width.command';-export { SetWorksheetOrderCommand } from './commands/commands/set-worksheet-order.command';-export { SetWorksheetRowHeightCommand } from './commands/commands/set-worksheet-row-height.command';--// #endregion-export {- AddWorksheetMergeAllCommand,- AddWorksheetMergeCommand,- AddWorksheetMergeHorizontalCommand,- AddWorksheetMergeVerticalCommand,-} from './commands/commands/add-worksheet-merge.command';-export { CopySheetCommand } from './commands/commands/copy-worksheet.command';-export { RemoveSheetCommand } from './commands/commands/remove-sheet.command';-export { RemoveWorksheetMergeCommand } from './commands/commands/remove-worksheet-merge.command';-export { ISetRangeValuesCommandParams, SetRangeValuesCommand } from './commands/commands/set-range-values.command';-export { SetTabColorCommand } from './commands/commands/set-tab-color.command';export { SetWorksheetHideCommand } from './commands/commands/set-worksheet-hide.command';export { SetWorksheetNameCommand } from './commands/commands/set-worksheet-name.command';+export { SetWorksheetOrderCommand } from './commands/commands/set-worksheet-order.command';+export { SetWorksheetRowHeightCommand } from './commands/commands/set-worksheet-row-height.command';export { SetWorksheetRowHideCommand } from './commands/commands/set-worksheet-row-hide.command';export { SetWorksheetRowShowCommand } from './commands/commands/set-worksheet-row-show.command';export { SetWorksheetShowCommand } from './commands/commands/set-worksheet-show.command';+export {+ InsertColMutation,+ InsertColMutationFactory,+ InsertRowMutation,+ InsertRowMutationFactory,+} from './commands/mutations/insert-row-col.mutation';+export { InsertSheetMutation, InsertSheetUndoMutationFactory } from './commands/mutations/insert-sheet.mutation';+export { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from './commands/mutations/remove-sheet.mutation';+export type { ISetRangeStyleMutationParams } from './commands/mutations/set-range-styles.mutation';+export { SetRangeStyleMutation } from './commands/mutations/set-range-styles.mutation';+export type { ISetRangeValuesMutationParams } from './commands/mutations/set-range-values.mutation';+export { SetRangeValuesMutation } from './commands/mutations/set-range-values.mutation';+export { SetTabColorMutation } from './commands/mutations/set-tab-color.mutation';+export { SetWorksheetActivateMutation } from './commands/mutations/set-worksheet-activate.mutation';+export {+ SetWorksheetColWidthMutation,+ SetWorksheetColWidthMutationFactory,+} from './commands/mutations/set-worksheet-col-width.mutation';+export { SetWorksheetHideMutation } from './commands/mutations/set-worksheet-hide.mutation';+export { SetWorksheetNameMutation } from './commands/mutations/set-worksheet-name.mutation';+export { SetWorksheetOrderMutation } from './commands/mutations/set-worksheet-order.mutation';+export { SetSelectionsOperation } from './commands/operations/selection.operation';export * from './Locale';++// #endregiondiff --git a/packages/base-sheets/src/services/selection-manager.service.ts b/packages/base-sheets/src/services/selection-manager.service.tsindex 7ce61d5587..1fb067dd2c 100644--- a/packages/base-sheets/src/services/selection-manager.service.ts+++ b/packages/base-sheets/src/services/selection-manager.service.ts@@ -4,7 +4,7 @@ import {mergeCellHandler,NORMAL_SELECTION_PLUGIN_STYLE,} from '@univerjs/base-render';-import { ISelectionRange, makeCellRangeToRangeData, Nullable } from '@univerjs/core';+import { ISelectionCell, ISelectionRange, makeCellRangeToRangeData, Nullable } from '@univerjs/core';import { IDisposable } from '@wendellhu/redi';import { BehaviorSubject } from 'rxjs';@@ -121,8 +121,11 @@ export class SelectionManagerService implements IDisposable {return this._getFirstByParam(this._currentSelection);}- getLast(): Readonly<Nullable<ISelectionRangeWithStyle>> {- return this._getLastByParam(this._currentSelection);+ getLast(): Readonly<Nullable<ISelectionRangeWithStyle & { cellRange: ISelectionCell }>> {+ // The last selection position must have a cellRange.+ return this._getLastByParam(this._currentSelection) as Readonly<+ Nullable<ISelectionRangeWithStyle & { cellRange: ISelectionCell }>+ >;}add(selectionDatas: ISelectionRangeWithStyle[]) {diff --git a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.tsindex 161bafcab6..bbb41b609a 100644--- a/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts+++ b/packages/common-plugin-data/src/Sheets/DEFAULT_WORKBOOK_DATA.ts@@ -1,1100 +1,1090 @@-import {- BaselineOffset,- BooleanNumber,- BorderStyleTypes,- BulletAlignment,- ColumnSeparatorType,- GlyphType,- HorizontalAlign,- IDocumentData,- IWorkbookConfig,- LocaleType,- ObjectRelativeFromH,- ObjectRelativeFromV,- PositionedObjectLayoutType,- SectionType,- SheetTypes,- Tools,- VerticalAlign,- WrapStrategy,- WrapTextType,-} from '@univerjs/core';--const richTextTestFloat: IDocumentData = {- id: 'd',- drawings: {- shapeTest1: {- objectId: 'shapeTest1',- objectProperties: {- title: 'test shape',- description: 'test shape',- size: {- width: 100,- height: 400,- },- positionH: {- relativeFrom: ObjectRelativeFromH.COLUMN,- posOffset: 100,- },- positionV: {- relativeFrom: ObjectRelativeFromV.PARAGRAPH,- posOffset: 160,- },- angle: 0,- imageProperties: {- contentUrl: 'https://cnbabylon.com/assets/img/agents.png',- },- },- layoutType: PositionedObjectLayoutType.WRAP_SQUARE,- behindDoc: BooleanNumber.FALSE,- wrapText: WrapTextType.BOTH_SIDES,- },- },- lists: {- unorderedTest: {- listId: 'unorderedTest',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %0',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25CF',- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25A0',- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphSymbol: '\u25C6',- hanging: 21,- indentStart: 63,- },- ],- },- testBullet: {- listId: 'testBullet',- nestingLevel: [- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 21,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2)',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 42,- },- {- bulletAlignment: BulletAlignment.START,- glyphFormat: ' %1.%2.%3.',- textStyle: {- fs: 12,- },- startNumber: 0,- glyphType: GlyphType.ROMAN,- hanging: 21,- indentStart: 63,- },- ],- },- },- body: {- dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r\n`,- textRuns: [- {- st: 0,- ed: 15,- ts: {- fs: 12,- bg: {- rgb: 'rgb(200,0,90)',- },- cl: {- rgb: 'rgb(255,130,0)',- },- },- },- {- st: 17,- ed: 18,- ts: {- fs: 14,- bg: {- rgb: 'rgb(2,128,2)',- },- cl: {- rgb: 'rgb(0,1,55)',- },- va: BaselineOffset.SUPERSCRIPT,- },- },- {- st: 19,- ed: 60,- ts: {- fs: 14,- bg: {- rgb: 'rgb(90,128,255)',- },- cl: {- rgb: 'rgb(0,1,255)',- },- },- },- ],- paragraphs: [- {- startIndex: 60,- bullet: {- listId: 'testBullet',- nestingLevel: 0,- textStyle: {- fs: 20,- },- },- },- ],- sectionBreaks: [- {- startIndex: 61,- columnProperties: [- {- width: 200,- paddingEnd: 20,- },- ],- columnSeparatorType: ColumnSeparatorType.NONE,- sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,- // textDirection: textDirectionDocument,- // contentDirection: textDirection!,- },- ],- },- documentStyle: {- pageSize: {- width: Infinity,- height: Infinity,- },- marginTop: 0,- marginBottom: 0,- marginRight: 2,- marginLeft: 2,- },-};--const richTextTest: IDocumentData = {- id: 'd',- body: {- dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r\n`,- textRuns: [- {- st: 0,- ed: 15,- ts: {- fs: 12,- bg: {- rgb: 'rgb(200,0,90)',- },- cl: {- rgb: 'rgb(255,130,0)',- },- },- },- {- st: 17,- ed: 18,- ts: {- fs: 14,- bg: {- rgb: 'rgb(2,128,2)',- },- cl: {- rgb: 'rgb(0,1,55)',- },- va: BaselineOffset.SUPERSCRIPT,- },- },- {- st: 19,- ed: 60,- ts: {- fs: 14,- bg: {- rgb: 'rgb(90,128,255)',- },- cl: {- rgb: 'rgb(0,1,255)',- },- },- },- ],- paragraphs: [- {- startIndex: 60,- bullet: {- listId: 'testBullet',- nestingLevel: 0,- textStyle: {- fs: 20,- },- },- },- ],- sectionBreaks: [- {- startIndex: 61,- columnProperties: [- {- width: 200,- paddingEnd: 20,- },- ],- columnSeparatorType: ColumnSeparatorType.NONE,- sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,- // textDirection: textDirectionDocument,- // contentDirection: textDirection!,- },- ],- },- documentStyle: {- pageSize: {- width: Infinity,- height: Infinity,- },- marginTop: 0,- marginBottom: 0,- marginRight: 2,- marginLeft: 2,- },-};--/**- * Default workbook data- */-export const DEFAULT_WORKBOOK_DATA: IWorkbookConfig = {- id: 'workbook-01',- theme: 'default',- locale: LocaleType.EN,- creator: 'univer',- name: 'universheet',- skin: 'default',- socketUrl: '',- socketEnable: BooleanNumber.FALSE,- extensions: [],- sheetOrder: ['sheet-01', 'sheet-02', 'sheet-03', 'sheet-04', 'sheet-05', 'sheet-06'],- pluginMeta: {},- styles: {- '1': {- cl: {- rgb: 'blue',- },- fs: 16,- bd: {- t: {- s: BorderStyleTypes.MEDIUM_DASHED,- cl: {- rgb: 'black',- },- },- l: {- s: BorderStyleTypes.MEDIUM_DASHED,- cl: {- rgb: 'black',- },- },- r: {- s: BorderStyleTypes.THICK,- cl: {- rgb: 'black',- },- },- b: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'red',- },- },- },- ht: 3,- },- '2': {- bg: {- rgb: 'rgb(200, 2, 0)',- },- fs: 24,- ht: HorizontalAlign.RIGHT,- vt: VerticalAlign.TOP,- },- '3': {- ht: HorizontalAlign.RIGHT,- vt: VerticalAlign.MIDDLE,- tb: WrapStrategy.WRAP,- // va: BaselineOffset.SUPERSCRIPT,- // cl: {- // rgb: 'rgb(0, 255, 0)',- // },- // st: {- // s: BooleanNumber.TRUE, // show- // },- bg: {- rgb: 'rgb(255, 255, 0)',- },- tr: {- a: 45,- v: BooleanNumber.FALSE,- },- bd: {- t: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- l: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- r: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- b: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'red',- },- },- },- },- '4': {- bg: {- rgb: 'rgb(0, 0, 255)',- },- },- '5': {- tb: WrapStrategy.WRAP,- },- },- timeZone: 'GMT+8',- createdTime: '2021-11-28 12:10:10',- modifiedTime: '2021-11-29 12:10:10',- appVersion: '3.0.0-alpha',- lastModifiedBy: 'univer',- sheets: {- 'sheet-01': {- type: SheetTypes.GRID,- id: 'sheet-01',- cellData: {- '0': {- '0': {- s: '1',- v: 1,- m: '1',- },- '1': {- s: '1',- v: 1,- m: '1',- },- '5': {- s: '1',- v: 8,- m: '8',- },- '6': {- s: '2',- v: 8,- m: '8',- },- },- '1': {- '0': {- v: 1,- m: '1',- },- '1': {- v: 1,- m: '1',- },- '2': {- v: 80,- m: '80',- s: '3',- },- '3': {- v: '富文本编辑',- m: '富文本编辑',- s: '2',- },- },- '2': {- '0': {- v: 1111,- m: '1111',- },- '1': {- v: 1111,- m: '1111',- },- '5': {- s: '1',- v: 8,- m: '8',- },- '6': {- s: '1',- v: 8,- m: '8',- },- '7': {- s: '1',- v: 8,- m: '8',- },- '8': {- s: '1',- v: 8,- m: '8',- },- },- '3': {- '0': {- v: 1111,- m: '1111',- },- '1': {- v: 1111,- m: '1111',- },- },- '10': {- '9': {- v: 1111,- s: '2',- m: '1111',- },- },- '13': {- '9': {- v: 1111,- s: '4',- m: '1111',- },- },- '17': {- '3': {- v: '做移动端开发和前端开发的人员,对 MVC、MVP、MVVM 这几个名词应该都不陌生,这是三个最常用的应用架构模式,目的都是为了将业务和视图的实现代码分离',- s: '3',- p: richTextTest,- },- },- '20': {- '10': {- v: '北京马拉松组委会办公室一位接电话的女士证实,的确有这项规定,她还称2014年马拉松的预登记工作将在本周启动。北京马拉松比赛将在10月19日举行。',- s: '3',- },- '12': {- s: '4',- },- },- '29': {- '13': {- p: Tools.deepClone(richTextTest),- s: '4',- },- },- '32': {- '3': {- p: richTextTestFloat,- s: '5',- },- },- },- name: 'sheet1',- tabColor: 'red',- hidden: BooleanNumber.FALSE,- freezeColumn: 1,- rowCount: 1000,- columnCount: 20,- freezeRow: 1,- zoomRatio: 1,- scrollTop: 200,- scrollLeft: 100,- defaultColumnWidth: 93,- defaultRowHeight: 27,- mergeData: [- {- startRow: 0,- endRow: 1,- startColumn: 0,- endColumn: 1,- },- {- startRow: 2,- endRow: 6,- startColumn: 5,- endColumn: 10,- },- {- startRow: 10,- endRow: 12,- startColumn: 9,- endColumn: 12,- },- {- startRow: 10,- endRow: 12,- startColumn: 9,- endColumn: 12,- },- {- startRow: 17,- endRow: 21,- startColumn: 3,- endColumn: 6,- },- {- startRow: 13,- endRow: 15,- startColumn: 9,- endColumn: 10,- },- {- startRow: 24,- endRow: 27,- startColumn: 9,- endColumn: 10,- },- {- startRow: 32,- endRow: 53,- startColumn: 3,- endColumn: 5,- },- ],- rowData: {- '3': {- h: 50,- hd: BooleanNumber.FALSE,- },- '4': {- h: 60,- hd: BooleanNumber.FALSE,- },- '29': {- h: 200,- hd: BooleanNumber.FALSE,- },- },- columnData: {- '5': {- w: 100,- hd: BooleanNumber.FALSE,- },- '6': {- w: 200,- hd: BooleanNumber.FALSE,- },- '13': {- w: 300,- hd: BooleanNumber.FALSE,- },- },- status: 1,- showGridlines: 1,- hideRow: [],- hideColumn: [],- rowHeader: {- width: 46,- hidden: BooleanNumber.FALSE,- },- columnHeader: {- height: 20,- hidden: BooleanNumber.FALSE,- },- selections: ['A2'],- rightToLeft: BooleanNumber.FALSE,- pluginMeta: {},- // metaData: [],- },- 'sheet-02': {- type: SheetTypes.GRID,- id: 'sheet-02',- name: 'sheet2',- cellData: {- '0': {- '0': {- s: '1',- v: 1,- m: '1',- },- '1': {- s: '1',- v: 1,- m: '1',- },- '5': {- s: '1',- v: 8,- m: '8',- },- '6': {- s: '2',- v: 8,- m: '8',- },- },- '20': {- '0': {- v: 'sheet2',- m: 'sheet2',- },- '1': {- v: 'sheet2 - 2',- m: 'sheet2 - 2',- },- },- },- },- 'sheet-03': {- type: SheetTypes.GRID,- id: 'sheet-03',- name: 'sheet3',- },- 'sheet-04': {- type: SheetTypes.GRID,- id: 'sheet-04',- name: 'sheet4',- },- 'sheet-05': {- type: SheetTypes.GRID,- id: 'sheet-05',- name: 'sheet5',- },- 'sheet-06': {- type: SheetTypes.GRID,- id: 'sheet-06',- name: 'sheet6',- },- },- namedRanges: [- {- namedRangeId: 'named-range-01',- name: 'namedRange01',- range: {- sheetId: 'sheet-01',- rangeData: {- startRow: 0,- startColumn: 0,- endRow: 1,- endColumn: 1,- },- },- },- {- namedRangeId: 'named-range-02',- name: 'namedRange02',- range: {- sheetId: 'sheet-01',- rangeData: {- startRow: 4,- startColumn: 2,- endRow: 5,- endColumn: 3,- },- },- },- ],-};-/**- * Default workbook data- */-export const DEFAULT_WORKBOOK_DATA_DOWN: IWorkbookConfig = {- id: 'workbook-02',- theme: 'default',- locale: LocaleType.EN,- creator: 'univer',- name: 'universheet',- skin: 'default',- socketUrl: '',- socketEnable: BooleanNumber.FALSE,- extensions: [],- sheetOrder: [],- pluginMeta: {},- styles: {- '1': {- cl: {- rgb: 'green',- },- fs: 16,- bd: {- t: {- s: BorderStyleTypes.MEDIUM_DASHED,- cl: {- rgb: 'black',- },- },- l: {- s: BorderStyleTypes.MEDIUM_DASHED,- cl: {- rgb: 'black',- },- },- r: {- s: BorderStyleTypes.THICK,- cl: {- rgb: 'black',- },- },- b: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'blue',- },- },- },- ht: 3,- },- '2': {- bg: {- rgb: 'rgb(2, 200, 0)',- },- fs: 24,- },- '3': {- ht: HorizontalAlign.RIGHT,- vt: VerticalAlign.TOP,- tb: WrapStrategy.WRAP,- // va: BaselineOffset.SUPERSCRIPT,- // cl: {- // rgb: 'rgb(0, 255, 0)',- // },- // st: {- // s: BooleanNumber.TRUE, // show- // },- bg: {- rgb: 'rgb(255, 255, 0)',- },- tr: {- a: 45,- v: BooleanNumber.FALSE,- },- bd: {- t: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- l: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- r: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'black',- },- },- b: {- s: BorderStyleTypes.THIN,- cl: {- rgb: 'red',- },- },- },- },- '4': {- bg: {- rgb: 'rgb(0, 0, 255)',- },- },- },- timeZone: 'GMT+8',- createdTime: '2021-11-28 12:10:10',- modifiedTime: '2021-11-29 12:10:10',- appVersion: '3.0.0-alpha',- lastModifiedBy: 'univer',- sheets: {- 'sheet-0001': {- type: SheetTypes.GRID,- id: 'sheet-0001',- cellData: {- '0': {- '0': {- s: '1',- v: 2,- m: '2',- },- '1': {- s: '1',- v: 1,- m: '1',- },- '5': {- s: '1',- v: 8,- m: '8',- },- '6': {- s: '2',- v: 8,- m: '8',- },- },- '1': {- '0': {- v: 22,- m: '22',- },- '1': {- v: 22,- m: '22',- },- '2': {- v: 80,- m: '80',- s: '3',- },- '3': {- v: '富文本编辑',- m: '富文本编辑',- s: '2',- },- },- '2': {- '0': {- v: 2222,- m: '2222',- },- '1': {- v: 2222,- m: '2222',- },- '5': {- s: '1',- v: 8,- m: '8',- },- '6': {- s: '1',- v: 8,- m: '8',- },- '7': {- s: '1',- v: 8,- m: '8',- },- '8': {- s: '1',- v: 8,- m: '8',- },- },- '3': {- '0': {- v: 1111,- m: '1111',- },- '1': {- v: 1111,- m: '1111',- },- },- '10': {- '9': {- v: 1111,- s: '2',- m: '1111',- },- },- '13': {- '9': {- v: 1111,- s: '4',- m: '1111',- },- },- '17': {- '3': {- v: '做移动端开发和前端开发的人员,对 MVC、MVP、MVVM 这几个名词应该都不陌生,这是三个最常用的应用架构模式,目的都是为了将业务和视图的实现代码分离',- s: '3',- p: richTextTest,- },- },- '20': {- '10': {- v: '北京马拉松组委会办公室一位接电话的女士证实,的确有这项规定,她还称2014年马拉松的预登记工作将在本周启动。北京马拉松比赛将在10月19日举行。',- s: '3',- },- '12': {- s: '4',- },- },- '29': {- '13': {- p: Tools.deepClone(richTextTest),- s: '4',- },- },- },- name: 'sheet0001',- tabColor: 'green',- hidden: BooleanNumber.FALSE,- freezeColumn: 1,- rowCount: 1000,- columnCount: 20,- freezeRow: 1,- zoomRatio: 1,- scrollTop: 200,- scrollLeft: 100,- defaultColumnWidth: 93,- defaultRowHeight: 27,- mergeData: [- {- startRow: 0,- endRow: 1,- startColumn: 0,- endColumn: 1,- },- {- startRow: 2,- endRow: 6,- startColumn: 5,- endColumn: 10,- },- {- startRow: 10,- endRow: 12,- startColumn: 9,- endColumn: 12,- },- {- startRow: 10,- endRow: 12,- startColumn: 9,- endColumn: 12,- },- {- startRow: 17,- endRow: 21,- startColumn: 3,- endColumn: 6,- },- {- startRow: 13,- endRow: 15,- startColumn: 9,- endColumn: 10,- },- {- startRow: 24,- endRow: 27,- startColumn: 9,- endColumn: 10,- },- ],- rowData: {- '3': {- h: 50,- hd: BooleanNumber.FALSE,- },- '4': {- h: 60,- hd: BooleanNumber.FALSE,- },- '29': {- h: 200,- hd: BooleanNumber.FALSE,- },- },- columnData: {- '5': {- w: 100,- hd: BooleanNumber.FALSE,- },- '6': {- w: 200,- hd: BooleanNumber.FALSE,- },- '13': {- w: 300,- hd: BooleanNumber.FALSE,- },- },- status: 1,- showGridlines: 1,- hideRow: [],- hideColumn: [],- rowHeader: {- width: 46,- hidden: BooleanNumber.FALSE,- },- columnHeader: {- height: 20,- hidden: BooleanNumber.FALSE,- },- selections: ['A2'],- rightToLeft: BooleanNumber.FALSE,- pluginMeta: {},- // metaData: [],- },- 'sheet-0002': {- type: SheetTypes.GRID,- id: 'sheet-0002',- name: 'sheet0003',- },- },- namedRanges: [- {- namedRangeId: 'named-range-0001',- name: 'namedRange0001',- range: {- sheetId: 'sheet-0001',- rangeData: {- startRow: 0,- startColumn: 0,- endRow: 1,- endColumn: 1,- },- },- },- ],-};+import {+ BaselineOffset,+ BooleanNumber,+ BorderStyleTypes,+ BulletAlignment,+ ColumnSeparatorType,+ GlyphType,+ HorizontalAlign,+ IDocumentData,+ IWorkbookConfig,+ LocaleType,+ ObjectRelativeFromH,+ ObjectRelativeFromV,+ PositionedObjectLayoutType,+ SectionType,+ SheetTypes,+ Tools,+ VerticalAlign,+ WrapStrategy,+ WrapTextType,+} from '@univerjs/core';++const richTextTestFloat: IDocumentData = {+ id: 'd',+ drawings: {+ shapeTest1: {+ objectId: 'shapeTest1',+ objectProperties: {+ title: 'test shape',+ description: 'test shape',+ size: {+ width: 100,+ height: 400,+ },+ positionH: {+ relativeFrom: ObjectRelativeFromH.COLUMN,+ posOffset: 100,+ },+ positionV: {+ relativeFrom: ObjectRelativeFromV.PARAGRAPH,+ posOffset: 160,+ },+ angle: 0,+ imageProperties: {+ contentUrl: 'https://cnbabylon.com/assets/img/agents.png',+ },+ },+ layoutType: PositionedObjectLayoutType.WRAP_SQUARE,+ behindDoc: BooleanNumber.FALSE,+ wrapText: WrapTextType.BOTH_SIDES,+ },+ },+ lists: {+ unorderedTest: {+ listId: 'unorderedTest',+ nestingLevel: [+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %0',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphSymbol: '\u25CF',+ hanging: 21,+ indentStart: 21,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphSymbol: '\u25A0',+ hanging: 21,+ indentStart: 42,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphSymbol: '\u25C6',+ hanging: 21,+ indentStart: 63,+ },+ ],+ },+ testBullet: {+ listId: 'testBullet',+ nestingLevel: [+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 21,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.%2)',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 42,+ },+ {+ bulletAlignment: BulletAlignment.START,+ glyphFormat: ' %1.%2.%3.',+ textStyle: {+ fs: 12,+ },+ startNumber: 0,+ glyphType: GlyphType.ROMAN,+ hanging: 21,+ indentStart: 63,+ },+ ],+ },+ },+ body: {+ dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r\n`,+ textRuns: [+ {+ st: 0,+ ed: 15,+ ts: {+ fs: 12,+ bg: {+ rgb: 'rgb(200,0,90)',+ },+ cl: {+ rgb: 'rgb(255,130,0)',+ },+ },+ },+ {+ st: 17,+ ed: 18,+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(2,128,2)',+ },+ cl: {+ rgb: 'rgb(0,1,55)',+ },+ va: BaselineOffset.SUPERSCRIPT,+ },+ },+ {+ st: 19,+ ed: 60,+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(90,128,255)',+ },+ cl: {+ rgb: 'rgb(0,1,255)',+ },+ },+ },+ ],+ paragraphs: [+ {+ startIndex: 60,+ bullet: {+ listId: 'testBullet',+ nestingLevel: 0,+ textStyle: {+ fs: 20,+ },+ },+ },+ ],+ sectionBreaks: [+ {+ startIndex: 61,+ columnProperties: [+ {+ width: 200,+ paddingEnd: 20,+ },+ ],+ columnSeparatorType: ColumnSeparatorType.NONE,+ sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,+ // textDirection: textDirectionDocument,+ // contentDirection: textDirection!,+ },+ ],+ },+ documentStyle: {+ pageSize: {+ width: Infinity,+ height: Infinity,+ },+ marginTop: 0,+ marginBottom: 0,+ marginRight: 2,+ marginLeft: 2,+ },+};++const richTextTest: IDocumentData = {+ id: 'd',+ body: {+ dataStream: `在“第1题”工作表中完成以下操作\b上标日期列单元格数据验证,限制只能输入日期(介于1949年1月1日至2099年1月1日)\r\n`,+ textRuns: [+ {+ st: 0,+ ed: 15,+ ts: {+ fs: 12,+ bg: {+ rgb: 'rgb(200,0,90)',+ },+ cl: {+ rgb: 'rgb(255,130,0)',+ },+ },+ },+ {+ st: 17,+ ed: 18,+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(2,128,2)',+ },+ cl: {+ rgb: 'rgb(0,1,55)',+ },+ va: BaselineOffset.SUPERSCRIPT,+ },+ },+ {+ st: 19,+ ed: 60,+ ts: {+ fs: 14,+ bg: {+ rgb: 'rgb(90,128,255)',+ },+ cl: {+ rgb: 'rgb(0,1,255)',+ },+ },+ },+ ],+ paragraphs: [+ {+ startIndex: 60,+ bullet: {+ listId: 'testBullet',+ nestingLevel: 0,+ textStyle: {+ fs: 20,+ },+ },+ },+ ],+ sectionBreaks: [+ {+ startIndex: 61,+ columnProperties: [+ {+ width: 200,+ paddingEnd: 20,+ },+ ],+ columnSeparatorType: ColumnSeparatorType.NONE,+ sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,+ // textDirection: textDirectionDocument,+ // contentDirection: textDirection!,+ },+ ],+ },+ documentStyle: {+ pageSize: {+ width: Infinity,+ height: Infinity,+ },+ marginTop: 0,+ marginBottom: 0,+ marginRight: 2,+ marginLeft: 2,+ },+};++/**+ * Default workbook data+ */+export const DEFAULT_WORKBOOK_DATA: IWorkbookConfig = {+ id: 'workbook-01',+ locale: LocaleType.EN,+ creator: 'univer',+ name: 'universheet',+ extensions: [],+ sheetOrder: ['sheet-01', 'sheet-02', 'sheet-03', 'sheet-04', 'sheet-05', 'sheet-06'],+ styles: {+ '1': {+ cl: {+ rgb: 'blue',+ },+ fs: 16,+ bd: {+ t: {+ s: BorderStyleTypes.MEDIUM_DASHED,+ cl: {+ rgb: 'black',+ },+ },+ l: {+ s: BorderStyleTypes.MEDIUM_DASHED,+ cl: {+ rgb: 'black',+ },+ },+ r: {+ s: BorderStyleTypes.THICK,+ cl: {+ rgb: 'black',+ },+ },+ b: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'red',+ },+ },+ },+ ht: 3,+ },+ '2': {+ bg: {+ rgb: 'rgb(200, 2, 0)',+ },+ fs: 24,+ ht: HorizontalAlign.RIGHT,+ vt: VerticalAlign.TOP,+ },+ '3': {+ ht: HorizontalAlign.RIGHT,+ vt: VerticalAlign.MIDDLE,+ tb: WrapStrategy.WRAP,+ // va: BaselineOffset.SUPERSCRIPT,+ // cl: {+ // rgb: 'rgb(0, 255, 0)',+ // },+ // st: {+ // s: BooleanNumber.TRUE, // show+ // },+ bg: {+ rgb: 'rgb(255, 255, 0)',+ },+ tr: {+ a: 45,+ v: BooleanNumber.FALSE,+ },+ bd: {+ t: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ l: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ r: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ b: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'red',+ },+ },+ },+ },+ '4': {+ bg: {+ rgb: 'rgb(0, 0, 255)',+ },+ },+ '5': {+ tb: WrapStrategy.WRAP,+ },+ },+ timeZone: 'GMT+8',+ createdTime: '2021-11-28 12:10:10',+ modifiedTime: '2021-11-29 12:10:10',+ appVersion: '3.0.0-alpha',+ lastModifiedBy: 'univer',+ sheets: {+ 'sheet-01': {+ type: SheetTypes.GRID,+ id: 'sheet-01',+ cellData: {+ '0': {+ '0': {+ s: '1',+ v: 1,+ m: '1',+ },+ '1': {+ s: '1',+ v: 1,+ m: '1',+ },+ '5': {+ s: '1',+ v: 8,+ m: '8',+ },+ '6': {+ s: '2',+ v: 8,+ m: '8',+ },+ },+ '1': {+ '0': {+ v: 1,+ m: '1',+ },+ '1': {+ v: 1,+ m: '1',+ },+ '2': {+ v: 80,+ m: '80',+ s: '3',+ },+ '3': {+ v: '富文本编辑',+ m: '富文本编辑',+ s: '2',+ },+ },+ '2': {+ '0': {+ v: 1111,+ m: '1111',+ },+ '1': {+ v: 1111,+ m: '1111',+ },+ '5': {+ s: '1',+ v: 8,+ m: '8',+ },+ '6': {+ s: '1',+ v: 8,+ m: '8',+ },+ '7': {+ s: '1',+ v: 8,+ m: '8',+ },+ '8': {+ s: '1',+ v: 8,+ m: '8',+ },+ },+ '3': {+ '0': {+ v: 1111,+ m: '1111',+ },+ '1': {+ v: 1111,+ m: '1111',+ },+ },+ '10': {+ '9': {+ v: 1111,+ s: '2',+ m: '1111',+ },+ },+ '13': {+ '9': {+ v: 1111,+ s: '4',+ m: '1111',+ },+ },+ '17': {+ '3': {+ v: '做移动端开发和前端开发的人员,对 MVC、MVP、MVVM 这几个名词应该都不陌生,这是三个最常用的应用架构模式,目的都是为了将业务和视图的实现代码分离',+ s: '3',+ p: richTextTest,+ },+ },+ '20': {+ '10': {+ v: '北京马拉松组委会办公室一位接电话的女士证实,的确有这项规定,她还称2014年马拉松的预登记工作将在本周启动。北京马拉松比赛将在10月19日举行。',+ s: '3',+ },+ '12': {+ s: '4',+ },+ },+ '29': {+ '13': {+ p: Tools.deepClone(richTextTest),+ s: '4',+ },+ },+ '32': {+ '3': {+ p: richTextTestFloat,+ s: '5',+ },+ },+ },+ name: 'sheet1',+ tabColor: 'red',+ hidden: BooleanNumber.FALSE,+ freezeColumn: 1,+ rowCount: 1000,+ columnCount: 20,+ freezeRow: 1,+ zoomRatio: 1,+ scrollTop: 200,+ scrollLeft: 100,+ defaultColumnWidth: 93,+ defaultRowHeight: 27,+ mergeData: [+ {+ startRow: 0,+ endRow: 1,+ startColumn: 0,+ endColumn: 1,+ },+ {+ startRow: 2,+ endRow: 6,+ startColumn: 5,+ endColumn: 10,+ },+ {+ startRow: 10,+ endRow: 12,+ startColumn: 9,+ endColumn: 12,+ },+ {+ startRow: 10,+ endRow: 12,+ startColumn: 9,+ endColumn: 12,+ },+ {+ startRow: 17,+ endRow: 21,+ startColumn: 3,+ endColumn: 6,+ },+ {+ startRow: 13,+ endRow: 15,+ startColumn: 9,+ endColumn: 10,+ },+ {+ startRow: 24,+ endRow: 27,+ startColumn: 9,+ endColumn: 10,+ },+ {+ startRow: 32,+ endRow: 53,+ startColumn: 3,+ endColumn: 5,+ },+ ],+ rowData: {+ '3': {+ h: 50,+ hd: BooleanNumber.FALSE,+ },+ '4': {+ h: 60,+ hd: BooleanNumber.FALSE,+ },+ '29': {+ h: 200,+ hd: BooleanNumber.FALSE,+ },+ },+ columnData: {+ '5': {+ w: 100,+ hd: BooleanNumber.FALSE,+ },+ '6': {+ w: 200,+ hd: BooleanNumber.FALSE,+ },+ '13': {+ w: 300,+ hd: BooleanNumber.FALSE,+ },+ },+ status: 1,+ showGridlines: 1,+ hideRow: [],+ hideColumn: [],+ rowHeader: {+ width: 46,+ hidden: BooleanNumber.FALSE,+ },+ columnHeader: {+ height: 20,+ hidden: BooleanNumber.FALSE,+ },+ selections: ['A2'],+ rightToLeft: BooleanNumber.FALSE,+ pluginMeta: {},+ // metaData: [],+ },+ 'sheet-02': {+ type: SheetTypes.GRID,+ id: 'sheet-02',+ name: 'sheet2',+ cellData: {+ '0': {+ '0': {+ s: '1',+ v: 1,+ m: '1',+ },+ '1': {+ s: '1',+ v: 1,+ m: '1',+ },+ '5': {+ s: '1',+ v: 8,+ m: '8',+ },+ '6': {+ s: '2',+ v: 8,+ m: '8',+ },+ },+ '20': {+ '0': {+ v: 'sheet2',+ m: 'sheet2',+ },+ '1': {+ v: 'sheet2 - 2',+ m: 'sheet2 - 2',+ },+ },+ },+ },+ 'sheet-03': {+ type: SheetTypes.GRID,+ id: 'sheet-03',+ name: 'sheet3',+ },+ 'sheet-04': {+ type: SheetTypes.GRID,+ id: 'sheet-04',+ name: 'sheet4',+ },+ 'sheet-05': {+ type: SheetTypes.GRID,+ id: 'sheet-05',+ name: 'sheet5',+ },+ 'sheet-06': {+ type: SheetTypes.GRID,+ id: 'sheet-06',+ name: 'sheet6',+ },+ },+ namedRanges: [+ {+ namedRangeId: 'named-range-01',+ name: 'namedRange01',+ range: {+ sheetId: 'sheet-01',+ rangeData: {+ startRow: 0,+ startColumn: 0,+ endRow: 1,+ endColumn: 1,+ },+ },+ },+ {+ namedRangeId: 'named-range-02',+ name: 'namedRange02',+ range: {+ sheetId: 'sheet-01',+ rangeData: {+ startRow: 4,+ startColumn: 2,+ endRow: 5,+ endColumn: 3,+ },+ },+ },+ ],+};+/**+ * Default workbook data+ */+export const DEFAULT_WORKBOOK_DATA_DOWN: IWorkbookConfig = {+ id: 'workbook-02',+ locale: LocaleType.EN,+ creator: 'univer',+ name: 'universheet',+ extensions: [],+ sheetOrder: [],+ styles: {+ '1': {+ cl: {+ rgb: 'green',+ },+ fs: 16,+ bd: {+ t: {+ s: BorderStyleTypes.MEDIUM_DASHED,+ cl: {+ rgb: 'black',+ },+ },+ l: {+ s: BorderStyleTypes.MEDIUM_DASHED,+ cl: {+ rgb: 'black',+ },+ },+ r: {+ s: BorderStyleTypes.THICK,+ cl: {+ rgb: 'black',+ },+ },+ b: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'blue',+ },+ },+ },+ ht: 3,+ },+ '2': {+ bg: {+ rgb: 'rgb(2, 200, 0)',+ },+ fs: 24,+ },+ '3': {+ ht: HorizontalAlign.RIGHT,+ vt: VerticalAlign.TOP,+ tb: WrapStrategy.WRAP,+ // va: BaselineOffset.SUPERSCRIPT,+ // cl: {+ // rgb: 'rgb(0, 255, 0)',+ // },+ // st: {+ // s: BooleanNumber.TRUE, // show+ // },+ bg: {+ rgb: 'rgb(255, 255, 0)',+ },+ tr: {+ a: 45,+ v: BooleanNumber.FALSE,+ },+ bd: {+ t: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ l: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ r: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'black',+ },+ },+ b: {+ s: BorderStyleTypes.THIN,+ cl: {+ rgb: 'red',+ },+ },+ },+ },+ '4': {+ bg: {+ rgb: 'rgb(0, 0, 255)',+ },+ },+ },+ timeZone: 'GMT+8',+ createdTime: '2021-11-28 12:10:10',+ modifiedTime: '2021-11-29 12:10:10',+ appVersion: '3.0.0-alpha',+ lastModifiedBy: 'univer',+ sheets: {+ 'sheet-0001': {+ type: SheetTypes.GRID,+ id: 'sheet-0001',+ cellData: {+ '0': {+ '0': {+ s: '1',+ v: 2,+ m: '2',+ },+ '1': {+ s: '1',+ v: 1,+ m: '1',+ },+ '5': {+ s: '1',+ v: 8,+ m: '8',+ },+ '6': {+ s: '2',+ v: 8,+ m: '8',+ },+ },+ '1': {+ '0': {+ v: 22,+ m: '22',+ },+ '1': {+ v: 22,+ m: '22',+ },+ '2': {+ v: 80,+ m: '80',+ s: '3',+ },+ '3': {+ v: '富文本编辑',+ m: '富文本编辑',+ s: '2',+ },+ },+ '2': {+ '0': {+ v: 2222,+ m: '2222',+ },+ '1': {+ v: 2222,+ m: '2222',+ },+ '5': {+ s: '1',+ v: 8,+ m: '8',+ },+ '6': {+ s: '1',+ v: 8,+ m: '8',+ },+ '7': {+ s: '1',+ v: 8,+ m: '8',+ },+ '8': {+ s: '1',+ v: 8,+ m: '8',+ },+ },+ '3': {+ '0': {+ v: 1111,+ m: '1111',+ },+ '1': {+ v: 1111,+ m: '1111',+ },+ },+ '10': {+ '9': {+ v: 1111,+ s: '2',+ m: '1111',+ },+ },+ '13': {+ '9': {+ v: 1111,+ s: '4',+ m: '1111',+ },+ },+ '17': {+ '3': {+ v: '做移动端开发和前端开发的人员,对 MVC、MVP、MVVM 这几个名词应该都不陌生,这是三个最常用的应用架构模式,目的都是为了将业务和视图的实现代码分离',+ s: '3',+ p: richTextTest,+ },+ },+ '20': {+ '10': {+ v: '北京马拉松组委会办公室一位接电话的女士证实,的确有这项规定,她还称2014年马拉松的预登记工作将在本周启动。北京马拉松比赛将在10月19日举行。',+ s: '3',+ },+ '12': {+ s: '4',+ },+ },+ '29': {+ '13': {+ p: Tools.deepClone(richTextTest),+ s: '4',+ },+ },+ },+ name: 'sheet0001',+ tabColor: 'green',+ hidden: BooleanNumber.FALSE,+ freezeColumn: 1,+ rowCount: 1000,+ columnCount: 20,+ freezeRow: 1,+ zoomRatio: 1,+ scrollTop: 200,+ scrollLeft: 100,+ defaultColumnWidth: 93,+ defaultRowHeight: 27,+ mergeData: [+ {+ startRow: 0,+ endRow: 1,+ startColumn: 0,+ endColumn: 1,+ },+ {+ startRow: 2,+ endRow: 6,+ startColumn: 5,+ endColumn: 10,+ },+ {+ startRow: 10,+ endRow: 12,+ startColumn: 9,+ endColumn: 12,+ },+ {+ startRow: 10,+ endRow: 12,+ startColumn: 9,+ endColumn: 12,+ },+ {+ startRow: 17,+ endRow: 21,+ startColumn: 3,+ endColumn: 6,+ },+ {+ startRow: 13,+ endRow: 15,+ startColumn: 9,+ endColumn: 10,+ },+ {+ startRow: 24,+ endRow: 27,+ startColumn: 9,+ endColumn: 10,+ },+ ],+ rowData: {+ '3': {+ h: 50,+ hd: BooleanNumber.FALSE,+ },+ '4': {+ h: 60,+ hd: BooleanNumber.FALSE,+ },+ '29': {+ h: 200,+ hd: BooleanNumber.FALSE,+ },+ },+ columnData: {+ '5': {+ w: 100,+ hd: BooleanNumber.FALSE,+ },+ '6': {+ w: 200,+ hd: BooleanNumber.FALSE,+ },+ '13': {+ w: 300,+ hd: BooleanNumber.FALSE,+ },+ },+ status: 1,+ showGridlines: 1,+ hideRow: [],+ hideColumn: [],+ rowHeader: {+ width: 46,+ hidden: BooleanNumber.FALSE,+ },+ columnHeader: {+ height: 20,+ hidden: BooleanNumber.FALSE,+ },+ selections: ['A2'],+ rightToLeft: BooleanNumber.FALSE,+ pluginMeta: {},+ // metaData: [],+ },+ 'sheet-0002': {+ type: SheetTypes.GRID,+ id: 'sheet-0002',+ name: 'sheet0003',+ },+ },+ namedRanges: [+ {+ namedRangeId: 'named-range-0001',+ name: 'namedRange0001',+ range: {+ sheetId: 'sheet-0001',+ rangeData: {+ startRow: 0,+ startColumn: 0,+ endRow: 1,+ endColumn: 1,+ },+ },+ },+ ],+};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 14f0f4483b..3b1217526c 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@@ -80,13 +80,9 @@ const richTextDemo1: IDocumentData = {export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {id: 'workbook-01',- theme: 'default',locale: LocaleType.EN,creator: 'univer',name: 'UniverSheet Demo',- skin: 'default',- socketUrl: '',- socketEnable: BooleanNumber.FALSE,extensions: [],sheetOrder: ['sheet-0010',@@ -100,7 +96,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookConfig = {'sheet-0002','sheet-0001',],- pluginMeta: {},styles: {'1': {fs: 30,diff --git a/packages/core/src/Basics/Univer.ts b/packages/core/src/Basics/Univer.tsindex 43b78dc349..5c2bd613e8 100644--- a/packages/core/src/Basics/Univer.ts+++ b/packages/core/src/Basics/Univer.ts@@ -42,16 +42,14 @@ export class Univer {locale && this._univerInjector.get(LocaleService).setLocale(locale);}- dispose() {}+ dispose(): void {+ // left empty for purpose+ }private get _currentUniverService(): ICurrentUniverService {return this._univerInjector.get(ICurrentUniverService);}- dispose(): void {- // left empty for purpose- }-/** Register a plugin into univer. */registerPlugin<T extends Plugin>(plugin: PluginCtor<T>, configs?: any): void {// TODO: type of `configs` could be optimized here using typescript infer@@ -238,6 +236,4 @@ export class Univer {slide.addPlugin(p.plugin as unknown as PluginCtor<any>, p.options);});}-- dispose(): void {}}diff --git a/packages/core/src/Shared/Rectangle.ts b/packages/core/src/Shared/Rectangle.tsindex c3cf51069e..1e5a01b38c 100644--- a/packages/core/src/Shared/Rectangle.ts+++ b/packages/core/src/Shared/Rectangle.ts@@ -5,6 +5,15 @@ import { Nullable } from './Types';* This class provides a set of methods to calculate `ISelectionRange`.*/export class Rectangle {+ static clone(src: ISelectionRange): ISelectionRange {+ return {+ startRow: src.startRow,+ startColumn: src.startColumn,+ endRow: src.endRow,+ endColumn: src.endColumn,+ };+ }+static equals(src: ISelectionRange, target: ISelectionRange): boolean {return (src.endRow === target.endRow &&diff --git a/packages/core/src/Types/Interfaces/ISelectionData.ts b/packages/core/src/Types/Interfaces/ISelectionData.tsindex 100617a36c..68a3d8a9b7 100644--- a/packages/core/src/Types/Interfaces/ISelectionData.ts+++ b/packages/core/src/Types/Interfaces/ISelectionData.ts@@ -35,9 +35,9 @@ export enum SELECTION_TYPE {export interface ISelection {/** range */- rangeData: ISelectionRange; // TODO@wzhudev: rename- cellRange: Nullable<ISelectionCell>;- selectionType?: SELECTION_TYPE;+ rangeData: ISelectionRange; // TODO@wzhudev: rename to range+ cellRange: Nullable<ISelectionCell>; // rename to primary+ selectionType?: SELECTION_TYPE; // should be a property of IRange instead of ISelection}export interface ISelectionWithCoord {diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 0b5bc481bf..c285b30eef 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -23,7 +23,7 @@ export { LifecycleService } from './services/lifecycle/lifecycle.service';export { LocaleService } from './services/locale/locale.service';export { DesktopLogService, ILogService } from './services/log/log.service';export { DesktopPermissionService, IPermissionService } from './services/permission/permission.service';-export * from './services/theme/theme.service';+export { ThemeService } from './services/theme/theme.service';export { IUndoRedoService, LocalUndoRedoService, RedoCommand, UndoCommand } from './services/undoredo/undoredo.service';export * from './Shared';export { Disposable, DisposableCollection, fromObservable, RxDisposable, toDisposable } from './Shared/lifecycle';