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
fix(editor): formula ref selection moving not work (#3920)
Gpound.liu9efc7eb29c71
diff --git a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts b/packages/sheets-formula-ui/src/controllers/prompt.controller.tsindex 89cde6e2e5..8c17fae1c7 100644--- a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts@@ -97,7 +97,7 @@ import {SheetSkeletonManagerService,} from '@univerjs/sheets-ui';import { IContextMenuService, ILayoutService, KeyCode, MetaKeys, SetEditorResizeOperation, UNI_DISABLE_CHANGING_FOCUS_KEY } from '@univerjs/ui';-import { debounceTime, distinctUntilChanged, distinctUntilKeyChanged, filter, merge } from 'rxjs';+import { distinctUntilChanged, distinctUntilKeyChanged, filter, merge } from 'rxjs';import { SelectEditorFormulaOperation } from '../commands/operations/editor-formula.operation';import { HelpFunctionOperation } from '../commands/operations/help-function.operation';import { ReferenceAbsoluteOperation } from '../commands/operations/reference-absolute.operation';@@ -452,7 +452,7 @@ export class PromptController extends Disposable {const selectionControls = this._allSelectionRenderServices.map((s) => s.getSelectionControls()).flat();selectionControls.forEach((c) => {c.disableHelperSelection();- d.add(merge(c.selectionMoving$, c.selectionScaling$).pipe(debounceTime(30)).subscribe((toRange) => {+ d.add(merge(c.selectionMoving$, c.selectionScaling$).subscribe((toRange) => {const docID = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)?.getUnitId() || '';if (isRangeSelector(docID) || isEmbeddingFormulaEditor(docID)) {d.dispose();diff --git a/packages/sheets-formula-ui/src/views/formula-editor/hooks/useSheetSelectionChange.ts b/packages/sheets-formula-ui/src/views/formula-editor/hooks/useSheetSelectionChange.tsindex 3756caee2e..0811fff6e5 100644--- a/packages/sheets-formula-ui/src/views/formula-editor/hooks/useSheetSelectionChange.ts+++ b/packages/sheets-formula-ui/src/views/formula-editor/hooks/useSheetSelectionChange.ts@@ -62,6 +62,7 @@ export const useSheetSelectionChange = (useEffect(() => {if (refSelectionsRenderService && isNeed) {let isFirst = true;+ // eslint-disable-next-line complexityconst handleSelectionsChange = (selections: ISelectionWithCoordAndStyle[]) => {if (isFirst || isScalingRef.current) {isFirst = false;@@ -142,7 +143,9 @@ export const useSheetSelectionChange = (const refRanges = unitRangesToText([unitRangeName], isSupportAcrossSheet);theLastList.push(refRanges[0]);}- const result = `${currentText}${theLastList.length && currentText.length ? ',' : ''}${theLastList.join(',')}`;+ const preNode = sequenceNodes[sequenceNodes.length - 1];+ const isPreNodeRef = preNode && (typeof preNode === 'string' ? false : preNode.nodeType === sequenceNodeType.REFERENCE);+ const result = `${currentText}${theLastList.length && isPreNodeRef ? ',' : ''}${theLastList.join(',')}`;handleRangeChange(result, result.length);}};