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