1

I'm writing my own CKEditor plugin to insert text snippets and have turned it into a custom module to work with the CKEditor stand-alone module.

  • The plugin works on a static page that just has CKEditor linked locally.
  • The button and plugin checkbox show up on the CKEditor Profile configuration page.
  • The button does NOT appear when I try adding or editing a node with a CKEditor-enabled text box.

Complete code for the Drupal module:

function ckeditor_insert_view_ckeditor_plugin() {
   return array(
      'insert_view' => array(
         // Plugin name.
            'name' => 'insert_view',
            // Plugin description - it will be displayed in the plugins management section of the profile settings.
            'desc' => t('Plugin for adding Insert Views shortcode.'),
            // The full path to the CKEditor plugin directory, trailing slash included.
            'path' => drupal_get_path('module', 'ckeditor_insert_view') . '/plugins/insert_view/',
            // Plugin buttons definition (optional).
            'buttons' => array(
               'insert_view' => array('label' => 'Insert View', 'icon' => 'icons/insert_view.png')
            )
        )
    );
}

Complete code of plugin.js:

CKEDITOR.plugins.add( 'insert_view', {
    init: function( editor ) {
        editor.addCommand( 'insert_view', new CKEDITOR.dialogCommand( 'viewDialog' ) );
        editor.ui.addButton( 'View', {
            label: 'Insert View',
            command: 'insert_view',
            //toolbar: 'insert',
            icon: this.path + 'icons/insert_view.png'
        });
        CKEDITOR.dialog.add( 'viewDialog', this.path + 'dialogs/insert_view.js' );
    }
});

Things I've already considered:

  • Advanced Content Filtering is turned off for this CKEditor profile.
  • I've tried it with the CDN and with a local CKEditor library. Doesn't seem to make a difference.
  • I think I have all the paths set correctly, but would appreciate another set of eyes!

What might I be missing?

Your Answer

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

Browse other questions tagged or ask your own question.