listpage-next 0.0.168 → 0.0.170

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.
Files changed (65) hide show
  1. package/dist/demos/demo8.js +42 -21
  2. package/dist/features/ChatClient/components/ChatContent/BubbleList.d.ts +4 -8
  3. package/dist/features/ChatClient/components/ChatContent/BubbleList.js +8 -28
  4. package/dist/features/ChatClient/components/ChatContent/ClientContentBody.d.ts +4 -2
  5. package/dist/features/ChatClient/components/ChatContent/ClientContentBody.js +6 -6
  6. package/dist/features/ChatClient/components/ChatContent/index.d.ts +6 -4
  7. package/dist/features/ChatClient/components/ChatContent/index.js +4 -3
  8. package/dist/features/ChatClient/components/ChatSender/index.js +10 -8
  9. package/dist/features/ChatClient/components/HistoryConversation/index.d.ts +3 -9
  10. package/dist/features/ChatClient/components/HistoryConversation/index.js +20 -73
  11. package/dist/features/ChatClient/components/HistoryConversation/styles.d.ts +0 -5
  12. package/dist/features/ChatClient/components/HistoryConversation/styles.js +17 -45
  13. package/dist/features/ChatClient/components/Logo/index.d.ts +1 -1
  14. package/dist/features/ChatClient/components/Logo/index.js +9 -9
  15. package/dist/features/ChatClient/index.d.ts +1 -4
  16. package/dist/features/ChatClient/index.js +1 -4
  17. package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +13 -0
  18. package/dist/features/ChatClient/ui/Bubble/BubbleList.js +41 -0
  19. package/dist/features/ChatClient/{components → ui}/Bubble/index.d.ts +2 -0
  20. package/dist/features/ChatClient/{components → ui}/Bubble/index.js +2 -0
  21. package/dist/features/ChatClient/ui/ConversationList/index.d.ts +21 -0
  22. package/dist/features/ChatClient/ui/ConversationList/index.js +85 -0
  23. package/dist/features/ChatClient/ui/ConversationList/styles.d.ts +5 -0
  24. package/dist/features/ChatClient/ui/ConversationList/styles.js +30 -0
  25. package/dist/features/ChatClient/ui/EditorContent/constants.d.ts +3 -0
  26. package/dist/features/ChatClient/ui/EditorContent/constants.js +4 -0
  27. package/dist/features/ChatClient/ui/EditorContent/editor.d.ts +13 -0
  28. package/dist/features/ChatClient/ui/EditorContent/editor.js +97 -0
  29. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.d.ts +2 -0
  30. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.js +44 -0
  31. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.d.ts +4 -0
  32. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.js +54 -0
  33. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.d.ts +24 -0
  34. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.js +331 -0
  35. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.d.ts +3 -0
  36. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.js +83 -0
  37. package/dist/features/ChatClient/ui/EditorContent/index.d.ts +2 -0
  38. package/dist/features/ChatClient/ui/EditorContent/index.js +2 -0
  39. package/dist/features/ChatClient/ui/EditorContent/utils.d.ts +7 -0
  40. package/dist/features/ChatClient/ui/EditorContent/utils.js +10 -0
  41. package/dist/features/ChatClient/ui/index.d.ts +5 -0
  42. package/dist/features/ChatClient/ui/index.js +5 -0
  43. package/dist/features/ChatClient/utils/parseSse.d.ts +1 -1
  44. package/dist/features/ChatClient/utils/parseSse.js +1 -1
  45. package/package.json +11 -2
  46. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.d.ts +0 -0
  47. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.js +0 -0
  48. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.d.ts +0 -0
  49. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.js +0 -0
  50. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.d.ts +0 -0
  51. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.js +0 -0
  52. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.d.ts +0 -0
  53. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.js +0 -0
  54. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.d.ts +0 -0
  55. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.js +0 -0
  56. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.d.ts +0 -0
  57. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.js +0 -0
  58. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.d.ts +0 -0
  59. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.js +1 -1
  60. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.d.ts +0 -0
  61. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.js +0 -0
  62. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.d.ts +0 -0
  63. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.js +0 -0
  64. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.d.ts +0 -0
  65. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.js +0 -0
