listpage-next 0.0.167 → 0.0.169

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 (58) 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/ClientContentHeader.js +27 -22
  7. package/dist/features/ChatClient/components/ChatContent/index.d.ts +6 -4
  8. package/dist/features/ChatClient/components/ChatContent/index.js +4 -3
  9. package/dist/features/ChatClient/components/ChatSender/index.js +10 -8
  10. package/dist/features/ChatClient/components/Logo/index.d.ts +1 -1
  11. package/dist/features/ChatClient/components/Logo/index.js +9 -9
  12. package/dist/features/ChatClient/index.d.ts +1 -4
  13. package/dist/features/ChatClient/index.js +1 -4
  14. package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +11 -0
  15. package/dist/features/ChatClient/ui/Bubble/BubbleList.js +34 -0
  16. package/dist/features/ChatClient/{components → ui}/Bubble/index.d.ts +2 -0
  17. package/dist/features/ChatClient/{components → ui}/Bubble/index.js +2 -0
  18. package/dist/features/ChatClient/ui/EditorContent/constants.d.ts +3 -0
  19. package/dist/features/ChatClient/ui/EditorContent/constants.js +4 -0
  20. package/dist/features/ChatClient/ui/EditorContent/editor.d.ts +13 -0
  21. package/dist/features/ChatClient/ui/EditorContent/editor.js +97 -0
  22. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.d.ts +2 -0
  23. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/component.js +44 -0
  24. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.d.ts +4 -0
  25. package/dist/features/ChatClient/ui/EditorContent/extensions/inputSlot/index.js +54 -0
  26. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.d.ts +24 -0
  27. package/dist/features/ChatClient/ui/EditorContent/extensions/plugins.js +331 -0
  28. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.d.ts +3 -0
  29. package/dist/features/ChatClient/ui/EditorContent/extensions/skillSlot/index.js +83 -0
  30. package/dist/features/ChatClient/ui/EditorContent/index.d.ts +2 -0
  31. package/dist/features/ChatClient/ui/EditorContent/index.js +2 -0
  32. package/dist/features/ChatClient/ui/EditorContent/utils.d.ts +7 -0
  33. package/dist/features/ChatClient/ui/EditorContent/utils.js +10 -0
  34. package/dist/features/ChatClient/ui/index.d.ts +4 -0
  35. package/dist/features/ChatClient/ui/index.js +4 -0
  36. package/dist/features/ChatClient/utils/parseSse.d.ts +1 -1
  37. package/dist/features/ChatClient/utils/parseSse.js +1 -1
  38. package/package.json +12 -2
  39. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.d.ts +0 -0
  40. package/dist/features/ChatClient/{components → ui}/Bubble/Bubble.js +0 -0
  41. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.d.ts +0 -0
  42. package/dist/features/ChatClient/{components → ui}/Bubble/LinkCard.js +0 -0
  43. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.d.ts +0 -0
  44. package/dist/features/ChatClient/{components → ui}/Bubble/Markdown.js +0 -0
  45. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.d.ts +0 -0
  46. package/dist/features/ChatClient/{components → ui}/Bubble/Reasoning.js +0 -0
  47. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.d.ts +0 -0
  48. package/dist/features/ChatClient/{components → ui}/Bubble/ReferenceList.js +0 -0
  49. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.d.ts +0 -0
  50. package/dist/features/ChatClient/{components → ui}/Bubble/SuggestMessageList.js +0 -0
  51. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.d.ts +0 -0
  52. package/dist/features/ChatClient/{components → ui}/ChatDialog/index.js +1 -1
  53. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.d.ts +0 -0
  54. /package/dist/features/ChatClient/{components → ui}/ChatDialog/styles.js +0 -0
  55. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.d.ts +0 -0
  56. /package/dist/features/ChatClient/{components → ui}/ChatDialog/useExtra.js +0 -0
  57. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.d.ts +0 -0
  58. /package/dist/features/ChatClient/{components → ui}/ChatSplitter/index.js +0 -0
