663f104f72e1b26d839794fe513facd53e27a6db
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / plugin / _ckeditor / plugin.twig
1 /**
2  * @file
3  * {{ plugin_label }} CKEditor plugin.
4  *
5  * Basic plugin inserting abbreviation elements into the CKEditor editing area.
6  *
7  * @DCG The code is based on an example from CKEditor Plugin SDK tutorial.
8  *
9  * @see http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
10  */
11 (function (Drupal) {
12
13   'use strict';
14
15   CKEDITOR.plugins.add('{{ plugin_id }}', {
16
17     // Register the icons.
18     icons: '{{ short_plugin_id }}',
19
20     // The plugin initialization logic goes inside this method.
21     init: function(editor) {
22
23       // Define an editor command that opens our dialog window.
24       editor.addCommand('{{ command_name }}', new CKEDITOR.dialogCommand('{{ command_name }}Dialog'));
25
26       // Create a toolbar button that executes the above command.
27       editor.ui.addButton('{{ short_plugin_id }}', {
28
29         // The text part of the button (if available) and the tooltip.
30         label: Drupal.t('Insert abbreviation'),
31
32         // The command to execute on click.
33         command: '{{ command_name }}',
34
35         // The button placement in the toolbar (toolbar group name).
36         toolbar: 'insert'
37       });
38
39       // Register our dialog file, this.path is the plugin folder path.
40       CKEDITOR.dialog.add('{{ command_name }}Dialog', this.path + 'dialogs/{{ short_plugin_id }}.js');
41     }
42   });
43
44 } (Drupal));