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): change sheet clone (#1261)
Gpound.liudd3b588a668f
diff --git a/packages/sheets-formula/src/controllers/prompt.controller.ts b/packages/sheets-formula/src/controllers/prompt.controller.tsindex 95374dd8c3..c4b876ae0c 100644--- a/packages/sheets-formula/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula/src/controllers/prompt.controller.ts@@ -78,7 +78,7 @@ import {SetEditorResizeOperation,SheetSkeletonManagerService,} from '@univerjs/sheets-ui';-import { KeyCode, MetaKeys } from '@univerjs/ui';+import { IContextMenuService, KeyCode, MetaKeys } from '@univerjs/ui';import { Inject } from '@wendellhu/redi';import type { ISelectEditorFormulaOperationParam } from '../commands/operations/editor-formula.operation';@@ -156,7 +156,8 @@ export class PromptController extends Disposable {@Inject(IDescriptionService) private readonly _descriptionService: IDescriptionService,@Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService,@IFormulaInputService private readonly _formulaInputService: IFormulaInputService,- @Inject(DocViewModelManagerService) private readonly _docViewModelManagerService: DocViewModelManagerService+ @Inject(DocViewModelManagerService) private readonly _docViewModelManagerService: DocViewModelManagerService,+ @IContextMenuService private readonly _contextMenuService: IContextMenuService) {super();@@ -638,6 +639,8 @@ export class PromptController extends Disposable {if (this._matchRefDrawToken(char)) {this._editorBridgeService.enableForceKeepVisible();+ this._contextMenuService.disable();+this._formulaInputService.enableLockedSelectionInsert();this._selectionRenderService.enableRemainLast();@@ -697,6 +700,8 @@ export class PromptController extends Disposable {private _disableForceKeepVisible() {this._editorBridgeService.disableForceKeepVisible();+ this._contextMenuService.enable();+this._formulaInputService.disableLockedSelectionInsert();this._currentInsertRefStringIndex = -1;diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.tsindex 4f8d9aeb82..f422d91afe 100644--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts@@ -234,12 +234,18 @@ export class EndEditController extends Disposable {/*** When closing the editor, switch to the current tab of the editor.*/- if (workbookId === unitId && sheetId !== worksheetId) {+ if (workbookId === unitId && sheetId !== worksheetId && this._editorBridgeService.isForceKeepVisible()) {this._commandService.executeCommand(SetWorksheetActivateCommand.id, {subUnitId: sheetId,unitId,});}++ /**+ * When switching tabs while the editor is open,+ * the operation to refresh the selection will be blocked and needs to be triggered manually.+ */+ this._selectionManagerService.refreshSelection();});}diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsxindex 63c1fc7898..8680f91901 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx@@ -37,6 +37,7 @@ import React, { useEffect, useRef, useState } from 'react';import { SheetMenuPosition } from '../../../controllers/menu/menu';import { ISelectionRenderService } from '../../../services/selection/selection-render.service';import { ISheetBarService } from '../../../services/sheet-bar/sheet-bar.service';+import { IEditorBridgeService } from '../../../services/editor-bridge.service';import styles from './index.module.less';import type { IBaseSheetBarProps } from './SheetBarItem';import { SheetBarItem } from './SheetBarItem';@@ -60,6 +61,7 @@ export function SheetBarTabs() {const localeService = useDependency(LocaleService);const confirmService = useDependency(IConfirmService);const selectionRenderService = useDependency(ISelectionRenderService);+ const editorBridgeService = useDependency(IEditorBridgeService);const injector = useInjector();const workbook = univerInstanceService.getCurrentUniverSheetInstance();@@ -313,6 +315,9 @@ export function SheetBarTabs() {};const onVisibleChange = (visible: boolean) => {+ if (editorBridgeService.isForceKeepVisible()) {+ return;+ }if (visible) {const { left: containerLeft } = slideTabBarContainerRef.current?.getBoundingClientRect() ?? {};// current active tab position@@ -332,7 +337,7 @@ export function SheetBarTabs() {visible={visible}align={{ offset }}trigger={['contextMenu']}- overlay={+ overlay={(<MenumenuType={SheetMenuPosition.SHEET_BAR}onOptionSelect={(params) => {@@ -341,7 +346,7 @@ export function SheetBarTabs() {setVisible(false);}}/>- }+ )}onVisibleChange={onVisibleChange}><div className={styles.slideTabBarContainer} ref={slideTabBarContainerRef}>