Apply custom table styles from CSS to CKEditor view

一曲冷凌霜 提交于 2020-01-04 05:16:10

问题


I'm trying to integrate CKEditor 4.1.1 in my site. So far, I've mostly got it working, except some of the specific table styles that I have in my site CSS doesn't get applied in the editor. I've already tried setting up config.contentsCss to point to my site-wide stylesheet, and that helps for most of my other contents, but it doesn't seem to apply the table styles. Here's the CSS I'm working with:

table#availability {
    width: 90%;
    border-collapse: collapse;
}

table#availability td, table#availability th {
    border: 1px solid #ccc;
    padding: 4px 7px 5px 8px;
}

table#availability th {
    text-align: center;
    font-weight: bold;
}

table#availability td + td {
    text-align: right;
}

Is this stuff too advanced for CKEditor somehow?


回答1:


By default CKEditor 4.1 strips out classes, styles, and any attribute that isn't specified in its rules, and of course any element that you can't generate with its buttons. You can check the content generated by the editor to verify that the ACF hasn't destroyed your current content.

If that's the problem, you might want to disable it:

CKEDITOR.config.allowedContent = true;


来源:https://stackoverflow.com/questions/16772981/apply-custom-table-styles-from-css-to-ckeditor-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!