ckeditor 4.1.5 → 4.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -27
- data/app/assets/javascripts/ckeditor/application.js +0 -1
- data/app/assets/javascripts/ckeditor/config.js +0 -59
- data/app/assets/javascripts/ckeditor/filebrowser/javascripts/application.js.erb +57 -55
- data/app/views/layouts/ckeditor/application.html.erb +3 -2
- data/lib/ckeditor.rb +17 -1
- data/lib/ckeditor/text_area.rb +2 -1
- data/lib/ckeditor/utils.rb +1 -5
- data/lib/ckeditor/version.rb +2 -2
- data/lib/generators/ckeditor/templates/ckeditor.rb +10 -0
- data/test/{ckeditor_test.rb → models/ckeditor_test.rb} +11 -0
- data/vendor/assets/javascripts/ckeditor/CHANGES.md +27 -1
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +364 -351
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/CHANGELOG.md +20 -0
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +19 -18
- metadata +76 -84
- data/app/assets/javascripts/ckeditor/filebrowser/javascripts/jquery.min.js +0 -4
- data/test/dummy/public/ckeditor_assets/attachments/1/rails_tar.gz +0 -0
- data/test/dummy/public/ckeditor_assets/pictures/1/content_rails.png +0 -0
- data/test/dummy/public/ckeditor_assets/pictures/1/original_rails.png +0 -0
- data/test/dummy/public/ckeditor_assets/pictures/1/thumb_rails.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eabd9522c6e41cc16b578e752c34cb931454a92
|
4
|
+
data.tar.gz: c11df316e009cde1dcef7c0046ee8db5ab08bdbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3eab2c3f744e674b0569974f4cab7832c1c64d5927f25d1d3155dc13160d78d0610966c16661b9d422c4bc84c7eeb28b49cad85168571689f5a9e18e20eb04
|
7
|
+
data.tar.gz: 1d01d18849af4afcb915182b1caf1d4fc2df8159001ceceed5e72c597e6a62943c45abe81254f19a7948768d8f2347a475444c3af0d37e48ed8fd44e50ab03a7
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ CKEditor is a WYSIWYG text editor designed to simplify web content creation. It
|
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
11
|
-
* Ckeditor version 4.5.
|
11
|
+
* Ckeditor version 4.5.6 (9 Dec 2015)
|
12
12
|
* Rails 4 integration
|
13
13
|
* Files browser
|
14
14
|
* HTML5 file uploader
|
@@ -29,14 +29,6 @@ or if you'd like to use the latest version from Github:
|
|
29
29
|
gem 'ckeditor', github: 'galetahub/ckeditor'
|
30
30
|
```
|
31
31
|
|
32
|
-
#### Using with ruby 1.8.7
|
33
|
-
|
34
|
-
For usage with ruby 1.8.7 you need to specify the gem version:
|
35
|
-
|
36
|
-
```
|
37
|
-
gem 'ckeditor', '4.0.4'
|
38
|
-
```
|
39
|
-
|
40
32
|
For file upload support, you must generate the necessary file storage models.
|
41
33
|
The currently supported backends are:
|
42
34
|
|
@@ -73,7 +65,6 @@ gem 'refile-mini_magick'
|
|
73
65
|
rails generate ckeditor:install --orm=active_record --backend=refile
|
74
66
|
```
|
75
67
|
|
76
|
-
|
77
68
|
#### ActiveRecord + dragonfly
|
78
69
|
|
79
70
|
Requires Dragonfly 1.0 or greater.
|
@@ -118,24 +109,40 @@ mount Ckeditor::Engine => '/ckeditor'
|
|
118
109
|
|
119
110
|
## Usage
|
120
111
|
|
112
|
+
### Load editor from gem vendor
|
113
|
+
|
121
114
|
Include ckeditor javascripts in your `app/assets/javascripts/application.js`:
|
122
115
|
|
123
116
|
```
|
124
117
|
//= require ckeditor/init
|
125
118
|
```
|
126
119
|
|
127
|
-
|
120
|
+
### Load editor via CKEditor CDN
|
128
121
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
122
|
+
Setup editor version to load (more info here http://cdn.ckeditor.com/)
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
# in config/initializers/ckeditor.rb
|
126
|
+
|
127
|
+
Ckeditor.setup do |config|
|
128
|
+
# //cdn.ckeditor.com/<version.number>/<distribution>/ckeditor.js
|
129
|
+
config.cdn_url = "//cdn.ckeditor.com/4.5.6/standard/ckeditor.js"
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
In view template include ckeditor CDN:
|
134
|
+
|
135
|
+
```slim
|
136
|
+
= javascript_include_tag Ckeditor.cdn_url
|
137
|
+
```
|
138
|
+
|
139
|
+
### Form helpers
|
140
|
+
|
141
|
+
```slim
|
142
|
+
= form_for @page do |form|
|
143
|
+
= form.cktext_area :notes, :class => 'someclass', :ckeditor => {:language => 'uk'}
|
144
|
+
= form.cktext_area :content, :value => 'Default value', :id => 'sometext'
|
145
|
+
= cktext_area :page, :info, :cols => 40, :ckeditor => {:uiColor => '#AADC6E', :toolbar => 'mini'}
|
139
146
|
```
|
140
147
|
|
141
148
|
### Customize ckeditor
|
@@ -171,7 +178,7 @@ CKEDITOR.editorConfig = function (config) {
|
|
171
178
|
|
172
179
|
When overriding the default `config.js` file, you must set all configuration options yourself as the bundled `config.js` will not be loaded. To see the default configuration, run `bundle open ckeditor`, copy `app/assets/javascripts/ckeditor/config.js` into your project and customize it to your needs.
|
173
180
|
|
174
|
-
### Deployment
|
181
|
+
### Deployment (only if you use ckeditor from gem vendor)
|
175
182
|
|
176
183
|
For Rails 4, add the following to `config/initializers/assets.rb`:
|
177
184
|
|
@@ -229,15 +236,15 @@ jQuery sample:
|
|
229
236
|
|
230
237
|
### Formtastic integration
|
231
238
|
|
232
|
-
```
|
233
|
-
|
234
|
-
|
239
|
+
```slim
|
240
|
+
= form.input :content, :as => :ckeditor
|
241
|
+
= form.input :content, :as => :ckeditor, :input_html => { :ckeditor => { :height => 400 } }
|
235
242
|
```
|
236
243
|
|
237
244
|
### SimpleForm integration
|
238
245
|
|
239
|
-
```
|
240
|
-
|
246
|
+
```slim
|
247
|
+
= form.input :content, :as => :ckeditor, :input_html => { :ckeditor => {:toolbar => 'Full'} }
|
241
248
|
```
|
242
249
|
|
243
250
|
### CanCan integration
|
@@ -33,65 +33,6 @@ CKEDITOR.editorConfig = function( config )
|
|
33
33
|
|
34
34
|
config.allowedContent = true;
|
35
35
|
|
36
|
-
// Rails CSRF token
|
37
|
-
config.filebrowserParams = function(){
|
38
|
-
var csrf_token, csrf_param, meta,
|
39
|
-
metas = document.getElementsByTagName('meta'),
|
40
|
-
params = new Object();
|
41
|
-
|
42
|
-
for ( var i = 0 ; i < metas.length ; i++ ){
|
43
|
-
meta = metas[i];
|
44
|
-
|
45
|
-
switch(meta.name) {
|
46
|
-
case "csrf-token":
|
47
|
-
csrf_token = meta.content;
|
48
|
-
break;
|
49
|
-
case "csrf-param":
|
50
|
-
csrf_param = meta.content;
|
51
|
-
break;
|
52
|
-
default:
|
53
|
-
continue;
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
if (csrf_param !== undefined && csrf_token !== undefined) {
|
58
|
-
params[csrf_param] = csrf_token;
|
59
|
-
}
|
60
|
-
|
61
|
-
return params;
|
62
|
-
};
|
63
|
-
|
64
|
-
config.addQueryString = function( url, params ){
|
65
|
-
var queryString = [];
|
66
|
-
|
67
|
-
if ( !params ) {
|
68
|
-
return url;
|
69
|
-
} else {
|
70
|
-
for ( var i in params )
|
71
|
-
queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
|
72
|
-
}
|
73
|
-
|
74
|
-
return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
|
75
|
-
};
|
76
|
-
|
77
|
-
// Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
|
78
|
-
CKEDITOR.on( 'dialogDefinition', function( ev ){
|
79
|
-
// Take the dialog name and its definition from the event data.
|
80
|
-
var dialogName = ev.data.name;
|
81
|
-
var dialogDefinition = ev.data.definition;
|
82
|
-
var content, upload;
|
83
|
-
|
84
|
-
if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
|
85
|
-
content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
|
86
|
-
upload = (content == null ? null : content.get('upload'));
|
87
|
-
|
88
|
-
if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {
|
89
|
-
upload.filebrowser['params'] = config.filebrowserParams();
|
90
|
-
upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
});
|
94
|
-
|
95
36
|
// Toolbar groups configuration.
|
96
37
|
config.toolbar = [
|
97
38
|
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
|
@@ -11,20 +11,22 @@ $.QueryString = (function(a) {
|
|
11
11
|
})(window.location.search.substr(1).split('&'))
|
12
12
|
|
13
13
|
$(document).ready(function(){
|
14
|
-
|
15
|
-
|
14
|
+
var selector = "div.gal-item div.gal-inner-holder";
|
15
|
+
|
16
|
+
$(document)
|
17
|
+
.on('mouseover', selector, function(e){
|
16
18
|
$(this).addClass('hover');
|
17
19
|
})
|
18
|
-
.
|
20
|
+
.on('mouseout', selector, function(e){
|
19
21
|
$(this).removeClass('hover');
|
20
22
|
})
|
21
|
-
.
|
23
|
+
.on('click', selector, function(e){
|
22
24
|
var url = $(this).parents('div.gal-item').data('url');
|
23
25
|
CKEDITOR.tools.callFunction(CKEditorFuncNum, url);
|
24
26
|
window.close();
|
25
27
|
});
|
26
|
-
|
27
|
-
$("div.gal-item a.gal-del"
|
28
|
+
|
29
|
+
$(document).on('ajax:complete', "div.gal-item a.gal-del", function(xhr, status){
|
28
30
|
$(this).parents('div.gal-item').remove();
|
29
31
|
});
|
30
32
|
|
@@ -49,15 +51,15 @@ qq.FileUploader.instances = new Object();
|
|
49
51
|
qq.FileUploaderInput = function(o){
|
50
52
|
// call parent constructor
|
51
53
|
qq.FileUploaderBasic.apply(this, arguments);
|
52
|
-
|
53
|
-
// additional options
|
54
|
+
|
55
|
+
// additional options
|
54
56
|
qq.extend(this._options, {
|
55
57
|
element: null,
|
56
58
|
// if set, will be used instead of qq-upload-list in template
|
57
59
|
listElement: null,
|
58
|
-
|
59
|
-
template_id: '#fileupload_tmpl',
|
60
|
-
|
60
|
+
|
61
|
+
template_id: '#fileupload_tmpl',
|
62
|
+
|
61
63
|
classes: {
|
62
64
|
// used to get elements from templates
|
63
65
|
button: 'fileupload-button',
|
@@ -65,7 +67,7 @@ qq.FileUploaderInput = function(o){
|
|
65
67
|
dropActive: 'fileupload-drop-area-active',
|
66
68
|
list: 'fileupload-list',
|
67
69
|
preview: 'fileupload-preview',
|
68
|
-
|
70
|
+
|
69
71
|
file: 'fileupload-file',
|
70
72
|
spinner: 'fileupload-spinner',
|
71
73
|
size: 'fileupload-size',
|
@@ -77,18 +79,18 @@ qq.FileUploaderInput = function(o){
|
|
77
79
|
fail: 'fileupload-fail'
|
78
80
|
}
|
79
81
|
});
|
80
|
-
// overwrite options with user supplied
|
81
|
-
qq.extend(this._options, o);
|
82
|
+
// overwrite options with user supplied
|
83
|
+
qq.extend(this._options, o);
|
82
84
|
|
83
85
|
this._element = document.getElementById(this._options.element);
|
84
86
|
this._listElement = this._options.listElement || this._find(this._element, 'list');
|
85
|
-
|
87
|
+
|
86
88
|
this._classes = this._options.classes;
|
87
|
-
|
88
|
-
this._button = this._createUploadButton(this._find(this._element, 'button'));
|
89
|
-
|
89
|
+
|
90
|
+
this._button = this._createUploadButton(this._find(this._element, 'button'));
|
91
|
+
|
90
92
|
//this._setupDragDrop();
|
91
|
-
|
93
|
+
|
92
94
|
qq.FileUploader.instances[this._element.id] = this;
|
93
95
|
};
|
94
96
|
|
@@ -99,18 +101,18 @@ qq.extend(qq.FileUploaderInput.prototype, {
|
|
99
101
|
/**
|
100
102
|
* Gets one of the elements listed in this._options.classes
|
101
103
|
**/
|
102
|
-
_find: function(parent, type){
|
103
|
-
var element = qq.getByClass(parent, this._options.classes[type])[0];
|
104
|
+
_find: function(parent, type){
|
105
|
+
var element = qq.getByClass(parent, this._options.classes[type])[0];
|
104
106
|
if (!element){
|
105
107
|
alert(type);
|
106
108
|
throw new Error('element not found ' + type);
|
107
109
|
}
|
108
|
-
|
110
|
+
|
109
111
|
return element;
|
110
112
|
},
|
111
113
|
_setupDragDrop: function(){
|
112
114
|
var self = this,
|
113
|
-
dropArea = this._find(this._element, 'drop');
|
115
|
+
dropArea = this._find(this._element, 'drop');
|
114
116
|
|
115
117
|
var dz = new qq.UploadDropZone({
|
116
118
|
element: dropArea,
|
@@ -122,49 +124,49 @@ qq.extend(qq.FileUploaderInput.prototype, {
|
|
122
124
|
e.stopPropagation();
|
123
125
|
},
|
124
126
|
onLeaveNotDescendants: function(e){
|
125
|
-
qq.removeClass(dropArea, self._classes.dropActive);
|
127
|
+
qq.removeClass(dropArea, self._classes.dropActive);
|
126
128
|
},
|
127
129
|
onDrop: function(e){
|
128
130
|
dropArea.style.display = 'none';
|
129
131
|
qq.removeClass(dropArea, self._classes.dropActive);
|
130
|
-
self._uploadFileList(e.dataTransfer.files);
|
132
|
+
self._uploadFileList(e.dataTransfer.files);
|
131
133
|
}
|
132
134
|
});
|
133
|
-
|
135
|
+
|
134
136
|
dropArea.style.display = 'none';
|
135
137
|
|
136
|
-
qq.attach(document, 'dragenter', function(e){
|
137
|
-
if (!dz._isValidFileDrag(e)) return;
|
138
|
-
|
139
|
-
dropArea.style.display = 'block';
|
140
|
-
});
|
138
|
+
qq.attach(document, 'dragenter', function(e){
|
139
|
+
if (!dz._isValidFileDrag(e)) return;
|
140
|
+
|
141
|
+
dropArea.style.display = 'block';
|
142
|
+
});
|
141
143
|
qq.attach(document, 'dragleave', function(e){
|
142
|
-
if (!dz._isValidFileDrag(e)) return;
|
143
|
-
|
144
|
+
if (!dz._isValidFileDrag(e)) return;
|
145
|
+
|
144
146
|
var relatedTarget = document.elementFromPoint(e.clientX, e.clientY);
|
145
147
|
// only fire when leaving document out
|
146
|
-
if ( ! relatedTarget || relatedTarget.nodeName == "HTML"){
|
147
|
-
dropArea.style.display = 'none';
|
148
|
+
if ( ! relatedTarget || relatedTarget.nodeName == "HTML"){
|
149
|
+
dropArea.style.display = 'none';
|
148
150
|
}
|
149
|
-
});
|
151
|
+
});
|
150
152
|
},
|
151
153
|
_onSubmit: function(id, fileName){
|
152
154
|
qq.FileUploaderBasic.prototype._onSubmit.apply(this, arguments);
|
153
|
-
this._addToList(id, fileName);
|
155
|
+
this._addToList(id, fileName);
|
154
156
|
},
|
155
157
|
_onProgress: function(id, fileName, loaded, total){
|
156
158
|
qq.FileUploaderBasic.prototype._onProgress.apply(this, arguments);
|
157
159
|
|
158
160
|
var item = this._getItemByFileId(id);
|
159
161
|
var size = this._find(item, 'size');
|
160
|
-
|
161
|
-
var text;
|
162
|
+
|
163
|
+
var text;
|
162
164
|
if (loaded != total){
|
163
165
|
text = Math.round(loaded / total * 100) + '% from ' + this._formatSize(total);
|
164
|
-
} else {
|
166
|
+
} else {
|
165
167
|
text = this._formatSize(total);
|
166
|
-
}
|
167
|
-
|
168
|
+
}
|
169
|
+
|
168
170
|
qq.setText(size, text);
|
169
171
|
},
|
170
172
|
_onComplete: function(id, fileName, result){
|
@@ -172,13 +174,13 @@ qq.extend(qq.FileUploaderInput.prototype, {
|
|
172
174
|
|
173
175
|
var item = this._getItemByFileId(id);
|
174
176
|
var asset = result.asset ? result.asset : result;
|
175
|
-
|
177
|
+
|
176
178
|
if (asset && asset.id){
|
177
179
|
qq.addClass(item, this._classes.success);
|
178
|
-
|
180
|
+
|
179
181
|
asset.size = this._formatSize(asset.size);
|
180
182
|
asset.controller = (asset.type !== undefined && asset.type.toLowerCase() == "ckeditor::picture" ? "pictures" : "attachment_files");
|
181
|
-
|
183
|
+
|
182
184
|
$(item).replaceWith($(this._options.template_id).tmpl(asset));
|
183
185
|
} else {
|
184
186
|
qq.addClass(item, this._classes.fail);
|
@@ -189,37 +191,37 @@ qq.extend(qq.FileUploaderInput.prototype, {
|
|
189
191
|
if (this._options.multiple === false) {
|
190
192
|
$(this._listElement).empty();
|
191
193
|
}
|
192
|
-
|
194
|
+
|
193
195
|
var asset = {
|
194
|
-
id: 0,
|
195
|
-
filename: this._formatFileName(fileName),
|
196
|
+
id: 0,
|
197
|
+
filename: this._formatFileName(fileName),
|
196
198
|
size: 0,
|
197
199
|
format_created_at: '',
|
198
200
|
url_content: "#",
|
199
201
|
controller: "assets",
|
200
202
|
url_thumb: "<%= asset_path('ckeditor/filebrowser/images/preloader.gif') %>"
|
201
203
|
};
|
202
|
-
|
204
|
+
|
203
205
|
var item = $(this._options.template_id)
|
204
206
|
.tmpl(asset)
|
205
207
|
.attr('qqfileid', id)
|
206
208
|
.prependTo( this._listElement );
|
207
|
-
|
209
|
+
|
208
210
|
item.find('div.img').addClass('preloader');
|
209
|
-
|
211
|
+
|
210
212
|
this._bindCancelEvent(item);
|
211
213
|
}
|
212
214
|
},
|
213
215
|
_getItemByFileId: function(id){
|
214
|
-
return $(this._listElement).find('div[qqfileid=' + id +']').get(0);
|
216
|
+
return $(this._listElement).find('div[qqfileid=' + id +']').get(0);
|
215
217
|
},
|
216
218
|
/**
|
217
|
-
* delegate click event for cancel link
|
219
|
+
* delegate click event for cancel link
|
218
220
|
**/
|
219
221
|
_bindCancelEvent: function(element){
|
220
222
|
var self = this,
|
221
|
-
item = $(element);
|
222
|
-
|
223
|
+
item = $(element);
|
224
|
+
|
223
225
|
item.find('a.' + this._classes.cancel).bind('click', function(e){
|
224
226
|
self._handler.cancel( item.attr('qqfileid') );
|
225
227
|
item.remove();
|
@@ -5,17 +5,18 @@
|
|
5
5
|
<meta name="robots" content="noindex, nofollow">
|
6
6
|
<%= csrf_meta_tag %>
|
7
7
|
<title><%= I18n.t('page_title', :scope => [:ckeditor]) %></title>
|
8
|
+
<script src="//code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
|
8
9
|
|
9
10
|
<% if assets_pipeline_enabled? -%>
|
10
11
|
<%= stylesheet_link_tag "ckeditor/application" %>
|
11
12
|
<%= javascript_include_tag "ckeditor/application" %>
|
12
13
|
<% else -%>
|
13
14
|
<link href="/javascripts/ckeditor/filebrowser/stylesheets/uploader.css" type="text/css" rel="stylesheet">
|
14
|
-
<% ["jquery.
|
15
|
+
<% ["jquery.tmpl.js", "fileuploader.js", "rails.js", "application.js"].each do |js| -%>
|
15
16
|
<script src="/javascripts/ckeditor/filebrowser/javascripts/<%= js %>" type="text/javascript"></script>
|
16
17
|
<% end -%>
|
17
18
|
<% end -%>
|
18
|
-
|
19
|
+
|
19
20
|
<script type="text/javascript">
|
20
21
|
var CKEditorFuncNum = $.QueryString["CKEditorFuncNum"];
|
21
22
|
var CKEditorName = $.QueryString["CKEditor"];
|