@univerjs/sheets-formula 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +178 -130
- package/lib/es/index.js +179 -131
- package/lib/index.js +179 -131
- package/lib/types/controllers/defined-name.controller.d.ts +2 -2
- package/lib/types/services/description.service.d.ts +7 -18
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -2055,7 +2055,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2055
2055
|
this._handleSetRangeValuesMutation(params);
|
|
2056
2056
|
}
|
|
2057
2057
|
}));
|
|
2058
|
-
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe((
|
|
2058
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe((event) => this._handleWorkbookAdded(event.unit)));
|
|
2059
2059
|
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.map)((unit) => unit.getUnitId())).subscribe((unitId) => this._handleWorkbookDisposed(unitId)));
|
|
2060
2060
|
}
|
|
2061
2061
|
_handleSetRangeValuesMutation(params) {
|
|
@@ -2322,7 +2322,7 @@ UpdateFormulaController = __decorate([
|
|
|
2322
2322
|
//#endregion
|
|
2323
2323
|
//#region package.json
|
|
2324
2324
|
var name = "@univerjs/sheets-formula";
|
|
2325
|
-
var version = "0.21.
|
|
2325
|
+
var version = "0.21.1";
|
|
2326
2326
|
|
|
2327
2327
|
//#endregion
|
|
2328
2328
|
//#region src/common/plugin-name.ts
|
|
@@ -15422,33 +15422,100 @@ function getFunctionName(item, localeService) {
|
|
|
15422
15422
|
//#endregion
|
|
15423
15423
|
//#region src/services/description.service.ts
|
|
15424
15424
|
const IDescriptionService = (0, _univerjs_core.createIdentifier)("formula.description-service");
|
|
15425
|
-
let DescriptionService = class DescriptionService {
|
|
15425
|
+
let DescriptionService = class DescriptionService extends _univerjs_core.Disposable {
|
|
15426
15426
|
constructor(_functionService, _localeService, _configService) {
|
|
15427
|
+
super();
|
|
15427
15428
|
this._functionService = _functionService;
|
|
15428
15429
|
this._localeService = _localeService;
|
|
15429
15430
|
this._configService = _configService;
|
|
15430
|
-
_defineProperty(this, "_descriptions",
|
|
15431
|
+
_defineProperty(this, "_descriptions", /* @__PURE__ */ new Map());
|
|
15431
15432
|
this._initialize();
|
|
15432
15433
|
}
|
|
15434
|
+
_initialize() {
|
|
15435
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._localeService.localeChanged$.subscribe(() => {
|
|
15436
|
+
this._functionService.clearDescriptions();
|
|
15437
|
+
const newDescriptions = /* @__PURE__ */ new Map();
|
|
15438
|
+
this._descriptions.forEach((item) => {
|
|
15439
|
+
const functionName = getFunctionName(item, this._localeService).toUpperCase();
|
|
15440
|
+
newDescriptions.set(functionName, item);
|
|
15441
|
+
});
|
|
15442
|
+
this._descriptions = newDescriptions;
|
|
15443
|
+
this._initRegisterDescriptions();
|
|
15444
|
+
})));
|
|
15445
|
+
this._initDescriptions();
|
|
15446
|
+
this._initRegisterDescriptions();
|
|
15447
|
+
}
|
|
15448
|
+
_initDescriptions() {
|
|
15449
|
+
var _config$description;
|
|
15450
|
+
const localeService = this._localeService;
|
|
15451
|
+
FUNCTION_LIST.forEach((item) => {
|
|
15452
|
+
if (_univerjs_engine_formula.ALL_IMPLEMENTED_FUNCTIONS_SET.has(item.functionName)) {
|
|
15453
|
+
const functionName = getFunctionName(item, localeService).toUpperCase();
|
|
15454
|
+
this._descriptions.set(functionName, item);
|
|
15455
|
+
}
|
|
15456
|
+
});
|
|
15457
|
+
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
15458
|
+
config === null || config === void 0 || (_config$description = config.description) === null || _config$description === void 0 || _config$description.forEach((item) => {
|
|
15459
|
+
const functionName = getFunctionName(item, localeService).toUpperCase();
|
|
15460
|
+
this._descriptions.set(functionName, item);
|
|
15461
|
+
});
|
|
15462
|
+
}
|
|
15463
|
+
_initRegisterDescriptions() {
|
|
15464
|
+
const localeService = this._localeService;
|
|
15465
|
+
const functionListLocale = Array.from(this._descriptions.values()).map((functionInfo) => ({
|
|
15466
|
+
functionName: getFunctionName(functionInfo, localeService),
|
|
15467
|
+
functionType: functionInfo.functionType,
|
|
15468
|
+
description: localeService.t(functionInfo.description),
|
|
15469
|
+
abstract: localeService.t(functionInfo.abstract),
|
|
15470
|
+
functionParameter: functionInfo.functionParameter.map((item) => ({
|
|
15471
|
+
name: localeService.t(item.name),
|
|
15472
|
+
detail: localeService.t(item.detail),
|
|
15473
|
+
example: item.example,
|
|
15474
|
+
require: item.require,
|
|
15475
|
+
repeat: item.repeat
|
|
15476
|
+
}))
|
|
15477
|
+
}));
|
|
15478
|
+
this._functionService.registerDescriptions(...functionListLocale);
|
|
15479
|
+
}
|
|
15480
|
+
_registerDescriptions(descriptions) {
|
|
15481
|
+
const localeService = this._localeService;
|
|
15482
|
+
const functionListLocale = descriptions.map((functionInfo) => ({
|
|
15483
|
+
functionName: getFunctionName(functionInfo, localeService),
|
|
15484
|
+
functionType: functionInfo.functionType,
|
|
15485
|
+
description: localeService.t(functionInfo.description),
|
|
15486
|
+
abstract: localeService.t(functionInfo.abstract),
|
|
15487
|
+
functionParameter: functionInfo.functionParameter.map((item) => ({
|
|
15488
|
+
name: localeService.t(item.name),
|
|
15489
|
+
detail: localeService.t(item.detail),
|
|
15490
|
+
example: item.example,
|
|
15491
|
+
require: item.require,
|
|
15492
|
+
repeat: item.repeat
|
|
15493
|
+
}))
|
|
15494
|
+
}));
|
|
15495
|
+
this._functionService.registerDescriptions(...functionListLocale);
|
|
15496
|
+
}
|
|
15433
15497
|
dispose() {
|
|
15434
|
-
|
|
15498
|
+
super.dispose();
|
|
15499
|
+
this._descriptions.clear();
|
|
15435
15500
|
}
|
|
15436
15501
|
getDescriptions() {
|
|
15437
15502
|
return this._functionService.getDescriptions();
|
|
15438
15503
|
}
|
|
15439
15504
|
hasFunction(searchText) {
|
|
15440
|
-
return this.
|
|
15505
|
+
return this._descriptions.has(searchText.toUpperCase());
|
|
15441
15506
|
}
|
|
15442
15507
|
getFunctionInfo(searchText) {
|
|
15443
|
-
|
|
15508
|
+
const item = this._descriptions.get(searchText.toUpperCase());
|
|
15509
|
+
if (!item) return;
|
|
15510
|
+
return this._functionService.getDescription(getFunctionName(item, this._localeService));
|
|
15444
15511
|
}
|
|
15445
15512
|
getSearchListByName(searchText) {
|
|
15446
|
-
const searchList = [];
|
|
15447
15513
|
const functionList = this._functionService.getDescriptions();
|
|
15448
|
-
const _searchText = searchText.
|
|
15514
|
+
const _searchText = searchText.toUpperCase().trim();
|
|
15515
|
+
const searchList = [];
|
|
15449
15516
|
functionList.forEach((item) => {
|
|
15450
15517
|
const { functionName, abstract, functionType } = item;
|
|
15451
|
-
if (functionName.
|
|
15518
|
+
if (functionName.toUpperCase().indexOf(_searchText) > -1 && functionType !== _univerjs_engine_formula.FunctionType.DefinedName) searchList.push({
|
|
15452
15519
|
name: functionName,
|
|
15453
15520
|
desc: abstract
|
|
15454
15521
|
});
|
|
@@ -15456,12 +15523,12 @@ let DescriptionService = class DescriptionService {
|
|
|
15456
15523
|
return searchList;
|
|
15457
15524
|
}
|
|
15458
15525
|
getSearchListByNameFirstLetter(searchText) {
|
|
15459
|
-
const searchList = [];
|
|
15460
15526
|
const functionList = this._functionService.getDescriptions();
|
|
15461
|
-
const _searchText = searchText.
|
|
15527
|
+
const _searchText = searchText.toUpperCase().trim();
|
|
15528
|
+
const searchList = [];
|
|
15462
15529
|
functionList.forEach((item) => {
|
|
15463
15530
|
const { functionName, abstract, functionType } = item;
|
|
15464
|
-
if (functionName.
|
|
15531
|
+
if (functionName.toUpperCase().indexOf(_searchText) === 0) searchList.push({
|
|
15465
15532
|
name: functionName,
|
|
15466
15533
|
desc: abstract,
|
|
15467
15534
|
functionType
|
|
@@ -15470,8 +15537,9 @@ let DescriptionService = class DescriptionService {
|
|
|
15470
15537
|
return searchList;
|
|
15471
15538
|
}
|
|
15472
15539
|
getSearchListByType(type) {
|
|
15540
|
+
const functionList = this._functionService.getDescriptions();
|
|
15473
15541
|
const searchList = [];
|
|
15474
|
-
|
|
15542
|
+
functionList.forEach((item) => {
|
|
15475
15543
|
const { functionName, functionType, abstract } = item;
|
|
15476
15544
|
if ((functionType === type || type === -1) && functionType !== _univerjs_engine_formula.FunctionType.DefinedName) searchList.push({
|
|
15477
15545
|
name: functionName,
|
|
@@ -15480,79 +15548,43 @@ let DescriptionService = class DescriptionService {
|
|
|
15480
15548
|
});
|
|
15481
15549
|
return searchList;
|
|
15482
15550
|
}
|
|
15483
|
-
registerDescriptions(
|
|
15484
|
-
|
|
15485
|
-
|
|
15551
|
+
registerDescriptions(descriptions) {
|
|
15552
|
+
const localeService = this._localeService;
|
|
15553
|
+
const functionNames = [];
|
|
15554
|
+
descriptions.forEach((item) => {
|
|
15555
|
+
const functionName = getFunctionName(item, localeService).toUpperCase();
|
|
15556
|
+
functionNames.push(functionName);
|
|
15557
|
+
this._descriptions.set(functionName, item);
|
|
15558
|
+
});
|
|
15559
|
+
this._registerDescriptions(descriptions);
|
|
15486
15560
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
15487
|
-
const functionNames = description.map((item) => item.functionName);
|
|
15488
15561
|
this.unregisterDescriptions(functionNames);
|
|
15489
15562
|
});
|
|
15490
15563
|
}
|
|
15491
15564
|
unregisterDescriptions(functionNames) {
|
|
15492
|
-
|
|
15493
|
-
|
|
15565
|
+
const removeFunctionNames = [];
|
|
15566
|
+
functionNames.forEach((name) => {
|
|
15567
|
+
const functionName = name.toUpperCase();
|
|
15568
|
+
const item = this._descriptions.get(functionName);
|
|
15569
|
+
if (!item) return;
|
|
15570
|
+
removeFunctionNames.push(getFunctionName(item, this._localeService));
|
|
15571
|
+
this._descriptions.delete(functionName);
|
|
15572
|
+
});
|
|
15573
|
+
this._functionService.unregisterDescriptions(...removeFunctionNames);
|
|
15494
15574
|
}
|
|
15495
15575
|
hasDescription(name) {
|
|
15496
|
-
return this._descriptions.
|
|
15576
|
+
return this._descriptions.has(name.toUpperCase());
|
|
15497
15577
|
}
|
|
15498
15578
|
hasDefinedNameDescription(name) {
|
|
15499
|
-
|
|
15579
|
+
const item = this._descriptions.get(name.toUpperCase());
|
|
15580
|
+
if (!item) return false;
|
|
15581
|
+
return item.functionType === _univerjs_engine_formula.FunctionType.DefinedName;
|
|
15500
15582
|
}
|
|
15501
15583
|
isFormulaDefinedName(name) {
|
|
15502
|
-
const
|
|
15503
|
-
if (
|
|
15504
|
-
|
|
15505
|
-
return !(0, _univerjs_engine_formula.isReferenceStrings)(
|
|
15506
|
-
}
|
|
15507
|
-
_initialize() {
|
|
15508
|
-
this._localeService.localeChanged$.subscribe(() => {
|
|
15509
|
-
this._registerDescriptions();
|
|
15510
|
-
});
|
|
15511
|
-
this._initDescription();
|
|
15512
|
-
this._registerDescriptions();
|
|
15513
|
-
}
|
|
15514
|
-
_initDescription() {
|
|
15515
|
-
var _config$description;
|
|
15516
|
-
const functions = [
|
|
15517
|
-
..._univerjs_engine_formula.functionArray,
|
|
15518
|
-
..._univerjs_engine_formula.functionCompatibility,
|
|
15519
|
-
..._univerjs_engine_formula.functionCube,
|
|
15520
|
-
..._univerjs_engine_formula.functionDatabase,
|
|
15521
|
-
..._univerjs_engine_formula.functionDate,
|
|
15522
|
-
..._univerjs_engine_formula.functionEngineering,
|
|
15523
|
-
..._univerjs_engine_formula.functionFinancial,
|
|
15524
|
-
..._univerjs_engine_formula.functionInformation,
|
|
15525
|
-
..._univerjs_engine_formula.functionLogical,
|
|
15526
|
-
..._univerjs_engine_formula.functionLookup,
|
|
15527
|
-
..._univerjs_engine_formula.functionMath,
|
|
15528
|
-
..._univerjs_engine_formula.functionMeta,
|
|
15529
|
-
..._univerjs_engine_formula.functionStatistical,
|
|
15530
|
-
..._univerjs_engine_formula.functionText,
|
|
15531
|
-
..._univerjs_engine_formula.functionUniver,
|
|
15532
|
-
..._univerjs_engine_formula.functionWeb
|
|
15533
|
-
].map((item) => item[1]);
|
|
15534
|
-
const filterFunctionList = FUNCTION_LIST.filter((item) => {
|
|
15535
|
-
return functions.includes(item.functionName);
|
|
15536
|
-
});
|
|
15537
|
-
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
15538
|
-
this._descriptions = filterFunctionList.concat((_config$description = config === null || config === void 0 ? void 0 : config.description) !== null && _config$description !== void 0 ? _config$description : []);
|
|
15539
|
-
}
|
|
15540
|
-
_registerDescriptions() {
|
|
15541
|
-
const localeService = this._localeService;
|
|
15542
|
-
const functionListLocale = this._descriptions.map((functionInfo) => ({
|
|
15543
|
-
functionName: getFunctionName(functionInfo, localeService),
|
|
15544
|
-
functionType: functionInfo.functionType,
|
|
15545
|
-
description: localeService.t(functionInfo.description),
|
|
15546
|
-
abstract: localeService.t(functionInfo.abstract),
|
|
15547
|
-
functionParameter: functionInfo.functionParameter.map((item) => ({
|
|
15548
|
-
name: localeService.t(item.name),
|
|
15549
|
-
detail: localeService.t(item.detail),
|
|
15550
|
-
example: item.example,
|
|
15551
|
-
require: item.require,
|
|
15552
|
-
repeat: item.repeat
|
|
15553
|
-
}))
|
|
15554
|
-
}));
|
|
15555
|
-
this._functionService.registerDescriptions(...functionListLocale);
|
|
15584
|
+
const item = this._descriptions.get(name.toUpperCase());
|
|
15585
|
+
if (!item) return false;
|
|
15586
|
+
if (item.functionType !== _univerjs_engine_formula.FunctionType.DefinedName) return false;
|
|
15587
|
+
return !(0, _univerjs_engine_formula.isReferenceStrings)(item.description);
|
|
15556
15588
|
}
|
|
15557
15589
|
};
|
|
15558
15590
|
DescriptionService = __decorate([
|
|
@@ -15579,37 +15611,66 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
15579
15611
|
this._changeSheetListener();
|
|
15580
15612
|
}
|
|
15581
15613
|
_descriptionListener() {
|
|
15582
|
-
(0, _univerjs_core.toDisposable)(this._definedNamesService.update$.subscribe(() => {
|
|
15583
|
-
this.
|
|
15584
|
-
}));
|
|
15614
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._definedNamesService.update$.subscribe((event) => {
|
|
15615
|
+
this._updateDescriptions(event);
|
|
15616
|
+
})));
|
|
15585
15617
|
}
|
|
15586
15618
|
_changeUnitListener() {
|
|
15587
|
-
(0, _univerjs_core.toDisposable)(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
|
|
15619
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
|
|
15588
15620
|
this._unRegisterDescriptions();
|
|
15589
|
-
if (workbook) this.
|
|
15590
|
-
}));
|
|
15621
|
+
if (workbook) this._initRegisterDescriptions(workbook.getUnitId());
|
|
15622
|
+
})));
|
|
15591
15623
|
}
|
|
15592
15624
|
_changeSheetListener() {
|
|
15593
15625
|
this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
|
|
15594
15626
|
if (options === null || options === void 0 ? void 0 : options.fromCollab) return;
|
|
15595
15627
|
if (command.id === _univerjs_sheets.SetWorksheetActiveOperation.id) {
|
|
15596
|
-
|
|
15597
|
-
this.
|
|
15628
|
+
const params = command.params;
|
|
15629
|
+
this._unregisterDescriptionsForNotInSheetId(params.unitId, params.subUnitId);
|
|
15630
|
+
this._initRegisterDescriptions(params.unitId, params.subUnitId);
|
|
15598
15631
|
} else if (command.id === _univerjs_engine_formula.SetDefinedNameMutation.id) {
|
|
15599
|
-
const
|
|
15600
|
-
this._registerDescription(
|
|
15632
|
+
const params = command.params;
|
|
15633
|
+
this._registerDescription(params);
|
|
15601
15634
|
} else if (command.id === _univerjs_engine_formula.RemoveDefinedNameMutation.id) {
|
|
15602
|
-
const
|
|
15603
|
-
this._unregisterDescription(
|
|
15635
|
+
const params = command.params;
|
|
15636
|
+
this._unregisterDescription(params);
|
|
15604
15637
|
}
|
|
15605
15638
|
}));
|
|
15606
15639
|
}
|
|
15607
|
-
|
|
15608
|
-
const target = this.
|
|
15640
|
+
_updateDescriptions(event) {
|
|
15641
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService);
|
|
15609
15642
|
if (!target) return;
|
|
15610
|
-
const {
|
|
15611
|
-
const {
|
|
15612
|
-
if (
|
|
15643
|
+
const { unitId, subUnitId } = target;
|
|
15644
|
+
const { type, unitId: updateUnitId, definedNames } = event;
|
|
15645
|
+
if (updateUnitId !== unitId) return;
|
|
15646
|
+
if (type === "update") {
|
|
15647
|
+
const functionList = [];
|
|
15648
|
+
definedNames.forEach((definedName) => {
|
|
15649
|
+
const { name, comment, formulaOrRefString, localSheetId } = definedName;
|
|
15650
|
+
if (localSheetId == null || localSheetId === _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME || localSheetId === subUnitId) functionList.push({
|
|
15651
|
+
functionName: name,
|
|
15652
|
+
description: formulaOrRefString + (comment || ""),
|
|
15653
|
+
abstract: formulaOrRefString,
|
|
15654
|
+
functionType: _univerjs_engine_formula.FunctionType.DefinedName,
|
|
15655
|
+
functionParameter: []
|
|
15656
|
+
});
|
|
15657
|
+
});
|
|
15658
|
+
this._descriptionService.registerDescriptions(functionList);
|
|
15659
|
+
} else if (type === "remove") {
|
|
15660
|
+
const functionList = [];
|
|
15661
|
+
definedNames.forEach((definedName) => {
|
|
15662
|
+
functionList.push(definedName.name);
|
|
15663
|
+
});
|
|
15664
|
+
this._descriptionService.unregisterDescriptions(functionList);
|
|
15665
|
+
}
|
|
15666
|
+
}
|
|
15667
|
+
_registerDescription(params) {
|
|
15668
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, params);
|
|
15669
|
+
if (!target) return;
|
|
15670
|
+
const { subUnitId } = target;
|
|
15671
|
+
const { name, comment, formulaOrRefString, localSheetId } = params;
|
|
15672
|
+
if (this._descriptionService.hasDescription(name)) return;
|
|
15673
|
+
if (localSheetId == null || localSheetId === _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME || localSheetId === subUnitId) this._descriptionService.registerDescriptions([{
|
|
15613
15674
|
functionName: name,
|
|
15614
15675
|
description: formulaOrRefString + (comment || ""),
|
|
15615
15676
|
abstract: formulaOrRefString,
|
|
@@ -15622,9 +15683,9 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
15622
15683
|
this._descriptionService.unregisterDescriptions([name]);
|
|
15623
15684
|
}
|
|
15624
15685
|
_unRegisterDescriptions() {
|
|
15625
|
-
if (this._preUnitId
|
|
15686
|
+
if (this._preUnitId === null) return;
|
|
15626
15687
|
const definedNames = this._definedNamesService.getDefinedNameMap(this._preUnitId);
|
|
15627
|
-
if (definedNames
|
|
15688
|
+
if (!definedNames) return;
|
|
15628
15689
|
const functionList = [];
|
|
15629
15690
|
Array.from(Object.values(definedNames)).forEach((value) => {
|
|
15630
15691
|
const { name } = value;
|
|
@@ -15633,28 +15694,21 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
15633
15694
|
this._descriptionService.unregisterDescriptions(functionList);
|
|
15634
15695
|
this._preUnitId = null;
|
|
15635
15696
|
}
|
|
15636
|
-
|
|
15637
|
-
const
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
if (!worksheet) return null;
|
|
15642
|
-
return {
|
|
15643
|
-
unitId: workbook.getUnitId(),
|
|
15644
|
-
sheetId: worksheet.getSheetId()
|
|
15645
|
-
};
|
|
15646
|
-
}
|
|
15647
|
-
_registerDescriptions() {
|
|
15648
|
-
const target = this._getUnitIdAndSheetId();
|
|
15697
|
+
_initRegisterDescriptions(unitId, subUnitId) {
|
|
15698
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._univerInstanceService, {
|
|
15699
|
+
unitId,
|
|
15700
|
+
subUnitId
|
|
15701
|
+
});
|
|
15649
15702
|
if (!target) return;
|
|
15650
|
-
const { unitId,
|
|
15651
|
-
const definedNames = this._definedNamesService.getDefinedNameMap(
|
|
15703
|
+
const { unitId: _unitId, subUnitId: _subUnitId } = target;
|
|
15704
|
+
const definedNames = this._definedNamesService.getDefinedNameMap(_unitId);
|
|
15652
15705
|
if (!definedNames) return;
|
|
15653
15706
|
const functionList = [];
|
|
15654
|
-
this._preUnitId =
|
|
15707
|
+
this._preUnitId = _unitId;
|
|
15655
15708
|
Array.from(Object.values(definedNames)).forEach((value) => {
|
|
15656
15709
|
const { name, comment, formulaOrRefString, localSheetId } = value;
|
|
15657
|
-
if (
|
|
15710
|
+
if (this._descriptionService.hasDescription(name)) return;
|
|
15711
|
+
if (localSheetId == null || localSheetId === _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME || localSheetId === _subUnitId) functionList.push({
|
|
15658
15712
|
functionName: name,
|
|
15659
15713
|
description: formulaOrRefString + (comment || ""),
|
|
15660
15714
|
abstract: formulaOrRefString,
|
|
@@ -15664,16 +15718,13 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
|
|
|
15664
15718
|
});
|
|
15665
15719
|
this._descriptionService.registerDescriptions(functionList);
|
|
15666
15720
|
}
|
|
15667
|
-
_unregisterDescriptionsForNotInSheetId() {
|
|
15668
|
-
const target = this._getUnitIdAndSheetId();
|
|
15669
|
-
if (!target) return;
|
|
15670
|
-
const { unitId, sheetId } = target;
|
|
15721
|
+
_unregisterDescriptionsForNotInSheetId(unitId, subUnitId) {
|
|
15671
15722
|
const definedNames = this._definedNamesService.getDefinedNameMap(unitId);
|
|
15672
15723
|
if (!definedNames) return;
|
|
15673
15724
|
const functionList = [];
|
|
15674
15725
|
Array.from(Object.values(definedNames)).forEach((value) => {
|
|
15675
15726
|
const { name, localSheetId } = value;
|
|
15676
|
-
if (localSheetId !== _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME && localSheetId !==
|
|
15727
|
+
if (localSheetId !== _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME && localSheetId !== subUnitId) functionList.push(name);
|
|
15677
15728
|
});
|
|
15678
15729
|
this._descriptionService.unregisterDescriptions(functionList);
|
|
15679
15730
|
}
|
|
@@ -16180,19 +16231,16 @@ let RegisterFunctionService = class RegisterFunctionService extends _univerjs_co
|
|
|
16180
16231
|
const { locales, description, calculate } = params;
|
|
16181
16232
|
if (locales) this._localeService.load(locales);
|
|
16182
16233
|
const disposables = new _univerjs_core.DisposableCollection();
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
});
|
|
16194
|
-
disposables.add(this._functionService.registerDescriptions(...descriptionList));
|
|
16195
|
-
}
|
|
16234
|
+
const descriptions = description !== null && description !== void 0 ? description : calculate.map(([_func, functionName, functionIntroduction]) => {
|
|
16235
|
+
return {
|
|
16236
|
+
functionName,
|
|
16237
|
+
functionType: _univerjs_engine_formula.FunctionType.User,
|
|
16238
|
+
description: "",
|
|
16239
|
+
abstract: functionIntroduction || "",
|
|
16240
|
+
functionParameter: []
|
|
16241
|
+
};
|
|
16242
|
+
});
|
|
16243
|
+
disposables.add(this._descriptionService.registerDescriptions(descriptions));
|
|
16196
16244
|
disposables.add(this._registerLocalExecutors(calculate));
|
|
16197
16245
|
if (this._remoteRegisterFunctionService) disposables.add(this._registerRemoteExecutors(calculate));
|
|
16198
16246
|
return disposables;
|