♻️ refactor(input): 优化粘贴文件处理逻辑,简化代码结构

im
YunaiV 2026-04-27 14:30:38 +08:00
parent cba5c15604
commit fc82ed3d7e
1 changed files with 6 additions and 5 deletions

View File

@ -347,8 +347,8 @@ function onPaste(e: ClipboardEvent) {
// 1. clipboardData.items /
const items = e.clipboardData?.items
if (items?.length) {
// TODO @AI linter
for (const item of items) {
for (let i = 0; i < items.length; i++) {
const item = items[i]
if (item.kind !== 'file') {
continue
}
@ -452,9 +452,10 @@ function detectAtMention() {
const node = range.startContainer
const offset = range.startOffset
const before = (node.textContent || '').slice(0, offset)
// (?:^|\s) @ email-like "test@example.com"
// match[1] @ = offset - keyword.length - 1
const match = before.match(/(?:^|\s)@([^\s@]*)$/)
// @" @ "@@
// email-like "test@example.com" email
// Esc [^\s@] / @
const match = before.match(/@([^\s@]*)$/)
if (!match) {
closeMention()
return