Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit b8d2798

Browse files
author
Max Stoiber
committed
Fix mentions in plaintext thread composer
1 parent 8e903bc commit b8d2798

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

shared/draft-utils/process-thread-content.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { addEmbedsToEditorState } from './add-embeds-to-draft-js';
66
export default (type: 'TEXT' | 'DRAFTJS', body: string): string => {
77
let newBody = body;
88
if (type === 'TEXT') {
9+
// workaround react-mentions bug by replacing @[username] with @username
10+
// @see withspectrum/spectrum#4587
11+
newBody = newBody.replace(/@\[([a-z0-9_-]+)\]/g, '@$1');
912
newBody = JSON.stringify(
1013
convertToRaw(
1114
stateFromMarkdown(newBody, {

src/components/composer/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,9 @@ class ComposerWithData extends Component<Props, State> {
538538

539539
const content = {
540540
title: title.trim(),
541-
body: body,
541+
// workaround react-mentions bug by replacing @[username] with @username
542+
// @see withspectrum/spectrum#4587
543+
body: body.replace(/@\[([a-z0-9_-]+)\]/g, '@$1'),
542544
};
543545

544546
// this.props.mutate comes from a higher order component defined at the

0 commit comments

Comments
 (0)