-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin.js
47 lines (41 loc) · 1.47 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
/**
* Created by anndoc on 25.08.16.
*
* @fileOverview The Image Crop plugin.
*/
CKEDITOR.plugins.add('imagecrop', {
requires: 'dialog,image',
icons: 'imagecrop',
lang: 'en',
init: function (editor) {
var pluginDirectory = this.path,
style = document.createElement('link');
editor.addCommand('imagecrop', new CKEDITOR.dialogCommand('cropDialog'));
style.type = 'text/css';
style.rel = 'stylesheet';
style.href = editor.config.cropperCssUrl;
document.getElementsByTagName("head")[0].appendChild(style);
CKEDITOR.scriptLoader.load(editor.config.cropperJsUrl);
editor.ui.addButton('ImageCrop', {
label: editor.lang.imagecrop.title,
command: 'imagecrop',
toolbar: 'insert',
icon: this.path + 'icons/imagecrop.png'
});
if (editor.contextMenu) {
editor.addMenuGroup('cropGroup');
editor.addMenuItem('cropItem', {
label: 'Edit Image',
icon: this.path + 'icons/imagecrop.png',
command: 'imagecrop',
group: 'cropGroup'
});
editor.contextMenu.addListener(function (element) {
if (element.getAscendant('img', true)) {
return {cropItem: CKEDITOR.TRISTATE_OFF};
}
});
}
CKEDITOR.dialog.add('cropDialog', pluginDirectory + 'dialogs/imagecrop.js');
}
});