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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: remove custom user func list if this empty (#6475)
Roman Sergeev6c54f4b6f70e
diff --git a/packages/sheets-formula-ui/src/services/utils.ts b/packages/sheets-formula-ui/src/services/utils.tsindex a42c0c7c33..d374cce9b0 100644--- a/packages/sheets-formula-ui/src/services/utils.ts+++ b/packages/sheets-formula-ui/src/services/utils.ts@@ -19,11 +19,12 @@ import type { FunctionType, IFunctionInfo, IFunctionParam } from '@univerjs/engiexport function getFunctionTypeValues(enumObj: typeof FunctionType,- localeService: LocaleService+ localeService: LocaleService,+ customFormula: boolean): Array<{ label: string; value: string }> {// Exclude the DefinedName keyreturn Object.keys(enumObj)- .filter((key) => isNaN(Number(key)) && key !== 'DefinedName' && key !== 'Table')+ .filter((key) => isNaN(Number(key)) && key !== 'DefinedName' && key !== 'Table' && (customFormula || key !== 'User')).map((key) => ({label: localeService.t(`formula.functionType.${key.toLocaleLowerCase()}`),value: `${enumObj[key as keyof typeof FunctionType]}`,diff --git a/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx b/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsxindex 3650ae2406..859701327b 100644--- a/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx+++ b/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx@@ -15,14 +15,14 @@*/import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';-import type { ISearchItem } from '@univerjs/sheets-formula';+import type { ISearchItem, IUniverSheetsFormulaBaseConfig } from '@univerjs/sheets-formula';import type { ISidebarMethodOptions } from '@univerjs/ui';import type { KeyboardEvent } from 'react';-import { LocaleService } from '@univerjs/core';+import { IConfigService, LocaleService } from '@univerjs/core';import { borderClassName, clsx, Input, scrollbarClassName, Select } from '@univerjs/design';import { FunctionType } from '@univerjs/engine-formula';import { CheckMarkIcon } from '@univerjs/icons';-import { IDescriptionService } from '@univerjs/sheets-formula';+import { IDescriptionService, PLUGIN_CONFIG_KEY_BASE } from '@univerjs/sheets-formula';import { ISidebarService, useDependency, useObservable } from '@univerjs/ui';import { useEffect, useState } from 'react';import { getFunctionTypeValues } from '../../../services/utils';@@ -34,6 +34,9 @@ export interface ISelectFunctionProps {}export function SelectFunction(props: ISelectFunctionProps) {+ const configService = useDependency(IConfigService);+ const customFunction = configService.getConfig<IUniverSheetsFormulaBaseConfig>(PLUGIN_CONFIG_KEY_BASE)?.function;+const { onChange } = props;const allTypeValue = '-1';@@ -48,7 +51,7 @@ export function SelectFunction(props: ISelectFunctionProps) {const sidebarService = useDependency(ISidebarService);const sidebarOptions = useObservable<ISidebarMethodOptions>(sidebarService.sidebarOptions$);- const options = getFunctionTypeValues(FunctionType, localeService);+ const options = getFunctionTypeValues(FunctionType, localeService, Boolean(customFunction));options.unshift({label: localeService.t('formula.moreFunctions.allFunctions'),value: allTypeValue,