editor icon indicating copy to clipboard operation
editor copied to clipboard

Rich Text mode doesn't render markdown correctly

Open jojonoparat opened this issue 3 years ago • 4 comments

Hi, really appreciate for your work so far, I have tried cloning from your Nextjs example repo and run it. And it seems that Rich Text mode doesn't render markdown correctly image image From the image above you can see that the size of text "hello world" should be rendered as Header1, however it still was rendered as normal text. Additionally, bulleted list and numbered list are also not working in rich text mode but bolding, underlining and italic work fine.

To replicate the issue:

  • clone this repo
  • npm i
  • npm run dev
  • go to localhost:3000 and see how the "hello world" text is rendered

So far, I've tried different version of both nextjs (version 13.4.12 and 13.4.4) and @mdxeditor/editor(version 0.6.1 and 0.10.1) and different local computer (Macbook M2 Pro and Macbook M2 Air). Still, it yields the same result.

Am I missing any configuration for rendering markdown properly in Rich text mode ? Or is it only happening on my local computer only ?

jojonoparat avatar Jul 24 '23 17:07 jojonoparat

Hi, thanks for giving the editor a try! I will update the repo to ensure people don't get confused with it.

The problem you're observing is due to the tailwind reset, which Next.js ships by default. Even though the markup is there, the styling is not present.

For the live demo, I've applied the typography plugin. If you use something similar, you can just pass the class to the editor component.

Alternatively, you can also remove the tailwind reset.

petyosi avatar Jul 24 '23 18:07 petyosi

Hi, thanks for giving the editor a try! I will update the repo to ensure people don't get confused with it.

The problem you're observing is due to the tailwind reset, which Next.js ships by default. Even though the markup is there, the styling is not present.

For the live demo, I've applied the typography plugin. If you use something similar, you can just pass the class to the editor component.

Alternatively, you can also remove the tailwind reset.

just want to simplify it more , just install @tailwindcss/typography to your next application and pass "pose" like this <MDXEditor markdown={""} contentEditableClassName="prose" />

Easyvipin avatar Aug 10 '23 14:08 Easyvipin

I tried an other idea for this. Instead of removing @tailwind base which causes a lot of style disruption. We can do a extend pre-flight css and the changes as we need. I was just creating simple editor so I override for heading and anchor only -


@tailwind base;
@layer base {
  h1 {
    @apply text-3xl;
  }
  h2 {
    @apply text-2xl;
  }
  h3 {
    @apply text-xl;
  }
  h4 {
    @apply text-lg;
  }
  h5 {
    @apply text-base;
  }
  h6 {
    @apply text-sm;
  }
  a {
    @apply text-blue-600 underline;
  }
}
@tailwind components;
@tailwind utilities;

vignesh-gupta avatar Sep 07 '23 08:09 vignesh-gupta

Hi, thanks for giving the editor a try! I will update the repo to ensure people don't get confused with it. The problem you're observing is due to the tailwind reset, which Next.js ships by default. Even though the markup is there, the styling is not present. For the live demo, I've applied the typography plugin. If you use something similar, you can just pass the class to the editor component. Alternatively, you can also remove the tailwind reset.

just want to simplify it more , just install @tailwindcss/typography to your next application and pass "pose" like this <MDXEditor markdown={""} contentEditableClassName="prose" />

Thanks, It works. If anyone else had issues with installing typography, check here

armannaj avatar Sep 12 '23 05:09 armannaj