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.

fix: add onUniver fix init bug

jerryfd178393c4d0
diff --git a/packages/core/src/Basics/SheetContext.ts b/packages/core/src/Basics/SheetContext.ts
index a688dcf2b1..11c388ee9b 100644
--- a/packages/core/src/Basics/SheetContext.ts
+++ b/packages/core/src/Basics/SheetContext.ts
@@ -3,6 +3,7 @@ import { WorkBookObserverImpl } from './WorkBookObserverImpl';
import { ContextBase } from './ContextBase';
import { Observable } from '../Observer';
import { GenName, PropsFrom } from '../Shared';
+import { Univer } from './Univer';
import { WorkBookObserver } from './WorkBookObserver';
import { IWorkbookConfig } from '../Interfaces';
@@ -29,6 +30,11 @@ export class SheetContext extends ContextBase {
return this._genname;
}
+ onUniver(univer: Univer) {
+ super.onUniver(univer);
+ this._workbook.onUniver(univer);
+ }
+
getContextObserver<Key extends keyof WorkBookObserver>(
value: Key
): Observable<PropsFrom<WorkBookObserver[Key]>> {
diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.ts
index e9d2183b86..118423134c 100644
--- a/packages/core/src/Sheets/Domain/Workbook.ts
+++ b/packages/core/src/Sheets/Domain/Workbook.ts
@@ -5,7 +5,7 @@ import {
} from '../../Const';
import { BooleanNumber } from '../../Enum';
-import { SheetContext } from '../../Basics';
+import { SheetContext, Univer } from '../../Basics';
import {
InsertSheetAction,
@@ -79,8 +79,6 @@ export class Workbook {
this._styles = new Styles(styles);
this._worksheets = new Map<string, Worksheet>();
// this._formatManage = new FormatManager();
- this._getDefaultWorkSheet();
-
// namedRange
this._namedRange = new NamedRange(this);
}
@@ -102,6 +100,10 @@ export class Workbook {
return typeof range === 'string' || 'startRow' in range || 'row' in range;
}
+ onUniver(univer: Univer) {
+ this._getDefaultWorkSheet();
+ }
+
getUnitId() {
return this._unitId;
}
diff --git a/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
index 6365fe5ea2..c01e8c69e4 100644
--- a/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
+++ b/packages/sheets-plugin-import-xlsx/src/ImportXlsxPlugin.tsx
@@ -1,7 +1,7 @@
import { Plugin, SheetContext, UniverSheet } from '@univerjs/core';
import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '@univerjs/ui-plugin-sheets';
import { zh, en } from './Locale';
-import { IMPORT_XLSX_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';
+import { IMPORT_XLSX_PLUGIN_NAME } from './Basics';
import { ImportXlsxController } from './Controller/ImportXlsxController';
import { DragAndDropExtensionFactory } from './Basics/Register/DragAndDropExtension';