1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/**
* Copyright (c) 2014, CKSource - Frederico Knabben. All rights reserved.
* Licensed under the terms of the MIT License (see LICENSE.md).
*
* Basic sample plugin inserting abbreviation elements into the CKEditor editing area.
*
* Created out of the CKEditor Plugin SDK:
* http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
*/
// Register the plugin within the editor.
CKEDITOR.plugins.add( 'abbr', {
// Register the icons.
icons: 'abbr',
lang: 'en,sl',
// The plugin initialization logic goes inside this method.
init: function( editor ) {
// Define an editor command that opens our dialog window.
editor.addCommand( 'abbr', new CKEDITOR.dialogCommand( 'abbrDialog' ) );
// Create a toolbar button that executes the above command.
editor.ui.addButton( 'Abbr', {
// The text part of the button (if available) and the tooltip.
label: editor.lang.abbr.gumb,
// The command to execute on click.
command: 'abbr',
// The button placement in the toolbar (toolbar group name).
toolbar: 'insert, 100'
});
if ( editor.contextMenu ) {
// Add a context menu group with the Edit Abbreviation item.
editor.addMenuGroup( 'abbrGroup' );
editor.addMenuItem( 'abbrItem', {
label: 'Uredi slovar',
icon: this.path + 'icons/abbr.png',
command: 'abbr',
group: 'abbrGroup'
});
editor.contextMenu.addListener( function( element ) {
if ( element.getAscendant( 'abbr', true ) ) {
return { abbrItem: CKEDITOR.TRISTATE_OFF };
}
});
}
// Register our dialog file -- this.path is the plugin folder path.
CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' );
}
});
|