Skip to content

Commit fc3f793

Browse files
committed
Merge branch 'develop' into theming-v2
# Conflicts: # src/components/MessageInput/hooks/useImageUploads.ts
2 parents 2c133ad + c8a490e commit fc3f793

File tree

15 files changed

+375
-55
lines changed

15 files changed

+375
-55
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ jobs:
9393
yarn lint
9494
yarn coverage
9595
yarn validate-translations
96+
97+
- name: 🧪 Validate CommonJS bundle with ${{ matrix.node }}
98+
run: yarn validate-cjs

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
node-version: 'lts/*'
2222
- name: Install dependencies
2323
run: yarn install --frozen-lockfile
24+
- name: Validate CommonJS bundle
25+
run: yarn validate-cjs
2426
- name: Release
2527
env:
2628
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# [9.4.0](https://github.com/GetStream/stream-chat-react/compare/v9.3.0...v9.4.0) (2022-08-03)
2+
3+
4+
### Bug Fixes
5+
6+
* detect mentions of users who have email as their name ([#1698](https://github.com/GetStream/stream-chat-react/issues/1698)) ([367b7c4](https://github.com/GetStream/stream-chat-react/commit/367b7c4cb30454140ff113e2b0a2671a14d9d276))
7+
8+
9+
### Features
10+
11+
* allow to send custom message data when editing a message ([#1696](https://github.com/GetStream/stream-chat-react/issues/1696)) ([05eae28](https://github.com/GetStream/stream-chat-react/commit/05eae28cd04f1605ae3fb1cd5767fa4bbbd067d3))
12+
13+
# [9.3.0](https://github.com/GetStream/stream-chat-react/compare/v9.2.0...v9.3.0) (2022-07-29)
14+
15+
16+
### Bug Fixes
17+
18+
* scroll to bottom on new message notification click after message list pagination ([#1689](https://github.com/GetStream/stream-chat-react/issues/1689)) ([d8f4bc5](https://github.com/GetStream/stream-chat-react/commit/d8f4bc57a602e5deeefeb0c8419658c61c7e695a))
19+
* update types for suggestions ([#1691](https://github.com/GetStream/stream-chat-react/issues/1691)) ([bb7442c](https://github.com/GetStream/stream-chat-react/commit/bb7442cbf4bb709ac477fc59f0ee35afb60888d5)), closes [#1659](https://github.com/GetStream/stream-chat-react/issues/1659)
20+
21+
22+
### Features
23+
24+
* **message-status:** extendable user information in read-by tooltip ([#1670](https://github.com/GetStream/stream-chat-react/issues/1670)) ([902029a](https://github.com/GetStream/stream-chat-react/commit/902029a3c9f7a720d0265dcfeb1957b17b8bdc9a))
25+
126
# [9.2.0](https://github.com/GetStream/stream-chat-react/compare/v9.1.5...v9.2.0) (2022-07-26)
227

328

docusaurus/docs/React/custom-code-examples/override-submit-handler.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The `MessageInput` component accepts an `overrideSubmitHandler` prop, which allo
1515
conclusion of the underlying `textarea` element's [`handleSubmit`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/hooks/useSubmitHandler.ts)
1616
function.
1717

18+
:::note
19+
You do not have to implement your custom submit handler, if the only thing you need is to pass custom message data to the underlying API call. In that case you can use the [`handleSubmit`](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageInput/hooks/useSubmitHandler.ts) function from the [`MessageInputContext`](../contexts/message-input-context.mdx). The `handleSubmit` function allows you to pass custom message data through its second parameter `customMessageData`. This applies to sending a new message as well as updating an existing one. In order for this to work, you will have to implement custom message input components and pass them to [`Channel`](../core-components/channel.mdx) props `EditMessageInput` or `Input` respectively.
20+
:::
21+
1822
The `overrideSubmitHandler` function receives two arguments, the message to be sent and the `cid` (channel type prepended to channel id)
1923
for the currently active channel. The message object is of the following type:
2024

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"lodash.isequal": "^4.5.0",
4343
"lodash.throttle": "^4.1.1",
4444
"lodash.uniqby": "^4.7.0",
45-
"mdast-util-find-and-replace": "1.1.1",
45+
"mdast-util-find-and-replace": "^2.2.1",
4646
"nanoid": "^3.3.4",
4747
"pretty-bytes": "^5.4.1",
4848
"prop-types": "^15.7.2",
@@ -106,6 +106,7 @@
106106
"@types/lodash.isequal": "^4.5.5",
107107
"@types/lodash.throttle": "^4.1.6",
108108
"@types/lodash.uniqby": "^4.7.6",
109+
"@types/mdast": "^3.0.10",
109110
"@types/moment": "^2.13.0",
110111
"@types/react": "^18.0.8",
111112
"@types/react-dom": "^18.0.3",
@@ -204,6 +205,7 @@
204205
"test": "jest",
205206
"types": "tsc --strict",
206207
"validate-translations": "node scripts/validate-translations.js",
208+
"validate-cjs": "node scripts/validate-cjs-bundle.cjs",
207209
"semantic-release": "semantic-release",
208210
"browse-examples": "ladle serve",
209211
"e2e": "playwright test",
@@ -212,7 +214,8 @@
212214
"docs-merge": "scripts/merge-stream-chat-css-docs.sh"
213215
},
214216
"resolutions": {
215-
"ast-types": "^0.14.0"
217+
"ast-types": "^0.14.0",
218+
"@types/unist": "^2.0.6"
216219
},
217220
"browserslist": [
218221
">0.2%",

rollup.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const externalDependencies = [
3333
'@braintree/sanitize-url',
3434
'@fortawesome/free-regular-svg-icons',
3535
'@fortawesome/react-fontawesome',
36+
'@juggle/resize-observer',
3637
'@stream-io/transliterate',
3738
'custom-event',
3839
/dayjs/,
@@ -45,13 +46,14 @@ const externalDependencies = [
4546
'lodash.isequal',
4647
'lodash.throttle',
4748
'lodash.uniqby',
48-
'mdast-util-find-and-replace',
4949
'mml-react',
50+
'nanoid',
5051
'pretty-bytes',
5152
'prop-types',
5253
'react-fast-compare',
5354
/react-file-utils/,
5455
'react-images',
56+
'react-image-gallery',
5557
'react-is',
5658
/react-markdown/,
5759
'react-player',
@@ -61,14 +63,17 @@ const externalDependencies = [
6163
/uuid/,
6264
];
6365

64-
const basePlugins = [
66+
const basePlugins = ({ useBrowserResolve = false }) => [
6567
replace({
6668
preventAssignment: true,
6769
'process.env.NODE_ENV': JSON.stringify('production'),
6870
}),
6971
// Remove peer-dependencies from final bundle
7072
external(),
7173
image(),
74+
resolve({
75+
browser: useBrowserResolve,
76+
}),
7277
typescript(),
7378
babel({
7479
babelHelpers: 'runtime',
@@ -109,7 +114,7 @@ const normalBundle = {
109114
sourcemap: true,
110115
},
111116
],
112-
plugins: [...basePlugins],
117+
plugins: [...basePlugins({ useBrowserResolve: false })],
113118
};
114119

115120
const fullBrowserBundle = ({ min } = { min: false }) => ({
@@ -128,16 +133,13 @@ const fullBrowserBundle = ({ min } = { min: false }) => ({
128133
},
129134
],
130135
plugins: [
131-
...basePlugins,
136+
...basePlugins({ useBrowserResolve: true }),
132137
{
133138
load: (id) => (id.match(/.s?css$/) ? '' : null),
134139
name: 'ignore-css-and-scss',
135140
resolveId: (importee) => (importee.match(/.s?css$/) ? importee : null),
136141
},
137142
builtins(),
138-
resolve({
139-
browser: true,
140-
}),
141143
globals({
142144
buffer: false,
143145
dirname: false,

scripts/validate-cjs-bundle.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// As the community transitions to ESM, we can easily break our CJS bundle.
2+
// This smoke test can help to detect this early.
3+
require('../dist/index.cjs.js');
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renderText handles the special case where user name matches to an e-mail pattern - 1 1`] = `
4+
<p>
5+
Hello
6+
<span
7+
className="str-chat__message-mention"
8+
>
9+
@username@email.com
10+
</span>
11+
, is
12+
<a
13+
className=""
14+
href="mailto:username@email.com"
15+
rel="nofollow noreferrer noopener"
16+
target="_blank"
17+
>
18+
username@email.com
19+
</a>
20+
your @primary e-mail?
21+
</p>
22+
`;
23+
24+
exports[`renderText handles the special case where user name matches to an e-mail pattern - 2 1`] = `
25+
<p>
26+
<a
27+
className=""
28+
href="mailto:username@email.com"
29+
rel="nofollow noreferrer noopener"
30+
target="_blank"
31+
>
32+
username@email.com
33+
</a>
34+
35+
<span
36+
className="str-chat__message-mention"
37+
>
38+
@username@email.com
39+
</span>
40+
is this the right address?
41+
</p>
42+
`;
43+
44+
exports[`renderText handles the special case where user name matches to an e-mail pattern - 3 1`] = `
45+
<p>
46+
<span
47+
className="str-chat__message-mention"
48+
>
49+
@username@email.com
50+
</span>
51+
52+
<span
53+
className="str-chat__message-mention"
54+
>
55+
@username@email.com
56+
</span>
57+
58+
<span
59+
className="str-chat__message-mention"
60+
>
61+
@username@email.com
62+
</span>
63+
64+
<span
65+
className="str-chat__message-mention"
66+
>
67+
@username@email.com
68+
</span>
69+
</p>
70+
`;
71+
72+
exports[`renderText handles the special case where user name matches to an e-mail pattern - 4 1`] = `
73+
<p>
74+
<span
75+
className="str-chat__message-mention"
76+
>
77+
@username@email.com
78+
</span>
79+
80+
<span
81+
className="str-chat__message-mention"
82+
>
83+
@username@email.com
84+
</span>
85+
86+
<a
87+
className=""
88+
href="mailto:username@email.com"
89+
rel="nofollow noreferrer noopener"
90+
target="_blank"
91+
>
92+
username@email.com
93+
</a>
94+
95+
<span
96+
className="str-chat__message-mention"
97+
>
98+
@username@email.com
99+
</span>
100+
</p>
101+
`;
102+
103+
exports[`renderText renders custom mention 1`] = `
104+
<p>
105+
<span
106+
className="my-mention"
107+
>
108+
@username@email.com
109+
</span>
110+
111+
<span
112+
className="my-mention"
113+
>
114+
@username@email.com
115+
</span>
116+
117+
<a
118+
className=""
119+
href="mailto:username@email.com"
120+
rel="nofollow noreferrer noopener"
121+
target="_blank"
122+
>
123+
username@email.com
124+
</a>
125+
126+
<span
127+
className="my-mention"
128+
>
129+
@username@email.com
130+
</span>
131+
</p>
132+
`;
133+
134+
exports[`renderText renders standard markdown text 1`] = `
135+
<p>
136+
Hi, shall we meet on
137+
<strong>
138+
Tuesday
139+
</strong>
140+
?
141+
</p>
142+
`;

src/__tests__/utils.test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React from 'react';
2+
import renderer from 'react-test-renderer';
3+
import { renderText } from '../utils';
4+
5+
describe(`renderText`, () => {
6+
it('handles the special case where user name matches to an e-mail pattern - 1', () => {
7+
const Markdown = renderText(
8+
'Hello @username@email.com, is username@email.com your @primary e-mail?',
9+
[{ id: 'id-username@email.com', name: 'username@email.com' }],
10+
);
11+
const tree = renderer.create(Markdown).toJSON();
12+
expect(tree).toMatchSnapshot();
13+
});
14+
15+
it('handles the special case where user name matches to an e-mail pattern - 2', () => {
16+
const Markdown = renderText(
17+
'username@email.com @username@email.com is this the right address?',
18+
[{ id: 'id-username@email.com', name: 'username@email.com' }],
19+
);
20+
const tree = renderer.create(Markdown).toJSON();
21+
expect(tree).toMatchSnapshot();
22+
});
23+
24+
it('handles the special case where user name matches to an e-mail pattern - 3', () => {
25+
const Markdown = renderText(
26+
'@username@email.com @username@email.com @username@email.com @username@email.com',
27+
[{ id: 'id-username@email.com', name: 'username@email.com' }],
28+
);
29+
const tree = renderer.create(Markdown).toJSON();
30+
expect(tree).toMatchSnapshot();
31+
});
32+
33+
it('handles the special case where user name matches to an e-mail pattern - 4', () => {
34+
const Markdown = renderText(
35+
'@username@email.com @username@email.com username@email.com @username@email.com',
36+
[{ id: 'id-username@email.com', name: 'username@email.com' }],
37+
);
38+
const tree = renderer.create(Markdown).toJSON();
39+
expect(tree).toMatchSnapshot();
40+
});
41+
42+
it('renders custom mention', () => {
43+
const Markdown = renderText(
44+
'@username@email.com @username@email.com username@email.com @username@email.com',
45+
[{ id: 'id-username@email.com', name: 'username@email.com' }],
46+
{
47+
customMarkDownRenderers: {
48+
mention: function MyMention(props) {
49+
return <span className='my-mention'>{props.children}</span>;
50+
},
51+
},
52+
},
53+
);
54+
const tree = renderer.create(Markdown).toJSON();
55+
expect(tree).toMatchSnapshot();
56+
});
57+
58+
it('renders standard markdown text', () => {
59+
const Markdown = renderText('Hi, shall we meet on **Tuesday**?', []);
60+
const tree = renderer.create(Markdown).toJSON();
61+
expect(tree).toMatchSnapshot();
62+
});
63+
});

0 commit comments

Comments
 (0)