@@ -0,0 +1,85 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Avatar, Button, Dropdown, Typography } from "antd";
4
+ import { ListContainer, ListItemContainer, ListText } from "./styles.js";
5
+ import { MessageOutlined, MoreOutlined } from "@ant-design/icons";
6
+ import { InfiniteList } from "../../../../components/InfiniteList/index.js";
7
+ const ConversationList = (props)=>{
8
+ const { ref, rowKey, request, menus = [], defaultActiveKey, onSelectConversation, onDeleteConversation, onRenameConversation } = props;
9
+ const [activeKey, setActiveKey] = useState(defaultActiveKey);
10
+ return /*#__PURE__*/ jsx(ListContainer, {
11
+ children: /*#__PURE__*/ jsx(InfiniteList, {
12
+ pageSize: 10,
13
+ rowKey: rowKey,
14
+ ref: ref,
15
+ request: request,
16
+ renderItem: (item, index, actions)=>{
17
+ const key = item[rowKey];
18
+ const items = [
19
+ ...menus.map((menu)=>({
20
+ ...menu,
21
+ onClick: ()=>menu.onClick?.(item, index, actions)
22
+ })),
23
+ onRenameConversation && {
24
+ key: 'rename',
25
+ label: '重命名',
26
+ onClick: async ()=>{
27
+ const newItem = await onRenameConversation?.(item);
28
+ if (!newItem) return;
29
+ actions.updateItem(key, newItem);
30
+ }
31
+ },
32
+ onDeleteConversation && {
33
+ key: 'delete',
34
+ danger: true,
35
+ label: '删除',
36
+ onClick: async ()=>{
37
+ await onDeleteConversation?.(item);
38
+ setActiveKey('');
39
+ actions.deleteItem(key);
40
+ }
41
+ }
42
+ ].filter(Boolean);
43
+ return /*#__PURE__*/ jsxs(ListItemContainer, {
44
+ isHover: activeKey === key ? true : void 0,
45
+ onClick: ()=>{
46
+ if (activeKey === key) return;
47
+ setActiveKey?.(key);
48
+ onSelectConversation?.(item);
49
+ },
50
+ children: [
51
+ /*#__PURE__*/ jsx(Avatar, {
52
+ size: 20,
53
+ icon: item.icon || /*#__PURE__*/ jsx(MessageOutlined, {})
54
+ }),
55
+ /*#__PURE__*/ jsx(ListText, {
56
+ children: /*#__PURE__*/ jsx(Typography.Text, {
57
+ ellipsis: {
58
+ tooltip: {
59
+ title: item.title,
60
+ placement: 'right'
61
+ }
62
+ },
63
+ children: item.title
64
+ })
65
+ }),
66
+ /*#__PURE__*/ jsx("div", {
67
+ onClick: (e)=>e.stopPropagation(),
68
+ children: /*#__PURE__*/ jsx(Dropdown, {
69
+ menu: {
70
+ items
71
+ },
72
+ children: /*#__PURE__*/ jsx(Button, {
73
+ type: "text",
74
+ size: "small",
75
+ icon: /*#__PURE__*/ jsx(MoreOutlined, {})
76
+ })
77
+ })
78
+ })
79
+ ]
80
+ });
81
+ }
82
+ })
83
+ });
84
+ };
85
+ export { ConversationList };
@@ -0,0 +1,5 @@
1
+ export declare const ListContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
+ export declare const ListItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
3
+ isHover?: boolean;
4
+ }>> & string;
5
+ export declare const ListText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,30 @@
1
+ import styled_components from "styled-components";
2
+ const ListContainer = styled_components.div`
3
+ flex: 1;
4
+ overflow: hidden;
5
+ padding: 0 2px;
6
+ `;
7
+ const ListItemContainer = styled_components.div`
8
+ display: flex;
9
+ align-items: center;
10
+ padding: 8px 4px;
11
+ border-radius: 8px;
12
+ cursor: pointer;
13
+ gap: 4px;
14
+
15
+ background-color: ${(props)=>props.isHover ? '#0000000a' : 'transparent'};
16
+
17
+ &:hover {
18
+ background-color: #0000000a;
19
+ }
20
+ `;
21
+ const ListText = styled_components.div`
22
+ flex: 1;
23
+
24
+ overflow: hidden;
25
+ text-overflow: ellipsis;
26
+ white-space: nowrap;
27
+ word-break: break-all;
28
+ word-wrap: break-word;
29
+ `;
30
+ export { ListContainer, ListItemContainer, ListText };
@@ -0,0 +1,3 @@
1
+ export declare const strings: {
2
+ ZERO_WIDTH_CHAR: string;
3
+ };
@@ -0,0 +1,4 @@
1
+ const strings = {
2
+ ZERO_WIDTH_CHAR: '\u200B'
3
+ };
4
+ export { strings };
@@ -0,0 +1,13 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { RefObject } from 'react';
3
+ export interface EditorContentProps {
4
+ placeholder?: string;
5
+ editorRef?: RefObject<Editor | null>;
6
+ onKeyDown?: (e: KeyboardEvent) => void;
7
+ onChange?: (content: string) => void;
8
+ handleKeyDown?: (view: any, event: KeyboardEvent) => boolean;
9
+ onFocus?: (event: FocusEvent) => void;
10
+ onBlur?: (event: FocusEvent) => void;
11
+ handleCreate?: () => void;
12
+ }
13
+ export declare const EditorContent: (props: EditorContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { EditorContent, useEditor } from "@tiptap/react";
3
+ import { useCallback, useEffect, useMemo, useRef } from "react";
4
+ import extension_document from "@tiptap/extension-document";
5
+ import extension_text from "@tiptap/extension-text";
6
+ import { Placeholder, UndoRedo } from "@tiptap/extensions";
7
+ import extension_paragraph from "@tiptap/extension-paragraph";
8
+ import extension_hard_break from "@tiptap/extension-hard-break";
9
+ import styled_components from "styled-components";
10
+ import { handleCompositionEndLogic, handlePasteLogic, handleTextInputLogic, handleZeroWidthCharLogic } from "./extensions/plugins.js";
11
+ import inputSlot from "./extensions/inputSlot/index.js";
12
+ import skillSlot from "./extensions/skillSlot/index.js";
13
+ const editor_EditorContent = (props)=>{
14
+ const { editorRef, onKeyDown, onChange, placeholder, handleKeyDown, onFocus, onBlur, handleCreate } = props;
15
+ const isComposing = useRef(false);
16
+ const handleCompositionStart = useCallback((view)=>{
17
+ isComposing.current = true;
18
+ }, []);
19
+ const handleCompositionEnd = useCallback((view)=>{
20
+ isComposing.current = false;
21
+ handleCompositionEndLogic(view);
22
+ }, []);
23
+ const handleTextInput = useCallback((view, from, to, text)=>{
24
+ if (isComposing.current) return false;
25
+ return handleTextInputLogic(view, from, to, text);
26
+ }, []);
27
+ const allExtensions = useMemo(()=>[
28
+ extension_document,
29
+ extension_paragraph,
30
+ extension_text,
31
+ UndoRedo,
32
+ extension_hard_break,
33
+ inputSlot,
34
+ skillSlot,
35
+ Placeholder.configure({
36
+ placeholder: placeholder
37
+ })
38
+ ], [
39
+ placeholder
40
+ ]);
41
+ const editorProps = useMemo(()=>({
42
+ handleKeyDown: handleKeyDown,
43
+ handlePaste: handlePasteLogic,
44
+ handleTextInput,
45
+ handleDOMEvents: {
46
+ compositionstart: handleCompositionStart,
47
+ compositionend: handleCompositionEnd
48
+ }
49
+ }), [
50
+ handleKeyDown,
51
+ handleTextInput,
52
+ handleCompositionStart,
53
+ handleCompositionEnd
54
+ ]);
55
+ const onCreate = useCallback(({ editor })=>{
56
+ const { state, view } = editor;
57
+ const tr = handleZeroWidthCharLogic(state);
58
+ if (tr) view.dispatch(tr);
59
+ handleCreate?.();
60
+ }, [
61
+ handleCreate
62
+ ]);
63
+ const onUpdate = useCallback(({ editor })=>{
64
+ const content = editor.getText();
65
+ onChange?.(content);
66
+ }, [
67
+ onChange
68
+ ]);
69
+ const editor = useEditor({
70
+ extensions: allExtensions,
71
+ content: "",
72
+ editorProps: editorProps,
73
+ onCreate,
74
+ onUpdate
75
+ });
76
+ useEffect(()=>{
77
+ if (editorRef) editorRef.current = editor;
78
+ }, [
79
+ editor,
80
+ editorRef
81
+ ]);
82
+ return /*#__PURE__*/ jsx(EditorContentStyled, {
83
+ editor: editor,
84
+ onKeyDown: onKeyDown,
85
+ onFocus: onFocus,
86
+ onBlur: onBlur
87
+ });
88
+ };
89
+ const EditorContentStyled = styled_components(EditorContent)`
90
+ .ProseMirror {
91
+ outline: none;
92
+ p {
93
+ margin: 2px 0;
94
+ }
95
+ }
96
+ `;
97
+ export { editor_EditorContent as EditorContent };
@@ -0,0 +1,2 @@
1
+ declare const _default: (props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -0,0 +1,44 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { NodeViewContent, NodeViewWrapper } from "@tiptap/react";
3
+ import { useLayoutEffect, useRef, useState } from "react";
4
+ import { strings } from "../../constants.js";
5
+ const component = (props)=>{
6
+ const isEmpty = props.node.textContent === strings.ZERO_WIDTH_CHAR;
7
+ const placeholder = props.node.attrs.placeholder || '';
8
+ const placeholderRef = useRef(null);
9
+ const [placeholderWidth, setPlaceholderWidth] = useState(void 0);
10
+ useLayoutEffect(()=>{
11
+ if (isEmpty && placeholderRef.current) {
12
+ const timer = setTimeout(()=>{
13
+ setPlaceholderWidth(placeholderRef.current?.offsetWidth);
14
+ });
15
+ return ()=>{
16
+ clearTimeout(timer);
17
+ };
18
+ }
19
+ }, [
20
+ isEmpty,
21
+ placeholder
22
+ ]);
23
+ return /*#__PURE__*/ jsxs(NodeViewWrapper, {
24
+ as: "span",
25
+ className: "input-slot",
26
+ style: {
27
+ minWidth: isEmpty && placeholderWidth ? `${placeholderWidth}px` : void 0
28
+ },
29
+ children: [
30
+ isEmpty && /*#__PURE__*/ jsx("span", {
31
+ ref: placeholderRef,
32
+ "data-placeholder": true,
33
+ contentEditable: false,
34
+ className: "input-slot-placeholder",
35
+ children: placeholder
36
+ }),
37
+ /*#__PURE__*/ jsx(NodeViewContent, {
38
+ as: "div",
39
+ className: "content"
40
+ })
41
+ ]
42
+ });
43
+ };
44
+ export { component as default };
@@ -0,0 +1,4 @@
1
+ import { Node } from '@tiptap/core';
2
+ export declare const REACT_COMPONENT_NODE_NAME = "inputSlot";
3
+ declare const _default: Node<any, any>;
4
+ export default _default;
@@ -0,0 +1,54 @@
1
+ import { Node, mergeAttributes } from "@tiptap/core";
2
+ import { ReactNodeViewRenderer } from "@tiptap/react";
3
+ import component from "./component.js";
4
+ import { ensureTrailingText, keyDownHandlePlugin } from "../plugins.js";
5
+ import { getCustomSlotAttribute } from "../../utils.js";
6
+ const REACT_COMPONENT_NODE_NAME = 'inputSlot';
7
+ const inputSlot = Node.create({
8
+ name: 'inputSlot',
9
+ group: 'inline',
10
+ inline: true,
11
+ content: 'inline*',
12
+ atom: false,
13
+ selectable: true,
14
+ draggable: false,
15
+ parseHTML () {
16
+ return [
17
+ {
18
+ tag: 'input-slot',
19
+ getAttrs: (element)=>({
20
+ placeholder: element.getAttribute('placeholder')
21
+ })
22
+ }
23
+ ];
24
+ },
25
+ renderHTML ({ HTMLAttributes }) {
26
+ return [
27
+ 'input-slot',
28
+ mergeAttributes(HTMLAttributes),
29
+ 0
30
+ ];
31
+ },
32
+ addAttributes () {
33
+ return {
34
+ placeholder: {
35
+ default: '',
36
+ parseHTML: (element)=>element.getAttribute('placeholder') || '',
37
+ renderHTML: (attributes)=>({
38
+ placeholder: attributes.placeholder
39
+ })
40
+ },
41
+ isCustomSlot: getCustomSlotAttribute()
42
+ };
43
+ },
44
+ addNodeView () {
45
+ return ReactNodeViewRenderer(component);
46
+ },
47
+ addProseMirrorPlugins () {
48
+ return [
49
+ ensureTrailingText(this.editor.schema),
50
+ keyDownHandlePlugin(this.editor.schema)
51
+ ];
52
+ }
53
+ });
54
+ export { REACT_COMPONENT_NODE_NAME, inputSlot as default };
@@ -0,0 +1,24 @@
1
+ import { EditorState, Plugin, Transaction } from 'prosemirror-state';
2
+ import { EditorView } from '@tiptap/pm/view';
3
+ /**
4
+ * @param newState
5
+ * @returns
6
+ * handleZeroWidthCharLogic 用于插入零宽字符或者删除多余的零宽字符
7
+ * 为什么需要插入零宽字符?
8
+ * 1. 保证自定义节点前后的光标高度正常,光标高度和内容相关,解决自定义节点是最后一个节点,
9
+ * 光标高度会和自定义节点占据高度一致,和文本中光标高度不一致的问题
10
+ * 2. 保证对于可编辑的 inline 节点(比如 input-slot),为最后一个节点时候,光标可以聚焦到该节点后
11
+ * Why do we need to insert zero-width characters?
12
+ * 1. Ensure that the cursor height before and after the custom node is normal.
13
+ * The cursor height is related to the content. Solve the problem that when the custom node is the last node,
14
+ * the cursor height will be consistent with the height occupied by the custom node, and inconsistent with the cursor height in the text.
15
+ * 2. Ensure that for an editable inline node (such as input-slot), when it is the last node, the cursor can focus after the node.
16
+ */
17
+ export declare function handleZeroWidthCharLogic(newState: EditorState): Transaction | null;
18
+ export declare function ensureTrailingText(schema: any): Plugin;
19
+ export declare function keyDownHandlePlugin(schema: any): Plugin;
20
+ export declare function handlePasteLogic(view: EditorView, event: ClipboardEvent): boolean;
21
+ export declare function removeZeroWidthChar($from: any, tr: Transaction): boolean;
22
+ export declare function removeZeroWidthCharForComposition($from: any, tr: Transaction): Transaction | null;
23
+ export declare function handleCompositionEndLogic(view: EditorView): void;
24
+ export declare function handleTextInputLogic(view: EditorView, from: number, to: number, text: string): boolean;