Skip to content

Commit 805d119

Browse files
committed
chore: upgrade stream-chat-react to v13.5.1
1 parent 6deae15 commit 805d119

File tree

11 files changed

+507
-1382
lines changed

11 files changed

+507
-1382
lines changed

gaming-livestream/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"emoji-mart": "^5.5.2",
1111
"react": "^19.0.0",
1212
"react-dom": "^19.0.0",
13-
"stream-chat": "^9.6.0",
14-
"stream-chat-react": "^13.1.0"
13+
"stream-chat": "^9.17.0",
14+
"stream-chat-react": "^13.5.1"
1515
},
1616
"devDependencies": {
1717
"@types/react": "^19.0.8",

gaming-livestream/yarn.lock

Lines changed: 108 additions & 341 deletions
Large diffs are not rendered by default.

social-messenger-ts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"lodash.debounce": "^4.0.8",
1313
"react": "^19.0.0",
1414
"react-dom": "^19.0.0",
15-
"stream-chat": "^9.6.0",
16-
"stream-chat-react": "^13.1.0"
15+
"stream-chat": "^9.17.0",
16+
"stream-chat-react": "^13.5.1"
1717
},
1818
"devDependencies": {
1919
"@types/jest": "^27.5.2",

social-messenger-ts/yarn.lock

Lines changed: 127 additions & 341 deletions
Large diffs are not rendered by default.

team-ts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"react-dom": "^19.0.0",
2020
"react-dropzone": "^14.2.3",
2121
"react-popper": "^2.3.0",
22-
"stream-chat": "^9.6.0",
23-
"stream-chat-react": "^13.1.0"
22+
"stream-chat": "^9.17.0",
23+
"stream-chat-react": "^13.5.1"
2424
},
2525
"devDependencies": {
2626
"@types/emoji-mart": "^3.0.9",

team-ts/src/App.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
createGiphyCommandInjectionMiddleware
1515
} from "./middleware/composition/giphyCommandInjectionMiddleware";
1616
import {createGiphyCommandControlMiddleware} from "./middleware/textComposition/giphyCommandControl";
17-
import {createFormattingMarkdownInjectionMiddleware} from "./middleware/textComposition/formattingMarkdownInjection";
1817

1918
const urlParams = new URLSearchParams(window.location.search);
2019

@@ -52,12 +51,6 @@ const App = () => {
5251
],
5352
position: {before: 'stream-io/text-composer/pre-validation-middleware'}
5453
})
55-
composer.textComposer.middlewareExecutor.insert({
56-
middleware: [
57-
createFormattingMarkdownInjectionMiddleware(composer),
58-
],
59-
position: {after: 'stream-io/text-composer/pre-validation-middleware'}
60-
})
6154
});
6255
}, []);
6356

team-ts/src/components/TeamMessageInput/hooks/useMessageInputCompositionControls.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const mdToFormattingType: Record<string, MessageInputFormattingType> = {
66
'**': 'bold',
77
'*': 'italics',
88
'~~': 'strikethrough',
9-
'``': 'code',
9+
'`': 'code',
1010
}
1111

1212
export const formattingTypeToMarkdown: Record<MessageInputFormattingType, string> = {
@@ -47,29 +47,36 @@ export const useMessageInputCompositionControls = () => {
4747
const textarea = textareaRef.current;
4848
if (!textarea) return;
4949

50+
let newSelection;
5051
const {activeFormatting} = customDataManager.customComposerData;
5152
if (!activeFormatting) {
5253
textComposer.wrapSelection({head: wrappingMarkdown, tail: wrappingMarkdown});
5354
customDataManager.setCustomData({activeFormatting: mdToFormattingType[wrappingMarkdown]});
54-
textarea.selectionStart = textComposer.selection.start;
55-
textarea.selectionEnd = textComposer.selection.end;
56-
textarea.focus();
57-
return;
58-
}
59-
const activeMarkdown = formattingTypeToMarkdown[activeFormatting];
60-
const newSelection = {
61-
start: textComposer.selection.start + activeMarkdown.length,
62-
end: textComposer.selection.end + + activeMarkdown.length,
63-
};
64-
textarea.selectionStart = newSelection.start;
65-
textarea.selectionEnd = newSelection.end;
66-
if (wrappingMarkdown === activeMarkdown) {
67-
customDataManager.setCustomData({activeFormatting: null});
55+
newSelection = {
56+
start:textComposer.selection.start,
57+
end: textComposer.selection.end,
58+
};
6859
} else {
69-
customDataManager.setCustomData({activeFormatting: mdToFormattingType[wrappingMarkdown]});
70-
textComposer.wrapSelection({head: wrappingMarkdown, selection: newSelection, tail: wrappingMarkdown});
60+
const activeMarkdown = formattingTypeToMarkdown[activeFormatting];
61+
newSelection = {
62+
start: textComposer.selection.start + activeMarkdown.length + wrappingMarkdown.length,
63+
end: textComposer.selection.end + +activeMarkdown.length + wrappingMarkdown.length,
64+
};
65+
if (wrappingMarkdown === activeMarkdown) {
66+
customDataManager.setCustomData({activeFormatting: null});
67+
} else {
68+
customDataManager.setCustomData({activeFormatting: mdToFormattingType[wrappingMarkdown]});
69+
textComposer.wrapSelection({head: wrappingMarkdown, selection: newSelection, tail: wrappingMarkdown});
70+
}
7171
}
7272
textarea.focus();
73+
/**
74+
* Some browsers (especially Chrome/Edge/WebKit) will move the caret to the end of the text after focus as part of their default focus-handling.
75+
* That happens after our JS runs, so it overwrites the position we set - browser invokes the event with the selection at the end of the textarea string
76+
*/
77+
setTimeout(() => {
78+
textarea.setSelectionRange(newSelection.start, newSelection.end)
79+
}, 0);
7380
}, [customDataManager, textareaRef, textComposer])
7481

7582
const formatter = useMemo<Record<MessageInputFormattingType, () => void>>(() => ({

team-ts/src/middleware/textComposition/formattingMarkdownInjection.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)