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.

feat: add `functionScreenTips` config to switch the function screen tips display in the formula editor (#5838)

wpxp123456a85deaa901f8
diff --git a/packages/sheets-formula-ui/src/controllers/config.schema.ts b/packages/sheets-formula-ui/src/controllers/config.schema.ts
index 6ca59a35d1..6a55beb172 100644
--- a/packages/sheets-formula-ui/src/controllers/config.schema.ts
+++ b/packages/sheets-formula-ui/src/controllers/config.schema.ts
@@ -30,6 +30,11 @@ export interface IUniverSheetsFormulaUIConfig {
notExecuteFormula?: boolean;
description?: IFunctionInfo[];
function?: Array<[Ctor<BaseFunction>, IFunctionNames]>;
+ /**
+ * The switch for the function screen tips display in the formula editor.
+ * @default true
+ */
+ functionScreenTips?: boolean;
}
export const defaultPluginConfig: IUniverSheetsFormulaUIConfig = {};
diff --git a/packages/sheets-formula-ui/src/views/formula-editor/index.tsx b/packages/sheets-formula-ui/src/views/formula-editor/index.tsx
index 4ae1643c72..603b1e2ef1 100644
--- a/packages/sheets-formula-ui/src/views/formula-editor/index.tsx
+++ b/packages/sheets-formula-ui/src/views/formula-editor/index.tsx
@@ -18,15 +18,17 @@ import type { DocumentDataModel, IDisposable, ITextRange } from '@univerjs/core'
import type { Editor, IKeyboardEventConfig } from '@univerjs/docs-ui';
import type { KeyCode, MetaKeys } from '@univerjs/ui';
import type { CSSProperties, ReactNode, Ref } from 'react';
+import type { IUniverSheetsFormulaUIConfig } from '../../controllers/config.schema';
import type { FormulaSelectingType } from './hooks/use-formula-selection';
import type { IRefSelection } from './hooks/use-highlight';
-import { BuildTextUtils, createInternalEditorID, generateRandomId, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
+import { BuildTextUtils, createInternalEditorID, generateRandomId, IConfigService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { clsx } from '@univerjs/design';
import { DocBackScrollRenderController, DocSelectionRenderService, IEditorService, useKeyboardEvent, useResize } from '@univerjs/docs-ui';
import { IRenderManagerService } from '@univerjs/engine-render';
import { EMBEDDING_FORMULA_EDITOR } from '@univerjs/sheets-ui';
import { useDependency, useEvent, useObservable, useUpdateEffect } from '@univerjs/ui';
import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
+import { PLUGIN_CONFIG_KEY_BASE } from '../../controllers/config.schema';
import { findIndexFromSequenceNodes, findRefSequenceIndex } from '../range-selector/utils/find-index-from-sequence-nodes';
import { HelpFunction } from './help-function/HelpFunction';
import { useFocus } from './hooks/use-focus';
@@ -144,6 +146,10 @@ export const FormulaEditor = forwardRef((props: IFormulaEditorProps, ref: Ref<IF
const refSelections = useRef([] as IRefSelection[]);
const selectingMode = isSelecting;
+ // whether to hide formula search and help popup
+ const configService = useDependency(IConfigService);
+ const functionScreenTips = configService.getConfig<IUniverSheetsFormulaUIConfig>(PLUGIN_CONFIG_KEY_BASE)?.functionScreenTips ?? true;
+
useUpdateEffect(() => {
onChange(formulaText);
}, [formulaText, onChange]);
@@ -335,7 +341,7 @@ export const FormulaEditor = forwardRef((props: IFormulaEditorProps, ref: Ref<IF
{errorText}
</div>
)}
- {(editor && formulaWithoutEqualSymbol !== '') && (
+ {(functionScreenTips && editor && formulaWithoutEqualSymbol !== '') && (
<HelpFunction
editor={editor}
isFocus={isFocus}
@@ -343,7 +349,7 @@ export const FormulaEditor = forwardRef((props: IFormulaEditorProps, ref: Ref<IF
onClose={() => focus()}
/>
)}
- {!!editor && (
+ {(functionScreenTips && !!editor) && (
<SearchFunction
isFocus={isFocus}
sequenceNodes={sequenceNodes}