-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
254 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/sheets-plugin-formula-ui/src/locale/function-list/math/en-US.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export default { | ||
SUM: { | ||
description: 'You can add individual values, cell references or ranges or a mix of all three.', | ||
abstract: 'You can add individual values, cell references or ranges or a mix of all three.', | ||
functionParameter: { | ||
number1: { | ||
name: 'number1', | ||
detail: 'The first number you want to add. The number can be like 4, a cell reference like B6, or a cell range like B2:B8.', | ||
}, | ||
number2: { | ||
name: 'number2', | ||
detail: 'This is the second number you want to add. You can specify up to 255 numbers in this way.', | ||
}, | ||
}, | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/sheets-plugin-formula-ui/src/locale/function-list/math/zh-CN.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export default { | ||
SUM: { | ||
description: '将单个值、单元格引用或是区域相加,或者将三者的组合相加。', | ||
abstract: '将单个值、单元格引用或是区域相加。', | ||
functionParameter: { | ||
number1: { | ||
name: '数值1', | ||
detail: '要相加的第一个数字。 该数字可以是 4 之类的数字,B6 之类的单元格引用或 B2:B8 之类的单元格范围。', | ||
}, | ||
number2: { | ||
name: '数值2', | ||
detail: '这是要相加的第二个数字。 可以按照这种方式最多指定 255 个数字。', | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/sheets-plugin-formula-ui/src/services/description.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { FormulaEngineService, IFunctionInfo } from '@univerjs/base-formula-engine'; | ||
import { LocaleService } from '@univerjs/core'; | ||
import { createIdentifier, IDisposable, Inject } from '@wendellhu/redi'; | ||
|
||
import { FUNCTION_LIST } from './function-list/function-list'; | ||
import { getRealFunctionName } from './utils'; | ||
|
||
export interface IDescriptionService { | ||
getDescriptions(): Map<string, IFunctionInfo>; | ||
} | ||
|
||
export const IDescriptionService = createIdentifier<IDescriptionService>('formula-ui.description-service'); | ||
|
||
export class DescriptionService implements IDescriptionService, IDisposable { | ||
constructor( | ||
private _description: IFunctionInfo[], | ||
@Inject(FormulaEngineService) private readonly _formulaEngineService: FormulaEngineService, | ||
@Inject(LocaleService) private readonly _localeService: LocaleService | ||
) { | ||
this._initialize(); | ||
this._registerDescription(); | ||
} | ||
|
||
private _initialize() { | ||
this._localeService.localeChanged$.subscribe(() => { | ||
this._registerDescription(); | ||
}); | ||
} | ||
|
||
private _registerDescription() { | ||
const localeService = this._localeService; | ||
const functionList = FUNCTION_LIST.concat(this._description || []); | ||
const functionListLocale = functionList.map((functionInfo) => ({ | ||
functionName: getRealFunctionName(functionInfo, localeService), | ||
functionType: functionInfo.functionType, | ||
description: localeService.t(functionInfo.description), | ||
abstract: localeService.t(functionInfo.abstract), | ||
parameterRange: functionInfo.parameterRange, | ||
functionParameter: functionInfo.functionParameter.map((item) => ({ | ||
name: localeService.t(item.name), | ||
detail: localeService.t(item.detail), | ||
example: item.example, | ||
require: item.require, | ||
repeat: item.repeat, | ||
})), | ||
})); | ||
this._formulaEngineService.registerDescription(...functionListLocale); | ||
} | ||
|
||
dispose(): void { | ||
this._localeService.localeChanged$.complete(); | ||
} | ||
|
||
getDescriptions() { | ||
return this._formulaEngineService.getDescriptions(); | ||
} | ||
} |
Oops, something went wrong.