Retain strikethrough formatting in message bubble mentions
This commit is contained in:
parent
c39d1359fd
commit
474f994118
2 changed files with 32 additions and 19 deletions
|
@ -10,6 +10,7 @@ export function AtMention({
|
||||||
direction,
|
direction,
|
||||||
id,
|
id,
|
||||||
isInvisible,
|
isInvisible,
|
||||||
|
isStrikethrough,
|
||||||
name,
|
name,
|
||||||
onClick,
|
onClick,
|
||||||
onKeyUp,
|
onKeyUp,
|
||||||
|
@ -17,10 +18,23 @@ export function AtMention({
|
||||||
direction: 'incoming' | 'outgoing' | undefined;
|
direction: 'incoming' | 'outgoing' | undefined;
|
||||||
id: string;
|
id: string;
|
||||||
isInvisible: boolean;
|
isInvisible: boolean;
|
||||||
|
isStrikethrough?: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
onKeyUp: KeyboardEventHandler;
|
onKeyUp: KeyboardEventHandler;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
|
const textElement = (
|
||||||
|
<>
|
||||||
|
@
|
||||||
|
<Emojify isInvisible={isInvisible} text={name} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
const formattedTextElement = isStrikethrough ? (
|
||||||
|
<s>{textElement}</s>
|
||||||
|
) : (
|
||||||
|
textElement
|
||||||
|
);
|
||||||
|
|
||||||
if (isInvisible) {
|
if (isInvisible) {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
|
@ -31,10 +45,7 @@ export function AtMention({
|
||||||
data-id={id}
|
data-id={id}
|
||||||
data-title={name}
|
data-title={name}
|
||||||
>
|
>
|
||||||
<bdi>
|
<bdi>{formattedTextElement}</bdi>
|
||||||
@
|
|
||||||
<Emojify isInvisible={isInvisible} text={name} />
|
|
||||||
</bdi>
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -52,10 +63,7 @@ export function AtMention({
|
||||||
data-id={id}
|
data-id={id}
|
||||||
data-title={name}
|
data-title={name}
|
||||||
>
|
>
|
||||||
<bdi>
|
<bdi>{formattedTextElement}</bdi>
|
||||||
@
|
|
||||||
<Emojify isInvisible={isInvisible} text={name} />
|
|
||||||
</bdi>
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ function renderNode({
|
||||||
isInvisible,
|
isInvisible,
|
||||||
mentions: node.mentions,
|
mentions: node.mentions,
|
||||||
onMentionTrigger,
|
onMentionTrigger,
|
||||||
text: node.text,
|
node,
|
||||||
});
|
});
|
||||||
|
|
||||||
// We use separate elements for these because we want screenreaders to understand them
|
// We use separate elements for these because we want screenreaders to understand them
|
||||||
|
@ -287,18 +287,19 @@ function renderMentions({
|
||||||
emojiSizeClass,
|
emojiSizeClass,
|
||||||
isInvisible,
|
isInvisible,
|
||||||
mentions,
|
mentions,
|
||||||
|
node,
|
||||||
onMentionTrigger,
|
onMentionTrigger,
|
||||||
text,
|
|
||||||
}: {
|
}: {
|
||||||
|
direction: 'incoming' | 'outgoing' | undefined;
|
||||||
|
disableLinks: boolean;
|
||||||
emojiSizeClass: SizeClassType | undefined;
|
emojiSizeClass: SizeClassType | undefined;
|
||||||
isInvisible: boolean;
|
isInvisible: boolean;
|
||||||
mentions: ReadonlyArray<HydratedBodyRangeMention>;
|
mentions: ReadonlyArray<HydratedBodyRangeMention>;
|
||||||
text: string;
|
node: DisplayNode;
|
||||||
disableLinks: boolean;
|
|
||||||
direction: 'incoming' | 'outgoing' | undefined;
|
|
||||||
onMentionTrigger: ((conversationId: string) => void) | undefined;
|
onMentionTrigger: ((conversationId: string) => void) | undefined;
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const result: Array<ReactElement> = [];
|
const result: Array<ReactElement> = [];
|
||||||
|
const { text } = node;
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
|
||||||
|
@ -323,6 +324,7 @@ function renderMentions({
|
||||||
disableLinks,
|
disableLinks,
|
||||||
direction,
|
direction,
|
||||||
name: mention.replacementText,
|
name: mention.replacementText,
|
||||||
|
node,
|
||||||
onMentionTrigger,
|
onMentionTrigger,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -345,19 +347,21 @@ function renderMentions({
|
||||||
|
|
||||||
function renderMention({
|
function renderMention({
|
||||||
conversationId,
|
conversationId,
|
||||||
name,
|
direction,
|
||||||
|
disableLinks,
|
||||||
isInvisible,
|
isInvisible,
|
||||||
key,
|
key,
|
||||||
disableLinks,
|
name,
|
||||||
direction,
|
node,
|
||||||
onMentionTrigger,
|
onMentionTrigger,
|
||||||
}: {
|
}: {
|
||||||
conversationId: string;
|
conversationId: string;
|
||||||
name: string;
|
direction: 'incoming' | 'outgoing' | undefined;
|
||||||
|
disableLinks: boolean;
|
||||||
isInvisible: boolean;
|
isInvisible: boolean;
|
||||||
key: string;
|
key: string;
|
||||||
disableLinks: boolean;
|
name: string;
|
||||||
direction: 'incoming' | 'outgoing' | undefined;
|
node: DisplayNode;
|
||||||
onMentionTrigger: ((conversationId: string) => void) | undefined;
|
onMentionTrigger: ((conversationId: string) => void) | undefined;
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
if (disableLinks) {
|
if (disableLinks) {
|
||||||
|
@ -374,6 +378,7 @@ function renderMention({
|
||||||
key={key}
|
key={key}
|
||||||
id={conversationId}
|
id={conversationId}
|
||||||
isInvisible={isInvisible}
|
isInvisible={isInvisible}
|
||||||
|
isStrikethrough={node.isStrikethrough}
|
||||||
name={name}
|
name={name}
|
||||||
direction={direction}
|
direction={direction}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue