复用引用节点插入逻辑
统一资源与 Skill 候选的 Lexical 节点插入流程 避免两个选择处理器在删除查询和关闭菜单行为上漂移
This commit is contained in:
+25
-29
@@ -858,41 +858,15 @@ function ResourceReferenceEditor({
|
||||
[editor, pickerOpen],
|
||||
);
|
||||
|
||||
const handleSelectMention = useCallback(
|
||||
const insertReferenceNode = useCallback(
|
||||
(
|
||||
option: ResourceMentionOption,
|
||||
reference: ChatReference,
|
||||
textNodeContainingQuery: TextNode | null,
|
||||
closeMenu: () => void,
|
||||
) => {
|
||||
textNodeContainingQuery?.remove();
|
||||
const selection = $getSelection();
|
||||
if ($isRangeSelection(selection)) {
|
||||
selection.insertNodes([
|
||||
$createResourceReferenceNode(option.reference),
|
||||
$createTextNode(' '),
|
||||
]);
|
||||
} else {
|
||||
const paragraph = $createParagraphNode();
|
||||
paragraph.append(
|
||||
$createResourceReferenceNode(option.reference),
|
||||
$createTextNode(' '),
|
||||
);
|
||||
$getRoot().append(paragraph);
|
||||
}
|
||||
closeMenu();
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleSelectSkill = useCallback(
|
||||
(
|
||||
option: SkillMentionOption,
|
||||
textNodeContainingQuery: TextNode | null,
|
||||
closeMenu: () => void,
|
||||
) => {
|
||||
textNodeContainingQuery?.remove();
|
||||
const selection = $getSelection();
|
||||
const node = $createResourceReferenceNode(option.skill);
|
||||
const node = $createResourceReferenceNode(reference);
|
||||
if ($isRangeSelection(selection)) {
|
||||
selection.insertNodes([node, $createTextNode(' ')]);
|
||||
} else {
|
||||
@@ -905,6 +879,28 @@ function ResourceReferenceEditor({
|
||||
[],
|
||||
);
|
||||
|
||||
const handleSelectMention = useCallback(
|
||||
(
|
||||
option: ResourceMentionOption,
|
||||
textNodeContainingQuery: TextNode | null,
|
||||
closeMenu: () => void,
|
||||
) => {
|
||||
insertReferenceNode(option.reference, textNodeContainingQuery, closeMenu);
|
||||
},
|
||||
[insertReferenceNode],
|
||||
);
|
||||
|
||||
const handleSelectSkill = useCallback(
|
||||
(
|
||||
option: SkillMentionOption,
|
||||
textNodeContainingQuery: TextNode | null,
|
||||
closeMenu: () => void,
|
||||
) => {
|
||||
insertReferenceNode(option.skill, textNodeContainingQuery, closeMenu);
|
||||
},
|
||||
[insertReferenceNode],
|
||||
);
|
||||
|
||||
// —— C8 AI 润色与发送前提醒 ——
|
||||
// 润色状态机抽到 `usePromptPolish`(资源侧两处入口共用同一份);这里只剩下
|
||||
// 聊天特有的「发送前提醒」:提醒偏好、本轮已确认草稿指纹与表单拦截。
|
||||
|
||||
Reference in New Issue
Block a user