Skip to content

Commit

Permalink
feat: fix cf render error on printing mode
Browse files Browse the repository at this point in the history
fix: #700
  • Loading branch information
weird94 authored and lumixraku committed May 15, 2024
1 parent b393980 commit da24282
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
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);

0 comments on commit da24282

Please sign in to comment.