Skip to content

Commit

Permalink
Merge branch 'dev' into feat/async-promise-function
Browse files Browse the repository at this point in the history
  • Loading branch information
hexf00 authored Jan 2, 2025
2 parents 9bd85f0 + 407f68b commit 819d078
Show file tree
Hide file tree
Showing 19 changed files with 338 additions and 80 deletions.
35 changes: 27 additions & 8 deletions packages/core/src/facade/f-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,31 @@ export class FEnum extends FBase {
return instance;
}

readonly UniverInstanceType = UniverInstanceType;
readonly LifecycleStages = LifecycleStages;

readonly DataValidationType = DataValidationType;
readonly DataValidationErrorStyle = DataValidationErrorStyle;
readonly DataValidationRenderMode = DataValidationRenderMode;
readonly DataValidationOperator = DataValidationOperator;
readonly DataValidationStatus = DataValidationStatus;
get UniverInstanceType() {
return UniverInstanceType;
}

get LifecycleStages() {
return LifecycleStages;
}

get DataValidationType() {
return DataValidationType;
}

get DataValidationErrorStyle() {
return DataValidationErrorStyle;
}

get DataValidationRenderMode() {
return DataValidationRenderMode;
}

get DataValidationOperator() {
return DataValidationOperator;
}

get DataValidationStatus() {
return DataValidationStatus;
}
}
9 changes: 7 additions & 2 deletions packages/core/src/facade/f-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ export class FEventName extends FBase {
return instance;
}

UnitCreated = 'UnitCreated' as const;
LifeCycleChanged = 'LifeCycleChanged' as const;
get UnitCreated() {
return 'UnitCreated' as const;
}

get LifeCycleChanged() {
return 'LifeCycleChanged' as const;
}
}

export interface IEventParamConfig {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/facade/f-univer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ICommandService } from '../services/command/command.service';
import { IUniverInstanceService } from '../services/instance/instance.service';
import { LifecycleService } from '../services/lifecycle/lifecycle.service';
import { RedoCommand, UndoCommand } from '../services/undoredo/undoredo.service';
import { toDisposable } from '../shared';
import { ColorBuilder, toDisposable } from '../shared';
import { Univer } from '../univer';
import { FBaseInitialable } from './f-base';
import { FBlob } from './f-blob';
Expand Down Expand Up @@ -190,6 +190,10 @@ export class FUniver extends FBaseInitialable {
return this._injector.createInstance(FBlob);
}

newColor(): ColorBuilder {
return new ColorBuilder();
}

get Enum() {
return FEnum.get();
}
Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/sheets/typedef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,22 @@ export function isCellV(cell: Nullable<ICellData | CellValue>) {
}

