@univerjs/core 0.1.2 → 0.1.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/index.js +7 -5
- package/lib/es/index.js +2195 -1714
- package/lib/types/common/__tests__/array.spec.d.ts +16 -0
- package/lib/types/common/array.d.ts +8 -0
- package/lib/types/common/interceptor.d.ts +1 -1
- package/lib/types/index.d.ts +10 -1
- package/lib/types/services/command/command.service.d.ts +4 -4
- package/lib/types/services/instance/instance.service.d.ts +1 -1
- package/lib/types/services/locale/locale.service.d.ts +4 -2
- package/lib/types/services/log/context.d.ts +18 -0
- package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +37 -0
- package/lib/types/services/snapshot/__tests__/snapshot-transform.spec.d.ts +16 -0
- package/lib/types/services/snapshot/snapshot-server.service.d.ts +57 -0
- package/lib/types/services/snapshot/snapshot-transform.d.ts +43 -0
- package/lib/types/services/snapshot/snapshot-utils.d.ts +34 -0
- package/lib/types/services/undoredo/undoredo.service.d.ts +20 -7
- package/lib/types/shared/coder.d.ts +17 -0
- package/lib/types/shared/color/color-kit.d.ts +3 -1
- package/lib/types/shared/compare.d.ts +1 -0
- package/lib/types/shared/index.d.ts +1 -1
- package/lib/types/shared/locale.d.ts +2 -1
- package/lib/types/shared/object-matrix.d.ts +3 -0
- package/lib/types/shared/rxjs.d.ts +20 -0
- package/lib/types/shared/tools.d.ts +1 -1
- package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -2
- package/lib/types/sheets/row-manager.d.ts +0 -2
- package/lib/types/sheets/workbook.d.ts +1 -0
- package/lib/types/sheets/worksheet.d.ts +7 -9
- package/lib/types/types/interfaces/i-cell-data.d.ts +6 -0
- package/lib/types/types/interfaces/i-column-data.d.ts +2 -2
- package/lib/types/types/interfaces/i-document-data.d.ts +2 -1
- package/lib/types/types/interfaces/i-range.d.ts +5 -0
- package/lib/types/types/interfaces/i-row-data.d.ts +2 -2
- package/lib/types/types/interfaces/i-selection-data.d.ts +6 -0
- package/lib/umd/index.js +7 -5
- package/package.json +8 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -21,3 +21,11 @@ export declare function remove<T>(arr: T[], item: T): boolean;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function dedupe<T>(arr: T[]): T[];
|
|
23
23
|
export declare function findLast<T>(arr: T[], callback: (item: T, index: number) => boolean): T | null;
|
|
24
|
+
/**
|
|
25
|
+
* Rotate an array without mutating the original array.
|
|
26
|
+
* @param arr the array to be rotated
|
|
27
|
+
* @param steps how many steps to rotate
|
|
28
|
+
* @returns the rotated array, it is another array, the original array is not mutated.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rotate<T>(arr: Readonly<T[]>, steps: number): readonly T[];
|
|
31
|
+
export declare function groupBy<T>(arr: Readonly<T[]>, keyFn: (v: T) => string): Map<string, T[]>;
|
|
@@ -24,7 +24,7 @@ export type IComposeInterceptors<T = any, C = any> = (interceptors: Array<IInter
|
|
|
24
24
|
/**
|
|
25
25
|
* A helper to compose a certain type of interceptors.
|
|
26
26
|
*/
|
|
27
|
-
export declare const composeInterceptors: <T, C>(interceptors: IInterceptor<T, C
|
|
27
|
+
export declare const composeInterceptors: <T, C>(interceptors: Array<IInterceptor<T, C>>) => (initValue: Nullable<T>, initContext: C) => Nullable<T>;
|
|
28
28
|
export declare class InterceptorManager<P extends Record<string, IInterceptor<any, any>>> {
|
|
29
29
|
private _interceptorsByName;
|
|
30
30
|
private _interceptorPoints;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export * from './basics';
|
|
17
|
-
export { dedupe, remove } from './common/array';
|
|
17
|
+
export { dedupe, remove, rotate, groupBy } from './common/array';
|
|
18
18
|
export { DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, } from './common/const';
|
|
19
19
|
export { throttle } from './common/function';
|
|
20
20
|
export { MemoryCursor } from './common/memory-cursor';
|
|
@@ -48,6 +48,7 @@ export { IResourceManagerService, ISnapshotPersistenceService } from './services
|
|
|
48
48
|
export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
|
|
49
49
|
export { type IUndoRedoCommandInfos, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, UndoCommand, RedoCommandId, UndoCommandId, } from './services/undoredo/undoredo.service';
|
|
50
50
|
export * from './shared';
|
|
51
|
+
export { fromCallback } from './shared/rxjs';
|
|
51
52
|
export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
|
|
52
53
|
export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
|
|
53
54
|
export { normalizeTextRuns } from './docs/data-model/apply-utils/common';
|
|
@@ -65,3 +66,11 @@ export * from './types/interfaces';
|
|
|
65
66
|
export { UniverInstanceService } from './services/instance/instance.service';
|
|
66
67
|
export { LifecycleInitializerService } from './services/lifecycle/lifecycle.service';
|
|
67
68
|
export { ConfigService } from './services/config/config.service';
|
|
69
|
+
export { ISnapshotServerService } from './services/snapshot/snapshot-server.service';
|
|
70
|
+
export { transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, transformDocumentDataToSnapshot, transformSnapshotToDocumentData, generateTemporarySnap, } from './services/snapshot/snapshot-transform';
|
|
71
|
+
export { textEncoder, textDecoder } from './services/snapshot/snapshot-utils';
|
|
72
|
+
export { type ILogContext } from './services/log/context';
|
|
73
|
+
export { b64DecodeUnicode, b64EncodeUnicode } from './shared/coder';
|
|
74
|
+
export { ClientSnapshotServerService } from './services/snapshot/snapshot-server.service';
|
|
75
|
+
export { getSheetBlocksFromSnapshot } from './services/snapshot/snapshot-transform';
|
|
76
|
+
export { isBlackColor, isWhiteColor } from './shared/color/color-kit';
|
|
@@ -17,7 +17,7 @@ import type { IAccessor, IDisposable } from '@wendellhu/redi';
|
|
|
17
17
|
import { Injector } from '@wendellhu/redi';
|
|
18
18
|
import { IContextService } from '../context/context.service';
|
|
19
19
|
import { ILogService } from '../log/log.service';
|
|
20
|
-
export declare
|
|
20
|
+
export declare enum CommandType {
|
|
21
21
|
/** Command could generate some operations or mutations. */
|
|
22
22
|
COMMAND = 0,
|
|
23
23
|
/** An operation that do not require conflict resolve. */
|
|
@@ -31,7 +31,7 @@ export interface ICommand<P extends object = object, R = boolean> {
|
|
|
31
31
|
*/
|
|
32
32
|
readonly id: string;
|
|
33
33
|
readonly type: CommandType;
|
|
34
|
-
handler(accessor: IAccessor, params?: P): Promise<R> | R;
|
|
34
|
+
handler(accessor: IAccessor, params?: P, options?: IExecutionOptions): Promise<R> | R;
|
|
35
35
|
/**
|
|
36
36
|
* When this command is unregistered, this function would be called.
|
|
37
37
|
*
|
|
@@ -103,8 +103,8 @@ export interface IExecutionOptions {
|
|
|
103
103
|
}
|
|
104
104
|
export type CommandListener = (commandInfo: Readonly<ICommandInfo>, options?: IExecutionOptions) => void;
|
|
105
105
|
export interface ICommandService {
|
|
106
|
-
registerCommand(command: ICommand): IDisposable;
|
|
107
|
-
registerMultipleCommand(command: ICommand): IDisposable;
|
|
106
|
+
registerCommand(command: ICommand<object, unknown>): IDisposable;
|
|
107
|
+
registerMultipleCommand(command: ICommand<object, unknown>): IDisposable;
|
|
108
108
|
executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
|
|
109
109
|
syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
|
|
110
110
|
/**
|
|
@@ -21,7 +21,7 @@ import { Workbook } from '../../sheets/workbook';
|
|
|
21
21
|
import { Slide } from '../../slides/domain/slide-model';
|
|
22
22
|
import type { IDocumentData, ISlideData, IWorkbookData } from '../../types/interfaces';
|
|
23
23
|
import { IContextService } from '../context/context.service';
|
|
24
|
-
export declare
|
|
24
|
+
export declare enum UniverInstanceType {
|
|
25
25
|
UNKNOWN = 0,
|
|
26
26
|
DOC = 1,
|
|
27
27
|
SHEET = 2,
|
|
@@ -26,17 +26,18 @@ export declare class LocaleService extends Disposable {
|
|
|
26
26
|
localeChanged$: Subject<void>;
|
|
27
27
|
constructor();
|
|
28
28
|
/**
|
|
29
|
-
* Load more locales after init
|
|
29
|
+
* Load more locales after init.
|
|
30
30
|
*
|
|
31
31
|
* @param locales - Locale object
|
|
32
|
-
*
|
|
33
32
|
*/
|
|
34
33
|
load(locales: ILocales): void;
|
|
35
34
|
/**
|
|
36
35
|
* Translate a key to the current locale
|
|
36
|
+
*
|
|
37
37
|
* @param {string} key the key to translate
|
|
38
38
|
* @param {string[]} args optional arguments to replace in the translated string
|
|
39
39
|
* @returns {string} the translated string
|
|
40
|
+
*
|
|
40
41
|
* @example
|
|
41
42
|
* const locales = {
|
|
42
43
|
* [LocaleType.EN_US]: {
|
|
@@ -58,4 +59,5 @@ export declare class LocaleService extends Disposable {
|
|
|
58
59
|
t: (key: string, ...args: string[]) => string;
|
|
59
60
|
setLocale(locale: LocaleType): void;
|
|
60
61
|
getLocales(): ILanguagePack | undefined;
|
|
62
|
+
getCurrentLocale(): LocaleType;
|
|
61
63
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export interface ILogContext {
|
|
17
|
+
metadata?: Record<string, string>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IFetchMissingChangesetsRequest, IFetchMissingChangesetsResponse, IGetResourcesRequest, IGetResourcesResponse, IGetSheetBlockRequest, IGetSheetBlockResponse, IGetUnitOnRevRequest, IGetUnitOnRevResponse, ISaveChangesetRequest, ISaveChangesetResponse, ISaveSheetBlockRequest, ISaveSheetBlockResponse, ISaveSnapshotRequest, ISaveSnapshotResponse, ISheetBlock, ISnapshot } from '@univerjs/protocol';
|
|
17
|
+
import type { IWorkbookData } from '../../../types/interfaces/i-workbook-data';
|
|
18
|
+
import type { ILogContext } from '../../log/context';
|
|
19
|
+
import type { ISnapshotServerService } from '../snapshot-server.service';
|
|
20
|
+
export declare const testSnapshot: () => ISnapshot;
|
|
21
|
+
export declare const testSheetBlocks: () => ISheetBlock[];
|
|
22
|
+
export declare const testWorkbookData: () => IWorkbookData;
|
|
23
|
+
export declare class MockSnapshotServerService implements ISnapshotServerService {
|
|
24
|
+
/** Load snapshot from a database. */
|
|
25
|
+
getUnitOnRev(context: ILogContext, params: IGetUnitOnRevRequest): Promise<IGetUnitOnRevResponse>;
|
|
26
|
+
/** Load sheet block from a database. */
|
|
27
|
+
getSheetBlock(context: ILogContext, params: IGetSheetBlockRequest): Promise<IGetSheetBlockResponse>;
|
|
28
|
+
/** Fetch missing changeset */
|
|
29
|
+
fetchMissingChangesets(context: ILogContext, params: IFetchMissingChangesetsRequest): Promise<IFetchMissingChangesetsResponse>;
|
|
30
|
+
getResourcesRequest(context: ILogContext, params: IGetResourcesRequest): Promise<IGetResourcesResponse>;
|
|
31
|
+
/** Save snapshot to a database. */
|
|
32
|
+
saveSnapshot(context: ILogContext, params: ISaveSnapshotRequest): Promise<ISaveSnapshotResponse>;
|
|
33
|
+
/** Save sheet block to a database. */
|
|
34
|
+
saveSheetBlock(context: ILogContext, params: ISaveSheetBlockRequest): Promise<ISaveSheetBlockResponse>;
|
|
35
|
+
/** Save changeset to a database. */
|
|
36
|
+
saveChangeset(context: ILogContext, params: ISaveChangesetRequest): Promise<ISaveChangesetResponse>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IFetchMissingChangesetsRequest, IFetchMissingChangesetsResponse, IGetResourcesRequest, IGetResourcesResponse, IGetSheetBlockRequest, IGetSheetBlockResponse, IGetUnitOnRevRequest, IGetUnitOnRevResponse, ISaveChangesetRequest, ISaveChangesetResponse, ISaveSheetBlockRequest, ISaveSheetBlockResponse, ISaveSnapshotRequest, ISaveSnapshotResponse } from '@univerjs/protocol';
|
|
17
|
+
import type { ILogContext } from '../log/context';
|
|
18
|
+
/**
|
|
19
|
+
* It provides implementations for server side controllers to load or save
|
|
20
|
+
* or load snapshots. This service should be implemented by the host environment.
|
|
21
|
+
* And it shouldn't contain any business logic.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ISnapshotServerService: import("@wendellhu/redi").IdentifierDecorator<ISnapshotServerService>;
|
|
24
|
+
export interface ISnapshotServerService {
|
|
25
|
+
/** Load snapshot from a database. */
|
|
26
|
+
getUnitOnRev: (context: ILogContext, params: IGetUnitOnRevRequest) => Promise<IGetUnitOnRevResponse>;
|
|
27
|
+
/** Load sheet block from a database. */
|
|
28
|
+
getSheetBlock: (context: ILogContext, params: IGetSheetBlockRequest) => Promise<IGetSheetBlockResponse>;
|
|
29
|
+
/** Fetch missing changeset */
|
|
30
|
+
fetchMissingChangesets: (context: ILogContext, params: IFetchMissingChangesetsRequest) => Promise<IFetchMissingChangesetsResponse>;
|
|
31
|
+
getResourcesRequest: (context: ILogContext, params: IGetResourcesRequest) => Promise<IGetResourcesResponse>;
|
|
32
|
+
/** Save snapshot to a database. */
|
|
33
|
+
saveSnapshot: (context: ILogContext, params: ISaveSnapshotRequest) => Promise<ISaveSnapshotResponse>;
|
|
34
|
+
/** Save sheet block to a database. */
|
|
35
|
+
saveSheetBlock: (context: ILogContext, params: ISaveSheetBlockRequest) => Promise<ISaveSheetBlockResponse>;
|
|
36
|
+
/** Save changeset to a database. */
|
|
37
|
+
saveChangeset: (context: ILogContext, params: ISaveChangesetRequest) => Promise<ISaveChangesetResponse>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The server needs to fully implement all interfaces, but when used by the client, use saveSheetBlock to cache the sheet block locally, and use getSheetBlock to obtain the sheet block.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ClientSnapshotServerService implements ISnapshotServerService {
|
|
43
|
+
private _sheetBlockCache;
|
|
44
|
+
/** Load snapshot from a database. */
|
|
45
|
+
getUnitOnRev(context: ILogContext, params: IGetUnitOnRevRequest): Promise<IGetUnitOnRevResponse>;
|
|
46
|
+
/** Load sheet block from a database. */
|
|
47
|
+
getSheetBlock(context: ILogContext, params: IGetSheetBlockRequest): Promise<IGetSheetBlockResponse>;
|
|
48
|
+
/** Fetch missing changeset */
|
|
49
|
+
fetchMissingChangesets(context: ILogContext, params: IFetchMissingChangesetsRequest): Promise<IFetchMissingChangesetsResponse>;
|
|
50
|
+
getResourcesRequest(context: ILogContext, params: IGetResourcesRequest): Promise<IGetResourcesResponse>;
|
|
51
|
+
/** Save snapshot to a database. */
|
|
52
|
+
saveSnapshot(context: ILogContext, params: ISaveSnapshotRequest): Promise<ISaveSnapshotResponse>;
|
|
53
|
+
/** Save sheet block to a database. */
|
|
54
|
+
saveSheetBlock(context: ILogContext, params: ISaveSheetBlockRequest): Promise<ISaveSheetBlockResponse>;
|
|
55
|
+
/** Save changeset to a database. */
|
|
56
|
+
saveChangeset(context: ILogContext, params: ISaveChangesetRequest): Promise<ISaveChangesetResponse>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ISheetBlock, ISnapshot } from '@univerjs/protocol';
|
|
17
|
+
import type { ILogContext } from '../log/context';
|
|
18
|
+
import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
|
|
19
|
+
import type { IDocumentData } from '../../types/interfaces/i-document-data';
|
|
20
|
+
import type { ISnapshotServerService } from './snapshot-server.service';
|
|
21
|
+
export declare function generateTemporarySnap(context: ILogContext, workbook: IWorkbookData, unitID: string, rev: number, snapshotService: ISnapshotServerService): Promise<{
|
|
22
|
+
snapshotRes: ISnapshot;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function transformWorkbookDataToSnapshot(context: ILogContext, workbook: IWorkbookData, unitID: string, rev: number, snapshotService: ISnapshotServerService): Promise<{
|
|
25
|
+
snapshot: ISnapshot;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Assemble a snapshot to a workbook.
|
|
29
|
+
* @param snapshot
|
|
30
|
+
* @param sheetBlocks
|
|
31
|
+
*/
|
|
32
|
+
export declare function transformSnapshotToWorkbookData(snapshot: ISnapshot, sheetBlocks: ISheetBlock[], _context?: ILogContext): IWorkbookData;
|
|
33
|
+
export declare function transformSnapshotToDocumentData(snapshot: ISnapshot): IDocumentData;
|
|
34
|
+
export declare function transformDocumentDataToSnapshot(context: ILogContext, document: IDocumentData, unitID: string, rev: number, snapshotService: ISnapshotServerService): Promise<{
|
|
35
|
+
snapshot: ISnapshot;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param snapshot
|
|
40
|
+
* @param snapshotService
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSheetBlocksFromSnapshot(snapshot: ISnapshot, snapshotService: ISnapshotServerService): Promise<ISheetBlock[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ISheetBlock } from '@univerjs/protocol';
|
|
17
|
+
import type { IWorksheetData } from '../../types/interfaces/i-worksheet-data';
|
|
18
|
+
import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
|
|
19
|
+
import type { IDocumentData } from '../../types/interfaces/i-document-data';
|
|
20
|
+
import type { ICellData } from '../../types/interfaces/i-cell-data';
|
|
21
|
+
import type { IObjectMatrixPrimitiveType } from '../../shared/object-matrix';
|
|
22
|
+
export declare const textEncoder: TextEncoder;
|
|
23
|
+
export declare const textDecoder: TextDecoder;
|
|
24
|
+
/**
|
|
25
|
+
* @param worksheet
|
|
26
|
+
*/
|
|
27
|
+
export declare function encodeWorksheetOtherMetas(worksheet: Partial<IWorksheetData>): Uint8Array;
|
|
28
|
+
export declare function encodeWorkbookOtherMetas(workbook: IWorkbookData): Uint8Array;
|
|
29
|
+
export declare function encodeDocOriginalMeta(document: IDocumentData): Uint8Array;
|
|
30
|
+
export declare function decodeWorksheetOtherMetas(buffer: Uint8Array): Partial<IWorksheetData>;
|
|
31
|
+
export declare function decodeWorkbookOtherMetas(buffer: Uint8Array): Partial<IWorkbookData>;
|
|
32
|
+
export declare function decodePartOfCellData(buffer: Uint8Array | string): IObjectMatrixPrimitiveType<ICellData>;
|
|
33
|
+
export declare function decodeDocOriginalMeta(buffer: Uint8Array | string): Partial<IDocumentData>;
|
|
34
|
+
export declare function splitCellDataToBlocks(cellData: IObjectMatrixPrimitiveType<ICellData>, maxColumn: number): ISheetBlock[];
|
|
@@ -13,7 +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 { IAccessor } from '@wendellhu/redi';
|
|
16
|
+
import type { IAccessor, IDisposable } from '@wendellhu/redi';
|
|
17
17
|
import type { Observable } from 'rxjs';
|
|
18
18
|
import { BehaviorSubject } from 'rxjs';
|
|
19
19
|
import { Disposable } from '../../shared/lifecycle';
|
|
@@ -21,22 +21,30 @@ import type { IMutationInfo } from '../command/command.service';
|
|
|
21
21
|
import { CommandType, ICommandService } from '../command/command.service';
|
|
22
22
|
import { IContextService } from '../context/context.service';
|
|
23
23
|
import { IUniverInstanceService } from '../instance/instance.service';
|
|
24
|
+
import type { Nullable } from '../../common/type-utils';
|
|
24
25
|
export interface IUndoRedoItem {
|
|
25
26
|
/** unitID maps to unitId for UniverSheet / UniverDoc / UniverSlide */
|
|
26
27
|
unitID: string;
|
|
27
28
|
undoMutations: IMutationInfo[];
|
|
28
29
|
redoMutations: IMutationInfo[];
|
|
29
|
-
undo?(mutations: IMutationInfo[]): Promise<boolean> | boolean;
|
|
30
|
-
redo?(mutations: IMutationInfo[]): Promise<boolean> | boolean;
|
|
31
30
|
}
|
|
32
31
|
export interface IUndoRedoService {
|
|
33
32
|
undoRedoStatus$: Observable<IUndoRedoStatus>;
|
|
34
33
|
pushUndoRedo(item: IUndoRedoItem): void;
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
/** Pitch the top redo element of the currently focused Univer document instance. */
|
|
35
|
+
pitchTopUndoElement(): Nullable<IUndoRedoItem>;
|
|
36
|
+
/** Pitch the top undo element of the currently focused Univer document instance. */
|
|
37
|
+
pitchTopRedoElement(): Nullable<IUndoRedoItem>;
|
|
37
38
|
popUndoToRedo(): void;
|
|
38
39
|
popRedoToUndo(): void;
|
|
39
40
|
clearUndoRedo(unitID: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Batch undo redo elements into a single `IUndoRedoItem` util the returned `IDisposable` is called.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated This is a temporary solution. We are going to refactor the undo redo service shortly.
|
|
45
|
+
* @returns a disposable to cancel batching undo redo elements
|
|
46
|
+
*/
|
|
47
|
+
__tempBatchingUndoRedo(unitId: string): IDisposable;
|
|
40
48
|
}
|
|
41
49
|
export interface IUndoRedoCommandInfos {
|
|
42
50
|
undos: IMutationInfo[];
|
|
@@ -77,13 +85,17 @@ export declare class LocalUndoRedoService extends Disposable implements IUndoRed
|
|
|
77
85
|
}>;
|
|
78
86
|
protected readonly _undoStacks: Map<string, IUndoRedoItem[]>;
|
|
79
87
|
protected readonly _redoStacks: Map<string, IUndoRedoItem[]>;
|
|
88
|
+
private _batchingStatus;
|
|
80
89
|
constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _contextService: IContextService);
|
|
81
90
|
pushUndoRedo(item: IUndoRedoItem): void;
|
|
82
91
|
clearUndoRedo(unitID: string): void;
|
|
83
|
-
pitchTopUndoElement(): IUndoRedoItem
|
|
84
|
-
pitchTopRedoElement(): IUndoRedoItem
|
|
92
|
+
pitchTopUndoElement(): Nullable<IUndoRedoItem>;
|
|
93
|
+
pitchTopRedoElement(): Nullable<IUndoRedoItem>;
|
|
94
|
+
private _pitchUndoElement;
|
|
95
|
+
private _pitchRedoElement;
|
|
85
96
|
popUndoToRedo(): void;
|
|
86
97
|
popRedoToUndo(): void;
|
|
98
|
+
__tempBatchingUndoRedo(unitId: string): IDisposable;
|
|
87
99
|
protected _updateStatus(): void;
|
|
88
100
|
protected _getUndoStack(unitId: string): IUndoRedoItem[] | null;
|
|
89
101
|
protected _getUndoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
|
|
@@ -91,5 +103,6 @@ export declare class LocalUndoRedoService extends Disposable implements IUndoRed
|
|
|
91
103
|
protected _getRedoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
|
|
92
104
|
protected _getUndoStackForFocused(): IUndoRedoItem[];
|
|
93
105
|
protected _getRedoStackForFocused(): IUndoRedoItem[];
|
|
106
|
+
private _tryBatchingElements;
|
|
94
107
|
private _getFocusedUniverInstanceId;
|
|
95
108
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare function b64EncodeUnicode(str: string): string;
|
|
17
|
+
export declare function b64DecodeUnicode(str: string): string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
interface IRgbColor {
|
|
16
|
+
export interface IRgbColor {
|
|
17
17
|
b: number;
|
|
18
18
|
g: number;
|
|
19
19
|
r: number;
|
|
@@ -61,4 +61,6 @@ export declare class ColorKit {
|
|
|
61
61
|
isLight(): boolean;
|
|
62
62
|
private _setNullColor;
|
|
63
63
|
}
|
|
64
|
+
export declare function isBlackColor(color: string): boolean;
|
|
65
|
+
export declare function isWhiteColor(color: string): boolean;
|
|
64
66
|
export {};
|
|
@@ -19,4 +19,5 @@ interface AnyObject {
|
|
|
19
19
|
}
|
|
20
20
|
export declare function deepCompare(arg1: AnyObject, arg2: AnyObject): boolean;
|
|
21
21
|
export declare function isSameStyleTextRun(tr1: ITextRun, tr2: ITextRun): boolean;
|
|
22
|
+
export declare function checkForSubstrings(searchString: string, substrings: string[]): boolean;
|
|
22
23
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
export * from './array-search';
|
|
17
17
|
export * from './blob';
|
|
18
18
|
export * from './color/color';
|
|
19
|
-
export { ColorKit, COLORS, RGB_PAREN, RGBA_PAREN } from './color/color-kit';
|
|
19
|
+
export { ColorKit, COLORS, RGB_PAREN, RGBA_PAREN, type IRgbColor } from './color/color-kit';
|
|
20
20
|
export * from './command-enum';
|
|
21
21
|
export * from './common';
|
|
22
22
|
export * from './compare';
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export type LanguageValue = string | string[] | ILanguagePack | ILanguagePack[] | boolean;
|
|
16
17
|
export interface ILanguagePack {
|
|
17
|
-
[key: string]:
|
|
18
|
+
[key: string]: LanguageValue;
|
|
18
19
|
}
|
|
19
20
|
export interface ILocales {
|
|
20
21
|
[key: string]: ILanguagePack;
|
|
@@ -42,6 +42,9 @@ export declare class ObjectMatrix<T> {
|
|
|
42
42
|
getMatrix(): IObjectMatrixPrimitiveType<T>;
|
|
43
43
|
forEach(callback: (row: number, objectArray: IObjectArrayPrimitiveType<T>) => Nullable<boolean>): ObjectMatrix<T>;
|
|
44
44
|
forRow(callback: (row: number, cols: number[]) => Nullable<boolean>): ObjectMatrix<T>;
|
|
45
|
+
/**
|
|
46
|
+
* Iterate the object matrix with row priority, which means it scan the whole range row by row.
|
|
47
|
+
*/
|
|
45
48
|
forValue(callback: (row: number, col: number, value: T) => Nullable<boolean>): ObjectMatrix<T>;
|
|
46
49
|
swapRow(src: number, target: number): void;
|
|
47
50
|
getRow(rowIndex: number): Nullable<IObjectArrayPrimitiveType<T>>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IDisposable } from '@wendellhu/redi';
|
|
17
|
+
import { Observable } from 'rxjs';
|
|
18
|
+
type CallbackFn<T extends readonly unknown[]> = (cb: (...args: T) => void) => IDisposable;
|
|
19
|
+
export declare function fromCallback<T extends readonly unknown[]>(callback: CallbackFn<T>): Observable<T>;
|
|
20
|
+
export {};
|
|
@@ -23,7 +23,7 @@ export declare class Tools {
|
|
|
23
23
|
static deleteBlank(value?: string): string | undefined;
|
|
24
24
|
static getSystemType(): string;
|
|
25
25
|
static getBrowserType(): string;
|
|
26
|
-
static generateRandomId(n?: number): string;
|
|
26
|
+
static generateRandomId(n?: number, alphabet?: string): string;
|
|
27
27
|
static getClassName(instance: object): string;
|
|
28
28
|
static deepMerge(target: any, ...sources: any[]): any;
|
|
29
29
|
static numberFixed(value: number, digit: number): number;
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { Dependency } from '@wendellhu/redi';
|
|
17
16
|
import { Univer } from '../../basics/univer';
|
|
18
17
|
import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
|
|
19
|
-
export declare function createCoreTestBed(workbookConfig?: IWorkbookData
|
|
18
|
+
export declare function createCoreTestBed(workbookConfig?: IWorkbookData): {
|
|
20
19
|
univer: Univer;
|
|
21
20
|
get: {
|
|
22
21
|
<T>(id: import("@wendellhu/redi").DependencyIdentifier<T>, lookUp?: import("@wendellhu/redi").LookUp | undefined): T;
|
|
@@ -18,8 +18,6 @@ import type { Nullable } from '../shared/types';
|
|
|
18
18
|
import type { IRange, IRowData, IWorksheetData } from '../types/interfaces';
|
|
19
19
|
/**
|
|
20
20
|
* Manage configuration information of all rows, get row height, row length, set row height, etc.
|
|
21
|
-
*
|
|
22
|
-
* @deprecated This class is not necessary. It increases the complexity of the code and does not bring any benefits.
|
|
23
21
|
*/
|
|
24
22
|
export declare class RowManager {
|
|
25
23
|
private readonly _config;
|
|
@@ -66,6 +66,7 @@ export declare class Workbook extends Disposable {
|
|
|
66
66
|
*/
|
|
67
67
|
addWorksheet(id: string, index: number, worksheetSnapshot: Partial<IWorksheetData>): boolean;
|
|
68
68
|
getParentRenderUnitId(): string | undefined;
|
|
69
|
+
getSheetOrders(): Readonly<string[]>;
|
|
69
70
|
getWorksheets(): Map<string, Worksheet>;
|
|
70
71
|
getActiveSpreadsheet(): Workbook;
|
|
71
72
|
getStyles(): Styles;
|
|
@@ -23,11 +23,10 @@ import { RowManager } from './row-manager';
|
|
|
23
23
|
import type { Styles } from './styles';
|
|
24
24
|
import { SheetViewModel } from './view-model';
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* The model of a Worksheet.
|
|
27
27
|
*/
|
|
28
28
|
export declare class Worksheet {
|
|
29
29
|
private readonly _styles;
|
|
30
|
-
protected _initialized: boolean;
|
|
31
30
|
protected _sheetId: string;
|
|
32
31
|
protected _snapshot: IWorksheetData;
|
|
33
32
|
protected _cellData: ObjectMatrix<ICellData>;
|
|
@@ -83,13 +82,6 @@ export declare class Worksheet {
|
|
|
83
82
|
*/
|
|
84
83
|
clone(): Worksheet;
|
|
85
84
|
getMergeData(): IRange[];
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated use `getMergedCell` instead
|
|
88
|
-
* @param row
|
|
89
|
-
* @param col
|
|
90
|
-
* @returns
|
|
91
|
-
*/
|
|
92
|
-
getMergedCells(row: number, col: number): Nullable<IRange[]>;
|
|
93
85
|
getMergedCell(row: number, col: number): Nullable<IRange>;
|
|
94
86
|
getCell(row: number, col: number): Nullable<ICellDataForSheetInterceptor>;
|
|
95
87
|
getCellRaw(row: number, col: number): Nullable<ICellData>;
|
|
@@ -215,3 +207,9 @@ export interface ICell {
|
|
|
215
207
|
colSpan?: number;
|
|
216
208
|
value: ICellData;
|
|
217
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Get pure text in a cell.
|
|
212
|
+
* @param cell
|
|
213
|
+
* @returns pure text in this cell
|
|
214
|
+
*/
|
|
215
|
+
export declare function extractPureTextFromCell(cell: ICellData): Nullable<string>;
|
|
@@ -37,7 +37,13 @@ export interface ICellData {
|
|
|
37
37
|
*/
|
|
38
38
|
v?: Nullable<CellValue>;
|
|
39
39
|
t?: Nullable<CellValueType>;
|
|
40
|
+
/**
|
|
41
|
+
* Raw formula string. For example `=SUM(A1:B4)`.
|
|
42
|
+
*/
|
|
40
43
|
f?: Nullable<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Id of the formula.
|
|
46
|
+
*/
|
|
41
47
|
si?: Nullable<string>;
|
|
42
48
|
}
|
|
43
49
|
export interface ICellDataForSheetInterceptor extends ICellData {
|