🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat: ChatInput support resize (#9215)
CanisMinor5e814e017df3
diff --git a/locales/ar/editor.json b/locales/ar/editor.jsonindex 305de166b95..b2202e34730 100644--- a/locales/ar/editor.json+++ b/locales/ar/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "يرجى إدخال معادلة TeX"},+ "slash": {+ "h1": "عنوان رئيسي من المستوى الأول",+ "h2": "عنوان فرعي من المستوى الثاني",+ "h3": "عنوان فرعي من المستوى الثالث",+ "hr": "خط فاصل",+ "table": "جدول",+ "tex": "معادلة TeX"+ },"table": {"delete": "حذف الجدول","deleteColumn": "حذف العمود",@@ -46,7 +54,7 @@"link": "رابط","numberList": "قائمة مرقمة","strikethrough": "شطب",- "table": "إدراج جدول",+ "table": "جدول","taskList": "قائمة المهام","tex": "معادلة TeX","underline": "تسطير"diff --git a/locales/bg-BG/editor.json b/locales/bg-BG/editor.jsonindex 96b9f4abaea..6f76adc0517 100644--- a/locales/bg-BG/editor.json+++ b/locales/bg-BG/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Моля, въведете TeX формула"},+ "slash": {+ "h1": "Заглавие ниво 1",+ "h2": "Заглавие ниво 2",+ "h3": "Заглавие ниво 3",+ "hr": "Разделителна линия",+ "table": "Таблица",+ "tex": "TeX формула"+ },"table": {"delete": "Премахни таблицата","deleteColumn": "Премахни колоната",@@ -46,7 +54,7 @@"link": "Връзка","numberList": "Номериран списък","strikethrough": "Зачеркване",- "table": "Вмъкване на таблица",+ "table": "таблица","taskList": "Списък със задачи","tex": "TeX формула","underline": "Подчертаване"diff --git a/locales/de-DE/editor.json b/locales/de-DE/editor.jsonindex e8ebdcf3bfd..6c16dd3f156 100644--- a/locales/de-DE/editor.json+++ b/locales/de-DE/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Bitte TeX-Formel eingeben"},+ "slash": {+ "h1": "Überschrift 1. Ordnung",+ "h2": "Überschrift 2. Ordnung",+ "h3": "Überschrift 3. Ordnung",+ "hr": "Trennlinie",+ "table": "Tabelle",+ "tex": "TeX-Formel"+ },"table": {"delete": "Tabelle löschen","deleteColumn": "Spalte löschen",@@ -46,7 +54,7 @@"link": "Link","numberList": "Nummerierte Liste","strikethrough": "Durchgestrichen",- "table": "Tabelle einfügen",+ "table": "Tabelle","taskList": "Aufgabenliste","tex": "TeX-Formel","underline": "Unterstrichen"diff --git a/locales/en-US/editor.json b/locales/en-US/editor.jsonindex cd3d60ab07f..e0777070c53 100644--- a/locales/en-US/editor.json+++ b/locales/en-US/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Please enter a TeX formula"},+ "slash": {+ "h1": "Heading 1",+ "h2": "Heading 2",+ "h3": "Heading 3",+ "hr": "Divider",+ "table": "Table",+ "tex": "TeX Formula"+ },"table": {"delete": "Delete table","deleteColumn": "Delete column",@@ -46,7 +54,7 @@"link": "Link","numberList": "Numbered list","strikethrough": "Strikethrough",- "table": "Insert table",+ "table": "Table","taskList": "Task List","tex": "TeX Formula","underline": "Underline"diff --git a/locales/es-ES/editor.json b/locales/es-ES/editor.jsonindex 31ef9f568e9..dc493044429 100644--- a/locales/es-ES/editor.json+++ b/locales/es-ES/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Por favor, introduzca la fórmula TeX"},+ "slash": {+ "h1": "Título de nivel 1",+ "h2": "Título de nivel 2",+ "h3": "Título de nivel 3",+ "hr": "Línea divisoria",+ "table": "Tabla",+ "tex": "Fórmula TeX"+ },"table": {"delete": "Eliminar tabla","deleteColumn": "Eliminar columna",@@ -46,7 +54,7 @@"link": "Enlace","numberList": "Lista ordenada","strikethrough": "Tachado",- "table": "Insertar tabla",+ "table": "tabla","taskList": "Lista de tareas","tex": "Fórmula TeX","underline": "Subrayado"diff --git a/locales/fa-IR/editor.json b/locales/fa-IR/editor.jsonindex b09d247ae4e..67ca5aa8e4e 100644--- a/locales/fa-IR/editor.json+++ b/locales/fa-IR/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "لطفاً فرمول TeX را وارد کنید"},+ "slash": {+ "h1": "عنوان سطح یک",+ "h2": "عنوان سطح دو",+ "h3": "عنوان سطح سه",+ "hr": "خط جداکننده",+ "table": "جدول",+ "tex": "فرمول TeX"+ },"table": {"delete": "حذف جدول","deleteColumn": "حذف ستون",@@ -46,7 +54,7 @@"link": "پیوند","numberList": "فهرست شمارهدار","strikethrough": "خط خورده",- "table": "درج جدول",+ "table": "جدول","taskList": "فهرست وظایف","tex": "فرمول TeX","underline": "زیرخط"diff --git a/locales/fr-FR/editor.json b/locales/fr-FR/editor.jsonindex dfb5523f1bb..af169b4c209 100644--- a/locales/fr-FR/editor.json+++ b/locales/fr-FR/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Veuillez saisir une formule TeX"},+ "slash": {+ "h1": "Titre de niveau 1",+ "h2": "Titre de niveau 2",+ "h3": "Titre de niveau 3",+ "hr": "Ligne de séparation",+ "table": "Tableau",+ "tex": "Formule TeX"+ },"table": {"delete": "Supprimer le tableau","deleteColumn": "Supprimer la colonne",@@ -46,7 +54,7 @@"link": "Lien","numberList": "Liste numérotée","strikethrough": "Barré",- "table": "Insérer un tableau",+ "table": "tableau","taskList": "Liste des tâches","tex": "Formule TeX","underline": "Souligné"diff --git a/locales/it-IT/editor.json b/locales/it-IT/editor.jsonindex 07c9ad5e741..5ed23d0f66a 100644--- a/locales/it-IT/editor.json+++ b/locales/it-IT/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Inserisci la formula TeX"},+ "slash": {+ "h1": "Titolo di primo livello",+ "h2": "Titolo di secondo livello",+ "h3": "Titolo di terzo livello",+ "hr": "Linea di separazione",+ "table": "Tabella",+ "tex": "Formula TeX"+ },"table": {"delete": "Elimina tabella","deleteColumn": "Elimina colonna",@@ -46,7 +54,7 @@"link": "Collegamento","numberList": "Elenco numerato","strikethrough": "Testo barrato",- "table": "Inserisci tabella",+ "table": "tabella","taskList": "Elenco attività","tex": "Formula TeX","underline": "Sottolineato"diff --git a/locales/ja-JP/editor.json b/locales/ja-JP/editor.jsonindex 1aae947dcd3..6e33863bdac 100644--- a/locales/ja-JP/editor.json+++ b/locales/ja-JP/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "TeX 公式を入力してください"},+ "slash": {+ "h1": "見出し1",+ "h2": "見出し2",+ "h3": "見出し3",+ "hr": "区切り線",+ "table": "表",+ "tex": "TeX 数式"+ },"table": {"delete": "表を削除","deleteColumn": "列を削除",@@ -46,7 +54,7 @@"link": "リンク","numberList": "番号付きリスト","strikethrough": "取り消し線",- "table": "表を挿入",+ "table": "表","taskList": "タスクリスト","tex": "TeX 公式","underline": "下線"diff --git a/locales/ko-KR/editor.json b/locales/ko-KR/editor.jsonindex 575274aa7dd..337a4e087e7 100644--- a/locales/ko-KR/editor.json+++ b/locales/ko-KR/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "TeX 수식을 입력하세요"},+ "slash": {+ "h1": "1단계 제목",+ "h2": "2단계 제목",+ "h3": "3단계 제목",+ "hr": "구분선",+ "table": "표",+ "tex": "TeX 수식"+ },"table": {"delete": "테이블 삭제","deleteColumn": "열 삭제",@@ -46,7 +54,7 @@"link": "링크","numberList": "번호 매긴 목록","strikethrough": "취소선",- "table": "표 삽입",+ "table": "표","taskList": "작업 목록","tex": "TeX 수식","underline": "밑줄"diff --git a/locales/nl-NL/editor.json b/locales/nl-NL/editor.jsonindex 40a4649d793..61926b29427 100644--- a/locales/nl-NL/editor.json+++ b/locales/nl-NL/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Voer TeX-formule in"},+ "slash": {+ "h1": "Kop 1",+ "h2": "Kop 2",+ "h3": "Kop 3",+ "hr": "Scheidingslijn",+ "table": "Tabel",+ "tex": "TeX-formule"+ },"table": {"delete": "Tabel verwijderen","deleteColumn": "Kolom verwijderen",@@ -46,7 +54,7 @@"link": "Link","numberList": "Genummerde lijst","strikethrough": "Doorhalen",- "table": "Tabel invoegen",+ "table": "tabel","taskList": "Takenlijst","tex": "TeX-formule","underline": "Onderstrepen"diff --git a/locales/pl-PL/editor.json b/locales/pl-PL/editor.jsonindex 2dc5404ba61..9c38d79229d 100644--- a/locales/pl-PL/editor.json+++ b/locales/pl-PL/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Wprowadź formułę TeX"},+ "slash": {+ "h1": "Nagłówek poziomu 1",+ "h2": "Nagłówek poziomu 2",+ "h3": "Nagłówek poziomu 3",+ "hr": "Linia pozioma",+ "table": "Tabela",+ "tex": "Formuła TeX"+ },"table": {"delete": "Usuń tabelę","deleteColumn": "Usuń kolumnę",@@ -46,7 +54,7 @@"link": "Link","numberList": "Lista numerowana","strikethrough": "Przekreślenie",- "table": "Wstaw tabelę",+ "table": "tabela","taskList": "Lista zadań","tex": "Formuła TeX","underline": "Podkreślenie"diff --git a/locales/pt-BR/editor.json b/locales/pt-BR/editor.jsonindex b54d4a75b97..8ef7be9c23f 100644--- a/locales/pt-BR/editor.json+++ b/locales/pt-BR/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Por favor, insira a fórmula TeX"},+ "slash": {+ "h1": "Título de Nível 1",+ "h2": "Título de Nível 2",+ "h3": "Título de Nível 3",+ "hr": "Linha Divisória",+ "table": "Tabela",+ "tex": "Fórmula TeX"+ },"table": {"delete": "Excluir tabela","deleteColumn": "Excluir coluna",@@ -46,7 +54,7 @@"link": "Link","numberList": "Lista numerada","strikethrough": "Tachado",- "table": "Inserir tabela",+ "table": "tabela","taskList": "Lista de Tarefas","tex": "Fórmula TeX","underline": "Sublinhado"diff --git a/locales/ru-RU/editor.json b/locales/ru-RU/editor.jsonindex 331be512df3..52cbd8fdc98 100644--- a/locales/ru-RU/editor.json+++ b/locales/ru-RU/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Введите формулу TeX"},+ "slash": {+ "h1": "Заголовок первого уровня",+ "h2": "Заголовок второго уровня",+ "h3": "Заголовок третьего уровня",+ "hr": "Разделитель",+ "table": "Таблица",+ "tex": "Формула TeX"+ },"table": {"delete": "Удалить таблицу","deleteColumn": "Удалить столбец",@@ -46,7 +54,7 @@"link": "Ссылка","numberList": "Нумерованный список","strikethrough": "Зачёркнутый",- "table": "Вставить таблицу",+ "table": "таблица","taskList": "Список задач","tex": "Формула TeX","underline": "Подчёркнутый"diff --git a/locales/tr-TR/editor.json b/locales/tr-TR/editor.jsonindex 84c20a1c400..617bfbcb78e 100644--- a/locales/tr-TR/editor.json+++ b/locales/tr-TR/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Lütfen TeX formülünü girin"},+ "slash": {+ "h1": "Birinci Seviye Başlık",+ "h2": "İkinci Seviye Başlık",+ "h3": "Üçüncü Seviye Başlık",+ "hr": "Ayırıcı Çizgi",+ "table": "Tablo",+ "tex": "TeX Formülü"+ },"table": {"delete": "Tabloyu sil","deleteColumn": "Sütunu sil",@@ -46,7 +54,7 @@"link": "Bağlantı","numberList": "Numaralı liste","strikethrough": "Üstü çizili",- "table": "Tablo ekle",+ "table": "tablo","taskList": "Görev Listesi","tex": "TeX Formülü","underline": "Altı çizili"diff --git a/locales/vi-VN/editor.json b/locales/vi-VN/editor.jsonindex 90ab23d5253..f8ef431cb52 100644--- a/locales/vi-VN/editor.json+++ b/locales/vi-VN/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "Vui lòng nhập công thức TeX"},+ "slash": {+ "h1": "Tiêu đề cấp 1",+ "h2": "Tiêu đề cấp 2",+ "h3": "Tiêu đề cấp 3",+ "hr": "Đường phân cách",+ "table": "Bảng",+ "tex": "Công thức TeX"+ },"table": {"delete": "Xóa bảng","deleteColumn": "Xóa cột",@@ -46,7 +54,7 @@"link": "Liên kết","numberList": "Danh sách có thứ tự","strikethrough": "Gạch ngang",- "table": "Chèn bảng",+ "table": "bảng","taskList": "Danh sách công việc","tex": "Công thức TeX","underline": "Gạch chân"diff --git a/locales/zh-CN/editor.json b/locales/zh-CN/editor.jsonindex db7cbb79a63..a6f826a75fc 100644--- a/locales/zh-CN/editor.json+++ b/locales/zh-CN/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "请输入 TeX 公式"},+ "slash": {+ "h1": "一级标题",+ "h2": "二级标题",+ "h3": "三级标题",+ "hr": "分割线",+ "table": "表格",+ "tex": "TeX 公式"+ },"table": {"delete": "删除表格","deleteColumn": "删除列",@@ -46,7 +54,7 @@"link": "链接","numberList": "有序列表","strikethrough": "删除线",- "table": "插入表格",+ "table": "table","taskList": "任务列表","tex": "TeX 公式","underline": "下划线"diff --git a/locales/zh-TW/editor.json b/locales/zh-TW/editor.jsonindex 53515a2fd7a..f561b4159a1 100644--- a/locales/zh-TW/editor.json+++ b/locales/zh-TW/editor.json@@ -27,6 +27,14 @@"math": {"placeholder": "請輸入 TeX 公式"},+ "slash": {+ "h1": "一級標題",+ "h2": "二級標題",+ "h3": "三級標題",+ "hr": "分隔線",+ "table": "表格",+ "tex": "TeX 公式"+ },"table": {"delete": "刪除表格","deleteColumn": "刪除列",@@ -46,7 +54,7 @@"link": "連結","numberList": "有序清單","strikethrough": "刪除線",- "table": "插入表格",+ "table": "表格","taskList": "任務列表","tex": "TeX 公式","underline": "底線"diff --git a/package.json b/package.jsonindex 28089cf53ff..267df3b9e7a 100644--- a/package.json+++ b/package.json@@ -155,7 +155,7 @@"@lobehub/charts": "^2.0.0","@lobehub/chat-plugin-sdk": "^1.32.4","@lobehub/chat-plugins-gateway": "^1.9.0",- "@lobehub/editor": "^1.6.1",+ "@lobehub/editor": "^1.8.0","@lobehub/icons": "^2.31.0","@lobehub/market-sdk": "^0.22.7","@lobehub/tts": "^2.0.1",diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsxindex a7094e85845..7a2da8ec0f0 100644--- a/src/features/ChatInput/Desktop/index.tsx+++ b/src/features/ChatInput/Desktop/index.tsx@@ -10,6 +10,8 @@ import { Center, Flexbox } from 'react-layout-kit';import { useChatInputStore } from '@/features/ChatInput/store';import { useChatStore } from '@/store/chat';import { chatSelectors } from '@/store/chat/selectors';+import { useGlobalStore } from '@/store/global';+import { systemStatusSelectors } from '@/store/global/selectors';import ActionBar from '../ActionBar';import InputEditor from '../InputEditor';@@ -49,6 +51,10 @@ const useStyles = createStyles(({ css, token }) => ({const DesktopChatInput = memo<{ showFootnote?: boolean }>(({ showFootnote }) => {const { t } = useTranslation('chat');+ const [chatInputHeight, updateSystemStatus] = useGlobalStore((s) => [+ systemStatusSelectors.chatInputHeight(s),+ s.updateSystemStatus,+ ]);const [slashMenuRef, expand, showTypoBar, editor, leftActions] = useChatInputStore((s) => [s.slashMenuRef,s.expand,@@ -77,6 +83,7 @@ const DesktopChatInput = memo<{ showFootnote?: boolean }>(({ showFootnote }) =>paddingInline={12}><ChatInput+ defaultHeight={chatInputHeight || 32}footer={<ChatInputActionBarleft={<ActionBar />}@@ -88,12 +95,13 @@ const DesktopChatInput = memo<{ showFootnote?: boolean }>(({ showFootnote }) =>}fullscreen={expand}header={showTypoBar && <TypoBar />}- slashMenuRef={slashMenuRef}- styles={{- body: {- minHeight: 64,- },+ maxHeight={320}+ minHeight={36}+ onSizeChange={(height) => {+ updateSystemStatus({ chatInputHeight: height });}}+ resize={true}+ slashMenuRef={slashMenuRef}>{expand && fileNode}<InputEditor />diff --git a/src/features/ChatInput/InputEditor/Placeholder.tsx b/src/features/ChatInput/InputEditor/Placeholder.tsxnew file mode 100644index 00000000000..1ec336c65ff--- /dev/null+++ b/src/features/ChatInput/InputEditor/Placeholder.tsx@@ -0,0 +1,42 @@+import { KeyEnum } from '@lobechat/types';+import { Hotkey, combineKeys } from '@lobehub/ui';+import { memo } from 'react';+import { Trans, useTranslation } from 'react-i18next';+import { Flexbox } from 'react-layout-kit';++import { useUserStore } from '@/store/user';+import { preferenceSelectors } from '@/store/user/selectors';++const Placeholder = memo(() => {+ const { t } = useTranslation(['editor', 'chat']);++ const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);+ const wrapperShortcut = useCmdEnterToSend+ ? KeyEnum.Enter+ : combineKeys([KeyEnum.Mod, KeyEnum.Enter]);++ return (+ <Flexbox align={'center'} as={'span'} gap={4} horizontal>+ {t('sendPlaceholder', { ns: 'chat' }).replace('...', ', ')}+ <Trans+ as={'span'}+ components={{+ key: (+ <Hotkey+ as={'span'}+ keys={wrapperShortcut}+ style={{ color: 'inherit' }}+ styles={{ kbdStyle: { color: 'inhert' } }}+ variant={'borderless'}+ />+ ),+ }}+ i18nKey={'input.warpWithKey'}+ ns={'chat'}+ />+ {'...'}+ </Flexbox>+ );+});++export default Placeholder;diff --git a/src/features/ChatInput/InputEditor/index.tsx b/src/features/ChatInput/InputEditor/index.tsxindex 7f533a0e793..f2c5c6017a1 100644--- a/src/features/ChatInput/InputEditor/index.tsx+++ b/src/features/ChatInput/InputEditor/index.tsx@@ -2,7 +2,6 @@ import { isDesktop } from '@lobechat/const';import { HotkeyEnum, KeyEnum } from '@lobechat/types';import { isCommandPressed } from '@lobechat/utils';import {- INSERT_TABLE_COMMAND,ReactCodePlugin,ReactCodeblockPlugin,ReactHRPlugin,@@ -12,17 +11,16 @@ import {ReactTablePlugin,} from '@lobehub/editor';import { Editor, FloatMenu, SlashMenu, useEditorState } from '@lobehub/editor/react';-import { Hotkey, combineKeys } from '@lobehub/ui';-import { Table2Icon } from 'lucide-react';+import { combineKeys } from '@lobehub/ui';import { memo, useEffect, useRef } from 'react';import { useHotkeysContext } from 'react-hotkeys-hook';-import { Trans, useTranslation } from 'react-i18next';-import { Flexbox } from 'react-layout-kit';import { useUserStore } from '@/store/user';import { preferenceSelectors, settingsSelectors } from '@/store/user/selectors';import { useChatInputStore, useStoreApi } from '../store';+import Placeholder from './Placeholder';+import { useSlashItems } from './useSlashItems';const InputEditor = memo<{ defaultRows?: number }>(() => {const [editor, slashMenuRef, send, updateMarkdownContent, expand] = useChatInputStore((s) => [@@ -37,14 +35,11 @@ const InputEditor = memo<{ defaultRows?: number }>(() => {const state = useEditorState(editor);const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.AddUserMessage));const { enableScope, disableScope } = useHotkeysContext();- const { t } = useTranslation(['editor', 'chat']);+ const slashItems = useSlashItems();const isChineseInput = useRef(false);const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);- const wrapperShortcut = useCmdEnterToSend- ? KeyEnum.Enter- : combineKeys([KeyEnum.Mod, KeyEnum.Enter]);useEffect(() => {const fn = (e: BeforeUnloadEvent) => {@@ -113,28 +108,7 @@ const InputEditor = memo<{ defaultRows?: number }>(() => {}}}}- placeholder={- <Flexbox align={'center'} as={'span'} gap={4} horizontal>- {t('sendPlaceholder', { ns: 'chat' }).replace('...', ', ')}- <Trans- as={'span'}- components={{- key: (- <Hotkey- as={'span'}- keys={wrapperShortcut}- style={{ color: 'inherit' }}- styles={{ kbdStyle: { color: 'inhert' } }}- variant={'borderless'}- />- ),- }}- i18nKey={'input.warpWithKey'}- ns={'chat'}- />- {'...'}- </Flexbox>- }+ placeholder={<Placeholder />}plugins={[ReactListPlugin,ReactLinkPlugin,@@ -151,16 +125,7 @@ const InputEditor = memo<{ defaultRows?: number }>(() => {}),]}slashOption={{- items: [- {- icon: Table2Icon,- key: 'table',- label: t('typobar.table'),- onSelect: (editor) => {- editor.dispatchCommand(INSERT_TABLE_COMMAND, { columns: '3', rows: '3' });- },- },- ],+ items: slashItems,renderComp: expand? undefined: (props) => {diff --git a/src/features/ChatInput/InputEditor/useSlashItems.tsx b/src/features/ChatInput/InputEditor/useSlashItems.tsxnew file mode 100644index 00000000000..afcbc85a975--- /dev/null+++ b/src/features/ChatInput/InputEditor/useSlashItems.tsx@@ -0,0 +1,92 @@+import {+ INSERT_HEADING_COMMAND,+ INSERT_HORIZONTAL_RULE_COMMAND,+ INSERT_MATH_COMMAND,+ INSERT_TABLE_COMMAND,+ SlashOptions,+} from '@lobehub/editor';+import { Text } from '@lobehub/ui';+import {+ Heading1Icon,+ Heading2Icon,+ Heading3Icon,+ MinusIcon,+ SigmaIcon,+ Table2Icon,+} from 'lucide-react';+import { useMemo } from 'react';+import { useTranslation } from 'react-i18next';++export const useSlashItems = (): SlashOptions['items'] => {+ const { t } = useTranslation('editor');+ return useMemo(() => {+ const data: SlashOptions['items'] = [+ {+ icon: Heading1Icon,+ key: 'h1',+ label: t('slash.h1'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h1' });+ },+ },+ {+ icon: Heading2Icon,+ key: 'h2',+ label: t('slash.h2'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h2' });+ },+ },+ {+ icon: Heading3Icon,+ key: 'h3',+ label: t('slash.h3'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h3' });+ },+ },++ {+ type: 'divider',+ },+ {+ icon: MinusIcon,+ key: 'hr',+ label: t('slash.hr'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, {});+ },+ },+ {+ icon: Table2Icon,+ key: 'table',+ label: t('slash.table'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_TABLE_COMMAND, { columns: '3', rows: '3' });+ },+ },+ {+ icon: SigmaIcon,+ key: 'tex',+ label: t('slash.tex'),+ onSelect: (editor) => {+ editor.dispatchCommand(INSERT_MATH_COMMAND, { code: 'x^2 + y^2 = z^2' });+ queueMicrotask(() => {+ editor.focus();+ });+ },+ },+ ];+ return data.map((item) => {+ if (item.type === 'divider') return item;+ return {+ ...item,+ extra: (+ <Text code fontSize={12} type={'secondary'}>+ {item.key}+ </Text>+ ),+ };+ });+ }, [t]);+};diff --git a/src/features/ChatInput/TypoBar/index.tsx b/src/features/ChatInput/TypoBar/index.tsxindex f0bb591954b..7fd0505dd16 100644--- a/src/features/ChatInput/TypoBar/index.tsx+++ b/src/features/ChatInput/TypoBar/index.tsx@@ -147,14 +147,7 @@ const TypoBar = memo(() => {return (<ChatInputActionBar- left={- <ChatInputActions- items={items}- onClick={() => {- editor?.focus();- }}- />- }+ left={<ChatInputActions items={items} />}style={{background: theme.colorFillQuaternary,borderTopLeftRadius: 8,diff --git a/src/locales/default/editor.ts b/src/locales/default/editor.tsindex 9e9cbc70b40..e5d130123d6 100644--- a/src/locales/default/editor.ts+++ b/src/locales/default/editor.ts@@ -27,6 +27,14 @@ export default {math: {placeholder: '请输入 TeX 公式',},+ slash: {+ h1: '一级标题',+ h2: '二级标题',+ h3: '三级标题',+ hr: '分割线',+ table: '表格',+ tex: 'TeX 公式',+ },table: {delete: '删除表格',deleteColumn: '删除列',@@ -46,7 +54,7 @@ export default {link: '链接',numberList: '有序列表',strikethrough: '删除线',- table: '插入表格',+ table: 'table',taskList: '任务列表',tex: 'TeX 公式',underline: '下划线',diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.tsindex c47580040ae..f607ced5072 100644--- a/src/store/global/initialState.ts+++ b/src/store/global/initialState.ts@@ -47,6 +47,7 @@ export enum ProfileTabs {}export interface SystemStatus {+ chatInputHeight?: number;expandInputActionbar?: boolean;// which sessionGroup should expandexpandSessionGroupKeys: string[];@@ -115,6 +116,7 @@ export interface GlobalState {}export const INITIAL_STATUS = {+ chatInputHeight: 64,expandInputActionbar: true,expandSessionGroupKeys: [SessionDefaultGroup.Pinned, SessionDefaultGroup.Default],filePanelWidth: 320,diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.tsindex 0bcf01d094b..efc88f0d688 100644--- a/src/store/global/selectors/systemStatus.ts+++ b/src/store/global/selectors/systemStatus.ts@@ -29,6 +29,7 @@ const filePanelWidth = (s: GlobalState) => s.status.filePanelWidth;const imagePanelWidth = (s: GlobalState) => s.status.imagePanelWidth;const imageTopicPanelWidth = (s: GlobalState) => s.status.imageTopicPanelWidth;const wideScreen = (s: GlobalState) => !s.status.noWideScreen;+const chatInputHeight = (s: GlobalState) => s.status.chatInputHeight || 64;const expandInputActionbar = (s: GlobalState) => s.status.expandInputActionbar;const isStatusInit = (s: GlobalState) => !!s.isStatusInit;const isPgliteNotEnabled = (s: GlobalState) =>@@ -63,6 +64,7 @@ const getAgentSystemRoleExpanded =};export const systemStatusSelectors = {+ chatInputHeight,expandInputActionbar,filePanelWidth,getAgentSystemRoleExpanded,