Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor(core)!: remove redundant files in core package (#3154)

Wenzhao Huf08fde624280
diff --git a/examples/src/data/sheets/default-workbook-data.ts b/examples/src/data/sheets/default-workbook-data.ts
index a7943c8b3d..0b46e233fd 100644
--- a/examples/src/data/sheets/default-workbook-data.ts
+++ b/examples/src/data/sheets/default-workbook-data.ts
@@ -552,7 +552,6 @@ export const DEFAULT_WORKBOOK_DATA: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
'sheet-02': {
@@ -929,7 +928,6 @@ export const DEFAULT_WORKBOOK_DATA_DOWN: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
'sheet-0002': {
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo.ts b/examples/src/data/sheets/demo/default-workbook-data-demo.ts
index 5429b790b7..78da31be40 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo.ts
@@ -14287,9 +14287,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: [
- 'A1',
- ],
rightToLeft: 0,
},
'dv-test': {
@@ -15711,7 +15708,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0009': {
@@ -16935,7 +16931,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0008': {
@@ -18566,7 +18561,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0007': {
@@ -19141,7 +19135,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0006': {
@@ -19790,7 +19783,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0005': {
@@ -21365,7 +21357,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
'sheet-0004': {
@@ -21835,7 +21826,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
'sheet-0003': {
@@ -22452,7 +22442,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
'sheet-0002': {
@@ -23375,7 +23364,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
'sheet-0001': {
@@ -23768,7 +23756,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
// 'sheet-0011': {
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo1.ts b/examples/src/data/sheets/demo/default-workbook-data-demo1.ts
index 412aea7e51..3df2c39c2f 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo1.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo1.ts
@@ -1827,7 +1827,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO1: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo2.ts b/examples/src/data/sheets/demo/default-workbook-data-demo2.ts
index 636207ad90..8fba153079 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo2.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo2.ts
@@ -2137,23 +2137,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO2: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
},
- // namedRanges: [
- // {
- // namedRangeId: 'named-rang',
- // name: 'namedRange',
- // range: {
- // sheetId: 'sheet-0001',
- // range: {
- // startRow: 0,
- // startColumn: 0,
- // endRow: 1,
- // endColumn: 1,
- // },
- // },
- // },
- // ],
};
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo3.ts b/examples/src/data/sheets/demo/default-workbook-data-demo3.ts
index 5f72d6985e..5bc36a68c4 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo3.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo3.ts
@@ -1644,23 +1644,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO3: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
},
- // namedRanges: [
- // {
- // namedRangeId: 'named-rang',
- // name: 'namedRange',
- // range: {
- // sheetId: 'sheet-0001',
- // range: {
- // startRow: 0,
- // startColumn: 0,
- // endRow: 1,
- // endColumn: 1,
- // },
- // },
- // },
- // ],
};
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo4.ts b/examples/src/data/sheets/demo/default-workbook-data-demo4.ts
index 2ea87914b0..885446d5c5 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo4.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo4.ts
@@ -1614,7 +1614,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO4: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo5.ts b/examples/src/data/sheets/demo/default-workbook-data-demo5.ts
index aa86dfafe3..e15d33c068 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo5.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo5.ts
@@ -4211,7 +4211,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO5: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo6.ts b/examples/src/data/sheets/demo/default-workbook-data-demo6.ts
index dac18fa298..aacaee78a9 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo6.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo6.ts
@@ -3289,7 +3289,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO6: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo7.ts b/examples/src/data/sheets/demo/default-workbook-data-demo7.ts
index 80bc93414f..c0e6e73df5 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo7.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo7.ts
@@ -16778,7 +16778,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
// 'sheet-0011':{
@@ -26638,9 +26637,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO7: IWorkbookData = {
// "height": 20,
// "hidden": 0
// },
- // "selections": [
- // "A1"
- // ],
// "rightToLeft": 0,
// }
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-demo8.ts b/examples/src/data/sheets/demo/default-workbook-data-demo8.ts
index 51480085b0..9d999b43b1 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-demo8.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-demo8.ts
@@ -38015,7 +38015,6 @@ export const DEFAULT_WORKBOOK_DATA_DEMO8: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
},
diff --git a/examples/src/data/sheets/demo/default-workbook-data-validation.ts b/examples/src/data/sheets/demo/default-workbook-data-validation.ts
index 58e04ab803..93273cafc9 100644
--- a/examples/src/data/sheets/demo/default-workbook-data-validation.ts
+++ b/examples/src/data/sheets/demo/default-workbook-data-validation.ts
@@ -142,9 +142,6 @@ export const DEFAULT_WORKBOOK_DATA_VALIDATION = {
height: 20,
hidden: 0,
},
- selections: [
- 'A1',
- ],
rightToLeft: 0,
},
},
diff --git a/examples/src/data/sheets/demo/testdata.json b/examples/src/data/sheets/demo/testdata.json
index a4aec46ccd..e3be9eef6e 100644
--- a/examples/src/data/sheets/demo/testdata.json
+++ b/examples/src/data/sheets/demo/testdata.json
@@ -26348,9 +26348,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0
},
"dv-test": {
@@ -26413,9 +26410,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0
},
"sheet-0010": {
@@ -27798,9 +27792,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0
},
"sheet-0009": {
@@ -29024,9 +29015,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -30663,9 +30651,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -31246,9 +31231,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -31903,9 +31885,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -33486,9 +33465,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A1"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -34006,9 +33982,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A2"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -34788,9 +34761,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A2"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -35719,9 +35689,7 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A2"
- ],
+
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
@@ -36157,9 +36125,6 @@
"height": 20,
"hidden": 0
},
- "selections": [
- "A2"
- ],
"rightToLeft": 0,
"freeze": {
"xSplit": 0,
diff --git a/examples/src/data/sheets/slide-workbook-data.ts b/examples/src/data/sheets/slide-workbook-data.ts
index 9d56b40611..75631370ed 100644
--- a/examples/src/data/sheets/slide-workbook-data.ts
+++ b/examples/src/data/sheets/slide-workbook-data.ts
@@ -611,7 +611,6 @@ export const SLIDE_WORKBOOK_DATA: IWorkbookData = {
height: 20,
hidden: BooleanNumber.FALSE,
},
- selections: ['A2'],
rightToLeft: BooleanNumber.FALSE,
},
},
diff --git a/examples/src/data/sheets/uniscript-data.ts b/examples/src/data/sheets/uniscript-data.ts
index 52dbbb9f19..473d82c7cb 100644
--- a/examples/src/data/sheets/uniscript-data.ts
+++ b/examples/src/data/sheets/uniscript-data.ts
@@ -5683,7 +5683,6 @@ export const UNISCRIT_WORKBOOK_DATA_DEMO: IWorkbookData = {
height: 20,
hidden: 0,
},
- selections: ['A1'],
rightToLeft: 0,
},
},
diff --git a/packages/core/src/common/equal.ts b/packages/core/src/common/equal.ts
index 5d0c30e13d..80dacf66cc 100644
--- a/packages/core/src/common/equal.ts
+++ b/packages/core/src/common/equal.ts
@@ -14,9 +14,6 @@
* limitations under the License.
*/
-import { Rectangle } from '../shared/rectangle';
-import type { IRange, IUnitRange } from '../types/interfaces';
-
/**
* Copyright 2023-present DreamNum Inc.
*
@@ -33,17 +30,6 @@ import type { IRange, IUnitRange } from '../types/interfaces';
* limitations under the License.
*/
-export const isRangesEqual = (oldRanges: IRange[], ranges: IRange[]) => {
- return ranges.length === oldRanges.length && !oldRanges.some((oldRange) => ranges.some((range) => !Rectangle.equals(range, oldRange)));
-};
-
-export const isUnitRangesEqual = (oldRanges: IUnitRange[], ranges: IUnitRange[]) => {
- return ranges.length === oldRanges.length && oldRanges.every((oldRange, i) => {
- const current = ranges[i];
- return current.unitId === oldRange.unitId && current.sheetId === oldRange.sheetId && Rectangle.equals(oldRange.range, current.range);
- });
-};
-
export function shallowEqual(objA: any, objB: any) {
if (Object.is(objA, objB)) {
return true;
diff --git a/packages/core/src/common/interceptor.ts b/packages/core/src/common/interceptor.ts
index 9773770050..a2467a5d40 100644
--- a/packages/core/src/common/interceptor.ts
+++ b/packages/core/src/common/interceptor.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
+import type { Nullable } from '../shared/types';
import { remove } from './array';
-import type { Nullable } from './type-util';
export type InterceptorHandler<M = unknown, C = unknown> = (
value: Nullable<M>,
diff --git a/packages/core/src/common/type-utils.ts b/packages/core/src/common/type-utils.ts
deleted file mode 100644
index 4757c3d8b5..0000000000
--- a/packages/core/src/common/type-utils.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export type Nullable<T> = T | null | undefined | void;
diff --git a/packages/core/src/docs/data-model/document-data-model.ts b/packages/core/src/docs/data-model/document-data-model.ts
index 6a4f924f5f..4eb522e1ec 100644
--- a/packages/core/src/docs/data-model/document-data-model.ts
+++ b/packages/core/src/docs/data-model/document-data-model.ts
@@ -94,16 +94,6 @@ class DocumentDataModelSimple extends UnitModel<IDocumentData, UniverInstanceTyp
return this.snapshot.body;
}
- getShouldRenderLoopImmediately() {
- const should = this.snapshot.shouldStartRenderingImmediately;
-
- return should !== false;
- }
-
- getContainer() {
- return this.snapshot.container;
- }
-
getSnapshot() {
return this.snapshot;
}
diff --git a/packages/core/src/docs/data-model/text-x/__tests__/invert.spec.ts b/packages/core/src/docs/data-model/text-x/__tests__/invert.spec.ts
index 9374b4f44f..ee9f80627e 100644
--- a/packages/core/src/docs/data-model/text-x/__tests__/invert.spec.ts
+++ b/packages/core/src/docs/data-model/text-x/__tests__/invert.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { describe, expect } from 'vitest';
+import { describe, expect, it } from 'vitest';
import type { IDocumentBody } from '../../../../types/interfaces';
import { BooleanNumber } from '../../../../types/enum';
import { TextX } from '../text-x';
@@ -23,7 +23,7 @@ import { TextXActionType } from '../action-types';
import { UpdateDocsAttributeType } from '../../../../shared/command-enum';
describe('test TextX static methods invert and makeInvertible', () => {
- describe('test TextX static method invert', () => {
+ it('test TextX static method invert', () => {
const actions: TextXAction[] = [{
t: TextXActionType.RETAIN,
len: 5,
@@ -147,7 +147,7 @@ describe('test TextX static methods invert and makeInvertible', () => {
expect(invertedActions).toEqual(exceptActions);
});
- describe('test TextX static method makeInvertible when `retain` action occur', () => {
+ it('test TextX static method makeInvertible when `retain` action occur', () => {
const docBody: IDocumentBody = {
dataStream: 'hello\r\n',
textRuns: [
@@ -208,7 +208,7 @@ describe('test TextX static methods invert and makeInvertible', () => {
expect(textX.serialize()).toEqual(expectedActions);
});
- describe('test TextX static method makeInvertible when `delete` action occur', () => {
+ it('test TextX static method makeInvertible when `delete` action occur', () => {
const docBody: IDocumentBody = {
dataStream: 'hello\r\n',
textRuns: [
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index f933356941..66e1512677 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -24,7 +24,7 @@ export { type UnitType, UnitModel, UniverInstanceType } from './common/unit';
export { Registry, RegistryAsMap } from './common/registry';
export { CustomCommandExecutionError } from './common/error';
export { Univer } from './univer';
-export { shallowEqual, isRangesEqual, isUnitRangesEqual } from './common/equal';
+export { shallowEqual } from './common/equal';
export { isNumeric, isSafeNumeric } from './common/number';
export { isBooleanString } from './common/boolean';
export { dedupe, remove, rotate, groupBy, makeArray } from './common/array';
@@ -131,6 +131,7 @@ export { ConfigService } from './services/config/config.service';
// #region sheet
+export { isRangesEqual, isUnitRangesEqual } from './sheets/util';
export { Range } from './sheets/range';
export { Styles } from './sheets/styles';
export {
@@ -149,6 +150,7 @@ export {
mergeWorksheetSnapshotWithDefault,
} from './sheets/sheet-snapshot-utils';
export { SheetViewModel } from './sheets/view-model';
+export * from './sheets/typedef';
export { getWorksheetUID, Workbook } from './sheets/workbook';
export { Worksheet, extractPureTextFromCell } from './sheets/worksheet';
export { SlideDataModel } from './slides/slide-model';
diff --git a/packages/core/src/services/permission/type.ts b/packages/core/src/services/permission/type.ts
index 21cf0d5ed2..140696562d 100644
--- a/packages/core/src/services/permission/type.ts
+++ b/packages/core/src/services/permission/type.ts
@@ -17,9 +17,9 @@
import type { BehaviorSubject, Observable } from 'rxjs';
import type { UnitAction, UnitObject } from '@univerjs/protocol';
import { createIdentifier } from '../../common/di';
-import type { Nullable } from '../../common/type-utils';
import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';
-import type { IRange } from '../../types/interfaces';
+import type { IRange } from '../../sheets/typedef';
+import type { Nullable } from '../../shared/types';
export enum PermissionStatus {
INIT = 'init',
diff --git a/packages/core/src/services/resource-loader/resource-loader.service.ts b/packages/core/src/services/resource-loader/resource-loader.service.ts
index bfc3f286ff..05edda2e1e 100644
--- a/packages/core/src/services/resource-loader/resource-loader.service.ts
+++ b/packages/core/src/services/resource-loader/resource-loader.service.ts
@@ -16,7 +16,6 @@
import { Inject } from '../../common/di';
import type { Workbook } from '../../sheets/workbook';
-import type { IWorkbookData } from '../../types/interfaces';
import type { IResourceHook } from '../resource-manager/type';
import { IResourceManagerService } from '../resource-manager/type';
import { IUniverInstanceService } from '../instance/instance.service';
@@ -24,6 +23,7 @@ import { Disposable } from '../../shared/lifecycle';
import { UniverInstanceType } from '../../common/unit';
import type { DocumentDataModel } from '../../docs';
import { isInternalEditorID } from '../../common/const';
+import type { IWorkbookData } from '../../sheets/typedef';
import type { IResourceLoaderService } from './type';
export class ResourceLoaderService extends Disposable implements IResourceLoaderService {
diff --git a/packages/core/src/services/resource-loader/type.ts b/packages/core/src/services/resource-loader/type.ts
index eeba166919..5b01b85475 100644
--- a/packages/core/src/services/resource-loader/type.ts
+++ b/packages/core/src/services/resource-loader/type.ts
@@ -16,10 +16,10 @@
import { createIdentifier } from '../../common/di';
import type { Workbook } from '../../sheets/workbook';
-import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';
import type { IDocumentData } from '../../types/interfaces';
import type { DocumentDataModel } from '../../docs';
+import type { IWorkbookData } from '../../sheets/typedef';
export interface IResourceLoaderService {
saveWorkbook: (workbook: Workbook) => IWorkbookData;
diff --git a/packages/core/src/services/resource-manager/resource-manager.service.ts b/packages/core/src/services/resource-manager/resource-manager.service.ts
index ff00ed4612..6f1d64ef50 100644
--- a/packages/core/src/services/resource-manager/resource-manager.service.ts
+++ b/packages/core/src/services/resource-manager/resource-manager.service.ts
@@ -16,8 +16,8 @@
import { Subject } from 'rxjs';
import { Disposable, toDisposable } from '../../shared/lifecycle';
-import type { Resources } from '../../types/interfaces/i-workbook-data';
import type { UniverInstanceType } from '../../common/unit';
+import type { Resources } from '../../types/interfaces/resource';
import type { IResourceHook, IResourceManagerService, IResourceName } from './type';
export class ResourceManagerService extends Disposable implements IResourceManagerService {
diff --git a/packages/core/src/services/resource-manager/type.ts b/packages/core/src/services/resource-manager/type.ts
index b645bd28c2..9bae32b3c5 100644
--- a/packages/core/src/services/resource-manager/type.ts
+++ b/packages/core/src/services/resource-manager/type.ts
@@ -18,7 +18,7 @@ import type { Observable } from 'rxjs';
import type { UniverInstanceType } from '@univerjs/core';
import type { IDisposable } from '../../common/di';
import { createIdentifier } from '../../common/di';
-import type { Resources } from '../../types/interfaces/i-workbook-data';
+import type { Resources } from '../../types/interfaces/resource';
type IBusinessName = 'SHEET' | 'DOC';
export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
diff --git a/packages/core/src/services/snapshot/__tests__/snapshot-mock.ts b/packages/core/src/services/snapshot/__tests__/snapshot-mock.ts
index 7891848f9e..ce788b9fb5 100644
--- a/packages/core/src/services/snapshot/__tests__/snapshot-mock.ts
+++ b/packages/core/src/services/snapshot/__tests__/snapshot-mock.ts
@@ -18,11 +18,11 @@ import type { IFetchMissingChangesetsRequest, IFetchMissingChangesetsResponse, I
import { ErrorCode } from '@univerjs/protocol';
import { textEncoder } from '../snapshot-utils';
-import type { IWorkbookData } from '../../../types/interfaces/i-workbook-data';
import { LocaleType } from '../../../types/enum/locale-type';
import type { ILogContext } from '../../log/context';
import type { ISnapshotServerService } from '../snapshot-server.service';
import { b64DecodeUnicode } from '../../../shared/coder';
+import type { IWorkbookData } from '../../../sheets/typedef';
export const testSnapshot = (): ISnapshot => ({
unitID: '100',
@@ -43,7 +43,9 @@ export const testSnapshot = (): ISnapshot => ({
name: 'Sheet 1',
rowCount: 1000,
columnCount: 20,
- originalMeta: textEncoder.encode(b64DecodeUnicode('eyJmcmVlemUiOiB7InhTcGxpdCI6IDAsICJ5U3BsaXQiOiAwLCAic3RhcnRSb3ciOiAtMSwgInN0YXJ0Q29sdW1uIjogLTF9LCAiaGlkZGVuIjogMCwgInJvd0RhdGEiOiB7IjAiOiB7ImgiOiAyNywgImFoIjogMjcsICJoZCI6IDB9fSwgInRhYkNvbG9yIjogInJlZCIsICJtZXJnZURhdGEiOiBbXSwgInJvd0hlYWRlciI6IHsid2lkdGgiOiA0NiwgImhpZGRlbiI6IDB9LCAic2Nyb2xsVG9wIjogMjAwLCAiem9vbVJhdGlvIjogMSwgImNvbHVtbkRhdGEiOiB7fSwgInNjcm9sbExlZnQiOiAxMDAsICJzZWxlY3Rpb25zIjogWyJBMSJdLCAicmlnaHRUb0xlZnQiOiAwLCAiY29sdW1uSGVhZGVyIjogeyJoZWlnaHQiOiAyMCwgImhpZGRlbiI6IDB9LCAic2hvd0dyaWRsaW5lcyI6IDEsICJkZWZhdWx0Um93SGVpZ2h0IjogMjcsICJkZWZhdWx0Q29sdW1uV2lkdGgiOiA5M30=')),
+ originalMeta: textEncoder.encode(b64DecodeUnicode(
+ 'eyJmcmVlemUiOiB7InhTcGxpdCI6IDAsICJ5U3BsaXQiOiAwLCAic3RhcnRSb3ciOiAtMSwgInN0YXJ0Q29sdW1uIjogLTF9LCAiaGlkZGVuIjogMCwgInJvd0RhdGEiOiB7IjAiOiB7ImgiOiAyNywgImFoIjogMjcsICJoZCI6IDB9fSwgInRhYkNvbG9yIjogInJlZCIsICJtZXJnZURhdGEiOiBbXSwgInJvd0hlYWRlciI6IHsid2lkdGgiOiA0NiwgImhpZGRlbiI6IDB9LCAic2Nyb2xsVG9wIjogMjAwLCAiem9vbVJhdGlvIjogMSwgImNvbHVtbkRhdGEiOiB7fSwgInNjcm9sbExlZnQiOiAxMDAsICJyaWdodFRvTGVmdCI6IDAsICJjb2x1bW5IZWFkZXIiOiB7ImhlaWdodCI6IDIwLCAiaGlkZGVuIjogMH0sICJzaG93R3JpZGxpbmVzIjogMSwgImRlZmF1bHRSb3dIZWlnaHQiOiAyNywgImRlZmF1bHRDb2x1bW5XaWR0aCI6IDkzfQ=='
+ )),
},
},
resources: [],
@@ -108,9 +110,6 @@ export const testWorkbookData = (): IWorkbookData => ({
zoomRatio: 1,
columnData: {},
scrollLeft: 100,
- selections: [
- 'A1',
- ],
rightToLeft: 0,
columnHeader: {
height: 20,
diff --git a/packages/core/src/services/snapshot/__tests__/snapshot-transform.spec.ts b/packages/core/src/services/snapshot/__tests__/snapshot-transform.spec.ts
index 58cf4ded51..cb8035bd15 100644
--- a/packages/core/src/services/snapshot/__tests__/snapshot-transform.spec.ts
+++ b/packages/core/src/services/snapshot/__tests__/snapshot-transform.spec.ts
@@ -64,6 +64,7 @@ describe('Test snapshot transform', () => {
expect(blocks).toStrictEqual(testSheetBlocks());
});
+
it('Function transformSnapshotToWorkbookData', () => {
expect(transformSnapshotToWorkbookData(testSnapshot(), testSheetBlocks())).toStrictEqual(testWorkbookData());
});
diff --git a/packages/core/src/services/snapshot/snapshot-transform.ts b/packages/core/src/services/snapshot/snapshot-transform.ts
index 117bcf1adf..e83930658f 100644
--- a/packages/core/src/services/snapshot/snapshot-transform.ts
+++ b/packages/core/src/services/snapshot/snapshot-transform.ts
@@ -14,16 +14,14 @@
* limitations under the License.
*/
-import type { IDocumentMeta, IGetSheetBlockRequest, ISheetBlock, ISheetBlockMeta, ISnapshot, IWorkbookMeta, IWorksheetMeta } from '@univerjs/protocol';
+import type { ICellData, IDocumentMeta, IGetSheetBlockRequest, ISheetBlock, ISheetBlockMeta, ISnapshot, IWorkbookMeta, IWorksheetMeta } from '@univerjs/protocol';
import { ErrorCode, isError, UniverType } from '@univerjs/protocol';
import type { ILogContext } from '../log/context';
-import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
import { SheetTypes } from '../../types/enum/sheet-types';
-import type { IWorksheetData } from '../../types/interfaces/i-worksheet-data';
-import type { ICellData } from '../../types/interfaces/i-cell-data';
import { LocaleType } from '../../types/enum/locale-type';
import type { IDocumentData } from '../../types/interfaces/i-document-data';
+import type { IWorkbookData, IWorksheetData } from '../../sheets/typedef';
import {
decodeDocOriginalMeta,
decodePartOfCellData,
diff --git a/packages/core/src/services/snapshot/snapshot-utils.ts b/packages/core/src/services/snapshot/snapshot-utils.ts
index cd65c83490..45a1a35781 100644
--- a/packages/core/src/services/snapshot/snapshot-utils.ts
+++ b/packages/core/src/services/snapshot/snapshot-utils.ts
@@ -17,13 +17,11 @@
import type { ISheetBlock } from '@univerjs/protocol';
import { b64DecodeUnicode } from '../../shared/coder';
-import type { IWorksheetData } from '../../types/interfaces/i-worksheet-data';
import { Tools } from '../../shared/tools';
-import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
import type { IDocumentData } from '../../types/interfaces/i-document-data';
-import type { ICellData } from '../../types/interfaces/i-cell-data';
import type { IObjectMatrixPrimitiveType } from '../../shared/object-matrix';
import { ObjectMatrix } from '../../shared/object-matrix';
+import type { ICellData, IWorkbookData, IWorksheetData } from '../../sheets/typedef';
// Some properties are stored in the meta fields or are in sheet blocks.
// They can be found in `packages/collaboration/src/services/snapshot/snapshot-utils.ts`.
diff --git a/packages/core/src/services/theme/theme.service.ts b/packages/core/src/services/theme/theme.service.ts
index ac1cfe38f1..92da9702e9 100644
--- a/packages/core/src/services/theme/theme.service.ts
+++ b/packages/core/src/services/theme/theme.service.ts
@@ -17,8 +17,8 @@
import type { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
-import type { Nullable } from '../../common/type-util';
import { Disposable, toDisposable } from '../../shared/lifecycle';
+import type { Nullable } from '../../shared/types';
export interface IStyleSheet {
[key: string]: string;
@@ -36,14 +36,15 @@ export class ThemeService extends Disposable {
this.disposeWithMe(toDisposable(() => this._currentTheme$.complete()));
}
- getCurrentTheme() {
+ getCurrentTheme(): IStyleSheet {
if (!this._currentTheme) {
throw new Error('[ThemeService]: current theme is not set!');
}
+
return this._currentTheme;
}
- setTheme(theme: IStyleSheet) {
+ setTheme(theme: IStyleSheet): void {
this._currentTheme = theme;
this._currentTheme$.next(theme);
}
diff --git a/packages/core/src/services/undoredo/undoredo.service.ts b/packages/core/src/services/undoredo/undoredo.service.ts
index b10220d064..32c76475dc 100644
--- a/packages/core/src/services/undoredo/undoredo.service.ts
+++ b/packages/core/src/services/undoredo/undoredo.service.ts
@@ -26,7 +26,7 @@ import { CommandType, ICommandService, sequenceExecute } from '../command/comman
import { EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHEET } from '../context/context';
import { IContextService } from '../context/context.service';
import { IUniverInstanceService } from '../instance/instance.service';
-import type { Nullable } from '../../common/type-util';
+import type { Nullable } from '../../shared/types';
export interface IUndoRedoItem {
/** unitID maps to unitId for UniverSheet / UniverDoc / UniverSlide */
diff --git a/packages/core/src/shared/__tests__/range.spec.ts b/packages/core/src/shared/__tests__/range.spec.ts
index eb73ad88f8..f66b76d48f 100644
--- a/packages/core/src/shared/__tests__/range.spec.ts
+++ b/packages/core/src/shared/__tests__/range.spec.ts
@@ -16,8 +16,8 @@
import { describe, expect, it } from 'vitest';
-import { AbsoluteRefType } from '../../types/interfaces/i-range';
import { moveRangeByOffset } from '../range';
+import { AbsoluteRefType } from '../../sheets/typedef';
describe('test moveRangeByOffset', () => {
it('test normal', () => {
diff --git a/packages/core/src/shared/__tests__/rectangle.spec.ts b/packages/core/src/shared/__tests__/rectangle.spec.ts
index 9b5ec2af1d..a0764f55f0 100644
--- a/packages/core/src/shared/__tests__/rectangle.spec.ts
+++ b/packages/core/src/shared/__tests__/rectangle.spec.ts
@@ -17,8 +17,8 @@
import { describe, expect, it } from 'vitest';
import { Rectangle } from '../rectangle';
-import { AbsoluteRefType } from '../../types/interfaces/i-range';
-import type { IRange } from '../../types/interfaces/i-range';
+import type { IRange } from '../../sheets/typedef';
+import { AbsoluteRefType } from '../../sheets/typedef';
const cellToRange = (row: number, col: number) => ({ startRow: row, endRow: row, startColumn: col, endColumn: col } as IRange);
describe('test "Rectangle"', () => {
diff --git a/packages/core/src/shared/check-if-move.ts b/packages/core/src/shared/check-if-move.ts
index 53f445d7c3..fa068e5ff6 100644
--- a/packages/core/src/shared/check-if-move.ts
+++ b/packages/core/src/shared/check-if-move.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { Nullable } from '../common/type-util';
import type { ITransformState } from '../types/interfaces/i-document-data';
+import type { Nullable } from './types';
export const MOVE_BUFFER_VALUE = 2;
diff --git a/packages/core/src/shared/color/color.ts b/packages/core/src/shared/color/color.ts
index 3c6052477c..dd972b3278 100644
--- a/packages/core/src/shared/color/color.ts
+++ b/packages/core/src/shared/color/color.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import type { Nullable } from '../../common/type-util';
import { THEME_COLORS } from '../../types/const/theme-color-map';
import { ColorType, ThemeColors, ThemeColorType } from '../../types/enum';
+import type { Nullable } from '../types';
export class ColorBuilder {
private _themeValue: ThemeColorType = ThemeColorType.LIGHT1;
diff --git a/packages/core/src/shared/common.ts b/packages/core/src/shared/common.ts
index 0435da4d21..6132f82730 100644
--- a/packages/core/src/shared/common.ts
+++ b/packages/core/src/shared/common.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import type { ICellData, ICellDataForSheetInterceptor, IRange, IRangeWithCoord, ISelectionCell, ISelectionCellWithMergeInfo } from '../sheets/typedef';
+import { RANGE_TYPE } from '../sheets/typedef';
import {
BaselineOffset,
BorderStyleTypes,
@@ -22,10 +24,7 @@ import {
VerticalAlign,
WrapStrategy,
} from '../types/enum';
-import { type IRange, RANGE_TYPE } from '../types/interfaces';
-import type { ICellData, ICellDataForSheetInterceptor } from '../types/interfaces/i-cell-data';
import type { IDocumentData } from '../types/interfaces/i-document-data';
-import type { IRangeWithCoord, ISelectionCell, ISelectionCellWithMergeInfo } from '../types/interfaces/i-selection-data';
import type { IColorStyle, IStyleData } from '../types/interfaces/i-style-data';
import { ColorBuilder } from './color/color';
import { Tools } from './tools';
diff --git a/packages/core/src/shared/object-matrix-query.ts b/packages/core/src/shared/object-matrix-query.ts
index d40ed5855c..ecca56d210 100644
--- a/packages/core/src/shared/object-matrix-query.ts
+++ b/packages/core/src/shared/object-matrix-query.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import type { Nullable } from '../common/type-util';
import { Range } from '../sheets/range';
-import type { IRange } from '../types/interfaces';
+import type { IRange } from '../sheets/typedef';
import type { ObjectMatrix } from './object-matrix';
+import type { Nullable } from './types';
function maximalRectangle<T>(matrix: T[][], match: (val: T) => boolean) {
if (matrix.length === 0 || matrix[0].length === 0) return null;
diff --git a/packages/core/src/shared/object-matrix.ts b/packages/core/src/shared/object-matrix.ts
index c52a30ea5c..275a3a7c51 100644
--- a/packages/core/src/shared/object-matrix.ts
+++ b/packages/core/src/shared/object-matrix.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IRange } from '../types/interfaces/i-range';
+import type { IRange } from '../sheets/typedef';
import { Tools } from './tools';
import type { Nullable } from './types';
@@ -473,19 +473,10 @@ export class ObjectMatrix<T> {
getSizeOf(): number {
const keys = Object.keys(this._matrix);
return keys.length;
- // return this._option.getSizeOf();
}
getLength(): number {
return getArrayLength(this._matrix);
- // let maxIndex = 0;
- // const keys = Object.keys(this._matrix);
- // for (const key of keys) {
- // const rowIndex = Number(key);
- // maxIndex = Math.max(maxIndex, rowIndex);
- // }
- // return maxIndex + 1;
- // return this._option.getLength();
}
getRange(): IRange {
diff --git a/packages/core/src/shared/range.ts b/packages/core/src/shared/range.ts
index 1a4ce726a4..a8559989d5 100644
--- a/packages/core/src/shared/range.ts
+++ b/packages/core/src/shared/range.ts
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-import { AbsoluteRefType, type IRange } from '../types/interfaces/i-range';
+import type { IRange } from '../sheets/typedef';
+import { AbsoluteRefType } from '../sheets/typedef';
import { Rectangle } from './rectangle';
export function moveRangeByOffset(range: IRange, refOffsetX: number, refOffsetY: number, ignoreAbsolute = false): IRange {
diff --git a/packages/core/src/shared/rectangle.ts b/packages/core/src/shared/rectangle.ts
index d90e328980..38b87ee883 100644
--- a/packages/core/src/shared/rectangle.ts
+++ b/packages/core/src/shared/rectangle.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-import type { IRange, IRectLTRB } from '../types/interfaces/i-range';
-import { AbsoluteRefType, RANGE_TYPE } from '../types/interfaces/i-range';
+import { AbsoluteRefType, type IRange, type IRectLTRB, RANGE_TYPE } from '../sheets/typedef';
import type { Nullable } from './types';
/**
diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.ts
index b3b31b11bc..cf5353e6dc 100644
--- a/packages/core/src/shared/tools.ts
+++ b/packages/core/src/shared/tools.ts
@@ -18,7 +18,7 @@ import { customAlphabet, nanoid } from 'nanoid';
import mergeWith from 'lodash.mergewith';
import { isLegalUrl, normalizeUrl } from '../common/url';
-import type { Class, IKeyValue } from './types';
+import type { IKeyValue } from './types';
const rmsPrefix = /^-ms-/;
const rDashAlpha = /-([a-z])/g;
@@ -361,10 +361,6 @@ export class Tools {
return false;
}
- static isAssignableFrom<T>(object: any, clazz: Class<T>): object is T {
- return object instanceof clazz;
- }
-
static isBoolean(value?: any): value is boolean {
return this.getValueType(value) === '[object Boolean]';
}
diff --git a/packages/core/src/shared/types.ts b/packages/core/src/shared/types.ts
index 97c0d5e6b1..8d809d5fa5 100644
--- a/packages/core/src/shared/types.ts
+++ b/packages/core/src/shared/types.ts
@@ -16,32 +16,20 @@
export type Nullable<T> = T | null | undefined | void;
-/**
- * wrap any
- */
-export type NoNeedCheckedType = any;
-
-/**
- * Class type
- */
-export interface Class<T> {
- new (...param: any): T;
-}
-
/**
* Key value object
*
- * @deprecated
+ * @ignore
+ * @deprecated As it has
*/
export interface IKeyValue {
[key: string]: any;
}
/**
- * Custom type of key
+ * @ignore
+ * @deprecated, use {@link Record} instead.
*/
export interface IKeyType<T> {
[key: string]: T;
}
-
-export type AsyncFunction<T = void, R = void> = (value: T) => Promise<R>;
diff --git a/packages/core/src/types/interfaces/__tests__/i-cell-data.spec.ts b/packages/core/src/sheets/__tests__/cell-data.spec.ts
similarity index 98%
rename from packages/core/src/types/interfaces/__tests__/i-cell-data.spec.ts
rename to packages/core/src/sheets/__tests__/cell-data.spec.ts
index d77b8581d1..1ea4798fbe 100644
--- a/packages/core/src/types/interfaces/__tests__/i-cell-data.spec.ts
+++ b/packages/core/src/sheets/__tests__/cell-data.spec.ts
@@ -15,8 +15,7 @@
*/
import { describe, expect, it } from 'vitest';
-
-import { isCellV, isICellData, isNullCell } from '../i-cell-data';
+import { isCellV, isICellData, isNullCell } from '../typedef';
const DOCUMENT_DATA = {
id: 'd',
diff --git a/packages/core/src/sheets/__tests__/create-core-test-bed.ts b/packages/core/src/sheets/__tests__/create-core-test-bed.ts
index 382a2485fe..60523e787d 100644
--- a/packages/core/src/sheets/__tests__/create-core-test-bed.ts
+++ b/packages/core/src/sheets/__tests__/create-core-test-bed.ts
@@ -18,7 +18,7 @@ import { Univer } from '../../univer';
import { IUniverInstanceService } from '../../services/instance/instance.service';
import { ILogService, LogLevel } from '../../services/log/log.service';
import { LocaleType } from '../../types/enum/locale-type';
-import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
+import type { IWorkbookData } from '../typedef';
const testWorkbookDataFactory: () => IWorkbookData = () => ({
id: 'test',
diff --git a/packages/core/src/sheets/__tests__/worksheet.spec.ts b/packages/core/src/sheets/__tests__/worksheet.spec.ts
index 8f34d73d37..1a934b8e73 100644
--- a/packages/core/src/sheets/__tests__/worksheet.spec.ts
+++ b/packages/core/src/sheets/__tests__/worksheet.spec.ts
@@ -17,12 +17,12 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import type { Univer } from '../../univer';
-import type { IWorkbookData } from '../../types/interfaces/i-workbook-data';
import { LocaleType } from '../../types/enum/locale-type';
import { extractPureTextFromCell, type Worksheet } from '../worksheet';
-import { type IRange, RANGE_TYPE } from '../../types/interfaces/i-range';
import { DisposableCollection } from '../../shared/lifecycle';
import { CellValueType } from '../../types/enum';
+import type { IRange, IWorkbookData } from '../typedef';
+import { RANGE_TYPE } from '../typedef';
import { createCoreTestBed } from './create-core-test-bed';
describe('test worksheet', () => {
diff --git a/packages/core/src/sheets/column-manager.ts b/packages/core/src/sheets/column-manager.ts
index 5c8eeeb83c..a79b839c59 100644
--- a/packages/core/src/sheets/column-manager.ts
+++ b/packages/core/src/sheets/column-manager.ts
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-import type { Nullable } from '../common/type-util';
import type { IObjectArrayPrimitiveType } from '../shared/object-matrix';
import { getArrayLength } from '../shared/object-matrix';
+import type { Nullable } from '../shared/types';
import { BooleanNumber } from '../types/enum';
-import type { IColumnData, IRange, IWorksheetData } from '../types/interfaces';
-import { RANGE_TYPE } from '../types/interfaces';
+import { type IColumnData, type IRange, type IWorksheetData, RANGE_TYPE } from './typedef';
/**
* Manage configuration information of all columns, get column width, column length, set column width, etc.
diff --git a/packages/core/src/sheets/empty-snapshot.ts b/packages/core/src/sheets/empty-snapshot.ts
index 64b80db686..b16aa806f6 100644
--- a/packages/core/src/sheets/empty-snapshot.ts
+++ b/packages/core/src/sheets/empty-snapshot.ts
@@ -15,8 +15,8 @@
*/
import { LocaleType } from '../types/enum/locale-type';
-import type { IWorkbookData } from '../types/interfaces';
import { version } from '../../package.json';
+import type { IWorkbookData } from './typedef';
export function getEmptySnapshot(
unitID = '',
diff --git a/packages/core/src/sheets/range.ts b/packages/core/src/sheets/range.ts
index ffb0261a30..271370f41a 100644
--- a/packages/core/src/sheets/range.ts
+++ b/packages/core/src/sheets/range.ts
@@ -19,19 +19,18 @@ import { ObjectMatrix, Tools } from '../shared';
import { DEFAULT_STYLES } from '../types/const';
import type { HorizontalAlign, VerticalAlign } from '../types/enum';
import { BooleanNumber, FontItalic, FontWeight, WrapStrategy } from '../types/enum';
-import {
- type IBorderData,
- type ICellData,
- type IDocumentBody,
- type IDocumentData,
- type IRange,
- type IStyleBase,
- type IStyleData,
- type ITextDecoration,
- type ITextRotation,
- RANGE_TYPE,
+import type {
+ IBorderData,
+ IDocumentBody,
+ IDocumentData,
+ IStyleBase,
+ IStyleData,
+ ITextDecoration,
+ ITextRotation,
} from '../types/interfaces';
import type { Styles } from './styles';
+import type { ICellData, IRange } from './typedef';
+import { RANGE_TYPE } from './typedef';
import type { Worksheet } from './worksheet';
/**
@@ -294,7 +293,7 @@ export class Range {
* @returns — A range containing a single cell at the specified coordinates.
*/
getCell(row: number, column: number): Range {
- const { startRow, endRow, startColumn, endColumn } = this._range;
+ const { startRow, startColumn } = this._range;
const cell = {
startRow: startRow + row,
endRow: startRow + row,
diff --git a/packages/core/src/sheets/row-manager.ts b/packages/core/src/sheets/row-manager.ts
index 15edc27830..7984078976 100644
--- a/packages/core/src/sheets/row-manager.ts
+++ b/packages/core/src/sheets/row-manager.ts
@@ -17,8 +17,7 @@
import { getArrayLength, type IObjectArrayPrimitiveType } from '../shared/object-matrix';
import type { Nullable } from '../shared/types';
import { BooleanNumber } from '../types/enum';
-import type { IRange, IRowData, IWorksheetData } from '../types/interfaces';
-import { RANGE_TYPE } from '../types/interfaces';
+import { type IRange, type IRowData, type IWorksheetData, RANGE_TYPE } from './typedef';
import type { SheetViewModel } from './view-model';
/**
diff --git a/packages/core/src/sheets/sheet-snapshot-utils.ts b/packages/core/src/sheets/sheet-snapshot-utils.ts
index 58954c42ce..73c5ae6ee7 100644
--- a/packages/core/src/sheets/sheet-snapshot-utils.ts
+++ b/packages/core/src/sheets/sheet-snapshot-utils.ts
@@ -15,7 +15,7 @@
*/
import { BooleanNumber } from '../types/enum/text-style';
-import type { IWorksheetData } from '../types/interfaces/i-worksheet-data';
+import type { IWorksheetData } from './typedef';
// TODO@wzhudev: default value should not be exposed, but the keys.
@@ -76,7 +76,6 @@ export function mergeWorksheetSnapshotWithDefault(snapshot: Partial<IWorksheetDa
height: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,
hidden: BooleanNumber.FALSE,
},
- selections: ['A1'],
rightToLeft: BooleanNumber.FALSE,
};
diff --git a/packages/core/src/sheets/styles.ts b/packages/core/src/sheets/styles.ts
index 89467ad932..b9b7b8e19b 100644
--- a/packages/core/src/sheets/styles.ts
+++ b/packages/core/src/sheets/styles.ts
@@ -16,7 +16,8 @@
import type { IKeyType, Nullable } from '../shared';
import { LRUMap, Tools } from '../shared';
-import type { ICellDataForSheetInterceptor, IStyleData } from '../types/interfaces';
+import type { IStyleData } from '../types/interfaces';
+import type { ICellDataForSheetInterceptor } from './typedef';
/**
* Styles in a workbook, cells locate styles based on style IDs
diff --git a/packages/core/src/sheets/typedef.ts b/packages/core/src/sheets/typedef.ts
new file mode 100644
index 0000000000..779cd3f6aa
--- /dev/null
+++ b/packages/core/src/sheets/typedef.ts
@@ -0,0 +1,652 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { LocaleType } from '../types/enum/locale-type';
+import type { IStyleData } from '../types/interfaces/i-style-data';
+import type { Resources } from '../types/interfaces/resource';
+import type { IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, Nullable } from '../shared';
+import { type BooleanNumber, CellValueType } from '../types/enum';
+import type { IDocumentData } from '../types/interfaces';
+import type { ICellCustomRender } from '../types/interfaces/i-cell-custom-render';
+import type { ICellValidationData } from '../types/interfaces/i-cell-validation-data';
+
+/**
+ * Snapshot of a workbook.
+ */
+export interface IWorkbookData {
+ /**
+ * Id of the Univer Sheet.
+ */
+ id: string;
+
+ /**
+ * Revision of this spreadsheet. Used in collaborated editing. Starts from one.
+ * @ignore
+ */
+ rev?: number;
+
+ /**
+ * Name of the Univer Sheet.
+ */
+ name: string;
+
+ /**
+ * Version of Univer model definition.
+ */
+ appVersion: string;
+
+ /**
+ * Locale of the document.
+ */
+ locale: LocaleType;
+
+ /**
+ * Style references.
+ */
+ styles: Record<string, Nullable<IStyleData>>;
+
+ /** Ids of {@link IWorksheetData}s of this Univer Sheet in sequence order. */
+ sheetOrder: string[];
+
+ /**
+ * Data of each {@link IWorksheetData} in this Univer Sheet.
+ */
+ sheets: { [sheetId: string]: Partial<IWorksheetData> };
+
+ /**
+ * Resources of the Univer Sheet. It is used to store the data of other plugins.
+ */
+ resources?: Resources;
+}
+
+/**
+ * Snapshot of a worksheet.
+ */
+export interface IWorksheetData {
+ /**
+ * Id of the worksheet. This should be unique and immutable across the lifecycle of the worksheet.
+ */
+ id: string;
+
+ /** Name of the sheet. */
+ name: string;
+
+ tabColor: string;
+
+ /**
+ * Determine whether the sheet is hidden.
+ *
+ * @remarks
+ * See {@link BooleanNumber| the BooleanNumber enum} for more details.
+ *
+ * @defaultValue `BooleanNumber.FALSE`
+ */
+ hidden: BooleanNumber;
+
+ freeze: IFreeze;
+
+ rowCount: number;
+ columnCount: number;
+ /** @deprecated */
+ zoomRatio: number;
+ /** @deprecated */
+ scrollTop: number;
+ /** @deprecated */
+ scrollLeft: number;
+ defaultColumnWidth: number;
+ defaultRowHeight: number;
+
+ /** All merged cells in this worksheet. */
+ mergeData: IRange[];
+
+ /** A matrix storing cell contents by row and column index. */
+ cellData: IObjectMatrixPrimitiveType<ICellData>;
+ rowData: IObjectArrayPrimitiveType<Partial<IRowData>>;
+ columnData: IObjectArrayPrimitiveType<Partial<IColumnData>>;
+
+ rowHeader: {
+ width: number;
+ hidden?: BooleanNumber;
+ };
+
+ columnHeader: {
+ height: number;
+ hidden?: BooleanNumber;
+ };
+
+ showGridlines: BooleanNumber;
+ rightToLeft: BooleanNumber;
+}
+
+/**
+ * Properties of row data
+ */
+export interface IRowData {
+ /**
+ * height in pixel
+ */
+ h?: number;
+
+ /**
+ * is current row self-adaptive to its content, use `ah` to set row height when true, else use `h`.
+ */
+ ia?: BooleanNumber; // pre name `isAutoHeight`
+
+ /**
+ * auto height
+ */
+ ah?: number;
+
+ /**
+ * hidden
+ */
+ hd?: BooleanNumber;
+}
+
+export interface IRowAutoHeightInfo {
+ row: number;
+ autoHeight?: number;
+}
+
+/**
+ * Properties of column data
+ */
+export interface IColumnData {
+ /**
+ * width
+ */
+ w?: number;
+
+ /**
+ * hidden
+ */
+ hd?: BooleanNumber;
+}
+
+/**
+ * Cell value type
+ */
+export type CellValue = string | number | boolean;
+
+/**
+ * Cell data
+ */
+export interface ICellData {
+ /**
+ * The unique key, a random string, is used for the plug-in to associate the cell. When the cell information changes,
+ * the plug-in does not need to change the data, reducing the pressure on the back-end interface id?: string.
+ */
+ p?: Nullable<IDocumentData>; // univer docs, set null for cell clear all
+
+ /** style id */
+ s?: Nullable<IStyleData | string>;
+
+ /**
+ * Origin value
+ */
+ v?: Nullable<CellValue>;
+
+ // Usually the type is automatically determined based on the data, or the user directly specifies
+ t?: Nullable<CellValueType>; // 1 string, 2 number, 3 boolean, 4 force string, green icon, set null for cell clear all
+
+ /**
+ * Raw formula string. For example `=SUM(A1:B4)`.
+ */
+ f?: Nullable<string>;
+
+ /**
+ * Id of the formula.
+ */
+ si?: Nullable<string>;
+
+ /**
+ * User stored custom fields
+ */
+ custom?: Nullable<Record<string, any>>;
+}
+
+export interface ICellMarksStyle {
+ color: string;
+ size: number;
+}
+
+export interface ICellMarks {
+ tl?: ICellMarksStyle;
+ tr?: ICellMarksStyle;
+ bl?: ICellMarksStyle;
+ br?: ICellMarksStyle;
+ isSkip?: boolean;
+}
+
+// TODO@weird94: should be moved outside of the core package
+export interface ICellDataForSheetInterceptor extends ICellData {
+ interceptorStyle?: Nullable<IStyleData>;
+ isInArrayFormulaRange?: Nullable<boolean>;
+ dataValidation?: Nullable<ICellValidationData>;
+ markers?: ICellMarks;
+ customRender?: Nullable<ICellCustomRender[]>;
+ interceptorAutoHeight?: number;
+ /**
+ * can cell be covered when sibling is overflow
+ */
+ coverable?: boolean;
+}
+
+export function isICellData(value: any): value is ICellData {
+ return (
+ value &&
+ ((value as ICellData).s !== undefined ||
+ (value as ICellData).p !== undefined ||
+ (value as ICellData).v !== undefined ||
+ (value as ICellData).t !== undefined ||
+ (value as ICellData).f !== undefined ||
+ (value as ICellData).si !== undefined)
+ );
+}
+
+export function getCellValueType(cell: ICellData) {
+ if (cell.t !== undefined) {
+ return cell.t;
+ }
+ if (typeof cell.v === 'string') {
+ return CellValueType.STRING;
+ }
+ if (typeof cell.v === 'number') {
+ return CellValueType.NUMBER;
+ }
+ if (typeof cell.v === 'boolean') {
+ return CellValueType.BOOLEAN;
+ }
+}
+
+export function isNullCell(cell: Nullable<ICellData>) {
+ if (cell == null) {
+ return true;
+ }
+
+ const { v, f, si, p, s, custom } = cell;
+
+ if (!(v == null || (typeof v === 'string' && v.length === 0))) {
+ return false;
+ }
+
+ if ((f != null && f.length > 0) || (si != null && si.length > 0)) {
+ return false;
+ }
+
+ if (p != null) {
+ return false;
+ }
+
+ if (custom != null) {
+ return false;
+ }
+
+ return true;
+}
+
+export function isCellV(cell: Nullable<ICellData | CellValue>) {
+ return cell != null && (typeof cell === 'string' || typeof cell === 'number' || typeof cell === 'boolean');
+}
+
+export interface IFreeze {
+ xSplit: number;
+ ySplit: number;
+ startRow: number;
+ startColumn: number;
+}
+
+export enum RANGE_TYPE {
+ NORMAL,
+ ROW,
+ COLUMN,
+ ALL,
+}
+
+/**
+ * none: A1
+ * row: A$1
+ * column: $A1
+ * all: $A$1
+ */
+export enum AbsoluteRefType {
+ NONE,
+ ROW,
+ COLUMN,
+ ALL,
+}
+
+interface IRangeLocation {
+ /**
+ * Id of the Workbook the range belongs to.
+ * When this field is not defined, it should be considered as the range in the currently activated worksheet.
+ */
+ unitId?: string;
+
+ /**
+ * Id of the Worksheet the range belongs to.
+ * When this field is not defined, it should be considered as the range in the currently activated worksheet.
+ */
+ sheetId?: string;
+}
+
+export interface IRowRange extends IRangeLocation {
+ /**
+ * The start row (inclusive) of the range
+ * startRow
+ */
+ startRow: number;
+
+ /**
+ * The end row (exclusive) of the range
+ * endRow
+ */
+ endRow: number;
+}
+
+export interface IColumnRange extends IRangeLocation {
+ /**
+ * The start column (inclusive) of the range
+ * startColumn
+ */
+ startColumn: number;
+
+ /**
+ * The end column (exclusive) of the range
+ * endColumn
+ */
+ endColumn: number;
+}
+
+/**
+ * Range data structure
+ *
+ * One of the range types,
+ *
+ * e.g.,
+ * {
+ * startRow:0 ,
+ * startColumn:0,
+ * endRow:1,
+ * endColumn:1,
+ * }
+ *
+ * means "A1:B2"
+ */
+export interface IRange extends IRowRange, IColumnRange {
+ rangeType?: RANGE_TYPE;
+
+ startAbsoluteRefType?: AbsoluteRefType;
+
+ endAbsoluteRefType?: AbsoluteRefType;
+}
+
+/**
+ * Transform an `IRange` object to an array.
+ * @param range
+ * @returns [rowStart, colStart, rowEnd, colEnd]
+ */
+export function selectionToArray(range: IRange): [number, number, number, number] {
+ return [range.startRow, range.startColumn, range.endRow, range.endColumn];
+}
+
+/**
+ * Range data of grid
+ */
+export interface IGridRange {
+ sheetId: string;
+ range: IRange;
+}
+
+export interface IUnitRangeName {
+ unitId: string;
+ sheetName: string;
+ range: IRange;
+}
+
+/**
+ * Range data of Unit
+ */
+export interface IUnitRange extends IGridRange {
+ unitId: string;
+}
+
+export interface IUnitRangeWithName extends IUnitRange {
+ sheetName: string;
+}
+
+/**
+ * One of the range types,
+ *
+ * e.g.,"A1:B2","sheet1!A1:B2","A1","1:1","A:A","AA1:BB2"
+ */
+export type IRangeStringData = string;
+
+/**
+ * Row data type
+ */
+export type IRowStartEndData = [startRow: number, endRow: number] | number[];
+
+/**
+ * Column data type
+ */
+export type IColumnStartEndData = [startColumn: number, endColumn: number] | number[];
+
+/**
+ * One of the range types,
+ *
+ * e.g.,
+ * {
+ * row:[0,1],
+ * column:[0,1]
+ * }
+ *todo
+
+ true false 枚举
+ * means "A1:B2"
+ */
+export interface IRangeArrayData {
+ /**
+ * row
+ */
+ row: IRowStartEndData;
+ /**
+ * column
+ */
+ column: IColumnStartEndData;
+}
+
+/**
+ * The row and column numbers represent a cell
+ */
+export interface IRangeCellData {
+ /**
+ * row
+ */
+ row: number;
+ /**
+ * column
+ */
+ column: number;
+}
+
+/**
+ * range types
+ *
+ * Allow users to provide one of three formats, we need to convert to IRange to store
+ */
+export type IRangeType = IRange | IRangeStringData | IRangeArrayData | IRangeCellData;
+
+/**
+ * Whether to clear only the contents. Whether to clear only the format; note that clearing format also clears data validation rules.
+ */
+export interface IOptionData {
+ /**
+ * 1. designates that only the format should be copied
+ *
+ * 2. Whether to clear only the format; note that clearing format also clears data validation rules.
+ *
+ * 3. worksheet Whether to clear the format.
+ */
+ formatOnly?: boolean;
+ /**
+ * 1. designates that only the content should be copied
+ *
+ * 2. Whether to clear only the contents.
+ *
+ * 3. worksheet Whether to clear the content.
+ *
+ */
+ contentsOnly?: boolean;
+}
+
+/**
+ * Option of copyTo function
+ */
+export interface ICopyToOptionsData extends IOptionData {}
+
+export interface IRectLTRB {
+ left: number;
+ top: number;
+ right: number;
+ bottom: number;
+ width?: number;
+ height?: number;
+}
+
+/**
+ * Properties of selection data
+ */
+export interface IPosition {
+ startX: number;
+ startY: number;
+ endX: number;
+ endY: number;
+}
+
+export interface ISingleCell {
+ actualRow: number;
+ actualColumn: number;
+ isMerged: boolean;
+ isMergedMainCell: boolean;
+}
+
+export interface IRangeWithCoord extends IPosition, IRange {}
+
+export interface ISelectionCell extends IRange, ISingleCell {}
+
+export interface ISelectionCellWithMergeInfo extends IPosition, ISingleCell {
+ mergeInfo: IRangeWithCoord; // merge cell, start and end is upper left cell
+}
+
+export interface ISelection {
+ /**
+ * Sheet selection range.
+ */
+ range: IRange;
+
+ /**
+ * The highlighted cell in the selection range. If there are several selections, only one selection would have a primary cell.
+ */
+ primary: Nullable<ISelectionCell>;
+}
+
+/**
+ * Selection range Info, contains selectionrange & primaryrange
+ * primaryrange is the range of the highlighted cell.
+ */
+export interface ISelectionWithCoord {
+ rangeWithCoord: IRangeWithCoord;
+ primaryWithCoord: Nullable<ISelectionCellWithMergeInfo>;
+}
+
+export interface ITextRangeStart {
+ startOffset: number;
+}
+
+export interface ITextRange extends ITextRangeStart {
+ endOffset: number;
+ collapsed: boolean;
+}
+
+export interface ITextRangeParam extends ITextRange {
+ segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
+ segmentPage?: number; //The page number of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
+ isActive?: boolean; // Whether the text range is active or current range.
+}
+
+/**
+ * Determines whether the cell(row, column) is within the range of the merged cells.
+ */
+export function getCellInfoInMergeData(row: number, column: number, mergeData?: IRange[]): ISelectionCell {
+ let isMerged = false; // The upper left cell only renders the content
+ let isMergedMainCell = false;
+ let newEndRow = row;
+ let newEndColumn = column;
+ let mergeRow = row;
+ let mergeColumn = column;
+
+ if (mergeData == null) {
+ return {
+ actualRow: row,
+ actualColumn: column,
+ isMergedMainCell,
+ isMerged,
+ endRow: newEndRow,
+ endColumn: newEndColumn,
+ startRow: mergeRow,
+ startColumn: mergeColumn,
+ };
+ }
+
+ for (let i = 0; i < mergeData.length; i++) {
+ const {
+ startRow: startRowMarge,
+ endRow: endRowMarge,
+ startColumn: startColumnMarge,
+ endColumn: endColumnMarge,
+ } = mergeData[i];
+ if (row === startRowMarge && column === startColumnMarge) {
+ newEndRow = endRowMarge;
+ newEndColumn = endColumnMarge;
+ mergeRow = startRowMarge;
+ mergeColumn = startColumnMarge;
+
+ isMergedMainCell = true;
+ break;
+ }
+ if (row >= startRowMarge && row <= endRowMarge && column >= startColumnMarge && column <= endColumnMarge) {
+ newEndRow = endRowMarge;
+ newEndColumn = endColumnMarge;
+ mergeRow = startRowMarge;
+ mergeColumn = startColumnMarge;
+
+ isMerged = true;
+ break;
+ }
+ }
+
+ return {
+ actualRow: row,
+ actualColumn: column,
+ isMergedMainCell,
+ isMerged,
+ endRow: newEndRow,
+ endColumn: newEndColumn,
+ startRow: mergeRow,
+ startColumn: mergeColumn,
+ };
+}
diff --git a/packages/core/src/sheets/util.ts b/packages/core/src/sheets/util.ts
new file mode 100644
index 0000000000..6edb4be68f
--- /dev/null
+++ b/packages/core/src/sheets/util.ts
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Rectangle } from '../shared';
+import type { IRange, IUnitRange } from './typedef';
+
+export const isRangesEqual = (oldRanges: IRange[], ranges: IRange[]): boolean => {
+ return ranges.length === oldRanges.length && !oldRanges.some((oldRange) => ranges.some((range) => !Rectangle.equals(range, oldRange)));
+};
+
+export const isUnitRangesEqual = (oldRanges: IUnitRange[], ranges: IUnitRange[]): boolean => {
+ return ranges.length === oldRanges.length && oldRanges.every((oldRange, i) => {
+ const current = ranges[i];
+ return current.unitId === oldRange.unitId && current.sheetId === oldRange.sheetId && Rectangle.equals(oldRange.range, current.range);
+ });
+};
+
diff --git a/packages/core/src/sheets/view-model.ts b/packages/core/src/sheets/view-model.ts
index 143f2ddd8a..93cf5c571c 100644
--- a/packages/core/src/sheets/view-model.ts
+++ b/packages/core/src/sheets/view-model.ts
@@ -16,9 +16,9 @@
import type { IDisposable } from '../common/di';
-import type { Nullable } from '../common/type-util';
import { Disposable, toDisposable } from '../shared/lifecycle';
-import type { ICellData, ICellDataForSheetInterceptor } from '../types/interfaces/i-cell-data';
+import type { Nullable } from '../shared/types';
+import type { ICellData, ICellDataForSheetInterceptor } from './typedef';
/**
* @internal
diff --git a/packages/core/src/sheets/workbook.ts b/packages/core/src/sheets/workbook.ts
index 3c2f46cc21..e29d5b3035 100644
--- a/packages/core/src/sheets/workbook.ts
+++ b/packages/core/src/sheets/workbook.ts
@@ -21,15 +21,11 @@ import { ILogService } from '../services/log/log.service';
import type { Nullable } from '../shared';
import { Tools } from '../shared';
import { BooleanNumber } from '../types/enum';
-import type {
- IRangeType,
- IWorkbookData,
- IWorksheetData,
-} from '../types/interfaces';
import { UnitModel, UniverInstanceType } from '../common/unit';
import { Styles } from './styles';
import { Worksheet } from './worksheet';
import { getEmptySnapshot } from './empty-snapshot';
+import type { IRangeType, IWorkbookData, IWorksheetData } from './typedef';
export function getWorksheetUID(workbook: Workbook, worksheet: Worksheet): string {
return `${workbook.getUnitId()}|${worksheet.getSheetId()}`;
@@ -164,15 +160,6 @@ export class Workbook extends UnitModel<IWorkbookData, UniverInstanceType.UNIVER
this._snapshot.rev = this.getRev() + 1;
}
- getShouldRenderLoopImmediately() {
- const should = this._snapshot.shouldStartRenderingImmediately;
- return should !== false;
- }
-
- getContainer() {
- return this._snapshot.container;
- }
-
/**
* Add a Worksheet into Workbook.
*/
diff --git a/packages/core/src/sheets/worksheet.ts b/packages/core/src/sheets/worksheet.ts
index 0ffd23dc59..916a54b11f 100644
--- a/packages/core/src/sheets/worksheet.ts
+++ b/packages/core/src/sheets/worksheet.ts
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-import type { Nullable } from '../shared';
+import type { IObjectMatrixPrimitiveType, Nullable } from '../shared';
import { ObjectMatrix, Rectangle, Tools } from '../shared';
import { createRowColIter } from '../shared/row-col-iter';
import { type BooleanNumber, CellValueType } from '../types/enum';
-import type { ICellData, ICellDataForSheetInterceptor, IFreeze, IRange, IWorksheetData } from '../types/interfaces';
import { ColumnManager } from './column-manager';
import { Range } from './range';
import { RowManager } from './row-manager';
import { mergeWorksheetSnapshotWithDefault } from './sheet-snapshot-utils';
import type { Styles } from './styles';
+import type { ICellData, ICellDataForSheetInterceptor, IFreeze, IRange, IWorksheetData } from './typedef';
import { SheetViewModel } from './view-model';
/**
@@ -48,7 +48,7 @@ export class Worksheet {
const { columnData, rowData, cellData } = this._snapshot;
this._sheetId = this._snapshot.id ?? Tools.generateRandomId(6);
- this._cellData = new ObjectMatrix<ICellData>(cellData);
+ this._cellData = new ObjectMatrix<ICellData>(cellData as IObjectMatrixPrimitiveType<ICellData>);
// This view model will immediately injected with hooks from SheetViewModel service as Worksheet is constructed.
this._viewModel = new SheetViewModel((row, col) => this.getCellRaw(row, col));
@@ -60,7 +60,7 @@ export class Worksheet {
* @internal
* @param callback
*/
- __interceptViewModel(callback: (viewModel: SheetViewModel) => void) {
+ __interceptViewModel(callback: (viewModel: SheetViewModel) => void): void {
callback(this._viewModel);
}
diff --git a/packages/core/src/slides/slide-model.ts b/packages/core/src/slides/slide-model.ts
index a26f5f4944..48e6f9e666 100644
--- a/packages/core/src/slides/slide-model.ts
+++ b/packages/core/src/slides/slide-model.ts
@@ -65,10 +65,6 @@ export class SlideDataModel extends UnitModel<ISlideData, UniverInstanceType.UNI
this._unitId = this._snapshot.id ?? generateRandomId(6);
}
- getContainer() {
- return this._snapshot.container;
- }
-
getSnapshot() {
return this._snapshot;
}
diff --git a/packages/core/src/types/enum/locale-type.ts b/packages/core/src/types/enum/locale-type.ts
index 507680ca5a..7a93496c91 100644
--- a/packages/core/src/types/enum/locale-type.ts
+++ b/packages/core/src/types/enum/locale-type.ts
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+/**
+ * Built-in locales.
+ */
export enum LocaleType {
EN_US = 'enUS',
ZH_CN = 'zhCN',
@@ -21,5 +24,3 @@ export enum LocaleType {
ZH_TW = 'zhTW',
VI_VN = 'viVN',
}
-
-export type LocaleTypes = `${LocaleType}`;
diff --git a/packages/core/src/types/enum/text-style.ts b/packages/core/src/types/enum/text-style.ts
index 4aff53bf2b..6e5967aa8b 100644
--- a/packages/core/src/types/enum/text-style.ts
+++ b/packages/core/src/types/enum/text-style.ts
@@ -124,7 +124,8 @@ export enum BaselineOffset {
/**
* General Boolean Enum
*/
-export enum BooleanNumber {
+// eslint-disable-next-line no-restricted-syntax
+export const enum BooleanNumber {
FALSE = 0,
TRUE = 1,
}
diff --git a/packages/core/src/types/interfaces/i-cell-custom-render.ts b/packages/core/src/types/interfaces/i-cell-custom-render.ts
index d1ad32e9c8..66252c0fe3 100644
--- a/packages/core/src/types/interfaces/i-cell-custom-render.ts
+++ b/packages/core/src/types/interfaces/i-cell-custom-render.ts
@@ -19,9 +19,8 @@
import type { Nullable } from '../../shared';
import type { Worksheet } from '../../sheets/worksheet';
import type { Workbook } from '../../sheets/workbook';
-import type { ISelectionCellWithMergeInfo } from './i-selection-data';
+import type { ICellDataForSheetInterceptor, ISelectionCellWithMergeInfo } from '../../sheets/typedef';
import type { IStyleData } from './i-style-data';
-import type { ICellDataForSheetInterceptor } from './i-cell-data';
export interface ICellRenderContext {
data: ICellDataForSheetInterceptor;
@@ -37,6 +36,7 @@ export interface ICellRenderContext {
/**
* @debt This shouldn't exist in core package.
+ * @ignore
*
* @deprecated This interface is subject to change in the future.
*/
diff --git a/packages/core/src/types/interfaces/i-cell-data.ts b/packages/core/src/types/interfaces/i-cell-data.ts
deleted file mode 100644
index f03f870f86..0000000000
--- a/packages/core/src/types/interfaces/i-cell-data.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { Nullable } from '../../shared/types';
-import { CellValueType } from '../enum/text-style';
-import type { ICellCustomRender } from './i-cell-custom-render';
-import type { IDocumentData } from './i-document-data';
-import type { IStyleData } from './i-style-data';
-import type { ICellValidationData } from './i-cell-validation-data';
-
-/**
- * Cell value type
- */
-export type CellValue = string | number | boolean;
-
-/**
- * Cell data
- */
-export interface ICellData {
- /**
- * The unique key, a random string, is used for the plug-in to associate the cell. When the cell information changes,
- * the plug-in does not need to change the data, reducing the pressure on the back-end interface id?: string.
- */
- p?: Nullable<IDocumentData>; // univer docs, set null for cell clear all
-
- /** style id */
- s?: Nullable<IStyleData | string>;
-
- /**
- * Origin value
- */
- v?: Nullable<CellValue>;
-
- // Usually the type is automatically determined based on the data, or the user directly specifies
- t?: Nullable<CellValueType>; // 1 string, 2 number, 3 boolean, 4 force string, green icon, set null for cell clear all
-
- /**
- * Raw formula string. For example `=SUM(A1:B4)`.
- */
- f?: Nullable<string>;
-
- /**
- * Id of the formula.
- */
- si?: Nullable<string>;
-
- /**
- * User stored custom fields
- */
- custom?: Nullable<Record<string, any>>;
-}
-
-export interface ICellMarksStyle {
- color: string;
- size: number;
-}
-
-export interface ICellMarks {
- tl?: ICellMarksStyle;
- tr?: ICellMarksStyle;
- bl?: ICellMarksStyle;
- br?: ICellMarksStyle;
- isSkip?: boolean;
-}
-
-export interface ICellDataForSheetInterceptor extends ICellData {
- interceptorStyle?: Nullable<IStyleData>;
- isInArrayFormulaRange?: Nullable<boolean>;
- dataValidation?: Nullable<ICellValidationData>;
- markers?: ICellMarks;
- customRender?: Nullable<ICellCustomRender[]>;
- interceptorAutoHeight?: number;
- /**
- * can cell be covered when sibling is overflow
- */
- coverable?: boolean;
-}
-
-export function isICellData(value: any): value is ICellData {
- return (
- value &&
- ((value as ICellData).s !== undefined ||
- (value as ICellData).p !== undefined ||
- (value as ICellData).v !== undefined ||
- (value as ICellData).t !== undefined ||
- (value as ICellData).f !== undefined ||
- (value as ICellData).si !== undefined)
- );
-}
-
-export function getCellValueType(cell: ICellData) {
- if (cell.t !== undefined) {
- return cell.t;
- }
- if (typeof cell.v === 'string') {
- return CellValueType.STRING;
- }
- if (typeof cell.v === 'number') {
- return CellValueType.NUMBER;
- }
- if (typeof cell.v === 'boolean') {
- return CellValueType.BOOLEAN;
- }
-}
-
-export function isNullCell(cell: Nullable<ICellData>) {
- if (cell == null) {
- return true;
- }
-
- const { v, f, si, p, s, custom } = cell;
-
- if (!(v == null || (typeof v === 'string' && v.length === 0))) {
- return false;
- }
-
- if ((f != null && f.length > 0) || (si != null && si.length > 0)) {
- return false;
- }
-
- if (p != null) {
- return false;
- }
-
- if (custom != null) {
- return false;
- }
-
- return true;
-}
-
-export function isCellV(cell: Nullable<ICellData | CellValue>) {
- return cell != null && (typeof cell === 'string' || typeof cell === 'number' || typeof cell === 'boolean');
-}
diff --git a/packages/core/src/types/interfaces/i-column-data.ts b/packages/core/src/types/interfaces/i-column-data.ts
deleted file mode 100644
index c69d498746..0000000000
--- a/packages/core/src/types/interfaces/i-column-data.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { BooleanNumber } from '../enum';
-
-/**
- * Properties of column data
- */
-export interface IColumnData {
- /**
- * width
- */
- w?: number;
- /**
- * hidden
- */
- hd?: BooleanNumber;
-}
diff --git a/packages/core/src/types/interfaces/i-data-validation.ts b/packages/core/src/types/interfaces/i-data-validation.ts
index 6d913e5068..8f3d9b04cf 100644
--- a/packages/core/src/types/interfaces/i-data-validation.ts
+++ b/packages/core/src/types/interfaces/i-data-validation.ts
@@ -19,7 +19,9 @@ import type { DataValidationType } from '../enum/data-validation-type';
import type { DataValidationImeMode } from '../enum/data-validation-ime-mode';
import type { DataValidationErrorStyle } from '../enum/data-validation-error-style';
import type { DataValidationRenderMode } from '../enum/data-validation-render-mode';
-import type { IRange } from './i-range';
+import type { IRange } from '../../sheets/typedef';
+
+// TODO@weird94: should be moved outside of the or package
export interface IDataValidationRuleBase {
type: DataValidationType;
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.ts
index 9bc6cffc2b..7bb457b876 100644
--- a/packages/core/src/types/interfaces/i-document-data.ts
+++ b/packages/core/src/types/interfaces/i-document-data.ts
@@ -14,17 +14,16 @@
* limitations under the License.
*/
-import type { Nullable } from '../../common/type-util';
import type { IAbsoluteTransform, ISize } from '../../shared/shape';
+import type { Nullable } from '../../shared/types';
import type { BooleanNumber, CellValueType, HorizontalAlign, LocaleType, TextDirection, VerticalAlign, WrapStrategy } from '../enum';
-import type { IExtraModelData } from './i-extra-model-data';
import type { IColorStyle, IStyleBase } from './i-style-data';
// Attention: all dimensional units, unless otherwise stated, refer to pt,1 pt = 1 / 72 in
/**
* Properties of document
*/
-export interface IDocumentData extends IReferenceSource, IExtraModelData {
+export interface IDocumentData extends IReferenceSource {
/** unit ID */
id: string;
/** Revision of this document. Would be used in collaborated editing. Starts with zero. */
diff --git a/packages/core/src/types/interfaces/i-extra-model-data.ts b/packages/core/src/types/interfaces/i-extra-model-data.ts
deleted file mode 100644
index b4d502c0bd..0000000000
--- a/packages/core/src/types/interfaces/i-extra-model-data.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface IExtraModelData {
- /**
- * should start renderLoop Immediately
- * default is true
- */
- shouldStartRenderingImmediately?: boolean;
-
- // Union field properties can be only one of the following:
- /**
- * HTML selector
- * default is null
- */
- container?: string;
-}
diff --git a/packages/core/src/types/interfaces/i-freeze.ts b/packages/core/src/types/interfaces/i-freeze.ts
deleted file mode 100644
index a838251477..0000000000
--- a/packages/core/src/types/interfaces/i-freeze.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface IFreeze {
- xSplit: number;
- ySplit: number;
- startRow: number;
- startColumn: number;
-}
diff --git a/packages/core/src/types/interfaces/i-range.ts b/packages/core/src/types/interfaces/i-range.ts
deleted file mode 100644
index 9c136fa803..0000000000
--- a/packages/core/src/types/interfaces/i-range.ts
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export enum RANGE_TYPE {
- NORMAL,
- ROW,
- COLUMN,
- ALL,
-}
-
-/**
- * none: A1
- * row: A$1
- * column: $A1
- * all: $A$1
- */
-export enum AbsoluteRefType {
- NONE,
- ROW,
- COLUMN,
- ALL,
-}
-
-interface IRangeLocation {
- /**
- * Id of the Workbook the range belongs to.
- * When this field is not defined, it should be considered as the range in the currently activated worksheet.
- */
- unitId?: string;
-
- /**
- * Id of the Worksheet the range belongs to.
- * When this field is not defined, it should be considered as the range in the currently activated worksheet.
- */
- sheetId?: string;
-}
-
-export interface IRowRange extends IRangeLocation {
- /**
- * The start row (inclusive) of the range
- * startRow
- */
- startRow: number;
-
- /**
- * The end row (exclusive) of the range
- * endRow
- */
- endRow: number;
-}
-
-export interface IColumnRange extends IRangeLocation {
- /**
- * The start column (inclusive) of the range
- * startColumn
- */
- startColumn: number;
-
- /**
- * The end column (exclusive) of the range
- * endColumn
- */
- endColumn: number;
-}
-
-/**
- * Range data structure
- *
- * One of the range types,
- *
- * e.g.,
- * {
- * startRow:0 ,
- * startColumn:0,
- * endRow:1,
- * endColumn:1,
- * }
- *
- * means "A1:B2"
- */
-export interface IRange extends IRowRange, IColumnRange {
- rangeType?: RANGE_TYPE;
-
- startAbsoluteRefType?: AbsoluteRefType;
-
- endAbsoluteRefType?: AbsoluteRefType;
-}
-
-/**
- * Transform an `IRange` object to an array.
- * @param range
- * @returns [rowStart, colStart, rowEnd, colEnd]
- */
-export function selectionToArray(range: IRange): [number, number, number, number] {
- return [range.startRow, range.startColumn, range.endRow, range.endColumn];
-}
-
-/**
- * Range data of grid
- */
-export interface IGridRange {
- sheetId: string;
- range: IRange;
-}
-
-export interface IUnitRangeName {
- unitId: string;
- sheetName: string;
- range: IRange;
-}
-
-/**
- * Range data of Unit
- */
-export interface IUnitRange extends IGridRange {
- unitId: string;
-}
-
-export interface IUnitRangeWithName extends IUnitRange {
- sheetName: string;
-}
-
-/**
- * One of the range types,
- *
- * e.g.,"A1:B2","sheet1!A1:B2","A1","1:1","A:A","AA1:BB2"
- */
-export type IRangeStringData = string;
-
-/**
- * Row data type
- */
-export type IRowStartEndData = [startRow: number, endRow: number] | number[];
-
-/**
- * Column data type
- */
-export type IColumnStartEndData = [startColumn: number, endColumn: number] | number[];
-
-/**
- * One of the range types,
- *
- * e.g.,
- * {
- * row:[0,1],
- * column:[0,1]
- * }
- *todo
-
- true false 枚举
- * means "A1:B2"
- */
-export interface IRangeArrayData {
- /**
- * row
- */
- row: IRowStartEndData;
- /**
- * column
- */
- column: IColumnStartEndData;
-}
-
-/**
- * The row and column numbers represent a cell
- */
-export interface IRangeCellData {
- /**
- * row
- */
- row: number;
- /**
- * column
- */
- column: number;
-}
-
-/**
- * range types
- *
- * Allow users to provide one of three formats, we need to convert to IRange to store
- */
-export type IRangeType = IRange | IRangeStringData | IRangeArrayData | IRangeCellData;
-
-// export interface IInfoObjData extends IRangeArrayData {
-// sheetId?: Nullable<string>;
-// }
-
-// export function isIRangeType(range: IRangeType | IRangeType[]) {
-// return typeof range === 'string' || 'startRow' in range || 'row' in range;
-// }
-// export function isIRangeData(range: IRangeType | IRangeType[]) {
-// return typeof range !== 'string' && 'startRow' in range;
-// }
-// export function isIRangeStringData(range: IRangeType | IRangeType[]) {
-// return typeof range === 'string';
-// }
-// export function isIRangeArrayData(range: IRangeType | IRangeType[]) {
-// return typeof range !== 'string' && 'row' in range;
-// }
-
-/**
- * Whether to clear only the contents. Whether to clear only the format; note that clearing format also clears data validation rules.
- */
-export interface IOptionData {
- /**
- * 1. designates that only the format should be copied
- *
- * 2. Whether to clear only the format; note that clearing format also clears data validation rules.
- *
- * 3. worksheet Whether to clear the format.
- */
- formatOnly?: boolean;
- /**
- * 1. designates that only the content should be copied
- *
- * 2. Whether to clear only the contents.
- *
- * 3. worksheet Whether to clear the content.
- *
- */
- contentsOnly?: boolean;
-}
-
-/**
- * Option of copyTo function
- */
-export interface ICopyToOptionsData extends IOptionData {}
-
-export interface IRectLTRB {
- left: number;
- top: number;
- right: number;
- bottom: number;
- width?: number;
- height?: number;
-}
diff --git a/packages/core/src/types/interfaces/i-row-data.ts b/packages/core/src/types/interfaces/i-row-data.ts
deleted file mode 100644
index d146b693d2..0000000000
--- a/packages/core/src/types/interfaces/i-row-data.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { BooleanNumber } from '../enum';
-
-/**
- * Properties of row data
- */
-export interface IRowData {
- /**
- * height in pixel
- */
- h?: number;
-
- /**
- * is current row self-adaptive to its content, use `ah` to set row height when true, else use `h`.
- */
- ia?: BooleanNumber; // pre name `isAutoHeight`
-
- /**
- * auto height
- */
- ah?: number;
-
- /**
- * hidden
- */
- hd?: BooleanNumber;
-}
-
-export interface IRowAutoHeightInfo {
- row: number;
- autoHeight?: number;
-}
-
diff --git a/packages/core/src/types/interfaces/i-selection-data.ts b/packages/core/src/types/interfaces/i-selection-data.ts
deleted file mode 100644
index 8909b487de..0000000000
--- a/packages/core/src/types/interfaces/i-selection-data.ts
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { Nullable } from '../../shared/types';
-import type { IRange } from './i-range';
-
-/**
- * Properties of selection data
- */
-export interface IPosition {
- startX: number;
- startY: number;
- endX: number;
- endY: number;
-}
-
-export interface ISingleCell {
- actualRow: number;
- actualColumn: number;
- isMerged: boolean;
- isMergedMainCell: boolean;
-}
-
-export interface IRangeWithCoord extends IPosition, IRange {}
-
-export interface ISelectionCell extends IRange, ISingleCell {}
-
-export interface ISelectionCellWithMergeInfo extends IPosition, ISingleCell {
- mergeInfo: IRangeWithCoord; // merge cell, start and end is upper left cell
-}
-
-export interface ISelection {
- /**
- * Sheet selection range.
- */
- range: IRange;
-
- /**
- * The highlighted cell in the selection range. If there are several selections, only one selection would have a primary cell.
- */
- primary: Nullable<ISelectionCell>;
-}
-
-/**
- * Selection range Info, contains selectionrange & primaryrange
- * primaryrange is the range of the highlighted cell.
- */
-export interface ISelectionWithCoord {
- rangeWithCoord: IRangeWithCoord;
- primaryWithCoord: Nullable<ISelectionCellWithMergeInfo>;
-}
-
-export interface ITextRangeStart {
- startOffset: number;
-}
-
-export interface ITextRange extends ITextRangeStart {
- endOffset: number;
- collapsed: boolean;
-}
-
-export interface ITextRangeParam extends ITextRange {
- segmentId?: string; //The ID of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
- segmentPage?: number; //The page number of the header, footer or footnote the location is in. An empty segment ID signifies the document's body.
- isActive?: boolean; // Whether the text range is active or current range.
-}
-
-/**
- * Determines whether the cell(row, column) is within the range of the merged cells.
- */
-export function getCellInfoInMergeData(row: number, column: number, mergeData?: IRange[]): ISelectionCell {
- let isMerged = false; // The upper left cell only renders the content
- let isMergedMainCell = false;
- let newEndRow = row;
- let newEndColumn = column;
- let mergeRow = row;
- let mergeColumn = column;
-
- if (mergeData == null) {
- return {
- actualRow: row,
- actualColumn: column,
- isMergedMainCell,
- isMerged,
- endRow: newEndRow,
- endColumn: newEndColumn,
- startRow: mergeRow,
- startColumn: mergeColumn,
- };
- }
-
- for (let i = 0; i < mergeData.length; i++) {
- const {
- startRow: startRowMarge,
- endRow: endRowMarge,
- startColumn: startColumnMarge,
- endColumn: endColumnMarge,
- } = mergeData[i];
- if (row === startRowMarge && column === startColumnMarge) {
- newEndRow = endRowMarge;
- newEndColumn = endColumnMarge;
- mergeRow = startRowMarge;
- mergeColumn = startColumnMarge;
-
- isMergedMainCell = true;
- break;
- }
- if (row >= startRowMarge && row <= endRowMarge && column >= startColumnMarge && column <= endColumnMarge) {
- newEndRow = endRowMarge;
- newEndColumn = endColumnMarge;
- mergeRow = startRowMarge;
- mergeColumn = startColumnMarge;
-
- isMerged = true;
- break;
- }
- }
-
- return {
- actualRow: row,
- actualColumn: column,
- isMergedMainCell,
- isMerged,
- endRow: newEndRow,
- endColumn: newEndColumn,
- startRow: mergeRow,
- startColumn: mergeColumn,
- };
-}
diff --git a/packages/core/src/types/interfaces/i-service-data.ts b/packages/core/src/types/interfaces/i-service-data.ts
deleted file mode 100644
index a4efa36b89..0000000000
--- a/packages/core/src/types/interfaces/i-service-data.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface IServiceData {}
diff --git a/packages/core/src/types/interfaces/i-shape-properties.ts b/packages/core/src/types/interfaces/i-shape-properties.ts
index af377a1291..416dfa1735 100644
--- a/packages/core/src/types/interfaces/i-shape-properties.ts
+++ b/packages/core/src/types/interfaces/i-shape-properties.ts
@@ -24,10 +24,6 @@ export interface IShapeProperties {
shapeBackgroundFill: IColorStyle;
radius?: number;
outline?: IOutline;
- // shadow: IShadow;
- // link: ILink;
- // contentAlignment: ContentAlignment;
- // autoFit: IAutoFit;
}
export interface IOutline {
diff --git a/packages/core/src/types/interfaces/i-slide-data.ts b/packages/core/src/types/interfaces/i-slide-data.ts
index 779ec9468c..f32e69291a 100644
--- a/packages/core/src/types/interfaces/i-slide-data.ts
+++ b/packages/core/src/types/interfaces/i-slide-data.ts
@@ -16,17 +16,16 @@
import type { ISize } from '../../shared/shape';
import type { IKeyType, Nullable } from '../../shared/types';
+import type { IWorksheetData } from '../../sheets/typedef';
import type { LocaleType, ThemeColorType } from '../enum';
import type { ShapeType } from '../enum/prst-geom-type';
import type { ICustomBlock, IDocumentData, ILists, ITransformState } from './i-document-data';
-import type { IExtraModelData } from './i-extra-model-data';
import type { IImageProperties } from './i-image-properties';
import type { IPlaceholder } from './i-placeholder';
import type { IShapeProperties } from './i-shape-properties';
import type { IColorStyle, IStyleBase, IStyleData } from './i-style-data';
-import type { IWorksheetData } from './i-worksheet-data';
-export interface ISlideData extends IReferenceSource, IExtraModelData {
+export interface ISlideData extends IReferenceSource {
id: string; // unit id
locale?: LocaleType;
title: string;
@@ -117,11 +116,15 @@ export interface IPageElement {
shape?: IShape;
image?: IImage;
richText?: IRichTextProps;
+
+ /** @deprecated */
spreadsheet?: {
worksheet: IWorksheetData;
styles: IKeyType<Nullable<IStyleData>>;
};
+ /** @deprecated */
document?: IDocumentData;
+ /** @deprecated */
slide?: ISlideData;
// video: IVideo;
// line: ILine;
diff --git a/packages/core/src/types/interfaces/i-univer-data.ts b/packages/core/src/types/interfaces/i-univer-data.ts
deleted file mode 100644
index 11aa48b46d..0000000000
--- a/packages/core/src/types/interfaces/i-univer-data.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { LogLevel } from '../../services/log/log.service';
-import type { DependencyOverride } from '../../services/plugin/plugin-override';
-import type { IStyleSheet } from '../../services/theme/theme.service';
-import type { ILocales } from '../../shared/locale';
-import type { LocaleType } from '../enum';
-
-export interface IUniverData {
- theme: IStyleSheet;
- locale: LocaleType;
- locales: ILocales;
- logLevel: LogLevel;
- id: string;
-
- override?: DependencyOverride;
-}
diff --git a/packages/core/src/types/interfaces/i-workbook-data.ts b/packages/core/src/types/interfaces/i-workbook-data.ts
deleted file mode 100644
index dc2421ab08..0000000000
--- a/packages/core/src/types/interfaces/i-workbook-data.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { IKeyType, Nullable } from '../../shared/types';
-import type { LocaleType } from '../enum';
-import type { IExtraModelData } from './i-extra-model-data';
-import type { IStyleData } from './i-style-data';
-import type { IWorksheetData } from './i-worksheet-data';
-
-export type Resources = Array<{ id?: string; name: string; data: string }>;
-
-/**
- * Properties of a workbook's configuration
- */
-export interface IWorkbookData extends IExtraModelData {
- /**
- * unit id
- */
- id: string;
-
- /**
- * Revision of this spreadsheet. Would be used in collaborated editing. Starts from one.
- */
- rev?: number;
-
- /**
- * Name of the spreadsheet.
- */
- name: string;
-
- /**
- * Version of Univer model definition.
- */
- appVersion: string;
-
- locale: LocaleType;
-
- /** Style reference. */
- styles: IKeyType<Nullable<IStyleData>>;
-
- sheetOrder: string[]; // sheet id order list ['xxxx-sheet3', 'xxxx-sheet1','xxxx-sheet2']
- sheets: { [sheetId: string]: Partial<IWorksheetData> };
-
- // The type of data depends on how the plug-in is defined
- resources?: Resources;
-}
diff --git a/packages/core/src/types/interfaces/i-worksheet-data.ts b/packages/core/src/types/interfaces/i-worksheet-data.ts
deleted file mode 100644
index 08f753251c..0000000000
--- a/packages/core/src/types/interfaces/i-worksheet-data.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType } from '../../shared/object-matrix';
-import type { BooleanNumber } from '../enum';
-import type { ICellData } from './i-cell-data';
-import type { IColumnData } from './i-column-data';
-import type { IFreeze } from './i-freeze';
-import type { IRange, IRangeType } from './i-range';
-import type { IRowData } from './i-row-data';
-
-// TODO: 考虑将非通用配置,抽离到插件
-// 比如 showGridlines 是 spreadsheet 特有的,而如果实现如普通表格,就不需要 showGridlines
-
-/**
- * Snapshot of a worksheet.
- */
-export interface IWorksheetData {
- /**
- * Id of the worksheet. This should be unique and immutable across the lifecycle of the worksheet.
- */
- id: string;
-
- /** Name of the sheet. */
- name: string;
-
- tabColor: string;
-
- /**
- * Determine whether the sheet is hidden.
- *
- * @remarks
- * See {@link BooleanNumber| the BooleanNumber enum} for more details.
- *
- * @defaultValue `BooleanNumber.FALSE`
- */
- hidden: BooleanNumber;
-
- freeze: IFreeze;
-
- rowCount: number;
- columnCount: number;
- zoomRatio: number;
- scrollTop: number;
- scrollLeft: number;
- defaultColumnWidth: number;
- defaultRowHeight: number;
-
- /** All merged cells in this worksheet. */
- mergeData: IRange[];
-
- /** A matrix storing cell contents by row and column index. */
- cellData: IObjectMatrixPrimitiveType<ICellData>;
- rowData: IObjectArrayPrimitiveType<Partial<IRowData>>;
- columnData: IObjectArrayPrimitiveType<Partial<IColumnData>>;
-
- rowHeader: {
- width: number;
- hidden?: BooleanNumber;
- };
-
- columnHeader: {
- height: number;
- hidden?: BooleanNumber;
- };
-
- showGridlines: BooleanNumber;
-
- /** @deprecated */
- selections: IRangeType[];
-
- rightToLeft: BooleanNumber;
-}
diff --git a/packages/core/src/types/interfaces/i-worksheet-order-data.ts b/packages/core/src/types/interfaces/i-worksheet-order-data.ts
deleted file mode 100644
index 1d87d50505..0000000000
--- a/packages/core/src/types/interfaces/i-worksheet-order-data.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export interface IWorksheetOrderData {}
diff --git a/packages/core/src/types/interfaces/index.ts b/packages/core/src/types/interfaces/index.ts
index 91b043f9ac..8114d15c09 100644
--- a/packages/core/src/types/interfaces/index.ts
+++ b/packages/core/src/types/interfaces/index.ts
@@ -14,21 +14,10 @@
* limitations under the License.
*/
-export * from './i-cell-data';
-export * from './i-column-data';
export * from './i-document-data';
export * from './i-document-data-interceptor';
-export * from './i-freeze';
export * from './i-image-properties';
export * from './i-placeholder';
-export * from './i-range';
-export * from './i-row-data';
-export * from './i-selection-data';
-export * from './i-service-data';
export * from './i-shape-properties';
export * from './i-slide-data';
export * from './i-style-data';
-export * from './i-univer-data';
-export * from './i-workbook-data';
-export * from './i-worksheet-data';
-export * from './i-worksheet-order-data';
diff --git a/packages/core/src/common/type-util.ts b/packages/core/src/types/interfaces/resource.ts
similarity index 88%
rename from packages/core/src/common/type-util.ts
rename to packages/core/src/types/interfaces/resource.ts
index 4757c3d8b5..498951fa67 100644
--- a/packages/core/src/common/type-util.ts
+++ b/packages/core/src/types/interfaces/resource.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export type Nullable<T> = T | null | undefined | void;
+export type Resources = Array<{ id?: string; name: string; data: string }>;
diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.ts
index ca3ecea8ee..fe978509c5 100644
--- a/packages/core/src/univer.ts
+++ b/packages/core/src/univer.ts
@@ -26,6 +26,7 @@ import { IUniverInstanceService, UniverInstanceService } from './services/instan
import { LifecycleStages } from './services/lifecycle/lifecycle';
import { LifecycleInitializerService, LifecycleService } from './services/lifecycle/lifecycle.service';
import { LocaleService } from './services/locale/locale.service';
+import type { LogLevel } from './services/log/log.service';
import { DesktopLogService, ILogService } from './services/log/log.service';
import { PermissionService } from './services/permission/permission.service';
import { IPermissionService } from './services/permission/type';
@@ -34,12 +35,13 @@ import { ResourceManagerService } from './services/resource-manager/resource-man
import { IResourceManagerService } from './services/resource-manager/type';
import { ResourceLoaderService } from './services/resource-loader/resource-loader.service';
import { IResourceLoaderService } from './services/resource-loader/type';
+import type { IStyleSheet } from './services/theme/theme.service';
import { ThemeService } from './services/theme/theme.service';
import { IUndoRedoService, LocalUndoRedoService } from './services/undoredo/undoredo.service';
import { Workbook } from './sheets/workbook';
import { SlideDataModel } from './slides/slide-model';
import type { LocaleType } from './types/enum/locale-type';
-import type { IDocumentData, ISlideData, IUniverData, IWorkbookData } from './types/interfaces';
+import type { IDocumentData, ISlideData } from './types/interfaces';
import type { UnitModel, UnitType } from './common/unit';
import { UniverInstanceType } from './common/unit';
import { PluginService } from './services/plugin/plugin.service';
@@ -49,6 +51,17 @@ import { mergeOverrideWithDependencies } from './services/plugin/plugin-override
import { UserManagerService } from './services/user-manager/user-manager.service';
import { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
import { IAuthzIoService } from './services/authz-io/type';
+import type { ILocales } from './shared';
+import type { IWorkbookData } from './sheets/typedef';
+
+export interface IUniverConfig {
+ theme: IStyleSheet;
+ locale: LocaleType;
+ locales: ILocales;
+ logLevel: LogLevel;
+
+ override?: DependencyOverride;
+}
export class Univer {
private _startedTypes = new Set<UnitType>();
@@ -67,15 +80,14 @@ export class Univer {
* @param config Configuration data for Univer
* @param parentInjector An optional parent injector of the Univer injector. For more information, see https://redi.wendell.fun/docs/hierarchy.
*/
- constructor(config: Partial<IUniverData> = {}, parentInjector?: Injector) {
+ constructor(config: Partial<IUniverConfig> = {}, parentInjector?: Injector) {
const injector = this._injector = createUniverInjector(parentInjector, config?.override);
const { theme, locale, locales, logLevel } = config;
-
- theme && this._injector.get(ThemeService).setTheme(theme);
- locales && this._injector.get(LocaleService).load(locales);
- locale && this._injector.get(LocaleService).setLocale(locale);
- logLevel && this._injector.get(ILogService).setLogLevel(logLevel);
+ if (theme) this._injector.get(ThemeService).setTheme(theme);
+ if (locales) this._injector.get(LocaleService).load(locales);
+ if (locale) this._injector.get(LocaleService).setLocale(locale);
+ if (logLevel) this._injector.get(ILogService).setLogLevel(logLevel);
this._init(injector);
}
@@ -88,7 +100,7 @@ export class Univer {
this._injector.dispose();
}
- setLocale(locale: LocaleType) {
+ setLocale(locale: LocaleType): void {
this._injector.get(LocaleService).setLocale(locale);
}
@@ -159,7 +171,7 @@ export class Univer {
}
}
-function createUniverInjector(parentInjector?: Injector, override?: DependencyOverride) {
+function createUniverInjector(parentInjector?: Injector, override?: DependencyOverride): Injector {
const dependencies: Dependency[] = mergeOverrideWithDependencies([
[ErrorService],
[LocaleService],
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
index d066c36040..3893971825 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc.render-controller.ts
@@ -121,12 +121,9 @@ export class DocRenderController extends RxDisposable implements IRenderModule {
this._addComponent();
- const should = unit.getShouldRenderLoopImmediately();
- if (should) {
- engine.runRenderLoop(() => {
- scene.render();
- });
- }
+ engine.runRenderLoop(() => {
+ scene.render();
+ });
}
private _addComponent() {
diff --git a/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
index 4561574082..6e2038b286 100644
--- a/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts
@@ -73,10 +73,7 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
const sheetId = worksheet.getSheetId();
this._sheetSkeletonManagerService.setCurrent({ sheetId });
- const should = workbook.getShouldRenderLoopImmediately();
- if (should) {
- engine.runRenderLoop(() => scene.render());
- }
+ engine.runRenderLoop(() => scene.render());
}
private _addComponent(workbook: Workbook) {