@patternfly/chatbot 6.8.0-prerelease.8 → 6.9.0-prerelease.1
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/cjs/CodeModal/CodeModal.js +5 -0
- package/dist/cjs/MarkdownContent/MarkdownContent.d.ts +26 -7
- package/dist/cjs/MarkdownContent/MarkdownContent.js +79 -166
- package/dist/cjs/MarkdownContent/MarkdownRenderer.d.ts +6 -0
- package/dist/cjs/MarkdownContent/MarkdownRenderer.js +187 -0
- package/dist/cjs/Message/Message.d.ts +3 -4
- package/dist/cjs/Message/Message.js +0 -2
- package/dist/cjs/MessageBox/MessageBox.js +5 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.js +1 -13
- package/dist/css/main.css +18 -3
- package/dist/css/main.css.map +1 -1
- package/dist/esm/CodeModal/CodeModal.js +5 -0
- package/dist/esm/MarkdownContent/MarkdownContent.d.ts +26 -7
- package/dist/esm/MarkdownContent/MarkdownContent.js +52 -165
- package/dist/esm/MarkdownContent/MarkdownRenderer.d.ts +6 -0
- package/dist/esm/MarkdownContent/MarkdownRenderer.js +182 -0
- package/dist/esm/Message/Message.d.ts +3 -4
- package/dist/esm/Message/Message.js +0 -2
- package/dist/esm/MessageBox/MessageBox.js +5 -1
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.js +0 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generate-index.js +41 -16
- package/generate-index.test.js +68 -0
- package/monaco-environment.js +45 -0
- package/package.json +20 -2
- package/patternfly-docs/content/extensions/chatbot/chatbot.md +1 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/monitor-sampleapp-quickstart.ts +1 -0
- package/patternfly-docs/content/extensions/chatbot/tree-shaking.md +124 -0
- package/patternfly-docs/monaco-environment.js +45 -0
- package/patternfly-docs/patternfly-docs.css.js +6 -0
- package/src/Chatbot/Chatbot.scss +4 -0
- package/src/ChatbotContent/ChatbotContent.scss +1 -1
- package/src/ChatbotFooter/ChatbotFooter.scss +2 -2
- package/src/ChatbotHeader/ChatbotHeader.scss +4 -0
- package/src/ChatbotModal/ChatbotModal.scss +10 -0
- package/src/CodeModal/CodeModal.tsx +6 -0
- package/src/DeepThinking/DeepThinking.test.tsx +10 -12
- package/src/MarkdownContent/MarkdownContent.test.tsx +52 -5
- package/src/MarkdownContent/MarkdownContent.tsx +77 -220
- package/src/MarkdownContent/MarkdownRenderer.tsx +235 -0
- package/src/Message/Message.test.tsx +5 -0
- package/src/Message/Message.tsx +3 -5
- package/src/MessageBox/MessageBox.tsx +13 -1
- package/src/ResponseActions/ResponseActions.test.tsx +42 -48
- package/src/ToolCall/ToolCall.test.tsx +6 -9
- package/src/ToolResponse/ToolResponse.test.tsx +16 -22
- package/src/index.ts +0 -12
- package/src/test-utils/markdownTestUtils.ts +21 -0
- package/tsconfig.json +6 -1
- package/dist/cjs/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
- package/dist/cjs/AttachmentEdit/AttachmentEdit.test.js +0 -77
- package/dist/cjs/Chatbot/Chatbot.test.d.ts +0 -1
- package/dist/cjs/Chatbot/Chatbot.test.js +0 -32
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.js +0 -27
- package/dist/cjs/ChatbotContent/ChatbotContent.test.d.ts +0 -1
- package/dist/cjs/ChatbotContent/ChatbotContent.test.js +0 -22
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -75
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -601
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +0 -27
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.js +0 -87
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.js +0 -18
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -22
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -46
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -44
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -55
- package/dist/cjs/ChatbotModal/ChatbotModal.test.d.ts +0 -1
- package/dist/cjs/ChatbotModal/ChatbotModal.test.js +0 -16
- package/dist/cjs/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
- package/dist/cjs/ChatbotToggle/ChatbotToggle.test.js +0 -64
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -61
- package/dist/cjs/CodeModal/CodeModal.test.d.ts +0 -1
- package/dist/cjs/CodeModal/CodeModal.test.js +0 -34
- package/dist/cjs/Compare/Compare.test.d.ts +0 -1
- package/dist/cjs/Compare/Compare.test.js +0 -18
- package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +0 -1
- package/dist/cjs/DeepThinking/DeepThinking.test.js +0 -146
- package/dist/cjs/FileDetails/FileDetails.test.d.ts +0 -1
- package/dist/cjs/FileDetails/FileDetails.test.js +0 -42
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +0 -79
- package/dist/cjs/FileDropZone/FileDropZone.test.d.ts +0 -1
- package/dist/cjs/FileDropZone/FileDropZone.test.js +0 -100
- package/dist/cjs/FilePreview/FilePreview.test.d.ts +0 -1
- package/dist/cjs/FilePreview/FilePreview.test.js +0 -97
- package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +0 -1
- package/dist/cjs/ImagePreview/ImagePreview.test.js +0 -225
- package/dist/cjs/MarkdownContent/MarkdownContent.test.d.ts +0 -1
- package/dist/cjs/MarkdownContent/MarkdownContent.test.js +0 -192
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -131
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
- package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.js +0 -30
- package/dist/cjs/Message/Message.test.d.ts +0 -1
- package/dist/cjs/Message/Message.test.js +0 -1128
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.js +0 -25
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -25
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
- package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -25
- package/dist/cjs/Message/MessageLoading.test.d.ts +0 -1
- package/dist/cjs/Message/MessageLoading.test.js +0 -25
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
- package/dist/cjs/Message/QuickResponse/QuickResponse.test.js +0 -109
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
- package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.js +0 -76
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
- package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +0 -181
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
- package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.js +0 -243
- package/dist/cjs/MessageBar/AttachButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/AttachButton.test.js +0 -152
- package/dist/cjs/MessageBar/MessageBar.test.d.ts +0 -1
- package/dist/cjs/MessageBar/MessageBar.test.js +0 -338
- package/dist/cjs/MessageBar/SendButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/SendButton.test.js +0 -58
- package/dist/cjs/MessageBar/StopButton.test.d.ts +0 -1
- package/dist/cjs/MessageBar/StopButton.test.js +0 -58
- package/dist/cjs/MessageBox/JumpButton.test.d.ts +0 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +0 -39
- package/dist/cjs/MessageBox/MessageBox.test.d.ts +0 -1
- package/dist/cjs/MessageBox/MessageBox.test.js +0 -294
- package/dist/cjs/MessageDivider/MessageDivider.test.d.ts +0 -1
- package/dist/cjs/MessageDivider/MessageDivider.test.js +0 -29
- package/dist/cjs/Onboarding/Onboarding.test.d.ts +0 -1
- package/dist/cjs/Onboarding/Onboarding.test.js +0 -80
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.js +0 -50
- package/dist/cjs/ResponseActions/ResponseActionButton.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActionButton.test.js +0 -54
- package/dist/cjs/ResponseActions/ResponseActions.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActions.test.js +0 -455
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
- package/dist/cjs/ResponseActions/ResponseActionsGroups.test.js +0 -25
- package/dist/cjs/Settings/SettingsForm.test.d.ts +0 -1
- package/dist/cjs/Settings/SettingsForm.test.js +0 -35
- package/dist/cjs/SourcesCard/SourcesCard.test.d.ts +0 -1
- package/dist/cjs/SourcesCard/SourcesCard.test.js +0 -39
- package/dist/cjs/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
- package/dist/cjs/SourcesCardBase/SourcesCardBase.test.js +0 -199
- package/dist/cjs/TermsOfUse/TermsOfUse.test.d.ts +0 -1
- package/dist/cjs/TermsOfUse/TermsOfUse.test.js +0 -77
- package/dist/cjs/ToolCall/ToolCall.test.d.ts +0 -1
- package/dist/cjs/ToolCall/ToolCall.test.js +0 -201
- package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +0 -1
- package/dist/cjs/ToolResponse/ToolResponse.test.js +0 -184
- package/dist/cjs/__mocks__/monaco-editor.d.ts +0 -11
- package/dist/cjs/__mocks__/monaco-editor.js +0 -18
- package/dist/cjs/__mocks__/rehype-external-links.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-external-links.js +0 -4
- package/dist/cjs/__mocks__/rehype-highlight.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-highlight.js +0 -4
- package/dist/cjs/__mocks__/rehype-sanitize.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-sanitize.js +0 -4
- package/dist/cjs/__mocks__/rehype-unwrap-images.d.ts +0 -2
- package/dist/cjs/__mocks__/rehype-unwrap-images.js +0 -4
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.js +0 -72
- package/dist/esm/Chatbot/Chatbot.test.d.ts +0 -1
- package/dist/esm/Chatbot/Chatbot.test.js +0 -27
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.js +0 -22
- package/dist/esm/ChatbotContent/ChatbotContent.test.d.ts +0 -1
- package/dist/esm/ChatbotContent/ChatbotContent.test.js +0 -17
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -70
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -596
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +0 -22
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.js +0 -82
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.js +0 -13
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -20
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -44
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -42
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -50
- package/dist/esm/ChatbotModal/ChatbotModal.test.d.ts +0 -1
- package/dist/esm/ChatbotModal/ChatbotModal.test.js +0 -11
- package/dist/esm/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
- package/dist/esm/ChatbotToggle/ChatbotToggle.test.js +0 -59
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -56
- package/dist/esm/CodeModal/CodeModal.test.d.ts +0 -1
- package/dist/esm/CodeModal/CodeModal.test.js +0 -29
- package/dist/esm/Compare/Compare.test.d.ts +0 -1
- package/dist/esm/Compare/Compare.test.js +0 -13
- package/dist/esm/DeepThinking/DeepThinking.test.d.ts +0 -1
- package/dist/esm/DeepThinking/DeepThinking.test.js +0 -141
- package/dist/esm/FileDetails/FileDetails.test.d.ts +0 -1
- package/dist/esm/FileDetails/FileDetails.test.js +0 -37
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +0 -74
- package/dist/esm/FileDropZone/FileDropZone.test.d.ts +0 -1
- package/dist/esm/FileDropZone/FileDropZone.test.js +0 -95
- package/dist/esm/FilePreview/FilePreview.test.d.ts +0 -1
- package/dist/esm/FilePreview/FilePreview.test.js +0 -92
- package/dist/esm/ImagePreview/ImagePreview.test.d.ts +0 -1
- package/dist/esm/ImagePreview/ImagePreview.test.js +0 -220
- package/dist/esm/MarkdownContent/MarkdownContent.test.d.ts +0 -1
- package/dist/esm/MarkdownContent/MarkdownContent.test.js +0 -187
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -126
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
- package/dist/esm/Message/ErrorMessage/ErrorMessage.test.js +0 -25
- package/dist/esm/Message/Message.test.d.ts +0 -1
- package/dist/esm/Message/Message.test.js +0 -1123
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
- package/dist/esm/Message/MessageAndActions/MessageAndActions.test.js +0 -20
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
- package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -20
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
- package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -20
- package/dist/esm/Message/MessageLoading.test.d.ts +0 -1
- package/dist/esm/Message/MessageLoading.test.js +0 -20
- package/dist/esm/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
- package/dist/esm/Message/QuickResponse/QuickResponse.test.js +0 -104
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
- package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.js +0 -48
- package/dist/esm/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
- package/dist/esm/Message/UserFeedback/UserFeedback.test.js +0 -176
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
- package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.js +0 -238
- package/dist/esm/MessageBar/AttachButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/AttachButton.test.js +0 -147
- package/dist/esm/MessageBar/MessageBar.test.d.ts +0 -1
- package/dist/esm/MessageBar/MessageBar.test.js +0 -333
- package/dist/esm/MessageBar/SendButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/SendButton.test.js +0 -53
- package/dist/esm/MessageBar/StopButton.test.d.ts +0 -1
- package/dist/esm/MessageBar/StopButton.test.js +0 -53
- package/dist/esm/MessageBox/JumpButton.test.d.ts +0 -1
- package/dist/esm/MessageBox/JumpButton.test.js +0 -34
- package/dist/esm/MessageBox/MessageBox.test.d.ts +0 -1
- package/dist/esm/MessageBox/MessageBox.test.js +0 -289
- package/dist/esm/MessageDivider/MessageDivider.test.d.ts +0 -1
- package/dist/esm/MessageDivider/MessageDivider.test.js +0 -24
- package/dist/esm/Onboarding/Onboarding.test.d.ts +0 -1
- package/dist/esm/Onboarding/Onboarding.test.js +0 -75
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.js +0 -48
- package/dist/esm/ResponseActions/ResponseActionButton.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActionButton.test.js +0 -49
- package/dist/esm/ResponseActions/ResponseActions.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActions.test.js +0 -450
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
- package/dist/esm/ResponseActions/ResponseActionsGroups.test.js +0 -20
- package/dist/esm/Settings/SettingsForm.test.d.ts +0 -1
- package/dist/esm/Settings/SettingsForm.test.js +0 -33
- package/dist/esm/SourcesCard/SourcesCard.test.d.ts +0 -1
- package/dist/esm/SourcesCard/SourcesCard.test.js +0 -34
- package/dist/esm/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
- package/dist/esm/SourcesCardBase/SourcesCardBase.test.js +0 -194
- package/dist/esm/TermsOfUse/TermsOfUse.test.d.ts +0 -1
- package/dist/esm/TermsOfUse/TermsOfUse.test.js +0 -72
- package/dist/esm/ToolCall/ToolCall.test.d.ts +0 -1
- package/dist/esm/ToolCall/ToolCall.test.js +0 -196
- package/dist/esm/ToolResponse/ToolResponse.test.d.ts +0 -1
- package/dist/esm/ToolResponse/ToolResponse.test.js +0 -179
- package/dist/esm/__mocks__/monaco-editor.d.ts +0 -11
- package/dist/esm/__mocks__/monaco-editor.js +0 -18
- package/dist/esm/__mocks__/rehype-external-links.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-external-links.js +0 -2
- package/dist/esm/__mocks__/rehype-highlight.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-highlight.js +0 -2
- package/dist/esm/__mocks__/rehype-sanitize.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-sanitize.js +0 -2
- package/dist/esm/__mocks__/rehype-unwrap-images.d.ts +0 -2
- package/dist/esm/__mocks__/rehype-unwrap-images.js +0 -2
|
@@ -1,34 +1,76 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
2
|
// Markdown Content - Shared component for rendering markdown
|
|
3
3
|
// ============================================================================
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useSyncExternalStore,
|
|
8
|
+
type ComponentType,
|
|
9
|
+
type FunctionComponent,
|
|
10
|
+
type ReactNode
|
|
11
|
+
} from 'react';
|
|
12
|
+
import type { Options } from 'react-markdown';
|
|
7
13
|
import { ContentVariants } from '@patternfly/react-core';
|
|
8
|
-
import
|
|
14
|
+
import type { CodeBlockMessageProps } from '../Message/CodeBlockMessage/CodeBlockMessage';
|
|
15
|
+
import type { TableProps } from '@patternfly/react-table';
|
|
16
|
+
import type { PluggableList } from 'unified';
|
|
17
|
+
import type { ButtonProps } from '@patternfly/react-core';
|
|
9
18
|
import TextMessage from '../Message/TextMessage/TextMessage';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
|
|
20
|
+
type MarkdownRendererModule = typeof import('./MarkdownRenderer');
|
|
21
|
+
|
|
22
|
+
let markdownRendererPromise: Promise<MarkdownRendererModule> | null = null;
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
let ResolvedMarkdownRenderer: ComponentType<any> | null = null;
|
|
25
|
+
const markdownRendererListeners = new Set<() => void>();
|
|
26
|
+
|
|
27
|
+
const importMarkdownRenderer = () => {
|
|
28
|
+
if (!markdownRendererPromise) {
|
|
29
|
+
markdownRendererPromise = import('./MarkdownRenderer').then((module) => {
|
|
30
|
+
ResolvedMarkdownRenderer = module.default;
|
|
31
|
+
markdownRendererListeners.forEach((listener) => listener());
|
|
32
|
+
return module;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return markdownRendererPromise;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const subscribeToMarkdownRendererReady = (listener: () => void) => {
|
|
40
|
+
markdownRendererListeners.add(listener);
|
|
41
|
+
void importMarkdownRenderer();
|
|
42
|
+
return () => markdownRendererListeners.delete(listener);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the lazy-loaded markdown renderer chunk has finished loading.
|
|
47
|
+
*/
|
|
48
|
+
export const useIsMarkdownRendererReady = (): boolean =>
|
|
49
|
+
useSyncExternalStore(
|
|
50
|
+
subscribeToMarkdownRendererReady,
|
|
51
|
+
() => ResolvedMarkdownRenderer !== null,
|
|
52
|
+
() => true
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* When provided by `MessageBox`, defers markdown rendering until the shared chunk is ready
|
|
57
|
+
* so existing messages don't each flash an individual loading state.
|
|
58
|
+
*/
|
|
59
|
+
export const MarkdownRendererReadyContext = createContext<boolean | null>(null);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Eagerly fetches the markdown renderer chunk so the first rendered message
|
|
63
|
+
* doesn't flash a loading state while the chunk downloads. Safe to call repeatedly
|
|
64
|
+
* (the dynamic import is cached).
|
|
65
|
+
*/
|
|
66
|
+
export const preloadMarkdownRenderer = (): void => {
|
|
67
|
+
void importMarkdownRenderer();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Resolves when the markdown renderer chunk has loaded.
|
|
72
|
+
*/
|
|
73
|
+
export const whenMarkdownRendererReady = (): Promise<MarkdownRendererModule> => importMarkdownRenderer();
|
|
32
74
|
|
|
33
75
|
/**
|
|
34
76
|
* MarkdownContent renders content either as plain text or with content with markdown support.
|
|
@@ -69,31 +111,13 @@ export interface MarkdownContentProps {
|
|
|
69
111
|
export const MarkdownContent: FunctionComponent<MarkdownContentProps> = ({
|
|
70
112
|
content,
|
|
71
113
|
isMarkdownDisabled,
|
|
72
|
-
codeBlockProps,
|
|
73
|
-
tableProps,
|
|
74
|
-
openLinkInNewTab = true,
|
|
75
|
-
additionalRehypePlugins = [],
|
|
76
|
-
additionalRemarkPlugins = [],
|
|
77
|
-
linkProps,
|
|
78
|
-
reactMarkdownProps,
|
|
79
|
-
remarkGfmProps,
|
|
80
|
-
hasNoImages = false,
|
|
81
114
|
isPrimary,
|
|
82
115
|
textComponent,
|
|
83
|
-
|
|
116
|
+
...markdownProps
|
|
84
117
|
}: MarkdownContentProps) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
if (additionalRehypePlugins) {
|
|
90
|
-
rehypePlugins.push(...additionalRehypePlugins);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const disallowedElements = hasNoImages ? ['img'] : [];
|
|
94
|
-
if (reactMarkdownProps && reactMarkdownProps.disallowedElements) {
|
|
95
|
-
disallowedElements.push(...reactMarkdownProps.disallowedElements);
|
|
96
|
-
}
|
|
118
|
+
const contextReady = useContext(MarkdownRendererReadyContext);
|
|
119
|
+
const storeReady = useIsMarkdownRendererReady();
|
|
120
|
+
const isMarkdownRendererReady = contextReady ?? storeReady;
|
|
97
121
|
|
|
98
122
|
if (isMarkdownDisabled) {
|
|
99
123
|
if (textComponent) {
|
|
@@ -106,178 +130,11 @@ export const MarkdownContent: FunctionComponent<MarkdownContentProps> = ({
|
|
|
106
130
|
);
|
|
107
131
|
}
|
|
108
132
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const { node, ...rest } = props;
|
|
115
|
-
return (
|
|
116
|
-
<section
|
|
117
|
-
{...rest}
|
|
118
|
-
className={css('pf-chatbot__message-text', shouldRetainStyles && 'pf-m-markdown', rest?.className)}
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
},
|
|
122
|
-
p: (props) => {
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
124
|
-
const { node, ...rest } = props;
|
|
125
|
-
return (
|
|
126
|
-
<TextMessage
|
|
127
|
-
shouldRetainStyles={shouldRetainStyles}
|
|
128
|
-
component={ContentVariants.p}
|
|
129
|
-
{...rest}
|
|
130
|
-
isPrimary={isPrimary}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
},
|
|
134
|
-
code: ({ children, ...props }) => {
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
136
|
-
const { node, ...codeProps } = props;
|
|
137
|
-
return (
|
|
138
|
-
<CodeBlockMessage
|
|
139
|
-
{...codeProps}
|
|
140
|
-
{...codeBlockProps}
|
|
141
|
-
isPrimary={isPrimary}
|
|
142
|
-
shouldRetainStyles={shouldRetainStyles}
|
|
143
|
-
>
|
|
144
|
-
{children}
|
|
145
|
-
</CodeBlockMessage>
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
h1: (props) => {
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
150
|
-
const { node, ...rest } = props;
|
|
151
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h1} {...rest} />;
|
|
152
|
-
},
|
|
153
|
-
h2: (props) => {
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
155
|
-
const { node, ...rest } = props;
|
|
156
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h2} {...rest} />;
|
|
157
|
-
},
|
|
158
|
-
h3: (props) => {
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
160
|
-
const { node, ...rest } = props;
|
|
161
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h3} {...rest} />;
|
|
162
|
-
},
|
|
163
|
-
h4: (props) => {
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
165
|
-
const { node, ...rest } = props;
|
|
166
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h4} {...rest} />;
|
|
167
|
-
},
|
|
168
|
-
h5: (props) => {
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
170
|
-
const { node, ...rest } = props;
|
|
171
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h5} {...rest} />;
|
|
172
|
-
},
|
|
173
|
-
h6: (props) => {
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
175
|
-
const { node, ...rest } = props;
|
|
176
|
-
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h6} {...rest} />;
|
|
177
|
-
},
|
|
178
|
-
blockquote: (props) => {
|
|
179
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
180
|
-
const { node, ...rest } = props;
|
|
181
|
-
return (
|
|
182
|
-
<TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.blockquote} {...rest} />
|
|
183
|
-
);
|
|
184
|
-
},
|
|
185
|
-
ul: (props) => {
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
187
|
-
const { node, ...rest } = props;
|
|
188
|
-
return <UnorderedListMessage shouldRetainStyles={shouldRetainStyles} {...rest} />;
|
|
189
|
-
},
|
|
190
|
-
ol: (props) => {
|
|
191
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
192
|
-
const { node, ...rest } = props;
|
|
193
|
-
return <OrderedListMessage shouldRetainStyles={shouldRetainStyles} {...rest} />;
|
|
194
|
-
},
|
|
195
|
-
li: (props) => {
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
197
|
-
const { node, ...rest } = props;
|
|
198
|
-
return <ListItemMessage {...rest} />;
|
|
199
|
-
},
|
|
200
|
-
// table requires node attribute for calculating headers for mobile breakpoint
|
|
201
|
-
table: (props) => (
|
|
202
|
-
<TableMessage shouldRetainStyles={shouldRetainStyles} {...props} {...tableProps} isPrimary={isPrimary} />
|
|
203
|
-
),
|
|
204
|
-
tbody: (props) => {
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
206
|
-
const { node, ...rest } = props;
|
|
207
|
-
return <TbodyMessage {...rest} />;
|
|
208
|
-
},
|
|
209
|
-
thead: (props) => {
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
211
|
-
const { node, ...rest } = props;
|
|
212
|
-
return <TheadMessage {...rest} />;
|
|
213
|
-
},
|
|
214
|
-
tr: (props) => {
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
216
|
-
const { node, ...rest } = props;
|
|
217
|
-
return <TrMessage {...rest} />;
|
|
218
|
-
},
|
|
219
|
-
td: (props) => {
|
|
220
|
-
// Conflicts with Td type
|
|
221
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
222
|
-
const { node, width, ...rest } = props;
|
|
223
|
-
return <TdMessage {...rest} />;
|
|
224
|
-
},
|
|
225
|
-
th: (props) => {
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
227
|
-
const { node, ...rest } = props;
|
|
228
|
-
return <ThMessage {...rest} />;
|
|
229
|
-
},
|
|
230
|
-
img: (props) => {
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
232
|
-
const { node, ...rest } = props;
|
|
233
|
-
return <ImageMessage {...rest} />;
|
|
234
|
-
},
|
|
235
|
-
a: (props) => {
|
|
236
|
-
// node is just the details of the document structure - not needed
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
238
|
-
const { node, ...rest } = props;
|
|
239
|
-
return (
|
|
240
|
-
// some a types conflict with ButtonProps, but it's ok because we are using an a tag
|
|
241
|
-
// there are too many to handle manually
|
|
242
|
-
<LinkMessage shouldRetainStyles={shouldRetainStyles} {...(rest as any)} {...linkProps}>
|
|
243
|
-
{props.children}
|
|
244
|
-
</LinkMessage>
|
|
245
|
-
);
|
|
246
|
-
},
|
|
247
|
-
// used for footnotes
|
|
248
|
-
sup: (props) => {
|
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
250
|
-
const { node, ...rest } = props;
|
|
251
|
-
return <SuperscriptMessage {...rest} />;
|
|
252
|
-
}
|
|
253
|
-
}}
|
|
254
|
-
remarkPlugins={[[remarkGfm, { ...remarkGfmProps }], ...additionalRemarkPlugins]}
|
|
255
|
-
rehypePlugins={rehypePlugins}
|
|
256
|
-
{...reactMarkdownProps}
|
|
257
|
-
remarkRehypeOptions={{
|
|
258
|
-
// removes sr-only class from footnote labels applied by default
|
|
259
|
-
footnoteLabelProperties: { className: [''] },
|
|
260
|
-
// omit default ↩ text; backref icon is rendered in LinkMessage
|
|
261
|
-
footnoteBackContent: (_referenceIndex, rereferenceIndex) => {
|
|
262
|
-
if (rereferenceIndex > 1) {
|
|
263
|
-
return [
|
|
264
|
-
{
|
|
265
|
-
type: 'element',
|
|
266
|
-
tagName: 'sup',
|
|
267
|
-
properties: {},
|
|
268
|
-
children: [{ type: 'text', value: String(rereferenceIndex) }]
|
|
269
|
-
}
|
|
270
|
-
];
|
|
271
|
-
}
|
|
272
|
-
return [];
|
|
273
|
-
},
|
|
274
|
-
...reactMarkdownProps?.remarkRehypeOptions
|
|
275
|
-
}}
|
|
276
|
-
disallowedElements={disallowedElements}
|
|
277
|
-
>
|
|
278
|
-
{content}
|
|
279
|
-
</Markdown>
|
|
280
|
-
);
|
|
133
|
+
if (!isMarkdownRendererReady || !ResolvedMarkdownRenderer) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return <ResolvedMarkdownRenderer {...markdownProps} content={content} isPrimary={isPrimary} />;
|
|
281
138
|
};
|
|
282
139
|
|
|
283
140
|
export default MarkdownContent;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Markdown Renderer - Heavy markdown pipeline (dynamically imported)
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { type FunctionComponent } from 'react';
|
|
5
|
+
import Markdown from 'react-markdown';
|
|
6
|
+
import remarkGfm from 'remark-gfm';
|
|
7
|
+
import { ContentVariants } from '@patternfly/react-core';
|
|
8
|
+
import CodeBlockMessage from '../Message/CodeBlockMessage/CodeBlockMessage';
|
|
9
|
+
import TextMessage from '../Message/TextMessage/TextMessage';
|
|
10
|
+
import ListItemMessage from '../Message/ListMessage/ListItemMessage';
|
|
11
|
+
import UnorderedListMessage from '../Message/ListMessage/UnorderedListMessage';
|
|
12
|
+
import OrderedListMessage from '../Message/ListMessage/OrderedListMessage';
|
|
13
|
+
import TableMessage from '../Message/TableMessage/TableMessage';
|
|
14
|
+
import TrMessage from '../Message/TableMessage/TrMessage';
|
|
15
|
+
import TdMessage from '../Message/TableMessage/TdMessage';
|
|
16
|
+
import TbodyMessage from '../Message/TableMessage/TbodyMessage';
|
|
17
|
+
import TheadMessage from '../Message/TableMessage/TheadMessage';
|
|
18
|
+
import ThMessage from '../Message/TableMessage/ThMessage';
|
|
19
|
+
import ImageMessage from '../Message/ImageMessage/ImageMessage';
|
|
20
|
+
import rehypeUnwrapImages from 'rehype-unwrap-images';
|
|
21
|
+
import rehypeExternalLinks from 'rehype-external-links';
|
|
22
|
+
import rehypeSanitize from 'rehype-sanitize';
|
|
23
|
+
import rehypeHighlight from 'rehype-highlight';
|
|
24
|
+
import 'highlight.js/styles/vs2015.css';
|
|
25
|
+
import type { PluggableList } from 'unified';
|
|
26
|
+
import LinkMessage from '../Message/LinkMessage/LinkMessage';
|
|
27
|
+
import { rehypeMoveImagesOutOfParagraphs } from '../Message/Plugins/rehypeMoveImagesOutOfParagraphs';
|
|
28
|
+
import SuperscriptMessage from '../Message/SuperscriptMessage/SuperscriptMessage';
|
|
29
|
+
import { css } from '@patternfly/react-styles';
|
|
30
|
+
import type { MarkdownContentProps } from './MarkdownContent';
|
|
31
|
+
|
|
32
|
+
export type MarkdownRendererProps = Omit<MarkdownContentProps, 'isMarkdownDisabled' | 'textComponent'>;
|
|
33
|
+
|
|
34
|
+
const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({
|
|
35
|
+
content,
|
|
36
|
+
codeBlockProps,
|
|
37
|
+
tableProps,
|
|
38
|
+
openLinkInNewTab = true,
|
|
39
|
+
additionalRehypePlugins = [],
|
|
40
|
+
additionalRemarkPlugins = [],
|
|
41
|
+
linkProps,
|
|
42
|
+
reactMarkdownProps,
|
|
43
|
+
remarkGfmProps,
|
|
44
|
+
hasNoImages = false,
|
|
45
|
+
isPrimary,
|
|
46
|
+
shouldRetainStyles
|
|
47
|
+
}) => {
|
|
48
|
+
let rehypePlugins: PluggableList = [rehypeUnwrapImages, rehypeMoveImagesOutOfParagraphs, rehypeHighlight];
|
|
49
|
+
if (openLinkInNewTab) {
|
|
50
|
+
rehypePlugins = rehypePlugins.concat([[rehypeExternalLinks, { target: '_blank' }, rehypeSanitize]]);
|
|
51
|
+
}
|
|
52
|
+
if (additionalRehypePlugins) {
|
|
53
|
+
rehypePlugins.push(...additionalRehypePlugins);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const disallowedElements = hasNoImages ? ['img'] : [];
|
|
57
|
+
if (reactMarkdownProps && reactMarkdownProps.disallowedElements) {
|
|
58
|
+
disallowedElements.push(...reactMarkdownProps.disallowedElements);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Markdown
|
|
63
|
+
components={{
|
|
64
|
+
section: (props) => {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
+
const { node, ...rest } = props;
|
|
67
|
+
return (
|
|
68
|
+
<section
|
|
69
|
+
{...rest}
|
|
70
|
+
className={css('pf-chatbot__message-text', shouldRetainStyles && 'pf-m-markdown', rest?.className)}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
p: (props) => {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
+
const { node, ...rest } = props;
|
|
77
|
+
return (
|
|
78
|
+
<TextMessage
|
|
79
|
+
shouldRetainStyles={shouldRetainStyles}
|
|
80
|
+
component={ContentVariants.p}
|
|
81
|
+
{...rest}
|
|
82
|
+
isPrimary={isPrimary}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
code: ({ children, ...props }) => {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88
|
+
const { node, ...codeProps } = props;
|
|
89
|
+
return (
|
|
90
|
+
<CodeBlockMessage
|
|
91
|
+
{...codeProps}
|
|
92
|
+
{...codeBlockProps}
|
|
93
|
+
isPrimary={isPrimary}
|
|
94
|
+
shouldRetainStyles={shouldRetainStyles}
|
|
95
|
+
>
|
|
96
|
+
{children}
|
|
97
|
+
</CodeBlockMessage>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
h1: (props) => {
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
|
+
const { node, ...rest } = props;
|
|
103
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h1} {...rest} />;
|
|
104
|
+
},
|
|
105
|
+
h2: (props) => {
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
const { node, ...rest } = props;
|
|
108
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h2} {...rest} />;
|
|
109
|
+
},
|
|
110
|
+
h3: (props) => {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
112
|
+
const { node, ...rest } = props;
|
|
113
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h3} {...rest} />;
|
|
114
|
+
},
|
|
115
|
+
h4: (props) => {
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
117
|
+
const { node, ...rest } = props;
|
|
118
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h4} {...rest} />;
|
|
119
|
+
},
|
|
120
|
+
h5: (props) => {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
|
+
const { node, ...rest } = props;
|
|
123
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h5} {...rest} />;
|
|
124
|
+
},
|
|
125
|
+
h6: (props) => {
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
127
|
+
const { node, ...rest } = props;
|
|
128
|
+
return <TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.h6} {...rest} />;
|
|
129
|
+
},
|
|
130
|
+
blockquote: (props) => {
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
132
|
+
const { node, ...rest } = props;
|
|
133
|
+
return (
|
|
134
|
+
<TextMessage shouldRetainStyles={shouldRetainStyles} component={ContentVariants.blockquote} {...rest} />
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
ul: (props) => {
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
139
|
+
const { node, ...rest } = props;
|
|
140
|
+
return <UnorderedListMessage shouldRetainStyles={shouldRetainStyles} {...rest} />;
|
|
141
|
+
},
|
|
142
|
+
ol: (props) => {
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
|
+
const { node, ...rest } = props;
|
|
145
|
+
return <OrderedListMessage shouldRetainStyles={shouldRetainStyles} {...rest} />;
|
|
146
|
+
},
|
|
147
|
+
li: (props) => {
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
149
|
+
const { node, ...rest } = props;
|
|
150
|
+
return <ListItemMessage {...rest} />;
|
|
151
|
+
},
|
|
152
|
+
// table requires node attribute for calculating headers for mobile breakpoint
|
|
153
|
+
table: (props) => (
|
|
154
|
+
<TableMessage shouldRetainStyles={shouldRetainStyles} {...props} {...tableProps} isPrimary={isPrimary} />
|
|
155
|
+
),
|
|
156
|
+
tbody: (props) => {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
158
|
+
const { node, ...rest } = props;
|
|
159
|
+
return <TbodyMessage {...rest} />;
|
|
160
|
+
},
|
|
161
|
+
thead: (props) => {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
163
|
+
const { node, ...rest } = props;
|
|
164
|
+
return <TheadMessage {...rest} />;
|
|
165
|
+
},
|
|
166
|
+
tr: (props) => {
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
168
|
+
const { node, ...rest } = props;
|
|
169
|
+
return <TrMessage {...rest} />;
|
|
170
|
+
},
|
|
171
|
+
td: (props) => {
|
|
172
|
+
// Conflicts with Td type
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
174
|
+
const { node, width, ...rest } = props;
|
|
175
|
+
return <TdMessage {...rest} />;
|
|
176
|
+
},
|
|
177
|
+
th: (props) => {
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
179
|
+
const { node, ...rest } = props;
|
|
180
|
+
return <ThMessage {...rest} />;
|
|
181
|
+
},
|
|
182
|
+
img: (props) => {
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
184
|
+
const { node, ...rest } = props;
|
|
185
|
+
return <ImageMessage {...rest} />;
|
|
186
|
+
},
|
|
187
|
+
a: (props) => {
|
|
188
|
+
// node is just the details of the document structure - not needed
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
190
|
+
const { node, ...rest } = props;
|
|
191
|
+
return (
|
|
192
|
+
// some a types conflict with ButtonProps, but it's ok because we are using an a tag
|
|
193
|
+
// there are too many to handle manually
|
|
194
|
+
<LinkMessage shouldRetainStyles={shouldRetainStyles} {...(rest as any)} {...linkProps}>
|
|
195
|
+
{props.children}
|
|
196
|
+
</LinkMessage>
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
// used for footnotes
|
|
200
|
+
sup: (props) => {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
|
+
const { node, ...rest } = props;
|
|
203
|
+
return <SuperscriptMessage {...rest} />;
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
remarkPlugins={[[remarkGfm, { ...remarkGfmProps }], ...additionalRemarkPlugins]}
|
|
207
|
+
rehypePlugins={rehypePlugins}
|
|
208
|
+
{...reactMarkdownProps}
|
|
209
|
+
remarkRehypeOptions={{
|
|
210
|
+
// removes sr-only class from footnote labels applied by default
|
|
211
|
+
footnoteLabelProperties: { className: [''] },
|
|
212
|
+
// omit default ↩ text; backref icon is rendered in LinkMessage
|
|
213
|
+
footnoteBackContent: (_referenceIndex, rereferenceIndex) => {
|
|
214
|
+
if (rereferenceIndex > 1) {
|
|
215
|
+
return [
|
|
216
|
+
{
|
|
217
|
+
type: 'element',
|
|
218
|
+
tagName: 'sup',
|
|
219
|
+
properties: {},
|
|
220
|
+
children: [{ type: 'text', value: String(rereferenceIndex) }]
|
|
221
|
+
}
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
return [];
|
|
225
|
+
},
|
|
226
|
+
...reactMarkdownProps?.remarkRehypeOptions
|
|
227
|
+
}}
|
|
228
|
+
disallowedElements={disallowedElements}
|
|
229
|
+
>
|
|
230
|
+
{content}
|
|
231
|
+
</Markdown>
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export default MarkdownRenderer;
|
|
@@ -8,6 +8,7 @@ import { monitorSampleAppQuickStartWithImage } from './QuickStarts/monitor-sampl
|
|
|
8
8
|
import rehypeExternalLinks from '../__mocks__/rehype-external-links';
|
|
9
9
|
import { AlertActionLink, Button, CodeBlockAction } from '@patternfly/react-core';
|
|
10
10
|
import { DeepThinkingProps } from '../DeepThinking';
|
|
11
|
+
import { warmupMarkdownRenderer } from '../test-utils/markdownTestUtils';
|
|
11
12
|
|
|
12
13
|
// Mock the icon components
|
|
13
14
|
jest.mock('@patternfly/react-icons', () => ({
|
|
@@ -222,6 +223,10 @@ const checkListItemsRendered = () => {
|
|
|
222
223
|
};
|
|
223
224
|
|
|
224
225
|
describe('Message', () => {
|
|
226
|
+
beforeAll(async () => {
|
|
227
|
+
await warmupMarkdownRenderer();
|
|
228
|
+
});
|
|
229
|
+
|
|
225
230
|
beforeEach(() => {
|
|
226
231
|
jest.clearAllMocks();
|
|
227
232
|
});
|
package/src/Message/Message.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { forwardRef, ReactNode, useEffect, useState } from 'react';
|
|
5
5
|
import type { FunctionComponent, HTMLProps, MouseEvent as ReactMouseEvent, Ref } from 'react';
|
|
6
|
-
import { Options } from 'react-markdown';
|
|
6
|
+
import type { Options } from 'react-markdown';
|
|
7
7
|
import {
|
|
8
8
|
AlertProps,
|
|
9
9
|
Avatar,
|
|
@@ -25,10 +25,8 @@ import { QuickStart, QuickstartAction } from './QuickStarts/types';
|
|
|
25
25
|
import QuickResponse from './QuickResponse/QuickResponse';
|
|
26
26
|
import UserFeedback, { UserFeedbackProps } from './UserFeedback/UserFeedback';
|
|
27
27
|
import UserFeedbackComplete, { UserFeedbackCompleteProps } from './UserFeedback/UserFeedbackComplete';
|
|
28
|
-
import { TableProps } from '@patternfly/react-table';
|
|
29
|
-
|
|
30
|
-
import 'highlight.js/styles/vs2015.css';
|
|
31
|
-
import { PluggableList } from 'unified';
|
|
28
|
+
import type { TableProps } from '@patternfly/react-table';
|
|
29
|
+
import type { PluggableList } from 'unified';
|
|
32
30
|
import ErrorMessage from './ErrorMessage/ErrorMessage';
|
|
33
31
|
import MessageInput from './MessageInput';
|
|
34
32
|
import ToolResponse, { ToolResponseProps } from '../ToolResponse';
|
|
@@ -18,9 +18,17 @@ import {
|
|
|
18
18
|
WheelEventHandler
|
|
19
19
|
} from 'react';
|
|
20
20
|
import JumpButton from './JumpButton';
|
|
21
|
+
import {
|
|
22
|
+
MarkdownRendererReadyContext,
|
|
23
|
+
preloadMarkdownRenderer,
|
|
24
|
+
useIsMarkdownRendererReady
|
|
25
|
+
} from '../MarkdownContent/MarkdownContent';
|
|
21
26
|
import { ButtonProps, getResizeObserver, TooltipProps } from '@patternfly/react-core';
|
|
22
27
|
import { css } from '@patternfly/react-styles';
|
|
23
28
|
|
|
29
|
+
// Start fetching the markdown chunk as soon as MessageBox enters the bundle.
|
|
30
|
+
preloadMarkdownRenderer();
|
|
31
|
+
|
|
24
32
|
export interface MessageBoxProps extends HTMLProps<HTMLDivElement> {
|
|
25
33
|
/** Content that can be announced, such as a new message, for screen readers */
|
|
26
34
|
announcement?: string;
|
|
@@ -123,6 +131,8 @@ export const MessageBox = forwardRef(
|
|
|
123
131
|
}: MessageBoxProps,
|
|
124
132
|
ref: ForwardedRef<MessageBoxHandle | null>
|
|
125
133
|
) => {
|
|
134
|
+
const isMarkdownReady = useIsMarkdownRendererReady();
|
|
135
|
+
|
|
126
136
|
const [atTop, setAtTop] = useState(true);
|
|
127
137
|
const [atBottom, setAtBottom] = useState(false);
|
|
128
138
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
@@ -447,7 +457,9 @@ export const MessageBox = forwardRef(
|
|
|
447
457
|
{...props}
|
|
448
458
|
{...(enableSmartScroll ? { ...smartScrollHandlers } : {})}
|
|
449
459
|
>
|
|
450
|
-
{
|
|
460
|
+
<MarkdownRendererReadyContext.Provider value={isMarkdownReady}>
|
|
461
|
+
{children}
|
|
462
|
+
</MarkdownRendererReadyContext.Provider>
|
|
451
463
|
<div className="pf-chatbot__messagebox-announcement pf-chatbot-m-hidden" aria-live="polite">
|
|
452
464
|
{announcement}
|
|
453
465
|
</div>
|