Skip to content

Commit 1851c29

Browse files
committed
feat: add blockquote support for preview in message
1 parent 68f8b88 commit 1851c29

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const generateMarkdownText = (text?: string) => {
3434
}
3535

3636
// Escape the " and ' characters, except in code blocks where we deem this allowed.
37-
resultText = resultText.replace(/(```[\s\S]*?```|`.*?`)|[<"'>]/g, (match, code) => {
37+
resultText = resultText.replace(/(```[\s\S]*?```|`.*?`)|[<"']/g, (match, code) => {
3838
if (code) return code;
3939
return `\\${match}`;
4040
});

package/src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ export const renderText = <
200200
color: colors.accent_blue,
201201
...markdownStyles?.autolink,
202202
},
203+
blockQuoteText: {
204+
...defaultMarkdownStyles.blockQuoteText,
205+
...markdownStyles?.blockQuoteText,
206+
},
207+
blockQuoteSection: {
208+
...defaultMarkdownStyles.blockQuoteSection,
209+
flexDirection: 'row',
210+
padding: 8,
211+
...markdownStyles?.blockQuoteSection,
212+
},
213+
blockQuoteSectionBar: {
214+
...defaultMarkdownStyles.blockQuoteSectionBar,
215+
width: 2,
216+
backgroundColor: colors.grey_gainsboro,
217+
marginRight: 8,
218+
...markdownStyles?.blockQuoteSectionBar,
219+
},
203220
codeBlock: {
204221
...defaultMarkdownStyles.codeBlock,
205222
backgroundColor: colors.code_block,
@@ -398,6 +415,13 @@ export const renderText = <
398415
</MarkdownReactiveScrollView>
399416
);
400417

418+
const blockQuoteReact: ReactNodeOutput = (node, output, state) => (
419+
<View key={state.key} style={styles.blockQuoteSection}>
420+
<View style={styles.blockQuoteSectionBar} />
421+
<View style={styles.blockQuoteText}>{output(node.content, state)}</View>
422+
</View>
423+
);
424+
401425
const customRules = {
402426
// do not render images, we will scrape them out of the message and show on attachment card component
403427
image: { match: () => null },
@@ -420,6 +444,9 @@ export const renderText = <
420444
: {}),
421445
codeBlock: { react: codeBlockReact },
422446
table: { react: tableReact },
447+
blockQuote: {
448+
react: blockQuoteReact,
449+
},
423450
};
424451

425452
return (

0 commit comments

Comments
 (0)