mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
fix: frontend supports chinese for listing datasets in RAG (#582)
* fix-web-rag * Update resource-suggestion.tsx
This commit is contained in:
@@ -21,7 +21,6 @@ import "~/styles/prosemirror.css";
|
||||
import { resourceSuggestion } from "./resource-suggestion";
|
||||
import React, { forwardRef, useEffect, useMemo, useRef } from "react";
|
||||
import type { Resource } from "~/core/messages";
|
||||
import { useConfig } from "~/core/api/hooks";
|
||||
import { LoadingOutlined } from "@ant-design/icons";
|
||||
import type { DeerFlowConfig } from "~/core/config";
|
||||
|
||||
|
||||
@@ -35,17 +35,26 @@ export const resourceSuggestion: MentionOptions["suggestion"] = {
|
||||
|
||||
return {
|
||||
onStart: (props) => {
|
||||
if (!props.clientRect) {
|
||||
return;
|
||||
}
|
||||
|
||||
reactRenderer = new ReactRenderer(ResourceMentions, {
|
||||
props,
|
||||
editor: props.editor,
|
||||
});
|
||||
|
||||
const clientRect = props.clientRect || (() => {
|
||||
const selection = props.editor.state.selection;
|
||||
const coords = props.editor.view.coordsAtPos(selection.from);
|
||||
return {
|
||||
top: coords.top,
|
||||
left: coords.left,
|
||||
right: coords.right,
|
||||
bottom: coords.bottom,
|
||||
width: 0,
|
||||
height: 0,
|
||||
};
|
||||
});
|
||||
|
||||
popup = tippy("body", {
|
||||
getReferenceClientRect: props.clientRect as any,
|
||||
getReferenceClientRect: clientRect as any,
|
||||
appendTo: () => document.body,
|
||||
content: reactRenderer.element,
|
||||
showOnCreate: true,
|
||||
@@ -56,15 +65,28 @@ export const resourceSuggestion: MentionOptions["suggestion"] = {
|
||||
},
|
||||
|
||||
onUpdate(props) {
|
||||
reactRenderer.updateProps(props);
|
||||
|
||||
if (!props.clientRect) {
|
||||
return;
|
||||
if (reactRenderer) {
|
||||
reactRenderer.updateProps(props);
|
||||
}
|
||||
|
||||
popup?.[0]?.setProps({
|
||||
getReferenceClientRect: props.clientRect as any,
|
||||
});
|
||||
if (popup?.[0] && !popup[0].state.isDestroyed) {
|
||||
const clientRect = props.clientRect || (() => {
|
||||
const selection = props.editor.state.selection;
|
||||
const coords = props.editor.view.coordsAtPos(selection.from);
|
||||
return {
|
||||
top: coords.top,
|
||||
left: coords.left,
|
||||
right: coords.right,
|
||||
bottom: coords.bottom,
|
||||
width: 0,
|
||||
height: 0,
|
||||
};
|
||||
});
|
||||
|
||||
popup[0].setProps({
|
||||
getReferenceClientRect: clientRect as any,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onKeyDown(props) {
|
||||
|
||||
Reference in New Issue
Block a user