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: remove builtin global component (#4714)

Wenzhao Hu51862a7f0d73
diff --git a/.nvmrc b/.nvmrc
index 39d00c0517..87bc4c77fe 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-18.17.0
\ No newline at end of file
+20.18.3
diff --git a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx b/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
index 23133c9993..b0e1e48d59 100644
--- a/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
+++ b/packages-experimental/uniui/src/views/workbench/UniWorkbench.tsx
@@ -28,10 +28,11 @@ import { debounce, ICommandService, IContextService, IUniverInstanceService, Loc
import { clsx, ConfigContext, ConfigProvider, defaultTheme, themeInstance } from '@univerjs/design';
import { IRenderManagerService } from '@univerjs/engine-render';
import { MenuSingle } from '@univerjs/icons';
-import { builtInGlobalComponents,
+import {
BuiltInUIPart,
ComponentContainer,
ContextMenu,
+ GlobalZone,
UNI_DISABLE_CHANGING_FOCUS_KEY,
useComponentsOfPart,
useDependency,
@@ -263,7 +264,7 @@ export function UniWorkbench(props: IUniWorkbenchProps) {
</div>
</div>
<ComponentContainer key="global" components={globalComponents} />
- <ComponentContainer key="built-in-global" components={builtInGlobalComponents} />
+ <GlobalZone />
{contextMenu && <ContextMenu />}
<FloatingContainer />
</ReactFlowProvider>
diff --git a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx b/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
index b0455ceaa9..d87f0dc891 100644
--- a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
+++ b/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
@@ -19,17 +19,14 @@ import type { IUniverUIConfig } from '../config.schema';
import type { IUIController, IWorkbenchOptions } from './ui.controller';
import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleService, LifecycleStages, Optional, toDisposable, UniverInstanceType } from '@univerjs/core';
import { render as createRoot, unmount } from '@univerjs/design';
-
import { IRenderManagerService } from '@univerjs/engine-render';
-
-import React from 'react';
import { ILayoutService } from '../../services/layout/layout.service';
import { IMenuManagerService } from '../../services/menu/menu-manager.service';
import { BuiltInUIPart, IUIPartsService } from '../../services/parts/parts.service';
import { connectInjector } from '../../utils/di';
import { FloatDom } from '../../views/components/dom/FloatDom';
import { CanvasPopup } from '../../views/components/popup/CanvasPopup';
-import { MobileApp } from '../../views/MobileApp';
+import { MobileWorkbench } from '../../views/mobile-workbench/MobileWorkbench';
import { menuSchema } from '../menus/menu.schema';
const STEADY_TIMEOUT = 3000;
@@ -113,7 +110,7 @@ function bootstrap(
mountContainer = createContainer('univer');
}
- const ConnectedApp = connectInjector(MobileApp, injector);
+ const ConnectedApp = connectInjector(MobileWorkbench, injector);
const onRendered = (canvasElement: HTMLElement) => callback(canvasElement, mountContainer);
function render() {
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 0a8040dabb..7154724b38 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -120,7 +120,6 @@ export { UNIVER_UI_PLUGIN_NAME } from './ui-plugin';
export * from './utils';
export { ComponentContainer, type IComponentContainerProps, useComponentsOfPart } from './views/components/ComponentContainer';
export { ZenZone } from './views/components/zen-zone/ZenZone';
-export { builtInGlobalComponents } from './views/parts';
// #region - workbench components
diff --git a/packages/ui/src/views/MobileApp.tsx b/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx
similarity index 88%
rename from packages/ui/src/views/MobileApp.tsx
rename to packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx
index bdc001e20e..0063dfc13c 100644
--- a/packages/ui/src/views/MobileApp.tsx
+++ b/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx
@@ -15,18 +15,18 @@
*/
import type { ILocale } from '@univerjs/design';
-import type { IWorkbenchOptions } from '../controllers/ui/ui.controller';
+import type { IWorkbenchOptions } from '../../controllers/ui/ui.controller';
import { LocaleService, ThemeService } from '@univerjs/core';
import { ConfigProvider, defaultTheme, themeInstance } from '@univerjs/design';
import React, { useEffect, useMemo, useRef, useState } from 'react';
-import { BuiltInUIPart } from '../services/parts/parts.service';
-import { useDependency } from '../utils/di';
-import { ComponentContainer, useComponentsOfPart } from './components/ComponentContainer';
-import { MobileContextMenu } from './components/context-menu/MobileContextMenu';
-import { Sidebar } from './components/sidebar/Sidebar';
-import { ZenZone } from './components/zen-zone/ZenZone';
-import styles from './mobile-app.module.less';
-import { builtInGlobalComponents } from './parts';
+import { BuiltInUIPart } from '../../services/parts/parts.service';
+import { useDependency } from '../../utils/di';
+import { ComponentContainer, useComponentsOfPart } from '../components/ComponentContainer';
+import { MobileContextMenu } from '../components/context-menu/MobileContextMenu';
+import { GlobalZone } from '../components/global-zone/GlobalZone';
+import { Sidebar } from '../components/sidebar/Sidebar';
+import { ZenZone } from '../components/zen-zone/ZenZone';
+import styles from './mobile-workbench.module.less';
export interface IUniverAppProps extends IWorkbenchOptions {
mountContainer: HTMLElement;
@@ -34,7 +34,7 @@ export interface IUniverAppProps extends IWorkbenchOptions {
onRendered?: (container: HTMLElement) => void;
}
-export function MobileApp(props: IUniverAppProps) {
+export function MobileWorkbench(props: IUniverAppProps) {
const {
header = true,
footer = true,
@@ -139,12 +139,11 @@ export function MobileApp(props: IUniverAppProps) {
<ComponentContainer key="footer" components={footerComponents} />
</footer>
)}
-
+ <GlobalZone />
<ZenZone />
</section>
</div>
<ComponentContainer key="global" components={globalComponents} />
- <ComponentContainer key="built-in-global" components={builtInGlobalComponents} />
{contextMenu && <MobileContextMenu />}
</ConfigProvider>
);
diff --git a/packages/ui/src/views/mobile-app.module.less b/packages/ui/src/views/mobile-workbench/mobile-workbench.module.less
similarity index 100%
rename from packages/ui/src/views/mobile-app.module.less
rename to packages/ui/src/views/mobile-workbench/mobile-workbench.module.less
diff --git a/packages/ui/src/views/parts.ts b/packages/ui/src/views/parts.ts
deleted file mode 100644
index c96507216d..0000000000
--- a/packages/ui/src/views/parts.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { ComponentType } from 'react';
-
-import { GlobalZone } from './components/global-zone/GlobalZone';
-
-export const builtInGlobalComponents: Set<ComponentType> = new Set([GlobalZone]);
diff --git a/packages/ui/src/views/workbench/Workbench.tsx b/packages/ui/src/views/workbench/Workbench.tsx
index 2b18bc42d7..8bad4b51e9 100644
--- a/packages/ui/src/views/workbench/Workbench.tsx
+++ b/packages/ui/src/views/workbench/Workbench.tsx
@@ -26,10 +26,9 @@ import { BuiltInUIPart } from '../../services/parts/parts.service';
import { useDependency } from '../../utils/di';
import { ComponentContainer, useComponentsOfPart } from '../components/ComponentContainer';
import { DesktopContextMenu } from '../components/context-menu/ContextMenu';
-
+import { GlobalZone } from '../components/global-zone/GlobalZone';
import { Sidebar } from '../components/sidebar/Sidebar';
import { ZenZone } from '../components/zen-zone/ZenZone';
-import { builtInGlobalComponents } from '../parts';
import styles from './workbench.module.less';
export interface IUniverWorkbenchProps extends IWorkbenchOptions {
@@ -197,7 +196,7 @@ export function DesktopWorkbench(props: IUniverWorkbenchProps) {
</section>
</div>
<ComponentContainer key="global" components={globalComponents} />
- <ComponentContainer key="built-in-global" components={builtInGlobalComponents} />
+ <GlobalZone />
{contextMenu && <DesktopContextMenu />}
<FloatingContainer />
<div id="univer-popup-portal" />