Skip to content

Commit

Permalink
fix(resources): employ univerType instead of the designated business …
Browse files Browse the repository at this point in the history
…strings
  • Loading branch information
Gggpound committed Apr 12, 2024
1 parent 64d4561 commit 3b9e75e
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 229 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/services/resource-manager/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import type { IDisposable } from '@wendellhu/redi';
import { createIdentifier } from '@wendellhu/redi';
import type { Observable } from 'rxjs';
import type { UniverType } from '@univerjs/protocol';
import type { Workbook } from '../../sheets/workbook';
import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';
Expand All @@ -25,7 +26,7 @@ type IBusinessName = 'SHEET' | 'DOC';
export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
export interface IResourceHook<T = any> {
pluginName: IResourceName;
businesses: IBusinessName[];
businesses: UniverType[];
onLoad: (unitID: string, resource: T) => void;
onUnLoad: (unitID: string) => void;
toJson: (unitID: string) => string;
Expand Down
1 change: 1 addition & 0 deletions packages/data-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/protocol": "^0.1.14",
"@univerjs/sheets": "workspace:*",
"@wendellhu/redi": "0.13.0",
"rxjs": ">=7.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import type { ISheetDataValidationRule } from '@univerjs/core';
import { Disposable, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';
import { Inject } from '@wendellhu/redi';
import { UniverType } from '@univerjs/protocol';
import { DataValidationModel } from '../models/data-validation-model';

type DataValidationJSON = Record<string, ISheetDataValidationRule[]>;
Expand Down Expand Up @@ -59,7 +60,7 @@ export class DataValidationResourceController extends Disposable {
this.disposeWithMe(
this._resourceManagerService.registerPluginResource<DataValidationJSON>({
pluginName: DATA_VALIDATION_PLUGIN_NAME,
businesses: ['SHEET'],
businesses: [UniverType.UNIVER_SHEET],
toJson: (unitID) => toJson(unitID),
parseJson: (json) => parseJson(json),
onUnLoad: (unitID) => {
Expand Down
1 change: 1 addition & 0 deletions packages/sheets-conditional-formatting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/protocol": "^0.1.14",
"@univerjs/sheets": "workspace:*",
"@wendellhu/redi": "0.13.0",
"rxjs": ">=7.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutati
import { Inject, Injector } from '@wendellhu/redi';
import { Subject } from 'rxjs';
import { filter } from 'rxjs/operators';
import { UniverType } from '@univerjs/protocol';
import type { IDeleteConditionalRuleMutationParams } from '../commands/mutations/delete-conditional-rule.mutation';
import { DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory } from '../commands/mutations/delete-conditional-rule.mutation';
import { ConditionalFormattingRuleModel } from '../models/conditional-formatting-rule-model';
Expand Down Expand Up @@ -141,7 +142,7 @@ export class ConditionalFormattingService extends Disposable {
this.disposeWithMe(
this._resourceManagerService.registerPluginResource<IRuleModelJson[keyof IRuleModelJson]>({
pluginName: SHEET_CONDITIONAL_FORMATTING_PLUGIN,
businesses: ['SHEET'],
businesses: [UniverType.UNIVER_SHEET],
toJson: (unitID) => toJson(unitID),
parseJson: (json) => parseJson(json),
onUnLoad: (unitID) => {
Expand Down
1 change: 1 addition & 0 deletions packages/sheets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/protocol": "^0.1.14",
"@wendellhu/redi": "0.13.0",
"rxjs": ">=7.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from '@univerjs/core';
import type { IDefinedNameMapItem } from '@univerjs/engine-formula';
import { IDefinedNamesService } from '@univerjs/engine-formula';
import { UniverType } from '@univerjs/protocol';

const SHEET_DEFINED_NAME_PLUGIN = 'SHEET_DEFINED_NAME_PLUGIN';

Expand Down Expand Up @@ -66,7 +67,7 @@ export class DefinedNameDataController extends Disposable {
this.disposeWithMe(
this._resourceManagerService.registerPluginResource<IDefinedNameMapItem>({
pluginName: SHEET_DEFINED_NAME_PLUGIN,
businesses: ['SHEET'],
businesses: [UniverType.UNIVER_SHEET],
toJson: (unitID) => toJson(unitID),
parseJson: (json) => parseJson(json),
onUnLoad: (unitID) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/sheets/src/services/numfmt/numfmt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from '@univerjs/core';
import { Inject } from '@wendellhu/redi';
import { Subject } from 'rxjs';
import { UniverType } from '@univerjs/protocol';

import type { FormatType, INumfmtItem, INumfmtService, IRefItem, ISnapshot } from './type';

Expand Down Expand Up @@ -68,7 +69,7 @@ export class NumfmtService extends Disposable implements INumfmtService {
this.disposeWithMe(
this._resourceManagerService.registerPluginResource<ISnapshot>({
pluginName: SHEET_NUMFMT_PLUGIN,
businesses: ['SHEET'],
businesses: [UniverType.UNIVER_SHEET],
toJson: (unitID) => this._toJson(unitID),
parseJson: (json) => this._parseJson(json),
onUnLoad: (unitID) => {
Expand Down
Loading

0 comments on commit 3b9e75e

Please sign in to comment.