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(uni): partially fix some uni mode feature (#5326)

Evan Huc1738d865320
diff --git a/e2e/memory/memory.spec.ts b/e2e/memory/memory.spec.ts
index d565b2c387..25ea087a81 100644
--- a/e2e/memory/memory.spec.ts
+++ b/e2e/memory/memory.spec.ts
@@ -121,6 +121,12 @@ test('memory', async ({ page }) => {
test.setTimeout(60_000);
const client = await page.context().newCDPSession(page);
+ let errored = false;
+ page.on('pageerror', (error) => {
+ console.error('Page error:', error);
+ errored = true;
+ });
+
await page.goto('http://localhost:3000/sheets/');
await page.waitForTimeout(5000);
const memoryAfterFirstInstance = (await getMetrics(page)).JSHeapUsedSize;
@@ -153,6 +159,9 @@ test('memory', async ({ page }) => {
expect(unitMemoryOverflow).toBeLessThanOrEqual(MAX_UNIT_MEMORY_OVERFLOW);
expect(instanceMemoryOverflow).toBeLessThanOrEqual(MAX_SECOND_INSTANCE_OVERFLOW);
expect(univerMemoryOverflow).toBeLessThanOrEqual(MAX_UNIVER_MEMORY_OVERFLOW);
+
+ // TODO: enable this when the memory leak is fixed
+ // expect(errored).toBeFalsy();
});
declare global {
diff --git a/examples/src/uni/main.ts b/examples/src/uni/main.ts
index f22ca035a7..7f2aea8f5c 100644
--- a/examples/src/uni/main.ts
+++ b/examples/src/uni/main.ts
@@ -16,7 +16,6 @@
import { Injector, LocaleType, LogLevel, Univer, UniverInstanceType } from '@univerjs/core';
import { FUniver } from '@univerjs/core/facade';
-import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';
import { DocUIController, UniverDocsUIPlugin } from '@univerjs/docs-ui';
@@ -69,9 +68,6 @@ univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO);
univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_EN);
univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO1);
-// debugger plugin
-univer.registerPlugin(UniverDebuggerPlugin);
-
declare global {
// eslint-disable-next-line ts/naming-convention
interface Window {
diff --git a/packages-experimental/uniui/src/plugin.ts b/packages-experimental/uniui/src/plugin.ts
index 7f62906f39..82ff80f972 100644
--- a/packages-experimental/uniui/src/plugin.ts
+++ b/packages-experimental/uniui/src/plugin.ts
@@ -64,6 +64,7 @@ import {
ShortcutPanelController,
ShortcutPanelService,
ShortcutService,
+ ThemeSwitcherService,
UIPartsService,
UNIVER_UI_PLUGIN_NAME,
ZIndexManager,
@@ -112,6 +113,7 @@ export class UniverUniUIPlugin extends Plugin {
[IPlatformService, { useClass: PlatformService }],
[IMenuManagerService, { useClass: MenuManagerService }],
[IContextMenuService, { useClass: ContextMenuService }],
+ [ThemeSwitcherService],
[IClipboardInterfaceService, { useClass: BrowserClipboardService, lazy: true }],
[INotificationService, { useClass: DesktopNotificationService, lazy: true }],
[IGalleryService, { useClass: DesktopGalleryService, lazy: true }],
diff --git a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx b/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
index 8040f443b6..b15985ff5e 100644
--- a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
+++ b/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
@@ -29,6 +29,7 @@ import {
ComponentContainer,
ContextMenu,
GlobalZone,
+ ThemeSwitcherService,
UNI_DISABLE_CHANGING_FOCUS_KEY,
useComponentsOfPart,
useDependency,
@@ -41,7 +42,7 @@ import {
ReactFlowProvider,
useNodesState,
} from '@xyflow/react';
-import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
+import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { UniFocusUnitOperation } from '../../commands/operations/uni-focus-unit.operation';
import { FlowManagerService } from '../../services/flow/flow-manager.service';
@@ -76,6 +77,7 @@ export function UniWorkbench(props: IUniWorkbenchProps) {
const renderManagerService = useDependency(IRenderManagerService);
const flowManagerService = useDependency(FlowManagerService);
const commandService = useDependency(ICommandService);
+ const themeSwitcherService = useDependency(ThemeSwitcherService);
const contentRef = useRef<HTMLDivElement>(null);
const floatingToolbarRef = useRef<IFloatingToolbarRef>(null);
@@ -93,6 +95,16 @@ export function UniWorkbench(props: IUniWorkbenchProps) {
}
}, [onRendered]);
+ useLayoutEffect(() => {
+ const sub = themeService.currentTheme$.subscribe((theme) => {
+ themeSwitcherService.injectThemeToHead(theme);
+ });
+
+ return () => {
+ sub.unsubscribe();
+ };
+ }, []);
+
const [locale, setLocale] = useState<ILocale>(localeService.getLocales() as unknown as ILocale);
const [zoom, setZoom] = useState<number>(DEFAULT_ZOOM);
diff --git a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx
index 3ef5c18b87..74416073d8 100644
--- a/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx
+++ b/packages/sheets-sort-ui/src/views/EmbedSortBtn.tsx
@@ -50,7 +50,7 @@ export default function EmbedSortBtn(props: IEmbedSortBtnProps) {
return (
<ButtonGroup
- className="univer-mb-3 univer-grid univer-w-full univer-grid-flow-col univer-grid-cols-2 univer-gap-2"
+ className="univer-mb-3 univer-grid univer-w-full univer-grid-flow-col univer-grid-cols-2"
>
<Button onClick={() => apply(true)}>
<AscendingIcon />