diff --git a/web/src/components/ChatBox/ChatInputBox/Addon.tsx b/web/src/components/ChatBox/ChatInputBox/Addon.tsx new file mode 100644 index 00000000..30756653 --- /dev/null +++ b/web/src/components/ChatBox/ChatInputBox/Addon.tsx @@ -0,0 +1,32 @@ +import { chatInputActions } from '@/plugin/common'; +import { Icon } from '@iconify/react'; +import { Dropdown, Menu } from 'antd'; +import React, { useMemo } from 'react'; + +export const ChatInputAddon: React.FC = React.memo(() => { + const menu = useMemo(() => { + return ( + + {chatInputActions.map((item, i) => ( + + {item.label} + + ))} + + ); + }, []); + + if (chatInputActions.length === 0) { + return null; + } + + return ( + + + + ); +}); +ChatInputAddon.displayName = 'ChatInputAddon'; diff --git a/web/src/components/ChatBox/ChatInputBox/index.tsx b/web/src/components/ChatBox/ChatInputBox/index.tsx index 8ad0cfc3..a832d1cf 100644 --- a/web/src/components/ChatBox/ChatInputBox/index.tsx +++ b/web/src/components/ChatBox/ChatInputBox/index.tsx @@ -2,6 +2,7 @@ import { isEnterHotkey } from '@/utils/hot-key'; import { Input } from 'antd'; import React, { useCallback, useRef, useState } from 'react'; import { t } from 'tailchat-shared'; +import { ChatInputAddon } from './Addon'; interface ChatInputBoxProps { onSendMsg: (msg: string) => void; @@ -27,14 +28,20 @@ export const ChatInputBox: React.FC = React.memo((props) => { return (
- setMessage(e.target.value)} - onKeyDown={handleKeyDown} - /> +
+ setMessage(e.target.value)} + onKeyDown={handleKeyDown} + /> + +
+ +
+
); }); diff --git a/web/src/plugin/common/reg.ts b/web/src/plugin/common/reg.ts index 64f94fde..0e45f890 100644 --- a/web/src/plugin/common/reg.ts +++ b/web/src/plugin/common/reg.ts @@ -52,3 +52,10 @@ export const [messageInterpreter, regMessageInterpreter] = export const [getMessageRender, regMessageRender] = buildRegFn< (message: string) => React.ReactNode >('message-render', (message) => message); + +interface ChatInputAction { + label: string; + onClick: () => void; +} +export const [chatInputActions, regChatInputAction] = + buildRegList();