From 4a320aa4668ce689a3eb4b1e436a2547d9839836 Mon Sep 17 00:00:00 2001 From: zhangw Date: Mon, 30 Sep 2024 14:18:27 +0800 Subject: [PATCH] feat: update --- .../render-controllers/render.controller.ts | 25 ++++++++++++++++++- packages/sheets-hyper-link-ui/src/plugin.ts | 10 ++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts index 07109855285..40c2c151000 100644 --- a/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts +++ b/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts @@ -14,11 +14,34 @@ * limitations under the License. */ +import type { Workbook } from '@univerjs/core'; +import type { IRenderContext, IRenderModule } from '@univerjs/engine-render'; import { Disposable, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle } from '@univerjs/core'; import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets'; import { HyperLinkModel } from '@univerjs/sheets-hyper-link'; +import { debounceTime } from 'rxjs'; -@OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRenderManagerController) +export class SheetsHyperLinkRenderController extends Disposable implements IRenderModule { + constructor( + private readonly _context: IRenderContext, + @Inject(HyperLinkModel) private readonly _hyperLinkModel: HyperLinkModel + ) { + super(); + this._initSkeletonChange(); + } + + private _initSkeletonChange() { + const markSkeletonDirty = () => { + this._context.mainComponent?.makeForceDirty(); + }; + + this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(debounceTime(16)).subscribe(() => { + markSkeletonDirty(); + })); + } +} + +@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkRenderManagerController) export class SheetsHyperLinkRenderManagerController extends Disposable { constructor( @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService, diff --git a/packages/sheets-hyper-link-ui/src/plugin.ts b/packages/sheets-hyper-link-ui/src/plugin.ts index 9a3779aac8c..3c9fdb7eddb 100644 --- a/packages/sheets-hyper-link-ui/src/plugin.ts +++ b/packages/sheets-hyper-link-ui/src/plugin.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type { Dependency } from '@univerjs/core'; +import type { Dependency, Workbook } from '@univerjs/core'; import type { IUniverSheetsHyperLinkUIConfig } from './controllers/config.schema'; import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; +import { IRenderManagerService } from '@univerjs/engine-render'; import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link'; import { SheetsHyperLinkAutoFillController } from './controllers/auto-fill.controller'; import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -25,7 +26,7 @@ import { SheetsHyperLinkCopyPasteController } from './controllers/copy-paste.con import { SheetsHyperLinkPermissionController } from './controllers/hyper-link-permission.controller'; import { SheetsHyperLinkPopupController } from './controllers/popup.controller'; import { SheetsHyperLinkRemoveSheetController } from './controllers/remove-sheet.controller'; -import { SheetsHyperLinkRenderManagerController } from './controllers/render-controllers/render.controller'; +import { SheetsHyperLinkRenderController, SheetsHyperLinkRenderManagerController } from './controllers/render-controllers/render.controller'; import { SheetsHyperLinkRichTextRefRangeController } from './controllers/rich-text-ref-range.controller'; import { SheetHyperLinkSetRangeController } from './controllers/set-range.controller'; import { SheetsHyperLinkUIController } from './controllers/ui.controller'; @@ -75,4 +76,9 @@ export class UniverSheetsHyperLinkUIPlugin extends Plugin { dependencies.forEach((dep) => this._injector.add(dep)); } + + override onReady(): void { + const renderManager = this._injector.get(IRenderManagerService); + renderManager.registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetsHyperLinkRenderController] as Dependency); + } }