mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
refactor: unify UniverType, UnitType, UniverInstanceType to UniverInstanceType (#6811)
This commit is contained in:
@@ -14,18 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { UniverType } from '@univerjs/protocol';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { Disposable } from '../shared/lifecycle';
|
||||
|
||||
export { UniverType as UniverInstanceType } from '@univerjs/protocol';
|
||||
|
||||
export type UnitType = UniverType | number;
|
||||
export enum UniverInstanceType {
|
||||
UNIVER_UNKNOWN = 0,
|
||||
UNIVER_DOC = 1, // Univer Docs
|
||||
UNIVER_SHEET = 2, // Univer Sheets
|
||||
UNIVER_SLIDE = 3, // Univer Slides
|
||||
UNIVER_PROJECT = 4,
|
||||
UNRECOGNIZED = -1,
|
||||
}
|
||||
|
||||
/**
|
||||
* The base class for all units.
|
||||
*/
|
||||
export abstract class UnitModel<D = object, T extends UnitType = UnitType> extends Disposable {
|
||||
export abstract class UnitModel<D = object, T extends UniverInstanceType = UniverInstanceType> extends Disposable {
|
||||
abstract readonly type: T;
|
||||
|
||||
abstract getUnitId(): string;
|
||||
|
||||
@@ -41,7 +41,7 @@ export { Registry, RegistryAsMap } from './common/registry';
|
||||
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
||||
export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
|
||||
export { mergeSets } from './common/set';
|
||||
export { UnitModel, type UnitType, UniverInstanceType } from './common/unit';
|
||||
export { UnitModel, UniverInstanceType } from './common/unit';
|
||||
export { resolveWithBasePath } from './common/url';
|
||||
export * from './docs/data-model';
|
||||
export { JSON1, JSONX } from './docs/data-model/json-x/json-x';
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
import type { IActionInfo, IAllowedRequest, IBatchAllowedResponse, ICollaborator, ICreateRequest, ICreateRequest_SelectRangeObject, IListPermPointRequest, IPermissionPoint, IPutCollaboratorsRequest, IUnitRoleKV, IUpdatePermPointRequest, UnitAction, UnitObject } from '@univerjs/protocol';
|
||||
import type { IAuthzIoService } from './type';
|
||||
import { ObjectScope, UnitRole, UniverType } from '@univerjs/protocol';
|
||||
import { ObjectScope, UnitRole } from '@univerjs/protocol';
|
||||
import { Inject } from '../../common/di';
|
||||
import { UniverInstanceType } from '../../common/unit';
|
||||
import { generateRandomId } from '../../shared/tools';
|
||||
import { IResourceManagerService } from '../resource-manager/type';
|
||||
import { createDefaultUser, isDevRole } from '../user-manager/const';
|
||||
@@ -86,7 +87,7 @@ export class AuthzIoLocalService implements IAuthzIoService {
|
||||
return JSON.parse(json);
|
||||
},
|
||||
pluginName: 'SHEET_AuthzIoMockService_PLUGIN',
|
||||
businesses: [UniverType.UNIVER_SHEET, UniverType.UNIVER_DOC, UniverType.UNIVER_SLIDE],
|
||||
businesses: [UniverInstanceType.UNIVER_SHEET, UniverInstanceType.UNIVER_DOC, UniverInstanceType.UNIVER_SLIDE],
|
||||
onLoad: (_unitId, resource) => {
|
||||
for (const key in resource) {
|
||||
this._permissionMap.set(key, resource[key]);
|
||||
|
||||
@@ -14,7 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { IAllowedRequest, IAllowedResponse, IBatchAllowedResponse, ICreateCollaboratorRequest, ICreateRequest, ICreateResponse, IDeleteCollaboratorRequest, IListCollaboratorRequest, IListCollaboratorResponse, IListPermPointRequest, IListPermPointResponse, IListRolesRequest, IListRolesResponse, IPutCollaboratorsRequest, IUpdateCollaboratorRequest, IUpdatePermPointRequest } from '@univerjs/protocol';
|
||||
import type {
|
||||
IAllowedRequest,
|
||||
IAllowedResponse,
|
||||
IBatchAllowedResponse,
|
||||
ICreateCollaboratorRequest,
|
||||
ICreateRequest,
|
||||
ICreateResponse,
|
||||
IDeleteCollaboratorRequest,
|
||||
IListCollaboratorRequest,
|
||||
IListCollaboratorResponse,
|
||||
IListPermPointRequest,
|
||||
IListPermPointResponse,
|
||||
IListRolesRequest,
|
||||
IListRolesResponse,
|
||||
IPutCollaboratorsRequest,
|
||||
IUpdateCollaboratorRequest,
|
||||
IUpdatePermPointRequest,
|
||||
} from '@univerjs/protocol';
|
||||
import type { ILogContext } from '../log/context';
|
||||
import { createIdentifier } from '../../common/di';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { IDisposable } from '../../common/di';
|
||||
import type { UnitModel, UnitType } from '../../common/unit';
|
||||
import type { UnitModel } from '../../common/unit';
|
||||
import type { Nullable } from '../../shared';
|
||||
import { BehaviorSubject, distinctUntilChanged, filter, map, Subject } from 'rxjs';
|
||||
import { createIdentifier, Inject, Injector } from '../../common/di';
|
||||
@@ -50,7 +50,7 @@ export interface IUniverInstanceService {
|
||||
/** Omits value when a new UnitModel is created. */
|
||||
unitAdded$: Observable<UnitModel>;
|
||||
/** Subscribe to curtain type of units' creation. */
|
||||
getTypeOfUnitAdded$<T extends UnitModel>(type: UnitType): Observable<T>;
|
||||
getTypeOfUnitAdded$<T extends UnitModel>(type: UniverInstanceType): Observable<T>;
|
||||
|
||||
/** @ignore */
|
||||
__addUnit(unit: UnitModel): void;
|
||||
@@ -58,7 +58,7 @@ export interface IUniverInstanceService {
|
||||
/** Omits value when a UnitModel is disposed. */
|
||||
unitDisposed$: Observable<UnitModel>;
|
||||
/** Subscribe to curtain type of units' disposing. */
|
||||
getTypeOfUnitDisposed$<T extends UnitModel>(type: UnitType): Observable<T>;
|
||||
getTypeOfUnitDisposed$<T extends UnitModel>(type: UniverInstanceType): Observable<T>;
|
||||
|
||||
/**
|
||||
* An observable value that emits the id of the focused unit. A Univer app instance
|
||||
@@ -74,24 +74,24 @@ export interface IUniverInstanceService {
|
||||
getFocusedUnit(): Nullable<UnitModel>;
|
||||
|
||||
/** @deprecated Use `getCurrentUnitOfType` instead. */
|
||||
getCurrentUnitForType<T extends UnitModel>(type: UnitType): Nullable<T>;
|
||||
getCurrentUnitOfType<T extends UnitModel>(type: UnitType): Nullable<T>;
|
||||
getCurrentUnitForType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
||||
getCurrentUnitOfType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
||||
setCurrentUnitForType(unitId: string): void;
|
||||
getCurrentTypeOfUnit$<T extends UnitModel>(type: UnitType): Observable<Nullable<T>>;
|
||||
getCurrentTypeOfUnit$<T extends UnitModel>(type: UniverInstanceType): Observable<Nullable<T>>;
|
||||
|
||||
/** Create a unit with snapshot info. */
|
||||
createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T>, options?: ICreateUnitOptions): U;
|
||||
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>, options?: ICreateUnitOptions): U;
|
||||
/** Dispose a unit */
|
||||
disposeUnit(unitId: string): boolean;
|
||||
|
||||
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new (...args: any[]) => T): IDisposable;
|
||||
registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new (...args: any[]) => T): IDisposable;
|
||||
|
||||
/** @deprecated */
|
||||
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
||||
|
||||
getUnit<T extends UnitModel>(id: string, type?: UnitType): Nullable<T>;
|
||||
getAllUnitsForType<T>(type: UnitType): T[];
|
||||
getUnitType(unitId: string): UnitType;
|
||||
getUnit<T extends UnitModel>(id: string, type?: UniverInstanceType): Nullable<T>;
|
||||
getAllUnitsForType<T>(type: UniverInstanceType): T[];
|
||||
getUnitType(unitId: string): UniverInstanceType;
|
||||
|
||||
/** @deprecated */
|
||||
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
||||
@@ -103,7 +103,7 @@ export interface IUniverInstanceService {
|
||||
|
||||
export const IUniverInstanceService = createIdentifier<IUniverInstanceService>('univer.current');
|
||||
export class UniverInstanceService extends Disposable implements IUniverInstanceService {
|
||||
private readonly _unitsByType = new Map<UnitType, UnitModel[]>();
|
||||
private readonly _unitsByType = new Map<UniverInstanceType, UnitModel[]>();
|
||||
|
||||
constructor(
|
||||
@Inject(Injector) private readonly _injector: Injector,
|
||||
@@ -126,23 +126,23 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
}
|
||||
|
||||
private _createHandler!: (
|
||||
type: UnitType,
|
||||
type: UniverInstanceType,
|
||||
data: unknown,
|
||||
ctor: UnitCtor,
|
||||
options?: ICreateUnitOptions
|
||||
) => UnitModel;
|
||||
|
||||
__setCreateHandler(handler: (type: UnitType, data: unknown, ctor: UnitCtor, options?: ICreateUnitOptions) => UnitModel): void {
|
||||
__setCreateHandler(handler: (type: UniverInstanceType, data: unknown, ctor: UnitCtor, options?: ICreateUnitOptions) => UnitModel): void {
|
||||
this._createHandler = handler;
|
||||
}
|
||||
|
||||
createUnit<T, U extends UnitModel>(type: UnitType, data: T, options?: ICreateUnitOptions): U {
|
||||
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: T, options?: ICreateUnitOptions): U {
|
||||
const model = this._createHandler(type, data, this._ctorByType.get(type)!, options);
|
||||
return model as U;
|
||||
}
|
||||
|
||||
private readonly _ctorByType = new Map<UnitType, new () => UnitModel>();
|
||||
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new () => T): IDisposable {
|
||||
private readonly _ctorByType = new Map<UniverInstanceType, new () => UnitModel>();
|
||||
registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new () => T): IDisposable {
|
||||
this._ctorByType.set(type, ctor);
|
||||
|
||||
return {
|
||||
@@ -152,22 +152,22 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
};
|
||||
}
|
||||
|
||||
__getCtorByType(type: UnitType): UnitCtor | undefined {
|
||||
__getCtorByType(type: UniverInstanceType): UnitCtor | undefined {
|
||||
return this._ctorByType.get(type);
|
||||
}
|
||||
|
||||
private _currentUnits = new Map<UnitType, Nullable<UnitModel>>();
|
||||
private readonly _currentUnits$ = new BehaviorSubject<Map<UnitType, Nullable<UnitModel>>>(this._currentUnits);
|
||||
private _currentUnits = new Map<UniverInstanceType, Nullable<UnitModel>>();
|
||||
private readonly _currentUnits$ = new BehaviorSubject<Map<UniverInstanceType, Nullable<UnitModel>>>(this._currentUnits);
|
||||
readonly currentUnits$ = this._currentUnits$.asObservable();
|
||||
getCurrentTypeOfUnit$<T>(type: number): Observable<Nullable<T>> {
|
||||
return this.currentUnits$.pipe(map((units) => units.get(type) ?? null), distinctUntilChanged()) as Observable<Nullable<T>>;
|
||||
}
|
||||
|
||||
getCurrentUnitForType<T extends UnitModel>(type: UnitType): Nullable<T> {
|
||||
getCurrentUnitForType<T extends UnitModel>(type: UniverInstanceType): Nullable<T> {
|
||||
return this._currentUnits.get(type) as Nullable<T>;
|
||||
}
|
||||
|
||||
getCurrentUnitOfType<T extends UnitModel>(type: UnitType): Nullable<T> {
|
||||
getCurrentUnitOfType<T extends UnitModel>(type: UniverInstanceType): Nullable<T> {
|
||||
return this.getCurrentUnitForType(type);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
|
||||
private readonly _unitAdded$ = new Subject<UnitModel>();
|
||||
readonly unitAdded$ = this._unitAdded$.asObservable();
|
||||
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type: UnitType): Observable<T> {
|
||||
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T> {
|
||||
return this._unitAdded$.pipe(filter((unit) => unit.type === type)) as Observable<T>;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
return this.unitDisposed$.pipe(filter((unit) => unit.type === type)) as Observable<T>;
|
||||
}
|
||||
|
||||
getUnit<T extends UnitModel = UnitModel>(id: string, type?: UnitType): Nullable<T> {
|
||||
getUnit<T extends UnitModel = UnitModel>(id: string, type?: UniverInstanceType): Nullable<T> {
|
||||
const unit = this._getUnitById(id)?.[0] as Nullable<T>;
|
||||
if (type && unit?.type !== type) return null;
|
||||
return unit;
|
||||
@@ -238,7 +238,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
return this.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET);
|
||||
}
|
||||
|
||||
getAllUnitsForType<T>(type: UnitType): T[] {
|
||||
getAllUnitsForType<T>(type: UniverInstanceType): T[] {
|
||||
return (this._unitsByType.get(type) ?? []) as T[];
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
return true;
|
||||
}
|
||||
|
||||
private _tryResetCurrentOnRemoval(unitId: string, type: UnitType): void {
|
||||
private _tryResetCurrentOnRemoval(unitId: string, type: UniverInstanceType): void {
|
||||
const current = this.getCurrentUnitForType(type);
|
||||
if (current?.getUnitId() === unitId) {
|
||||
this._currentUnits.set(type, null);
|
||||
@@ -341,7 +341,7 @@ export class UniverInstanceService extends Disposable implements IUniverInstance
|
||||
}
|
||||
};
|
||||
|
||||
private _getUnitById(unitId: string): Nullable<[UnitModel, UnitType]> {
|
||||
private _getUnitById(unitId: string): Nullable<[UnitModel, UniverInstanceType]> {
|
||||
for (const [type, units] of this._unitsByType) {
|
||||
const unit = units.find((unit) => unit.getUnitId() === unitId);
|
||||
if (unit) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import type { Ctor, IDisposable } from '../../common/di';
|
||||
import type { UnitType } from '../../common/unit';
|
||||
|
||||
import { skip } from 'rxjs';
|
||||
import pkg from '../../../package.json';
|
||||
import { Inject, Injector } from '../../common/di';
|
||||
@@ -30,7 +30,7 @@ const INIT_LAZY_PLUGINS_TIMEOUT = 4;
|
||||
export const DependentOnSymbol = Symbol('DependentOn');
|
||||
|
||||
export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
|
||||
type: UnitType;
|
||||
type: UniverInstanceType;
|
||||
pluginName: string;
|
||||
packageName: string;
|
||||
version: string;
|
||||
@@ -45,7 +45,7 @@ export abstract class Plugin extends Disposable {
|
||||
static packageName = pkg.name;
|
||||
static version = pkg.version;
|
||||
|
||||
static type: UnitType = UniverInstanceType.UNIVER_UNKNOWN;
|
||||
static type: UniverInstanceType = UniverInstanceType.UNIVER_UNKNOWN;
|
||||
|
||||
protected abstract _injector: Injector;
|
||||
|
||||
@@ -65,7 +65,7 @@ export abstract class Plugin extends Disposable {
|
||||
// empty
|
||||
}
|
||||
|
||||
getUnitType(): UnitType {
|
||||
getUnitType(): UniverInstanceType {
|
||||
return (this.constructor as typeof Plugin).type;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ export class PluginService implements IDisposable {
|
||||
private readonly _seenPlugins = new Set<string>();
|
||||
private readonly _loadedPlugins = new Set<string>();
|
||||
|
||||
private readonly _loadedPluginTypes = new Set<UnitType>([UniverInstanceType.UNIVER_UNKNOWN]);
|
||||
private readonly _loadedPluginTypes = new Set<UniverInstanceType>([UniverInstanceType.UNIVER_UNKNOWN]);
|
||||
|
||||
constructor(
|
||||
@Inject(Injector) private readonly _injector: Injector,
|
||||
@@ -165,7 +165,7 @@ export class PluginService implements IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
startPluginsForType(type: UnitType): void {
|
||||
startPluginsForType(type: UniverInstanceType): void {
|
||||
if (this._loadedPluginTypes.has(type)) {
|
||||
return;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ export class PluginService implements IDisposable {
|
||||
this._loadPluginsForType(type);
|
||||
}
|
||||
|
||||
private _loadPluginsForType(type: UnitType): void {
|
||||
private _loadPluginsForType(type: UniverInstanceType): void {
|
||||
const keys = Array.from(this._pluginRegistry.keys());
|
||||
const allPluginsOfThisType: IPluginRegistryItem[] = [];
|
||||
keys.forEach((key) => {
|
||||
@@ -213,8 +213,8 @@ export class PluginService implements IDisposable {
|
||||
this._seenPlugins.add(ctor.pluginName);
|
||||
}
|
||||
|
||||
private _flushTimerByType = new Map<UnitType, number>();
|
||||
private _flushType(type: UnitType): void {
|
||||
private _flushTimerByType = new Map<UniverInstanceType, number>();
|
||||
private _flushType(type: UniverInstanceType): void {
|
||||
if (this._flushTimerByType.get(type) === undefined) {
|
||||
this._flushTimerByType.set(type, setTimeout(() => {
|
||||
this._loadPluginsForType(type);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import type { Theme } from '@univerjs/themes';
|
||||
import type { Dependency, IDisposable } from './common/di';
|
||||
import type { UnitModel, UnitType } from './common/unit';
|
||||
import type { UnitModel } from './common/unit';
|
||||
import type { LogLevel } from './services/log/log.service';
|
||||
import type { DependencyOverride } from './services/plugin/plugin-override';
|
||||
import type { Plugin, PluginCtor } from './services/plugin/plugin.service';
|
||||
@@ -96,7 +96,7 @@ export interface IUniverConfig {
|
||||
* @hideconstructor
|
||||
*/
|
||||
export class Univer implements IDisposable {
|
||||
private _startedTypes = new Set<UnitType>();
|
||||
private _startedTypes = new Set<UniverInstanceType>();
|
||||
private _injector: Injector;
|
||||
|
||||
private get _univerInstanceService(): IUniverInstanceService {
|
||||
@@ -159,7 +159,7 @@ export class Univer implements IDisposable {
|
||||
this._injector.get(LocaleService).setLocale(locale);
|
||||
}
|
||||
|
||||
createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T>): U {
|
||||
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>): U {
|
||||
return this._univerInstanceService.createUnit(type, data);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ export class Univer implements IDisposable {
|
||||
|
||||
const univerInstanceService = injector.get(IUniverInstanceService) as UniverInstanceService;
|
||||
univerInstanceService.__setCreateHandler(
|
||||
(type: UnitType, data, ctor, options) => {
|
||||
(type: UniverInstanceType, data, ctor, options) => {
|
||||
const isFirstTime = !this._startedTypes.has(type);
|
||||
if (isFirstTime) {
|
||||
this._pluginService.startPluginsForType(type);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel, UnitType } from '@univerjs/core';
|
||||
import type { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel } from '@univerjs/core';
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { BaseObject } from '../base-object';
|
||||
import type { DocComponent } from '../components/docs/doc-component';
|
||||
@@ -73,7 +73,7 @@ export interface IRenderManagerService extends IDisposable {
|
||||
* @param type
|
||||
* @param dep
|
||||
*/
|
||||
registerRenderModule<T extends UnitModel>(type: UnitType, dep: Dependency<T>): IDisposable;
|
||||
registerRenderModule<T extends UnitModel>(type: UniverInstanceType, dep: Dependency<T>): IDisposable;
|
||||
}
|
||||
|
||||
const DEFAULT_SCENE_SIZE = { width: 1500, height: 1000 };
|
||||
@@ -102,7 +102,7 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
|
||||
return this._defaultEngine;
|
||||
}
|
||||
|
||||
private readonly _renderDependencies = new Map<UnitType, Dependency[]>();
|
||||
private readonly _renderDependencies = new Map<UniverInstanceType, Dependency[]>();
|
||||
|
||||
constructor(
|
||||
@Inject(Injector) protected readonly _injector: Injector,
|
||||
@@ -124,7 +124,7 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
|
||||
this._renderDisposed$.complete();
|
||||
}
|
||||
|
||||
registerRenderModules(type: UnitType, deps: Dependency[]): IDisposable {
|
||||
registerRenderModules(type: UniverInstanceType, deps: Dependency[]): IDisposable {
|
||||
if (!this._renderDependencies.has(type)) {
|
||||
this._renderDependencies.set(type, []);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
|
||||
* @param type
|
||||
* @param depCtor
|
||||
*/
|
||||
registerRenderModule(type: UnitType, depCtor: Dependency): IDisposable {
|
||||
registerRenderModule(type: UniverInstanceType, depCtor: Dependency): IDisposable {
|
||||
if (!this._renderDependencies.has(type)) {
|
||||
this._renderDependencies.set(type, []);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
|
||||
* @param type
|
||||
* @returns Dependency[]
|
||||
*/
|
||||
private _getRenderDepsByType(type: UnitType): Array<Dependency> {
|
||||
private _getRenderDepsByType(type: UniverInstanceType): Array<Dependency> {
|
||||
return Array.from(this._renderDependencies.get(type) ?? []);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel, UnitType, UniverInstanceType } from '@univerjs/core';
|
||||
import type { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel, UniverInstanceType } from '@univerjs/core';
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Engine } from '../engine';
|
||||
import type { Scene } from '../scene';
|
||||
@@ -68,7 +68,7 @@ export interface IRenderModule extends IDisposable { }
|
||||
*/
|
||||
export interface IRenderContext<T extends UnitModel = UnitModel> extends Omit<IRender, 'with'> {
|
||||
unit: T;
|
||||
type: UnitType;
|
||||
type: UniverInstanceType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ export class RenderUnit extends Disposable implements IRender {
|
||||
readonly activated$ = this._activated$.pipe(distinctUntilChanged());
|
||||
|
||||
get unitId(): string { return this._renderContext.unitId; }
|
||||
get type(): UnitType { return this._renderContext.type; }
|
||||
get type(): UniverInstanceType { return this._renderContext.type; }
|
||||
|
||||
private readonly _injector: Injector;
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
import type { ICommand, Workbook } from '@univerjs/core';
|
||||
|
||||
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService } from '@univerjs/core';
|
||||
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
|
||||
|
||||
import { UniverType } from '@univerjs/protocol';
|
||||
import { AddWorksheetProtectionCommand, DeleteWorksheetProtectionCommand, WorksheetProtectionRuleModel } from '@univerjs/sheets';
|
||||
|
||||
export const DeleteWorksheetProtectionFormSheetBarCommand: ICommand = {
|
||||
@@ -34,7 +33,7 @@ export const DeleteWorksheetProtectionFormSheetBarCommand: ICommand = {
|
||||
const worksheetProtectionRuleModel = accessor.get(WorksheetProtectionRuleModel);
|
||||
const univerInstanceService = accessor.get(IUniverInstanceService);
|
||||
|
||||
const workbook = univerInstanceService.getCurrentUnitForType<Workbook>(UniverType.UNIVER_SHEET)!;
|
||||
const workbook = univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;
|
||||
const worksheet = workbook?.getActiveSheet();
|
||||
const unitId = workbook.getUnitId();
|
||||
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@
|
||||
import type { UnitAction } from '@univerjs/protocol';
|
||||
|
||||
import type { IObjectModel } from '../../../model/range-protection-rule.model';
|
||||
import { Disposable, Inject, IPermissionService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
||||
import { UnitObject, UniverType } from '@univerjs/protocol';
|
||||
import { Disposable, Inject, IPermissionService, IResourceManagerService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
|
||||
import { UnitObject } from '@univerjs/protocol';
|
||||
import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';
|
||||
|
||||
import { RangeProtectionCache } from '../../../model/range-protection.cache';
|
||||
@@ -95,7 +95,7 @@ export class RangeProtectionService extends Disposable {
|
||||
toJson,
|
||||
parseJson,
|
||||
pluginName: PLUGIN_NAME,
|
||||
businesses: [UniverType.UNIVER_SHEET],
|
||||
businesses: [UniverInstanceType.UNIVER_SHEET],
|
||||
onLoad: (unitId, resources) => {
|
||||
const result = this._selectionProtectionRuleModel.toObject();
|
||||
result[unitId] = resources;
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@
|
||||
import type { Workbook, Worksheet } from '@univerjs/core';
|
||||
import type { IObjectModel, IObjectPointModel } from '../type';
|
||||
import { ILogService, Inject, Injector, IPermissionService, IResourceManagerService, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';
|
||||
import { UniverType } from '@univerjs/protocol';
|
||||
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';
|
||||
@@ -147,7 +146,7 @@ export class WorksheetPermissionService extends RxDisposable {
|
||||
toJson,
|
||||
parseJson,
|
||||
pluginName: RULE_MODEL_PLUGIN_NAME,
|
||||
businesses: [UniverType.UNIVER_SHEET],
|
||||
businesses: [UniverInstanceType.UNIVER_SHEET],
|
||||
onLoad: (unitId, resources) => {
|
||||
this._worksheetProtectionRuleModel.fromObject(resources);
|
||||
Object.keys(resources).forEach((subUnitId) => {
|
||||
@@ -202,7 +201,7 @@ export class WorksheetPermissionService extends RxDisposable {
|
||||
toJson,
|
||||
parseJson,
|
||||
pluginName: POINT_MODEL_PLUGIN_NAME,
|
||||
businesses: [UniverType.UNIVER_SHEET],
|
||||
businesses: [UniverInstanceType.UNIVER_SHEET],
|
||||
onLoad: (unitId, resources) => {
|
||||
this._worksheetProtectionPointRuleModel.fromObject(resources);
|
||||
Object.keys(resources).forEach((subUnitId) => {
|
||||
|
||||
Reference in New Issue
Block a user