listpage-next 0.0.262 → 0.0.264
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/ChatClient/components/ChatContent/BubbleList.js +6 -1
- package/dist/features/ChatClient/context/useChatContext.d.ts +1 -0
- package/dist/features/ChatClient/context/useChatContext.js +2 -1
- package/dist/features/ChatClient/ui/Bubble/Bubble.js +2 -0
- package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +4 -0
- package/dist/features/ChatClient/ui/Bubble/BubbleList.js +2 -4
- package/dist/features/ChatClient/ui/Bubble/Markdown.d.ts +4 -0
- package/dist/features/ChatClient/ui/Bubble/Markdown.js +12 -32
- package/package.json +3 -2
|
@@ -23,10 +23,15 @@ const ChatBubbleList = (props)=>{
|
|
|
23
23
|
scrollToBottom,
|
|
24
24
|
scrollToBottomWhenAtBottom
|
|
25
25
|
}), [
|
|
26
|
-
scrollToBottom
|
|
26
|
+
scrollToBottom,
|
|
27
|
+
scrollToBottomWhenAtBottom
|
|
27
28
|
]);
|
|
28
29
|
return /*#__PURE__*/ jsx(BubbleList, {
|
|
29
30
|
styles: styles,
|
|
31
|
+
refs: {
|
|
32
|
+
bottomRef,
|
|
33
|
+
containerRef
|
|
34
|
+
},
|
|
30
35
|
messages: ctx.messages,
|
|
31
36
|
messageRender: (message)=>render.renderMessage(message, ctx)
|
|
32
37
|
});
|
|
@@ -9,5 +9,6 @@ export declare function useChatContext(): {
|
|
|
9
9
|
updateConversation: ((key: string, item: any) => void) | undefined;
|
|
10
10
|
appendConversation: ((item: any, index?: number) => void) | undefined;
|
|
11
11
|
scrollToBottom: () => void;
|
|
12
|
+
scrollToBottomWhenAtBottom: () => void;
|
|
12
13
|
};
|
|
13
14
|
export type ChatInstance = ReturnType<typeof useChatContext>;
|
|
@@ -14,7 +14,8 @@ function useChatContext() {
|
|
|
14
14
|
deleteConversation: deleteItem,
|
|
15
15
|
updateConversation: updateItem,
|
|
16
16
|
appendConversation: appendItem,
|
|
17
|
-
scrollToBottom: ()=>bubbleListRef.current?.scrollToBottom()
|
|
17
|
+
scrollToBottom: ()=>bubbleListRef.current?.scrollToBottom(),
|
|
18
|
+
scrollToBottomWhenAtBottom: ()=>bubbleListRef.current?.scrollToBottomWhenAtBottom()
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export { useChatContext };
|
|
@@ -14,9 +14,11 @@ const Bubble = (props)=>{
|
|
|
14
14
|
const hovered = containerHovered || feedbackHovered;
|
|
15
15
|
const cursorPlaceholder = 'pending' === status && 'assistant' === role ? '<placeholder type="pending" />' : '';
|
|
16
16
|
const messageMarkdownEle = markdownRender ? markdownRender(content || '', status) : /*#__PURE__*/ jsx(Markdown, {
|
|
17
|
+
hasNextChunk: 'success' !== status,
|
|
17
18
|
content: (content || '') + cursorPlaceholder
|
|
18
19
|
});
|
|
19
20
|
const reasoningMarkdownEle = reasoningMarkdownRender ? reasoningMarkdownRender(reasoning_content || '', status) : /*#__PURE__*/ jsx(Markdown, {
|
|
21
|
+
hasNextChunk: !content,
|
|
20
22
|
content: reasoning_content || ''
|
|
21
23
|
});
|
|
22
24
|
const message = 'user' === role ? /*#__PURE__*/ jsx(UserContentWrapper, {
|
|
@@ -6,6 +6,10 @@ export interface BubbleListProps<MessageInfo extends BaseMessageInfo> {
|
|
|
6
6
|
bottomPlaceholder?: CSSProperties;
|
|
7
7
|
content?: CSSProperties;
|
|
8
8
|
};
|
|
9
|
+
refs: {
|
|
10
|
+
bottomRef: React.Ref<HTMLDivElement>;
|
|
11
|
+
containerRef: React.Ref<HTMLDivElement>;
|
|
12
|
+
};
|
|
9
13
|
loading?: boolean;
|
|
10
14
|
messages: Message<MessageInfo>[];
|
|
11
15
|
messageRender: (message: Message<MessageInfo>) => React.ReactNode;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
2
|
import { styled } from "styled-components";
|
|
4
3
|
import { PageLoading } from "../../../../components/PageLayout/index.js";
|
|
5
4
|
const BubbleList = (props)=>{
|
|
6
|
-
const { loading, styles, messages, messageRender } = props;
|
|
7
|
-
const bottomRef =
|
|
8
|
-
const containerRef = useRef(null);
|
|
5
|
+
const { loading, styles, messages, messageRender, refs } = props;
|
|
6
|
+
const { bottomRef, containerRef } = refs;
|
|
9
7
|
const content = [
|
|
10
8
|
/*#__PURE__*/ jsx("div", {
|
|
11
9
|
style: styles?.headerPlaceholder ?? {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { XMarkdownProps } from '@ant-design/x-markdown';
|
|
2
|
+
import '@ant-design/x-markdown/themes/light.css';
|
|
1
3
|
export interface MarkdownProps {
|
|
2
4
|
content: string;
|
|
5
|
+
hasNextChunk?: boolean;
|
|
6
|
+
components?: XMarkdownProps['components'];
|
|
3
7
|
}
|
|
4
8
|
export declare const Markdown: (props: MarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,39 +1,19 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import markdown_it from "markdown-it";
|
|
3
2
|
import styled_components from "styled-components";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
breaks: true
|
|
7
|
-
});
|
|
8
|
-
const defaultLinkOpen = md.renderer.rules.link_open || function(tokens, idx, options, env, self) {
|
|
9
|
-
return self.renderToken(tokens, idx, options);
|
|
10
|
-
};
|
|
11
|
-
md.renderer.rules.link_open = function(tokens, idx, options, env, self) {
|
|
12
|
-
const targetIndex = tokens[idx].attrIndex('target');
|
|
13
|
-
if (targetIndex < 0) tokens[idx].attrPush([
|
|
14
|
-
'target',
|
|
15
|
-
'_blank'
|
|
16
|
-
]);
|
|
17
|
-
else tokens[idx].attrs[targetIndex][1] = '_blank';
|
|
18
|
-
const relIndex = tokens[idx].attrIndex('rel');
|
|
19
|
-
if (relIndex < 0) tokens[idx].attrPush([
|
|
20
|
-
'rel',
|
|
21
|
-
'noopener noreferrer'
|
|
22
|
-
]);
|
|
23
|
-
else tokens[idx].attrs[relIndex][1] = 'noopener noreferrer';
|
|
24
|
-
return defaultLinkOpen(tokens, idx, options, env, self);
|
|
25
|
-
};
|
|
26
|
-
md.renderer.rules.text = (tokens, idx)=>{
|
|
27
|
-
let text = tokens[idx].content;
|
|
28
|
-
text = text.replace(/\[\[(-?\d+(\.\d+)?)\]\]/g, '<sup>[$1]</sup>');
|
|
29
|
-
return text;
|
|
30
|
-
};
|
|
3
|
+
import x_markdown from "@ant-design/x-markdown";
|
|
4
|
+
import "@ant-design/x-markdown/themes/light.css";
|
|
31
5
|
const Markdown = (props)=>/*#__PURE__*/ jsx(MarkdownBody, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
streaming: {
|
|
7
|
+
enableAnimation: true,
|
|
8
|
+
hasNextChunk: props.hasNextChunk,
|
|
9
|
+
animationConfig: {
|
|
10
|
+
fadeDuration: 400
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
content: props.content,
|
|
14
|
+
openLinksInNewTab: true
|
|
35
15
|
});
|
|
36
|
-
const MarkdownBody = styled_components
|
|
16
|
+
const MarkdownBody = styled_components(x_markdown)`
|
|
37
17
|
h1 {
|
|
38
18
|
font-size: 18px;
|
|
39
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.264",
|
|
4
4
|
"description": "A React component library for creating filter forms with Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"json-schema-faker": "~0.5.9",
|
|
96
96
|
"ansi-to-html": "~0.7.2",
|
|
97
97
|
"@aws-sdk/client-s3": "~3.946.0",
|
|
98
|
-
"@google/genai": "~1.31.0"
|
|
98
|
+
"@google/genai": "~1.31.0",
|
|
99
|
+
"@ant-design/x-markdown": "~2.1.1"
|
|
99
100
|
}
|
|
100
101
|
}
|