Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: fix RTL layout issues in sheet UI components (#7187)
白熱0ecbd3de1d4b
diff --git a/packages/sheets-ui/src/views/defined-name/DefinedName.tsx b/packages/sheets-ui/src/views/defined-name/DefinedName.tsxindex 2078d09eec..16dc59e01d 100644--- a/packages/sheets-ui/src/views/defined-name/DefinedName.tsx+++ b/packages/sheets-ui/src/views/defined-name/DefinedName.tsx@@ -18,16 +18,42 @@ import type { Workbook, Worksheet } from '@univerjs/core';import type { IDefinedNamesServiceParam } from '@univerjs/engine-formula';import type { ChangeEvent, KeyboardEvent } from 'react';import type { IScrollToCellCommandParams } from '../../commands/commands/set-scroll.command';-import { debounce, generateRandomId, ICommandService, IUniverInstanceService, ThemeService, UniverInstanceType } from '@univerjs/core';+import {+ debounce,+ generateRandomId,+ ICommandService,+ IUniverInstanceService,+ ThemeService,+ UniverInstanceType,+} from '@univerjs/core';import { borderRightClassName, clsx, Dropdown } from '@univerjs/design';-import { deserializeRangeWithSheet, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder } from '@univerjs/engine-formula';+import {+ deserializeRangeWithSheet,+ IDefinedNamesService,+ IFunctionService,+ ISuperTableService,+ LexerTreeBuilder,+} from '@univerjs/engine-formula';import { MoreDownIcon } from '@univerjs/icons';-import { getPrimaryForRange, InsertDefinedNameCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetSelectionsOperation, SetWorksheetShowCommand, SheetPermissionCheckController, SheetsSelectionsService, WorkbookEditablePermission } from '@univerjs/sheets';+import {+ getPrimaryForRange,+ InsertDefinedNameCommand,+ SCOPE_WORKBOOK_VALUE_DEFINED_NAME,+ SetSelectionsOperation,+ SetWorksheetShowCommand,+ SheetPermissionCheckController,+ SheetsSelectionsService,+ WorkbookEditablePermission,+} from '@univerjs/sheets';import { ILayoutService, useDependency } from '@univerjs/ui';import { useEffect, useRef, useState } from 'react';import { ScrollToCellCommand } from '../../commands/commands/set-scroll.command';import { genNormalSelectionStyle } from '../../services/selection/const';-import { DefinedNameBoxActionType, getAbsoluteRefStringFromSelection, resolveDefinedNameBoxAction } from '../../services/utils/defined-name-utils';+import {+ DefinedNameBoxActionType,+ getAbsoluteRefStringFromSelection,+ resolveDefinedNameBoxAction,+} from '../../services/utils/defined-name-utils';import { DefinedNameOverlay } from './DefinedNameOverlay';export function DefinedName({ disable }: { disable: boolean }) {@@ -273,6 +299,7 @@ export function DefinedName({ disable }: { disable: boolean }) {univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5univer-text-gray-900focus:univer-outline-none+ rtl:univer-pl-5 rtl:univer-pr-1.5dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white`, borderRightClassName, {'univer-cursor-not-allowed': disable,@@ -300,6 +327,7 @@ export function DefinedName({ disable }: { disable: boolean }) {univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointeruniver-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200hover:univer-bg-gray-100+ rtl:univer-left-0 rtl:univer-right-autodark:!univer-text-whitedark:hover:!univer-bg-gray-800`, {diff --git a/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx b/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsxindex 02b79a147f..6dcbf3dab1 100644--- a/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx+++ b/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx@@ -32,6 +32,7 @@ export function DefinedNameOverlay({ search, isInputEvent }: { search: string; iconst definedNamesService = useDependency(IDefinedNamesService);const univerInstanceService = useDependency(IUniverInstanceService);const sidebarService = useDependency(ISidebarService);+ const direction = localeService.getDirection();const workbook = univerInstanceService.getCurrentUnitOfType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;const unitId = workbook.getUnitId();@@ -106,7 +107,14 @@ export function DefinedNameOverlay({ search, isInputEvent }: { search: string; i};return (- <div className="univer-w-[300px]">+ <div+ data-u-comp="defined-name-overlay"+ dir={direction}+ className="+ univer-w-[300px]+ rtl:univer-text-right+ "+ ><divref={listContainerRef}className={clsx('univer-max-h-[360px] univer-min-h-0 univer-overflow-y-auto', scrollbarClassName, {@@ -127,14 +135,18 @@ export function DefinedNameOverlay({ search, isInputEvent }: { search: string; ionClick={() => { focusDefinedName(definedName); }}><div+ data-u-comp="defined-name-overlay-row"className={clsx(`- univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1+ univer-flex univer-items-center univer-gap-2 univer-py-1+ rtl:univer-flex-row-reverse`, borderBottomClassName)}><div+ data-u-comp="defined-name-overlay-name"className={`- univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-sm+ univer-min-w-0 univer-flex-1 univer-basis-0 univer-truncate univer-text-smuniver-text-gray-600+ rtl:univer-text-rightdark:!univer-text-gray-200`}title={definedName.name}@@ -142,9 +154,11 @@ export function DefinedNameOverlay({ search, isInputEvent }: { search: string; i{definedName.name}</div><div+ data-u-comp="defined-name-overlay-reference"className={`- univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-xs+ univer-min-w-0 univer-flex-1 univer-basis-0 univer-truncate univer-text-xsuniver-text-gray-400+ rtl:univer-text-right`}title={definedName.formulaOrRefString}>@@ -157,9 +171,11 @@ export function DefinedNameOverlay({ search, isInputEvent }: { search: string; i</div></div><div+ data-u-comp="defined-name-overlay-footer"className={`univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200hover:univer-bg-gray-100+ rtl:univer-text-rightdark:hover:!univer-bg-gray-600`}onClick={openSlider}diff --git a/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx b/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsxindex e12e8e0a3f..4f768ad032 100644--- a/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx@@ -51,7 +51,11 @@ export const SheetBar = () => {const workbookCreateSheetPermission = useObservable(permissionService.getPermissionPoint$(new WorkbookCreateSheetPermission(unitId)?.id));const config = useConfigValue<IUniverSheetsUIConfig>(SHEETS_UI_PLUGIN_CONFIG_KEY);- const { show: addSheetButtonShow = true, defaultRowCount = DEFAULT_WORKSHEET_ROW_COUNT, defaultColumnCount = DEFAULT_WORKSHEET_COLUMN_COUNT } = (config?.footer || {}).addSheetButtonConfig || {};+ const {+ show: addSheetButtonShow = true,+ defaultRowCount = DEFAULT_WORKSHEET_ROW_COUNT,+ defaultColumnCount = DEFAULT_WORKSHEET_COLUMN_COUNT,+ } = (config?.footer || {}).addSheetButtonConfig || {};const updateScrollButtonState = (state: IScrollState) => {const { leftEnd, rightEnd } = state;@@ -113,10 +117,13 @@ export const SheetBar = () => {{/* Scroll arrows */}{(!leftScrollState || !rightScrollState) && (<div+ data-u-comp="sheet-bar-scroll-buttons"className={`univer-relative univer-flex univer-items-center univer-px-2after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-h-4 after:univer-w-pxafter:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[""]+ rtl:univer-flex-row-reverse+ rtl:after:univer-left-0 rtl:after:univer-right-auto`}><SheetBarButton disabled={leftScrollState} onClick={handleScrollLeft}>diff --git a/packages/ui/src/views/components/ribbon/Ribbon.tsx b/packages/ui/src/views/components/ribbon/Ribbon.tsxindex fcb8010019..ee4ea0d591 100644--- a/packages/ui/src/views/components/ribbon/Ribbon.tsx+++ b/packages/ui/src/views/components/ribbon/Ribbon.tsx@@ -220,8 +220,9 @@ export function Ribbon(props: IRibbonProps) {{headerMenu && (headerMenuComponents && headerMenuComponents.size > 0) && (<divclassName={`- univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center- univer-gap-2+ univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-flex-row+ univer-items-center univer-gap-2+ rtl:univer-left-2 rtl:univer-right-auto[&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded[&>*]:univer-px-1 [&>*]:univer-transition-colorshover:[&>*]:univer-bg-gray-100@@ -252,7 +253,10 @@ export function Ribbon(props: IRibbonProps) {<divdata-u-comp="ribbon-toolbar"ref={containerRef}- className={clsx('univer-flex univer-overflow-hidden', divideXClassName, {+ className={clsx(`+ univer-flex univer-overflow-hidden+ rtl:univer-divide-x-reverse+ `, divideXClassName, {'univer-justify-center': ribbonType === 'classic',})}role="toolbar"