@@ -1,31 +1,52 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import "../features/ChatClient/index.js";
3
- import { SimplifyChatPage } from "../features/ChatClient/components/ChatPage/SimplifyChatPage.js";
4
- const Demo8 = ()=>/*#__PURE__*/ jsx(SimplifyChatPage, {
5
- style: {
6
- height: '100%'
7
- },
8
- initialMessages: [
2
+ import { ChatPage, ClientContent } from "../features/ChatClient/index.js";
3
+ import "../features/ChatClient/components/ChatPage/SimplifyChatPage.js";
4
+ const request = {
5
+ chat: async ()=>{},
6
+ getConversations: async ()=>({
7
+ list: [
8
+ {
9
+ id: '11',
10
+ title: 'xxxxxxx'
11
+ }
12
+ ]
13
+ }),
14
+ getMessages: ()=>[
9
15
  {
10
16
  role: 'user',
11
- content: '你是谁?'
17
+ content: 'xxxx'
12
18
  },
13
19
  {
14
20
  role: 'assistant',
15
- content: '我是一个AI'
16
- }
17
- ],
18
- request: {
19
- chat: function(info, callbacks) {
20
- throw new Error('Function not implemented.');
21
+ content: 'xxxx'
21
22
  }
23
+ ]
24
+ };
25
+ const Demo8 = ()=>/*#__PURE__*/ jsx("div", {
26
+ style: {
27
+ width: 1000
22
28
  },
23
- render: {
24
- renderMessage: function(message) {
25
- return /*#__PURE__*/ jsx("div", {
26
- children: message.info.content
27
- });
28
- }
29
- }
29
+ children: /*#__PURE__*/ jsx(ChatPage, {
30
+ request: request,
31
+ render: {
32
+ renderMessage (message) {
33
+ return /*#__PURE__*/ jsx("div", {
34
+ children: message.info.content
35
+ });
36
+ }
37
+ },
38
+ action: {
39
+ onClickConversation: void 0,
40
+ onClickNewConversation: void 0,
41
+ onRenameConversation: void 0,
42
+ onDeleteConversation: void 0
43
+ },
44
+ children: /*#__PURE__*/ jsx(ClientContent, {
45
+ style: {
46
+ height: '100%'
47
+ },
48
+ title: "搜索海量信息,生成研究报告"
49
+ })
50
+ })
30
51
  });
31
52
  export { Demo8 };
@@ -1,8 +1,4 @@
1
- import { CSSProperties } from 'react';
2
- export interface BubbleListProps {
3
- styles?: {
4
- bottomPlaceholder?: CSSProperties;
5
- content?: CSSProperties;
6
- };
7
- }
8
- export declare const BubbleList: (props: BubbleListProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { BaseMessageInfo } from '../../context';
2
+ import { BubbleListProps } from '../../ui';
3
+ export type ChatBubbleListProps<MessageInfo extends BaseMessageInfo = any> = Pick<BubbleListProps<MessageInfo>, 'styles'>;
4
+ export declare const ChatBubbleList: (props: ChatBubbleListProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { useImperativeHandle, useRef } from "react";
3
- import { styled } from "styled-components";
4
3
  import { useChatClientContext, useMessageContext } from "../../context/index.js";
5
- const BubbleList = (props)=>{
4
+ import { BubbleList } from "../../ui/index.js";
5
+ const ChatBubbleList = (props)=>{
6
6
  const { styles } = props;
7
7
  const bottomRef = useRef(null);
8
8
  const containerRef = useRef(null);
@@ -25,30 +25,10 @@ const BubbleList = (props)=>{
25
25
  }), [
26
26
  scrollToBottom
27
27
  ]);
28
- return /*#__PURE__*/ jsxs(ContentContainer, {
29
- ref: containerRef,
30
- children: [
31
- /*#__PURE__*/ jsx("div", {
32
- style: styles?.content,
33
- children: (ctx.messages ?? []).map((msg)=>render.renderMessage(msg, ctx))
34
- }),
35
- /*#__PURE__*/ jsx("div", {
36
- ref: bottomRef,
37
- style: styles?.bottomPlaceholder ?? {
38
- height: 60
39
- }
40
- })
41
- ]
28
+ return /*#__PURE__*/ jsx(BubbleList, {
29
+ styles: styles,
30
+ messages: ctx.messages,
31
+ messageRender: (message)=>render.renderMessage(message, ctx)
42
32
  });
43
33
  };
44
- const ContentContainer = styled.div`
45
- min-height: 100px;
46
- flex-grow: 1;
47
- flex-shrink: 1;
48
- overflow: auto;
49
- position: relative;
50
- width: 100%;
51
- box-sizing: border-box;
52
- padding: 0 calc((100% - 800px) / 2);
53
- `;
54
- export { BubbleList };
34
+ export { ChatBubbleList };
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * 极简版对话内容
3
3
  */
4
- import { BubbleListProps } from './BubbleList';
4
+ import { ChatBubbleListProps } from './BubbleList';
5
5
  import { ChatSenderProps } from '../ChatSender';
6
+ import { ReactNode } from 'react';
6
7
  export interface ClientContentBodyProps {
7
8
  senderProps?: ChatSenderProps;
8
- bubbleProps?: BubbleListProps;
9
+ bubbleProps?: ChatBubbleListProps;
9
10
  style?: React.CSSProperties;
11
+ sender?: ReactNode;
10
12
  }
11
13
  export declare const ClientContentBody: (props: ClientContentBodyProps) => import("react/jsx-runtime").JSX.Element;
12
14
  export declare const SimplifyClientContentBody: (props: ClientContentBodyProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,20 +1,20 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { BubbleList } from "./BubbleList.js";
2
+ import { ChatBubbleList } from "./BubbleList.js";
3
3
  import { ChatSender } from "../ChatSender/index.js";
4
4
  import { styled } from "styled-components";
5
5
  const ClientContentBody = (props)=>{
6
- const { senderProps, bubbleProps, style } = props;
6
+ const { senderProps, bubbleProps, style, sender } = props;
7
7
  return /*#__PURE__*/ jsxs(Content, {
8
8
  style: style,
9
9
  children: [
10
- /*#__PURE__*/ jsx(BubbleList, {
10
+ /*#__PURE__*/ jsx(ChatBubbleList, {
11
11
  ...bubbleProps
12
12
  }),
13
- /*#__PURE__*/ jsx(SenderContainer, {
13
+ void 0 === sender ? /*#__PURE__*/ jsx(SenderContainer, {
14
14
  children: /*#__PURE__*/ jsx(ChatSender, {
15
15
  ...senderProps
16
16
  })
17
- })
17
+ }) : sender
18
18
  ]
19
19
  });
20
20
  };
@@ -23,7 +23,7 @@ const SimplifyClientContentBody = (props)=>{
23
23
  return /*#__PURE__*/ jsxs(Content, {
24
24
  style: style,
25
25
  children: [
26
- /*#__PURE__*/ jsx(BubbleList, {
26
+ /*#__PURE__*/ jsx(ChatBubbleList, {
27
27
  ...bubbleProps
28
28
  }),
29
29
  /*#__PURE__*/ jsx(ChatSender, {
@@ -78,41 +78,46 @@ const HeaderLeft = (props)=>{
78
78
  });
79
79
  };
80
80
  const ActionContainer = styled.div`
81
- display: flex;
82
- align-items: center;
81
+ display: flex;
82
+ align-items: center;
83
83
 
84
- gap: 4px;
84
+ gap: 4px;
85
85
  `;
86
86
  const NameContainer = styled.div`
87
- display: flex;
88
- align-items: flex-start;
89
- flex-direction: column;
87
+ display: flex;
88
+ align-items: flex-start;
89
+ flex-direction: column;
90
90
  `;
91
91
  const NameText = styled.span`
92
- font-size: 14px;
93
- font-weight: 500;
94
- color: #000000;
92
+ font-size: 14px;
93
+ font-weight: 500;
94
+ color: #000000;
95
95
 
96
- font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
96
+ font-family:
97
+ ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
98
+ 'Segoe UI Symbol', 'Noto Color Emoji';
97
99
  `;
98
100
  const AiTipText = styled.span`
99
- font-size: 11px;
100
- color: #00000080;
101
- padding: 0 8px;
101
+ font-size: 11px;
102
+ color: #00000080;
103
+ padding: 0 8px;
102
104
  `;
103
105
  const Left = styled.div`
104
- display: flex;
105
- align-items: center;
106
+ display: flex;
107
+ align-items: center;
106
108
  `;
107
109
  const Right = styled.div`
108
-
110
+ flex-grow: 1;
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: flex-end;
109
114
  `;
110
115
  const HeaderContainer = styled.div`
111
- height: 60px;
112
- flex-shrink: 0;
113
- flex-grow: 0;
114
- display: flex;
115
- padding: 12.5px 0px;
116
- box-sizing: border-box;
116
+ height: 60px;
117
+ flex-shrink: 0;
118
+ flex-grow: 0;
119
+ display: flex;
120
+ padding: 12.5px 0px;
121
+ box-sizing: border-box;
117
122
  `;
118
123
  export { ClientContentHeader };
@@ -1,15 +1,17 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
- import { BubbleListProps } from './BubbleList';
3
- import { ChatSenderProps } from '../ChatSender';
2
+ import { ChatBubbleListProps } from './BubbleList';
3
+ import { ClientContentBodyProps } from './ClientContentBody';
4
4
  export interface ClientContentProps {
5
5
  style?: CSSProperties;
6
6
  className?: string;
7
7
  extra?: ReactNode;
8
8
  title?: string;
9
+ header?: ReactNode;
10
+ sender?: ReactNode;
9
11
  onTitleChange?: (title: string) => void;
10
12
  onClickNewConversation?: () => void;
11
13
  loading?: boolean;
12
- senderProps?: ChatSenderProps;
13
- bubbleProps?: BubbleListProps;
14
+ senderProps?: ClientContentBodyProps['senderProps'];
15
+ bubbleProps?: ChatBubbleListProps;
14
16
  }
15
17
  export declare const ClientContent: ({ loading, ...props }: ClientContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,18 +7,19 @@ import { ClientContentHeader } from "./ClientContentHeader.js";
7
7
  import { MessageProvider, useChatClientContext } from "../../context/index.js";
8
8
  import { PageLoading } from "../../../../components/Page/components/Loading/index.js";
9
9
  const ClientContentComponent = (props)=>{
10
- const { extra, style, className, title, onTitleChange, onClickNewConversation, senderProps, bubbleProps } = props;
10
+ const { extra, style, header, sender, className, title, onTitleChange, onClickNewConversation, senderProps, bubbleProps } = props;
11
11
  return /*#__PURE__*/ jsxs(Container, {
12
12
  style: style,
13
13
  className: className,
14
14
  children: [
15
- /*#__PURE__*/ jsx(ClientContentHeader, {
15
+ void 0 === header ? /*#__PURE__*/ jsx(ClientContentHeader, {
16
16
  defaultTitle: title,
17
17
  onTitleChange: onTitleChange,
18
18
  onClickNewConversation: onClickNewConversation,
19
19
  extra: extra
20
- }),
20
+ }) : header,
21
21
  /*#__PURE__*/ jsx(ClientContentBody, {
22
+ sender: sender,
22
23
  senderProps: senderProps,
23
24
  bubbleProps: bubbleProps
24
25
  })
@@ -1,7 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import { useRef, useState } from "react";
3
3
  import { Button, Divider, Input } from "antd";
4
4
  import { ArrowUpOutlined, PauseCircleTwoTone } from "@ant-design/icons";
5
+ import { EditorContent } from "../../ui/index.js";
5
6
  import { useChatClientContext, useMessageContext } from "../../context/index.js";
6
7
  import { ChatInputBottom, ChatInputContent, ChatInputPanel, MiniChatInputContent, MiniChatInputPanel } from "./styles.js";
7
8
  const ChatSender = (props)=>{
@@ -25,10 +26,12 @@ const ChatSender = (props)=>{
25
26
  };
26
27
  const PureChatSender = (props)=>{
27
28
  const { style, className, placeholder, extra, loading, onSubmit, mode = 'textarea' } = props;
28
- const [inputValue, setInputValue] = useState("");
29
+ const ref = useRef(null);
30
+ const [inputValue, setInputValue] = useState('');
29
31
  const handleClick = async ()=>{
30
32
  onSubmit?.(inputValue);
31
- setInputValue("");
33
+ setInputValue('');
34
+ ref.current?.commands.clearContent();
32
35
  };
33
36
  const handleKeyDown = (e)=>{
34
37
  if ('Enter' === e.key && !e.shiftKey) {
@@ -65,12 +68,11 @@ const PureChatSender = (props)=>{
65
68
  className: className,
66
69
  children: [
67
70
  /*#__PURE__*/ jsx(ChatInputContent, {
68
- children: /*#__PURE__*/ jsx(Input.TextArea, {
71
+ children: /*#__PURE__*/ jsx(EditorContent, {
69
72
  placeholder: placeholder,
70
- value: inputValue,
71
- autoSize: false,
72
- onChange: (e)=>setInputValue?.(e.target.value),
73
- onKeyDown: handleKeyDown
73
+ editorRef: ref,
74
+ onChange: (content)=>setInputValue(content),
75
+ onKeyDown: (e)=>handleKeyDown(e)
74
76
  })
75
77
  }),
76
78
  /*#__PURE__*/ jsxs(ChatInputBottom, {
@@ -1,4 +1,4 @@
1
- import { ReactNode } from "react";
1
+ import { ReactNode } from 'react';
2
2
  export interface LogoProps {
3
3
  icon: ReactNode;
4
4
  title: string;
@@ -9,7 +9,7 @@ const Logo = (props)=>{
9
9
  size: 36,
10
10
  shape: "circle",
11
11
  src: icon,
12
- icon: "AI"
12
+ icon: 'AI'
13
13
  }),
14
14
  /*#__PURE__*/ jsx(LogoTitle, {
15
15
  children: title
@@ -18,15 +18,15 @@ const Logo = (props)=>{
18
18
  });
19
19
  };
20
20
  const LogoContainer = styled.div`
21
- height: 36px;
22
- margin: 12px 0px 0px 0px;
23
- display: flex;
24
- gap: 8px;
25
- align-items: center;
21
+ height: 36px;
22
+ margin: 12px 0px 0px 0px;
23
+ display: flex;
24
+ gap: 8px;
25
+ align-items: center;
26
26
  `;
27
27
  const LogoTitle = styled.div`
28
- color: #000000d9;
29
- font-weight: 600;
30
- font-size: 16px;
28
+ color: #000000d9;
29
+ font-weight: 600;
30
+ font-size: 16px;
31
31
  `;
32
32
  export { Logo };
@@ -1,11 +1,8 @@
1
1
  export * from './components/ChatPage';
2
2
  export * from './components/ChatGuidance';
3
3
  export * from './components/ChatContent';
4
- export * from './components/Bubble';
5
4
  export { SimplifyChatPage, type SimplifyChatPageProps, } from './components/ChatPage/SimplifyChatPage';
6
- export * from './components/ChatDialog';
7
- export * from './components/ChatSplitter';
8
- export * from './components/Bubble/Markdown';
9
5
  export { useChatContext } from './context/useChatContext';
10
6
  export * from './context/types';
11
7
  export * from './utils/parseSse';
8
+ export * from './ui';
@@ -3,10 +3,7 @@ import { useChatContext } from "./context/useChatContext.js";
3
3
  export * from "./components/ChatPage/index.js";
4
4
  export * from "./components/ChatGuidance/index.js";
5
5
  export * from "./components/ChatContent/index.js";
6
- export * from "./components/Bubble/index.js";
7
- export * from "./components/ChatDialog/index.js";
8
- export * from "./components/ChatSplitter/index.js";
9
- export * from "./components/Bubble/Markdown.js";
10
6
  export * from "./context/types.js";
11
7
  export * from "./utils/parseSse.js";
8
+ export * from "./ui/index.js";
12
9
  export { SimplifyChatPage, useChatContext };
@@ -0,0 +1,11 @@
1
+ import { CSSProperties } from 'react';
2
+ import { BaseMessageInfo, Message } from '../../context';
3
+ export interface BubbleListProps<MessageInfo extends BaseMessageInfo> {
4
+ styles?: {
5
+ bottomPlaceholder?: CSSProperties;
6
+ content?: CSSProperties;
7
+ };
8
+ messages: Message<MessageInfo>[];
9
+ messageRender: (message: Message<MessageInfo>) => React.ReactNode;
10
+ }
11
+ export declare const BubbleList: <MessageInfo extends BaseMessageInfo = any>(props: BubbleListProps<MessageInfo>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { styled } from "styled-components";
4
+ const BubbleList = (props)=>{
5
+ const { styles, messages, messageRender } = props;
6
+ const bottomRef = useRef(null);
7
+ const containerRef = useRef(null);
8
+ return /*#__PURE__*/ jsxs(ContentContainer, {
9
+ ref: containerRef,
10
+ children: [
11
+ /*#__PURE__*/ jsx("div", {
12
+ style: styles?.content,
13
+ children: (messages ?? []).map(messageRender)
14
+ }),
15
+ /*#__PURE__*/ jsx("div", {
16
+ ref: bottomRef,
17
+ style: styles?.bottomPlaceholder ?? {
18
+ height: 60
19
+ }
20
+ })
21
+ ]
22
+ });
23
+ };
24
+ const ContentContainer = styled.div`
25
+ min-height: 100px;
26
+ flex-grow: 1;
27
+ flex-shrink: 1;
28
+ overflow: auto;
29
+ position: relative;
30
+ width: 100%;
31
+ box-sizing: border-box;
32
+ padding: 0 calc((100% - 800px) / 2);
33
+ `;
34
+ export { BubbleList };
@@ -3,3 +3,5 @@ export * from './Reasoning';
3
3
  export * from './ReferenceList';
4
4
  export * from './SuggestMessageList';
5
5
  export * from './LinkCard';
6
+ export * from './BubbleList';
7
+ export * from './Markdown';
@@ -3,3 +3,5 @@ export * from "./Reasoning.js";
3
3
  export * from "./ReferenceList.js";
4
4
  export * from "./SuggestMessageList.js";
5
5
  export * from "./LinkCard.js";
6
+ export * from "./BubbleList.js";
7
+ export * from "./Markdown.js";
@@ -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;