Skip to content

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.

fix: refine localized translations

白熱44f378388e0a
diff --git a/packages/docs-hyper-link-ui/src/locale/zh-HK.ts b/packages/docs-hyper-link-ui/src/locale/zh-HK.ts
index a1d33e4112..b77b703d01 100644
--- a/packages/docs-hyper-link-ui/src/locale/zh-HK.ts
+++ b/packages/docs-hyper-link-ui/src/locale/zh-HK.ts
@@ -23,8 +23,8 @@ const locale: typeof enUS = {
cancel: '取消',
title: '連結',
address: '連結',
- label: '文本',
- labelError: '请输入链接文本',
+ label: '文字',
+ labelError: '請輸入連結文字',
placeholder: '請輸入合法的連結',
addressError: '請輸入合法的連結',
},
diff --git a/packages/docs-hyper-link-ui/src/locale/zh-TW.ts b/packages/docs-hyper-link-ui/src/locale/zh-TW.ts
index a1d33e4112..b77b703d01 100644
--- a/packages/docs-hyper-link-ui/src/locale/zh-TW.ts
+++ b/packages/docs-hyper-link-ui/src/locale/zh-TW.ts
@@ -23,8 +23,8 @@ const locale: typeof enUS = {
cancel: '取消',
title: '連結',
address: '連結',
- label: '文本',
- labelError: '请输入链接文本',
+ label: '文字',
+ labelError: '請輸入連結文字',
placeholder: '請輸入合法的連結',
addressError: '請輸入合法的連結',
},
diff --git a/packages/docs-quick-insert-ui/src/locale/zh-HK.ts b/packages/docs-quick-insert-ui/src/locale/zh-HK.ts
index ccb32a17b2..a5c1f85013 100644
--- a/packages/docs-quick-insert-ui/src/locale/zh-HK.ts
+++ b/packages/docs-quick-insert-ui/src/locale/zh-HK.ts
@@ -22,7 +22,7 @@ const locale: typeof enUS = {
numberedList: '有序列表',
bulletedList: '無序列表',
divider: '分隔線',
- text: '文本',
+ text: '文字',
table: '表格',
image: '圖片',
},
diff --git a/packages/docs-quick-insert-ui/src/locale/zh-TW.ts b/packages/docs-quick-insert-ui/src/locale/zh-TW.ts
index ccb32a17b2..a5c1f85013 100644
--- a/packages/docs-quick-insert-ui/src/locale/zh-TW.ts
+++ b/packages/docs-quick-insert-ui/src/locale/zh-TW.ts
@@ -22,7 +22,7 @@ const locale: typeof enUS = {
numberedList: '有序列表',
bulletedList: '無序列表',
divider: '分隔線',
- text: '文本',
+ text: '文字',
table: '表格',
image: '圖片',
},
diff --git a/packages/docs-ui/src/locale/zh-HK.ts b/packages/docs-ui/src/locale/zh-HK.ts
index 56832f8a55..377da18fe1 100644
--- a/packages/docs-ui/src/locale/zh-HK.ts
+++ b/packages/docs-ui/src/locale/zh-HK.ts
@@ -45,7 +45,7 @@ const locale: typeof enUS = {
order: '有序列表',
unorder: '無序列表',
checklist: '任務列表',
- documentFlavor: '现代模式',
+ documentFlavor: '現代模式',
alignLeft: '左對齊',
alignCenter: '居中對齊',
alignRight: '右對齊',
@@ -177,7 +177,7 @@ const locale: typeof enUS = {
noBackground: '無背景色',
},
'page-settings': {
- 'document-setting': '文檔設置',
+ 'document-setting': '文件設定',
mode: '模式',
'modern-mode': '現代模式',
'classic-mode': '經典模式',
diff --git a/packages/docs-ui/src/locale/zh-TW.ts b/packages/docs-ui/src/locale/zh-TW.ts
index 58b3ced74b..3216bd54bf 100644
--- a/packages/docs-ui/src/locale/zh-TW.ts
+++ b/packages/docs-ui/src/locale/zh-TW.ts
@@ -45,7 +45,7 @@ const locale: typeof enUS = {
order: '有序列表',
unorder: '無序列表',
checklist: '任務列表',
- documentFlavor: '现代模式',
+ documentFlavor: '現代模式',
alignLeft: '左對齊',
alignCenter: '居中對齊',
alignRight: '右對齊',
@@ -177,7 +177,7 @@ const locale: typeof enUS = {
noBackground: '無背景色',
},
'page-settings': {
- 'document-setting': '文檔設置',
+ 'document-setting': '文件設定',
mode: '模式',
'modern-mode': '現代模式',
'classic-mode': '經典模式',
diff --git a/packages/docs-ui/src/menu/__tests__/context-menu.spec.ts b/packages/docs-ui/src/menu/__tests__/context-menu.spec.ts
deleted file mode 100644
index 9ad0c98bee..0000000000
--- a/packages/docs-ui/src/menu/__tests__/context-menu.spec.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { ITextRangeWithStyle } from '@univerjs/engine-render';
-import { DOC_RANGE_TYPE, IUniverInstanceService } from '@univerjs/core';
-import { DocSelectionManagerService } from '@univerjs/docs';
-import { Subject } from 'rxjs';
-import { describe, expect, it } from 'vitest';
-import { InsertRowBeforeMenuItemFactory } from '../context-menu';
-
-describe('doc context menu table predicates', () => {
- it('disables table actions for expanded text selections inside a table cell', () => {
- const harness = createTableMenuHarness({
- activeTextRange: {
- collapsed: false,
- endOffset: 16,
- startOffset: 12,
- },
- rectRanges: [],
- });
-
- expect(readDisabledState(harness)).toBe(true);
- });
-
- it('keeps table actions enabled for collapsed cursors inside a table cell', () => {
- const harness = createTableMenuHarness({
- activeTextRange: {
- collapsed: true,
- endOffset: 12,
- startOffset: 12,
- },
- rectRanges: [],
- });
-
- expect(readDisabledState(harness)).toBe(false);
- });
-
- it('keeps table actions enabled for table rect selections', () => {
- const harness = createTableMenuHarness({
- activeTextRange: null,
- rectRanges: [{
- endOffset: 16,
- rangeType: DOC_RANGE_TYPE.RECT,
- startOffset: 12,
- tableId: 'table-1',
- }],
- });
-
- expect(readDisabledState(harness)).toBe(false);
- });
-});
-
-function readDisabledState(harness: ReturnType<typeof createTableMenuHarness>) {
- const item = InsertRowBeforeMenuItemFactory(harness.accessor as never);
- const values: boolean[] = [];
- const subscription = item.disabled$!.subscribe((value) => {
- values.push(value);
- });
- subscription.unsubscribe();
-
- return values.at(-1);
-}
-
-function createTableMenuHarness(options: {
- activeTextRange: Pick<ITextRangeWithStyle, 'collapsed' | 'endOffset' | 'startOffset'> | null;
- rectRanges: Array<{ endOffset: number; rangeType: DOC_RANGE_TYPE | string; startOffset: number; tableId: string }>;
-}) {
- const selection$ = new Subject<unknown>();
- const selectionManager = {
- getActiveTextRange: () => options.activeTextRange,
- getRectRanges: () => options.rectRanges,
- textSelection$: selection$,
- };
- const univerInstanceService = {
- getCurrentUnitOfType: () => ({
- getSelfOrHeaderFooterModel: () => ({
- getBody: () => ({
- tables: [{ endIndex: 30, startIndex: 10, tableId: 'table-1' }],
- }),
- }),
- }),
- };
-
- return {
- accessor: {
- get: (token: unknown) => {
- if (token === DocSelectionManagerService) {
- return selectionManager;
- }
-
- if (token === IUniverInstanceService) {
- return univerInstanceService;
- }
-
- return null;
- },
- },
- selection$,
- };
-}
diff --git a/packages/docs-ui/src/menu/__tests__/menu-lifecycle.spec.ts b/packages/docs-ui/src/menu/__tests__/menu-lifecycle.spec.ts
deleted file mode 100644
index 8be074f282..0000000000
--- a/packages/docs-ui/src/menu/__tests__/menu-lifecycle.spec.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { Subscriber } from 'rxjs';
-import { ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { DocSelectionManagerService } from '@univerjs/docs';
-import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render';
-import { Observable } from 'rxjs';
-import { describe, expect, it } from 'vitest';
-import { HeaderFooterMenuItemFactory, TableMenuFactory } from '../menu';
-
-function createTrackedObservable<T>() {
- const subscribers = new Set<Subscriber<T>>();
- const observable = new Observable<T>((subscriber) => {
- subscribers.add(subscriber);
- return () => subscribers.delete(subscriber);
- });
-
- return {
- observable,
- emit: (value: T) => subscribers.forEach((subscriber) => subscriber.next(value)),
- get subscriberCount() {
- return subscribers.size;
- },
- };
-}
-
-describe('doc menu observable lifecycles', () => {
- it('disposes header and footer menu listeners when no document is active', () => {
- const focused = createTrackedObservable<string | null>();
- let commandListenerCount = 0;
- const univerInstanceService = {
- focused$: focused.observable,
- getCurrentUnitOfType: () => null,
- getFocusedUnit: () => null,
- getUnit: () => null,
- getUnitType: () => UniverInstanceType.UNIVER_DOC,
- };
- const commandService = {
- onCommandExecuted: () => {
- commandListenerCount++;
- return { dispose: () => commandListenerCount-- };
- },
- };
- const accessor = {
- get: (token: unknown) => {
- if (token === IUniverInstanceService) return univerInstanceService;
- if (token === ICommandService) return commandService;
- throw new Error('Unexpected dependency');
- },
- };
-
- const subscription = HeaderFooterMenuItemFactory(accessor as never).hidden$!.subscribe();
- expect(focused.subscriberCount).toBe(2);
- expect(commandListenerCount).toBe(1);
-
- subscription.unsubscribe();
- expect(focused.subscriberCount).toBe(0);
- expect(commandListenerCount).toBe(0);
- });
-
- it('replaces and disposes the table menu edit-area listener when focus changes', () => {
- const focused = createTrackedObservable<string | null>();
- const editArea = createTrackedObservable<DocumentEditArea>();
- const viewModel = { editAreaChange$: editArea.observable };
- const univerInstanceService = {
- focused$: focused.observable,
- getCurrentUnitOfType: () => null,
- getFocusedUnit: () => null,
- getUnitType: () => UniverInstanceType.UNIVER_DOC,
- };
- const renderManagerService = {
- getRenderUnitById: () => ({
- with: () => ({ getViewModel: () => viewModel }),
- }),
- };
- const accessor = {
- get: (token: unknown) => {
- if (token === IUniverInstanceService) return univerInstanceService;
- if (token === IRenderManagerService) return renderManagerService;
- if (token === DocSelectionManagerService) return {};
- throw new Error('Unexpected dependency');
- },
- };
-
- const subscription = TableMenuFactory(accessor as never).hidden$!.subscribe();
- focused.emit('doc-1');
- expect(editArea.subscriberCount).toBe(1);
-
- focused.emit('doc-2');
- expect(editArea.subscriberCount).toBe(1);
-
- editArea.emit(DocumentEditArea.BODY);
- subscription.unsubscribe();
- expect(editArea.subscriberCount).toBe(0);
- });
-});
diff --git a/packages/docs-ui/src/menu/__tests__/paragraph-menu.spec.ts b/packages/docs-ui/src/menu/__tests__/paragraph-menu.spec.ts
deleted file mode 100644
index f6d7885c84..0000000000
--- a/packages/docs-ui/src/menu/__tests__/paragraph-menu.spec.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { ThemeService } from '@univerjs/core';
-import { of } from 'rxjs';
-import { describe, expect, it, vi } from 'vitest';
-import {
- BACKGROUND_COLOR_SWATCH_ICONS,
- ParagraphMenuBackgroundColorSwatchMenuItemFactories,
- ParagraphMenuIndentDecreaseMenuItemFactory,
- ParagraphMenuIndentIncreaseMenuItemFactory,
-} from '../paragraph-menu';
-
-vi.mock('@univerjs/ui', async () => {
- const actual = await vi.importActual<typeof import('@univerjs/ui')>('@univerjs/ui');
- return {
- ...actual,
- getMenuHiddenObservable: vi.fn(() => of(false)),
- };
-});
-
-describe('paragraph menu theme colors', () => {
- it('uses semantic line-indent icons for indent actions', () => {
- const accessor = {
- get: vi.fn(),
- };
- const increase = ParagraphMenuIndentIncreaseMenuItemFactory(accessor as never);
- const decrease = ParagraphMenuIndentDecreaseMenuItemFactory(accessor as never);
-
- expect(increase.icon).toBe('LineIndentIncreaseIcon');
- expect(decrease.icon).toBe('LineIndentDecreaseIcon');
- });
-
- it('uses direct theme highlight background tokens for background swatches', () => {
- const themeService = {
- getColorFromTheme: vi.fn((path: string) => ({
- 'highlight.background.1': { color: 'purple.500', alpha: 0.3 },
- 'highlight.background.2': { color: 'red.500', alpha: 0.15 },
- 'purple.500': '#010203',
- 'red.500': '#040506',
- })[path]),
- };
- const accessor = {
- get: vi.fn((id) => id === ThemeService ? themeService : undefined),
- };
-
- const firstFactory = ParagraphMenuBackgroundColorSwatchMenuItemFactories['doc.menu.paragraph-t.background-color.0'].menuItemFactory;
- const secondFactory = ParagraphMenuBackgroundColorSwatchMenuItemFactories['doc.menu.paragraph-t.background-color.1'].menuItemFactory;
-
- expect(BACKGROUND_COLOR_SWATCH_ICONS).toHaveLength(16);
- expect(firstFactory(accessor as never).params).toEqual({ value: 'rgba(1,2,3,0.3)' });
- expect(secondFactory(accessor as never).params).toEqual({ value: 'rgba(4,5,6,0.15)' });
- expect(themeService.getColorFromTheme).toHaveBeenCalledWith('highlight.background.1');
- expect(themeService.getColorFromTheme).toHaveBeenCalledWith('highlight.background.2');
- });
-});
diff --git a/packages/find-replace/src/menu/__tests__/find-replace.menu.spec.ts b/packages/find-replace/src/menu/__tests__/find-replace.menu.spec.ts
deleted file mode 100644
index 02ec0c29d8..0000000000
--- a/packages/find-replace/src/menu/__tests__/find-replace.menu.spec.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { Injector, Univer } from '@univerjs/core';
-import { EDITOR_ACTIVATED, FOCUSING_SHEET, IContextService } from '@univerjs/core';
-import { RibbonDataGroup } from '@univerjs/ui';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { createTestBed } from '../../__tests__/create-test-bed';
-import { OpenFindDialogOperation } from '../../commands/operations/find-replace.operation';
-import { FindReplaceMenuItemFactory } from '../find-replace.menu';
-import { menuSchema } from '../schema';
-
-describe('find-replace.menu', () => {
- let univer: Univer;
- let get: Injector['get'];
-
- beforeEach(() => {
- const testBed = createTestBed();
- univer = testBed.univer;
- get = testBed.get;
- });
-
- afterEach(() => {
- univer.dispose();
- });
-
- it('should build menu item and compute disabled state from context values', () => {
- const contextService = get(IContextService);
- contextService.setContextValue(EDITOR_ACTIVATED, false);
- contextService.setContextValue(FOCUSING_SHEET, true);
-
- const menuItem = FindReplaceMenuItemFactory({ get } as never);
- const states: boolean[] = [];
- const sub = menuItem.disabled$!.subscribe((value) => states.push(value));
-
- contextService.setContextValue(EDITOR_ACTIVATED, true);
- contextService.setContextValue(FOCUSING_SHEET, false);
- sub.unsubscribe();
-
- expect(menuItem.id).toBe(OpenFindDialogOperation.id);
- expect(menuItem.tooltip).toBe('find-replace.toolbar');
- expect(states[0]).toBe(false);
- expect(states).toContain(true);
- });
-
- it('should expose toolbar schema entry for open-find operation', () => {
- const schema = menuSchema as Record<string, Record<string, unknown>>;
- expect(schema[RibbonDataGroup.ORGANIZATION][OpenFindDialogOperation.id]).toEqual(
- expect.objectContaining({
- order: 2,
- menuItemFactory: FindReplaceMenuItemFactory,
- })
- );
- });
-});
diff --git a/packages/sheets-filter-ui/src/menu/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/menu/__tests__/sheets-filter.menu.spec.ts
deleted file mode 100644
index d4108eb7fa..0000000000
--- a/packages/sheets-filter-ui/src/menu/__tests__/sheets-filter.menu.spec.ts
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { IWorkbookData, Workbook } from '@univerjs/core';
-import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
-import {
- DisposableCollection,
- ICommandService,
- Inject,
- Injector,
- LocaleType,
- Plugin,
- Univer,
- UniverInstanceType,
-} from '@univerjs/core';
-import { SetWorksheetActiveOperation } from '@univerjs/sheets';
-import {
- RemoveSheetsFilterMutation,
- SetSheetsFilterCriteriaMutation,
- SetSheetsFilterRangeMutation,
- UniverSheetsFilterPlugin,
-} from '@univerjs/sheets-filter';
-import {
- IMenuManagerService,
- IPlatformService,
- IShortcutService,
- MenuManagerService,
- PlatformService,
- ShortcutService,
-} from '@univerjs/ui';
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
-import {
- ClearFilterCriteriaMenuItemFactory,
- ReCalcFilterMenuItemFactory,
- SmartToggleFilterMenuItemFactory,
-} from '../sheets-filter.menu';
-
-const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
- id: 'test',
- appVersion: '3.0.0-alpha',
- sheets: {
- sheet1: {
- id: 'sheet1',
- cellData: {
- 0: {
- 0: {
- v: 'A1',
- },
- },
- },
- },
- },
- locale: LocaleType.ZH_CN,
- name: '',
- sheetOrder: [],
- styles: {},
-};
-
-function createSheetsFilterMenuTestBed() {
- const univer = new Univer();
- const injector = univer.__getInjector();
- const get = injector.get.bind(injector);
-
- class TestPlugin extends Plugin {
- static override type = UniverInstanceType.UNIVER_SHEET;
- static override pluginName = 'test-plugin';
-
- constructor(
- _config: unknown,
- @Inject(Injector) override readonly _injector: Injector
- ) {
- super();
- }
-
- override onStarting(): void {
- const injector = this._injector;
- injector.add([IPlatformService, { useClass: PlatformService }]);
- injector.add([IShortcutService, { useClass: ShortcutService }]);
- injector.add([IMenuManagerService, { useClass: MenuManagerService }]);
-
- const commandService = injector.get(ICommandService);
- [
- OpenFilterPanelOperation,
- CloseFilterPanelOperation,
- ].forEach((command) => commandService.registerCommand(command));
- }
- }
-
- univer.registerPlugin(TestPlugin);
- univer.registerPlugin(UniverSheetsFilterPlugin);
-
- const sheet = univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, TEST_WORKBOOK_DATA_DEMO);
-
- return { univer, get, sheet };
-}
-
-describe('test sheet filter menu items', () => {
- let univer: Univer;
- let get: Injector['get'];
-
- let disposableCollection: DisposableCollection;
-
- let commandService: ICommandService;
-
- beforeEach(() => {
- const testBed = createSheetsFilterMenuTestBed();
-
- univer = testBed.univer;
- get = testBed.get;
-
- disposableCollection = new DisposableCollection();
-
- commandService = get(ICommandService);
-
- // Active sheet, prevent activeSheet from being initialized to null, causing activeFilterModel$ to also transmit null.
- expect(commandService.syncExecuteCommand(SetWorksheetActiveOperation.id, { unitId: 'test', subUnitId: 'sheet1' })).toBeTruthy();
- });
-
- afterEach(() => {
- univer.dispose();
-
- disposableCollection.dispose();
- });
-
- it('should "SmartToggleSheetsFilterMenu" change status correctly', () => {
- let activated = false;
-
- const menuItem = get(Injector).invoke(SmartToggleFilterMenuItemFactory);
- disposableCollection.add(menuItem.activated$!.subscribe((value) => (activated = value)));
- expect(activated).toBeFalsy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterRangeMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- range: { startRow: 0, startColumn: 0, endRow: 5, endColumn: 5 },
- } as ISetSheetsFilterRangeMutationParams)).toBeTruthy();
- expect(activated).toBeTruthy();
-
- expect(commandService.syncExecuteCommand(RemoveSheetsFilterMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- })).toBeTruthy();
- expect(activated).toBeFalsy();
- });
-
- it('should "ClearSheetsFilterCriteriaCommand" be enabled when there is filter criteria', () => {
- let disabled = false;
-
- const menuItem = get(Injector).invoke(ClearFilterCriteriaMenuItemFactory);
- disposableCollection.add(menuItem.disabled$!.subscribe((value) => (disabled = value)));
- expect(disabled).toBeTruthy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterRangeMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- range: { startRow: 0, startColumn: 0, endRow: 5, endColumn: 5 },
- } as ISetSheetsFilterRangeMutationParams)).toBeTruthy();
- expect(disabled).toBeTruthy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterCriteriaMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- col: 0,
- criteria: {
- colId: 0,
- filters: ['123'],
- },
- } as ISetSheetsFilterCriteriaMutationParams)).toBeTruthy();
- expect(disabled).toBeFalsy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterCriteriaMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- col: 0,
- criteria: null,
- } as ISetSheetsFilterCriteriaMutationParams)).toBeTruthy();
- expect(disabled).toBeTruthy();
- });
-
- it('should "ReCalcFilterMenuItemFactory" be enabled when there is filter criteria', () => {
- let disabled = false;
-
- const menuItem = get(Injector).invoke(ReCalcFilterMenuItemFactory);
- disposableCollection.add(menuItem.disabled$!.subscribe((value) => (disabled = value)));
- expect(disabled).toBeTruthy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterRangeMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- range: { startRow: 0, startColumn: 0, endRow: 5, endColumn: 5 },
- } as ISetSheetsFilterRangeMutationParams)).toBeTruthy();
- expect(disabled).toBeTruthy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterCriteriaMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- col: 0,
- criteria: {
- colId: 0,
- filters: ['123'],
- },
- } as ISetSheetsFilterCriteriaMutationParams)).toBeTruthy();
- expect(disabled).toBeFalsy();
-
- expect(commandService.syncExecuteCommand(SetSheetsFilterCriteriaMutation.id, {
- unitId: 'test',
- subUnitId: 'sheet1',
- col: 0,
- criteria: null,
- } as ISetSheetsFilterCriteriaMutationParams)).toBeTruthy();
- expect(disabled).toBeTruthy();
- });
-});
diff --git a/packages/sheets-hyper-link-ui/src/locale/zh-HK.ts b/packages/sheets-hyper-link-ui/src/locale/zh-HK.ts
index a6f22082d1..7cc72d5b51 100644
--- a/packages/sheets-hyper-link-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-hyper-link-ui/src/locale/zh-HK.ts
@@ -21,7 +21,7 @@ const locale: typeof enUS = {
form: {
editTitle: '編輯連結',
addTitle: '插入連結',
- label: '文本',
+ label: '文字',
labelPlaceholder: '輸入文字',
type: '類型',
link: '連結',
diff --git a/packages/sheets-hyper-link-ui/src/locale/zh-TW.ts b/packages/sheets-hyper-link-ui/src/locale/zh-TW.ts
index a6f22082d1..7cc72d5b51 100644
--- a/packages/sheets-hyper-link-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-hyper-link-ui/src/locale/zh-TW.ts
@@ -21,7 +21,7 @@ const locale: typeof enUS = {
form: {
editTitle: '編輯連結',
addTitle: '插入連結',
- label: '文本',
+ label: '文字',
labelPlaceholder: '輸入文字',
type: '類型',
link: '連結',
diff --git a/packages/sheets-note-ui/src/locale/zh-HK.ts b/packages/sheets-note-ui/src/locale/zh-HK.ts
index 12dd550f27..15eb87a34f 100644
--- a/packages/sheets-note-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-note-ui/src/locale/zh-HK.ts
@@ -22,7 +22,7 @@ const locale: typeof enUS = {
placeholder: '在此輸入',
},
rightClick: {
- addNote: '添加批註',
+ addNote: '新增批註',
deleteNote: '刪除批註',
toggleNote: '顯示/隱藏批註',
},
diff --git a/packages/sheets-note-ui/src/locale/zh-TW.ts b/packages/sheets-note-ui/src/locale/zh-TW.ts
index 12dd550f27..15eb87a34f 100644
--- a/packages/sheets-note-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-note-ui/src/locale/zh-TW.ts
@@ -22,7 +22,7 @@ const locale: typeof enUS = {
placeholder: '在此輸入',
},
rightClick: {
- addNote: '添加批註',
+ addNote: '新增批註',
deleteNote: '刪除批註',
toggleNote: '顯示/隱藏批註',
},
diff --git a/packages/sheets-table-ui/src/locale/ca-ES.ts b/packages/sheets-table-ui/src/locale/ca-ES.ts
index e03f4c32e4..7db916179c 100644
--- a/packages/sheets-table-ui/src/locale/ca-ES.ts
+++ b/packages/sheets-table-ui/src/locale/ca-ES.ts
@@ -43,9 +43,9 @@ const locale: typeof enUS = {
tablePrefix: 'Taula',
tableNameError: 'El nom de la taula no pot contenir espais, no pot començar amb un número i no pot ser idèntic a un nom de taula existent',
columnMenu: {
- 'insert-left': 'Insert 1 table column left',
- 'insert-right': 'Insert 1 table column right',
- delete: 'Delete table column',
+ 'insert-left': 'Insereix una columna de taula a l’esquerra',
+ 'insert-right': 'Insereix una columna de taula a la dreta',
+ delete: 'Suprimeix la columna de la taula',
},
sort: {
diff --git a/packages/sheets-table-ui/src/locale/zh-HK.ts b/packages/sheets-table-ui/src/locale/zh-HK.ts
index 28de7ff12f..d1147a5ca4 100644
--- a/packages/sheets-table-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-table-ui/src/locale/zh-HK.ts
@@ -20,28 +20,28 @@ const locale: typeof enUS = {
'sheets-table-ui': {
title: '表格',
selectRange: '選擇表格範圍',
- rename: '重命名表格',
+ rename: '重新命名表格',
renamePlaceholder: '輸入表格名稱',
updateRange: '更新表格範圍',
tableRangeWithMergeError: '表格範圍不能與合併儲存格重疊',
tableRangeWithOtherTableError: '表格範圍不能與其他表格重疊',
- tableRangeSingleRowError: '表格範圍不能是單獨的一行',
- updateError: '不能將表格範圍設置到和原先不重合且不在同一行的範圍',
+ tableRangeSingleRowError: '表格範圍不能只有一列',
+ updateError: '不能將表格範圍設定為與原範圍不重疊且不在同一列的範圍',
tableStyle: '表格樣式',
defaultStyle: '預設樣式',
- customStyle: '自定義樣式',
- customTooMore: '自定義主題數量超出最大限制,請刪除一些無用的主題後再次添加',
- setTheme: '設置表格主題',
+ customStyle: '自訂樣式',
+ customTooMore: '自訂主題數量超出上限,請刪除一些不需要的主題後再新增',
+ setTheme: '設定表格主題',
removeTable: '刪除表格',
cancel: '取消',
confirm: '確認',
header: '頁首',
footer: '頁尾',
- firstLine: '第一行',
- secondLine: '第二行',
- columnPrefix: '列',
+ firstLine: '第一列',
+ secondLine: '第二列',
+ columnPrefix: '欄',
tablePrefix: '表格',
- tableNameError: '表格名稱不能包含空格, 不能以數字開頭,不能和已有表格名稱重複',
+ tableNameError: '表格名稱不能包含空格、以數字開頭或與現有表格名稱重複',
columnMenu: {
'insert-left': '向左插入 1 個表格欄',
'insert-right': '向右插入 1 個表格欄',
@@ -55,14 +55,14 @@ const locale: typeof enUS = {
insert: {
main: '表格插入',
- row: '插入表格行',
- col: '插入表格列',
+ row: '插入表格列',
+ col: '插入表格欄',
},
remove: {
main: '表格刪除',
- row: '刪除表格行',
- col: '刪除表格列',
+ row: '刪除表格列',
+ col: '刪除表格欄',
},
condition: {
diff --git a/packages/sheets-table-ui/src/locale/zh-TW.ts b/packages/sheets-table-ui/src/locale/zh-TW.ts
index 28de7ff12f..d1147a5ca4 100644
--- a/packages/sheets-table-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-table-ui/src/locale/zh-TW.ts
@@ -20,28 +20,28 @@ const locale: typeof enUS = {
'sheets-table-ui': {
title: '表格',
selectRange: '選擇表格範圍',
- rename: '重命名表格',
+ rename: '重新命名表格',
renamePlaceholder: '輸入表格名稱',
updateRange: '更新表格範圍',
tableRangeWithMergeError: '表格範圍不能與合併儲存格重疊',
tableRangeWithOtherTableError: '表格範圍不能與其他表格重疊',
- tableRangeSingleRowError: '表格範圍不能是單獨的一行',
- updateError: '不能將表格範圍設置到和原先不重合且不在同一行的範圍',
+ tableRangeSingleRowError: '表格範圍不能只有一列',
+ updateError: '不能將表格範圍設定為與原範圍不重疊且不在同一列的範圍',
tableStyle: '表格樣式',
defaultStyle: '預設樣式',
- customStyle: '自定義樣式',
- customTooMore: '自定義主題數量超出最大限制,請刪除一些無用的主題後再次添加',
- setTheme: '設置表格主題',
+ customStyle: '自訂樣式',
+ customTooMore: '自訂主題數量超出上限,請刪除一些不需要的主題後再新增',
+ setTheme: '設定表格主題',
removeTable: '刪除表格',
cancel: '取消',
confirm: '確認',
header: '頁首',
footer: '頁尾',
- firstLine: '第一行',
- secondLine: '第二行',
- columnPrefix: '列',
+ firstLine: '第一列',
+ secondLine: '第二列',
+ columnPrefix: '欄',
tablePrefix: '表格',
- tableNameError: '表格名稱不能包含空格, 不能以數字開頭,不能和已有表格名稱重複',
+ tableNameError: '表格名稱不能包含空格、以數字開頭或與現有表格名稱重複',
columnMenu: {
'insert-left': '向左插入 1 個表格欄',
'insert-right': '向右插入 1 個表格欄',
@@ -55,14 +55,14 @@ const locale: typeof enUS = {
insert: {
main: '表格插入',
- row: '插入表格行',
- col: '插入表格列',
+ row: '插入表格列',
+ col: '插入表格欄',
},
remove: {
main: '表格刪除',
- row: '刪除表格行',
- col: '刪除表格列',
+ row: '刪除表格列',
+ col: '刪除表格欄',
},
condition: {
diff --git a/packages/sheets-ui/src/__tests__/plugin.spec.ts b/packages/sheets-ui/src/__tests__/plugin.spec.ts
deleted file mode 100644
index fc9479acd7..0000000000
--- a/packages/sheets-ui/src/__tests__/plugin.spec.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { IConfigService, IUniverInstanceService, Univer, UniverInstanceType } from '@univerjs/core';
-import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
-import { ComponentManager, IconManager } from '@univerjs/ui';
-import { describe, expect, it, vi } from 'vitest';
-import { UniverSheetsUIPlugin } from '../plugin';
-import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';
-
-describe('UniverSheetsUIPlugin', () => {
- it('registers basic render modules during Starting', () => {
- const univer = new Univer();
- const injector = univer.__getInjector();
- injector.add([ComponentManager]);
- injector.add([IconManager]);
- injector.add([IRenderManagerService, { useClass: RenderManagerService }]);
-
- const renderManagerService = injector.get(IRenderManagerService);
- const registerRenderModule = vi.spyOn(renderManagerService, 'registerRenderModule');
- const plugin = new UniverSheetsUIPlugin(
- undefined,
- injector,
- renderManagerService,
- injector.get(IConfigService),
- injector.get(IUniverInstanceService)
- );
-
- plugin.onStarting();
-
- expect(registerRenderModule).toHaveBeenCalledWith(
- UniverInstanceType.UNIVER_SHEET,
- [SheetSkeletonManagerService]
- );
-
- univer.dispose();
- });
-});
diff --git a/packages/sheets-ui/src/locale/zh-CN.ts b/packages/sheets-ui/src/locale/zh-CN.ts
index ad37212355..3d4ffa80f6 100644
--- a/packages/sheets-ui/src/locale/zh-CN.ts
+++ b/packages/sheets-ui/src/locale/zh-CN.ts
@@ -347,7 +347,7 @@ const locale: typeof enUS = {
inputRangePlaceholder: '请输入范围(必填)',
inputFormulaPlaceholder: '请输入公式(必填)',
formulaOrRefStringInvalid: '公式或引用字符串无效',
- defaultName: 'DefinedName',
+ defaultName: '定义名称',
updateButton: '修改',
deleteButton: '删除',
deleteConfirmText: '确定删除定义名称?',
diff --git a/packages/sheets-ui/src/locale/zh-HK.ts b/packages/sheets-ui/src/locale/zh-HK.ts
index fe49c95472..1862350fa1 100644
--- a/packages/sheets-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-ui/src/locale/zh-HK.ts
@@ -259,7 +259,7 @@ const locale: typeof enUS = {
copy: '副本',
return: '返回',
rename: '重新命名',
- tips: '重命名',
+ tips: '重新命名',
noName: '未命名的試算表',
wait: '待更新',
add: '新增',
@@ -347,7 +347,7 @@ const locale: typeof enUS = {
inputRangePlaceholder: '請輸入範圍(必填)',
inputFormulaPlaceholder: '請輸入公式(必填)',
formulaOrRefStringInvalid: '公式或引用字串無效',
- defaultName: 'DefinedName',
+ defaultName: '定義名稱',
updateButton: '修改',
deleteButton: '刪除',
deleteConfirmText: '確定刪除定義名稱? ',
@@ -429,7 +429,7 @@ const locale: typeof enUS = {
setCellStyle: '設定儲存格樣式',
copy: '複製',
alert: '提示',
- search: '搜索',
+ search: '搜尋',
ownerInherit: '文檔所有者,已開啟權限繼承',
ownerWithoutInherit: '文檔所有者,未開啟權限繼承',
alertContent: '該範圍已被保護,目前無編輯權限。如需編輯,請聯絡創建者。 ',
diff --git a/packages/sheets-ui/src/locale/zh-TW.ts b/packages/sheets-ui/src/locale/zh-TW.ts
index fe49c95472..1862350fa1 100644
--- a/packages/sheets-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-ui/src/locale/zh-TW.ts
@@ -259,7 +259,7 @@ const locale: typeof enUS = {
copy: '副本',
return: '返回',
rename: '重新命名',
- tips: '重命名',
+ tips: '重新命名',
noName: '未命名的試算表',
wait: '待更新',
add: '新增',
@@ -347,7 +347,7 @@ const locale: typeof enUS = {
inputRangePlaceholder: '請輸入範圍(必填)',
inputFormulaPlaceholder: '請輸入公式(必填)',
formulaOrRefStringInvalid: '公式或引用字串無效',
- defaultName: 'DefinedName',
+ defaultName: '定義名稱',
updateButton: '修改',
deleteButton: '刪除',
deleteConfirmText: '確定刪除定義名稱? ',
@@ -429,7 +429,7 @@ const locale: typeof enUS = {
setCellStyle: '設定儲存格樣式',
copy: '複製',
alert: '提示',
- search: '搜索',
+ search: '搜尋',
ownerInherit: '文檔所有者,已開啟權限繼承',
ownerWithoutInherit: '文檔所有者,未開啟權限繼承',
alertContent: '該範圍已被保護,目前無編輯權限。如需編輯,請聯絡創建者。 ',
diff --git a/packages/sheets/src/locale/zh-CN.ts b/packages/sheets/src/locale/zh-CN.ts
index e5b35105a8..f3515ce921 100644
--- a/packages/sheets/src/locale/zh-CN.ts
+++ b/packages/sheets/src/locale/zh-CN.ts
@@ -35,7 +35,7 @@ const locale: typeof enUS = {
nameSheetConflict: '名称与工作表名称冲突',
formulaOrRefStringEmpty: '公式或引用字符串不能为空',
nameConflict: '名称与函数名称冲突',
- defaultName: 'DefinedName',
+ defaultName: '定义名称',
},
permission: {
dialog: {
diff --git a/packages/sheets/src/locale/zh-HK.ts b/packages/sheets/src/locale/zh-HK.ts
index 2dad37a925..7a085af8fe 100644
--- a/packages/sheets/src/locale/zh-HK.ts
+++ b/packages/sheets/src/locale/zh-HK.ts
@@ -35,7 +35,7 @@ const locale: typeof enUS = {
nameSheetConflict: '名稱與工作表名稱衝突',
formulaOrRefStringEmpty: '公式或引用字串不能為空',
nameConflict: '名稱與函數名稱衝突',
- defaultName: 'DefinedName',
+ defaultName: '定義名稱',
},
permission: {
dialog: {
diff --git a/packages/sheets/src/locale/zh-TW.ts b/packages/sheets/src/locale/zh-TW.ts
index 2dad37a925..7a085af8fe 100644
--- a/packages/sheets/src/locale/zh-TW.ts
+++ b/packages/sheets/src/locale/zh-TW.ts
@@ -35,7 +35,7 @@ const locale: typeof enUS = {
nameSheetConflict: '名稱與工作表名稱衝突',
formulaOrRefStringEmpty: '公式或引用字串不能為空',
nameConflict: '名稱與函數名稱衝突',
- defaultName: 'DefinedName',
+ defaultName: '定義名稱',
},
permission: {
dialog: {
diff --git a/packages/slides-ui/src/locale/zh-HK.ts b/packages/slides-ui/src/locale/zh-HK.ts
index 8a0f84917c..2c045f6067 100644
--- a/packages/slides-ui/src/locale/zh-HK.ts
+++ b/packages/slides-ui/src/locale/zh-HK.ts
@@ -18,7 +18,7 @@ import type enUS from './en-US';
const locale: typeof enUS = {
'slides-ui': {
- append: '新增幻灯片',
+ append: '新增投影片',
text: {
insert: {
diff --git a/packages/slides-ui/src/locale/zh-TW.ts b/packages/slides-ui/src/locale/zh-TW.ts
index 8a0f84917c..2c045f6067 100644
--- a/packages/slides-ui/src/locale/zh-TW.ts
+++ b/packages/slides-ui/src/locale/zh-TW.ts
@@ -18,7 +18,7 @@ import type enUS from './en-US';
const locale: typeof enUS = {
'slides-ui': {
- append: '新增幻灯片',
+ append: '新增投影片',
text: {
insert: {
diff --git a/packages/ui/src/menu/__tests__/history.menu.spec.ts b/packages/ui/src/menu/__tests__/history.menu.spec.ts
deleted file mode 100644
index 7aa3cdf136..0000000000
--- a/packages/ui/src/menu/__tests__/history.menu.spec.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * 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 { IAccessor } from '@univerjs/core';
-import {
- EDITOR_ACTIVATED,
- FOCUSING_FX_BAR_EDITOR,
- IContextService,
- IUndoRedoService,
- LocaleService,
-} from '@univerjs/core';
-import { BehaviorSubject, Subject } from 'rxjs';
-import { describe, expect, it } from 'vitest';
-import { RedoMenuItemFactory, UndoMenuItemFactory } from '../history.menu';
-
-function createAccessor() {
- const undoRedoStatus$ = new BehaviorSubject({ undos: 1, redos: 1 });
- const contextChanged$ = new Subject<void>();
- const direction$ = new BehaviorSubject<'ltr' | 'rtl'>('ltr');
- const contextStore: Record<string, boolean> = {
- [EDITOR_ACTIVATED]: false,
- [FOCUSING_FX_BAR_EDITOR]: false,
- };
-
- const undoRedoService = { undoRedoStatus$ };
- const contextService = {
- contextChanged$,
- getContextValue: (key: string) => contextStore[key] ?? false,
- };
- const localeService = { direction$ };
-
- const accessor = {
- get: (token: unknown) => {
- if (token === IUndoRedoService) return undoRedoService;
- if (token === IContextService) return contextService;
- if (token === LocaleService) return localeService;
- throw new Error('Unknown token');
- },
- } as unknown as IAccessor;
-
- return { accessor, undoRedoStatus$, contextChanged$, contextStore, direction$ };
-}
-
-describe('menus controller factories', () => {
- it('should toggle undo disabled state by status and editor context', () => {
- const { accessor, undoRedoStatus$, contextChanged$, contextStore } = createAccessor();
- const item = UndoMenuItemFactory(accessor);
- const values: boolean[] = [];
- const sub = item.disabled$!.subscribe((v) => values.push(v));
-
- expect(values.at(-1)).toBe(false);
-
- undoRedoStatus$.next({ undos: 0, redos: 1 });
- expect(values.at(-1)).toBe(true);
-
- contextStore[EDITOR_ACTIVATED] = true;
- contextChanged$.next();
- undoRedoStatus$.next({ undos: 2, redos: 1 });
- expect(values.at(-1)).toBe(true);
-
- contextStore[EDITOR_ACTIVATED] = false;
- contextStore[FOCUSING_FX_BAR_EDITOR] = false;
- contextChanged$.next();
- undoRedoStatus$.next({ undos: 3, redos: 1 });
- expect(values.at(-1)).toBe(false);
-
- sub.unsubscribe();
- });
-
- it('should toggle redo disabled state by status and fx bar context', () => {
- const { accessor, undoRedoStatus$, contextChanged$, contextStore } = createAccessor();
- const item = RedoMenuItemFactory(accessor);
- const values: boolean[] = [];
- const sub = item.disabled$!.subscribe((v) => values.push(v));
-
- expect(values.at(-1)).toBe(false);
-
- undoRedoStatus$.next({ undos: 1, redos: 0 });
- expect(values.at(-1)).toBe(true);
-
- contextStore[FOCUSING_FX_BAR_EDITOR] = true;
- contextChanged$.next();
- undoRedoStatus$.next({ undos: 1, redos: 3 });
- expect(values.at(-1)).toBe(true);
-
- contextStore[FOCUSING_FX_BAR_EDITOR] = false;
- contextChanged$.next();
- undoRedoStatus$.next({ undos: 1, redos: 4 });
- expect(values.at(-1)).toBe(false);
-
- sub.unsubscribe();
- });
-});