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
feat(sheet): sheet bar delete sheet dialog (#801)
Dushusir6a8478959959
diff --git a/packages/core/src/shared/gen-name.ts b/packages/core/src/shared/gen-name.tsdeleted file mode 100644index e03751c3e0..0000000000--- a/packages/core/src/shared/gen-name.ts+++ /dev/null@@ -1,51 +0,0 @@-/**- * Copyright 2023-present DreamNum Inc.- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--export class GenName {- private _include: string[];-- private _count: number;-- constructor() {- this._include = [];- this._count = 1;- }-- checked(name: string): boolean {- return this._include.includes(name);- }-- onlyName(name: string): string {- let output = name;- let count = 1;- while (this.checked(output)) {- output = name + count;- count++;- }- this._include.push(output);- return output;- }-- sheetName(name: string = 'sheet1'): string {- let output = name;- while (this.checked(output)) {- output = `sheet${this._count}`;- this._count++;- }- this._include.push(output);- return output;- }-}diff --git a/packages/core/src/shared/index.ts b/packages/core/src/shared/index.tsindex a32330e7f4..9477163716 100644--- a/packages/core/src/shared/index.ts+++ b/packages/core/src/shared/index.ts@@ -22,7 +22,6 @@ export * from './command-enum';export * from './common';export * from './compare';export * from './doc-tool';-export * from './gen-name';export * from './generate';export * from './hash-algorithm';export * from './lifecycle';diff --git a/packages/core/src/sheets/workbook.ts b/packages/core/src/sheets/workbook.tsindex 2dca06c5f2..46b38f9936 100644--- a/packages/core/src/sheets/workbook.ts+++ b/packages/core/src/sheets/workbook.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import { Inject, Injector } from '@wendellhu/redi';import { BehaviorSubject, Subject } from 'rxjs';+import { ILogService } from '../services/log/log.service';import type { Nullable } from '../shared';-import { GenName, Tools } from '../shared';+import { Tools } from '../shared';import { Disposable } from '../shared/lifecycle';import { DEFAULT_RANGE_ARRAY, DEFAULT_WORKBOOK, DEFAULT_WORKSHEET } from '../types/const';import { BooleanNumber } from '../types/enum';@@ -49,8 +49,6 @@ export class Workbook extends Disposable {private readonly _sheetDisposed$ = new Subject<Worksheet>();readonly sheetDisposed$ = this._sheetDisposed$.asObservable();- private readonly _genName = new GenName();-private readonly _activeSheet$ = new BehaviorSubject<Nullable<Worksheet>>(null);readonly activeSheet$ = this._activeSheet$.asObservable();@@ -76,9 +74,11 @@ export class Workbook extends Disposable {private _unitId: string;+ private _count: number;+constructor(workbookData: Partial<IWorkbookData> = {},- @Inject(Injector) readonly _injector: Injector+ @ILogService private readonly _log: ILogService) {super();@@ -91,6 +91,7 @@ export class Workbook extends Disposable {this._unitId = this._snapshot.id;this._styles = new Styles(styles);+ this._count = 1;this._worksheets = new Map<string, Worksheet>();this._getDefaultWorkSheet();@@ -235,6 +236,21 @@ export class Workbook extends Disposable {return sheetOrder.map((sheetId) => this._worksheets.get(sheetId)) as Worksheet[];}+ getSheetsName(): string[] {+ const { sheetOrder } = this._snapshot;++ const names: string[] = [];++ sheetOrder.forEach((sheetId) => {+ const worksheet = this._worksheets.get(sheetId);+ if (worksheet) {+ names.push(worksheet.getName());+ }+ });++ return names;+ }+getSheetIndex(sheet: Worksheet): number {const { sheetOrder } = this._snapshot;@@ -270,28 +286,6 @@ export class Workbook extends Disposable {.map((s) => s.getConfig().id);}- // getPluginMeta<T>(name: string): T {- // return this._config.pluginMeta[name];- // }-- // setPluginMeta<T>(name: string, value: T) {- // if (!this._config.pluginMeta) {- // this._config.pluginMeta = {};- // }- // return (this._config.pluginMeta[name] = value);- // }-- /**- * Creates a builder for a conditional formatting rule.- */- // newConditionalFormatRule(): ConditionalFormatRuleBuilder {- // return new ConditionalFormatRuleBuilder();- // }-- // newFilterCriteria(): FilterCriteriaBuilder {- // return new FilterCriteriaBuilder();- // }-/*** transform any range type to range data*@@ -359,16 +353,25 @@ export class Workbook extends Disposable {this._snapshot = config;}+ checkSheetName(name: string): boolean {+ const sheetsName = this.getSheetsName();+ return sheetsName.includes(name);+ }++ uniqueSheetName(name: string = 'sheet1'): string {+ let output = name;+ while (this.checkSheetName(output)) {+ output = name + this._count;+ this._count++;+ }+ return output;+ }+/*** Get the range array based on the range string and sheet id*- * @privateRemarks- * zh: 根据范围字符串和sheet id取得范围数组- ** @param txt - range string* @returns- *- * @internal*/private _getCellRange(txt: IRangeStringData): IGridRange {let sheetTxt: string = '';@@ -450,7 +453,6 @@ export class Workbook extends Disposable {/*** Get Default Sheet- * @private*/private _getDefaultWorkSheet(): void {const { _snapshot: _config, _worksheets } = this;@@ -467,7 +469,14 @@ export class Workbook extends Disposable {for (const sheetId in sheets) {const config = sheets[sheetId];- config.name = this._genName.sheetName(config.name);++ const { name } = config;+ config.name = this.uniqueSheetName(name);++ if (config.name !== name) {+ this._log.warn(`The worksheet name ${name} is duplicated, we change it to ${config.name}`);+ }+const worksheet = new Worksheet(config, this._styles);_worksheets.set(sheetId, worksheet);if (!sheetOrder.includes(sheetId)) {diff --git a/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.ts b/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.tsnew file mode 100644index 0000000000..4a0050639d--- /dev/null+++ b/packages/sheets-ui/src/commands/commands/remove-sheet-confirm.command.ts@@ -0,0 +1,52 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ICommand } from '@univerjs/core';+import { CommandType, ICommandService, LocaleService } from '@univerjs/core';+import { RemoveSheetCommand } from '@univerjs/sheets';+import { IConfirmService } from '@univerjs/ui';+import type { IAccessor } from '@wendellhu/redi';++interface IRemoveSheetConfirmCommandParams {+ subUnitId: string;+}++export const RemoveSheetConfirmCommand: ICommand = {+ id: 'sheet.command.remove-sheet-confirm',+ type: CommandType.COMMAND,+ handler: async (accessor: IAccessor, params: IRemoveSheetConfirmCommandParams) => {+ const { subUnitId } = params;+ const confirmService = accessor.get(IConfirmService);+ const commandService = accessor.get(ICommandService);+ const localeService = accessor.get(LocaleService);+ const result = await confirmService.confirm({+ id: 'merge.confirm.add-worksheet-merge',+ title: {+ title: localeService.t('sheetConfig.deleteSheet'),+ },+ children: { title: localeService.t('sheetConfig.deleteSheetContent') },+ cancelText: localeService.t('button.cancel'),+ confirmText: localeService.t('button.confirm'),+ });++ if (result) {+ await commandService.executeCommand(RemoveSheetCommand.id, { subUnitId });+ return true;+ }++ return false;+ },+};diff --git a/packages/sheets-ui/src/commands/commands/rename.command.ts b/packages/sheets-ui/src/commands/operations/rename-sheet.operation.tssimilarity index 87%rename from packages/sheets-ui/src/commands/commands/rename.command.tsrename to packages/sheets-ui/src/commands/operations/rename-sheet.operation.tsindex 5d3c7e13ea..79f3d7a8af 100644--- a/packages/sheets-ui/src/commands/commands/rename.command.ts+++ b/packages/sheets-ui/src/commands/operations/rename-sheet.operation.ts@@ -20,14 +20,14 @@ import type { IAccessor } from '@wendellhu/redi';import { ISheetBarService } from '../../services/sheet-bar/sheet-bar.service';-interface IRenameCommandParams {+interface IRenameSheetOperationParams {subUnitId: string;}export const RenameSheetOperation: ICommand = {- id: 'sheet.command.rename-sheet',+ id: 'sheet.operation.rename-sheet',type: CommandType.OPERATION,- handler: async (accessor: IAccessor, params?: IRenameCommandParams) => {+ handler: async (accessor: IAccessor, params?: IRenameSheetOperationParams) => {const sheetBarService = accessor.get(ISheetBarService);if (params) {sheetBarService.setRenameId(params.subUnitId);diff --git a/packages/sheets-ui/src/controllers/menu/sheet.menu.ts b/packages/sheets-ui/src/controllers/menu/sheet.menu.tsindex 11ed5b5318..f18bbb5d38 100644--- a/packages/sheets-ui/src/controllers/menu/sheet.menu.ts+++ b/packages/sheets-ui/src/controllers/menu/sheet.menu.ts@@ -17,7 +17,6 @@import { ICommandService, IUniverInstanceService } from '@univerjs/core';import {CopySheetCommand,- RemoveSheetCommand,SetTabColorCommand,SetWorksheetHideCommand,SetWorksheetShowCommand,@@ -27,14 +26,15 @@ import { MenuItemType } from '@univerjs/ui';import type { IAccessor } from '@wendellhu/redi';import { Observable } from 'rxjs';-import { RenameSheetOperation } from '../../commands/commands/rename.command';+import { RemoveSheetConfirmCommand } from '../../commands/commands/remove-sheet-confirm.command';import { ShowMenuListCommand } from '../../commands/commands/unhide.command';+import { RenameSheetOperation } from '../../commands/operations/rename-sheet.operation';import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';import { SheetMenuPosition } from './menu';export function DeleteSheetMenuItemFactory(): IMenuButtonItem {return {- id: RemoveSheetCommand.id,+ id: RemoveSheetConfirmCommand.id,type: MenuItemType.BUTTON,positions: [SheetMenuPosition.SHEET_BAR],title: 'sheetConfig.delete',diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.tsindex d98cf50e00..5cb32ec58f 100644--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts@@ -47,7 +47,7 @@ import {SetRangeUnderlineCommand,} from '../commands/commands/inline-format.command';import { RefillCommand } from '../commands/commands/refill.command';-import { RenameSheetOperation } from '../commands/commands/rename.command';+import { RemoveSheetConfirmCommand } from '../commands/commands/remove-sheet-confirm.command';import {ApplyFormatPainterCommand,SetInfiniteFormatPainterCommand,@@ -73,6 +73,7 @@ import {SetCellEditVisibleArrowOperation,SetCellEditVisibleOperation,} from '../commands/operations/cell-edit.operation';+import { RenameSheetOperation } from '../commands/operations/rename-sheet.operation';import { SetScrollOperation } from '../commands/operations/scroll.operation';import { SetEditorResizeOperation } from '../commands/operations/set-editor-resize.operation';import { SetFormatPainterOperation } from '../commands/operations/set-format-painter.operation';@@ -245,6 +246,7 @@ export class SheetUIController extends Disposable {MoveSelectionCommand,MoveSelectionEnterAndTabCommand,RenameSheetOperation,+ RemoveSheetConfirmCommand,ScrollCommand,SelectAllCommand,SetActivateCellEditOperation,diff --git a/packages/sheets-ui/src/locale/en-US.ts b/packages/sheets-ui/src/locale/en-US.tsindex 9418658049..950e65b442 100644--- a/packages/sheets-ui/src/locale/en-US.ts+++ b/packages/sheets-ui/src/locale/en-US.ts@@ -436,8 +436,13 @@ export default {redoDelete: 'Can be undo by Ctrl+Z',noHide: "Can't hide, at least keep one sheet tag",chartEditNoOpt: 'This operation is not allowed in chart editing mode!',+ sheetNameErrorTitle: 'There was a problem',sheetNameSpecCharError: 'The name cannot contain:[ ] : ? * / \' "',- sheetNameCannotIsEmptyError: 'The sheet name cannot be empty',+ sheetNameCannotIsEmptyError: 'The sheet name cannot be empty.',+ sheetNameAlreadyExistsError: 'The sheet name already exists. Please enter another name.',+ deleteSheet: 'Delete worksheet',+ deleteSheetContent:+ 'Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?',},rightClick: {copy: 'Copy',diff --git a/packages/sheets-ui/src/locale/zh-CN.ts b/packages/sheets-ui/src/locale/zh-CN.tsindex 34d5fca2d2..08bf6da935 100644--- a/packages/sheets-ui/src/locale/zh-CN.ts+++ b/packages/sheets-ui/src/locale/zh-CN.ts@@ -300,8 +300,12 @@ export default {redoDelete: '可以通过Ctrl+Z撤销删除',noHide: '不能隐藏, 至少保留一个sheet标签',chartEditNoOpt: '图表编辑模式下不允许该操作!',+ sheetNameErrorTitle: '错误',sheetNameSpecCharError: "名称不能超过31个字符,首尾不能是' 且名称不能包含:\r\n[ ] : \\ ? * /",- sheetNameCannotIsEmptyError: '名称不能为空',+ sheetNameCannotIsEmptyError: '名称不能为空。',+ sheetNameAlreadyExistsError: '工作表已存在,请输入其它名称。',+ deleteSheet: '删除工作表',+ deleteSheetContent: '确认删除此工作表,删除后将不可找回,确定要删除吗?',},rightClick: {copy: '复制',diff --git a/packages/sheets-ui/src/services/sheet-bar/sheet-bar.service.ts b/packages/sheets-ui/src/services/sheet-bar/sheet-bar.service.tsindex 7e84a0afe7..82650ac859 100644--- a/packages/sheets-ui/src/services/sheet-bar/sheet-bar.service.ts+++ b/packages/sheets-ui/src/services/sheet-bar/sheet-bar.service.ts@@ -28,10 +28,12 @@ export interface ISheetBarMenuHandler {export interface ISheetBarService {renameId$: Observable<string>;+ removeId$: Observable<string>;scroll$: Observable<IScrollState>;scrollX$: Observable<number>;addSheet$: Observable<number>;setRenameId(id: string): void;+ setRemoveId(id: string): void;setScroll(state: IScrollState): void;setScrollX(x: number): void;setAddSheet(index: number): void;@@ -43,11 +45,13 @@ export const ISheetBarService = createIdentifier<ISheetBarService>('univer.sheetexport class SheetBarService extends Disposable implements ISheetBarService {readonly renameId$: Observable<string>;+ readonly removeId$: Observable<string>;readonly scroll$: Observable<IScrollState>;readonly scrollX$: Observable<number>;readonly addSheet$: Observable<number>;private readonly _renameId$: Subject<string>;+ private readonly _removeId$: Subject<string>;private readonly _scroll$: Subject<IScrollState>;private readonly _scrollX$: Subject<number>;private readonly _addSheet$: Subject<number>;@@ -60,6 +64,9 @@ export class SheetBarService extends Disposable implements ISheetBarService {this._renameId$ = new Subject();this.renameId$ = this._renameId$.asObservable();+ this._removeId$ = new Subject();+ this.removeId$ = this._removeId$.asObservable();+this._scroll$ = new Subject();this.scroll$ = this._scroll$.asObservable();@@ -74,6 +81,10 @@ export class SheetBarService extends Disposable implements ISheetBarService {this._renameId$.next(renameId);}+ setRemoveId(removeId: string): void {+ this._removeId$.next(removeId);+ }+setScroll(state: IScrollState): void {this._scroll$.next(state);}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 f4912de6e7..f51cff755c 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@@ -104,20 +104,8 @@ export function SheetBarTabs() {onScroll: (state: IScrollState) => {sheetBarService.setScroll(state);},- onEmptyAlert: () => {- const id = 'slideTabBarAlert';- confirmService.open({- id,- children: { title: localeService.t('sheetConfig.sheetNameCannotIsEmptyError') },- // TODO@Dushusir: i18n- title: { title: 'There was a problem' },- onClose() {- confirmService.close(id);- },- onConfirm() {- confirmService.close(id);- },- });+ onNameCheckAlert: (text: string) => {+ return nameEmptyCheck(text) || nameRepeatCheck(text);},});@@ -129,6 +117,71 @@ export function SheetBarTabs() {return slideTabBar;};+ const nameEmptyCheck = (name: string) => {+ if (name.trim() === '') {+ const id = 'sheetNameEmptyAlert';+ confirmService.open({+ id,+ title: { title: localeService.t('sheetConfig.sheetNameErrorTitle') },+ children: { title: localeService.t('sheetConfig.sheetNameCannotIsEmptyError') },+ cancelText: localeService.t('button.cancel'),+ confirmText: localeService.t('button.confirm'),+ onClose() {+ confirmService.close(id);+ focusTabEditor();+ },+ onConfirm() {+ confirmService.close(id);+ focusTabEditor();+ },+ });++ return true;+ }+ return false;+ };++ const nameRepeatCheck = (name: string) => {+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();+ const worksheet = workbook.getActiveSheet();+ const currenSheetName = worksheet.getName();+ if (currenSheetName === name) return true;++ const checked = workbook.checkSheetName(name);++ if (checked) {+ const id = 'sheetNameRepeatAlert';+ confirmService.open({+ id,+ title: { title: localeService.t('sheetConfig.sheetNameErrorTitle') },+ children: { title: localeService.t('sheetConfig.sheetNameAlreadyExistsError') },+ cancelText: localeService.t('button.cancel'),+ confirmText: localeService.t('button.confirm'),+ onClose() {+ confirmService.close(id);+ setTabEditor();+ },+ onConfirm() {+ confirmService.close(id);+ setTabEditor();+ },+ });+ }++ return checked;+ };++ const focusTabEditor = () => {+ const slideTabEditor = slideTabBarRef.current.slideTabBar?.getActiveItem()?.getEditor();+ if (slideTabEditor) {+ slideTabEditor.focus();+ }+ };++ const setTabEditor = () => {+ slideTabBarRef.current.slideTabBar?.getActiveItem()?.setEditor();+ };+const setupSlideTabBarUpdate = () => {const currentIndex = sheetList.findIndex((item) => item.selected);slideTabBarRef.current.slideTabBar?.update(currentIndex);@@ -152,8 +205,8 @@ export function SheetBarTabs() {});const statusInit = () => {- const currentsubUnitId = workbook.getActiveSheet().getSheetId();- setActiveKey(currentsubUnitId);+ const currentSubUnitId = workbook.getActiveSheet().getSheetId();+ setActiveKey(currentSubUnitId);const sheets = workbook.getSheets();const sheetListItems = sheets@@ -180,7 +233,7 @@ export function SheetBarTabs() {const setupSubscribeRenameId = () =>sheetBarService.renameId$.subscribe(() => {- slideTabBarRef.current.slideTabBar?.getActiveItem()?.editor();+ setTabEditor();});const setupSubscribeAddSheet = () =>diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.tsindex f5039fa836..3512dd400e 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts@@ -32,7 +32,7 @@ export interface SlideTabBarConfig {onChangeName: (id: string, name: string) => void;onChangeTab: (event: FocusEvent, id: string) => void;onScroll: (state: IScrollState) => void;- onEmptyAlert: () => void;+ onNameCheckAlert: (text: string) => boolean;}export interface SlideTabItemAnimate {@@ -90,6 +90,10 @@ export class SlideTabItem {return this._slideTabItem;}+ getEditor() {+ return this._slideTabItem.querySelector('span');+ }+isEditMode(): boolean {return this._editMode;}@@ -98,23 +102,19 @@ export class SlideTabItem {return this._slideTabItem.classList;}- primeval(): HTMLElement {- return this._slideTabItem;- }-translateX(x: number) {this._translateX = x;this._slideTabItem.style.transform = `translateX(${x}px)`;return this.getTranslateXDirection();}- editor(callback?: (event: FocusEvent) => void): void {+ setEditor(callback?: (event: FocusEvent) => void): void {let compositionFlag = true;if (this._editMode === false) {- const input = this.primeval().querySelector('span');+ const input = this._slideTabItem.querySelector('span');const blurAction = (focusEvent: FocusEvent) => {- if (this.emptyCheck()) return;+ if (this.nameCheck()) return;this._editMode = false;@@ -188,15 +188,13 @@ export class SlideTabItem {}}- emptyCheck() {- const input = this.primeval().querySelector('span');+ nameCheck() {+ const input = this._slideTabItem.querySelector('span');if (!input) return false;+const text = input.innerText;- if (text.trim() === '') {- this._slideTabBar.getConfig().onEmptyAlert();- return true;- }- return false;+ const checkAlert = this._slideTabBar.getConfig().onNameCheckAlert(text);+ return checkAlert;}animate(): SlideTabItemAnimate {@@ -239,18 +237,20 @@ export class SlideTabItem {if (this._placeholder) {const primeval = this._slideTabBar.primeval();+ // change to set unsetthis._slideTabItem.style.removeProperty('position');this._slideTabItem.style.removeProperty('left');this._slideTabItem.style.removeProperty('top');this._slideTabItem.style.removeProperty('width');this._slideTabItem.style.removeProperty('height');- this._slideTabItem.style.removeProperty('box-shadow');this._slideTabItem.style.removeProperty('background');this._slideTabItem.style.removeProperty('padding');- this._slideTabItem.style.removeProperty('boxSizing');- this._slideTabItem.style.removeProperty('fontSize');+ this._slideTabItem.style.removeProperty('box-sizing');+ this._slideTabItem.style.removeProperty('font-size');+ this._slideTabItem.style.removeProperty('font-family');+ this._slideTabItem.style.removeProperty('font-weight');this._slideTabItem.style.removeProperty('color');- this._slideTabItem.style.removeProperty('borderRadius');+ this._slideTabItem.style.removeProperty('border-radius');this._placeholder.after(this._slideTabItem);primeval.removeChild(this._placeholder);@@ -277,6 +277,8 @@ export class SlideTabItem {}this._slideTabItem.style.boxSizing = computedStyles.boxSizing;this._slideTabItem.style.fontSize = computedStyles.fontSize;+ this._slideTabItem.style.fontFamily = computedStyles.fontFamily;+ this._slideTabItem.style.fontWeight = computedStyles.fontWeight;this._slideTabItem.style.color = computedStyles.color;this._slideTabItem.style.borderRadius = computedStyles.borderRadius;@@ -284,7 +286,6 @@ export class SlideTabItem {this._slideTabItem.style.top = `${boundingRect.y}px`;this._slideTabItem.style.width = `${boundingRect.width}px`;this._slideTabItem.style.height = `${boundingRect.height}px`;- this._slideTabItem.style.boxShadow = '0px 0px 1px 1px rgba(82,82,82,0.1)';this._slideTabItem.style.position = 'fixed';this._slideTabItem.after(placeholder);@@ -501,7 +502,7 @@ export class SlideTabBar {// double clickif (diffTime && diffPageX && diffPageY) {// user editor- this._activeTabItem.editor();+ this._activeTabItem.setEditor();}lastPageX = pageX;diff --git a/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.tsindex aaa85aae16..e0c16e31c6 100644--- a/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts@@ -15,10 +15,12 @@*/import type { Univer, Worksheet } from '@univerjs/core';-import { ICommandService, IUniverInstanceService, RedoCommand, UndoCommand } from '@univerjs/core';+import { ICommandService, IUniverInstanceService, LocaleService, RedoCommand, UndoCommand } from '@univerjs/core';import type { Injector } from '@wendellhu/redi';import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import enUS from '../../../locale/en-US';+import zhCN from '../../../locale/zh-CN';import { InsertSheetMutation } from '../../mutations/insert-sheet.mutation';import { RemoveSheetMutation } from '../../mutations/remove-sheet.mutation';import { SetWorksheetActiveOperation } from '../../operations/set-worksheet-active.operation';@@ -33,7 +35,7 @@ describe('Test copy worksheet commands', () => {let commandService: ICommandService;beforeEach(() => {- const testBed = createCommandTestBed();+ const testBed = createCommandTestBed(undefined);univer = testBed.univer;get = testBed.get;@@ -44,6 +46,8 @@ describe('Test copy worksheet commands', () => {commandService.registerCommand(SetWorksheetActivateCommand);commandService.registerCommand(RemoveSheetCommand);commandService.registerCommand(RemoveSheetMutation);++ get(LocaleService).load({ zhCN, enUS });});afterEach(() => {diff --git a/packages/sheets/src/commands/commands/copy-worksheet.command.ts b/packages/sheets/src/commands/commands/copy-worksheet.command.tsindex 42d5e1dc14..32b592fa90 100644--- a/packages/sheets/src/commands/commands/copy-worksheet.command.ts+++ b/packages/sheets/src/commands/commands/copy-worksheet.command.ts@@ -15,7 +15,14 @@*/import type { ICommand } from '@univerjs/core';-import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, Tools } from '@univerjs/core';+import {+ CommandType,+ ICommandService,+ IUndoRedoService,+ IUniverInstanceService,+ LocaleService,+ Tools,+} from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';import type {@@ -37,6 +44,7 @@ export const CopySheetCommand: ICommand = {const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);+ const localeService = accessor.get(LocaleService);let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();let subUnitId = univerInstanceService@@ -54,7 +62,7 @@ export const CopySheetCommand: ICommand = {if (!worksheet) return false;const config = Tools.deepClone(worksheet.getConfig());- config.name += '副本'; // TODO: 文字国际化+ config.name += localeService.t('sheets.sheetCopy'); // TODO: 文字国际化config.id = Tools.generateRandomId();const sheetIndex = workbook.getSheetIndex(worksheet);diff --git a/packages/sheets/src/locale/en-US.ts b/packages/sheets/src/locale/en-US.tsindex 1c4630e861..3f7d62412f 100644--- a/packages/sheets/src/locale/en-US.ts+++ b/packages/sheets/src/locale/en-US.ts@@ -14,4 +14,8 @@* limitations under the License.*/-export default {};+export default {+ sheets: {+ sheetCopy: '(Copy)',+ },+};diff --git a/packages/sheets/src/locale/zh-CN.ts b/packages/sheets/src/locale/zh-CN.tsindex 1c4630e861..69d2c04765 100644--- a/packages/sheets/src/locale/zh-CN.ts+++ b/packages/sheets/src/locale/zh-CN.ts@@ -14,4 +14,8 @@* limitations under the License.*/-export default {};+export default {+ sheets: {+ sheetCopy: '(副本)',+ },+};diff --git a/packages/ui/src/services/confirm/desktop-confirm.service.ts b/packages/ui/src/services/confirm/desktop-confirm.service.tsindex 810fafb37e..251237c5bd 100644--- a/packages/ui/src/services/confirm/desktop-confirm.service.ts+++ b/packages/ui/src/services/confirm/desktop-confirm.service.ts@@ -29,7 +29,7 @@ export class DesktopConfirmService implements IConfirmService {if (this._confirmOptions.find((item) => item.id === option.id)) {this._confirmOptions = this._confirmOptions.map((item) => ({...(item.id === option.id ? option : item),- visible: true,+ visible: item.id === option.id ? true : item.visible,}));} else {this._confirmOptions.push({