-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.js
49 lines (44 loc) · 1.45 KB
/
plugin.js
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
CKEDITOR.plugins.add('btbuttons', {
requires: 'dialog,smethods',
lang: 'en,ru,uk',
icons: 'btbuttons,rmbtbuttons',
init: function(editor){
editor.addCommand('btbuttons', new CKEDITOR.dialogCommand('btbuttonsDialog', {
allowedContent: 'button[!class,type]; a[!href,!class,target,role]; input[!class,!value,!type]'
}));
editor.addCommand('rmbtbuttons', {
exec: function(editor){
editor.getSelection().getStartElement().rmClass(/(btn([^\s]+|\b))|(active|disabled)/g).removeAttributes(['role', 'type']);
}
});
editor.ui.addButton('btbuttons', {
label: editor.lang.btbuttons.label,
command: 'btbuttons'
});
if (editor.contextMenu){
editor.addMenuGroup('btbuttonsGroup');
editor.addMenuItems({
btbuttonsItem: {
label: editor.lang.btbuttons.label,
icon: 'btbuttons',
command: 'btbuttons',
group: 'btbuttonsGroup'
},
btbuttonsRemove: {
label: editor.lang.btbuttons.remove,
icon: 'rmbtbuttons',
command: 'rmbtbuttons',
group: 'btbuttonsGroup'
}
});
editor.contextMenu.addListener(function(element){
if (element.is('button', 'a', 'input') && !element.hasClass('badge'))
return {
btbuttonsItem: CKEDITOR.TRISTATE_OFF,
btbuttonsRemove: element.hasClass('btn') ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
};
});
}
CKEDITOR.dialog.add('btbuttonsDialog', this.path + 'dialogs/btbuttons.js');
}
});