2025-04-27 17:00:41 +08:00
|
|
|
import { Toaster as Sonner } from '@/components/ui/sonner';
|
|
|
|
|
import { Toaster } from '@/components/ui/toaster';
|
2026-04-03 16:50:18 +08:00
|
|
|
import { changeLanguageAsync } from '@/locales/config';
|
2024-07-19 09:07:36 +08:00
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
2025-12-26 12:11:19 +08:00
|
|
|
import { configResponsive } from 'ahooks';
|
2024-04-16 19:06:47 +08:00
|
|
|
import dayjs from 'dayjs';
|
2026-03-13 18:04:54 +08:00
|
|
|
import 'dayjs/locale/ar';
|
2026-03-18 16:09:32 +03:00
|
|
|
import 'dayjs/locale/tr';
|
2026-03-13 18:04:54 +08:00
|
|
|
import 'dayjs/locale/zh-cn';
|
2024-04-16 19:06:47 +08:00
|
|
|
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
|
|
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
|
|
|
import localeData from 'dayjs/plugin/localeData';
|
|
|
|
|
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
|
|
|
import weekYear from 'dayjs/plugin/weekYear';
|
2024-06-05 10:46:06 +08:00
|
|
|
import weekday from 'dayjs/plugin/weekday';
|
2026-03-27 19:24:52 +08:00
|
|
|
import React, { useEffect } from 'react';
|
2026-01-04 19:14:20 +08:00
|
|
|
import { RouterProvider } from 'react-router';
|
2026-03-27 19:24:52 +08:00
|
|
|
import { ThemeProvider } from './components/theme-provider';
|
2025-01-15 14:39:33 +08:00
|
|
|
import { TooltipProvider } from './components/ui/tooltip';
|
2025-07-31 12:14:00 +08:00
|
|
|
import { ThemeEnum } from './constants/common';
|
2026-01-04 19:14:20 +08:00
|
|
|
import { routers } from './routes';
|
2024-07-25 14:38:17 +08:00
|
|
|
import storage from './utils/authorization-util';
|
2024-04-16 19:06:47 +08:00
|
|
|
|
2025-12-26 12:11:19 +08:00
|
|
|
import 'react-photo-view/dist/react-photo-view.css';
|
2025-12-25 15:54:07 +08:00
|
|
|
|
|
|
|
|
configResponsive({
|
|
|
|
|
sm: 640,
|
|
|
|
|
md: 768,
|
|
|
|
|
lg: 1024,
|
|
|
|
|
xl: 1280,
|
|
|
|
|
'2xl': 1536,
|
|
|
|
|
'3xl': 1780,
|
|
|
|
|
'4xl': 1980,
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-16 19:06:47 +08:00
|
|
|
dayjs.extend(customParseFormat);
|
|
|
|
|
dayjs.extend(advancedFormat);
|
|
|
|
|
dayjs.extend(weekday);
|
|
|
|
|
dayjs.extend(localeData);
|
|
|
|
|
dayjs.extend(weekOfYear);
|
|
|
|
|
dayjs.extend(weekYear);
|
|
|
|
|
|
2025-05-30 12:14:44 +08:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2026-01-04 19:14:20 +08:00
|
|
|
import('@welldone-software/why-did-you-render').then(
|
|
|
|
|
(whyDidYouRenderModule) => {
|
|
|
|
|
const whyDidYouRender = whyDidYouRenderModule.default;
|
|
|
|
|
whyDidYouRender(React, {
|
|
|
|
|
trackAllPureComponents: true,
|
|
|
|
|
trackExtraHooks: [],
|
2026-04-09 18:51:45 +08:00
|
|
|
logOnDifferentValues: false,
|
2026-02-06 16:20:52 +08:00
|
|
|
exclude: [/^RouterProvider$/],
|
2026-01-04 19:14:20 +08:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
2025-05-30 12:14:44 +08:00
|
|
|
}
|
2026-02-13 18:40:41 +08:00
|
|
|
|
2026-02-05 15:53:20 +08:00
|
|
|
const queryClient = new QueryClient({
|
|
|
|
|
defaultOptions: {
|
|
|
|
|
queries: {
|
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
|
retry: 2,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
2024-06-05 10:46:06 +08:00
|
|
|
|
2024-12-10 10:42:04 +07:00
|
|
|
function Root({ children }: React.PropsWithChildren) {
|
|
|
|
|
return (
|
Feature rtl support (#13118)
### What problem does this PR solve?
This PR adds comprehensive **Right-to-Left (RTL) language support**,
primarily targeting Arabic and other RTL scripts (Hebrew, Persian, Urdu,
etc.).
Previously, RTL content had multiple rendering issues:
- Incorrect sentence splitting for Arabic punctuation in citation logic
- Misaligned text in chat messages and markdown components
- Improper positioning of blockquotes and “think” sections
- Incorrect table alignment
- Citation placement ambiguity in RTL prompts
- UI layout inconsistencies when mixing LTR and RTL text
This PR introduces backend and frontend improvements to properly detect,
render, and style RTL content while preserving existing LTR behavior.
#### Backend
- Updated sentence boundary regex in `rag/nlp/search.py` to include
Arabic punctuation:
- `،` (comma)
- `؛` (semicolon)
- `؟` (question mark)
- `۔` (Arabic full stop)
- Ensures citation insertion works correctly in RTL sentences.
- Updated citation prompt instructions to clarify citation placement
rules for RTL languages.
#### Frontend
- Introduced a new utility: `text-direction.ts`
- Detects text direction based on Unicode ranges.
- Supports Arabic, Hebrew, Syriac, Thaana, and related scripts.
- Provides `getDirAttribute()` for automatic `dir` assignment.
- Applied dynamic `dir` attributes across:
- Markdown rendering
- Chat messages
- Search results
- Tables
- Hover cards and reference popovers
- Added proper RTL styling in LESS:
- Text alignment adjustments
- Blockquote border flipping
- Section indentation correction
- Table direction switching
- Use of `<bdi>` for figure labels to prevent bidirectional conflicts
#### DevOps / Environment
- Added Windows backend launch script with retry handling.
- Updated dependency metadata.
- Adjusted development-only React debugging behavior.
---
### Type of change
- [x] Bug Fix (non-breaking change which fixes RTL rendering and
citation issues)
- [x] New Feature (non-breaking change which adds RTL detection and
dynamic direction handling)
---------
Co-authored-by: 6ba3i <isbaaoui09@gmail.com>
Co-authored-by: Ahmad Intisar <ahmadintisar@Ahmads-MacBook-M4-Pro.local>
Co-authored-by: Ahmad Intisar <168020872+ahmadintisar@users.noreply.github.com>
Co-authored-by: Liu An <asiro@qq.com>
2026-03-02 08:03:44 +03:00
|
|
|
<>
|
2026-03-27 19:24:52 +08:00
|
|
|
{children}
|
2026-03-05 20:47:29 +08:00
|
|
|
|
2026-03-27 19:24:52 +08:00
|
|
|
<Sonner position="top-right" expand richColors closeButton />
|
2026-03-05 20:47:29 +08:00
|
|
|
|
2026-03-27 19:24:52 +08:00
|
|
|
<Toaster />
|
Feature rtl support (#13118)
### What problem does this PR solve?
This PR adds comprehensive **Right-to-Left (RTL) language support**,
primarily targeting Arabic and other RTL scripts (Hebrew, Persian, Urdu,
etc.).
Previously, RTL content had multiple rendering issues:
- Incorrect sentence splitting for Arabic punctuation in citation logic
- Misaligned text in chat messages and markdown components
- Improper positioning of blockquotes and “think” sections
- Incorrect table alignment
- Citation placement ambiguity in RTL prompts
- UI layout inconsistencies when mixing LTR and RTL text
This PR introduces backend and frontend improvements to properly detect,
render, and style RTL content while preserving existing LTR behavior.
#### Backend
- Updated sentence boundary regex in `rag/nlp/search.py` to include
Arabic punctuation:
- `،` (comma)
- `؛` (semicolon)
- `؟` (question mark)
- `۔` (Arabic full stop)
- Ensures citation insertion works correctly in RTL sentences.
- Updated citation prompt instructions to clarify citation placement
rules for RTL languages.
#### Frontend
- Introduced a new utility: `text-direction.ts`
- Detects text direction based on Unicode ranges.
- Supports Arabic, Hebrew, Syriac, Thaana, and related scripts.
- Provides `getDirAttribute()` for automatic `dir` assignment.
- Applied dynamic `dir` attributes across:
- Markdown rendering
- Chat messages
- Search results
- Tables
- Hover cards and reference popovers
- Added proper RTL styling in LESS:
- Text alignment adjustments
- Blockquote border flipping
- Section indentation correction
- Table direction switching
- Use of `<bdi>` for figure labels to prevent bidirectional conflicts
#### DevOps / Environment
- Added Windows backend launch script with retry handling.
- Updated dependency metadata.
- Adjusted development-only React debugging behavior.
---
### Type of change
- [x] Bug Fix (non-breaking change which fixes RTL rendering and
citation issues)
- [x] New Feature (non-breaking change which adds RTL detection and
dynamic direction handling)
---------
Co-authored-by: 6ba3i <isbaaoui09@gmail.com>
Co-authored-by: Ahmad Intisar <ahmadintisar@Ahmads-MacBook-M4-Pro.local>
Co-authored-by: Ahmad Intisar <168020872+ahmadintisar@users.noreply.github.com>
Co-authored-by: Liu An <asiro@qq.com>
2026-03-02 08:03:44 +03:00
|
|
|
</>
|
2024-12-10 10:42:04 +07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const RootProvider = ({ children }: React.PropsWithChildren) => {
|
2024-04-07 17:41:29 +08:00
|
|
|
useEffect(() => {
|
2024-04-08 10:41:03 +08:00
|
|
|
const lng = storage.getLanguage();
|
|
|
|
|
if (lng) {
|
2026-03-02 19:10:11 +08:00
|
|
|
void changeLanguageAsync(lng);
|
2024-04-08 10:41:03 +08:00
|
|
|
}
|
|
|
|
|
}, []);
|
2024-01-29 15:02:27 +08:00
|
|
|
|
2024-04-02 15:44:09 +08:00
|
|
|
return (
|
2025-01-15 14:39:33 +08:00
|
|
|
<TooltipProvider>
|
|
|
|
|
<QueryClientProvider client={queryClient}>
|
2025-07-31 12:14:00 +08:00
|
|
|
<ThemeProvider
|
2025-10-14 19:06:50 +08:00
|
|
|
defaultTheme={ThemeEnum.Dark}
|
2025-07-31 12:14:00 +08:00
|
|
|
storageKey="ragflow-ui-theme"
|
|
|
|
|
>
|
2025-01-15 14:39:33 +08:00
|
|
|
<Root>{children}</Root>
|
|
|
|
|
</ThemeProvider>
|
|
|
|
|
</QueryClientProvider>
|
|
|
|
|
</TooltipProvider>
|
2024-03-20 18:20:42 +08:00
|
|
|
);
|
2024-04-07 17:41:29 +08:00
|
|
|
};
|
2026-01-04 19:14:20 +08:00
|
|
|
|
2026-02-06 16:20:52 +08:00
|
|
|
const RouterProviderWrapper: React.FC<{ router: typeof routers }> = ({
|
|
|
|
|
router,
|
|
|
|
|
}) => {
|
|
|
|
|
return <RouterProvider router={router}></RouterProvider>;
|
|
|
|
|
};
|
|
|
|
|
RouterProviderWrapper.whyDidYouRender = false;
|
|
|
|
|
|
2026-01-04 19:14:20 +08:00
|
|
|
export default function AppContainer() {
|
|
|
|
|
return (
|
|
|
|
|
<RootProvider>
|
2026-02-06 16:20:52 +08:00
|
|
|
<RouterProviderWrapper router={routers} />
|
2026-01-04 19:14:20 +08:00
|
|
|
</RootProvider>
|
|
|
|
|
);
|
2024-01-29 15:02:27 +08:00
|
|
|
}
|