Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sheet): render viewport wrong size #1727

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
feat: fix cf render error on printing mode
fix: #700
  • Loading branch information
weird94 authored and lumixraku committed May 24, 2024
commit 43bfb91ba435fad70b7bab441c80e91a26188492
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { Inject } from '@wendellhu/redi';
import { bufferTime, filter } from 'rxjs/operators';
import type { ISheetFontRenderExtension, Spreadsheet } from '@univerjs/engine-render';
import type { ISheetFontRenderExtension } from '@univerjs/engine-render';
import { IRenderManagerService } from '@univerjs/engine-render';

import { ConditionalFormattingIcon, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DataBar, dataBarUKey, DEFAULT_PADDING, DEFAULT_WIDTH, IconUKey } from '@univerjs/sheets-conditional-formatting';
import { ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_PADDING, DEFAULT_WIDTH } from '@univerjs/sheets-conditional-formatting';

import type { IConditionalFormattingCellData } from '@univerjs/sheets-conditional-formatting';

Expand All @@ -42,29 +42,6 @@ export class RenderController extends Disposable {
super();
this._initViewModelInterceptor();
this._initSkeleton();
this._initRender();
}

_initRender() {
const list: [string, new () => any][] = [[dataBarUKey, DataBar], [IconUKey, ConditionalFormattingIcon]];
const register = (renderId: string) => {
const render = renderId && this._renderManagerService.getRenderById(renderId);
const spreadsheetRender = render && render.mainComponent as Spreadsheet;
if (spreadsheetRender) {
list.forEach(([key, Instance]) => {
if (!spreadsheetRender.getExtensionByKey(key)) {
spreadsheetRender.register(new Instance());
}
});
}
};
this.disposeWithMe(this._renderManagerService.currentRender$.subscribe((renderId) => {
renderId && register(renderId);
}));
const workbook = this._univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;
if (workbook) {
register(workbook.getUnitId());
}
}

_initSkeleton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import type { IRange, IScale } from '@univerjs/core';
import { Range } from '@univerjs/core';
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension } from '@univerjs/engine-render';
import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension, SpreadsheetExtensionRegistry } from '@univerjs/engine-render';
import type { IDataBarCellData } from './type';

export const dataBarUKey = 'sheet-conditional-rule-data-bar';
Expand Down Expand Up @@ -150,3 +150,5 @@ export class DataBar extends SheetExtension {
ctx.fill();
}
}

SpreadsheetExtensionRegistry.add(DataBar);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import type { IRange, IScale } from '@univerjs/core';
import { Range } from '@univerjs/core';
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
import { SheetExtension } from '@univerjs/engine-render';
import { SheetExtension, SpreadsheetExtensionRegistry } from '@univerjs/engine-render';
import type { IIconType } from '../models/icon-map';
import { EMPTY_ICON_TYPE, iconMap } from '../models/icon-map';
import type { IIconSetCellData } from './type';
Expand Down Expand Up @@ -115,3 +115,5 @@ export class ConditionalFormattingIcon extends SheetExtension {
return `${iconType}_${iconIndex}`;
}
}

SpreadsheetExtensionRegistry.add(ConditionalFormattingIcon);