From ff96f95507136fe2598542c7e6fd08de4afea881 Mon Sep 17 00:00:00 2001 From: jocs Date: Sat, 9 Mar 2024 11:52:05 +0800 Subject: [PATCH 1/2] feat: empty formular bar when in array range --- .../src/controllers/editor/formula-editor.controller.ts | 8 ++++---- .../src/controllers/editor/start-edit.controller.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts index 6871cbe6b0c..600e149a244 100644 --- a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts +++ b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts @@ -62,12 +62,12 @@ export class FormulaEditorController extends RxDisposable { @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService, @IRenderManagerService private readonly _renderManagerService: IRenderManagerService, @IEditorBridgeService private readonly _editorBridgeService: IEditorBridgeService, - @Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService, - @Inject(DocViewModelManagerService) private readonly _docViewModelManagerService: DocViewModelManagerService, @ICommandService private readonly _commandService: ICommandService, @IContextService private readonly _contextService: IContextService, @IFormulaEditorManagerService private readonly _formulaEditorManagerService: IFormulaEditorManagerService, @IUndoRedoService private readonly _undoRedoService: IUndoRedoService, + @Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService, + @Inject(DocViewModelManagerService) private readonly _docViewModelManagerService: DocViewModelManagerService, @Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService ) { super(); @@ -207,7 +207,7 @@ export class FormulaEditorController extends RxDisposable { if (visibleState.visible === false) { this._editorBridgeService.changeVisible({ visible: true, - eventType: DeviceInputEventType.PointerDown, + eventType: DeviceInputEventType.Dblclick, }); } }) @@ -284,7 +284,7 @@ export class FormulaEditorController extends RxDisposable { if ( param.isInArrayFormulaRange === true && - this._editorBridgeService.isVisible().eventType === DeviceInputEventType.Dblclick + (this._editorBridgeService.isVisible().eventType === DeviceInputEventType.Dblclick) ) { dataStream = '\r\n'; paragraphs = [ diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts index 245003991c9..69005cf0f0c 100644 --- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts +++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts @@ -519,7 +519,7 @@ export class StartEditController extends Disposable { return; } - this._resetBodyStyle(snapshot.body!); + this._resetBodyStyle(snapshot.body!, !!isInArrayFormulaRange); documentDataModel.reset(snapshot); documentViewModel.reset(documentDataModel); @@ -559,11 +559,11 @@ export class StartEditController extends Disposable { ); } - private _resetBodyStyle(body: IDocumentBody) { + private _resetBodyStyle(body: IDocumentBody, removeStyle = false) { body.dataStream = DEFAULT_EMPTY_DOCUMENT_VALUE; if (body.textRuns != null) { - if (body.textRuns.length === 1) { + if (body.textRuns.length === 1 && !removeStyle) { body.textRuns[0].st = 0; body.textRuns[0].ed = 1; } else { From f8ec7572cb641c9251acd8c17b22060439d42ae8 Mon Sep 17 00:00:00 2001 From: jocs Date: Sat, 9 Mar 2024 11:54:36 +0800 Subject: [PATCH 2/2] refactor: remove unused codes --- .../src/controllers/editor/formula-editor.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts index 600e149a244..a7914356677 100644 --- a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts +++ b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts @@ -284,7 +284,7 @@ export class FormulaEditorController extends RxDisposable { if ( param.isInArrayFormulaRange === true && - (this._editorBridgeService.isVisible().eventType === DeviceInputEventType.Dblclick) + this._editorBridgeService.isVisible().eventType === DeviceInputEventType.Dblclick ) { dataStream = '\r\n'; paragraphs = [