Skip to content

Commit 07812fe

Browse files
authored
chore(deps): upgrade react-markdown to v9 (#2643)
1 parent d545207 commit 07812fe

File tree

5 files changed

+613
-497
lines changed

5 files changed

+613
-497
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@
122122
"react-dropzone": "^14.2.3",
123123
"react-fast-compare": "^3.2.2",
124124
"react-image-gallery": "1.2.12",
125-
"react-markdown": "^8.0.7",
125+
"react-markdown": "^9.0.3",
126126
"react-player": "2.10.1",
127127
"react-popper": "^2.3.0",
128128
"react-textarea-autosize": "^8.3.0",
129129
"react-virtuoso": "^2.16.5",
130-
"remark-gfm": "^3.0.1",
130+
"remark-gfm": "^4.0.1",
131131
"textarea-caret": "^3.1.0",
132132
"tslib": "^2.6.2",
133-
"unist-builder": "^3.0.0",
133+
"unist-builder": "^4.0.0",
134134
"unist-util-visit": "^5.0.0",
135135
"use-sync-external-store": "^1.4.0"
136136
},

src/components/Message/renderText/__tests__/__snapshots__/renderText.test.js.snap

+10
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ exports[`keepLineBreaksPlugin present keeps line breaks around a blockquote 1`]
266266
267267
268268
<blockquote>
269+
270+
269271
<p>
270272
b
271273
</p>
@@ -556,6 +558,8 @@ exports[`keepLineBreaksPlugin present keeps line breaks between the items in an
556558
557559
558560
<li>
561+
562+
559563
<p>
560564
item 2
561565
</p>
@@ -579,6 +583,8 @@ exports[`keepLineBreaksPlugin present keeps line breaks between the items in an
579583
580584
581585
<li>
586+
587+
582588
<p>
583589
item 3
584590
</p>
@@ -622,6 +628,8 @@ exports[`keepLineBreaksPlugin present keeps line breaks between the items in an
622628
623629
624630
<li>
631+
632+
625633
<p>
626634
item 2
627635
</p>
@@ -645,6 +653,8 @@ exports[`keepLineBreaksPlugin present keeps line breaks between the items in an
645653
646654
647655
<li>
656+
657+
648658
<p>
649659
item 3
650660
</p>

src/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { u } from 'unist-builder';
44
import { visit } from 'unist-util-visit';
55

66
import type { Nodes } from 'hast-util-find-and-replace/lib';
7-
import type { Element } from 'react-markdown/lib/ast-to-react';
7+
import type { Element } from 'hast';
88
import type { UserResponse } from 'stream-chat';
99
import type { DefaultStreamChatGenerics } from '../../../../types';
1010

src/components/Message/renderText/renderText.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React, { ComponentType } from 'react';
2-
import ReactMarkdown, { Options, uriTransformer } from 'react-markdown';
2+
import ReactMarkdown, { defaultUrlTransform } from 'react-markdown';
33
import { find } from 'linkifyjs';
44
import uniqBy from 'lodash.uniqby';
55
import remarkGfm from 'remark-gfm';
66

7-
import type { PluggableList } from 'react-markdown/lib/react-markdown';
8-
import type { UserResponse } from 'stream-chat';
9-
107
import { Anchor, Emoji, Mention, MentionProps } from './componentRenderers';
118
import { detectHttp, escapeRegExp, matchMarkdownLinks, messageCodeBlocks } from './regex';
129
import { emojiMarkdownPlugin, mentionsMarkdownPlugin } from './rehypePlugins';
1310
import { htmlToTextPlugin, keepLineBreaksPlugin } from './remarkPlugins';
1411
import { ErrorBoundary } from '../../UtilityComponents';
1512

13+
import type { Options } from 'react-markdown/lib';
14+
import type { UserResponse } from 'stream-chat';
15+
import type { PluggableList } from 'unified'; // A subdependency of react-markdown. The type is not declared or re-exported from anywhere else
16+
1617
import type { DefaultStreamChatGenerics } from '../../../types/types';
1718

1819
export type RenderTextPluginConfigurator = (
@@ -65,7 +66,7 @@ function encodeDecode(url: string) {
6566
}
6667

6768
const urlTransform = (uri: string) =>
68-
uri.startsWith('app://') ? uri : uriTransformer(uri);
69+
uri.startsWith('app://') ? uri : defaultUrlTransform(uri);
6970

7071
const getPluginsForward: RenderTextPluginConfigurator = (plugins: PluggableList) =>
7172
plugins;
@@ -189,8 +190,8 @@ export const renderText = <
189190
rehypePlugins={getRehypePlugins(rehypePlugins)}
190191
remarkPlugins={getRemarkPlugins(remarkPlugins)}
191192
skipHtml
192-
transformLinkUri={urlTransform}
193193
unwrapDisallowed
194+
urlTransform={urlTransform}
194195
>
195196
{newText}
196197
</ReactMarkdown>

0 commit comments

Comments
 (0)