forked from ucsf-web-services/ucsf_webedit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucsf_webedit_config.js
182 lines (154 loc) · 4.57 KB
/
ucsf_webedit_config.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
Custom configuration for ckeditor.
Configuration options can be set here. Any settings described here will be
overridden by settings defined in the $settings variable of the hook. To
override those settings, do it directly in the hook itself to $settings.
*/
var ctrl ='CTRL';
if ( CKEDITOR.env.mac ) {
ctrl = 'CMD';
}
/* Lang override from http://stackoverflow.com/questions/17475263/change-language-value-in-ckeditor */
// Save the old CKEDITOR.plugins.load
var orgLoad = CKEDITOR.plugins.load;
// Overwrite CKEDITOR.plugins.load
CKEDITOR.plugins.load = function() {
// Save the old callback argument.
var oldCallback = arguments[ 1 ];
// Overwrite the old callback argument.
arguments[ 1 ] = function( plugins ) {
// Modify the plugin by adding beforeInit to the definition.
plugins.format.beforeInit = function( editor ) {
//relabel some items in the (en) format menu
editor.lang.format.panelTitle = '';
editor.lang.format.tag_p = 'Paragraph';
};
// Call the old callback.
oldCallback.call( this, plugins );
};
// Call old CKEDITOR.plugins.load
orgLoad.apply( this, arguments );
};
/**
* Things that happen once the instance is loaded
* CKEDITOR is the INSTANCE in this block of code
*/
CKEDITOR.on('instanceReady', function(CKEDITOR) {
CKEDITOR.editor.removeMenuItem('paste');
CKEDITOR.editor.removeMenuItem('cut');
CKEDITOR.editor.removeMenuItem('copy');
CKEDITOR.editor.addMenuGroup( 'indicators' );
var copy = 'Copy: ' + ctrl + '-C';
var paste = 'Paste: ' + ctrl + '-V';
var cut = 'Cut: ' + ctrl + '-X';
var spelling = 'Spelling suggestions: ' + ctrl + '-Right-Click';
//PASTE BEGIN
CKEDITOR.editor.addCommand("pasteIndi", {
exec : function(editor)
{
}});
CKEDITOR.editor.contextMenu.addListener( function( element, selection ) {
return {
pasteIndi : 0
};
});
CKEDITOR.editor.addMenuItems({
pasteIndi : {
label : paste,
command : 'pasteIndi',
group : 'indicators',
order : 2
}});
CKEDITOR.editor.addCommand("cutIndi", {
exec : function(editor)
{
}});
CKEDITOR.editor.contextMenu.addListener( function( element, selection ) {
return {
cutIndi : 0
};
});
CKEDITOR.editor.addMenuItems({
cutIndi : {
label : cut,
command : 'cutIndi',
group : 'indicators',
order : 3
}});
CKEDITOR.editor.addCommand("copyIndi", {
exec : function(editor)
{
alert (media);
}});
CKEDITOR.editor.contextMenu.addListener( function( element, selection ) {
return {
copyIndi : 0
};
});
CKEDITOR.editor.addMenuItems({
copyIndi : {
label : copy,
command : 'copyIndi',
group : 'indicators',
order : 1
}});
CKEDITOR.editor.addCommand("spellingIndi", {
exec : function(editor)
{
}});
CKEDITOR.editor.contextMenu.addListener( function( element, selection ) {
return {
spellingIndi : 0
};
});
CKEDITOR.editor.addMenuItems({
spellingIndi : {
label : spelling,
command : 'spellingIndi',
group : 'indicators',
order : 4
}});
//spelling END
//media BEGIN
if (CKEDITOR.editor.plugins.media) {
CKEDITOR.editor.addCommand("mediaBrowser", {
exec : function(editor)
{
editor.execCommand('media');
}});
CKEDITOR.editor.contextMenu.addListener( function( element, selection ) {
return {
mediaBrowser : CKEDITOR.TRISTATE_ON
};
});
CKEDITOR.editor.addMenuItems({
mediaBrowser : {
label : "Add/Edit Media",
command : 'media',
group : 'image',
order : 1
}});
}
//media END*/
});
CKEDITOR.on('dialogDefinition', function( ev ) {
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
//modify the default state of the table dialog
if(dialogName === 'table') {
var infoTab = dialogDefinition.getContents('info');
//set defaults of following to blank
var cellSpacing = infoTab.get('txtCellSpace');
cellSpacing['default'] = "";
var cellPadding = infoTab.get('txtCellPad');
cellPadding['default'] = "";
var border = infoTab.get('txtBorder');
border['default'] = "";
var width = infoTab.get('txtWidth');
width['default'] = "";
//not supported for html5
infoTab.remove('txtSummary');
var advTab = dialogDefinition.getContents('advanced');
advTab.remove('advLangDir');
}
});