export interface IFreeze {
/**
* count of fixed cols
*/
xSplit: number;
/**
* count of fixed rows
*/
ySplit: number;
/**
* scrollable start row
*/
startRow: number;

/**
* scrollable start column
*/
startColumn: number;
}

Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/sheets/worksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,13 @@ export class Worksheet {
} else if (dataMode === CellModeEnum.Intercepted) {
cellData = this.getCell(row, col);
} else if (dataMode === CellModeEnum.Both) {
cellData = this.getCellRaw(row, col);
const displayV = this.getCell(row, col)?.v;
if (isNotNullOrUndefined(displayV) && cellData) {
cellData.displayV = String(displayV);
const cellDataRaw = this.getCellRaw(row, col);
if (cellDataRaw) {
cellData = { ...cellDataRaw };
const displayV = this.getCell(row, col)?.v;
if (isNotNullOrUndefined(displayV) && cellData) {
cellData.displayV = String(displayV);
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions packages/engine-render/src/components/sheets/sheet-skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2299,4 +2299,24 @@ export class SpreadsheetSkeleton extends Skeleton {
const i = Math.max(0, col - 1);
return arr[i];
}

getHiddenRowsInRange(range: IRowRange) {
const hiddenRows = [];
for (let i = range.startRow; i <= range.endRow; i++) {
if (!this.worksheet.getRowVisible(i)) {
hiddenRows.push(i);
}
}
return hiddenRows;
}

getHiddenColumnsInRange(range: IColumnRange) {
const hiddenCols = [];
for (let i = range.startColumn; i <= range.endColumn; i++) {
if (!this.worksheet.getColVisible(i)) {
hiddenCols.push(i);
}
}
return hiddenCols;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { ColorBuilder } from '@univerjs/core';
import { FWorkbook } from '@univerjs/sheets/facade';

export interface IFWorkbookConditionalFormattingMixin {
/**
* @deprecated use `univerAPI.newColor()` as instead.
*/
newColor(): ColorBuilder;
}

Expand Down
27 changes: 24 additions & 3 deletions packages/sheets-ui/src/commands/commands/set-scroll.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ export interface ISetScrollRelativeCommandParams {
export interface IScrollCommandParams {
offsetX?: number;
offsetY?: number;
/**
* The index of row in spreadsheet.
* e.g. if row start 10 at current viewport after freeze, and scroll value is zero, startRow is 0.
* e.g. if scrolled about 2 rows, now top is 12, then sheetViewStartRow is 2.
*/
sheetViewStartRow?: number;

/**
* Not the index of col in spreadsheet, but index of first column in current viewport.
* e.g. if col start C at current viewport after freeze, and scroll value is zero, startColumn is 0.
* e.g. if scrolled about 2 columns, now left is E, then sheetViewStartColumn is 2.
*/
sheetViewStartColumn?: number;
}

Expand Down Expand Up @@ -65,9 +76,15 @@ export const SetScrollRelativeCommand: ICommand<ISetScrollRelativeCommandParams>
offsetY: currentOffsetY = 0,
} = currentScroll || {};
// the receiver is scroll.operation.ts
// const { xSplit, ySplit } = target.worksheet.getConfig().freeze;

return commandService.executeCommand(SetScrollOperation.id, {
unitId,
sheetId: subUnitId,

// why + ySplit? receiver - ySplit in scroll.operation.ts
// sheetViewStartRow: sheetViewStartRow + ySplit,
// sheetViewStartColumn: sheetViewStartColumn + xSplit,
sheetViewStartRow,
sheetViewStartColumn,
offsetX: currentOffsetX + offsetX, // currentOffsetX + offsetX may be negative or over max
Expand Down Expand Up @@ -110,13 +127,17 @@ export const ScrollCommand: ICommand<IScrollCommandParams> = {
offsetX: currentOffsetX,
offsetY: currentOffsetY,
} = currentScroll || {};

const { xSplit, ySplit } = target.worksheet.getConfig().freeze;
const commandService = accessor.get(ICommandService);

return commandService.syncExecuteCommand(SetScrollOperation.id, {
unitId: workbook.getUnitId(),
sheetId: worksheet.getSheetId(),
sheetViewStartRow: sheetViewStartRow ?? (currentRow ?? 0),
sheetViewStartColumn: sheetViewStartColumn ?? (currentColumn ?? 0),
// why + ySplit? receiver - ySplit in scroll.operation.ts
// sheetViewStartRow: sheetViewStartRow + ySplit,
// sheetViewStartColumn: sheetViewStartColumn + xSplit,
sheetViewStartRow: sheetViewStartRow ?? (currentRow ?? 0 + ySplit),
sheetViewStartColumn: sheetViewStartColumn ?? (currentColumn ?? 0 + xSplit),
offsetX: offsetX ?? currentOffsetX,
offsetY: offsetY ?? currentOffsetY,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const SetScrollOperation: IOperation<IScrollStateWithSearchParam> = {
const { unitId, sheetId, offsetX, offsetY, sheetViewStartColumn, sheetViewStartRow } = params;
const renderManagerService = accessor.get(IRenderManagerService);
const scrollManagerService = renderManagerService.getRenderById(unitId)!.with(SheetScrollManagerService);
// const currentService = accessor.get(IUniverInstanceService);
// const workbook = currentService.getUniverSheetInstance(unitId);
// const worksheet = workbook!.getSheetBySheetId(sheetId);
// const { xSplit, ySplit } = worksheet!.getConfig().freeze;

scrollManagerService.setScrollInfoAndEmitEvent({
unitId,
Expand Down
Loading

0 comments on commit 819d078

Please sign in to comment.