mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
Merge 79554198ec into 53fb175855
This commit is contained in:
commit
a53a9ed935
4 changed files with 37 additions and 0 deletions
|
|
@ -1962,6 +1962,37 @@ export const ChatComposer = forwardRef<ChatComposerHandle, Props>(
|
|||
}}
|
||||
/>
|
||||
<div className="composer-tools-wrap">
|
||||
<button
|
||||
type="button"
|
||||
className="icon-btn"
|
||||
onClick={() => {
|
||||
const ta = textareaRef.current;
|
||||
if (!ta) return;
|
||||
const cursor = ta.selectionStart;
|
||||
const before = draft.slice(0, cursor);
|
||||
const after = draft.slice(cursor);
|
||||
const next = before + '@' + after;
|
||||
setDraft(next);
|
||||
// Manually open the mention popover, same as handleChange
|
||||
// does when it detects a fresh @ in the typed input.
|
||||
const pos = cursor + 1;
|
||||
const textBefore = next.slice(0, pos);
|
||||
const m = /(^|\\s)@([^\\s@]*)$/.exec(textBefore);
|
||||
if (m) {
|
||||
setMention({ q: m[2] ?? '', cursor: pos });
|
||||
} else {
|
||||
setMention(null);
|
||||
}
|
||||
requestAnimationFrame(() => {
|
||||
ta.focus();
|
||||
ta.setSelectionRange(pos, pos);
|
||||
});
|
||||
}}
|
||||
title={t('chat.mentionButtonTitle')}
|
||||
aria-label={t('chat.mentionButtonAria')}
|
||||
>
|
||||
<span style={{ fontFamily: 'monospace', fontSize: 15 }}>@</span>
|
||||
</button>
|
||||
<button
|
||||
ref={toolsTriggerRef}
|
||||
type="button"
|
||||
|
|
|
|||
|
|
@ -1517,6 +1517,8 @@ export const en: Dict = {
|
|||
'chat.send': 'Send',
|
||||
'chat.stop': 'Stop',
|
||||
'chat.removeAria': 'Remove {name}',
|
||||
'chat.mentionButtonTitle': 'Mention a file',
|
||||
'chat.mentionButtonAria': 'Open file mention picker',
|
||||
'chat.example1Title': 'Editorial pitch deck',
|
||||
'chat.example1Tag': 'Magazine',
|
||||
'chat.example1Prompt':
|
||||
|
|
|
|||
|
|
@ -1508,6 +1508,8 @@ export const zhCN: Dict = {
|
|||
'chat.send': '发送',
|
||||
'chat.stop': '停止',
|
||||
'chat.removeAria': '移除 {name}',
|
||||
'chat.mentionButtonTitle': '引用文件',
|
||||
'chat.mentionButtonAria': '打开文件引用选择器',
|
||||
'chat.example1Title': '编辑风路演 PPT',
|
||||
'chat.example1Tag': '杂志',
|
||||
'chat.example1Prompt':
|
||||
|
|
|
|||
|
|
@ -1842,6 +1842,8 @@ export interface Dict {
|
|||
'chat.send': string;
|
||||
'chat.stop': string;
|
||||
'chat.removeAria': string;
|
||||
'chat.mentionButtonTitle': string;
|
||||
'chat.mentionButtonAria': string;
|
||||
'chat.example1Title': string;
|
||||
'chat.example1Tag': string;
|
||||
'chat.example1Prompt': string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue