Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I either call my custom styles "drupal" and erratically get the following error:
Error: [CKEDITOR.resourceManager.add] The resource name "drupal" is already registered.
Or I call them "cc_drupal" and they are not applied to the document, and the styles button is greyed out.
Code:
if(typeof(CKEDITOR) !== 'undefined') {
CKEDITOR.addStylesSet( 'cc_drupal',
[
/* Block Styles */
// These styles are already available in the "Format" drop-down list, so they are
// not needed here by default. You may enable them to avoid placing the
// "Format" drop-down list in the toolbar, maintaining the same features.
{ name : 'Paragraph' , element : 'p' },
{ name : 'Heading 3' , element : 'h3' },
{ name : 'Heading 4' , element : 'h4' },
{ name : 'Heading 5' , element : 'h5' },
{ name : 'Heading 6' , element : 'h6' },
{ name : 'Monospaced' , element : 'pre' },
]);
}
Generates error with:
CKEDITOR.addStylesSet( 'drupal',
Comments
Comment #2
glass.dimly CreditAttribution: glass.dimly commentedI found the following ckeditor page which was immensely useful: http://docs.ckeditor.com/#!/guide/dev_howtos_styles
I replaced the default styles in the following manner:
Then in the file location specified above ('my_module/js/my_module.ckeditor.styles.js') I put the following JS:
Note: the key line here that I did not seem to see or notice in other tutorials was this:
CKEDITOR.config.stylesSet = 'cc_drupal';
The started code for styles can be got from here: "ckeditor/ckeditor.styles.js"