-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.js
58 lines (50 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
50
51
52
53
54
55
56
57
CKEDITOR.plugins.add('elementeditor', {
lang: 'en,ru,uk',
requires: 'dialog,menubutton,smethods',
icons: 'elementeditor',
init: function(editor){
var lang = editor.lang.elementeditor,
commandDefinition = {
exec: function(editor){
var name = 'element' + CKEDITOR.tools.capitalize(this.name.slice(11));
editor.openDialog('elementeditorDialog', function(){
this.parts.title.setText(lang[name]);
this.selectPage(name);
});
}
};
CKEDITOR.dialog.add('elementeditorDialog', this.path + 'dialogs/elementeditor.js');
editor.addCommands({
editElementSource: commandDefinition,
editElementAttributes: commandDefinition
});
editor.addMenuGroup('elementeditorGroup');
editor.addMenuItems({
editSourceItem: {
label: lang.elementSource,
group: 'elementeditorGroup',
command: 'editElementSource',
},
editAttributesItem: {
label: lang.elementAttributes,
group: 'elementeditorGroup',
command: 'editElementAttributes'
}
});
editor.ui.addMenuButton('ElementEditor', {
label: lang.title,
onMenu: function(){
return {
editSourceItem: CKEDITOR.TRISTATE_OFF,
editAttributesItem: CKEDITOR.TRISTATE_OFF
}
}
});
CKEDITOR.plugins.widget && editor.on('selectionChange', function(e){
editor.ui.get('ElementEditor').setState(CKEDITOR.plugins.widget.isDomWidget(e.data.path.lastElement)
? CKEDITOR.TRISTATE_DISABLED
: CKEDITOR.TRISTATE_OFF
);
});
}
});