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: formular confirm error (#2318)
Ran Luo1eca6d1f53ac
diff --git a/packages/docs-ui/src/controllers/doc-editor-bridge.controller.ts b/packages/docs-ui/src/controllers/doc-editor-bridge.controller.tsindex 85eb4137db..d2d32e9176 100644--- a/packages/docs-ui/src/controllers/doc-editor-bridge.controller.ts+++ b/packages/docs-ui/src/controllers/doc-editor-bridge.controller.ts@@ -17,7 +17,6 @@import type { ICommandInfo, Nullable, Workbook } from '@univerjs/core';import { checkForSubstrings, Disposable, ICommandService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import { Inject } from '@wendellhu/redi';-import { IRenderManagerService, ITextSelectionRenderManager, ScrollBar } from '@univerjs/engine-render';import type { IRichTextEditingMutationParams } from '@univerjs/docs';import { CoverContentCommand, DocSkeletonManagerService, RichTextEditingMutation, VIEWPORT_KEY } from '@univerjs/docs';@@ -265,7 +264,7 @@ export class DocEditorBridgeController extends Disposable {}/**- * Listen to document edits to refresh the size of the normula editor.+ * Listen to document edits to refresh the size of the formula editor.*/private _commandExecutedListener() {const updateCommandList = [RichTextEditingMutation.id, SetEditorResizeOperation.id];diff --git a/packages/sheets-formula/src/controllers/prompt.controller.ts b/packages/sheets-formula/src/controllers/prompt.controller.tsindex d34d562819..3c45050fe0 100644--- a/packages/sheets-formula/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula/src/controllers/prompt.controller.ts@@ -248,8 +248,7 @@ export class PromptController extends Disposable {this.disposeWithMe(toDisposable(this._textSelectionManagerService.textSelection$.subscribe((params) => {- if (params?.unitId == null- ) {+ if (params?.unitId == null) {return;}diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.tsindex 10a1bcea73..0da34baf04 100644--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts@@ -121,8 +121,10 @@ export class EndEditController extends Disposable {this._cursorStateListener();}+ // eslint-disable-next-line max-lines-per-functionprivate _initialExitInput() {this.disposeWithMe(+ // eslint-disable-next-line max-lines-per-functionthis._editorBridgeService.visible$.subscribe(async (param) => {const { visible, keycode, eventType } = param;diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.tsindex b21f6c4ff4..89a190334a 100644--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts@@ -515,8 +515,7 @@ export class StartEditController extends Disposable {const { skeleton } = docParam;this._fitTextSize(position, canvasOffset, skeleton, documentLayoutObject, scaleX, scaleY);-- // move selection+ // move selectionif (eventType === DeviceInputEventType.Keyboard ||(eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange)@@ -535,7 +534,7 @@ export class StartEditController extends Disposable {document.makeDirty();- // @JOCS, Why calculate here?+ // @JOCS, Why calculate here?if (keycode === KeyCode.BACKSPACE || eventType === DeviceInputEventType.Dblclick) {skeleton.calculate();this._editorBridgeService.changeEditorDirty(true);diff --git a/packages/sheets-ui/src/services/selection/selection-render.service.ts b/packages/sheets-ui/src/services/selection/selection-render.service.tsindex 0cf003c939..6d220004ec 100644--- a/packages/sheets-ui/src/services/selection/selection-render.service.ts+++ b/packages/sheets-ui/src/services/selection/selection-render.service.ts@@ -14,6 +14,9 @@* limitations under the License.*/+/* eslint-disable complexity */+/* eslint-disable max-lines-per-function */+import type {IInterceptor,IRange,@@ -307,7 +310,7 @@ export class SelectionRenderService implements ISelectionRenderService {const skeleton = this._skeleton;- let style = data.style;+ let { style } = data;if (style == null) {style = getNormalSelectionStyle(this._themeService);@@ -321,6 +324,7 @@ export class SelectionRenderService implements ISelectionRenderService {const control = new SelectionShape(scene, currentControls.length, this._isHeaderHighlight, this._themeService);+ // eslint-disable-next-line no-newnew SelectionShapeExtension(control, skeleton, scene, this._themeService, this._injector);const { rowHeaderWidth, columnHeaderHeight } = skeleton;@@ -336,12 +340,6 @@ export class SelectionRenderService implements ISelectionRenderService {currentControls.push(control);}- /**- * update selection- * @param selectionRange- * @param curCellRange- * @returns- */updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]) {const currentControls = this.getCurrentControls();if (!currentControls) {@@ -538,7 +536,6 @@ export class SelectionRenderService implements ISelectionRenderService {* @param zIndex Stacking order of the selection object* @param rangeType Determines whether the selection is made normally according to the range or by rows and columns*/- // eslint-disable-next-line max-lines-per-function, complexityeventTrigger(evt: IPointerEvent | IMouseEvent,zIndex = 0,@@ -786,7 +783,6 @@ export class SelectionRenderService implements ISelectionRenderService {let lastX = newEvtOffsetX;let lastY = newEvtOffsetY;- // eslint-disable-next-line max-lines-per-function, complexitythis._moveObserver = scene.onPointerMoveObserver.add((moveEvt: IPointerEvent | IMouseEvent) => {const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;@@ -1045,8 +1041,6 @@ export class SelectionRenderService implements ISelectionRenderService {/*** When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack*/-- // eslint-disable-next-line max-lines-per-functionprivate _moving(moveOffsetX: number,moveOffsetY: number,diff --git a/packages/sheets-ui/src/views/defined-name/DefinedName.tsx b/packages/sheets-ui/src/views/defined-name/DefinedName.tsxindex 3aa08ad30e..17df487f7c 100644--- a/packages/sheets-ui/src/views/defined-name/DefinedName.tsx+++ b/packages/sheets-ui/src/views/defined-name/DefinedName.tsx@@ -36,6 +36,7 @@ export function DefinedName({ disable }: { disable: boolean }) {return () => {subscription.unsubscribe();};+ // eslint-disable-next-line react-hooks/exhaustive-deps}, []); // Empty dependency array means this effect runs once on mount and clean up on unmountreturn (diff --git a/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx b/packages/sheets-ui/src/views/editor-container/EditorContainer.tsxindex a3ad7c9d7e..c8f376bcd3 100644--- a/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx+++ b/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx@@ -107,6 +107,7 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {cellEditorManagerService.setRect({ left, top, width, height });}});+ // eslint-disable-next-line react-hooks/exhaustive-deps}, []); // Empty dependency array means this effect runs once on mount and clean up on unmountuseEffect(() => {diff --git a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsxindex b4c2111f05..c05fa7aed9 100644--- a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx+++ b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx@@ -94,6 +94,7 @@ export function FormulaBar() {}});+ // eslint-disable-next-line react-hooks/exhaustive-deps}, []);const INITIAL_SNAPSHOT = {@@ -154,6 +155,7 @@ export function FormulaBar() {}, ANIMATION_DURATION);}+ // Handle click the "×" button.function handleCloseBtnClick() {const visibleState = editorBridgeService.isVisible();if (visibleState.visible) {@@ -165,6 +167,7 @@ export function FormulaBar() {}}+ // Handle click the "√" button.function handleConfirmBtnClick() {const visibleState = editorBridgeService.isVisible();if (visibleState.visible) {diff --git a/packages/sheets/src/services/selection-manager.service.ts b/packages/sheets/src/services/selection-manager.service.tsindex 22020774a3..3cb120d746 100644--- a/packages/sheets/src/services/selection-manager.service.ts+++ b/packages/sheets/src/services/selection-manager.service.ts@@ -104,14 +104,22 @@ export class SelectionManagerService implements IDisposable {}changePluginNoRefresh(pluginName: string) {- if (this._currentSelection == null) {+ if (this._currentSelection == null || this._currentSelection.pluginName === pluginName) {return;}++ // Fetch the old selections.+ const selections = this.getSelectionDatasByParam(this._currentSelection);+this._currentSelection = {pluginName,unitId: this._currentSelection?.unitId,sheetId: this._currentSelection?.sheetId,};++ if (selections != null) {+ this.add([]);+ }}reset() {@@ -217,6 +225,7 @@ export class SelectionManagerService implements IDisposable {if (this._currentSelection == null) {return;}+this._addByParam({...this._currentSelection,selectionDatas,