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: improve RTL and locale-sensitive UI rendering (#7211)

白熱7b9803a655c7
diff --git a/e2e/thread-comment/thread-comment-editing.spec.ts b/e2e/thread-comment/thread-comment-editing.spec.ts
deleted file mode 100644
index 8ca0e5439f..0000000000
--- a/e2e/thread-comment/thread-comment-editing.spec.ts
+++ /dev/null
@@ -1,174 +0,0 @@
-import type { Locator, Page } from '@playwright/test';
-import { expect, test } from '@playwright/test';
-import { generateSnapshotName } from '../visual-comparison/const';
-
-test.use({ viewport: { width: 1400, height: 900 } });
-
-const DOC_INITIAL_COMMENT = 'doc e2e comment';
-const DOC_UPDATED_COMMENT = 'doc e2e comment updated';
-const SHEET_INITIAL_COMMENT = 'sheet e2e comment';
-const SHEET_UPDATED_COMMENT = 'sheet e2e comment updated';
-
-function collectPageErrors(page: Page) {
- const errors: string[] = [];
-
- page.on('pageerror', (error) => {
- errors.push(error.stack || error.message);
- });
-
- return errors;
-}
-
-async function waitForUniverCanvas(page: Page) {
- await page.waitForFunction(() => document.querySelectorAll('canvas').length > 0, undefined, { timeout: 30_000 });
-}
-
-async function waitForE2EController(page: Page) {
- await page.waitForFunction(() => Boolean(window.E2EControllerAPI), undefined, { timeout: 30_000 });
-}
-
-async function getCommentEditorText(page: Page) {
- return page.evaluate(() => {
- const univer = window.univer;
- if (!univer?.__getInjector) {
- return null;
- }
-
- const injector = univer.__getInjector();
- const editorServiceToken = [...injector.dependencyCollection.dependencyMap.keys()]
- .find((token) => String(token) === 'univer.editor.service');
- if (!editorServiceToken) {
- return null;
- }
-
- const editorService = injector.get(editorServiceToken);
- const editors = editorService.getAllEditor();
- const editorList = Array.isArray(editors)
- ? editors
- : editors instanceof Map
- ? [...editors.values()]
- : [...editors];
- const commentEditor = editorList.find((editor) => String(editor.getEditorId?.() || editor.getId?.()).includes('COMMENT_EDITOR'));
- const dataStream = commentEditor?.getDocumentData?.().body?.dataStream;
-
- return typeof dataStream === 'string' ? dataStream.replace(/\r\n$/, '') : null;
- });
-}
-
-async function expectCommentEditorText(page: Page, text: string) {
- await expect.poll(() => getCommentEditorText(page), { timeout: 5_000 }).toBe(text);
-}
-
-async function getThreadCommentCardId(page: Page, commentText: string) {
- const id = await page.evaluate((text) => {
- const commentCard = [...document.querySelectorAll<HTMLElement>('[id^="PANEL-"]')]
- .find((element) => element.textContent?.includes(text));
-
- return commentCard?.id ?? null;
- }, commentText);
-
- expect(id).not.toBeNull();
-
- return id!;
-}
-
-async function clickThreadMoreMenu(page: Page, commentText: string) {
- const cardId = await getThreadCommentCardId(page, commentText);
- const card = page.locator(`[id="${cardId}"]`);
-
- await card.locator('[class*="univer-cursor-pointer"]').last().click();
-
- return card;
-}
-
-async function maskDynamicCommentCardHeader(card: Locator) {
- await card.evaluate((element) => {
- if (element.querySelector('[data-e2e-comment-card-header-mask]')) {
- return;
- }
-
- const mask = document.createElement('div');
- mask.dataset.e2eCommentCardHeaderMask = 'true';
- Object.assign(mask.style, {
- position: 'absolute',
- top: '0',
- left: '0',
- right: '0',
- height: '44px',
- background: '#ff00ff',
- pointerEvents: 'none',
- zIndex: '2147483647',
- });
- element.append(mask);
- });
-}
-
-async function editCommentFromThread(page: Page, originalText: string, updatedText: string, locale: 'zh' | 'en', snapshotName?: string) {
- const card = await clickThreadMoreMenu(page, originalText);
- await page.getByText(locale === 'zh' ? '编辑' : 'Edit', { exact: true }).last().click();
-
- await expectCommentEditorText(page, originalText);
- if (snapshotName) {
- await maskDynamicCommentCardHeader(card);
- await expect(card).toHaveScreenshot(generateSnapshotName(snapshotName), {
- maxDiffPixels: 100,
- mask: [card.locator('time')],
- });
- }
-
- await page.keyboard.type(' updated');
- await expectCommentEditorText(page, updatedText);
- await page.getByRole('button', { name: locale === 'zh' ? '保存' : 'Save' }).last().click();
- await expect(page.getByText(updatedText).first()).toBeVisible({ timeout: 5_000 });
-
- await clickThreadMoreMenu(page, updatedText);
- await page.getByText(locale === 'zh' ? '编辑' : 'Edit', { exact: true }).last().click();
- await expectCommentEditorText(page, updatedText);
-}
-
-test('docs comment keeps content visible while editing, saves, and edits again', async ({ page }) => {
- const errors = collectPageErrors(page);
-
- await page.goto('/docs/');
- await waitForE2EController(page);
- await page.evaluate(() => window.E2EControllerAPI.loadDefaultDoc());
- await waitForUniverCanvas(page);
- await page.waitForTimeout(2_000);
-
- await page.mouse.move(370, 195);
- await page.mouse.down();
- await page.mouse.move(740, 195, { steps: 20 });
- await page.mouse.up();
- await page.locator('[data-u-command="docs.operation.start-add-comment"]').last().click();
-
- await page.mouse.click(1220, 285);
- await page.keyboard.type(DOC_INITIAL_COMMENT);
- await page.getByRole('button', { name: '回复' }).last().click();
- await expect(page.getByText(DOC_INITIAL_COMMENT)).toBeVisible({ timeout: 5_000 });
-
- await editCommentFromThread(page, DOC_INITIAL_COMMENT, DOC_UPDATED_COMMENT, 'zh', 'doc-comment-editing');
-
- expect(errors).toEqual([]);
-});
-
-test('sheets comment keeps content visible while editing, saves, and edits again', async ({ page }) => {
- const errors = collectPageErrors(page);
-
- await page.goto('/sheets/');
- await waitForE2EController(page);
- await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet());
- await waitForUniverCanvas(page);
- await page.waitForTimeout(2_000);
- await page.evaluate(async (commentText) => {
- const workbook = window.univerAPI.getActiveWorkbook();
- const worksheet = workbook.getActiveSheet();
- const range = worksheet.getRange('A1');
- await range.addCommentAsync(window.univerAPI.newTheadComment().setContent(window.univerAPI.newRichText().insertText(commentText)));
- await window.univerAPI.executeCommand('sheet.operation.toggle-comment-panel');
- }, SHEET_INITIAL_COMMENT);
-
- await expect(page.getByText(SHEET_INITIAL_COMMENT)).toBeVisible({ timeout: 5_000 });
- await editCommentFromThread(page, SHEET_INITIAL_COMMENT, SHEET_UPDATED_COMMENT, 'en', 'sheet-comment-editing');
-
- expect(errors).toEqual([]);
-});
diff --git a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-chromium-linux.png b/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-chromium-linux.png
deleted file mode 100644
index 555745d8f9..0000000000
Binary files a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-chromium-linux.png and /dev/null differ
diff --git a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-ci-chromium-linux.png b/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-ci-chromium-linux.png
deleted file mode 100644
index c9c4f5e14a..0000000000
Binary files a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/doc-comment-editing-ci-chromium-linux.png and /dev/null differ
diff --git a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-chromium-linux.png b/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-chromium-linux.png
deleted file mode 100644
index 460c95c066..0000000000
Binary files a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-chromium-linux.png and /dev/null differ
diff --git a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-ci-chromium-linux.png b/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-ci-chromium-linux.png
deleted file mode 100644
index 44d0639f17..0000000000
Binary files a/e2e/thread-comment/thread-comment-editing.spec.ts-snapshots/sheet-comment-editing-ci-chromium-linux.png and /dev/null differ
diff --git a/packages/design/src/components/input/Input.tsx b/packages/design/src/components/input/Input.tsx
index e902b8245b..a34aee0597 100644
--- a/packages/design/src/components/input/Input.tsx
+++ b/packages/design/src/components/input/Input.tsx
@@ -126,10 +126,12 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
if (allowClear && !(slot && slotRef.current)) setPaddingRight(26);
}, []); // only enough for init, otherwise it works again when you click it
- const shouldOmitDefaultPaddingRight = direction === 'rtl' && paddingRight === 0;
- const mergedInputStyle = shouldOmitDefaultPaddingRight
+ const shouldOmitDefaultPadding = direction === 'rtl' && paddingRight === 0;
+ const mergedInputStyle = shouldOmitDefaultPadding
? inputStyle
- : { ...inputStyle, paddingRight };
+ : direction === 'rtl'
+ ? { ...inputStyle, paddingLeft: paddingRight }
+ : { ...inputStyle, paddingRight };
return (
<div
@@ -151,7 +153,7 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
univer-cursor-not-allowed univer-bg-gray-50 univer-text-gray-400
dark:!univer-text-gray-500
`,
- (allowClear && !slot) && 'univer-pr-8',
+ (allowClear && !slot) && (direction === 'rtl' ? 'univer-pl-8' : 'univer-pr-8'),
inputClass
)}
placeholder={placeholder}
@@ -168,10 +170,10 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
/>
{hasSlotContent && (
<div
- className={`
- univer-absolute univer-right-2 univer-flex univer-items-center univer-gap-1
- univer-rounded-full
- `}
+ className={clsx(
+ 'univer-absolute univer-flex univer-items-center univer-gap-1 univer-rounded-full',
+ direction === 'rtl' ? 'univer-left-2' : 'univer-right-2'
+ )}
ref={slotRef}
>
{slot}
diff --git a/packages/design/src/components/input/__tests__/index.spec.tsx b/packages/design/src/components/input/__tests__/index.spec.tsx
index a137923398..770ff2e970 100644
--- a/packages/design/src/components/input/__tests__/index.spec.tsx
+++ b/packages/design/src/components/input/__tests__/index.spec.tsx
@@ -131,6 +131,53 @@ describe('Input', () => {
}
});
+ it('should observe slot mutations and apply slot paddingLeft in rtl', () => {
+ const observe = vi.fn();
+ class MockMutationObserver {
+ private _callback: MutationCallback;
+
+ constructor(callback: MutationCallback) {
+ this._callback = callback;
+ }
+
+ observe(...args: unknown[]) {
+ observe(...args);
+ this._callback([], {} as MutationObserver);
+ }
+
+ disconnect() {
+ }
+ }
+
+ vi.stubGlobal('MutationObserver', MockMutationObserver);
+
+ const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
+ Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
+ configurable: true,
+ get() {
+ return 20;
+ },
+ });
+
+ const { container } = render(
+ <ConfigProvider mountContainer={document.body} direction="rtl">
+ <Input value="x" slot={<span>slot</span>} />
+ </ConfigProvider>
+ );
+ const input = container.querySelector('input') as HTMLInputElement;
+ const slot = container.querySelector('[data-u-comp="input"] > div') as HTMLDivElement;
+
+ expect(observe).toHaveBeenCalled();
+ expect(input.style.paddingLeft).toBe('28px');
+ expect(input.style.paddingRight).toBe('');
+ expect(slot.className).toContain('univer-left-2');
+ expect(slot.className).not.toContain('univer-right-2');
+
+ if (originalOffsetWidth) {
+ Object.defineProperty(HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);
+ }
+ });
+
it('should set default allowClear padding when no slot exists', () => {
const { container } = render(<Input allowClear value="x" />);
const input = container.querySelector('input') as HTMLInputElement;
diff --git a/packages/docs-ui/package.json b/packages/docs-ui/package.json
index 32ed42fa13..7877f02013 100644
--- a/packages/docs-ui/package.json
+++ b/packages/docs-ui/package.json
@@ -88,7 +88,6 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@univerjs/drawing": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/icons": "1.19.0",
"@univerjs/ui": "workspace:*"
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/ar-SA.ts b/packages/sheets-conditional-formatting-ui/src/locale/ar-SA.ts
index f15f169df3..f893d4c061 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/ar-SA.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/ar-SA.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'و',
when: 'عندما',
onlyShowIcon: 'إظهار الأيقونة فقط',
+ noCellIcon: 'بدون أيقونة خلية',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/ca-ES.ts b/packages/sheets-conditional-formatting-ui/src/locale/ca-ES.ts
index 4789d38370..1485b324cd 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/ca-ES.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/ca-ES.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'I',
when: 'Quan',
onlyShowIcon: 'Mostra només la icona',
+ noCellIcon: 'Sense icona de cel·la',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/de-DE.ts b/packages/sheets-conditional-formatting-ui/src/locale/de-DE.ts
index 018904fa78..162fcb1616 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/de-DE.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/de-DE.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'Und',
when: 'Wenn',
onlyShowIcon: 'Nur Symbol anzeigen',
+ noCellIcon: 'Kein Zellsymbol',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts b/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts
index d219bf863c..ff7e4b8552 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/en-US.ts
@@ -44,6 +44,7 @@ const locale = {
and: 'And',
when: 'When',
onlyShowIcon: 'Only Show Icon',
+ noCellIcon: 'No Cell Icon',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/es-ES.ts b/packages/sheets-conditional-formatting-ui/src/locale/es-ES.ts
index 3867be9996..500d8bbbd2 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/es-ES.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/es-ES.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'Y',
when: 'Cuando',
onlyShowIcon: 'Mostrar solo icono',
+ noCellIcon: 'Sin icono de celda',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/fa-IR.ts b/packages/sheets-conditional-formatting-ui/src/locale/fa-IR.ts
index 8d96656e73..554399d0fd 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/fa-IR.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/fa-IR.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'و',
when: 'هنگامی که',
onlyShowIcon: 'فقط نمایش آیکون',
+ noCellIcon: 'بدون نماد سلول',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/fr-FR.ts b/packages/sheets-conditional-formatting-ui/src/locale/fr-FR.ts
index d932ad13a4..9087e89f69 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/fr-FR.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/fr-FR.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'Et',
when: 'Quand',
onlyShowIcon: 'Afficher uniquement l\'icône',
+ noCellIcon: 'Aucune icône de cellule',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/id-ID.ts b/packages/sheets-conditional-formatting-ui/src/locale/id-ID.ts
index b39c5065da..94f9a5ea9d 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/id-ID.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/id-ID.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'Dan',
when: 'Ketika',
onlyShowIcon: 'Tampilkan Ikon Saja',
+ noCellIcon: 'Tanpa Ikon Sel',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/it-IT.ts b/packages/sheets-conditional-formatting-ui/src/locale/it-IT.ts
index f169fbd556..67d54d4a07 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/it-IT.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/it-IT.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'E',
when: 'Quando',
onlyShowIcon: 'Mostra Solo Icona',
+ noCellIcon: 'Nessuna icona cella',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/ja-JP.ts b/packages/sheets-conditional-formatting-ui/src/locale/ja-JP.ts
index 375bb3d42d..a351009620 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/ja-JP.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/ja-JP.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'かつ',
when: '次の場合',
onlyShowIcon: 'アイコンのみ表示',
+ noCellIcon: 'セル アイコンなし',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/ko-KR.ts b/packages/sheets-conditional-formatting-ui/src/locale/ko-KR.ts
index b0ac2bceb9..3a2f3063cc 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/ko-KR.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/ko-KR.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: '그리고',
when: '조건',
onlyShowIcon: '아이콘만 표시',
+ noCellIcon: '셀 아이콘 없음',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/pl-PL.ts b/packages/sheets-conditional-formatting-ui/src/locale/pl-PL.ts
index 8748d2457e..5fce84eafd 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/pl-PL.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/pl-PL.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'I',
when: 'Gdy',
onlyShowIcon: 'Pokaż tylko ikonę',
+ noCellIcon: 'Brak ikony komórki',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/pt-BR.ts b/packages/sheets-conditional-formatting-ui/src/locale/pt-BR.ts
index 8dd4ecf4f1..3885f66356 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/pt-BR.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/pt-BR.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'E',
when: 'Quando',
onlyShowIcon: 'Mostrar Apenas Ícone',
+ noCellIcon: 'Sem ícone de célula',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/ru-RU.ts b/packages/sheets-conditional-formatting-ui/src/locale/ru-RU.ts
index 84d5353efe..474c2d62be 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/ru-RU.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/ru-RU.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'И',
when: 'Когда',
onlyShowIcon: 'Показывать только иконку',
+ noCellIcon: 'Без значка ячейки',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/sk-SK.ts b/packages/sheets-conditional-formatting-ui/src/locale/sk-SK.ts
index a0cb38e87d..b1d9fc0590 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/sk-SK.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/sk-SK.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: 'A',
when: 'Keď',
onlyShowIcon: 'Zobraziť iba ikonu',
+ noCellIcon: 'Bez ikony bunky',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/vi-VN.ts b/packages/sheets-conditional-formatting-ui/src/locale/vi-VN.ts
index 02d5b803a8..e23db01a91 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/vi-VN.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/vi-VN.ts
@@ -45,6 +45,7 @@ const locale: typeof enUS = {
and: 'Và',
when: 'Khi giá trị',
onlyShowIcon: 'Chỉ hiển thị biểu tượng',
+ noCellIcon: 'Không có biểu tượng ô',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts b/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts
index aaa41d2ca3..c404cf2185 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/zh-CN.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: '且',
when: '当值',
onlyShowIcon: '仅显示图标',
+ noCellIcon: '无单元格图标',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/zh-HK.ts b/packages/sheets-conditional-formatting-ui/src/locale/zh-HK.ts
index dee2a89472..6e1d9a8dbe 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/zh-HK.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/zh-HK.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: '且',
when: '當值',
onlyShowIcon: '僅顯示圖示',
+ noCellIcon: '無儲存格圖示',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/locale/zh-TW.ts b/packages/sheets-conditional-formatting-ui/src/locale/zh-TW.ts
index dee2a89472..6e1d9a8dbe 100644
--- a/packages/sheets-conditional-formatting-ui/src/locale/zh-TW.ts
+++ b/packages/sheets-conditional-formatting-ui/src/locale/zh-TW.ts
@@ -46,6 +46,7 @@ const locale: typeof enUS = {
and: '且',
when: '當值',
onlyShowIcon: '僅顯示圖示',
+ noCellIcon: '無儲存格圖示',
},
symbol: {
greaterThan: '>',
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
index 0c5f9188a4..c8961c525a 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/ColorScale.tsx
@@ -34,7 +34,7 @@ const createOptionItem = (text: string, localeService: LocaleService) => ({
value: text,
});
-const TextInput = (props: { id: string; type: CFValueType | 'none'; value: number | string; onChange: (v: number | string) => void; className: string }) => {
+const TextInput = (props: { id: string; type: CFValueType | 'none'; value: number | string; onChange: (v: number | string) => void; className?: string }) => {
const { type, className, onChange, value } = props;
const univerInstanceService = useDependency(IUniverInstanceService);
const unitId = univerInstanceService.getCurrentUnitOfType<Workbook>(UniverInstanceType.UNIVER_SHEET)!.getUnitId();
@@ -247,7 +247,7 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
>
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.valueType.min')}
</div>
- <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center">
+ <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2">
<Select
className="univer-flex-shrink-0"
options={minOptions}
@@ -316,7 +316,7 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
>
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.panel.medianValue')}
</div>
- <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center">
+ <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2">
<Select
className="univer-flex-shrink-0"
options={medianOptions}
@@ -389,7 +389,7 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
>
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.valueType.max')}
</div>
- <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center">
+ <div className="univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2">
<Select
className="univer-flex-shrink-0"
options={maxOptions}
@@ -413,7 +413,6 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
/>
<TextInput
id="max"
- className="univer-ml-1"
value={maxValue}
type={maxType}
onChange={(v) => {
@@ -432,7 +431,6 @@ export const ColorScaleStyleEditor = (props: IStyleEditorProps) => {
}}
/>
<ColorPicker
- className="univer-ml-1"
color={maxColor}
onChange={(v) => {
setMaxColor(v);
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/IconSet.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/IconSet.tsx
index 0518999f7a..634850d9a9 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/IconSet.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/IconSet.tsx
@@ -35,7 +35,7 @@ import {
IIconSetType,
} from '@univerjs/sheets-conditional-formatting';
import { FormulaEditor } from '@univerjs/sheets-formula-ui';
-import { ILayoutService, useDependency, useScrollYOverContainer, useSidebarClick } from '@univerjs/ui';
+import { ILayoutService, useDependency, useObservable, useScrollYOverContainer, useSidebarClick } from '@univerjs/ui';
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
const getIcon = (iconType: IIconSetType, iconId: string | number) => {
@@ -117,12 +117,13 @@ interface IIconGroupListProps {
const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, ref) => {
const { onClick } = props;
const localeService = useDependency(LocaleService);
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
const handleClick = (iconType: IIconSetType) => {
onClick(iconType);
};
return (
- <div ref={ref} className="univer-w-80">
+ <div ref={ref} dir={direction} className="univer-w-80">
{iconGroup.map((group, index) => {
return (
<div key={index} className="univer-mb-3">
@@ -134,7 +135,10 @@ const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, re
return (
<div
key={groupItem.name}
- className="univer-mb-1 univer-flex univer-w-1/2 univer-items-center"
+ className="
+ univer-mb-1 univer-flex univer-w-1/2 univer-items-center
+ rtl:univer-flex-row-reverse rtl:univer-justify-end
+ "
onClick={() => { handleClick(groupItem.name); }}
>
<a
@@ -157,7 +161,6 @@ const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, re
);
})}
</div>
-
</div>
);
})}
@@ -167,6 +170,8 @@ const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, re
const IconItemList = (props: { onClick: (iconType: IIconSetType, iconId: string) => void; iconType?: IIconSetType; iconId: string }) => {
const { onClick } = props;
+ const localeService = useDependency(LocaleService);
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
const list = useMemo(() => {
const result: { iconType: IIconSetType; iconId: string; base64: string }[] = [];
@@ -189,21 +194,25 @@ const IconItemList = (props: { onClick: (iconType: IIconSetType, iconId: string)
};
return (
- <div>
+ <div dir={direction}>
<div
- className="univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1"
+ data-u-comp="cf-icon-set-no-icon-option"
+ className="
+ univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-text-sm
+ "
onClick={() => handleClick({ iconType: IIconSetType.empty, iconId: '', base64: '' })}
>
- <SlashDoubleIcon className="univer-size-5" />
- <span className="univer-ml-2">无单元格图标</span>
+ {localeService.t<LocaleKey>('sheets-conditional-formatting-ui.iconSet.noCellIcon')}
</div>
- <div className="univer-flex univer-w-64 univer-flex-wrap">
+ <div
+ className="univer-flex univer-w-64 univer-flex-wrap univer-gap-2"
+ >
{list.map((item) => (
<div
key={`${item.iconType}_${item.iconId}`}
className={`
- univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center
- univer-justify-center univer-rounded
+ univer-mb-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center
+ univer-rounded
hover:univer-bg-gray-100
dark:hover:!univer-bg-gray-700
`}
@@ -322,7 +331,13 @@ const IconSetRuleEdit = (props: {
</>
</div>
</div>
- <div className="univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4">
+ <div
+ data-u-comp="cf-icon-set-rule-grid"
+ className="
+ univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4
+ rtl:univer-grid-flow-dense
+ "
+ >
<div className="univer-flex univer-items-center">
<Dropdown
overlay={(
@@ -418,6 +433,7 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {
const { interceptorManager } = props;
const rule = props.rule?.type === CFRuleType.iconSet ? props.rule : undefined;
const localeService = useDependency(LocaleService);
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
const [errorMap, setErrorMap] = useState<Record<string, string>>({});
const [currentIconType, setCurrentIconType] = useState<IIconSetType>(() => {
const defaultV = Object.keys(iconMap)[0] as IIconSetType;
@@ -463,7 +479,13 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {
return getIcon(item.iconType, item.iconId);
});
return (
- <div className="univer-flex univer-items-center">
+ <div
+ data-u-comp="cf-icon-set-preview"
+ className="
+ univer-flex univer-items-center
+ rtl:univer-flex-row-reverse
+ "
+ >
{list.map((icon, index) => (icon
? (
<img
@@ -575,14 +597,14 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {
useScrollYOverContainer(iconGroupListEl, layoutService.rootContainerElement);
return (
- <div>
+ <div data-u-comp="cf-icon-set-editor" dir={direction}>
<div className="univer-mt-4 univer-text-sm univer-text-gray-600">
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.panel.styleRule')}
</div>
<div className="univer-mt-3">
<Dropdown
overlay={(
- <div className="univer-rounded-lg univer-p-4">
+ <div dir={direction} className="univer-rounded-lg univer-p-4">
<IconGroupList
ref={(el) => {
!iconGroupListEl && el && setIconGroupListEl(el);
@@ -606,12 +628,23 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {
</div>
</Dropdown>
</div>
- <div className="univer-mt-3 univer-flex univer-items-center univer-gap-3 univer-text-xs">
- <div className="univer-flex univer-items-center univer-text-xs">
+ <div
+ className="
+ univer-mt-3 univer-flex univer-items-center univer-gap-2 univer-text-xs
+ rtl:univer-flex-row-reverse rtl:univer-justify-end
+ "
+ >
+ <div
+ data-u-comp="cf-icon-set-option-row"
+ className="univer-flex univer-items-center univer-text-xs"
+ >
<Checkbox onChange={reverseIcon} />
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.iconSet.reverseIconOrder')}
</div>
- <div className="univer-flex univer-items-center univer-text-xs">
+ <div
+ data-u-comp="cf-icon-set-option-row"
+ className="univer-flex univer-items-center univer-text-xs"
+ >
<Checkbox checked={!isShowValue} onChange={(v) => { setIsShowValue(!v); }} />
{localeService.t<LocaleKey>('sheets-conditional-formatting-ui.iconSet.onlyShowIcon')}
</div>
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/Rank.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/Rank.tsx
index 6da4a02e26..62159ce285 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/Rank.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/Rank.tsx
@@ -165,7 +165,7 @@ export const RankStyleEditor = (props: IStyleEditorProps) => {
}}
/>
{['isNotBottom', 'isBottom'].includes(type) && (
- <div className="univer-mt-3 univer-flex univer-items-center">
+ <div className="univer-mt-3 univer-flex univer-items-center univer-gap-2">
<InputNumber
min={1}
max={1000}
@@ -177,7 +177,7 @@ export const RankStyleEditor = (props: IStyleEditorProps) => {
}}
/>
<div
- className="univer-ml-3 univer-flex univer-items-center univer-text-xs"
+ className="univer-flex univer-items-center univer-text-xs"
>
<Checkbox
checked={isPercent}
diff --git a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
index 52ec1cb9d1..35c90f7b00 100644
--- a/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/views/panel/rule-edit/__tests__/RuleEditors.spec.tsx
@@ -35,6 +35,7 @@ import { createRoot } from 'react-dom/client';
import { Subject } from 'rxjs';
import { afterEach, describe, expect, it } from 'vitest';
import { createCfUiTestBed } from '../../../../__tests__/create-cf-ui-test-bed';
+import enUS from '../../../../locale/en-US';
import { ColorScaleStyleEditor } from '../ColorScale';
import { DataBarStyleEditor } from '../DataBar';
import { FormulaStyleEditor } from '../Formula';
@@ -114,7 +115,7 @@ function createEditorTestBed() {
testBed.injector.add([IShortcutService, { useClass: TestShortcutService as never }]);
testBed.injector.add([IContextMenuService, { useClass: TestContextMenuService as never }]);
testBed.injector.add([LexerTreeBuilder]);
- testBed.get(LocaleService).load({ [LocaleType.ZH_CN]: {} });
+ testBed.get(LocaleService).load({ [LocaleType.EN_US]: enUS, [LocaleType.ZH_CN]: {} });
return testBed;
}
@@ -158,6 +159,17 @@ async function selectOption(selectIndex: number, optionText: string) {
option.dispatchEvent(new MouseEvent('click', { bubbles: true }));
}
+async function openDropdown(dropdownIndex: number) {
+ const dropdown = Array.from(document.querySelectorAll<HTMLElement>('[data-slot="popover-trigger"]'))[dropdownIndex];
+ if (!dropdown) {
+ throw new Error(`Dropdown ${dropdownIndex} was not rendered`);
+ }
+
+ dropdown.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0 }));
+ dropdown.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ await Promise.resolve();
+}
+
describe('conditional formatting rule editors', () => {
let root: Root | undefined;
let container: HTMLDivElement | undefined;
diff --git a/packages/thread-comment-ui/src/views/ThreadCommentTree.tsx b/packages/thread-comment-ui/src/views/ThreadCommentTree.tsx
index c22f6abfb6..01e1e8e0e1 100644
--- a/packages/thread-comment-ui/src/views/ThreadCommentTree.tsx
+++ b/packages/thread-comment-ui/src/views/ThreadCommentTree.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IUser, UniverInstanceType } from '@univerjs/core';
+import type { IUser, LocaleType, UniverInstanceType } from '@univerjs/core';
import type { IAddCommentCommandParams, IThreadComment, IUpdateCommentCommandParams } from '@univerjs/thread-comment';
import type { IUniverUIConfig } from '@univerjs/ui';
import type { LocaleKey } from '../locale/types';
import type { IThreadCommentEditorInstance } from './ThreadCommentEditor';
-import { generateRandomId, ICommandService, LocaleService, UserManagerService } from '@univerjs/core';
+import { dateKit, generateRandomId, ICommandService, LOCALE_META, LocaleService, UserManagerService } from '@univerjs/core';
import { borderClassName, clsx, Dropdown, scrollbarClassName, Tooltip } from '@univerjs/design';
import { DeleteIcon, MoreHorizontalIcon, ReplyToCommentIcon, SuccessIcon, SuccessOutlineIcon } from '@univerjs/icons';
import {
@@ -85,6 +85,20 @@ export interface IThreadCommentItemProps {
const MOCK_ID = '__mock__';
+function formatCommentDateTime(value: string, locale: LocaleType): string {
+ const date = dateKit(value);
+ const localeTag = LOCALE_META[locale].tag;
+
+ return date.formatIntl(localeTag, {
+ year: 'numeric',
+ month: 'numeric',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: false,
+ });
+}
+
const ThreadCommentItem = (props: IThreadCommentItemProps) => {
const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment, type, threadCommentEditorId } = props;
const commandService = useDependency(ICommandService);
@@ -97,6 +111,8 @@ const ThreadCommentItem = (props: IThreadCommentItemProps) => {
const [showReply, setShowReply] = useState(false);
const uiConfig = useConfigValue<IUniverUIConfig>(UI_PLUGIN_CONFIG_KEY);
const avatarFallback = uiConfig?.avatarFallback;
+ const currentLocale = useObservable(localeService.currentLocale$, localeService.getCurrentLocale());
+ const dateText = formatCommentDateTime(item.dT, currentLocale);
const handleDeleteItem = () => {
if (onDeleteComment?.(item) === false) {
@@ -117,11 +133,19 @@ const ThreadCommentItem = (props: IThreadCommentItemProps) => {
};
return (
- <div className="univer-relative univer-mb-3 univer-pl-[30px]" onMouseLeave={() => setShowReply(false)} onMouseEnter={() => setShowReply(true)}>
+ <div
+ className="
+ univer-relative univer-mb-3 univer-pl-[30px]
+ rtl:univer-pl-0 rtl:univer-pr-[30px]
+ "
+ onMouseLeave={() => setShowReply(false)}
+ onMouseEnter={() => setShowReply(true)}
+ >
<div
className={`
univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover
univer-bg-center univer-bg-no-repeat
+ rtl:univer-left-auto rtl:univer-right-0
`}
style={{
backgroundImage: `url(${user?.avatar || avatarFallback})`,
@@ -145,6 +169,7 @@ const ThreadCommentItem = (props: IThreadCommentItemProps) => {
univer-items-center univer-justify-center univer-rounded-sm
univer-text-base
hover:univer-bg-gray-50
+ rtl:univer-ml-0 rtl:univer-mr-1
dark:hover:!univer-bg-gray-800
`}
onClick={() => onReply(user)}
@@ -194,6 +219,7 @@ const ThreadCommentItem = (props: IThreadCommentItemProps) => {
univer-items-center univer-justify-center univer-rounded-sm
univer-text-base
hover:univer-bg-gray-50
+ rtl:univer-ml-0 rtl:univer-mr-1
dark:hover:!univer-bg-gray-800
`}
>
@@ -207,12 +233,13 @@ const ThreadCommentItem = (props: IThreadCommentItemProps) => {
)
: null}
<time
+ dir="ltr"
className={`
- univer-mb-1 univer-text-xs/normal univer-text-gray-600
+ univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600
dark:!univer-text-gray-200
`}
>
- {item.dT}
+ {dateText}
</time>
{editing
? (
@@ -421,6 +448,7 @@ export const ThreadCommentTree = (props: IThreadCommentTreeProps) => {
className={`
univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0
univer-rounded-sm univer-bg-yellow-500
+ rtl:univer-ml-2 rtl:univer-mr-0
`}
/>
<Tooltip showIfEllipsis title={title}>
@@ -438,6 +466,7 @@ export const ThreadCommentTree = (props: IThreadCommentTreeProps) => {
univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center
univer-justify-center univer-rounded-[3px] univer-text-base
hover:univer-bg-gray-50
+ rtl:univer-ml-0 rtl:univer-mr-1
dark:hover:!univer-bg-gray-800
`, {
'univer-text-green-500': resolved,
@@ -453,6 +482,7 @@ export const ThreadCommentTree = (props: IThreadCommentTreeProps) => {
univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer
univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
hover:univer-bg-gray-50
+ rtl:univer-ml-0 rtl:univer-mr-1
dark:hover:!univer-bg-gray-800
`}
onClick={handleDeleteRoot}
diff --git a/packages/thread-comment-ui/src/views/thread-comment-panel/__tests__/index.spec.tsx b/packages/thread-comment-ui/src/views/thread-comment-panel/__tests__/index.spec.tsx
index 6e161c3a58..f1cab20b75 100644
--- a/packages/thread-comment-ui/src/views/thread-comment-panel/__tests__/index.spec.tsx
+++ b/packages/thread-comment-ui/src/views/thread-comment-panel/__tests__/index.spec.tsx
@@ -34,6 +34,7 @@ import {
LifecycleService,
LifecycleStages,
LocaleService,
+ LocaleType,
LogLevel,
toDisposable,
UniverInstanceType,
@@ -78,9 +79,16 @@ interface IEditorRecord {
}
class TestLocaleService {
+ private readonly _currentLocale$ = new BehaviorSubject<LocaleType>(LocaleType.ZH_CN);
+ readonly currentLocale$ = this._currentLocale$.asObservable();
+
t(key: string) {
return key;
}
+
+ getCurrentLocale() {
+ return this._currentLocale$.getValue();
+ }
}
class TestEditor {
diff --git a/packages/thread-comment-ui/src/views/thread-comment-tree/__tests__/index.spec.tsx b/packages/thread-comment-ui/src/views/thread-comment-tree/__tests__/index.spec.tsx
index 993d240fe6..c5771cdbdc 100644
--- a/packages/thread-comment-ui/src/views/thread-comment-tree/__tests__/index.spec.tsx
+++ b/packages/thread-comment-ui/src/views/thread-comment-tree/__tests__/index.spec.tsx
@@ -24,6 +24,7 @@ import {
ConfigService,
ContextService,
createIdentifier,
+ dateKit,
DesktopLogService,
ICommandService,
IConfigService,
@@ -33,7 +34,9 @@ import {
IUniverInstanceService,
LifecycleService,
LifecycleStages,
+ LOCALE_META,
LocaleService,
+ LocaleType,
LogLevel,
toDisposable,
UniverInstanceType,
@@ -89,9 +92,20 @@ class TestState {
}
class TestLocaleService {
+ private readonly _currentLocale$ = new BehaviorSubject<LocaleType>(LocaleType.ZH_CN);
+ readonly currentLocale$ = this._currentLocale$.asObservable();
+
t(key: string) {
return key;
}
+
+ setLocale(locale: LocaleType) {
+ this._currentLocale$.next(locale);
+ }
+
+ getCurrentLocale() {
+ return this._currentLocale$.getValue();
+ }
}
class TestEditor {
@@ -521,6 +535,57 @@ describe('ThreadCommentTree', () => {
container = undefined;
});
+ it('provides mirrored layout hooks for RTL comment rows', () => {
+ const testBed = createTreeTestBed();
+ addRootComment(testBed.threadCommentModel, createComment({ id: 'root-thread', ref: 'A1', dT: '2026/07/07 20:35' }));
+
+ const rendered = renderDefaultTree(testBed.injector, 'root-thread');
+ root = rendered.root;
+ container = rendered.container;
+
+ const tree = getTree(container, 'root-thread');
+ const header = tree.firstElementChild as HTMLElement;
+ const titleAccent = header.firstElementChild?.firstElementChild as HTMLElement;
+ const resolveAction = getResolveAction(container, 'root-thread');
+ const item = getRootCommentItem(container, 'root-thread');
+ const avatar = item.firstElementChild as HTMLElement;
+ const time = item.querySelector('time');
+
+ expect(titleAccent.className).toContain('rtl:univer-ml-2');
+ expect(titleAccent.className).toContain('rtl:univer-mr-0');
+ expect(resolveAction.className).toContain('rtl:univer-ml-0');
+ expect(resolveAction.className).toContain('rtl:univer-mr-1');
+ expect(item.className).toContain('rtl:univer-pl-0');
+ expect(item.className).toContain('rtl:univer-pr-[30px]');
+ expect(avatar.className).toContain('rtl:univer-left-auto');
+ expect(avatar.className).toContain('rtl:univer-right-0');
+ expect(time?.getAttribute('dir')).toBe('ltr');
+ });
+
+ it('formats comment timestamps with dateKit intl using the current locale', () => {
+ const testBed = createTreeTestBed();
+ const rawDate = '2026/07/07 20:35';
+ testBed.injector.get(LocaleService).setLocale(LocaleType.EN_US);
+ addRootComment(testBed.threadCommentModel, createComment({ id: 'root-thread', ref: 'A1', dT: rawDate }));
+
+ const rendered = renderDefaultTree(testBed.injector, 'root-thread');
+ root = rendered.root;
+ container = rendered.container;
+
+ const time = getRootCommentItem(container, 'root-thread').querySelector('time');
+ const expected = dateKit(rawDate).formatIntl(LOCALE_META[LocaleType.EN_US].tag, {
+ year: 'numeric',
+ month: 'numeric',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: false,
+ });
+
+ expect(time?.textContent).toBe(expected);
+ expect(time?.textContent).not.toBe(rawDate);
+ });
+
it('adds a reply through the tree editor and stores it under the root thread', async () => {
const testBed = createTreeTestBed();
addRootComment(testBed.threadCommentModel, createComment({ id: 'root-thread', ref: 'A1' }));
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ea4578caaa..c9fe10693e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1259,9 +1259,6 @@ importers:
'@univerjs/docs':
specifier: workspace:*
version: link:../docs
- '@univerjs/drawing':
- specifier: workspace:*
- version: link:../drawing
'@univerjs/engine-render':
specifier: workspace:*
version: link:../engine-render
@@ -14311,8 +14308,8 @@ snapshots:
'@typescript-eslint/[email protected]([email protected])':
dependencies:
- '@typescript-eslint/tsconfig-utils': 8.56.1([email protected])
- '@typescript-eslint/types': 8.56.1
+ '@typescript-eslint/tsconfig-utils': 8.63.0([email protected])
+ '@typescript-eslint/types': 8.63.0
debug: 4.4.3
typescript: 6.0.3
transitivePeerDependencies: