Skip to content

Commit

Permalink
Add markdown support for Q&A (#2324)
Browse files Browse the repository at this point in the history
  • Loading branch information
osamasayed authored Feb 23, 2025
1 parent e3db813 commit 945ab5e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/QuestionAndAnswer/Answer/AnswerBody/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable i18next/no-literal-string */
import React, { useEffect, useState } from 'react';

import { MilkdownProvider } from '@milkdown/react';
import clipboardCopy from 'clipboard-copy';
import useTranslation from 'next-translate/useTranslation';
import {
Expand All @@ -13,6 +14,7 @@ import {

import styles from './AnswerBody.module.scss';

import MarkdownEditor from '@/components/MarkdownEditor';
import Button, { ButtonSize, ButtonVariant } from '@/dls/Button/Button';
import CopyLinkIcon from '@/icons/copy-link-new.svg';
import FacebookIcon from '@/icons/fb.svg';
Expand Down Expand Up @@ -76,11 +78,15 @@ const AnswerBody: React.FC<Props> = ({ question }) => {
<>
<div className={styles.answerBody}>
<p className={styles.header}>{t('q-and-a.answer')}</p>
<div className={styles.text}>{question?.answers[0]?.body}</div>
<MilkdownProvider>
<MarkdownEditor isEditable={false} defaultValue={question?.answers[0]?.body} />
</MilkdownProvider>
{question?.summary && (
<>
<p className={styles.header}>{t('q-and-a.summary')}</p>
<div className={styles.text}>{question?.summary}</div>
<MilkdownProvider>
<MarkdownEditor isEditable={false} defaultValue={question?.summary} />
</MilkdownProvider>
</>
)}
{question?.references && (
Expand Down

0 comments on commit 945ab5e

Please sign in to comment.