1

Let's say I'm currently editing a page and there is a WYSIWYG editor in the backend to edit a specific part.

Now I add a table via the WYSIWYG. How can I apply CSS styles on that table WITHOUT altering the CKEditor plugin settings (I don't want to provide classes in the "Styles" dropdown)?

3

You can either implement hook_ckeditor_css_alter or you can add ckeditor_stylesheets to your themes info.yml file.

See: hook_ckeditor_css_alter for more.

Example:

function mymodule_ckeditor_css_alter(array &$css, Editor $editor) {
  $css[] = drupal_get_path('theme', 'mytheme') . '/css/mymodule-ckeditor.css';
}

Or in mytheme.info.yml:

ckeditor_stylesheets:
  - css/styles.css
  • Thank you! I edited the mytheme.info.yml as you suggested and it worked perfectly! – elterr1ble Mar 27 '17 at 16:02
0

You can do this by flipping to HTML source, and adding a class in the html.

Perhaps this is for a user that you do not want to give privileged permissions to? (which I assume would include 'Source' button on a WYSIWYG)

If so maybe you can generally style a table in a nice way (ie not need a class or inline styling) or perhaps target the area that this table will be displaying, if its a particular node type you could target that existing class and style the table beneath that:

.custom_content_type table {
  /* Your styles here*/
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.