ckeditor - 将样式应用于 CKEditor 5 的 HTML 输出

标签 ckeditor ckeditor5

我正在使用 CKEditor 5 来帮助我的客户发布他们的文章。但编辑器生成的内容是纯HTML 片段。如何设计内容样式?是否有可能页面 <div/> 中的内容样式和ckeditor5中的样式一样吗?

我知道我可以为内容编写 CSS,这是最好的方法吗?

最佳答案

您的问题归结为 FAQ entry :

There is no such thing as the contents.css file because in CKEditor 5 features bring their own content styles, which are by default included in the JavaScript build and loaded by the style–loader (they can be extracted, too). It optimizes the size of the builds as the styles of unused features are simply excluded.

Although some styles are provided by the features, it is up to the developers to make sure the content created by CKEditor 5 is properly styled, both in the front–end and in the back–end. To style the content in the editor (back–end), use the .ck-content CSS class

目前编辑器提供的内容样式很少。这就是为什么网站维护人员需要在前端/后端设置编辑内容的样式。

例如,要确保 <a>元素的样式正确,您可能想要这样的东西:

#content-container-in-frontend a,
#backend-container .ck-content a {
   ...
}
<小时/>

附注不要犹豫,在the issue about content styles中发表您的意见。 。我们很想了解更多关于您的用例(您的环境是什么?您使用 Webpack 吗?您如何管理项目中的样式?)、您的期望是什么以及什么最适合您。

<小时/>

更新:您现在可以浏览编辑器使用的内容样式并在应用程序的前端使用它们。 Learn more .

关于ckeditor - 将样式应用于 CKEditor 5 的 HTML 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52401319/

相关文章:

javascript - 将对话框字段值设置为选定文本

ckeditor - yii2 ckeditor 自定义插件

javascript - 当文本由外部源更新时,防止 ckeditor 触发设置回调

javascript - 如何将通过CKEditor5插入的所有URL预先转换为正确的URL?

javascript - 在ckeditor5-react中上传图片

position - 移动 CKEditor 内联工具栏

ckeditor - ckeditor中的自定义字体

javascript - 图像对话框——扩展 onOk,而不是完全覆盖

javascript - 如何设置CKEditor5 textarea不能为空?

ckeditor - 如何禁用 CKEditor 5 中的自定义工具栏按钮?