diff --git a/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts b/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts index 63eda2b76d8..17a5eb283a3 100644 --- a/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts +++ b/e2e/visual-comparison/sheets/sheets-gridlines.spec.ts @@ -32,7 +32,7 @@ test('sheets no gridlines', async () => { await page.waitForTimeout(2000); await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet()); await page.waitForTimeout(5000); - await page.evaluate(() => window.univerAPI.setGridlineVisible(false)); + await page.evaluate(() => window.univerAPI.getActiveWorkbook().getActiveSheet().setGridlinesVisible(false)); await page.waitForTimeout(1000); const filename = generateSnapshotName('sheets-no-gridlines'); @@ -45,29 +45,3 @@ test('sheets no gridlines', async () => { expect(screenshot).toMatchSnapshot(filename, { maxDiffPixels: 5 }); }); -test('sheets gridlines color', async () => { - const browser = await chromium.launch({ - headless: !!isCI, // Set to false to see the browser window - }); - const context = await browser.newContext({ - viewport: { width: 1280, height: 720 }, - deviceScaleFactor: 2, // Set your desired DPR - }); - const page = await context.newPage(); - await page.goto('http://localhost:3000/sheets/'); - await page.waitForTimeout(2000); - await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet()); - await page.waitForTimeout(5000); - await page.evaluate(() => window.univerAPI.setGridlineColor('rgb(200, 0, 0)')); - await page.waitForTimeout(1000); - - const filename = generateSnapshotName('sheets-gridlines-color'); - const screenshot = await page.screenshot({ - mask: [ - page.locator('.univer-headerbar'), - ], - fullPage: true, - }); - expect(screenshot).toMatchSnapshot(filename, { maxDiffPixels: 5 }); -}); - diff --git a/packages/facade/src/apis/facade.ts b/packages/facade/src/apis/facade.ts index 9eca7743a4b..daaeef40572 100644 --- a/packages/facade/src/apis/facade.ts +++ b/packages/facade/src/apis/facade.ts @@ -35,11 +35,9 @@ import type { SpreadsheetRowHeader, } from '@univerjs/engine-render'; import type { ISocket } from '@univerjs/network'; -import type { IToggleGridlinesCommandParams } from '@univerjs/sheets'; import type { ISetCrosshairHighlightColorOperationParams } from '@univerjs/sheets-crosshair-highlight'; import type { IRegisterFunctionParams } from '@univerjs/sheets-formula'; -import type { ISetGridlineColorOperationParams } from '@univerjs/sheets-ui'; import { BorderStyleTypes, debounce, @@ -59,10 +57,9 @@ import { import { SetFormulaCalculationStartMutation } from '@univerjs/engine-formula'; import { IRenderManagerService } from '@univerjs/engine-render'; import { ISocketService, WebSocketService } from '@univerjs/network'; -import { ToggleGridlinesCommand } from '@univerjs/sheets'; import { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, SetCrosshairHighlightColorOperation } from '@univerjs/sheets-crosshair-highlight'; import { IRegisterFunctionService, RegisterFunctionService } from '@univerjs/sheets-formula'; -import { SetGridlineColorOperation, SHEET_VIEW_KEY } from '@univerjs/sheets-ui'; +import { SHEET_VIEW_KEY } from '@univerjs/sheets-ui'; import { CopyCommand, PasteCommand } from '@univerjs/ui'; import { FDocument } from './docs/f-document'; import { FHooks } from './f-hooks'; @@ -529,23 +526,6 @@ export class FUniver { } as ISetCrosshairHighlightColorOperationParams); } - /** - * Show or hide grid line. - * @param {boolean} visible If the grid line should be visible. - */ - setGridlinesVisible(visible?: boolean): Promise { - return this._commandService.executeCommand(ToggleGridlinesCommand.id, { - showGridlines: visible, - } as IToggleGridlinesCommandParams); - } - - /** - * Set the color of the gridlines. - */ - setGridlinesColor(color: string): void { - this._commandService.executeCommand(SetGridlineColorOperation.id, { color } as ISetGridlineColorOperationParams); - } - // #endregion /** diff --git a/packages/facade/src/apis/sheets/f-worksheet.ts b/packages/facade/src/apis/sheets/f-worksheet.ts index b188af3b144..5dbd33ad3ac 100644 --- a/packages/facade/src/apis/sheets/f-worksheet.ts +++ b/packages/facade/src/apis/sheets/f-worksheet.ts @@ -15,7 +15,7 @@ */ import type { ICellData, IDisposable, IFreeze, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core'; -import type { ISetRangeValuesMutationParams } from '@univerjs/sheets'; +import type { ISetRangeValuesMutationParams, IToggleGridlinesCommandParams } from '@univerjs/sheets'; import type { IDataValidationResCache } from '@univerjs/sheets-data-validation'; import type { FilterModel } from '@univerjs/sheets-filter'; @@ -23,7 +23,7 @@ import type { FWorkbook, IFICanvasFloatDom } from './f-workbook'; import { Direction, ICommandService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core'; import { DataValidationModel } from '@univerjs/data-validation'; import { deserializeRangeWithSheet } from '@univerjs/engine-formula'; -import { copyRangeStyles, InsertColCommand, InsertRowCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColWidthCommand, SetFrozenCommand, SetRangeValuesMutation, SetRowHeightCommand, SetRowHiddenCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetRowIsAutoHeightCommand, SheetsSelectionsService } from '@univerjs/sheets'; +import { copyRangeStyles, InsertColCommand, InsertRowCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColWidthCommand, SetFrozenCommand, SetRangeValuesMutation, SetRowHeightCommand, SetRowHiddenCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetRowIsAutoHeightCommand, SheetsSelectionsService, ToggleGridlinesCommand } from '@univerjs/sheets'; import { SheetsDataValidationValidatorService } from '@univerjs/sheets-data-validation'; import { SheetCanvasFloatDomManagerService } from '@univerjs/sheets-drawing-ui'; import { SheetsFilterService } from '@univerjs/sheets-filter'; @@ -1037,6 +1037,18 @@ export class FWorksheet { return freeze.startRow; } + /** + * Show or hide grid line. + * @param {boolean} visible If the grid line should be visible. + */ + setGridlinesVisible(visible?: boolean): Promise { + return this._commandService.executeCommand(ToggleGridlinesCommand.id, { + unitId: this._workbook.getUnitId(), + subUnitId: this._worksheet.getSheetId(), + showGridlines: visible, + } as IToggleGridlinesCommandParams); + } + /** * Subscribe to the cell data change event. * @param callback - The callback function to be executed when the cell data changes.