Skip to content

🤯 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.

✨ feat: Add Math and TaskList to Editor (#9165)

CanisMinor9e0621f873dc
diff --git a/locales/ar/editor.json b/locales/ar/editor.json
index 8295cdfac18..305de166b95 100644
--- a/locales/ar/editor.json
+++ b/locales/ar/editor.json
@@ -9,6 +9,8 @@
"on": "إظهار شريط أدوات التنسيق"
}
},
+ "cancel": "إلغاء",
+ "confirm": "تأكيد",
"file": {
"error": "خطأ: {{message}}",
"uploading": "جاري رفع الملف..."
@@ -22,6 +24,9 @@
"placeholder": "أدخل عنوان URL للرابط",
"unlink": "إزالة الرابط"
},
+ "math": {
+ "placeholder": "يرجى إدخال معادلة TeX"
+ },
"table": {
"delete": "حذف الجدول",
"deleteColumn": "حذف العمود",
@@ -42,6 +47,8 @@
"numberList": "قائمة مرقمة",
"strikethrough": "شطب",
"table": "إدراج جدول",
+ "taskList": "قائمة المهام",
+ "tex": "معادلة TeX",
"underline": "تسطير"
}
}
diff --git a/locales/bg-BG/editor.json b/locales/bg-BG/editor.json
index 09efac468a0..96b9f4abaea 100644
--- a/locales/bg-BG/editor.json
+++ b/locales/bg-BG/editor.json
@@ -9,6 +9,8 @@
"on": "Покажи лентата за форматиране"
}
},
+ "cancel": "Отказ",
+ "confirm": "Потвърждение",
"file": {
"error": "Грешка: {{message}}",
"uploading": "Качване на файл..."
@@ -22,6 +24,9 @@
"placeholder": "Въведете URL адрес на връзката",
"unlink": "Премахни връзката"
},
+ "math": {
+ "placeholder": "Моля, въведете TeX формула"
+ },
"table": {
"delete": "Премахни таблицата",
"deleteColumn": "Премахни колоната",
@@ -42,6 +47,8 @@
"numberList": "Номериран списък",
"strikethrough": "Зачеркване",
"table": "Вмъкване на таблица",
+ "taskList": "Списък със задачи",
+ "tex": "TeX формула",
"underline": "Подчертаване"
}
}
diff --git a/locales/de-DE/editor.json b/locales/de-DE/editor.json
index 14fb5dc2147..e8ebdcf3bfd 100644
--- a/locales/de-DE/editor.json
+++ b/locales/de-DE/editor.json
@@ -9,6 +9,8 @@
"on": "Formatierungsleiste anzeigen"
}
},
+ "cancel": "Abbrechen",
+ "confirm": "Bestätigen",
"file": {
"error": "Fehler: {{message}}",
"uploading": "Datei wird hochgeladen..."
@@ -22,6 +24,9 @@
"placeholder": "Link-URL eingeben",
"unlink": "Link entfernen"
},
+ "math": {
+ "placeholder": "Bitte TeX-Formel eingeben"
+ },
"table": {
"delete": "Tabelle löschen",
"deleteColumn": "Spalte löschen",
@@ -42,6 +47,8 @@
"numberList": "Nummerierte Liste",
"strikethrough": "Durchgestrichen",
"table": "Tabelle einfügen",
+ "taskList": "Aufgabenliste",
+ "tex": "TeX-Formel",
"underline": "Unterstrichen"
}
}
diff --git a/locales/en-US/editor.json b/locales/en-US/editor.json
index 211926b8b89..cd3d60ab07f 100644
--- a/locales/en-US/editor.json
+++ b/locales/en-US/editor.json
@@ -9,6 +9,8 @@
"on": "Show formatting toolbar"
}
},
+ "cancel": "Cancel",
+ "confirm": "Confirm",
"file": {
"error": "Error: {{message}}",
"uploading": "Uploading file..."
@@ -22,6 +24,9 @@
"placeholder": "Enter link URL",
"unlink": "Unlink"
},
+ "math": {
+ "placeholder": "Please enter a TeX formula"
+ },
"table": {
"delete": "Delete table",
"deleteColumn": "Delete column",
@@ -42,6 +47,8 @@
"numberList": "Numbered list",
"strikethrough": "Strikethrough",
"table": "Insert table",
+ "taskList": "Task List",
+ "tex": "TeX Formula",
"underline": "Underline"
}
}
diff --git a/locales/es-ES/editor.json b/locales/es-ES/editor.json
index 07ed2ba8ea0..31ef9f568e9 100644
--- a/locales/es-ES/editor.json
+++ b/locales/es-ES/editor.json
@@ -9,6 +9,8 @@
"on": "Mostrar barra de herramientas de formato"
}
},
+ "cancel": "Cancelar",
+ "confirm": "Confirmar",
"file": {
"error": "Error: {{message}}",
"uploading": "Subiendo archivo..."
@@ -22,6 +24,9 @@
"placeholder": "Introduce la URL del enlace",
"unlink": "Quitar enlace"
},
+ "math": {
+ "placeholder": "Por favor, introduzca la fórmula TeX"
+ },
"table": {
"delete": "Eliminar tabla",
"deleteColumn": "Eliminar columna",
@@ -42,6 +47,8 @@
"numberList": "Lista ordenada",
"strikethrough": "Tachado",
"table": "Insertar tabla",
+ "taskList": "Lista de tareas",
+ "tex": "Fórmula TeX",
"underline": "Subrayado"
}
}
diff --git a/locales/fa-IR/editor.json b/locales/fa-IR/editor.json
index 6ffbd7cd690..b09d247ae4e 100644
--- a/locales/fa-IR/editor.json
+++ b/locales/fa-IR/editor.json
@@ -9,6 +9,8 @@
"on": "نمایش نوار ابزار قالب‌بندی"
}
},
+ "cancel": "لغو",
+ "confirm": "تأیید",
"file": {
"error": "خطا: {{message}}",
"uploading": "در حال بارگذاری فایل..."
@@ -22,6 +24,9 @@
"placeholder": "آدرس URL پیوند را وارد کنید",
"unlink": "حذف پیوند"
},
+ "math": {
+ "placeholder": "لطفاً فرمول TeX را وارد کنید"
+ },
"table": {
"delete": "حذف جدول",
"deleteColumn": "حذف ستون",
@@ -42,6 +47,8 @@
"numberList": "فهرست شماره‌دار",
"strikethrough": "خط خورده",
"table": "درج جدول",
+ "taskList": "فهرست وظایف",
+ "tex": "فرمول TeX",
"underline": "زیرخط"
}
}
diff --git a/locales/fr-FR/editor.json b/locales/fr-FR/editor.json
index dda80e9553e..dfb5523f1bb 100644
--- a/locales/fr-FR/editor.json
+++ b/locales/fr-FR/editor.json
@@ -9,6 +9,8 @@
"on": "Afficher la barre d'outils de formatage"
}
},
+ "cancel": "Annuler",
+ "confirm": "Confirmer",
"file": {
"error": "Erreur : {{message}}",
"uploading": "Téléversement du fichier en cours..."
@@ -22,6 +24,9 @@
"placeholder": "Entrez l'URL du lien",
"unlink": "Supprimer le lien"
},
+ "math": {
+ "placeholder": "Veuillez saisir une formule TeX"
+ },
"table": {
"delete": "Supprimer le tableau",
"deleteColumn": "Supprimer la colonne",
@@ -42,6 +47,8 @@
"numberList": "Liste numérotée",
"strikethrough": "Barré",
"table": "Insérer un tableau",
+ "taskList": "Liste des tâches",
+ "tex": "Formule TeX",
"underline": "Souligné"
}
}
diff --git a/locales/it-IT/editor.json b/locales/it-IT/editor.json
index 7ca65dd2b43..07c9ad5e741 100644
--- a/locales/it-IT/editor.json
+++ b/locales/it-IT/editor.json
@@ -9,6 +9,8 @@
"on": "Mostra barra degli strumenti di formattazione"
}
},
+ "cancel": "Annulla",
+ "confirm": "Conferma",
"file": {
"error": "Errore: {{message}}",
"uploading": "Caricamento file in corso..."
@@ -22,6 +24,9 @@
"placeholder": "Inserisci URL del link",
"unlink": "Rimuovi link"
},
+ "math": {
+ "placeholder": "Inserisci la formula TeX"
+ },
"table": {
"delete": "Elimina tabella",
"deleteColumn": "Elimina colonna",
@@ -42,6 +47,8 @@
"numberList": "Elenco numerato",
"strikethrough": "Testo barrato",
"table": "Inserisci tabella",
+ "taskList": "Elenco attività",
+ "tex": "Formula TeX",
"underline": "Sottolineato"
}
}
diff --git a/locales/ja-JP/editor.json b/locales/ja-JP/editor.json
index 445c34a1cbc..1aae947dcd3 100644
--- a/locales/ja-JP/editor.json
+++ b/locales/ja-JP/editor.json
@@ -9,6 +9,8 @@
"on": "書式ツールバーを表示"
}
},
+ "cancel": "キャンセル",
+ "confirm": "確認",
"file": {
"error": "エラー:{{message}}",
"uploading": "ファイルをアップロードしています..."
@@ -22,6 +24,9 @@
"placeholder": "リンクの URL を入力",
"unlink": "リンクを解除"
},
+ "math": {
+ "placeholder": "TeX 公式を入力してください"
+ },
"table": {
"delete": "表を削除",
"deleteColumn": "列を削除",
@@ -42,6 +47,8 @@
"numberList": "番号付きリスト",
"strikethrough": "取り消し線",
"table": "表を挿入",
+ "taskList": "タスクリスト",
+ "tex": "TeX 公式",
"underline": "下線"
}
}
diff --git a/locales/ko-KR/editor.json b/locales/ko-KR/editor.json
index 9ef4a0abdb8..575274aa7dd 100644
--- a/locales/ko-KR/editor.json
+++ b/locales/ko-KR/editor.json
@@ -9,6 +9,8 @@
"on": "서식 도구 모음 표시"
}
},
+ "cancel": "취소",
+ "confirm": "확인",
"file": {
"error": "오류: {{message}}",
"uploading": "파일 업로드 중..."
@@ -22,6 +24,9 @@
"placeholder": "링크 URL 입력",
"unlink": "링크 제거"
},
+ "math": {
+ "placeholder": "TeX 수식을 입력하세요"
+ },
"table": {
"delete": "테이블 삭제",
"deleteColumn": "열 삭제",
@@ -42,6 +47,8 @@
"numberList": "번호 매긴 목록",
"strikethrough": "취소선",
"table": "표 삽입",
+ "taskList": "작업 목록",
+ "tex": "TeX 수식",
"underline": "밑줄"
}
}
diff --git a/locales/nl-NL/editor.json b/locales/nl-NL/editor.json
index 9068c949e19..40a4649d793 100644
--- a/locales/nl-NL/editor.json
+++ b/locales/nl-NL/editor.json
@@ -9,6 +9,8 @@
"on": "Toon opmaakwerkbalk"
}
},
+ "cancel": "Annuleren",
+ "confirm": "Bevestigen",
"file": {
"error": "Fout: {{message}}",
"uploading": "Bestand wordt geüpload..."
@@ -22,6 +24,9 @@
"placeholder": "Voer de URL van de link in",
"unlink": "Link verwijderen"
},
+ "math": {
+ "placeholder": "Voer TeX-formule in"
+ },
"table": {
"delete": "Tabel verwijderen",
"deleteColumn": "Kolom verwijderen",
@@ -42,6 +47,8 @@
"numberList": "Genummerde lijst",
"strikethrough": "Doorhalen",
"table": "Tabel invoegen",
+ "taskList": "Takenlijst",
+ "tex": "TeX-formule",
"underline": "Onderstrepen"
}
}
diff --git a/locales/pl-PL/editor.json b/locales/pl-PL/editor.json
index 18d4f41dded..2dc5404ba61 100644
--- a/locales/pl-PL/editor.json
+++ b/locales/pl-PL/editor.json
@@ -9,6 +9,8 @@
"on": "Pokaż pasek narzędzi formatowania"
}
},
+ "cancel": "Anuluj",
+ "confirm": "Potwierdź",
"file": {
"error": "Błąd: {{message}}",
"uploading": "Przesyłanie pliku..."
@@ -22,6 +24,9 @@
"placeholder": "Wpisz adres URL linku",
"unlink": "Usuń link"
},
+ "math": {
+ "placeholder": "Wprowadź formułę TeX"
+ },
"table": {
"delete": "Usuń tabelę",
"deleteColumn": "Usuń kolumnę",
@@ -42,6 +47,8 @@
"numberList": "Lista numerowana",
"strikethrough": "Przekreślenie",
"table": "Wstaw tabelę",
+ "taskList": "Lista zadań",
+ "tex": "Formuła TeX",
"underline": "Podkreślenie"
}
}
diff --git a/locales/pt-BR/editor.json b/locales/pt-BR/editor.json
index 1ef95f79c40..b54d4a75b97 100644
--- a/locales/pt-BR/editor.json
+++ b/locales/pt-BR/editor.json
@@ -9,6 +9,8 @@
"on": "Mostrar barra de formatação"
}
},
+ "cancel": "Cancelar",
+ "confirm": "Confirmar",
"file": {
"error": "Erro: {{message}}",
"uploading": "Enviando arquivo..."
@@ -22,6 +24,9 @@
"placeholder": "Digite a URL do link",
"unlink": "Remover link"
},
+ "math": {
+ "placeholder": "Por favor, insira a fórmula TeX"
+ },
"table": {
"delete": "Excluir tabela",
"deleteColumn": "Excluir coluna",
@@ -42,6 +47,8 @@
"numberList": "Lista numerada",
"strikethrough": "Tachado",
"table": "Inserir tabela",
+ "taskList": "Lista de Tarefas",
+ "tex": "Fórmula TeX",
"underline": "Sublinhado"
}
}
diff --git a/locales/ru-RU/editor.json b/locales/ru-RU/editor.json
index 7e86c3d07e3..331be512df3 100644
--- a/locales/ru-RU/editor.json
+++ b/locales/ru-RU/editor.json
@@ -9,6 +9,8 @@
"on": "Показать панель форматирования"
}
},
+ "cancel": "Отмена",
+ "confirm": "Подтвердить",
"file": {
"error": "Ошибка: {{message}}",
"uploading": "Загрузка файла..."
@@ -22,6 +24,9 @@
"placeholder": "Введите URL ссылки",
"unlink": "Удалить ссылку"
},
+ "math": {
+ "placeholder": "Введите формулу TeX"
+ },
"table": {
"delete": "Удалить таблицу",
"deleteColumn": "Удалить столбец",
@@ -42,6 +47,8 @@
"numberList": "Нумерованный список",
"strikethrough": "Зачёркнутый",
"table": "Вставить таблицу",
+ "taskList": "Список задач",
+ "tex": "Формула TeX",
"underline": "Подчёркнутый"
}
}
diff --git a/locales/tr-TR/editor.json b/locales/tr-TR/editor.json
index 5a6f96656d3..84c20a1c400 100644
--- a/locales/tr-TR/editor.json
+++ b/locales/tr-TR/editor.json
@@ -9,6 +9,8 @@
"on": "Biçim araç çubuğunu göster"
}
},
+ "cancel": "İptal",
+ "confirm": "Onayla",
"file": {
"error": "Hata: {{message}}",
"uploading": "Dosya yükleniyor..."
@@ -22,6 +24,9 @@
"placeholder": "Bağlantı URL'si girin",
"unlink": "Bağlantıyı kaldır"
},
+ "math": {
+ "placeholder": "Lütfen TeX formülünü girin"
+ },
"table": {
"delete": "Tabloyu sil",
"deleteColumn": "Sütunu sil",
@@ -42,6 +47,8 @@
"numberList": "Numaralı liste",
"strikethrough": "Üstü çizili",
"table": "Tablo ekle",
+ "taskList": "Görev Listesi",
+ "tex": "TeX Formülü",
"underline": "Altı çizili"
}
}
diff --git a/locales/vi-VN/editor.json b/locales/vi-VN/editor.json
index 4d586ae770d..90ab23d5253 100644
--- a/locales/vi-VN/editor.json
+++ b/locales/vi-VN/editor.json
@@ -9,6 +9,8 @@
"on": "Hiển thị thanh công cụ định dạng"
}
},
+ "cancel": "Hủy",
+ "confirm": "Xác nhận",
"file": {
"error": "Lỗi: {{message}}",
"uploading": "Đang tải tệp lên..."
@@ -22,6 +24,9 @@
"placeholder": "Nhập URL liên kết",
"unlink": "Gỡ liên kết"
},
+ "math": {
+ "placeholder": "Vui lòng nhập công thức TeX"
+ },
"table": {
"delete": "Xóa bảng",
"deleteColumn": "Xóa cột",
@@ -42,6 +47,8 @@
"numberList": "Danh sách có thứ tự",
"strikethrough": "Gạch ngang",
"table": "Chèn 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.json
index 0c1b155eeb0..db7cbb79a63 100644
--- a/locales/zh-CN/editor.json
+++ b/locales/zh-CN/editor.json
@@ -9,6 +9,8 @@
"on": "显示格式工具栏"
}
},
+ "cancel": "取消",
+ "confirm": "确认",
"file": {
"error": "错误:{{message}}",
"uploading": "正在上传文件..."
@@ -22,6 +24,9 @@
"placeholder": "输入链接 URL",
"unlink": "取消链接"
},
+ "math": {
+ "placeholder": "请输入 TeX 公式"
+ },
"table": {
"delete": "删除表格",
"deleteColumn": "删除列",
@@ -42,6 +47,8 @@
"numberList": "有序列表",
"strikethrough": "删除线",
"table": "插入表格",
+ "taskList": "任务列表",
+ "tex": "TeX 公式",
"underline": "下划线"
}
}
diff --git a/locales/zh-TW/editor.json b/locales/zh-TW/editor.json
index 0200caf26bf..53515a2fd7a 100644
--- a/locales/zh-TW/editor.json
+++ b/locales/zh-TW/editor.json
@@ -9,6 +9,8 @@
"on": "顯示格式工具列"
}
},
+ "cancel": "取消",
+ "confirm": "確認",
"file": {
"error": "錯誤:{{message}}",
"uploading": "正在上傳檔案..."
@@ -22,6 +24,9 @@
"placeholder": "輸入連結 URL",
"unlink": "取消連結"
},
+ "math": {
+ "placeholder": "請輸入 TeX 公式"
+ },
"table": {
"delete": "刪除表格",
"deleteColumn": "刪除列",
@@ -42,6 +47,8 @@
"numberList": "有序清單",
"strikethrough": "刪除線",
"table": "插入表格",
+ "taskList": "任務列表",
+ "tex": "TeX 公式",
"underline": "底線"
}
}
diff --git a/package.json b/package.json
index e2e0dd6102a..37007794312 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.4.4",
+ "@lobehub/editor": "^1.5.4",
"@lobehub/icons": "^2.31.0",
"@lobehub/market-sdk": "^0.22.7",
"@lobehub/tts": "^2.0.1",
diff --git a/src/features/ChatInput/InputEditor/index.tsx b/src/features/ChatInput/InputEditor/index.tsx
index 1eab248636d..541af15c338 100644
--- a/src/features/ChatInput/InputEditor/index.tsx
+++ b/src/features/ChatInput/InputEditor/index.tsx
@@ -3,13 +3,15 @@ import { HotkeyEnum } from '@lobechat/types';
import { isCommandPressed } from '@lobechat/utils';
import {
INSERT_TABLE_COMMAND,
+ ReactCodePlugin,
ReactCodeblockPlugin,
ReactHRPlugin,
ReactLinkPlugin,
ReactListPlugin,
+ ReactMathPlugin,
ReactTablePlugin,
} from '@lobehub/editor';
-import { Editor, SlashMenu, useEditorState } from '@lobehub/editor/react';
+import { Editor, FloatMenu, SlashMenu, useEditorState } from '@lobehub/editor/react';
import { Table2Icon } from 'lucide-react';
import { memo, useEffect, useRef } from 'react';
import { useHotkeysContext } from 'react-hotkeys-hook';
@@ -21,11 +23,12 @@ import { preferenceSelectors } from '@/store/user/selectors';
import { useChatInputStore, useStoreApi } from '../store';
const InputEditor = memo<{ defaultRows?: number }>(({ defaultRows = 2 }) => {
- const [editor, slashMenuRef, send, updateMarkdownContent] = useChatInputStore((s) => [
+ const [editor, slashMenuRef, send, updateMarkdownContent, expand] = useChatInputStore((s) => [
s.editor,
s.slashMenuRef,
s.handleSendButton,
s.updateMarkdownContent,
+ s.expand,
]);
const storeApi = useStoreApi();
@@ -101,9 +104,17 @@ const InputEditor = memo<{ defaultRows?: number }>(({ defaultRows = 2 }) => {
plugins={[
ReactListPlugin,
ReactLinkPlugin,
+ ReactCodePlugin,
ReactCodeblockPlugin,
ReactHRPlugin,
ReactTablePlugin,
+ Editor.withProps(ReactMathPlugin, {
+ renderComp: expand
+ ? undefined
+ : (props) => (
+ <FloatMenu {...props} getPopupContainer={() => (slashMenuRef as any)?.current} />
+ ),
+ }),
]}
slashOption={{
items: [
@@ -116,9 +127,13 @@ const InputEditor = memo<{ defaultRows?: number }>(({ defaultRows = 2 }) => {
},
},
],
- renderComp: (props) => {
- return <SlashMenu {...props} getPopupContainer={() => (slashMenuRef as any)?.current} />;
- },
+ renderComp: expand
+ ? undefined
+ : (props) => {
+ return (
+ <SlashMenu {...props} getPopupContainer={() => (slashMenuRef as any)?.current} />
+ );
+ },
}}
style={{
minHeight: defaultRows > 1 ? defaultRows * 23 : undefined,
diff --git a/src/features/ChatInput/TypoBar/index.tsx b/src/features/ChatInput/TypoBar/index.tsx
index e4b2c19cb2c..ee37ed1e190 100644
--- a/src/features/ChatInput/TypoBar/index.tsx
+++ b/src/features/ChatInput/TypoBar/index.tsx
@@ -13,7 +13,9 @@ import {
LinkIcon,
ListIcon,
ListOrderedIcon,
+ ListTodoIcon,
MessageSquareQuote,
+ SigmaIcon,
SquareDashedBottomCodeIcon,
StrikethroughIcon,
} from 'lucide-react';
@@ -79,6 +81,15 @@ const TypoBar = memo(() => {
label: t('typobar.numberList'),
onClick: editorState.numberList,
},
+ {
+ icon: ListTodoIcon,
+ key: 'tasklist',
+ label: t('typobar.taskList'),
+ onClick: editorState.checkList,
+ },
+ {
+ type: 'divider',
+ },
{
active: editorState.isBlockquote,
icon: MessageSquareQuote,
@@ -95,6 +106,12 @@ const TypoBar = memo(() => {
{
type: 'divider',
},
+ {
+ icon: SigmaIcon,
+ key: 'math',
+ label: t('typobar.tex'),
+ onClick: editorState.insertMath,
+ },
{
active: editorState.isCode,
icon: CodeXmlIcon,
diff --git a/src/locales/default/editor.ts b/src/locales/default/editor.ts
index 9ee81bd5018..9e9cbc70b40 100644
--- a/src/locales/default/editor.ts
+++ b/src/locales/default/editor.ts
@@ -9,6 +9,8 @@ export default {
on: '显示格式工具栏',
},
},
+ cancel: '取消',
+ confirm: '确认',
file: {
error: '错误:{{message}}',
uploading: '正在上传文件...',
@@ -22,6 +24,9 @@ export default {
placeholder: '输入链接 URL',
unlink: '取消链接',
},
+ math: {
+ placeholder: '请输入 TeX 公式',
+ },
table: {
delete: '删除表格',
deleteColumn: '删除列',
@@ -42,6 +47,8 @@ export default {
numberList: '有序列表',
strikethrough: '删除线',
table: '插入表格',
+ taskList: '任务列表',
+ tex: 'TeX 公式',
underline: '下划线',
},
};