@copilotz/chat-ui 0.1.38 → 0.1.39
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/index.cjs +40 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +40 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { Options, Components } from 'react-markdown';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
import { ClassValue } from 'clsx';
|
|
5
6
|
|
|
@@ -94,6 +95,11 @@ interface ChatThread {
|
|
|
94
95
|
isArchived?: boolean;
|
|
95
96
|
metadata?: Record<string, any>;
|
|
96
97
|
}
|
|
98
|
+
interface ChatMarkdownConfig {
|
|
99
|
+
remarkPlugins?: Options['remarkPlugins'];
|
|
100
|
+
rehypePlugins?: Options['rehypePlugins'];
|
|
101
|
+
components?: Components;
|
|
102
|
+
}
|
|
97
103
|
interface ChatConfig {
|
|
98
104
|
branding?: {
|
|
99
105
|
logo?: ReactNode;
|
|
@@ -202,6 +208,7 @@ interface ChatConfig {
|
|
|
202
208
|
longMessageChunkChars?: number;
|
|
203
209
|
renderUserMarkdown?: boolean;
|
|
204
210
|
};
|
|
211
|
+
markdown?: ChatMarkdownConfig;
|
|
205
212
|
voiceCompose?: {
|
|
206
213
|
enabled?: boolean;
|
|
207
214
|
defaultMode?: 'text' | 'voice';
|
|
@@ -445,6 +452,7 @@ interface MessageProps {
|
|
|
445
452
|
longMessagePreviewChars?: number;
|
|
446
453
|
longMessageChunkChars?: number;
|
|
447
454
|
renderUserMarkdown?: boolean;
|
|
455
|
+
markdown?: ChatMarkdownConfig;
|
|
448
456
|
isExpanded?: boolean;
|
|
449
457
|
onToggleExpanded?: (messageId: string) => void;
|
|
450
458
|
/** When true, hides the avatar and name (for grouped consecutive messages from same sender) */
|
|
@@ -675,4 +683,4 @@ declare const chatUtils: {
|
|
|
675
683
|
generateThreadTitle: (firstMessage: string) => string;
|
|
676
684
|
};
|
|
677
685
|
|
|
678
|
-
export { type AgentOption, type AudioAttachment, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderConfig, type ChatHeaderProps, ChatInput, type ChatMessage, type ChatState, type ChatThread, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatV2Props, type CreateVoiceProvider, type CustomField, type FileUploadProgress, type MediaAttachment, type MemoryItem, Message, type MessageAction, type MessageActionEvent, Sidebar, type SidebarConfig, type SidebarProps, type StateCallback, type StreamingUpdate, ThreadManager, type ToolCall, type UserCustomField, UserMenu, type UserMenuCallbacks, type UserMenuConfig, type UserMenuProps, type UserMenuUser, UserProfile, type UserProfileConfig, type UserProfileProps, type UserProfileUser, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, chatConfigPresets, chatUtils, cn, configUtils, createObjectUrlFromDataUrl, defaultChatConfig, featureFlags, formatDate, mergeConfig, themeUtils, useChatUserContext, validateConfig };
|
|
686
|
+
export { type AgentOption, type AudioAttachment, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderConfig, type ChatHeaderProps, ChatInput, type ChatMarkdownConfig, type ChatMessage, type ChatState, type ChatThread, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatV2Props, type CreateVoiceProvider, type CustomField, type FileUploadProgress, type MediaAttachment, type MemoryItem, Message, type MessageAction, type MessageActionEvent, Sidebar, type SidebarConfig, type SidebarProps, type StateCallback, type StreamingUpdate, ThreadManager, type ToolCall, type UserCustomField, UserMenu, type UserMenuCallbacks, type UserMenuConfig, type UserMenuProps, type UserMenuUser, UserProfile, type UserProfileConfig, type UserProfileProps, type UserProfileUser, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, chatConfigPresets, chatUtils, cn, configUtils, createObjectUrlFromDataUrl, defaultChatConfig, featureFlags, formatDate, mergeConfig, themeUtils, useChatUserContext, validateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { Options, Components } from 'react-markdown';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
import { ClassValue } from 'clsx';
|
|
5
6
|
|
|
@@ -94,6 +95,11 @@ interface ChatThread {
|
|
|
94
95
|
isArchived?: boolean;
|
|
95
96
|
metadata?: Record<string, any>;
|
|
96
97
|
}
|
|
98
|
+
interface ChatMarkdownConfig {
|
|
99
|
+
remarkPlugins?: Options['remarkPlugins'];
|
|
100
|
+
rehypePlugins?: Options['rehypePlugins'];
|
|
101
|
+
components?: Components;
|
|
102
|
+
}
|
|
97
103
|
interface ChatConfig {
|
|
98
104
|
branding?: {
|
|
99
105
|
logo?: ReactNode;
|
|
@@ -202,6 +208,7 @@ interface ChatConfig {
|
|
|
202
208
|
longMessageChunkChars?: number;
|
|
203
209
|
renderUserMarkdown?: boolean;
|
|
204
210
|
};
|
|
211
|
+
markdown?: ChatMarkdownConfig;
|
|
205
212
|
voiceCompose?: {
|
|
206
213
|
enabled?: boolean;
|
|
207
214
|
defaultMode?: 'text' | 'voice';
|
|
@@ -445,6 +452,7 @@ interface MessageProps {
|
|
|
445
452
|
longMessagePreviewChars?: number;
|
|
446
453
|
longMessageChunkChars?: number;
|
|
447
454
|
renderUserMarkdown?: boolean;
|
|
455
|
+
markdown?: ChatMarkdownConfig;
|
|
448
456
|
isExpanded?: boolean;
|
|
449
457
|
onToggleExpanded?: (messageId: string) => void;
|
|
450
458
|
/** When true, hides the avatar and name (for grouped consecutive messages from same sender) */
|
|
@@ -675,4 +683,4 @@ declare const chatUtils: {
|
|
|
675
683
|
generateThreadTitle: (firstMessage: string) => string;
|
|
676
684
|
};
|
|
677
685
|
|
|
678
|
-
export { type AgentOption, type AudioAttachment, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderConfig, type ChatHeaderProps, ChatInput, type ChatMessage, type ChatState, type ChatThread, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatV2Props, type CreateVoiceProvider, type CustomField, type FileUploadProgress, type MediaAttachment, type MemoryItem, Message, type MessageAction, type MessageActionEvent, Sidebar, type SidebarConfig, type SidebarProps, type StateCallback, type StreamingUpdate, ThreadManager, type ToolCall, type UserCustomField, UserMenu, type UserMenuCallbacks, type UserMenuConfig, type UserMenuProps, type UserMenuUser, UserProfile, type UserProfileConfig, type UserProfileProps, type UserProfileUser, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, chatConfigPresets, chatUtils, cn, configUtils, createObjectUrlFromDataUrl, defaultChatConfig, featureFlags, formatDate, mergeConfig, themeUtils, useChatUserContext, validateConfig };
|
|
686
|
+
export { type AgentOption, type AudioAttachment, type ChatCallbacks, type ChatConfig, ChatHeader, type ChatHeaderConfig, type ChatHeaderProps, ChatInput, type ChatMarkdownConfig, type ChatMessage, type ChatState, type ChatThread, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatV2Props, type CreateVoiceProvider, type CustomField, type FileUploadProgress, type MediaAttachment, type MemoryItem, Message, type MessageAction, type MessageActionEvent, Sidebar, type SidebarConfig, type SidebarProps, type StateCallback, type StreamingUpdate, ThreadManager, type ToolCall, type UserCustomField, UserMenu, type UserMenuCallbacks, type UserMenuConfig, type UserMenuProps, type UserMenuUser, UserProfile, type UserProfileConfig, type UserProfileProps, type UserProfileUser, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, chatConfigPresets, chatUtils, cn, configUtils, createObjectUrlFromDataUrl, defaultChatConfig, featureFlags, formatDate, mergeConfig, themeUtils, useChatUserContext, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,11 @@ var defaultChatConfig = {
|
|
|
114
114
|
longMessageChunkChars: 12e3,
|
|
115
115
|
renderUserMarkdown: true
|
|
116
116
|
},
|
|
117
|
+
markdown: {
|
|
118
|
+
remarkPlugins: [],
|
|
119
|
+
rehypePlugins: [],
|
|
120
|
+
components: {}
|
|
121
|
+
},
|
|
117
122
|
voiceCompose: {
|
|
118
123
|
enabled: false,
|
|
119
124
|
defaultMode: "text",
|
|
@@ -147,6 +152,10 @@ function mergeConfig(_baseConfig, userConfig) {
|
|
|
147
152
|
...defaultChatConfig.ui,
|
|
148
153
|
...userConfig.ui
|
|
149
154
|
},
|
|
155
|
+
markdown: {
|
|
156
|
+
...defaultChatConfig.markdown,
|
|
157
|
+
...userConfig.markdown
|
|
158
|
+
},
|
|
150
159
|
voiceCompose: {
|
|
151
160
|
...defaultChatConfig.voiceCompose,
|
|
152
161
|
...userConfig.voiceCompose
|
|
@@ -653,7 +662,7 @@ var ThinkingBlock = memo(function ThinkingBlock2({ reasoning, isStreaming = fals
|
|
|
653
662
|
] }) })
|
|
654
663
|
] });
|
|
655
664
|
});
|
|
656
|
-
var
|
|
665
|
+
var defaultMarkdownComponents = {
|
|
657
666
|
code: ({ node, className, children, ...props }) => {
|
|
658
667
|
const inline = props.inline;
|
|
659
668
|
const match = /language-(\w+)/.exec(className || "");
|
|
@@ -718,12 +727,34 @@ var StreamingText = memo(function StreamingText2({
|
|
|
718
727
|
thinkingLabel = "Thinking...",
|
|
719
728
|
className = "",
|
|
720
729
|
renderMarkdown = true,
|
|
730
|
+
markdown,
|
|
721
731
|
plainTextChunkChars = 12e3,
|
|
722
732
|
contentStyle,
|
|
723
733
|
hideThinkingIndicator = false
|
|
724
734
|
}) {
|
|
725
735
|
const hasContent = content.trim().length > 0;
|
|
726
736
|
const enableSyntaxHighlight = renderMarkdown && !isStreaming && hasCodeBlocks(content);
|
|
737
|
+
const mergedComponents = useMemo(
|
|
738
|
+
() => ({
|
|
739
|
+
...defaultMarkdownComponents,
|
|
740
|
+
...markdown?.components
|
|
741
|
+
}),
|
|
742
|
+
[markdown?.components]
|
|
743
|
+
);
|
|
744
|
+
const mergedRemarkPlugins = useMemo(
|
|
745
|
+
() => [
|
|
746
|
+
...remarkPluginsDefault,
|
|
747
|
+
...markdown?.remarkPlugins ?? []
|
|
748
|
+
],
|
|
749
|
+
[markdown?.remarkPlugins]
|
|
750
|
+
);
|
|
751
|
+
const mergedRehypePlugins = useMemo(
|
|
752
|
+
() => [
|
|
753
|
+
...enableSyntaxHighlight ? rehypePluginsDefault : rehypePluginsEmpty,
|
|
754
|
+
...markdown?.rehypePlugins ?? []
|
|
755
|
+
],
|
|
756
|
+
[enableSyntaxHighlight, markdown?.rehypePlugins]
|
|
757
|
+
);
|
|
727
758
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
728
759
|
hasContent ? renderMarkdown ? /* @__PURE__ */ jsx7(
|
|
729
760
|
LongContentShell,
|
|
@@ -733,9 +764,9 @@ var StreamingText = memo(function StreamingText2({
|
|
|
733
764
|
children: /* @__PURE__ */ jsx7(
|
|
734
765
|
ReactMarkdown,
|
|
735
766
|
{
|
|
736
|
-
remarkPlugins:
|
|
737
|
-
rehypePlugins:
|
|
738
|
-
components:
|
|
767
|
+
remarkPlugins: mergedRemarkPlugins,
|
|
768
|
+
rehypePlugins: mergedRehypePlugins,
|
|
769
|
+
components: mergedComponents,
|
|
739
770
|
children: content
|
|
740
771
|
}
|
|
741
772
|
)
|
|
@@ -909,6 +940,7 @@ var arePropsEqual = (prevProps, nextProps) => {
|
|
|
909
940
|
if (prevProps.longMessagePreviewChars !== nextProps.longMessagePreviewChars) return false;
|
|
910
941
|
if (prevProps.longMessageChunkChars !== nextProps.longMessageChunkChars) return false;
|
|
911
942
|
if (prevProps.renderUserMarkdown !== nextProps.renderUserMarkdown) return false;
|
|
943
|
+
if (prevProps.markdown !== nextProps.markdown) return false;
|
|
912
944
|
if (prevProps.isExpanded !== nextProps.isExpanded) return false;
|
|
913
945
|
if (prevProps.onToggleExpanded !== nextProps.onToggleExpanded) return false;
|
|
914
946
|
if (prevProps.isGrouped !== nextProps.isGrouped) return false;
|
|
@@ -940,6 +972,7 @@ var Message = memo(({
|
|
|
940
972
|
longMessagePreviewChars = 4e3,
|
|
941
973
|
longMessageChunkChars = 12e3,
|
|
942
974
|
renderUserMarkdown = true,
|
|
975
|
+
markdown,
|
|
943
976
|
isExpanded = false,
|
|
944
977
|
onToggleExpanded,
|
|
945
978
|
isGrouped = false
|
|
@@ -1057,6 +1090,7 @@ var Message = memo(({
|
|
|
1057
1090
|
isStreaming: message.isStreaming,
|
|
1058
1091
|
thinkingLabel,
|
|
1059
1092
|
renderMarkdown: shouldRenderMarkdown,
|
|
1093
|
+
markdown,
|
|
1060
1094
|
plainTextChunkChars: normalizedChunkChars,
|
|
1061
1095
|
contentStyle,
|
|
1062
1096
|
hideThinkingIndicator: !!message.reasoning
|
|
@@ -5187,6 +5221,7 @@ var ChatUI = ({
|
|
|
5187
5221
|
longMessagePreviewChars: config.ui.longMessagePreviewChars,
|
|
5188
5222
|
longMessageChunkChars: config.ui.longMessageChunkChars,
|
|
5189
5223
|
renderUserMarkdown: config.ui.renderUserMarkdown,
|
|
5224
|
+
markdown: config.markdown,
|
|
5190
5225
|
onToggleExpanded: handleToggleMessageExpansion
|
|
5191
5226
|
}), [
|
|
5192
5227
|
user?.avatar,
|
|
@@ -5209,6 +5244,7 @@ var ChatUI = ({
|
|
|
5209
5244
|
config.ui.longMessagePreviewChars,
|
|
5210
5245
|
config.ui.longMessageChunkChars,
|
|
5211
5246
|
config.ui.renderUserMarkdown,
|
|
5247
|
+
config.markdown,
|
|
5212
5248
|
handleMessageAction,
|
|
5213
5249
|
handleToggleMessageExpansion
|
|
5214
5250
|
]);
|