@univerjs/core 0.25.0 → 1.0.0-alpha.0
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.
- package/lib/cjs/facade.js +32 -8
- package/lib/cjs/index.js +2519 -1867
- package/lib/es/facade.js +32 -8
- package/lib/es/index.js +2510 -1867
- package/lib/facade.js +32 -8
- package/lib/index.js +2510 -1867
- package/lib/types/bases/base-data-model.d.ts +33 -0
- package/lib/types/bases/empty-snapshot.d.ts +27 -0
- package/lib/types/bases/index.d.ts +18 -0
- package/lib/types/bases/typedef.d.ts +642 -0
- package/lib/types/common/const.d.ts +0 -1
- package/lib/types/common/equal.d.ts +0 -15
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +8 -1
- package/lib/types/docs/data-model/text-x/build-utils/drawings.d.ts +0 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +3 -0
- package/lib/types/docs/paragraph-id.d.ts +24 -0
- package/lib/types/facade/f-univer.d.ts +20 -0
- package/lib/types/facade/f-util.d.ts +1 -1
- package/lib/types/index.d.ts +31 -15
- package/lib/types/services/config/config.service.d.ts +2 -3
- package/lib/types/services/locale/locale.service.d.ts +1 -1
- package/lib/types/services/resource-loader/resource-loader.service.d.ts +2 -1
- package/lib/types/services/resource-manager/resource-manager.service.d.ts +1 -4
- package/lib/types/services/resource-manager/type.d.ts +1 -1
- package/lib/types/services/theme/theme.service.d.ts +2 -2
- package/lib/types/shared/index.d.ts +1 -0
- package/lib/types/shared/locale.d.ts +3 -0
- package/lib/types/{docs/data-model/text-x/build-utils/__test__/text-x.d.ts → shared/random-id.d.ts} +2 -1
- package/lib/types/shared/tools.d.ts +0 -1
- package/lib/types/sheets/typedef.d.ts +20 -32
- package/lib/types/types/const/const.d.ts +1 -1
- package/lib/types/types/interfaces/i-document-data.d.ts +55 -8
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +11 -10
- package/package.json +7 -8
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { ICustomDecoration, IDocumentBlockRange, IDocumentBody, ITextRun } from '../../../types/interfaces/i-document-data';
|
|
17
|
+
import type { DocumentDataModel } from '../../data-model';
|
|
17
18
|
import type { IRetainAction } from './action-types';
|
|
18
19
|
import { UpdateDocsAttributeType } from '../../../shared/command-enum';
|
|
19
20
|
export declare enum SliceBodyType {
|
|
@@ -29,6 +30,7 @@ export declare function getTableSlice(body: IDocumentBody, startOffset: number,
|
|
|
29
30
|
export declare function getBlockRangeSlice(body: IDocumentBody, startOffset: number, endOffset: number): IDocumentBlockRange[];
|
|
30
31
|
export declare function getParagraphsSlice(body: IDocumentBody, startOffset: number, endOffset: number, type?: SliceBodyType): {
|
|
31
32
|
startIndex: number;
|
|
33
|
+
paragraphId: string;
|
|
32
34
|
paragraphStyle?: import("../../..").IParagraphStyle;
|
|
33
35
|
bullet?: import("../../..").IBullet;
|
|
34
36
|
}[] | undefined;
|
|
@@ -89,3 +91,4 @@ export declare function getCustomRangeSlice(body: IDocumentBody, startOffset: nu
|
|
|
89
91
|
export declare function getCustomDecorationSlice(body: IDocumentBody, startOffset: number, endOffset: number): ICustomDecoration[] | undefined;
|
|
90
92
|
export declare function composeBody(thisBody: IDocumentBody, otherBody: IDocumentBody, coverType?: UpdateDocsAttributeType): IDocumentBody;
|
|
91
93
|
export declare function isUselessRetainAction(action: IRetainAction): boolean;
|
|
94
|
+
export declare function getRichTextEditPath(docDataModel: DocumentDataModel, segmentId?: string): string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type { IDocumentBody, IParagraph } from '../types/interfaces/i-document-data';
|
|
17
|
+
export declare const PARAGRAPH_ID_PREFIX = "para_";
|
|
18
|
+
export interface IParagraphIdScope {
|
|
19
|
+
unitId: string;
|
|
20
|
+
segmentId?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function createParagraphId(existingIds: Set<string>): string;
|
|
23
|
+
export declare function cloneBodyWithFreshParagraphIds(body: IDocumentBody, _scope: IParagraphIdScope): IDocumentBody;
|
|
24
|
+
export declare function cloneParagraphWithId(paragraph: IParagraph, existingIds: Set<string>, preserveId?: boolean): IParagraph;
|
|
@@ -144,6 +144,26 @@ export declare class FUniver extends Disposable {
|
|
|
144
144
|
* ```
|
|
145
145
|
*/
|
|
146
146
|
setLocale(locale: string): void;
|
|
147
|
+
/**
|
|
148
|
+
* Get the current locale.
|
|
149
|
+
* @returns {string} The current locale identifier.
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const currentLocale = univerAPI.getCurrentLocale();
|
|
153
|
+
* console.log(currentLocale);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
getCurrentLocale(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Get the locales for the current locale.
|
|
159
|
+
* @returns {ILanguagePack | undefined} The locales object for the current locale, it returns undefined if the locales is not loaded.
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const locales = univerAPI.getLocales();
|
|
163
|
+
* console.log(locales);
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
getLocales(): ILanguagePack | undefined;
|
|
147
167
|
/**
|
|
148
168
|
* Register a callback that will be triggered before invoking a command.
|
|
149
169
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {})` instead.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export * from './bases';
|
|
16
17
|
export { dedupe, dedupeBy, groupBy, makeArray, remove, rotate } from './common/array';
|
|
17
18
|
export * from './common/async';
|
|
18
19
|
export { isBooleanString } from './common/boolean';
|
|
@@ -33,7 +34,8 @@ export { mixinClass } from './common/mixin';
|
|
|
33
34
|
export { isNumeric, isSafeNumeric, willLoseNumericPrecision } from './common/number';
|
|
34
35
|
export { Registry, RegistryAsMap } from './common/registry';
|
|
35
36
|
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
|
36
|
-
export {
|
|
37
|
+
export { sequence, sequenceAsync } from './common/sequence';
|
|
38
|
+
export type { ISequenceExecuteResult } from './common/sequence';
|
|
37
39
|
export { mergeSets } from './common/set';
|
|
38
40
|
export { UnitModel, UniverInstanceType } from './common/unit';
|
|
39
41
|
export { isSafeUrl, normalizeUrl, resolveWithBasePath } from './common/url';
|
|
@@ -44,41 +46,50 @@ export { replaceInDocumentBody } from './docs/data-model/replacement';
|
|
|
44
46
|
export { ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, } from './docs/data-model/rich-text-builder';
|
|
45
47
|
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './docs/data-model/subdocument';
|
|
46
48
|
export { ActionIterator } from './docs/data-model/text-x/action-iterator';
|
|
47
|
-
export {
|
|
49
|
+
export { TextXActionType } from './docs/data-model/text-x/action-types';
|
|
50
|
+
export type { IDeleteAction, IInsertAction, IRetainAction, TextXAction } from './docs/data-model/text-x/action-types';
|
|
48
51
|
export { normalizeTextRuns } from './docs/data-model/text-x/apply-utils/common';
|
|
49
52
|
export { updateAttributeByDelete } from './docs/data-model/text-x/apply-utils/delete-apply';
|
|
50
53
|
export { updateAttributeByInsert } from './docs/data-model/text-x/apply-utils/insert-apply';
|
|
51
54
|
export { getPlainText } from './docs/data-model/text-x/build-utils/parse';
|
|
52
55
|
export { TextX } from './docs/data-model/text-x/text-x';
|
|
53
56
|
export type { TPriority } from './docs/data-model/text-x/text-x';
|
|
54
|
-
export { composeBody, getBodySlice, getCustomBlockSlice, getCustomDecorationSlice, getCustomRangeSlice, getParagraphsSlice, getSectionBreakSlice, getTableSlice, getTextRunSlice, normalizeBody, SliceBodyType, } from './docs/data-model/text-x/utils';
|
|
55
|
-
export {
|
|
57
|
+
export { composeBody, getBodySlice, getCustomBlockSlice, getCustomDecorationSlice, getCustomRangeSlice, getParagraphsSlice, getRichTextEditPath, getSectionBreakSlice, getTableSlice, getTextRunSlice, normalizeBody, SliceBodyType, } from './docs/data-model/text-x/utils';
|
|
58
|
+
export { cloneBodyWithFreshParagraphIds, cloneParagraphWithId, createParagraphId, PARAGRAPH_ID_PREFIX, } from './docs/paragraph-id';
|
|
59
|
+
export type { IParagraphIdScope } from './docs/paragraph-id';
|
|
60
|
+
export { EventState, EventSubject, fromEventSubject } from './observer/observable';
|
|
61
|
+
export type { IEventObserver } from './observer/observable';
|
|
56
62
|
export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
|
|
57
63
|
export { IAuthzIoService } from './services/authz-io/type';
|
|
58
|
-
export { COMMAND_LOG_EXECUTION_CONFIG_KEY,
|
|
64
|
+
export { COMMAND_LOG_EXECUTION_CONFIG_KEY, CommandService, CommandType, ICommandService, NilCommand, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
|
|
65
|
+
export type { CommandListener, ICommand, ICommandInfo, IExecutionOptions, IMultiCommand, IMutation, IMutationCommonParams, IMutationInfo, IOperation, IOperationInfo, } from './services/command/command.service';
|
|
59
66
|
export { IConfigService } from './services/config/config.service';
|
|
60
67
|
export { ConfigService } from './services/config/config.service';
|
|
61
68
|
export { IConfirmService, TestConfirmService } from './services/confirm/confirm.service';
|
|
62
69
|
export * from './services/context/context';
|
|
63
70
|
export { ContextService, IContextService } from './services/context/context.service';
|
|
64
|
-
export { ErrorService
|
|
71
|
+
export { ErrorService } from './services/error/error.service';
|
|
72
|
+
export type { IError } from './services/error/error.service';
|
|
65
73
|
export { IImageIoService, ImageSourceType, ImageUploadStatusType } from './services/image-io/image-io.service';
|
|
66
74
|
export type { IImageIoServiceParam } from './services/image-io/image-io.service';
|
|
67
75
|
export { IURLImageService } from './services/image-io/url-image.service';
|
|
68
|
-
export {
|
|
76
|
+
export { IUniverInstanceService, UniverInstanceService } from './services/instance/instance.service';
|
|
77
|
+
export type { ICreateUnitOptions } from './services/instance/instance.service';
|
|
69
78
|
export { LifecycleStages } from './services/lifecycle/lifecycle';
|
|
70
79
|
export { LifecycleService, LifecycleUnreachableError } from './services/lifecycle/lifecycle.service';
|
|
71
80
|
export { ILocalStorageService } from './services/local-storage/local-storage.service';
|
|
72
81
|
export { LocaleService } from './services/locale/locale.service';
|
|
73
82
|
export { DesktopLogService, ILogService, LogLevel } from './services/log/log.service';
|
|
74
83
|
export { MentionIOLocalService } from './services/mention-io/mention-io-local.service';
|
|
75
|
-
export {
|
|
84
|
+
export { IMentionIOService } from './services/mention-io/type';
|
|
85
|
+
export type { IListMentionParam, IListMentionResponse, ITypeMentionList } from './services/mention-io/type';
|
|
76
86
|
export { PermissionService } from './services/permission/permission.service';
|
|
77
87
|
export { IPermissionService, PermissionStatus } from './services/permission/type';
|
|
78
88
|
export type { IPermissionParam } from './services/permission/type';
|
|
79
89
|
export type { IPermissionPoint } from './services/permission/type';
|
|
80
90
|
export type { IPermissionTypes, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor, } from './services/permission/type';
|
|
81
|
-
export {
|
|
91
|
+
export { mergeOverrideWithDependencies } from './services/plugin/plugin-override';
|
|
92
|
+
export type { DependencyOverride } from './services/plugin/plugin-override';
|
|
82
93
|
export type { PluginCtor } from './services/plugin/plugin.service';
|
|
83
94
|
export { DependentOn, Plugin, PluginService } from './services/plugin/plugin.service';
|
|
84
95
|
export { IResourceLoaderService } from './services/resource-loader/type';
|
|
@@ -86,17 +97,21 @@ export { ResourceManagerService } from './services/resource-manager/resource-man
|
|
|
86
97
|
export type { IResourceHook, IResources } from './services/resource-manager/type';
|
|
87
98
|
export { IResourceManagerService } from './services/resource-manager/type';
|
|
88
99
|
export { ThemeService } from './services/theme/theme.service';
|
|
89
|
-
export {
|
|
100
|
+
export { IUndoRedoService, LocalUndoRedoService, RedoCommand, RedoCommandId, UndoCommand, UndoCommandId, } from './services/undoredo/undoredo.service';
|
|
101
|
+
export type { IUndoRedoCommandInfos, IUndoRedoCommandInfosByInterceptor, IUndoRedoItem, IUndoRedoStatus, } from './services/undoredo/undoredo.service';
|
|
90
102
|
export { createDefaultUser } from './services/user-manager/const';
|
|
91
|
-
export {
|
|
103
|
+
export { UserManagerService } from './services/user-manager/user-manager.service';
|
|
104
|
+
export type { IUser } from './services/user-manager/user-manager.service';
|
|
92
105
|
export * from './shared';
|
|
93
106
|
export { ImageCacheMap } from './shared/cache/image-cache';
|
|
94
107
|
export { isBlackColor, isWhiteColor } from './shared/color/color-kit';
|
|
95
108
|
export { cellToRange } from './shared/common';
|
|
96
109
|
export { customNameCharacterCheck, nameCharacterCheck } from './shared/name';
|
|
97
|
-
export {
|
|
110
|
+
export { RBush, RTree } from './shared/r-tree';
|
|
111
|
+
export type { BBox, IRTreeItem } from './shared/r-tree';
|
|
112
|
+
export { generateRandomId } from './shared/random-id';
|
|
98
113
|
export { getIntersectRange } from './shared/range';
|
|
99
|
-
export { afterTime, bufferDebounceTime, convertObservableToBehaviorSubject, fromCallback, takeAfter } from './shared/rxjs';
|
|
114
|
+
export { afterTime, bufferDebounceTime, convertObservableToBehaviorSubject, fromCallback, takeAfter, } from './shared/rxjs';
|
|
100
115
|
export { awaitTime, delayAnimationFrame } from './shared/timer';
|
|
101
116
|
export { isNodeEnv } from './shared/tools';
|
|
102
117
|
export * from './sheets/clone';
|
|
@@ -108,7 +123,7 @@ export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEF
|
|
|
108
123
|
export { Styles } from './sheets/styles';
|
|
109
124
|
export * from './sheets/typedef';
|
|
110
125
|
export type { IPosition } from './sheets/typedef';
|
|
111
|
-
export { addLinkToDocumentModel, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual } from './sheets/util';
|
|
126
|
+
export { addLinkToDocumentModel, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual, } from './sheets/util';
|
|
112
127
|
export { createDocumentModelWithStyle } from './sheets/util';
|
|
113
128
|
export { SheetViewModel } from './sheets/view-model';
|
|
114
129
|
export { getWorksheetUID, Workbook } from './sheets/workbook';
|
|
@@ -126,4 +141,5 @@ export { DataValidationType } from './types/enum/data-validation-type';
|
|
|
126
141
|
export * from './types/interfaces';
|
|
127
142
|
export type { ICellCustomRender, ICellRenderContext } from './types/interfaces/i-cell-custom-render';
|
|
128
143
|
export type { IDataValidationRule, IDataValidationRuleBase, IDataValidationRuleInfo, IDataValidationRuleOptions, ISheetDataValidationRule, } from './types/interfaces/i-data-validation';
|
|
129
|
-
export {
|
|
144
|
+
export { Univer } from './univer';
|
|
145
|
+
export type { IUniverConfig } from './univer';
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IDisposable } from '../../common/di';
|
|
17
|
-
import type { Nullable } from '../../shared/types';
|
|
18
17
|
import { Observable } from 'rxjs';
|
|
19
18
|
/**
|
|
20
19
|
* IConfig provides universal configuration for the whole application.
|
|
@@ -34,7 +33,7 @@ interface IConfigOptions {
|
|
|
34
33
|
merge?: boolean;
|
|
35
34
|
}
|
|
36
35
|
export interface IConfigService {
|
|
37
|
-
getConfig<T>(id: string | symbol):
|
|
36
|
+
getConfig<T>(id: string | symbol): T;
|
|
38
37
|
setConfig(id: string | symbol, value: unknown, options?: IConfigOptions): void;
|
|
39
38
|
deleteConfig(id: string): boolean;
|
|
40
39
|
subscribeConfigValue$<T = unknown>(key: string): Observable<T>;
|
|
@@ -46,7 +45,7 @@ export declare class ConfigService implements IConfigService, IDisposable {
|
|
|
46
45
|
}>;
|
|
47
46
|
private readonly _config;
|
|
48
47
|
dispose(): void;
|
|
49
|
-
getConfig<T>(id: string | symbol):
|
|
48
|
+
getConfig<T>(id: string | symbol): T;
|
|
50
49
|
setConfig(id: string, value: unknown, options?: IConfigOptions): void;
|
|
51
50
|
deleteConfig(id: string | symbol): boolean;
|
|
52
51
|
subscribeConfigValue$<T = unknown>(key: string): Observable<T>;
|
|
@@ -60,7 +60,7 @@ export declare class LocaleService extends Disposable {
|
|
|
60
60
|
* }
|
|
61
61
|
* t('foo.bar', 'World') => 'Hello World'
|
|
62
62
|
*/
|
|
63
|
-
t: (key:
|
|
63
|
+
t: <TKey extends string = string>(key: TKey, ...args: string[]) => string;
|
|
64
64
|
setLocale(locale: LocaleType): void;
|
|
65
65
|
getLocales(): ILanguagePack | undefined;
|
|
66
66
|
getCurrentLocale(): LocaleType;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { IResources } from '../resource-manager/type';
|
|
16
17
|
import type { IResourceLoaderService } from './type';
|
|
17
18
|
import { Disposable } from '../../shared/lifecycle';
|
|
18
19
|
import { IUniverInstanceService } from '../instance/instance.service';
|
|
@@ -23,6 +24,6 @@ export declare class ResourceLoaderService extends Disposable implements IResour
|
|
|
23
24
|
constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
|
|
24
25
|
private _init;
|
|
25
26
|
saveUnit<T = object>(unitId: string): ({
|
|
26
|
-
resources:
|
|
27
|
+
resources: IResources;
|
|
27
28
|
} & T) | null;
|
|
28
29
|
}
|
|
@@ -26,10 +26,7 @@ export declare class ResourceManagerService extends Disposable implements IResou
|
|
|
26
26
|
getAllResourceHooks(): IResourceHook<any>[];
|
|
27
27
|
getResources(unitId: string): IResources;
|
|
28
28
|
getResources(unitId: string, type: UniverInstanceType): IResources;
|
|
29
|
-
getResourcesByType(unitId: string, type: UniverInstanceType):
|
|
30
|
-
name: `SHEET_${string}_PLUGIN` | `DOC_${string}_PLUGIN`;
|
|
31
|
-
data: string;
|
|
32
|
-
}[];
|
|
29
|
+
getResourcesByType(unitId: string, type: UniverInstanceType): IResources;
|
|
33
30
|
registerPluginResource<T = unknown>(hook: IResourceHook<T>): import("@wendellhu/redi").IDisposable;
|
|
34
31
|
disposePluginResource(pluginName: IResourceName): void;
|
|
35
32
|
loadResources(unitId: string, resources?: IResources): void;
|
|
@@ -21,7 +21,7 @@ export type IResources = Array<{
|
|
|
21
21
|
name: string;
|
|
22
22
|
data: string;
|
|
23
23
|
}>;
|
|
24
|
-
type IBusinessName = 'SHEET' | 'DOC';
|
|
24
|
+
type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE';
|
|
25
25
|
export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
|
|
26
26
|
export interface IResourceHook<T = any> {
|
|
27
27
|
pluginName: IResourceName;
|
|
@@ -55,7 +55,7 @@ export declare class ThemeService extends Disposable {
|
|
|
55
55
|
/**
|
|
56
56
|
* Get a color from the current theme.
|
|
57
57
|
* @param {string} color - The color key to retrieve.
|
|
58
|
-
* @returns
|
|
58
|
+
* @returns The value from the current theme.
|
|
59
59
|
*/
|
|
60
|
-
getColorFromTheme(color: string):
|
|
60
|
+
getColorFromTheme<T = string>(color: string): T;
|
|
61
61
|
}
|
|
@@ -35,6 +35,7 @@ export type { INumfmtLocaleTag } from './numfmt';
|
|
|
35
35
|
export { currencySymbols, DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isTextFormat, numfmt, } from './numfmt';
|
|
36
36
|
export * from './object-matrix';
|
|
37
37
|
export { queryObjectMatrix } from './object-matrix-query';
|
|
38
|
+
export * from './random-id';
|
|
38
39
|
export { moveRangeByOffset, splitIntoGrid } from './range';
|
|
39
40
|
export * from './rectangle';
|
|
40
41
|
export { RefAlias } from './ref-alias';
|
|
@@ -20,6 +20,9 @@ export interface ILanguagePack {
|
|
|
20
20
|
export interface ILocales {
|
|
21
21
|
[key: string]: ILanguagePack;
|
|
22
22
|
}
|
|
23
|
+
export type LocaleLeafKeys<T> = {
|
|
24
|
+
[K in keyof T & string]: T[K] extends string ? K : T[K] extends readonly unknown[] ? never : T[K] extends Record<string, unknown> ? `${K}.${LocaleLeafKeys<T[K]>}` : never;
|
|
25
|
+
}[keyof T & string];
|
|
23
26
|
type MergeLocalesInput = Record<string, any>;
|
|
24
27
|
/**
|
|
25
28
|
* Merges multiple locale objects into a single locale object.
|
package/lib/types/{docs/data-model/text-x/build-utils/__test__/text-x.d.ts → shared/random-id.d.ts}
RENAMED
|
@@ -13,4 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export declare function createRandomId(size?: number, alphabet?: string): string;
|
|
17
|
+
export declare function generateRandomId(n?: number, alphabet?: string): string;
|
|
@@ -78,7 +78,6 @@ export declare class Tools {
|
|
|
78
78
|
static clamp(value: number, min: number, max: number): number;
|
|
79
79
|
static now(): number;
|
|
80
80
|
}
|
|
81
|
-
export declare function generateRandomId(n?: number, alphabet?: string): string;
|
|
82
81
|
/**
|
|
83
82
|
* compose styles by priority, the latter will overwrite the former
|
|
84
83
|
* @param { Nullable<IStyleData>[]} styles the styles to be composed
|
|
@@ -67,7 +67,10 @@ export interface IWorkbookData {
|
|
|
67
67
|
*/
|
|
68
68
|
resources?: IResources;
|
|
69
69
|
/**
|
|
70
|
-
* User stored custom fields
|
|
70
|
+
* User stored custom fields.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This field is not recommended for external use. Use it at your own risk.
|
|
71
74
|
*/
|
|
72
75
|
custom?: CustomData;
|
|
73
76
|
}
|
|
@@ -127,7 +130,10 @@ export interface IWorksheetData {
|
|
|
127
130
|
gridlinesColor?: string;
|
|
128
131
|
rightToLeft: BooleanNumber;
|
|
129
132
|
/**
|
|
130
|
-
* User stored custom fields
|
|
133
|
+
* User stored custom fields.
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* This field is not recommended for external use. Use it at your own risk.
|
|
131
137
|
*/
|
|
132
138
|
custom?: CustomData;
|
|
133
139
|
}
|
|
@@ -157,7 +163,10 @@ export interface IRowData {
|
|
|
157
163
|
*/
|
|
158
164
|
s?: Nullable<IStyleData | string>;
|
|
159
165
|
/**
|
|
160
|
-
* User stored custom fields
|
|
166
|
+
* User stored custom fields.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* This field is not recommended for external use. Use it at your own risk.
|
|
161
170
|
*/
|
|
162
171
|
custom?: CustomData;
|
|
163
172
|
}
|
|
@@ -182,7 +191,10 @@ export interface IColumnData {
|
|
|
182
191
|
*/
|
|
183
192
|
s?: Nullable<IStyleData | string>;
|
|
184
193
|
/**
|
|
185
|
-
* User stored custom fields
|
|
194
|
+
* User stored custom fields.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* This field is not recommended for external use. Use it at your own risk.
|
|
186
198
|
*/
|
|
187
199
|
custom?: CustomData;
|
|
188
200
|
}
|
|
@@ -229,7 +241,10 @@ export interface ICellData {
|
|
|
229
241
|
*/
|
|
230
242
|
si?: Nullable<string>;
|
|
231
243
|
/**
|
|
232
|
-
* User stored custom fields
|
|
244
|
+
* User stored custom fields.
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* This field is not recommended for external use. Use it at your own risk.
|
|
233
248
|
*/
|
|
234
249
|
custom?: CustomData;
|
|
235
250
|
}
|
|
@@ -446,33 +461,6 @@ export interface IRangeCellData {
|
|
|
446
461
|
* Allow users to provide one of three formats, we need to convert to IRange to store
|
|
447
462
|
*/
|
|
448
463
|
export type IRangeType = IRange | IRangeStringData | IRangeArrayData | IRangeCellData;
|
|
449
|
-
/**
|
|
450
|
-
* Whether to clear only the contents. Whether to clear only the format; note that clearing format also clears data validation rules.
|
|
451
|
-
*/
|
|
452
|
-
export interface IOptionData {
|
|
453
|
-
/**
|
|
454
|
-
* 1. designates that only the format should be copied
|
|
455
|
-
*
|
|
456
|
-
* 2. Whether to clear only the format; note that clearing format also clears data validation rules.
|
|
457
|
-
*
|
|
458
|
-
* 3. worksheet Whether to clear the format.
|
|
459
|
-
*/
|
|
460
|
-
formatOnly?: boolean;
|
|
461
|
-
/**
|
|
462
|
-
* 1. designates that only the content should be copied
|
|
463
|
-
*
|
|
464
|
-
* 2. Whether to clear only the contents.
|
|
465
|
-
*
|
|
466
|
-
* 3. worksheet Whether to clear the content.
|
|
467
|
-
*
|
|
468
|
-
*/
|
|
469
|
-
contentsOnly?: boolean;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Option of copyTo function
|
|
473
|
-
*/
|
|
474
|
-
export interface ICopyToOptionsData extends IOptionData {
|
|
475
|
-
}
|
|
476
464
|
export interface IRectLTRB {
|
|
477
465
|
left: number;
|
|
478
466
|
top: number;
|
|
@@ -159,7 +159,7 @@ export declare const SHEET_EDITOR_UNITS: string[];
|
|
|
159
159
|
export declare const NAMED_STYLE_MAP: Record<NamedStyleType, Nullable<ITextStyle>>;
|
|
160
160
|
export declare const DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = 1.5;
|
|
161
161
|
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = 0;
|
|
162
|
-
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW =
|
|
162
|
+
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = 12;
|
|
163
163
|
export declare const NAMED_STYLE_SPACE_MAP: Record<NamedStyleType, Nullable<IParagraphStyle>>;
|
|
164
164
|
export declare const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
|
|
165
165
|
export declare const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import type { ImageSourceType } from '../../services/image-io/image-io.service';
|
|
17
|
+
import type { IResources } from '../../services/resource-manager/type';
|
|
16
18
|
import type { ISize } from '../../shared/shape';
|
|
17
19
|
import type { BooleanNumber, CellValueType, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
|
|
18
20
|
import type { IDrawingParam } from './i-drawing';
|
|
@@ -31,11 +33,7 @@ export interface IDocumentData extends IReferenceSource {
|
|
|
31
33
|
body?: IDocumentBody;
|
|
32
34
|
documentStyle: IDocumentStyle;
|
|
33
35
|
settings?: IDocumentSettings;
|
|
34
|
-
resources?:
|
|
35
|
-
id?: string;
|
|
36
|
-
name: string;
|
|
37
|
-
data: string;
|
|
38
|
-
}>;
|
|
36
|
+
resources?: IResources;
|
|
39
37
|
disabled?: boolean;
|
|
40
38
|
}
|
|
41
39
|
export interface IReferenceSource {
|
|
@@ -141,14 +139,14 @@ export declare enum DocStyleType {
|
|
|
141
139
|
/**
|
|
142
140
|
* Properties of doc footer
|
|
143
141
|
*/
|
|
144
|
-
export interface IFooterData {
|
|
142
|
+
export interface IFooterData extends IReferenceSource {
|
|
145
143
|
footerId: string;
|
|
146
144
|
body: IDocumentBody;
|
|
147
145
|
}
|
|
148
146
|
/**
|
|
149
147
|
* Properties of doc header
|
|
150
148
|
*/
|
|
151
|
-
export interface IHeaderData {
|
|
149
|
+
export interface IHeaderData extends IReferenceSource {
|
|
152
150
|
headerId: string;
|
|
153
151
|
body: IDocumentBody;
|
|
154
152
|
}
|
|
@@ -303,11 +301,16 @@ export type IHyperLinkCustomRange = ICustomRange<{
|
|
|
303
301
|
url: string;
|
|
304
302
|
}>;
|
|
305
303
|
export type IMentionCustomRange = ICustomRange<IMention>;
|
|
304
|
+
export declare enum DocumentBlockRangeType {
|
|
305
|
+
CALLOUT = "callout",
|
|
306
|
+
QUOTE = "quote",
|
|
307
|
+
CODE = "code"
|
|
308
|
+
}
|
|
306
309
|
export interface IDocumentBlockRange {
|
|
307
310
|
startIndex: number;
|
|
308
311
|
endIndex: number;
|
|
309
312
|
blockId: string;
|
|
310
|
-
blockType:
|
|
313
|
+
blockType: DocumentBlockRangeType;
|
|
311
314
|
}
|
|
312
315
|
export declare enum CustomRangeType {
|
|
313
316
|
HYPERLINK = 0,
|
|
@@ -390,6 +393,11 @@ export declare enum GridType {
|
|
|
390
393
|
}
|
|
391
394
|
export interface IDocumentStyle extends IDocStyleBase, IDocumentLayout, IHeaderAndFooterBase {
|
|
392
395
|
textStyle?: ITextStyle;
|
|
396
|
+
background?: IDocumentBackground;
|
|
397
|
+
}
|
|
398
|
+
export interface IDocumentBackground {
|
|
399
|
+
source?: string;
|
|
400
|
+
sourceType?: ImageSourceType;
|
|
393
401
|
}
|
|
394
402
|
/**
|
|
395
403
|
* the alignment mode is returned with respect to the offset of the sheet cell,
|
|
@@ -415,6 +423,7 @@ export interface IDocumentRenderConfig {
|
|
|
415
423
|
cellValueType?: CellValueType;
|
|
416
424
|
isRenderStyle?: BooleanNumber;
|
|
417
425
|
zeroWidthParagraphBreak?: BooleanNumber;
|
|
426
|
+
shapeTextOpticalVerticalAlign?: BooleanNumber;
|
|
418
427
|
}
|
|
419
428
|
export interface ISectionBreakBase {
|
|
420
429
|
charSpace?: number;
|
|
@@ -468,6 +477,7 @@ export interface ISectionColumnProperties {
|
|
|
468
477
|
}
|
|
469
478
|
export interface IParagraph {
|
|
470
479
|
startIndex: number;
|
|
480
|
+
paragraphId: string;
|
|
471
481
|
paragraphStyle?: IParagraphStyle;
|
|
472
482
|
bullet?: IBullet;
|
|
473
483
|
}
|
|
@@ -555,10 +565,47 @@ export interface IChartProperties {
|
|
|
555
565
|
/**
|
|
556
566
|
* Properties of text style
|
|
557
567
|
*/
|
|
568
|
+
export type DocTextFillType = 'none' | 'solid' | 'gradient' | 'picture';
|
|
569
|
+
export type DocTextFillGradientType = 'linear' | 'radial' | 'angular' | 'diamond';
|
|
570
|
+
export type DocTextFillPictureMode = 'stretch' | 'tile';
|
|
571
|
+
export interface IDocTextFillGradientStop {
|
|
572
|
+
/**
|
|
573
|
+
* Offset in percent. Values in the 0-1 range are also accepted by renderers
|
|
574
|
+
* for compatibility and normalized to percent.
|
|
575
|
+
*/
|
|
576
|
+
offset: number;
|
|
577
|
+
color: string;
|
|
578
|
+
opacity?: number;
|
|
579
|
+
}
|
|
580
|
+
export interface IDocTextFill {
|
|
581
|
+
/**
|
|
582
|
+
* Hidden renderer-level text fill. Normal document UI does not expose it,
|
|
583
|
+
* but rich-text renderers honor it when present on a run style.
|
|
584
|
+
*/
|
|
585
|
+
type: DocTextFillType;
|
|
586
|
+
color?: string;
|
|
587
|
+
opacity?: number;
|
|
588
|
+
gradient?: {
|
|
589
|
+
type?: DocTextFillGradientType;
|
|
590
|
+
angle?: number;
|
|
591
|
+
stops?: IDocTextFillGradientStop[];
|
|
592
|
+
};
|
|
593
|
+
picture?: {
|
|
594
|
+
source?: string;
|
|
595
|
+
sourceType?: ImageSourceType;
|
|
596
|
+
opacity?: number;
|
|
597
|
+
mode?: DocTextFillPictureMode;
|
|
598
|
+
scaleX?: number;
|
|
599
|
+
scaleY?: number;
|
|
600
|
+
offsetX?: number;
|
|
601
|
+
offsetY?: number;
|
|
602
|
+
};
|
|
603
|
+
}
|
|
558
604
|
export interface ITextStyle extends IStyleBase {
|
|
559
605
|
sc?: number;
|
|
560
606
|
pos?: number;
|
|
561
607
|
sa?: number;
|
|
608
|
+
textFill?: IDocTextFill;
|
|
562
609
|
}
|
|
563
610
|
export interface IIndentStart {
|
|
564
611
|
indentFirstLine?: INumberUnit;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t==null?`text/plain`:t});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,"FHooks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t==null?`text/plain`:t});return this._blob=n,this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get DocCreated(){return`DocCreated`}get DocDisposed(){return`DocDisposed`}get LifeCycleChanged(){return`LifeCycleChanged`}get Redo(){return`Redo`}get Undo(){return`Undo`}get BeforeRedo(){return`BeforeRedo`}get BeforeUndo(){return`BeforeUndo`}get CommandExecuted(){return`CommandExecuted`}get BeforeCommandExecute(){return`BeforeCommandExecute`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,"FHooks",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|