@univerjs/sheets-formula-ui 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +89 -186
- package/lib/es/index.js +86 -184
- package/lib/index.js +86 -184
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/prompt.service.d.ts +1 -2
- package/lib/types/views/formula-editor/hooks/use-formula-search.d.ts +1 -6
- package/lib/types/views/formula-editor/hooks/use-highlight.d.ts +1 -8
- package/lib/types/views/formula-editor/hooks/use-sheet-selection-change.d.ts +0 -7
- package/lib/types/views/formula-editor/index.d.ts +1 -1
- package/lib/umd/index.js +4 -4
- package/package.json +14 -14
package/lib/es/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AbsoluteRefType, BuildTextUtils, CellValueType, ColorKit, CommandType, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, HorizontalAlign, ICommandService, IConfigService, IContextService, ILogService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RANGE_TYPE, Range, Rectangle, RichTextBuilder, RxDisposable, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, createInternalEditorID, generateRandomId, getCellValueType, getEmptyCell, isFormulaId, isFormulaString, isICellData, isRealNum, merge, noop, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
-
import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, JumpOver, MoveSelectionCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, SELECTION_SHAPE_DEPTH, SelectionControl, SetCellEditVisibleOperation, SheetPasteCommand, SheetSkeletonManagerService, SheetsUIPart, checkInHeaderRanges, genNormalSelectionStyle, getAllSelection, getCoordByOffset, getCurrentRangeDisable$, getSheetObject, menuClipboardDisabledObservable, useActiveWorkbook, whenSheetEditorActivated, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
3
|
-
import { ErrorType, FormulaDataModel, FunctionType, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, handleRefStringInfo, isFormulaLexerToken, matchRefDrawToken, matchToken, operatorToken, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
|
|
2
|
+
import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand, HoverManagerService, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, JumpOver, MoveSelectionCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, SELECTION_SHAPE_DEPTH, SelectionControl, SetCellEditVisibleOperation, SheetPasteCommand, SheetSkeletonManagerService, SheetsUIPart, UniverSheetsUIPlugin, checkInHeaderRanges, genNormalSelectionStyle, getAllSelection, getCoordByOffset, getCurrentRangeDisable$, getSheetObject, menuClipboardDisabledObservable, useActiveWorkbook, whenSheetEditorActivated, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
3
|
+
import { ErrorType, FormulaDataModel, FunctionType, IDescriptionService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, UniverFormulaEnginePlugin, buildFormulaTextRuns, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReplaceResult, handleRefStringInfo, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, matchRefDrawToken, matchToken, operatorToken, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
|
|
4
4
|
import { BehaviorSubject, Subject, combineLatestWith, debounceTime, distinctUntilChanged, filter, map, merge as merge$1, throttleTime } from "rxjs";
|
|
5
5
|
import { DocBackScrollRenderController, DocSelectionRenderService, IEditorService, MoveCursorOperation, MoveSelectionOperation, ReplaceTextRunsCommand, RichTextEditor, createEditorUndoRedoKeyboardConfig, useKeyboardEvent, useResize } from "@univerjs/docs-ui";
|
|
6
|
-
import { DeviceInputEventType, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimerType, Vector2 } from "@univerjs/engine-render";
|
|
7
|
-
import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, ReorderRangeCommand, SelectionMoveType, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, WorkbookCopyPermission, WorkbookEditablePermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetSetCellValuePermission, attachSelectionWithCoord, convertSelectionDataToRange, getCellAtRowCol, getSheetCommandTarget, setEndForRange } from "@univerjs/sheets";
|
|
8
|
-
import {
|
|
9
|
-
import { BuiltInUIPart, ComponentManager, IContextMenuService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, ProgressBar, RectPopup, RibbonFormulasGroup, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
|
|
6
|
+
import { DeviceInputEventType, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimerType, UniverRenderEnginePlugin, Vector2 } from "@univerjs/engine-render";
|
|
7
|
+
import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, ReorderRangeCommand, SelectionMoveType, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCopyPermission, WorkbookEditablePermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetSetCellValuePermission, attachSelectionWithCoord, convertSelectionDataToRange, getCellAtRowCol, getSheetCommandTarget, setEndForRange } from "@univerjs/sheets";
|
|
8
|
+
import { ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, QuickSumCommand, TriggerCalculationController, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
9
|
+
import { BuiltInUIPart, ComponentManager, IContextMenuService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, ProgressBar, RectPopup, RibbonFormulasGroup, UniverUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
|
|
10
10
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
11
11
|
import { CheckMarkIcon, CloseIcon, DatabaseFunctionIcon, DateFunctionIcon, DeleteIcon, EngineeringFunctionIcon, FinancialFunctionIcon, FunctionIcon, IncreaseIcon, InformationFunctionIcon, LogicalFunctionIcon, LookupFunctionIcon, MathFunctionIcon, MoreRightIcon, SelectRangeIcon, StatisticalFunctionIcon, TextFunctionIcon } from "@univerjs/icons";
|
|
12
12
|
import { Button, Dialog, Input, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
|
|
@@ -31,7 +31,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
35
35
|
function _typeof(o) {
|
|
36
36
|
"@babel/helpers - typeof";
|
|
37
37
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -42,7 +42,7 @@ function _typeof(o) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region \0@oxc-project+runtime@0.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
|
|
46
46
|
function toPrimitive(t, r) {
|
|
47
47
|
if ("object" != _typeof(t) || !t) return t;
|
|
48
48
|
var e = t[Symbol.toPrimitive];
|
|
@@ -55,14 +55,14 @@ function toPrimitive(t, r) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
|
|
59
59
|
function toPropertyKey(t) {
|
|
60
60
|
var i = toPrimitive(t, "string");
|
|
61
61
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region \0@oxc-project+runtime@0.
|
|
65
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
|
|
66
66
|
function _defineProperty(e, r, t) {
|
|
67
67
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
68
68
|
value: t,
|
|
@@ -73,7 +73,7 @@ function _defineProperty(e, r, t) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
|
|
77
77
|
function __decorateParam(paramIndex, decorator) {
|
|
78
78
|
return function(target, key) {
|
|
79
79
|
decorator(target, key, paramIndex);
|
|
@@ -81,7 +81,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
84
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
|
|
85
85
|
function __decorate(decorators, target, key, desc) {
|
|
86
86
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
87
87
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -327,7 +327,8 @@ const InsertFunctionOperation = {
|
|
|
327
327
|
editColumn = column;
|
|
328
328
|
return true;
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const rangeString = serializeRange(refRange);
|
|
331
|
+
const formulaString = `=${value}(${rangeString})`;
|
|
331
332
|
list.push({
|
|
332
333
|
range,
|
|
333
334
|
primary: {
|
|
@@ -340,12 +341,13 @@ const InsertFunctionOperation = {
|
|
|
340
341
|
const { startRow, startColumn, endRow, endColumn } = range;
|
|
341
342
|
if (startRow === endRow) {
|
|
342
343
|
const blankCellColumn = findBlankCellOfRow(cellMatrix, startRow, endColumn, worksheet.getColumnCount() - 1);
|
|
343
|
-
const
|
|
344
|
+
const rangeString = serializeRange({
|
|
344
345
|
startRow,
|
|
345
346
|
endRow,
|
|
346
347
|
startColumn,
|
|
347
348
|
endColumn: blankCellColumn === endColumn ? endColumn - 1 : endColumn
|
|
348
|
-
})
|
|
349
|
+
});
|
|
350
|
+
const formulaString = `=${value}(${rangeString})`;
|
|
349
351
|
listOfRangeHasNumber.push({
|
|
350
352
|
range,
|
|
351
353
|
primary: {
|
|
@@ -362,12 +364,13 @@ const InsertFunctionOperation = {
|
|
|
362
364
|
}
|
|
363
365
|
const newEndRow = maxBlankCellRow === endRow ? endRow - 1 : endRow;
|
|
364
366
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
365
|
-
const
|
|
367
|
+
const rangeString = serializeRange({
|
|
366
368
|
startRow,
|
|
367
369
|
endRow: newEndRow,
|
|
368
370
|
startColumn: c,
|
|
369
371
|
endColumn: c
|
|
370
|
-
})
|
|
372
|
+
});
|
|
373
|
+
const formulaString = `=${value}(${rangeString})`;
|
|
371
374
|
listOfRangeHasNumber.push({
|
|
372
375
|
range,
|
|
373
376
|
primary: {
|
|
@@ -695,6 +698,30 @@ const SearchFunctionOperation = {
|
|
|
695
698
|
}
|
|
696
699
|
};
|
|
697
700
|
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/common/selection.ts
|
|
703
|
+
function genFormulaRefSelectionStyle(themeService, refColor, id) {
|
|
704
|
+
return {
|
|
705
|
+
id,
|
|
706
|
+
strokeWidth: 1,
|
|
707
|
+
stroke: refColor,
|
|
708
|
+
fill: new ColorKit(refColor).setAlpha(.05).toRgbString(),
|
|
709
|
+
widgets: {
|
|
710
|
+
tl: true,
|
|
711
|
+
tc: true,
|
|
712
|
+
tr: true,
|
|
713
|
+
ml: true,
|
|
714
|
+
mr: true,
|
|
715
|
+
bl: true,
|
|
716
|
+
bc: true,
|
|
717
|
+
br: true
|
|
718
|
+
},
|
|
719
|
+
widgetSize: 6,
|
|
720
|
+
widgetStrokeWidth: 1,
|
|
721
|
+
widgetStroke: themeService.getColorFromTheme("white")
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
|
|
698
725
|
//#endregion
|
|
699
726
|
//#region src/controllers/formula-reorder.controller.ts
|
|
700
727
|
let FormulaReorderController = class FormulaReorderController extends Disposable {
|
|
@@ -719,7 +746,7 @@ let FormulaReorderController = class FormulaReorderController extends Disposable
|
|
|
719
746
|
const redos = [];
|
|
720
747
|
const undos = [];
|
|
721
748
|
const { unitId, subUnitId, range, order } = params;
|
|
722
|
-
const workbook = this._univerInstanceService.
|
|
749
|
+
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
723
750
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
724
751
|
if (!worksheet) return {
|
|
725
752
|
redos,
|
|
@@ -902,6 +929,12 @@ const menuSchema = {
|
|
|
902
929
|
[RibbonFormulasGroup.BASIC]: {
|
|
903
930
|
[`${InsertFunctionOperation.id}.common`]: {
|
|
904
931
|
order: 0,
|
|
932
|
+
gridLayout: {
|
|
933
|
+
row: 1,
|
|
934
|
+
column: 1,
|
|
935
|
+
rowSpan: 2,
|
|
936
|
+
showLabel: false
|
|
937
|
+
},
|
|
905
938
|
menuItemFactory: InsertCommonFunctionMenuItemFactory,
|
|
906
939
|
[MoreFunctionsOperation.id]: {
|
|
907
940
|
order: 0,
|
|
@@ -962,7 +995,7 @@ const menuSchema = {
|
|
|
962
995
|
//#endregion
|
|
963
996
|
//#region package.json
|
|
964
997
|
var name = "@univerjs/sheets-formula-ui";
|
|
965
|
-
var version = "1.0.0-alpha.
|
|
998
|
+
var version = "1.0.0-alpha.8";
|
|
966
999
|
|
|
967
1000
|
//#endregion
|
|
968
1001
|
//#region src/config/config.ts
|
|
@@ -1289,14 +1322,16 @@ const useFormulaDescribe = (isNeed, formulaText, editor) => {
|
|
|
1289
1322
|
const currentSequenceNode = formulaPromptService.getCurrentSequenceNodeByIndex(nodeIndex);
|
|
1290
1323
|
const nextSequenceNode = formulaPromptService.getCurrentSequenceNodeByIndex(nodeIndex + 1);
|
|
1291
1324
|
if (currentSequenceNode) if (typeof currentSequenceNode !== "string" && currentSequenceNode.nodeType === 3 && !descriptionService.hasDefinedNameDescription(currentSequenceNode.token.trim()) && nextSequenceNode === matchToken.OPEN_BRACKET) {
|
|
1292
|
-
|
|
1325
|
+
const info = descriptionService.getFunctionInfo(currentSequenceNode.token);
|
|
1326
|
+
setFunctionInfo(info);
|
|
1293
1327
|
setParamIndex(-1);
|
|
1294
1328
|
return;
|
|
1295
1329
|
} else {
|
|
1296
1330
|
const res = lexerTreeBuilder.getFunctionAndParameter(`${formulaTextRef.current}A`, startOffset - 1);
|
|
1297
1331
|
if (res) {
|
|
1298
1332
|
const { functionName, paramIndex } = res;
|
|
1299
|
-
|
|
1333
|
+
const info = descriptionService.getFunctionInfo(functionName);
|
|
1334
|
+
setFunctionInfo(info);
|
|
1300
1335
|
setParamIndex(paramIndex);
|
|
1301
1336
|
return;
|
|
1302
1337
|
}
|
|
@@ -1901,8 +1936,8 @@ function useFormulaSelecting(opts) {
|
|
|
1901
1936
|
const { editor, editorId, isFocus, disableOnClick, unitId, subUnitId } = opts;
|
|
1902
1937
|
const renderManagerService = useDependency(IRenderManagerService);
|
|
1903
1938
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1904
|
-
const sheetRenderer = renderManagerService.
|
|
1905
|
-
const renderer = renderManagerService.
|
|
1939
|
+
const sheetRenderer = renderManagerService.getRenderUnitById(unitId);
|
|
1940
|
+
const renderer = renderManagerService.getRenderUnitById(editorId);
|
|
1906
1941
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
1907
1942
|
const docSelectionManagerService = useDependency(DocSelectionManagerService);
|
|
1908
1943
|
const injector = useDependency(Injector);
|
|
@@ -2060,30 +2095,6 @@ const useFormulaToken = () => {
|
|
|
2060
2095
|
return useCallback((text) => lexerTreeBuilder.sequenceNodesBuilder(text) || [], [lexerTreeBuilder]);
|
|
2061
2096
|
};
|
|
2062
2097
|
|
|
2063
|
-
//#endregion
|
|
2064
|
-
//#region src/common/selection.ts
|
|
2065
|
-
function genFormulaRefSelectionStyle(themeService, refColor, id) {
|
|
2066
|
-
return {
|
|
2067
|
-
id,
|
|
2068
|
-
strokeWidth: 1,
|
|
2069
|
-
stroke: refColor,
|
|
2070
|
-
fill: new ColorKit(refColor).setAlpha(.05).toRgbString(),
|
|
2071
|
-
widgets: {
|
|
2072
|
-
tl: true,
|
|
2073
|
-
tc: true,
|
|
2074
|
-
tr: true,
|
|
2075
|
-
ml: true,
|
|
2076
|
-
mr: true,
|
|
2077
|
-
bl: true,
|
|
2078
|
-
bc: true,
|
|
2079
|
-
br: true
|
|
2080
|
-
},
|
|
2081
|
-
widgetSize: 6,
|
|
2082
|
-
widgetStrokeWidth: 1,
|
|
2083
|
-
widgetStroke: themeService.getColorFromTheme("white")
|
|
2084
|
-
};
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
2098
|
//#endregion
|
|
2088
2099
|
//#region src/views/formula-editor/hooks/use-highlight.ts
|
|
2089
2100
|
function isSameSelectionRange(left, right) {
|
|
@@ -2155,7 +2166,7 @@ function useSheetHighlight(unitId, subUnitId) {
|
|
|
2155
2166
|
const themeService = useDependency(ThemeService);
|
|
2156
2167
|
const refSelectionsService = useDependency(IRefSelectionsService);
|
|
2157
2168
|
const renderManagerService = useDependency(IRenderManagerService);
|
|
2158
|
-
const ownerRender = renderManagerService.
|
|
2169
|
+
const ownerRender = renderManagerService.getRenderUnitById(unitId);
|
|
2159
2170
|
const ownerRefSelectionsRenderService = ownerRender === null || ownerRender === void 0 ? void 0 : ownerRender.with(RefSelectionsRenderService);
|
|
2160
2171
|
const getHighlightWorkbook = useEvent((refSelections) => {
|
|
2161
2172
|
const ownerWorkbook = univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
@@ -2167,7 +2178,7 @@ function useSheetHighlight(unitId, subUnitId) {
|
|
|
2167
2178
|
var _currentWorkbook$getA;
|
|
2168
2179
|
const currentWorkbook = getHighlightWorkbook(refSelections);
|
|
2169
2180
|
if (!currentWorkbook) return;
|
|
2170
|
-
const currentRender = renderManagerService.
|
|
2181
|
+
const currentRender = renderManagerService.getRenderUnitById(currentWorkbook.getUnitId());
|
|
2171
2182
|
const refSelectionsRenderService = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(RefSelectionsRenderService);
|
|
2172
2183
|
const sheetSelectionRenderService = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(ISheetSelectionRenderService);
|
|
2173
2184
|
const sheetSkeletonManagerService = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(SheetSkeletonManagerService);
|
|
@@ -2258,12 +2269,6 @@ function createFormulaHighlightBody(dataStream, textRuns) {
|
|
|
2258
2269
|
textRuns
|
|
2259
2270
|
};
|
|
2260
2271
|
}
|
|
2261
|
-
function getFormulaHighlightDataStream(leadingCharacter, sequenceNodes, sourceText) {
|
|
2262
|
-
return `${leadingCharacter}${sourceText !== null && sourceText !== void 0 ? sourceText : sequenceNodes.reduce((pre, cur) => {
|
|
2263
|
-
if (typeof cur === "string") return `${pre}${cur}`;
|
|
2264
|
-
return `${pre}${cur.token}`;
|
|
2265
|
-
}, "")}\r\n`;
|
|
2266
|
-
}
|
|
2267
2272
|
function useColor() {
|
|
2268
2273
|
const themeService = useDependency(ThemeService);
|
|
2269
2274
|
return useMemo(() => {
|
|
@@ -2289,79 +2294,7 @@ function useColor() {
|
|
|
2289
2294
|
}, [themeService.getCurrentTheme()]);
|
|
2290
2295
|
}
|
|
2291
2296
|
function buildTextRuns(descriptionService, colorMap, sequenceNodes) {
|
|
2292
|
-
|
|
2293
|
-
const textRuns = [];
|
|
2294
|
-
const refSelections = [];
|
|
2295
|
-
const themeColorMap = /* @__PURE__ */ new Map();
|
|
2296
|
-
let refColorIndex = 0;
|
|
2297
|
-
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2298
|
-
const node = sequenceNodes[i];
|
|
2299
|
-
if (typeof node === "string") {
|
|
2300
|
-
const theLastItem = textRuns[textRuns.length - 1];
|
|
2301
|
-
const start = theLastItem ? theLastItem.ed : 0;
|
|
2302
|
-
const end = start + node.length;
|
|
2303
|
-
textRuns.push({
|
|
2304
|
-
st: start,
|
|
2305
|
-
ed: end,
|
|
2306
|
-
ts: {
|
|
2307
|
-
cl: { rgb: plainTextColor },
|
|
2308
|
-
fs: 11
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2311
|
-
continue;
|
|
2312
|
-
}
|
|
2313
|
-
if (descriptionService.hasDefinedNameDescription(node.token.trim())) {
|
|
2314
|
-
textRuns.push({
|
|
2315
|
-
st: node.startIndex,
|
|
2316
|
-
ed: node.endIndex + 1,
|
|
2317
|
-
ts: {
|
|
2318
|
-
cl: { rgb: plainTextColor },
|
|
2319
|
-
fs: 11
|
|
2320
|
-
}
|
|
2321
|
-
});
|
|
2322
|
-
continue;
|
|
2323
|
-
}
|
|
2324
|
-
const { startIndex, endIndex, nodeType, token } = node;
|
|
2325
|
-
let themeColor = "";
|
|
2326
|
-
if (nodeType === sequenceNodeType.REFERENCE) {
|
|
2327
|
-
if (themeColorMap.has(token)) themeColor = themeColorMap.get(token);
|
|
2328
|
-
else {
|
|
2329
|
-
themeColor = formulaRefColors[refColorIndex % formulaRefColors.length];
|
|
2330
|
-
themeColorMap.set(token, themeColor);
|
|
2331
|
-
refColorIndex++;
|
|
2332
|
-
}
|
|
2333
|
-
refSelections.push({
|
|
2334
|
-
refIndex: i,
|
|
2335
|
-
themeColor,
|
|
2336
|
-
token,
|
|
2337
|
-
startIndex: node.startIndex,
|
|
2338
|
-
endIndex: node.endIndex,
|
|
2339
|
-
index: refSelections.length
|
|
2340
|
-
});
|
|
2341
|
-
} else if (nodeType === sequenceNodeType.NUMBER) themeColor = numberColor;
|
|
2342
|
-
else if (nodeType === sequenceNodeType.STRING) themeColor = stringColor;
|
|
2343
|
-
else if (nodeType === sequenceNodeType.ARRAY) themeColor = stringColor;
|
|
2344
|
-
if (themeColor && themeColor.length > 0) textRuns.push({
|
|
2345
|
-
st: startIndex,
|
|
2346
|
-
ed: endIndex + 1,
|
|
2347
|
-
ts: {
|
|
2348
|
-
cl: { rgb: themeColor },
|
|
2349
|
-
fs: 11
|
|
2350
|
-
}
|
|
2351
|
-
});
|
|
2352
|
-
else textRuns.push({
|
|
2353
|
-
st: startIndex,
|
|
2354
|
-
ed: endIndex + 1,
|
|
2355
|
-
ts: {
|
|
2356
|
-
cl: { rgb: plainTextColor },
|
|
2357
|
-
fs: 11
|
|
2358
|
-
}
|
|
2359
|
-
});
|
|
2360
|
-
}
|
|
2361
|
-
return {
|
|
2362
|
-
textRuns,
|
|
2363
|
-
refSelections
|
|
2364
|
-
};
|
|
2297
|
+
return buildFormulaTextRuns(descriptionService, colorMap, sequenceNodes);
|
|
2365
2298
|
}
|
|
2366
2299
|
|
|
2367
2300
|
//#endregion
|
|
@@ -2544,7 +2477,7 @@ const useRefactorEffect = (isNeed, selecting, unitId, editorId, disableContextMe
|
|
|
2544
2477
|
const refSelectionsService = useDependency(IRefSelectionsService);
|
|
2545
2478
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
2546
2479
|
const currentUnit = useObservable(useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), [univerInstanceService]));
|
|
2547
|
-
const render = renderManagerService.
|
|
2480
|
+
const render = renderManagerService.getRenderUnitById((_currentUnit$getUnitI = currentUnit === null || currentUnit === void 0 ? void 0 : currentUnit.getUnitId()) !== null && _currentUnit$getUnitI !== void 0 ? _currentUnit$getUnitI : "");
|
|
2548
2481
|
const refSelectionsRenderService = render === null || render === void 0 ? void 0 : render.with(RefSelectionsRenderService);
|
|
2549
2482
|
useLayoutEffect(() => {
|
|
2550
2483
|
if (isNeed) {
|
|
@@ -2651,24 +2584,6 @@ const prepareSelectionChangeContext = (opts) => {
|
|
|
2651
2584
|
offset
|
|
2652
2585
|
};
|
|
2653
2586
|
};
|
|
2654
|
-
function getSequenceNodeCharAtOffset(sequenceNodes, offset) {
|
|
2655
|
-
let currentOffset = 0;
|
|
2656
|
-
for (const node of sequenceNodes) {
|
|
2657
|
-
const text = typeof node === "string" ? node : node.token;
|
|
2658
|
-
const nextOffset = currentOffset + text.length;
|
|
2659
|
-
if (offset > currentOffset && offset <= nextOffset) return text[offset - currentOffset - 1];
|
|
2660
|
-
currentOffset = nextOffset;
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
function isFormulaReferenceAddingContext(sequenceNodes, offset) {
|
|
2664
|
-
const char = getSequenceNodeCharAtOffset(sequenceNodes, offset);
|
|
2665
|
-
return Boolean(char && matchRefDrawToken(char));
|
|
2666
|
-
}
|
|
2667
|
-
function isFormulaReferenceAddingTextContext(formulaText, offset) {
|
|
2668
|
-
const char = formulaText[offset - 1];
|
|
2669
|
-
const nextChar = formulaText[offset];
|
|
2670
|
-
return Boolean(char && matchRefDrawToken(char) && (!nextChar || isFormulaLexerToken(nextChar) && nextChar !== matchToken.OPEN_BRACKET));
|
|
2671
|
-
}
|
|
2672
2587
|
function insertFormulaReferenceText(formulaText, refText, offset) {
|
|
2673
2588
|
return `${formulaText.slice(0, offset)}${refText}${formulaText.slice(offset)}`;
|
|
2674
2589
|
}
|
|
@@ -2806,7 +2721,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
2806
2721
|
sheetName
|
|
2807
2722
|
});
|
|
2808
2723
|
const activeWorkbook = resolveFormulaSelectionWorkbook(useObservable(useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), [univerInstanceService])), workbook);
|
|
2809
|
-
const render = renderManagerService.
|
|
2724
|
+
const render = renderManagerService.getRenderUnitById((_activeWorkbook$getUn = activeWorkbook === null || activeWorkbook === void 0 ? void 0 : activeWorkbook.getUnitId()) !== null && _activeWorkbook$getUn !== void 0 ? _activeWorkbook$getUn : unitId);
|
|
2810
2725
|
const refSelectionsRenderService = render === null || render === void 0 ? void 0 : render.with(RefSelectionsRenderService);
|
|
2811
2726
|
const sheetSkeletonManagerService = render === null || render === void 0 ? void 0 : render.with(SheetSkeletonManagerService);
|
|
2812
2727
|
const refSelectionsService = useDependency(IRefSelectionsService);
|
|
@@ -3107,7 +3022,7 @@ const useSheetSelectionChange = (isNeed, isFocus, isSelectingRef, unitId, subUni
|
|
|
3107
3022
|
const useSwitchSheet = (isNeed, unitId, isSupportAcrossSheet, isFocusSet, onBlur, refresh) => {
|
|
3108
3023
|
const commandService = useDependency(ICommandService);
|
|
3109
3024
|
const editorService = useDependency(IEditorService);
|
|
3110
|
-
const render = useDependency(IRenderManagerService).
|
|
3025
|
+
const render = useDependency(IRenderManagerService).getRenderUnitById(unitId);
|
|
3111
3026
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
3112
3027
|
const refSelectionsRenderService = render === null || render === void 0 ? void 0 : render.with(RefSelectionsRenderService);
|
|
3113
3028
|
useEffect(() => {
|
|
@@ -3170,25 +3085,8 @@ const useVerify = (isNeed, onVerify, formulaText) => {
|
|
|
3170
3085
|
|
|
3171
3086
|
//#endregion
|
|
3172
3087
|
//#region src/views/formula-editor/hooks/use-formula-search.ts
|
|
3173
|
-
function
|
|
3174
|
-
return
|
|
3175
|
-
}
|
|
3176
|
-
function getFormulaReplaceResult(nodes, index, formulaName, functionType) {
|
|
3177
|
-
const cloneNodes = [...nodes];
|
|
3178
|
-
if (index !== -1) {
|
|
3179
|
-
const lastNodes = cloneNodes.splice(index + 1);
|
|
3180
|
-
const oldNode = cloneNodes.pop() || "";
|
|
3181
|
-
let offset = (typeof oldNode === "string" ? oldNode.length : oldNode.token.length) - formulaName.length;
|
|
3182
|
-
cloneNodes.push(formulaName);
|
|
3183
|
-
if (lastNodes[0] !== matchToken.OPEN_BRACKET && shouldAppendOpenBracket(functionType)) {
|
|
3184
|
-
cloneNodes.push(matchToken.OPEN_BRACKET);
|
|
3185
|
-
offset--;
|
|
3186
|
-
}
|
|
3187
|
-
return {
|
|
3188
|
-
text: sequenceNodeToText([...cloneNodes, ...lastNodes]),
|
|
3189
|
-
offset
|
|
3190
|
-
};
|
|
3191
|
-
}
|
|
3088
|
+
function getFormulaReplaceResult$1(nodes, index, formulaName, functionType) {
|
|
3089
|
+
return getFormulaReplaceResult(nodes, index, formulaName, functionType);
|
|
3192
3090
|
}
|
|
3193
3091
|
const useFormulaSearch = (isNeed, nodes = [], editor) => {
|
|
3194
3092
|
const descriptionService = useDependency(IDescriptionService);
|
|
@@ -3215,7 +3113,8 @@ const useFormulaSearch = (isNeed, nodes = [], editor) => {
|
|
|
3215
3113
|
if (currentNode && typeof currentNode !== "string" && currentNode.nodeType === sequenceNodeType.FUNCTION) {
|
|
3216
3114
|
indexRef.current = currentNodeIndex;
|
|
3217
3115
|
const token = currentNode.token;
|
|
3218
|
-
|
|
3116
|
+
const list = searchFormulaFunctions(descriptionService, token);
|
|
3117
|
+
setSearchList(list);
|
|
3219
3118
|
setSearchText(token);
|
|
3220
3119
|
return;
|
|
3221
3120
|
}
|
|
@@ -3237,7 +3136,7 @@ const useFormulaSearch = (isNeed, nodes = [], editor) => {
|
|
|
3237
3136
|
if (!isNeed) reset();
|
|
3238
3137
|
}, [isNeed]);
|
|
3239
3138
|
const handlerFormulaReplace = (formulaName, functionType) => {
|
|
3240
|
-
return getFormulaReplaceResult(stateRef.current.nodes, indexRef.current, formulaName, functionType);
|
|
3139
|
+
return getFormulaReplaceResult$1(stateRef.current.nodes, indexRef.current, formulaName, functionType);
|
|
3241
3140
|
};
|
|
3242
3141
|
return {
|
|
3243
3142
|
searchList,
|
|
@@ -3480,7 +3379,7 @@ const FormulaEditor = forwardRef((props, ref) => {
|
|
|
3480
3379
|
disableOnClick: disableSelectionOnClick
|
|
3481
3380
|
});
|
|
3482
3381
|
const highTextRef = useRef("");
|
|
3483
|
-
const renderer = useDependency(IRenderManagerService).
|
|
3382
|
+
const renderer = useDependency(IRenderManagerService).getRenderUnitById(editorId);
|
|
3484
3383
|
const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
|
|
3485
3384
|
const isFocusing = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing;
|
|
3486
3385
|
const currentDoc = useObservable(useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), [univerInstanceService]));
|
|
@@ -3918,11 +3817,13 @@ function SelectFunction(props) {
|
|
|
3918
3817
|
};
|
|
3919
3818
|
function handleSelectChange(value) {
|
|
3920
3819
|
setTypeSelected(value);
|
|
3921
|
-
|
|
3820
|
+
const selectList = descriptionService.getSearchListByType(+value);
|
|
3821
|
+
setSelectList(selectList);
|
|
3922
3822
|
}
|
|
3923
3823
|
function handleSearchInputChange(value) {
|
|
3924
3824
|
setSearchText(value);
|
|
3925
|
-
|
|
3825
|
+
const selectList = descriptionService.getSearchListByName(value);
|
|
3826
|
+
setSelectList(selectList);
|
|
3926
3827
|
}
|
|
3927
3828
|
function handleSelectListKeyDown(e) {
|
|
3928
3829
|
e.stopPropagation();
|
|
@@ -4181,11 +4082,12 @@ function useRangeSelectorSelectionChange(opts) {
|
|
|
4181
4082
|
if (!supportAcrossSheet && currentSheet.getSheetId() !== subUnitId) return;
|
|
4182
4083
|
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return;
|
|
4183
4084
|
const sheetName = keepSheetReference ? currentSheet.getName() : currentSheet.getSheetId() === subUnitId ? "" : currentSheet.getName();
|
|
4184
|
-
|
|
4085
|
+
const ranges = selections.map((item) => ({
|
|
4185
4086
|
range: item.range,
|
|
4186
4087
|
unitId,
|
|
4187
4088
|
sheetName
|
|
4188
|
-
}))
|
|
4089
|
+
}));
|
|
4090
|
+
onChange(ranges, isStart);
|
|
4189
4091
|
});
|
|
4190
4092
|
useEffect(() => {
|
|
4191
4093
|
const disposableCollection = new DisposableCollection();
|
|
@@ -4298,7 +4200,8 @@ function RangeSelectorDialog(props) {
|
|
|
4298
4200
|
});
|
|
4299
4201
|
} else {
|
|
4300
4202
|
newRanges.splice(focusIndex, 1, ...addedRanges);
|
|
4301
|
-
|
|
4203
|
+
const finalRanges = newRanges.slice(0, maxRangeCount);
|
|
4204
|
+
setRanges(finalRanges);
|
|
4302
4205
|
setFocusIndex(focusIndex + addedRanges.length - 1);
|
|
4303
4206
|
}
|
|
4304
4207
|
}
|
|
@@ -4459,10 +4362,9 @@ function RangeSelector(props) {
|
|
|
4459
4362
|
maxRangeCount,
|
|
4460
4363
|
onConfirm: (ranges) => {
|
|
4461
4364
|
const resultStr = stringifyRanges(ranges);
|
|
4462
|
-
const
|
|
4463
|
-
empty.body.dataStream = resultStr;
|
|
4365
|
+
const documentData = RichTextBuilder.create().insertText(resultStr).getData();
|
|
4464
4366
|
editor === null || editor === void 0 || editor.replaceText(resultStr, false);
|
|
4465
|
-
onChange === null || onChange === void 0 || onChange(
|
|
4367
|
+
onChange === null || onChange === void 0 || onChange(documentData, resultStr);
|
|
4466
4368
|
setPopupVisible(false);
|
|
4467
4369
|
setRangeSelectorRanges([]);
|
|
4468
4370
|
requestAnimationFrame(() => {
|
|
@@ -4749,7 +4651,7 @@ function getSetCellFormulaMutations(unitId, subUnitId, range, matrix, accessor,
|
|
|
4749
4651
|
const setValuesMutation = {
|
|
4750
4652
|
unitId,
|
|
4751
4653
|
subUnitId,
|
|
4752
|
-
cellValue: valueMatrix.
|
|
4654
|
+
cellValue: valueMatrix.clone()
|
|
4753
4655
|
};
|
|
4754
4656
|
redoMutationsInfo.push({
|
|
4755
4657
|
id: SetRangeValuesMutation.id,
|
|
@@ -5092,7 +4994,7 @@ let FormulaEditorShowController = class FormulaEditorShowController extends Disp
|
|
|
5092
4994
|
return cellInfo;
|
|
5093
4995
|
}
|
|
5094
4996
|
_createArrayFormulaRangeShape(arrayRange, unitId, subUnitId) {
|
|
5095
|
-
const renderUnit = this._renderManagerService.
|
|
4997
|
+
const renderUnit = this._renderManagerService.getRenderUnitById(unitId);
|
|
5096
4998
|
const skeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
|
|
5097
4999
|
if (!renderUnit || !skeleton) return;
|
|
5098
5000
|
const { scene } = renderUnit;
|
|
@@ -5229,7 +5131,7 @@ let ImageFormulaRenderController = class ImageFormulaRenderController extends Di
|
|
|
5229
5131
|
this._imageFormulaCellInterceptorController.registerRefreshRenderFunction(() => {
|
|
5230
5132
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
5231
5133
|
if (!workbook) return;
|
|
5232
|
-
const render = this._renderManagerService.
|
|
5134
|
+
const render = this._renderManagerService.getRenderUnitById(workbook.getUnitId());
|
|
5233
5135
|
if (!render) return;
|
|
5234
5136
|
render.with(SheetSkeletonManagerService).reCalculate();
|
|
5235
5137
|
const mainComponent = render.mainComponent;
|
|
@@ -5455,7 +5357,7 @@ _defineProperty(UniverSheetsFormulaUIPlugin, "packageName", name);
|
|
|
5455
5357
|
_defineProperty(UniverSheetsFormulaUIPlugin, "version", version);
|
|
5456
5358
|
_defineProperty(UniverSheetsFormulaUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
5457
5359
|
UniverSheetsFormulaUIPlugin = __decorate([
|
|
5458
|
-
DependentOn(UniverSheetsFormulaPlugin),
|
|
5360
|
+
DependentOn(UniverFormulaEnginePlugin, UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsFormulaPlugin, UniverSheetsUIPlugin),
|
|
5459
5361
|
__decorateParam(1, Inject(Injector)),
|
|
5460
5362
|
__decorateParam(2, IRenderManagerService),
|
|
5461
5363
|
__decorateParam(3, IConfigService),
|
|
@@ -5463,4 +5365,4 @@ UniverSheetsFormulaUIPlugin = __decorate([
|
|
|
5463
5365
|
], UniverSheetsFormulaUIPlugin);
|
|
5464
5366
|
|
|
5465
5367
|
//#endregion
|
|
5466
|
-
export { FORMULA_PROMPT_ACTIVATED, FormulaEditor, FormulaReorderController, GlobalRangeSelectorService, HelpFunctionOperation, InsertFunctionOperation, MoreFunctionsOperation, RangeSelector, RefSelectionsRenderService, ReferenceAbsoluteOperation, SearchFunctionOperation, SheetCopyFormulaOnlyCommand, SheetOnlyPasteFormulaCommand, menuSchema as SheetsFormulaUIMenuSchema, UniverSheetsFormulaUIPlugin };
|
|
5368
|
+
export { FORMULA_PROMPT_ACTIVATED, FormulaEditor, FormulaReorderController, GlobalRangeSelectorService, HelpFunctionOperation, InsertFunctionOperation, MoreFunctionsOperation, RangeSelector, RefSelectionsRenderService, ReferenceAbsoluteOperation, SearchFunctionOperation, SheetCopyFormulaOnlyCommand, SheetOnlyPasteFormulaCommand, menuSchema as SheetsFormulaUIMenuSchema, UniverSheetsFormulaUIPlugin, genFormulaRefSelectionStyle };
|