Skip to content

Commit

Permalink
fix: rich text editor v2 [WPB-12089] (#18528)
Browse files Browse the repository at this point in the history
* fix: mentions tag wrapping

* fix: adjust white-space and line-height in message list styles

* fix: edit view message styles while rich text is turned off

* chore: bring back list line heigt

* fix: ensure unique mentions in edited message plugin

* fix: add column gap to input bar layout
  • Loading branch information
olafsulich authored Dec 18, 2024
1 parent ce3e833 commit 4cdae2b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function EditedMessagePlugin({message}: Props): null {

const mentionNodes = getMentionNodesFromMessage(message);

const allowedMentions = mentionNodes.map(node => node.getTextContent());
const allowedMentions = [...new Set(mentionNodes.map(node => node.getTextContent()))];

const wrappedWithTags = wrapMentionsWithTags(messageContent, allowedMentions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const wrapMentionsWithTags = (text: string, allMentions: string[]): strin
return text;
}

const mentionRegex = new RegExp(`(${allMentions.join('|')})`, 'g');

return text.replace(mentionRegex, '<mention>$1</mention>');
return allMentions.reduce(
(updatedText, mention) => updatedText.split(mention).join(`<mention>${mention}</mention>`),
text,
);
};
3 changes: 2 additions & 1 deletion src/style/content/conversation/input-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,11 @@

display: grid;
padding-left: var(--input-bar-avatar-spacing);
column-gap: 8px;
grid-template-areas:
'avatar input input'
'avatar buttons buttons';
grid-template-columns: calc(var(--input-bar-avatar-size) + var(--input-bar-avatar-spacing)) 1fr 1fr;
grid-template-columns: calc(var(--input-bar-avatar-size) + var(--input-bar-avatar-spacing)) 1fr min-content;
row-gap: 8px;

@media (min-width: 900px) {
Expand Down
2 changes: 1 addition & 1 deletion src/style/content/conversation/message-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
display: inline;
min-width: 0;
line-height: var(--line-height-lg);
white-space: pre-wrap;
white-space: normal;
word-wrap: break-word;

li {
Expand Down

0 comments on commit 4cdae2b

Please sign in to comment.