-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.js
89 lines (77 loc) · 2.06 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
CKEDITOR.plugins.add('btgrids', {
requires: 'dialog,smethods',
lang: 'en,ru,uk',
icons: 'btgrids',
init: function(editor){
editor.addCommand('btgrids', new CKEDITOR.dialogCommand('btgridsDialog', {
allowedContent: 'div(row,col)',
requiredContent: 'div',
}));
editor.addCommand('btGridRowInsertBefore', {
exec: function(){
createRow().insertBefore(getRow());
}
});
editor.addCommand('btGridRowInsertAfter', {
exec: function(){
createRow().insertAfter(getRow());
}
});
editor.addCommand('btGridRowDelete', {
exec: function(){
getRow().remove();
}
});
editor.ui.addButton('btgrids', {
label: editor.lang.btgrids.label,
command: 'btgrids'
});
if (editor.contextMenu){
editor.addMenuGroup('btgridsGroup');
editor.addMenuItems({
btGridRow: {
label: editor.lang.btgrids.label,
group: 'btgridsGroup',
order: 1,
getItems: function(){
return {
btGridRowInsertBefore: CKEDITOR.TRISTATE_OFF,
btGridRowInsertAfter: CKEDITOR.TRISTATE_OFF,
btGridRowDelete: CKEDITOR.TRISTATE_OFF
};
}
},
btGridRowInsertBefore: {
label: editor.lang.btgrids.insertBefore,
command: 'btGridRowInsertBefore',
group: 'btgridsGroup'
},
btGridRowInsertAfter: {
label: editor.lang.btgrids.insertAfter,
command: 'btGridRowInsertAfter',
group: 'btgridsGroup'
},
btGridRowDelete: {
label: editor.lang.btgrids.deleteRow,
command: 'btGridRowDelete',
group: 'btgridsGroup'
}
});
editor.contextMenu.addListener(function(element){
if (element.findParent('div.row'))
return { btGridRow: CKEDITOR.TRISTATE_OFF };
});
}
CKEDITOR.dialog.add('btgridsDialog', this.path + 'dialogs/btgrids.js');
function getRow(){
return editor.getSelection().getStartElement().findParent('div.row');
}
function createRow(){
var row = editor.document.createElement('div').addClass('row'),
col = editor.document.createElement('div').addClass('col');
col.setText('Column');
row.append(col);
return row;
}
}
});