@univerjs/core 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +85 -27
- package/lib/cjs/index.js +9898 -8248
- package/lib/es/facade.js +86 -28
- package/lib/es/index.js +9864 -8253
- package/lib/facade.js +86 -28
- package/lib/index.js +9864 -8253
- package/lib/types/bases/base-data-model.d.ts +4 -0
- package/lib/types/bases/empty-snapshot.d.ts +2 -1
- package/lib/types/bases/index.d.ts +3 -2
- package/lib/types/bases/typedef.d.ts +80 -67
- package/lib/types/common/regexp/charset.d.ts +63 -0
- package/lib/types/common/regexp/escape.d.ts +30 -0
- package/lib/types/common/regexp/factory.d.ts +16 -0
- package/lib/types/common/regexp/index.d.ts +37 -0
- package/lib/types/common/regexp/or.d.ts +57 -0
- package/lib/types/docs/data-model/empty-snapshot.d.ts +2 -1
- package/lib/types/docs/data-model/index.d.ts +20 -0
- package/lib/types/docs/data-model/paragraph-style.d.ts +22 -0
- package/lib/types/docs/data-model/preset-list-type.d.ts +19 -6
- package/lib/types/docs/data-model/rich-text-builder.d.ts +269 -1
- package/lib/types/docs/data-model/text-x/action-types.d.ts +1 -0
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +4 -1
- package/lib/types/docs/data-model/text-x/build-utils/data-stream-change.d.ts +28 -0
- package/lib/types/docs/data-model/text-x/build-utils/index.d.ts +5 -0
- package/lib/types/docs/data-model/text-x/build-utils/paragraph.d.ts +4 -1
- package/lib/types/docs/data-model/text-x/build-utils/range-interval.d.ts +74 -0
- package/lib/types/docs/data-model/text-x/structure-validator.d.ts +31 -0
- package/lib/types/docs/data-model/text-x/utils.d.ts +12 -4
- package/lib/types/docs/index.d.ts +5 -0
- package/lib/types/docs/section-break-id.d.ts +19 -0
- package/lib/types/docs/section-header-footer.d.ts +32 -0
- package/lib/types/facade/f-enum.d.ts +40 -1
- package/lib/types/facade/f-hooks.d.ts +8 -0
- package/lib/types/facade/f-univer.d.ts +28 -27
- package/lib/types/index.d.ts +3 -32
- package/lib/types/services/authz-io/authz-io-local.service.d.ts +1 -1
- package/lib/types/services/instance/instance.service.d.ts +26 -0
- package/lib/types/services/resource-manager/type.d.ts +1 -1
- package/lib/types/shared/date-kit.d.ts +1 -0
- package/lib/types/shared/tools.d.ts +0 -11
- package/lib/types/sheets/index.d.ts +26 -0
- package/lib/types/sheets/typedef.d.ts +2 -0
- package/lib/types/types/const/const.d.ts +0 -1
- package/lib/types/types/enum/locale-type.d.ts +9 -0
- package/lib/types/types/interfaces/i-document-data-interceptor.d.ts +1 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +35 -2
- package/lib/types/types/interfaces/i-drawing.d.ts +25 -1
- package/lib/types/types/interfaces/i-style-data.d.ts +1 -5
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +19 -11
- package/package.json +5 -5
|
@@ -25,41 +25,49 @@ export declare class FHooks extends FBase {
|
|
|
25
25
|
constructor(_injector: Injector, _lifecycleService: LifecycleService);
|
|
26
26
|
/**
|
|
27
27
|
* @param callback
|
|
28
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
28
29
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
29
30
|
*/
|
|
30
31
|
onStarting(callback: () => void): IDisposable;
|
|
31
32
|
/**
|
|
32
33
|
* @param callback
|
|
34
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
33
35
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
34
36
|
*/
|
|
35
37
|
onReady(callback: () => void): IDisposable;
|
|
36
38
|
/**
|
|
37
39
|
* @param callback
|
|
40
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
38
41
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
39
42
|
*/
|
|
40
43
|
onRendered(callback: () => void): IDisposable;
|
|
41
44
|
/**
|
|
42
45
|
* @param callback
|
|
46
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
43
47
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
|
|
44
48
|
*/
|
|
45
49
|
onSteady(callback: () => void): IDisposable;
|
|
46
50
|
/**
|
|
47
51
|
* @param callback
|
|
52
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
48
53
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
|
|
49
54
|
*/
|
|
50
55
|
onBeforeUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
|
|
51
56
|
/**
|
|
52
57
|
* @param callback
|
|
58
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
53
59
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
|
|
54
60
|
*/
|
|
55
61
|
onUndo(callback: (action: IUndoRedoItem) => void): IDisposable;
|
|
56
62
|
/**
|
|
57
63
|
* @param callback
|
|
64
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
58
65
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
|
|
59
66
|
*/
|
|
60
67
|
onBeforeRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
|
|
61
68
|
/**
|
|
62
69
|
* @param callback
|
|
70
|
+
* @returns {IDisposable} A disposable used to remove the listener.
|
|
63
71
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
|
|
64
72
|
*/
|
|
65
73
|
onRedo(callback: (action: IUndoRedoItem) => void): IDisposable;
|
|
@@ -259,46 +259,47 @@ export declare class FUniver extends Disposable {
|
|
|
259
259
|
newBlob(): FBlob;
|
|
260
260
|
/**
|
|
261
261
|
* Create a new rich text.
|
|
262
|
-
* @param {IDocumentData} data
|
|
263
262
|
* @returns {RichTextBuilder} The new rich text instance
|
|
264
263
|
* @example
|
|
265
264
|
* ```ts
|
|
266
|
-
* const richText = univerAPI.newRichText(
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
* range.setRichTextValueForCell(richText);
|
|
265
|
+
* const richText = univerAPI.newRichText()
|
|
266
|
+
* .align({ horizontal: univerAPI.Enum.HorizontalAlign.CENTER })
|
|
267
|
+
* .text('Status: ')
|
|
268
|
+
* .span('Ready', { bold: true, color: '#16a34a' });
|
|
271
269
|
* ```
|
|
272
270
|
*/
|
|
273
|
-
newRichText(
|
|
271
|
+
newRichText(): RichTextBuilder;
|
|
272
|
+
/**
|
|
273
|
+
* Create a rich-text builder from raw Univer document data.
|
|
274
|
+
*
|
|
275
|
+
* This is an advanced integration escape hatch for importers and adapters. Application and agent code should use
|
|
276
|
+
* the fluent builder returned by `newRichText()`.
|
|
277
|
+
*
|
|
278
|
+
* @param data Raw Univer document data.
|
|
279
|
+
* @returns A rich-text builder initialized with the supplied document data.
|
|
280
|
+
* @advanced
|
|
281
|
+
*/
|
|
282
|
+
newRichTextFromDocumentData(data: IDocumentData): RichTextBuilder;
|
|
274
283
|
/**
|
|
275
284
|
* Create a new rich text value.
|
|
276
|
-
*
|
|
285
|
+
*
|
|
286
|
+
* This is an advanced integration escape hatch for callers that already own Univer document data. Application and
|
|
287
|
+
* agent code should prefer the fluent value returned by `newRichText()`.
|
|
288
|
+
*
|
|
289
|
+
* @param {IDocumentData} data The raw Univer document data.
|
|
277
290
|
* @returns {RichTextValue} The new rich text value instance
|
|
278
|
-
* @
|
|
279
|
-
* ```ts
|
|
280
|
-
* const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
|
|
281
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
282
|
-
* if (!fWorksheet) return;
|
|
283
|
-
* const range = fWorksheet.getRange('A1');
|
|
284
|
-
* range.setRichTextValueForCell(richTextValue);
|
|
285
|
-
* ```
|
|
291
|
+
* @advanced
|
|
286
292
|
*/
|
|
287
293
|
newRichTextValue(data: IDocumentData): RichTextValue;
|
|
288
294
|
/**
|
|
289
295
|
* Create a new paragraph style.
|
|
290
|
-
*
|
|
296
|
+
*
|
|
297
|
+
* This is an advanced document-model API. Application and agent code should normally use
|
|
298
|
+
* `newRichText().paragraph({ ... })`.
|
|
299
|
+
*
|
|
300
|
+
* @param {IParagraphStyle} style The paragraph style
|
|
291
301
|
* @returns {ParagraphStyleBuilder} The new paragraph style instance
|
|
292
|
-
* @
|
|
293
|
-
* ```ts
|
|
294
|
-
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
295
|
-
* const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
|
|
296
|
-
* richText.insertParagraph(paragraphStyle);
|
|
297
|
-
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
298
|
-
* if (!fWorksheet) return;
|
|
299
|
-
* const range = fWorksheet.getRange('A1');
|
|
300
|
-
* range.setRichTextValueForCell(richText);
|
|
301
|
-
* ```
|
|
302
|
+
* @advanced
|
|
302
303
|
*/
|
|
303
304
|
newParagraphStyle(style?: IParagraphStyle): ParagraphStyleBuilder;
|
|
304
305
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from './common/lodash';
|
|
|
32
32
|
export { MemoryCursor } from './common/memory-cursor';
|
|
33
33
|
export { mixinClass } from './common/mixin';
|
|
34
34
|
export { isNumeric, isSafeNumeric, willLoseNumericPrecision } from './common/number';
|
|
35
|
+
export { regexp } from './common/regexp';
|
|
35
36
|
export { Registry, RegistryAsMap } from './common/registry';
|
|
36
37
|
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
|
37
38
|
export { sequence, sequenceAsync } from './common/sequence';
|
|
@@ -39,24 +40,7 @@ export type { ISequenceExecuteResult } from './common/sequence';
|
|
|
39
40
|
export { mergeSets } from './common/set';
|
|
40
41
|
export { UnitModel, UniverInstanceType } from './common/unit';
|
|
41
42
|
export { isSafeUrl, normalizeUrl, resolveWithBasePath } from './common/url';
|
|
42
|
-
export * from './docs
|
|
43
|
-
export { JSON1, JSONX } from './docs/data-model/json-x/json-x';
|
|
44
|
-
export type { JSONXActions, JSONXPath } from './docs/data-model/json-x/json-x';
|
|
45
|
-
export { replaceInDocumentBody } from './docs/data-model/replacement';
|
|
46
|
-
export { ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, } from './docs/data-model/rich-text-builder';
|
|
47
|
-
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID } from './docs/data-model/subdocument';
|
|
48
|
-
export { ActionIterator } from './docs/data-model/text-x/action-iterator';
|
|
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';
|
|
51
|
-
export { normalizeTextRuns, RESTORE_INSERTED_PARAGRAPH_IDS } from './docs/data-model/text-x/apply-utils/common';
|
|
52
|
-
export { updateAttributeByDelete } from './docs/data-model/text-x/apply-utils/delete-apply';
|
|
53
|
-
export { updateAttributeByInsert } from './docs/data-model/text-x/apply-utils/insert-apply';
|
|
54
|
-
export { getPlainText } from './docs/data-model/text-x/build-utils/parse';
|
|
55
|
-
export { TextX } from './docs/data-model/text-x/text-x';
|
|
56
|
-
export type { TPriority } from './docs/data-model/text-x/text-x';
|
|
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';
|
|
43
|
+
export * from './docs';
|
|
60
44
|
export { EventState, EventSubject, fromEventSubject } from './observer/observable';
|
|
61
45
|
export type { IEventObserver } from './observer/observable';
|
|
62
46
|
export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
|
|
@@ -114,20 +98,7 @@ export { getIntersectRange } from './shared/range';
|
|
|
114
98
|
export { afterTime, bufferDebounceTime, convertObservableToBehaviorSubject, fromCallback, takeAfter, } from './shared/rxjs';
|
|
115
99
|
export { awaitTime, delayAnimationFrame } from './shared/timer';
|
|
116
100
|
export { isNodeEnv } from './shared/tools';
|
|
117
|
-
export * from './sheets
|
|
118
|
-
export { Range } from './sheets/range';
|
|
119
|
-
export { getCellCoordByIndexSimple, getCellWithCoordByIndexCore, SheetSkeleton } from './sheets/sheet-skeleton';
|
|
120
|
-
export type { IGetRowColByPosOptions } from './sheets/sheet-skeleton';
|
|
121
|
-
export * from './sheets/sheet-skeleton';
|
|
122
|
-
export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, mergeWorksheetSnapshotWithDefault, } from './sheets/sheet-snapshot-utils';
|
|
123
|
-
export { Styles } from './sheets/styles';
|
|
124
|
-
export * from './sheets/typedef';
|
|
125
|
-
export type { IPosition } from './sheets/typedef';
|
|
126
|
-
export { addLinkToDocumentModel, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual, } from './sheets/util';
|
|
127
|
-
export { createDocumentModelWithStyle } from './sheets/util';
|
|
128
|
-
export { SheetViewModel } from './sheets/view-model';
|
|
129
|
-
export { getWorksheetUID, Workbook } from './sheets/workbook';
|
|
130
|
-
export { extractPureTextFromCell, getDisplayValueFromCell, getOriginCellValue, Worksheet } from './sheets/worksheet';
|
|
101
|
+
export * from './sheets';
|
|
131
102
|
export { Skeleton } from './skeleton';
|
|
132
103
|
export * from './types/const';
|
|
133
104
|
export { skipParseTagNames } from './types/const/clipboard';
|
|
@@ -66,7 +66,7 @@ export declare class AuthzIoLocalService implements IAuthzIoService {
|
|
|
66
66
|
clearAllOverrides(objectID: string): void;
|
|
67
67
|
updateCollaborator(): Promise<void>;
|
|
68
68
|
createCollaborator(): Promise<void>;
|
|
69
|
-
putCollaborators(
|
|
69
|
+
putCollaborators(_config: IPutCollaboratorsRequest): Promise<void>;
|
|
70
70
|
setCfgEnableObjInherit(enabled: boolean): void;
|
|
71
71
|
getCfgEnableObjInherit(): boolean;
|
|
72
72
|
}
|
|
@@ -32,6 +32,28 @@ export interface ICreateUnitOptions {
|
|
|
32
32
|
* @default true
|
|
33
33
|
*/
|
|
34
34
|
makeCurrent?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If product UI render services should skip their default main-canvas render
|
|
37
|
+
* creation. Embedded units create their render explicitly into a host-owned
|
|
38
|
+
* container instead.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
skipAutoRender?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If render services should create the render unit as an embedded/non-main
|
|
45
|
+
* render. Embedded renders are mounted explicitly by a host container and
|
|
46
|
+
* must not mutate global workbench state while resolving their local view.
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
embeddedRender?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Optional parent injector for an embedded render unit. Render modules will
|
|
53
|
+
* resolve their dependencies from this injector before falling back to the
|
|
54
|
+
* root injector.
|
|
55
|
+
*/
|
|
56
|
+
renderParentInjector?: Injector;
|
|
35
57
|
}
|
|
36
58
|
interface ICreateUnitEvent<T extends UnitModel = UnitModel> {
|
|
37
59
|
unit: T;
|
|
@@ -71,6 +93,8 @@ export interface IUniverInstanceService {
|
|
|
71
93
|
getCurrentTypeOfUnit$<T extends UnitModel>(type: UniverInstanceType): Observable<Nullable<T>>;
|
|
72
94
|
/** Create a unit with snapshot info. */
|
|
73
95
|
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>, options?: ICreateUnitOptions): U;
|
|
96
|
+
/** Get the options originally used to create a unit. */
|
|
97
|
+
getUnitCreateOptions(unitId: string): Nullable<ICreateUnitOptions>;
|
|
74
98
|
/** Dispose a unit */
|
|
75
99
|
disposeUnit(unitId: string): boolean;
|
|
76
100
|
registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new (...args: any[]) => T): IDisposable;
|
|
@@ -88,6 +112,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
88
112
|
private readonly _contextService;
|
|
89
113
|
private readonly _logService;
|
|
90
114
|
private readonly _unitsByType;
|
|
115
|
+
private readonly _unitCreateOptions;
|
|
91
116
|
constructor(_injector: Injector, _contextService: IContextService, _logService: ILogService);
|
|
92
117
|
dispose(): void;
|
|
93
118
|
private _createHandler;
|
|
@@ -117,6 +142,7 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
117
142
|
readonly unitDisposed$: Observable<UnitModel<object, UniverInstanceType>>;
|
|
118
143
|
getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
|
|
119
144
|
getUnit<T extends UnitModel = UnitModel>(id: string, type?: UniverInstanceType): Nullable<T>;
|
|
145
|
+
getUnitCreateOptions(unitId: string): Nullable<ICreateUnitOptions>;
|
|
120
146
|
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
|
121
147
|
getAllUnitsForType<T>(type: UniverInstanceType): T[];
|
|
122
148
|
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
|
@@ -21,7 +21,7 @@ export type IResources = Array<{
|
|
|
21
21
|
name: string;
|
|
22
22
|
data: string;
|
|
23
23
|
}>;
|
|
24
|
-
type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE';
|
|
24
|
+
type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE' | 'BASE' | 'UNIVER';
|
|
25
25
|
export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
|
|
26
26
|
export interface IResourceHook<T = any> {
|
|
27
27
|
pluginName: IResourceName;
|
|
@@ -19,6 +19,7 @@ export type DateKitInput = Date | number | string | IDateKit | null | undefined;
|
|
|
19
19
|
export interface IDateKit {
|
|
20
20
|
isValid(): boolean;
|
|
21
21
|
format(template?: string): string;
|
|
22
|
+
formatIntl(locale?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
22
23
|
valueOf(): number;
|
|
23
24
|
toDate(): Date;
|
|
24
25
|
add(value: number, unit?: DateKitUnitType): IDateKit;
|
|
@@ -85,14 +85,3 @@ export declare class Tools {
|
|
|
85
85
|
*/
|
|
86
86
|
export declare function composeStyles(...styles: Nullable<IStyleData>[]): IStyleData;
|
|
87
87
|
export declare const isNodeEnv: () => boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Converts a wildcard pattern with ? and * to a regular expression.
|
|
90
|
-
* @param {string} wildChar - The wildcard string containing ? and *
|
|
91
|
-
* @returns {RegExp} The generated regular expression
|
|
92
|
-
*/
|
|
93
|
-
export declare function createREGEXFromWildChar(wildChar: string): RegExp;
|
|
94
|
-
/**
|
|
95
|
-
* Escapes characters that have special meaning in a regular expression so the
|
|
96
|
-
* returned string can be safely embedded in a RegExp pattern as literal text.
|
|
97
|
-
*/
|
|
98
|
-
export declare function escapeRegExp(str: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export * from './clone';
|
|
17
|
+
export { getEmptySnapshot as getSheetsEmptySnapshot } from './empty-snapshot';
|
|
18
|
+
export { Range } from './range';
|
|
19
|
+
export * from './sheet-skeleton';
|
|
20
|
+
export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, mergeWorksheetSnapshotWithDefault, } from './sheet-snapshot-utils';
|
|
21
|
+
export { Styles } from './styles';
|
|
22
|
+
export * from './typedef';
|
|
23
|
+
export { addLinkToDocumentModel, createDocumentModelWithStyle, getEmptyCell, isNotNullOrUndefined, isRangesEqual, isUnitRangesEqual, } from './util';
|
|
24
|
+
export { SheetViewModel } from './view-model';
|
|
25
|
+
export { getWorksheetUID, Workbook } from './workbook';
|
|
26
|
+
export { extractPureTextFromCell, getDisplayValueFromCell, getOriginCellValue, Worksheet } from './worksheet';
|
|
@@ -562,6 +562,7 @@ export interface ISelection {
|
|
|
562
562
|
primary: Nullable<ISelectionCell>;
|
|
563
563
|
}
|
|
564
564
|
export interface ITextRangeStart {
|
|
565
|
+
/** Inclusive insertion offset at the start of the selection. */
|
|
565
566
|
startOffset: number;
|
|
566
567
|
}
|
|
567
568
|
export declare enum RANGE_DIRECTION {
|
|
@@ -570,6 +571,7 @@ export declare enum RANGE_DIRECTION {
|
|
|
570
571
|
FORWARD = "forward"
|
|
571
572
|
}
|
|
572
573
|
export interface ITextRange extends ITextRangeStart {
|
|
574
|
+
/** Exclusive insertion offset at the end of a non-collapsed selection. */
|
|
573
575
|
endOffset: number;
|
|
574
576
|
collapsed: boolean;
|
|
575
577
|
direction?: RANGE_DIRECTION;
|
|
@@ -161,5 +161,4 @@ export declare const DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING = 1.5;
|
|
|
161
161
|
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE = 0;
|
|
162
162
|
export declare const DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW = 12;
|
|
163
163
|
export declare const NAMED_STYLE_SPACE_MAP: Record<NamedStyleType, Nullable<IParagraphStyle>>;
|
|
164
|
-
export declare const PRINT_CHART_COMPONENT_KEY = "univer-sheets-chart-print-chart";
|
|
165
164
|
export declare const DOC_DRAWING_PRINTING_COMPONENT_KEY = "univer-docs-drawing-printing";
|
|
@@ -37,3 +37,12 @@ export declare enum LocaleType {
|
|
|
37
37
|
PL_PL = "plPL",
|
|
38
38
|
AR_SA = "arSA"
|
|
39
39
|
}
|
|
40
|
+
type LocaleDirection = 'ltr' | 'rtl';
|
|
41
|
+
interface ILocaleMeta {
|
|
42
|
+
name: string;
|
|
43
|
+
tag: string;
|
|
44
|
+
direction: LocaleDirection;
|
|
45
|
+
numberingSystem?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const LOCALE_META: Record<LocaleType, ILocaleMeta>;
|
|
48
|
+
export {};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import type { ICustomDecoration, ICustomRange, IParagraph } from './i-document-data';
|
|
17
17
|
export interface ICustomRangeForInterceptor extends ICustomRange {
|
|
18
18
|
active?: boolean;
|
|
19
|
+
glyphWidthEm?: number;
|
|
19
20
|
show?: boolean;
|
|
20
21
|
}
|
|
21
22
|
export interface ICustomDecorationForInterceptor extends ICustomDecoration {
|
|
@@ -286,7 +286,9 @@ export interface IHyperlink {
|
|
|
286
286
|
* A ParagraphElement that represents a run of text that all has the same styling.
|
|
287
287
|
*/
|
|
288
288
|
export interface ITextRun {
|
|
289
|
+
/** Inclusive character index of the first styled character. */
|
|
289
290
|
st: number;
|
|
291
|
+
/** Exclusive character boundary after the last styled character. */
|
|
290
292
|
ed: number;
|
|
291
293
|
sId?: string;
|
|
292
294
|
ts?: ITextStyle;
|
|
@@ -295,7 +297,9 @@ export interface ITextRun {
|
|
|
295
297
|
* Block element, link like, disabled to self nested
|
|
296
298
|
*/
|
|
297
299
|
export interface ICustomRange<T extends Record<string, any> = Record<string, any>> {
|
|
300
|
+
/** Inclusive index of the first character covered by this annotation. */
|
|
298
301
|
startIndex: number;
|
|
302
|
+
/** Inclusive index of the last character covered by this annotation. */
|
|
299
303
|
endIndex: number;
|
|
300
304
|
rangeId: string;
|
|
301
305
|
rangeType: CustomRangeType | number;
|
|
@@ -319,7 +323,9 @@ export declare enum DocumentBlockRangeType {
|
|
|
319
323
|
CODE = "code"
|
|
320
324
|
}
|
|
321
325
|
export interface IDocumentBlockRange {
|
|
326
|
+
/** Inclusive index that must point at a `BLOCK_START` sentinel. */
|
|
322
327
|
startIndex: number;
|
|
328
|
+
/** Inclusive index that must point at the matching `BLOCK_END` sentinel. */
|
|
323
329
|
endIndex: number;
|
|
324
330
|
blockId: string;
|
|
325
331
|
blockType: DocumentBlockRangeType;
|
|
@@ -339,6 +345,7 @@ export declare enum CustomRangeType {
|
|
|
339
345
|
* Custom Block
|
|
340
346
|
*/
|
|
341
347
|
export interface ICustomBlock {
|
|
348
|
+
/** Index that must point at exactly one `CUSTOM_BLOCK` sentinel. */
|
|
342
349
|
startIndex: number;
|
|
343
350
|
blockType?: BlockType;
|
|
344
351
|
blockId: string;
|
|
@@ -348,7 +355,9 @@ export declare enum CustomDecorationType {
|
|
|
348
355
|
DELETED = 9999
|
|
349
356
|
}
|
|
350
357
|
export interface ICustomDecoration {
|
|
358
|
+
/** Inclusive index of the first decorated character. */
|
|
351
359
|
startIndex: number;
|
|
360
|
+
/** Inclusive index of the last decorated character. */
|
|
352
361
|
endIndex: number;
|
|
353
362
|
id: string;
|
|
354
363
|
type: CustomDecorationType;
|
|
@@ -383,7 +392,9 @@ export interface IDocStyleBase extends IMargin {
|
|
|
383
392
|
pageSize?: ISize;
|
|
384
393
|
pageOrient?: PageOrientType;
|
|
385
394
|
documentFlavor?: DocumentFlavor;
|
|
395
|
+
/** Distance from the page edge to the header, in points (pt). */
|
|
386
396
|
marginHeader?: number;
|
|
397
|
+
/** Distance from the page edge to the footer, in points (pt). */
|
|
387
398
|
marginFooter?: number;
|
|
388
399
|
renderConfig?: IDocumentRenderConfig;
|
|
389
400
|
}
|
|
@@ -405,6 +416,7 @@ export declare enum GridType {
|
|
|
405
416
|
}
|
|
406
417
|
export interface IDocumentStyle extends IDocStyleBase, IDocumentLayout, IHeaderAndFooterBase {
|
|
407
418
|
textStyle?: ITextStyle;
|
|
419
|
+
defaultParagraphStyle?: IDocumentDefaultParagraphStyle;
|
|
408
420
|
background?: IDocumentBackground;
|
|
409
421
|
}
|
|
410
422
|
export interface IDocumentBackground {
|
|
@@ -452,6 +464,8 @@ export interface ISectionBreakBase {
|
|
|
452
464
|
* Properties of section break
|
|
453
465
|
*/
|
|
454
466
|
export interface ISectionBreak extends IDocStyleBase, ISectionBreakBase, IHeaderAndFooterBase {
|
|
467
|
+
/** Stable identity of the section-break metadata entry. */
|
|
468
|
+
sectionId: string;
|
|
455
469
|
startIndex: number;
|
|
456
470
|
}
|
|
457
471
|
/**
|
|
@@ -484,7 +498,9 @@ export declare enum TextDirectionType {
|
|
|
484
498
|
* Properties of section column
|
|
485
499
|
*/
|
|
486
500
|
export interface ISectionColumnProperties {
|
|
501
|
+
/** Column width in points (pt). */
|
|
487
502
|
width: number;
|
|
503
|
+
/** Trailing space after the column in points (pt). */
|
|
488
504
|
paddingEnd: number;
|
|
489
505
|
}
|
|
490
506
|
export interface IParagraph {
|
|
@@ -526,8 +542,8 @@ export interface IBullet {
|
|
|
526
542
|
*/
|
|
527
543
|
export interface IDocDrawingBase extends IDrawingParam {
|
|
528
544
|
drawingId: string;
|
|
529
|
-
title
|
|
530
|
-
description
|
|
545
|
+
title?: string;
|
|
546
|
+
description?: string;
|
|
531
547
|
docTransform: IDocDrawingPosition;
|
|
532
548
|
layoutType: PositionedObjectLayoutType;
|
|
533
549
|
behindDoc?: BooleanNumber;
|
|
@@ -632,6 +648,11 @@ export interface IIndentStart {
|
|
|
632
648
|
export interface IParagraphStyle extends IParagraphProperties {
|
|
633
649
|
textStyle?: ITextStyle;
|
|
634
650
|
}
|
|
651
|
+
/**
|
|
652
|
+
* Paragraph properties that may be inherited from the document defaults.
|
|
653
|
+
* Paragraph identity and named/text styles have their own inheritance mechanisms.
|
|
654
|
+
*/
|
|
655
|
+
export type IDocumentDefaultParagraphStyle = Omit<IParagraphStyle, 'headingId' | 'namedStyleType' | 'textStyle'>;
|
|
635
656
|
export interface IParagraphProperties extends IIndentStart {
|
|
636
657
|
headingId?: string;
|
|
637
658
|
namedStyleType?: NamedStyleType;
|
|
@@ -759,12 +780,16 @@ export declare enum TableTextWrapType {
|
|
|
759
780
|
WRAP = 1
|
|
760
781
|
}
|
|
761
782
|
export interface ICustomTable {
|
|
783
|
+
/** Inclusive index that must point at a `TABLE_START` sentinel. */
|
|
762
784
|
startIndex: number;
|
|
785
|
+
/** Exclusive boundary immediately after the matching `TABLE_END` sentinel. */
|
|
763
786
|
endIndex: number;
|
|
764
787
|
tableId: string;
|
|
765
788
|
}
|
|
766
789
|
export interface ICustomColumnGroup {
|
|
790
|
+
/** Inclusive index that must point at a `COLUMN_GROUP_START` sentinel. */
|
|
767
791
|
startIndex: number;
|
|
792
|
+
/** Inclusive index that must point at the matching `COLUMN_GROUP_END` sentinel. */
|
|
768
793
|
endIndex: number;
|
|
769
794
|
columnGroupId: string;
|
|
770
795
|
columns?: IColumn[];
|
|
@@ -828,6 +853,10 @@ export interface ITableRowSize {
|
|
|
828
853
|
* Properties of row of table
|
|
829
854
|
*/
|
|
830
855
|
export interface ITableRow {
|
|
856
|
+
/**
|
|
857
|
+
* Rows do not persist stream offsets. Their ordinal position must match the
|
|
858
|
+
* corresponding `TABLE_ROW_START`/`TABLE_ROW_END` pair in `dataStream`.
|
|
859
|
+
*/
|
|
831
860
|
tableCells: ITableCell[];
|
|
832
861
|
trHeight: ITableRowSize;
|
|
833
862
|
cantSplit?: BooleanNumber;
|
|
@@ -838,6 +867,10 @@ export interface ITableRow {
|
|
|
838
867
|
* Properties of table cell
|
|
839
868
|
*/
|
|
840
869
|
export interface ITableCell {
|
|
870
|
+
/**
|
|
871
|
+
* Cells do not persist stream offsets. Their ordinal position must match the
|
|
872
|
+
* corresponding `TABLE_CELL_START`/`TABLE_CELL_END` pair in the row stream.
|
|
873
|
+
*/
|
|
841
874
|
margin?: ITableCellMargin;
|
|
842
875
|
rowSpan?: number;
|
|
843
876
|
columnSpan?: number;
|
|
@@ -80,7 +80,11 @@ export declare enum DrawingTypeEnum {
|
|
|
80
80
|
/**
|
|
81
81
|
* Dom element, allows inserting HTML elements as floating objects into the document
|
|
82
82
|
*/
|
|
83
|
-
DRAWING_DOM = 8
|
|
83
|
+
DRAWING_DOM = 8,
|
|
84
|
+
/**
|
|
85
|
+
* Block element, allows host products to place embeddable unit-backed blocks as drawing objects.
|
|
86
|
+
*/
|
|
87
|
+
DRAWING_BLOCK = 9
|
|
84
88
|
}
|
|
85
89
|
export type DrawingType = DrawingTypeEnum | number;
|
|
86
90
|
export interface IDrawingSpace {
|
|
@@ -104,6 +108,18 @@ export interface ITransformStateDisableOption {
|
|
|
104
108
|
}
|
|
105
109
|
export interface ITransformState extends IAbsoluteTransform, IRotationSkewFlipTransform, ITransformStateDisableOption {
|
|
106
110
|
}
|
|
111
|
+
export interface IDrawingObjectLocks {
|
|
112
|
+
/**
|
|
113
|
+
* Prevent selecting the drawing directly from the canvas. Layer/object panels may still select it for management.
|
|
114
|
+
*/
|
|
115
|
+
noSelect?: boolean;
|
|
116
|
+
noMove?: boolean;
|
|
117
|
+
noResize?: boolean;
|
|
118
|
+
noRotate?: boolean;
|
|
119
|
+
noTextEdit?: boolean;
|
|
120
|
+
noEditPoints?: boolean;
|
|
121
|
+
noChangeAspect?: boolean;
|
|
122
|
+
}
|
|
107
123
|
export interface IDrawingParam extends IDrawingSearch {
|
|
108
124
|
drawingType: DrawingType;
|
|
109
125
|
transform?: Nullable<ITransformState>;
|
|
@@ -120,6 +136,14 @@ export interface IDrawingParam extends IDrawingSearch {
|
|
|
120
136
|
* The drawing element is hidden when render
|
|
121
137
|
*/
|
|
122
138
|
hidden?: boolean;
|
|
139
|
+
name?: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Compatibility shortcut for whether the drawing can be selected from the canvas.
|
|
143
|
+
* Prefer locks.noSelect for fine-grained behavior when available.
|
|
144
|
+
*/
|
|
145
|
+
selectable?: boolean;
|
|
146
|
+
locks?: IDrawingObjectLocks;
|
|
123
147
|
}
|
|
124
148
|
/**
|
|
125
149
|
* Describes a single group node's direct children in a group hierarchy.
|
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 if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):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});
|
|
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 if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):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 SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}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}get ImageSourceType(){return t.ImageSourceType}};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(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(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});
|