@univerjs/core 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,6 @@ export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './docs/data-model/subdocument
17
17
  export { type UnitType, UnitModel, UniverInstanceType } from './common/unit';
18
18
  export { Registry, RegistryAsMap } from './common/registry';
19
19
  export { Univer } from './univer';
20
- export { PluginHolder } from './services/plugin/plugin-holder';
21
20
  export { shallowEqual, isRangesEqual, isUnitRangesEqual } from './common/equal';
22
21
  export { isNumeric, isSafeNumeric } from './common/number';
23
22
  export { isBooleanString } from './common/boolean';
@@ -40,7 +39,7 @@ export type { JSONXActions, JSONXPath } from './docs/data-model/json-x/json-x';
40
39
  export { replaceInDocumentBody } from './docs/data-model/replacement';
41
40
  export * from './observer';
42
41
  export { Plugin } from './services/plugin/plugin';
43
- export { PluginService } from './services/plugin/plugin.service';
42
+ export { PluginService, DependentOn } from './services/plugin/plugin.service';
44
43
  export { type CommandListener, CommandService, CommandType, type ICommand, type ICommandInfo, ICommandService, type IExecutionOptions, type IMultiCommand, type IMutation, type IMutationCommonParams, type IMutationInfo, type IOperation, type IOperationInfo, NilCommand, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
45
44
  export { IConfigService } from './services/config/config.service';
46
45
  export * from './services/context/context';
@@ -63,7 +62,7 @@ export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
63
62
  export { type IUndoRedoCommandInfos, type IUndoRedoCommandInfosByInterceptor, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, UndoCommand, RedoCommandId, UndoCommandId, } from './services/undoredo/undoredo.service';
64
63
  export * from './shared';
65
64
  export { fromCallback } from './shared/rxjs';
66
- export { UserManagerService } from './services/user-manager/user-manager.service';
65
+ export { UserManagerService, type IUser } from './services/user-manager/user-manager.service';
67
66
  export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
68
67
  export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
69
68
  export { normalizeTextRuns } from './docs/data-model/text-x/apply-utils/common';
@@ -101,7 +100,8 @@ export { DataValidationImeMode } from './types/enum/data-validation-ime-mode';
101
100
  export { DataValidationOperator } from './types/enum/data-validation-operator';
102
101
  export { DataValidationType } from './types/enum/data-validation-type';
103
102
  export { DataValidationStatus } from './types/enum/data-validation-status';
104
- export type { IPermissionTypes } from './services/permission/type';
103
+ export type { IPermissionTypes, WorkbookPermissionPointConstructor } from './services/permission/type';
104
+ export { PermissionService } from './services/permission/permission.service';
105
105
  export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
106
106
  export { IAuthzIoService } from './services/authz-io/type';
107
107
  export { createDefaultUser } from './services/user-manager/const';
@@ -8,9 +8,9 @@ export declare enum PermissionStatus {
8
8
  FETCHING = "fetching",
9
9
  DONE = "done"
10
10
  }
11
- type WorkbookPermissionPointConstructor = new (unitId: string) => IPermissionPoint;
12
- type WorkSheetPermissionPointConstructor = new (unitId: string, subUnitId: string) => IPermissionPoint;
13
- type RangePermissionPointConstructor = new (unitId: string, subUnitId: string, permissionId: string) => IPermissionPoint;
11
+ export type WorkbookPermissionPointConstructor = new (unitId: string) => IPermissionPoint;
12
+ export type WorkSheetPermissionPointConstructor = new (unitId: string, subUnitId: string) => IPermissionPoint;
13
+ export type RangePermissionPointConstructor = new (unitId: string, subUnitId: string, permissionId: string) => IPermissionPoint;
14
14
  export interface IPermissionTypes {
15
15
  rangeTypes?: RangePermissionPointConstructor[];
16
16
  worksheetTypes?: WorkSheetPermissionPointConstructor[];
@@ -40,4 +40,3 @@ export interface IPermissionService {
40
40
  composePermission(permissionId: string[]): IPermissionPoint<unknown>[];
41
41
  }
42
42
  export declare const IPermissionService: import('@wendellhu/redi').IdentifierDecorator<IPermissionService>;
43
- export {};
@@ -2,9 +2,11 @@ import { Ctor, Injector } from '@wendellhu/redi';
2
2
  import { Disposable } from '../../shared';
3
3
  import { UniverInstanceType } from '../../common/unit';
4
4
 
5
- export type PluginCtor<T extends Plugin> = Ctor<T> & {
5
+ export declare const DependentOnSymbol: unique symbol;
6
+ export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
6
7
  type: UniverInstanceType;
7
8
  pluginName: string;
9
+ [DependentOnSymbol]?: PluginCtor[];
8
10
  };
9
11
  /**
10
12
  * Plug-in base class, all plug-ins must inherit from this base class. Provide basic methods.
@@ -13,7 +15,7 @@ export declare abstract class Plugin extends Disposable {
13
15
  static pluginName: string;
14
16
  static type: UniverInstanceType;
15
17
  protected abstract _injector: Injector;
16
- onStarting(_injector: Injector): void;
18
+ onStarting(injector: Injector): void;
17
19
  onReady(): void;
18
20
  onRendered(): void;
19
21
  onSteady(): void;
@@ -1,8 +1,23 @@
1
1
  import { IDisposable, Injector } from '@wendellhu/redi';
2
- import { UnitType, UniverInstanceType } from '../../common/unit';
3
- import { PluginHolder } from './plugin-holder';
4
- import { Plugin, PluginCtor } from './plugin';
2
+ import { Disposable } from '../../shared/lifecycle';
3
+ import { UniverInstanceType } from '../../common/unit';
4
+ import { LifecycleInitializerService, LifecycleService } from '../lifecycle/lifecycle.service';
5
+ import { ILogService } from '../log/log.service';
6
+ import { Plugin, PluginCtor, PluginRegistry, PluginStore } from './plugin';
5
7
 
8
+ /**
9
+ * Use this decorator to declare dependencies among plugins. If a dependent plugin is not registered yet,
10
+ * Univer will automatically register it with no configuration.
11
+ *
12
+ * For example:
13
+ *
14
+ * ```ts
15
+ * ⁣@DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin)
16
+ * export class UniverSheetsDrawingUIPlugin extends Plugin {
17
+ * }
18
+ * ```
19
+ */
20
+ export declare function DependentOn(...plugins: PluginCtor<Plugin>[]): (target: PluginCtor<Plugin>) => void;
6
21
  /**
7
22
  * This service manages plugin registration.
8
23
  */
@@ -10,15 +25,40 @@ export declare class PluginService implements IDisposable {
10
25
  private readonly _injector;
11
26
  private readonly _pluginHolderForUniver;
12
27
  private readonly _pluginHoldersForTypes;
28
+ private readonly _seenPlugins;
13
29
  constructor(_injector: Injector);
14
30
  dispose(): void;
15
31
  /** Register a plugin into univer. */
16
- registerPlugin<T extends PluginCtor<Plugin>>(plugin: T, config?: ConstructorParameters<T>[0]): void;
32
+ registerPlugin<T extends PluginCtor>(ctor: T, config?: ConstructorParameters<T>[0]): void;
17
33
  startPluginForType(type: UniverInstanceType): void;
18
- _ensurePluginHolderForType(type: UnitType): PluginHolder;
34
+ private _ensurePluginHolderForType;
35
+ private _immediateInitPlugin;
36
+ private _checkPluginSeen;
19
37
  private _assertPluginValid;
20
38
  private _flushTimer?;
21
39
  private _scheduleInitPlugin;
22
40
  private _clearFlushTimer;
23
41
  private _flushPlugins;
24
42
  }
43
+ export declare class PluginHolder extends Disposable {
44
+ private _checkPluginRegistered;
45
+ private _registerPlugin;
46
+ protected readonly _logService: ILogService;
47
+ protected readonly _injector: Injector;
48
+ protected readonly _lifecycleService: LifecycleService;
49
+ protected readonly _lifecycleInitializerService: LifecycleInitializerService;
50
+ protected _started: boolean;
51
+ get started(): boolean;
52
+ /** Plugin constructors waiting to be initialized. */
53
+ protected readonly _pluginRegistry: PluginRegistry;
54
+ /** Stores initialized plugin instances. */
55
+ protected readonly _pluginStore: PluginStore;
56
+ constructor(_checkPluginRegistered: (pluginCtor: PluginCtor) => boolean, _registerPlugin: <T extends PluginCtor>(plugin: T, config?: ConstructorParameters<T>[0]) => void, _logService: ILogService, _injector: Injector, _lifecycleService: LifecycleService, _lifecycleInitializerService: LifecycleInitializerService);
57
+ dispose(): void;
58
+ register<T extends PluginCtor<Plugin>>(pluginCtor: T, config?: ConstructorParameters<T>[0]): void;
59
+ immediateInitPlugin<T extends Plugin>(plugin: PluginCtor<T>): void;
60
+ start(): void;
61
+ flush(): void;
62
+ private _initPlugin;
63
+ protected _pluginsRunLifecycle(plugins: Plugin[]): void;
64
+ }
@@ -1,4 +1,4 @@
1
1
  import { IUser, UnitRole } from '@univerjs/protocol';
2
2
 
3
- export declare const createDefaultUser: (type: UnitRole) => IUser;
3
+ export declare const createDefaultUser: (type?: UnitRole) => IUser;
4
4
  export declare const isDevRole: (userId: string, type: UnitRole) => boolean;
@@ -1,5 +1,23 @@
1
- import { IUser } from '@univerjs/protocol';
2
-
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export interface IUser {
17
+ userID: string;
18
+ name: string;
19
+ avatar?: string;
20
+ }
3
21
  export declare class UserManagerService {
4
22
  private _model;
5
23
  private _userChange$;
@@ -15,10 +33,10 @@ export declare class UserManagerService {
15
33
  * @memberof UserManagerService
16
34
  */
17
35
  currentUser$: import('rxjs').Observable<IUser>;
18
- get currentUser(): IUser;
19
- set currentUser(user: IUser);
20
- addUser(user: IUser): void;
21
- getUser(userId: string, callBack?: () => void): IUser | undefined;
36
+ getCurrentUser<T extends IUser>(): T;
37
+ setCurrentUser<T extends IUser>(user: T): void;
38
+ addUser<T extends IUser>(user: T): void;
39
+ getUser<T extends IUser>(userId: string, callBack?: () => void): T | undefined;
22
40
  delete(userId: string): void;
23
41
  clear(): void;
24
42
  }
@@ -14,5 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  type debounceFn<T extends (...args: any[]) => any> = (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
17
- export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): debounceFn<T>;
17
+ /**
18
+ * Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked.
19
+ * @template T - The type of the function to be debounced.
20
+ * @param {T} func - The function to be debounced.
21
+ * @param {number} wait - The number of milliseconds to wait before invoking the function.
22
+ * @returns {debounceFn<T> & { cancel: () => void }} - The debounced function, which also has a `cancel` method to cancel the scheduled function call.
23
+ */
24
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): debounceFn<T> & {
25
+ cancel: () => void;
26
+ };
18
27
  export {};
@@ -97,4 +97,12 @@ export declare class Tools {
97
97
  static hasIntersectionBetweenTwoRanges(range1Start: number, range1End: number, range2Start: number, range2End: number): boolean;
98
98
  static isStartValidPosition(name: string): boolean;
99
99
  static isValidParameter(name: string): boolean;
100
+ /**
101
+ * As lodash set, via a path string to set value to deep property
102
+ * set(obj, 'xx.yy', val)
103
+ * @param data
104
+ * @param propertyPath
105
+ * @param value
106
+ */
107
+ static set(data: Record<string, any>, propertyPath: string, value: any): void;
100
108
  }
@@ -33,6 +33,7 @@ export declare class Range {
33
33
  private _worksheet;
34
34
  constructor(workSheet: Worksheet, range: IRange, _deps: IRangeDependencies);
35
35
  static foreach(range: IRange, action: (row: number, column: number) => void): void;
36
+ static transformRange: (range: IRange, worksheet: Worksheet) => IRange;
36
37
  /**
37
38
  * get current range data
38
39
  *
@@ -89,6 +89,10 @@ export declare class Worksheet {
89
89
  getRange(range: IRange): Range;
90
90
  getRange(startRow: number, startColumn: number): Range;
91
91
  getRange(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
92
+ getScrollLeftTopFromSnapshot(): {
93
+ scrollLeft: number;
94
+ scrollTop: number;
95
+ };
92
96
  /**
93
97
  * Return WorkSheetZoomRatio
94
98
  * @return zoomRatio
@@ -1,4 +1,6 @@
1
1
  import { Nullable } from '../../shared';
2
+ import { Worksheet } from '../../sheets/worksheet';
3
+ import { Workbook } from '../../sheets/workbook';
2
4
  import { ISelectionCellWithCoord } from './i-selection-data';
3
5
  import { IStyleData } from './i-style-data';
4
6
  import { ICellDataForSheetInterceptor } from './i-cell-data';
@@ -11,6 +13,8 @@ export interface ICellRenderContext {
11
13
  subUnitId: string;
12
14
  row: number;
13
15
  col: number;
16
+ worksheet: Worksheet;
17
+ workbook?: Workbook;
14
18
  }
15
19
  /**
16
20
  * @debt This shouldn't exist in core package.
@@ -291,6 +291,7 @@ export interface IDocumentRenderConfig {
291
291
  background?: IColorStyle;
292
292
  wrapStrategy?: WrapStrategy;
293
293
  cellValueType?: CellValueType;
294
+ isRenderStyle?: BooleanNumber;
294
295
  }
295
296
  export interface ISectionBreakBase {
296
297
  columnProperties?: ISectionColumnProperties[];
@@ -21,3 +21,7 @@ export interface IRowData {
21
21
  */
22
22
  hd?: BooleanNumber;
23
23
  }
24
+ export interface IRowAutoHeightInfo {
25
+ row: number;
26
+ autoHeight?: number;
27
+ }
@@ -48,3 +48,7 @@ export interface ITextRangeParam extends ITextRange {
48
48
  segmentId?: string;
49
49
  isActive?: boolean;
50
50
  }
51
+ /**
52
+ * Determines whether the cell(row, column) is within the range of the merged cells.
53
+ */
54
+ export declare function getCellInfoInMergeData(row: number, column: number, mergeData?: IRange[]): ISelectionCell;