Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
collectCoverage: true,
// most of these are to fix https://github.com/remarkjs/react-markdown/issues/635
transformIgnorePatterns: [
'node_modules/(?!@patternfly|@data-driven-forms|react-syntax-highlighter|remark-gfm|react-markdown|remark-parse|devlop|hast-util-to-jsx-runtime|comma-separated-tokens|estree-util-is-identifier-name|hast-util-whitespace|property-information|space-separated-tokens|unist-util-position|vfile-message|unist-util-stringify-position|html-url-attributes|mdast-util-from-markdown|mdast-util-to-string|micromark|decode-named-character-reference|remark-rehype|mdast-util-to-hast|trim-lines|unist-util-visit|unist-util-is|unified|bail|is-plain-obj|trough|vfile|mdast-util-gfm|ccount|mdast-util-find-and-replace|escape-string-regexp|markdown-table|mdast-util-to-markdown|zwitch|longest-streak|mdast-util-phrasing)'
'node_modules/(?!@patternfly|@data-driven-forms|remark-gfm|react-markdown|remark-parse|devlop|hast-util-to-jsx-runtime|comma-separated-tokens|estree-util-is-identifier-name|hast-util-whitespace|property-information|space-separated-tokens|unist-util-position|vfile-message|unist-util-stringify-position|html-url-attributes|mdast-util-from-markdown|mdast-util-to-string|micromark|decode-named-character-reference|remark-rehype|mdast-util-to-hast|trim-lines|unist-util-visit|unist-util-is|unified|bail|is-plain-obj|trough|vfile|mdast-util-gfm|ccount|mdast-util-find-and-replace|escape-string-regexp|markdown-table|mdast-util-to-markdown|zwitch|longest-streak|mdast-util-phrasing)'
// Uncomment the below line if you face any errors with jest
// '/node_modules/(?!@redhat-cloud-services)',
],
Expand Down
118 changes: 17 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"clsx": "^2.1.0",
"framer-motion": "^11.3.28",
"react-markdown": "^9.0.1",
"react-syntax-highlighter": "^15.5.0",
"remark-gfm": "^4.0.0",
"rehype-unwrap-images": "^1.0.0",
"rehype-external-links": "^3.0.0",
Expand Down
30 changes: 3 additions & 27 deletions packages/module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Chatbot Main - Message - Content - Code Block
// ============================================================================
import { useState, useRef, useId, useCallback, useEffect } from 'react';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { obsidian } from 'react-syntax-highlighter/dist/esm/styles/hljs';
// Import PatternFly components
import {
CodeBlock,
Expand All @@ -20,7 +18,6 @@ import {

import { CheckIcon } from '@patternfly/react-icons/dist/esm/icons/check-icon';
import { CopyIcon } from '@patternfly/react-icons/dist/esm/icons/copy-icon';
import { ExpandableSectionForSyntaxHighlighter } from './ExpandableSectionForSyntaxHighlighter';

export interface CodeBlockMessageProps {
/** Content rendered in code block */
Expand Down Expand Up @@ -137,30 +134,7 @@ const CodeBlockMessage = ({
<CodeBlock actions={actions}>
<CodeBlockCode>
<>
{language ? (
// SyntaxHighlighter doesn't work with ExpandableSection because it targets the direct child
// Forked for now and adjusted to match what we need
<ExpandableSectionForSyntaxHighlighter
variant={ExpandableSectionVariant.truncate}
isExpanded={isExpanded}
isDetached
toggleId={toggleId}
contentId={contentId}
language={language}
{...expandableSectionProps}
>
<SyntaxHighlighter
{...props}
language={language}
style={obsidian}
PreTag="div"
CodeTag="div"
wrapLongLines
>
{String(children).replace(/\n$/, '')}
</SyntaxHighlighter>
</ExpandableSectionForSyntaxHighlighter>
) : (
{isExpandable ? (
<ExpandableSection
variant={ExpandableSectionVariant.truncate}
isExpanded={isExpanded}
Expand All @@ -171,6 +145,8 @@ const CodeBlockMessage = ({
>
{children}
</ExpandableSection>
) : (
children
)}
</>
</CodeBlockCode>
Expand Down
Loading
Loading