rails_kindeditor 0.4.7 → 0.5.0
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 +40 -90
- data/app/uploaders/kindeditor/asset_uploader.rb +0 -2
- data/lib/rails_kindeditor/helper.rb +2 -0
- data/lib/rails_kindeditor/simple_form.rb +1 -1
- data/lib/rails_kindeditor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1646a9cc4af470cf7ff498125e965fccf45c09a6
|
4
|
+
data.tar.gz: 1598b87d18c480a7808c4be83a5e1ca6f60b573b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 478d1d2302dc65481cd4d09cbbc1772de6473b53f94c2072965d04c987f38d339b6a783268d172ccf9447cf29f36b0df341da2b1a440928ca947e259bb010be8
|
7
|
+
data.tar.gz: 608345c25a88ad695f677cb282b56faecb17b34fd34a1b9ea231090d957166877470a7faeb6c47304755c21a024963f4e39e758443100a3dd219aba5949ad4c7
|
data/README.md
CHANGED
@@ -22,17 +22,17 @@ rails_kindeditor will helps your rails app integrate with kindeditor, includes i
|
|
22
22
|
### Run install generator:
|
23
23
|
|
24
24
|
```bash
|
25
|
-
rails
|
25
|
+
rails g rails_kindeditor:install
|
26
26
|
```
|
27
27
|
notice: rails_kindeditor needs applications.js in your project.
|
28
28
|
|
29
|
-
###
|
29
|
+
### Production mode
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
Precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. see https://github.com/rails/rails/pull/7968
|
32
|
+
please run 'rails kindeditor:assets', this method just copy kindeditor into public folder.
|
33
33
|
|
34
34
|
```bash
|
35
|
-
|
35
|
+
rails kindeditor:assets
|
36
36
|
```
|
37
37
|
|
38
38
|
### Usage:
|
@@ -66,56 +66,32 @@ additionally, rails_kindeditor provides one "simple_mode" parameter for render s
|
|
66
66
|
|
67
67
|
That's all.
|
68
68
|
|
69
|
-
### Work with
|
69
|
+
### Work with Turbolinks5
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
1.use "'data-no-turbolink' => true" when we need to load kindeditor,this will shut down the turbolinks in this page
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
<%= link_to 'Edit', edit_article_path(article), 'data-no-turbolink' => true %>
|
77
|
-
```
|
78
|
-
|
79
|
-
2.load kindeditor manually, but you should specify the parameters again, include the textarea's id.
|
71
|
+
Create a file app/assets/javascripts/load_kindeditor.coffee
|
80
72
|
|
81
73
|
```coffeescript
|
82
74
|
# coffeescript code
|
83
|
-
$(document).on '
|
84
|
-
|
85
|
-
|
75
|
+
$(document).on 'turbolinks:before-cache', ->
|
76
|
+
KindEditor.remove('.rails_kindeditor')
|
77
|
+
|
78
|
+
$(document).on 'turbolinks:load', ->
|
79
|
+
$('.rails_kindeditor').each ->
|
80
|
+
KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300'
|
86
81
|
```
|
87
82
|
|
88
83
|
simple mode
|
89
84
|
```coffeescript
|
90
85
|
# coffeescript code
|
91
|
-
$(document).on '
|
92
|
-
|
93
|
-
KindEditor.create '#article_content',
|
94
|
-
"width":"100%",
|
95
|
-
"height":300,
|
96
|
-
"allowFileManager":true,
|
97
|
-
"uploadJson":"/kindeditor/upload",
|
98
|
-
"fileManagerJson":"/kindeditor/filemanager",
|
99
|
-
"items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
|
100
|
-
```
|
86
|
+
$(document).on 'turbolinks:before-cache', ->
|
87
|
+
KindEditor.remove('.rails_kindeditor')
|
101
88
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
f.kindeditor :content, owner: @article
|
89
|
+
$(document).on 'turbolinks:load', ->
|
90
|
+
$('.rails_kindeditor').each ->
|
91
|
+
KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300', "items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
|
106
92
|
```
|
107
93
|
|
108
|
-
|
109
|
-
# coffeescript code
|
110
|
-
$(document).on 'page:load', ->
|
111
|
-
if $('#article_content').length > 0
|
112
|
-
KindEditor.create '#article_content',
|
113
|
-
"width" : "100%",
|
114
|
-
"height" : 300,
|
115
|
-
"allowFileManager" : true,
|
116
|
-
"uploadJson" : $('#article_content').data('upload'),
|
117
|
-
"fileManagerJson" : $('#article_content').data('filemanager')
|
118
|
-
```
|
94
|
+
Make sure the file is loaded from your app/assets/javascripts/application.js
|
119
95
|
|
120
96
|
### Include javascript files at bottom ? Not in the head tag ? How can I load kindeditor correctly ?
|
121
97
|
|
@@ -125,7 +101,7 @@ For some reasons, you includes javascript files at bottom in your template, rail
|
|
125
101
|
<%= f.kindeditor :content, :window_onload => true %>
|
126
102
|
```
|
127
103
|
|
128
|
-
Warning: Kindeditor will load
|
104
|
+
Warning: Kindeditor will be load when the others have been loaded.
|
129
105
|
|
130
106
|
## SimpleForm and Formtastic integration
|
131
107
|
|
@@ -286,17 +262,17 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
|
|
286
262
|
### 安装Kindeditor,运行下面的代码:
|
287
263
|
|
288
264
|
```bash
|
289
|
-
rails
|
265
|
+
rails g rails_kindeditor:install
|
290
266
|
```
|
291
267
|
注意: 在你的工程中需要有application.js文件。
|
292
268
|
|
293
|
-
###
|
269
|
+
### Production mode
|
294
270
|
|
295
|
-
|
296
|
-
|
271
|
+
Precompiling assets不再自动从vendor/assets和lib/assets拷贝非JS/CSS文件. 参见 https://github.com/rails/rails/pull/7968
|
272
|
+
如果要使用生产模式,请运行'rails kindeditor:assets', 此方法可将kindeditor自动拷贝到你的public/assets目录.
|
297
273
|
|
298
274
|
```bash
|
299
|
-
|
275
|
+
rails kindeditor:assets
|
300
276
|
```
|
301
277
|
|
302
278
|
### 使用方法:
|
@@ -328,58 +304,32 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
|
|
328
304
|
|
329
305
|
完毕!
|
330
306
|
|
331
|
-
### 如何在
|
332
|
-
|
333
|
-
rails_kindeditor在turbolinks下不会正常加载,只有当页面刷新时才正常。turbolinks的机制就是这样的,页面根本没刷新,这和pjax是一样的,所以kindeditor没加载很正常。
|
307
|
+
### 如何在Turbolinks5下使用
|
334
308
|
|
335
|
-
|
336
|
-
|
337
|
-
1.在需要加载kindeditor的链接加入 'data-no-turbolink' => true ,此时相当在这个页面于关闭turbolinks。
|
338
|
-
|
339
|
-
```ruby
|
340
|
-
<%= link_to 'Edit', edit_article_path(article), 'data-no-turbolink' => true %>
|
341
|
-
```
|
342
|
-
|
343
|
-
2.在turbolinks载入完毕后手动加载kindeditor,不过所有参数都要设置,而且需要知道并设定textarea的id。
|
309
|
+
创建如下文件 app/assets/javascripts/load_kindeditor.coffee
|
344
310
|
|
345
311
|
```coffeescript
|
346
312
|
# coffeescript code
|
347
|
-
$(document).on '
|
348
|
-
|
349
|
-
|
313
|
+
$(document).on 'turbolinks:before-cache', ->
|
314
|
+
KindEditor.remove('.rails_kindeditor')
|
315
|
+
|
316
|
+
$(document).on 'turbolinks:load', ->
|
317
|
+
$('.rails_kindeditor').each ->
|
318
|
+
KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300'
|
350
319
|
```
|
351
320
|
|
352
|
-
|
321
|
+
简单编辑模式
|
353
322
|
```coffeescript
|
354
323
|
# coffeescript code
|
355
|
-
$(document).on '
|
356
|
-
|
357
|
-
KindEditor.create '#article_content',
|
358
|
-
"width":"100%",
|
359
|
-
"height":300,
|
360
|
-
"allowFileManager":true,
|
361
|
-
"uploadJson":"/kindeditor/upload",
|
362
|
-
"fileManagerJson":"/kindeditor/filemanager",
|
363
|
-
"items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
|
364
|
-
```
|
365
|
-
|
366
|
-
需要指定owner_id的方法:
|
324
|
+
$(document).on 'turbolinks:before-cache', ->
|
325
|
+
KindEditor.remove('.rails_kindeditor')
|
367
326
|
|
368
|
-
|
369
|
-
|
327
|
+
$(document).on 'turbolinks:load', ->
|
328
|
+
$('.rails_kindeditor').each ->
|
329
|
+
KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300', "items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
|
370
330
|
```
|
371
331
|
|
372
|
-
|
373
|
-
# coffeescript code
|
374
|
-
$(document).on 'page:load', ->
|
375
|
-
if $('#article_content').length > 0
|
376
|
-
KindEditor.create '#article_content',
|
377
|
-
"width" : "100%",
|
378
|
-
"height" : 300,
|
379
|
-
"allowFileManager" : true,
|
380
|
-
"uploadJson" : $('#article_content').data('upload'),
|
381
|
-
"fileManagerJson" : $('#article_content').data('filemanager')
|
382
|
-
```
|
332
|
+
请确保以上文件被app/assets/javascripts/application.js正确加载
|
383
333
|
|
384
334
|
### 把javascript放在模板最下方,不放在head里面,如何正确加载kindeditor?
|
385
335
|
|
@@ -3,6 +3,7 @@ module RailsKindeditor
|
|
3
3
|
def kindeditor_tag(name, content = nil, options = {})
|
4
4
|
id = sanitize_to_id(name)
|
5
5
|
input_html = { :id => id }.merge(options.delete(:input_html) || {})
|
6
|
+
input_html[:class] = "#{input_html[:class]} rails_kindeditor"
|
6
7
|
output = ActiveSupport::SafeBuffer.new
|
7
8
|
output << text_area_tag(name, content, input_html)
|
8
9
|
output << javascript_tag(js_replace(id, options))
|
@@ -18,6 +19,7 @@ module RailsKindeditor
|
|
18
19
|
|
19
20
|
def merge_assets_info(options)
|
20
21
|
owner = options.delete(:owner)
|
22
|
+
options[:class] = "#{options[:class]} rails_kindeditor"
|
21
23
|
if Kindeditor::AssetUploader.save_upload_info? && (!owner.nil?) && (!owner.id.nil?)
|
22
24
|
begin
|
23
25
|
owner_id = owner.id
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_kindeditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Macrow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -304,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
304
|
version: '0'
|
305
305
|
requirements: []
|
306
306
|
rubyforge_project: rails_kindeditor
|
307
|
-
rubygems_version: 2.
|
307
|
+
rubygems_version: 2.5.1
|
308
308
|
signing_key:
|
309
309
|
specification_version: 4
|
310
310
|
summary: Kindeditor for Ruby on Rails
|