forked from prbaron/pbckcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
executable file
·59 lines (50 loc) · 2.12 KB
/
Copy pathplugin.js
File metadata and controls
executable file
·59 lines (50 loc) · 2.12 KB
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
CKEDITOR.plugins.add('pbckcode', {
icons: 'pbckcode',
lang : ['fr', 'en'],
init: function(editor) {
// load JS file
var head = document.getElementsByTagName('HEAD').item(0);
var script = document.createElement("script");
script.type = "text/javascript";
script.src = CKEDITOR.plugins.getPath('pbckcode') + "dialogs/ace/ace.js";
head.appendChild(script);
// load SHighlighter class
head = document.getElementsByTagName('HEAD').item(0);
script = document.createElement("script");
script.type = "text/javascript";
script.src = CKEDITOR.plugins.getPath('pbckcode') + "dialogs/PBSyntaxHighlighter.js";
head.appendChild(script);
// load CSS file
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = CKEDITOR.plugins.getPath('pbckcode') + "dialogs/style.css";
link.media = 'all';
head.appendChild(link);
// init a new id to the code element for ACE Editor
editor.codeId = Math.random().toString(36).substring(3);
editor.addCommand('pbckcodeCommand', new CKEDITOR.dialogCommand('pbckcodeDialog', {
allowedContent: 'pre[*]{*}(*)'
}));
editor.ui.addButton('pbckcode', {
label : editor.lang.pbckcode.addCode,
command : 'pbckcodeCommand',
toolbar : 'pbckcode'
});
if (editor.contextMenu) {
editor.addMenuGroup('pbckcodeGroup');
editor.addMenuItem('pbckcodeItem', {
label : editor.lang.pbckcode.editCode,
icon : this.path + "icons/pbckcode.png",
command : 'pbckcodeCommand',
group : 'pbckcodeGroup'
});
editor.contextMenu.addListener( function(element) {
if(element.getAscendant('pre', true)) {
return { pbckcodeItem: CKEDITOR.TRISTATE_OFF };
}
});
}
CKEDITOR.dialog.add('pbckcodeDialog', this.path + 'dialogs/pbckcode.js' );
}
});