Skip to content

Commit

Permalink
feat: make Facade more common
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev committed Oct 21, 2024
1 parent b41495e commit 6700919
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion e2e/visual-comparison/sheets/sheets-gridlines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.getActiveWorkbook().getActiveSheet().setGridlinesVisible(false));
await page.evaluate(() => window.univerAPI.getActiveWorkbook().getActiveSheet().setHiddenGridlines(true));
await page.waitForTimeout(1000);

const filename = generateSnapshotName('sheets-no-gridlines');
Expand Down
17 changes: 12 additions & 5 deletions packages/facade/src/apis/sheets/f-worksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { IDataValidationResCache } from '@univerjs/sheets-data-validation';
import type { FilterModel } from '@univerjs/sheets-filter';

import type { FWorkbook, IFICanvasFloatDom } from './f-workbook';
import { Direction, ICommandService, Inject, Injector, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';
import { BooleanNumber, 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, ToggleGridlinesCommand } from '@univerjs/sheets';
Expand Down Expand Up @@ -1038,14 +1038,21 @@ export class FWorksheet {
}

/**
* Show or hide grid line.
* @param {boolean} visible If the grid line should be visible.
* Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
*/
setGridlinesVisible(visible?: boolean): Promise<boolean> {
hasHiddenGridLines(): boolean {
return this._worksheet.getConfig().showGridlines === BooleanNumber.FALSE;
}

/**
* Hides or reveals the sheet gridlines.
* @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
*/
setHiddenGridlines(hidden: boolean): Promise<boolean> {
return this._commandService.executeCommand(ToggleGridlinesCommand.id, {
unitId: this._workbook.getUnitId(),
subUnitId: this._worksheet.getSheetId(),
showGridlines: visible,
showGridlines: hidden ? BooleanNumber.FALSE : BooleanNumber.TRUE,
} as IToggleGridlinesCommandParams);
}

Expand Down

0 comments on commit 6700919

Please sign in to comment.