-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.js
52 lines (46 loc) · 1.34 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
CKEDITOR.plugins.add('fdlbs', {
requires: 'dialog,smethods',
lang: 'en,ru,uk',
icons: 'fdlbs,rmfdlbs',
init: function(editor){
editor.addCommand('fdlbs', new CKEDITOR.dialogCommand('fdlbsDialog', {
allowedContent: 'i,span[!class];a[!class,!href,target]'
}));
editor.addCommand('removefdlbs', {
exec: function(editor){
var el = editor.getSelection().getStartElement().rmClass(/label|badge|primary|secondary|success|alert|warning/g);
if (el.is('span') && !el.hasAttributes())
el.remove(true);
}
});
editor.ui.addButton('fdlbs', {
label: editor.lang.fdlbs.buttonLabel,
command: 'fdlbs'
});
if (editor.contextMenu){
editor.addMenuGroup('fdlbsGroup');
editor.addMenuItems({
fdlbsItem: {
label: editor.lang.fdlbs.buttonLabel,
icon: 'fdlbs',
command: 'fdlbs',
group: 'fdlbsGroup'
},
rmfdlbs: {
label: editor.lang.fdlbs.remove,
icon: 'rmfdlbs',
command: 'removefdlbs',
group: 'fdlbsGroup'
}
});
editor.contextMenu.addListener(function(element){
if (element.is('span', 'a') && !element.hasClass('button'))
return {
fdlbsItem: CKEDITOR.TRISTATE_OFF,
rmfdlbs: element.matchClass(/label|badge/) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
};
});
}
CKEDITOR.dialog.add('fdlbsDialog', this.path + 'dialogs/fdlbs.js');
}
});