-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.js
52 lines (47 loc) · 1.41 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
50
51
52
CKEDITOR.plugins.add('btbadges', {
requires: 'dialog,smethods',
lang: 'en,ru,uk',
icons: 'btbadges,rmbtbadges',
init: function(editor){
editor.addCommand('btbadges', new CKEDITOR.dialogCommand('btbadgesDialog', {
allowedContent: 'span[!class]; a[!class,!href,target]'
}));
editor.addCommand('rmbtbadges', {
exec: function(editor){
var el = editor.getSelection().getStartElement();
el.rmClass(/badge([^\s]+|\b)/g);
if (el.is('span') && !el.hasAttributes())
el.remove(true);
}
});
editor.ui.addButton('btbadges', {
label: editor.lang.btbadges.label,
command: 'btbadges'
});
if (editor.contextMenu){
editor.addMenuGroup('btbadgesGroup');
editor.addMenuItems({
btbadgesItem: {
label: editor.lang.btbadges.label,
icon: 'btbadges',
command: 'btbadges',
group: 'btbadgesGroup'
},
btbadgesRemove: {
label: editor.lang.btbadges.remove,
icon: 'rmbtbadges',
command: 'rmbtbadges',
group: 'btbadgesGroup'
}
});
editor.contextMenu.addListener(function(element){
if (element.is('span', 'a') && !element.hasClass('btn'))
return {
btbadgesItem: CKEDITOR.TRISTATE_OFF,
btbadgesRemove: element.hasClass('badge') ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
};
});
}
CKEDITOR.dialog.add('btbadgesDialog', this.path + 'dialogs/btbadges.js');
}
});