Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
901 views
in Technique[技术] by (71.8m points)

css - How to render HTML coming out of TinyMCE with proper stylesheets in my own frontend?

Having a TinyMCE-Editor, it gives me as output proper html tags like h1, h2, b, ul, ol, li. Like this:

enter image description here

However, when I want to render exactly the output of TinyMCE in my own frontend, which is consisting of TailWindCSS or Bootstrap, every style of every html-tag looks very plain with same size, same margin, same padding, as it would be in a normal text-element.

enter image description here

I found out, that these CSS-frameworks use something like "normalize-css" to achieve this look. However, how can I restore the CSS-styles of TinyMCE in my frontend although I am using Tailwind and/or BootstrapCSS?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Talwind Preflight is responsible for this. Preflight removes all the margins, paddings and every set of base styles.

@tailwind base; /* Preflight will be injected here */

@tailwind components;

@tailwind utilities;

You can disable it

// tailwind.config.js
module.exports = {
  corePlugins: {
   preflight: false,
  }
}

Once disabled, html tags like h1, h2, b, ul, ol, li will be rendered properly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...