Skip to content
Merged
12 changes: 12 additions & 0 deletions .changeset/calm-carrots-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/core-services": patch
"@rocket.chat/core-typings": patch
"@rocket.chat/gazzodown": patch
"@rocket.chat/livechat": patch
"@rocket.chat/rest-typings": patch
"@rocket.chat/pdf-worker": patch
"rocketchat-services": patch
---

feat: Implemented InlineCode handling in Bold, Italic and Strike
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@rocket.chat/core-services": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
"@rocket.chat/logger": "workspace:^",
"@rocket.chat/logo": "^0.31.29",
"@rocket.chat/memo": "~0.31.25",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/model-typings": "workspace:^",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/mp3-encoder": "0.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type MessageBlock =
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Bold>;
| MessageParser.MarkupExcluding<MessageParser.Bold>
| MessageParser.InlineCode;

type BoldSpanProps = {
children: MessageBlock[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type MessageBlock =
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Italic>;
| MessageParser.MarkupExcluding<MessageParser.Italic>
| MessageParser.InlineCode;

type ItalicSpanProps = {
children: MessageBlock[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type MessageBlock =
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Strike>;
| MessageParser.MarkupExcluding<MessageParser.Strike>
| MessageParser.InlineCode;

type StrikeSpanProps = {
children: MessageBlock[];
Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/icons": "^0.33.0",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/models": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/icons": "^0.33.0",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/ui-kit": "workspace:~"
},
"volta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gazzodown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@rocket.chat/css-in-js": "~0.31.25",
"@rocket.chat/fuselage": "^0.44.2",
"@rocket.chat/fuselage-tokens": "~0.32.0",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/styled": "~0.31.25",
"@rocket.chat/ui-client": "workspace:^",
"@rocket.chat/ui-contexts": "workspace:^",
Expand Down
17 changes: 15 additions & 2 deletions packages/gazzodown/src/elements/BoldSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react';
import { lazy } from 'react';

import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement';
Expand All @@ -9,12 +10,15 @@ import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan';

const CodeElement = lazy(() => import('../code/CodeElement'));

type MessageBlock =
| MessageParser.Emoji
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Bold>;
| MessageParser.MarkupExcluding<MessageParser.Bold>
| MessageParser.InlineCode;

type BoldSpanProps = {
children: MessageBlock[];
Expand All @@ -23,7 +27,13 @@ type BoldSpanProps = {
const BoldSpan = ({ children }: BoldSpanProps): ReactElement => (
<>
{children.map((block, index) => {
if (block.type === 'LINK' || block.type === 'PLAIN_TEXT' || block.type === 'STRIKE' || block.type === 'ITALIC') {
if (
block.type === 'LINK' ||
block.type === 'PLAIN_TEXT' ||
block.type === 'STRIKE' ||
block.type === 'ITALIC' ||
block.type === 'INLINE_CODE'
) {
return <strong key={index}>{renderBlockComponent(block, index)}</strong>;
}
return renderBlockComponent(block, index);
Expand Down Expand Up @@ -54,6 +64,9 @@ const renderBlockComponent = (block: MessageBlock, index: number): ReactElement
case 'ITALIC':
return <ItalicSpan key={index} children={block.value} />;

case 'INLINE_CODE':
return <CodeElement key={index} code={block.value.value} />;

default:
return null;
}
Expand Down
11 changes: 10 additions & 1 deletion packages/gazzodown/src/elements/ImageElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import type * as MessageParser from '@rocket.chat/message-parser';
import { ReactElement, useMemo } from 'react';

const flattenMarkup = (
markup: MessageParser.Markup | MessageParser.Link | MessageParser.Emoji | MessageParser.ChannelMention | MessageParser.UserMention,
markup:
| MessageParser.Markup
| MessageParser.InlineCode
| MessageParser.Link
| MessageParser.Emoji
| MessageParser.ChannelMention
| MessageParser.UserMention,
): string => {
switch (markup.type) {
case 'PLAIN_TEXT':
Expand All @@ -13,6 +19,9 @@ const flattenMarkup = (
case 'STRIKE':
return markup.value.map(flattenMarkup).join('');

case 'INLINE_CODE':
return flattenMarkup(markup.value);

case 'LINK': {
const label = flattenMarkup(markup.value.label as MessageParser.Markup);
const href = markup.value.src.value;
Expand Down
17 changes: 15 additions & 2 deletions packages/gazzodown/src/elements/ItalicSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react';
import { lazy } from 'react';

import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement';
Expand All @@ -9,12 +10,15 @@ import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan';
import StrikeSpan from './StrikeSpan';

const CodeElement = lazy(() => import('../code/CodeElement'));

type MessageBlock =
| MessageParser.Emoji
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Italic>;
| MessageParser.MarkupExcluding<MessageParser.Italic>
| MessageParser.InlineCode;

type ItalicSpanProps = {
children: MessageBlock[];
Expand All @@ -23,7 +27,13 @@ type ItalicSpanProps = {
const ItalicSpan = ({ children }: ItalicSpanProps): ReactElement => (
<>
{children.map((block, index) => {
if (block.type === 'LINK' || block.type === 'PLAIN_TEXT' || block.type === 'STRIKE' || block.type === 'BOLD') {
if (
block.type === 'LINK' ||
block.type === 'PLAIN_TEXT' ||
block.type === 'STRIKE' ||
block.type === 'BOLD' ||
block.type === 'INLINE_CODE'
) {
return <em key={index}>{renderBlockComponent(block, index)}</em>;
}
return renderBlockComponent(block, index);
Expand Down Expand Up @@ -54,6 +64,9 @@ const renderBlockComponent = (block: MessageBlock, index: number): ReactElement
case 'BOLD':
return <BoldSpan key={index} children={block.value} />;

case 'INLINE_CODE':
return <CodeElement key={index} code={block.value.value} />;

default:
return null;
}
Expand Down
17 changes: 15 additions & 2 deletions packages/gazzodown/src/elements/StrikeSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as MessageParser from '@rocket.chat/message-parser';
import type { ReactElement } from 'react';
import { lazy } from 'react';

import EmojiElement from '../emoji/EmojiElement';
import ChannelMentionElement from '../mentions/ChannelMentionElement';
Expand All @@ -9,12 +10,15 @@ import ItalicSpan from './ItalicSpan';
import LinkSpan from './LinkSpan';
import PlainSpan from './PlainSpan';

const CodeElement = lazy(() => import('../code/CodeElement'));

type MessageBlock =
| MessageParser.Emoji
| MessageParser.ChannelMention
| MessageParser.UserMention
| MessageParser.Link
| MessageParser.MarkupExcluding<MessageParser.Strike>;
| MessageParser.MarkupExcluding<MessageParser.Strike>
| MessageParser.InlineCode;

type StrikeSpanProps = {
children: MessageBlock[];
Expand All @@ -23,7 +27,13 @@ type StrikeSpanProps = {
const StrikeSpan = ({ children }: StrikeSpanProps): ReactElement => (
<>
{children.map((block, index) => {
if (block.type === 'LINK' || block.type === 'PLAIN_TEXT' || block.type === 'ITALIC' || block.type === 'BOLD') {
if (
block.type === 'LINK' ||
block.type === 'PLAIN_TEXT' ||
block.type === 'ITALIC' ||
block.type === 'BOLD' ||
block.type === 'INLINE_CODE'
) {
return <del key={index}>{renderBlockComponent(block, index)}</del>;
}
return renderBlockComponent(block, index);
Expand Down Expand Up @@ -54,6 +64,9 @@ const renderBlockComponent = (block: MessageBlock, index: number): ReactElement
case 'BOLD':
return <BoldSpan key={index} children={block.value} />;

case 'INLINE_CODE':
return <CodeElement key={index} code={block.value.value} />;

default:
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/livechat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
},
"dependencies": {
"@rocket.chat/gazzodown": "workspace:^",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/random": "workspace:~",
"@rocket.chat/sdk": "^1.0.0-alpha.42",
"@rocket.chat/ui-kit": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@rocket.chat/apps-engine": "1.41.0",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/message-parser": "~0.31.27",
"@rocket.chat/message-parser": "~0.31.28",
"@rocket.chat/ui-kit": "workspace:~",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1"
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9002,7 +9002,7 @@ __metadata:
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.33.0
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/models": "workspace:^"
"@rocket.chat/rest-typings": "workspace:^"
"@rocket.chat/ui-kit": "workspace:~"
Expand All @@ -9027,7 +9027,7 @@ __metadata:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ^0.33.0
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/ui-kit": "workspace:~"
eslint: ~8.45.0
mongodb: ^4.17.1
Expand Down Expand Up @@ -9383,7 +9383,7 @@ __metadata:
"@rocket.chat/css-in-js": ~0.31.25
"@rocket.chat/fuselage": ^0.44.2
"@rocket.chat/fuselage-tokens": ~0.32.0
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/styled": ~0.31.25
"@rocket.chat/ui-client": "workspace:^"
"@rocket.chat/ui-contexts": "workspace:^"
Expand Down Expand Up @@ -9533,7 +9533,7 @@ __metadata:
"@rocket.chat/fuselage-tokens": ~0.32.0
"@rocket.chat/gazzodown": "workspace:^"
"@rocket.chat/logo": ^0.31.29
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/random": "workspace:~"
"@rocket.chat/sdk": ^1.0.0-alpha.42
"@rocket.chat/ui-kit": "workspace:~"
Expand Down Expand Up @@ -9662,12 +9662,12 @@ __metadata:
languageName: node
linkType: hard

"@rocket.chat/message-parser@npm:~0.31.27":
version: 0.31.27
resolution: "@rocket.chat/message-parser@npm:0.31.27"
"@rocket.chat/message-parser@npm:~0.31.28":
version: 0.31.28
resolution: "@rocket.chat/message-parser@npm:0.31.28"
dependencies:
tldts: ~5.7.112
checksum: 27f206171ce744d66ba727b5329cacafb29b00e9e95ae0109fba839a48d2b3cc4a087f91120e6dbee040a482a8e9738b5063419aaae25ef6c8727bc3d8c007c2
checksum: 26a1a49318052201c0f4d2807ea740f69ffe741f7d51ea192bf56d2a9e1a19c8317232dff8f0b0f332a63035a3589683d41b1fb64503d76f8cd76122a5f6b0fe
languageName: node
linkType: hard

Expand Down Expand Up @@ -9731,7 +9731,7 @@ __metadata:
"@rocket.chat/logger": "workspace:^"
"@rocket.chat/logo": ^0.31.29
"@rocket.chat/memo": ~0.31.25
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/mock-providers": "workspace:^"
"@rocket.chat/model-typings": "workspace:^"
"@rocket.chat/models": "workspace:^"
Expand Down Expand Up @@ -10403,7 +10403,7 @@ __metadata:
"@rocket.chat/apps-engine": 1.41.0
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/ui-kit": "workspace:~"
"@types/jest": ~29.5.7
ajv: ^8.11.0
Expand Down Expand Up @@ -36529,7 +36529,7 @@ __metadata:
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
"@rocket.chat/icons": ^0.33.0
"@rocket.chat/message-parser": ~0.31.27
"@rocket.chat/message-parser": ~0.31.28
"@rocket.chat/model-typings": "workspace:^"
"@rocket.chat/models": "workspace:^"
"@rocket.chat/rest-typings": "workspace:^"
Expand Down