backdrop-contrib / ckeditor

NOW IN BACKDROP CORE 🎉 Rich text editor integration using the CKeditor library.
GNU General Public License v2.0
0 stars 0 forks source link

Adding Custom Styles to Dropdown #7

Open JugglingCoder opened 8 years ago

JugglingCoder commented 8 years ago

In Drupal 7 I was able to add specific "Styles" per role using the function below. Is there a quick fix for Backdrop?

=================================
/**
 * =====================================
 * CKEditor Styles
 *
 * Set a .js "Style" for the CKEditor WizyWig "per" user
 *
 */
function bscool_wysiwyg_editor_settings_alter(&$settings, $context) {
    echo '<p>im here</p>';die();
    // See:
    // 1.) (WORKS) http://fuseinteractive.ca/blog/wysiwyg-module-ckeditor-taming-beast#.VUjvq_lVhBc

  if ($context['profile']->editor == 'ckeditor') {

        global $base_path;
        global $user;

        $path = $base_path . backdrop_get_path('module', 'bscool') . '/ckeditor_styles/';

            // The $settings variable contains all the config options ckeditor uses. 
            // The array keys correspond directly with any setting that can be applied 
            // to CKEditor - as outlined in the CKEditor docs: 
            // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html 
            // Another way to override configuration is to use your own configuration javascript
            // file. In this case, we're going to add our own configuration file that will
            // Hold our stylesSet customizations... 

            // Load a different .js "Per User"

        if(
            $user->uid == 1 ||
            in_array('administrator', array_values($user->roles)) ||
            in_array('Content Contributor', array_values($user->roles))
        ){
            $settings['customConfig'] = $path . 'admin.js';
        }elseif(
            in_array('authenticated', array_values($user->roles))
        ){
            $settings['customConfig'] = $path . 'authenticated_user_limited.js';
        }else{
            echo '';
        }

    }
} // ========= END Function =============================================

=============================
klonos commented 8 years ago

"WizyWig" LOL :laughing: