mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-05-02 10:10:44 +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 { resourceSuggestion } from "./resource-suggestion";
|
||||||
import React, { forwardRef, useEffect, useMemo, useRef } from "react";
|
import React, { forwardRef, useEffect, useMemo, useRef } from "react";
|
||||||
import type { Resource } from "~/core/messages";
|
import type { Resource } from "~/core/messages";
|
||||||
import { useConfig } from "~/core/api/hooks";
|
|
||||||
import { LoadingOutlined } from "@ant-design/icons";
|
import { LoadingOutlined } from "@ant-design/icons";
|
||||||
import type { DeerFlowConfig } from "~/core/config";
|
import type { DeerFlowConfig } from "~/core/config";
|
||||||
|
|
||||||
|
|||||||
@@ -35,17 +35,26 @@ export const resourceSuggestion: MentionOptions["suggestion"] = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
onStart: (props) => {
|
onStart: (props) => {
|
||||||
if (!props.clientRect) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
reactRenderer = new ReactRenderer(ResourceMentions, {
|
reactRenderer = new ReactRenderer(ResourceMentions, {
|
||||||
props,
|
props,
|
||||||
editor: props.editor,
|
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", {
|
popup = tippy("body", {
|
||||||
getReferenceClientRect: props.clientRect as any,
|
getReferenceClientRect: clientRect as any,
|
||||||
appendTo: () => document.body,
|
appendTo: () => document.body,
|
||||||
content: reactRenderer.element,
|
content: reactRenderer.element,
|
||||||
showOnCreate: true,
|
showOnCreate: true,
|
||||||
@@ -56,15 +65,28 @@ export const resourceSuggestion: MentionOptions["suggestion"] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onUpdate(props) {
|
onUpdate(props) {
|
||||||
reactRenderer.updateProps(props);
|
if (reactRenderer) {
|
||||||
|
reactRenderer.updateProps(props);
|
||||||
if (!props.clientRect) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
popup?.[0]?.setProps({
|
if (popup?.[0] && !popup[0].state.isDestroyed) {
|
||||||
getReferenceClientRect: props.clientRect as any,
|
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) {
|
onKeyDown(props) {
|
||||||
|
|||||||
Reference in New Issue
Block a user