activeadmin_froala_editor 0.2.4 → 0.2.8
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e66d66d41a835a90bea94e459269eda888b2827a79212ee15e8ad19599601505
|
4
|
+
data.tar.gz: 2d4e2b1d9298f6694641564cdd599f5b5297b9d81c9e3672505c1d8e68c87ce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb69003f8ed110ed582d1a44b27e8d97b72d04bc1fb1fd1989fb8d86ddbcaaeccdc6ad83ce3d2106c5a3d3081d3bf8f9db9e560c3af50125db104319d8ce1a9
|
7
|
+
data.tar.gz: 48a278d486e936ea5e8a11b8bc68ea3625a8083b0cc49582b4f19d4abe08f38ec2a4e6d656b805db5f52259b47412a8ad2b935f72b79f1c422ea6521b07764a2
|
data/README.md
CHANGED
@@ -23,11 +23,14 @@ Features:
|
|
23
23
|
```
|
24
24
|
- Use the input with `as: :froala_editor` in Active Admin model conf
|
25
25
|
|
26
|
-
##
|
27
|
-
|
26
|
+
## Notes
|
27
|
+
- To use this plugins with Active Admin 1.x please use the version [0.1.3](https://github.com/blocknotes/activeadmin_froala_editor/releases/tag/v0.1.3)
|
28
|
+
- **data-options**: permits to set *froala editor* options directly from the form field (examples below) - see [options list](https://www.froala.com/wysiwyg-editor/docs/options)
|
28
29
|
|
29
30
|
## Examples
|
30
31
|
|
32
|
+
### Basic usage
|
33
|
+
|
31
34
|
```ruby
|
32
35
|
# Active Admin article form conf:
|
33
36
|
form do |f|
|
@@ -40,21 +43,35 @@ Features:
|
|
40
43
|
end
|
41
44
|
```
|
42
45
|
|
43
|
-
Toolbar buttons configuration
|
46
|
+
### Toolbar buttons configuration
|
44
47
|
|
45
48
|
```ruby
|
49
|
+
# Form field
|
46
50
|
f.input :description, as: :froala_editor, input_html: { data: { options: { toolbarButtons: ['undo', 'redo', '|', 'bold', 'italic'] } } }
|
47
51
|
```
|
48
52
|
|
49
|
-
Froala upload plugin
|
53
|
+
### Froala upload plugin
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# Upload method (to be included in the admin entity configuration)
|
57
|
+
member_action :upload, method: [:post] do
|
58
|
+
success = resource.images.attach(params[:file_upload])
|
59
|
+
result = success ? { link: url_for(resource.images.last) } : {}
|
60
|
+
render json: result
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
# Form field
|
66
|
+
f.input :description, as: :froala_editor, input_html: { data: { options: { imageUploadParam: 'file_upload', imageUploadURL: upload_admin_post_path(resource.id), toolbarButtons: %w[bold italic underline | insertImage insertVideo insertFile] } } }
|
67
|
+
```
|
68
|
+
|
69
|
+
For the relevant files of an upload example see [here](examples/upload_plugin_using_activestorage/).
|
50
70
|
Consider that this is just a basic example: images are uploaded as soon as they are attached to the
|
51
71
|
editor (regardless of the form submit), it shows the editor only for an existing record (because of
|
52
72
|
the *upload_admin_post_path*) and it doesn't provide a way to remove images (just deleting them from
|
53
73
|
the editor will not destroy them, you'll need to implement a purge logic for that).
|
54
74
|
|
55
|
-
## Notes
|
56
|
-
- To use this plugins with Active Admin 1.x please use the version [0.1.3](https://github.com/blocknotes/activeadmin_froala_editor/releases/tag/v0.1.3)
|
57
|
-
|
58
75
|
## Do you like it? Star it!
|
59
76
|
If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
|
60
77
|
|
@@ -65,5 +82,6 @@ Take a look at [other Active Admin components](https://github.com/blocknotes?utf
|
|
65
82
|
- The good guys that opened issues and pull requests from time to time
|
66
83
|
|
67
84
|
## License
|
68
|
-
|
69
|
-
|
85
|
+
The gem is available as open-source under the terms of the [MIT](LICENSE.txt).
|
86
|
+
|
87
|
+
For Froala editor License: see [Froala website](https://froala.com/wysiwyg-editor/).
|
@@ -1,48 +1,54 @@
|
|
1
|
-
function
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
align: 'left',
|
15
|
-
buttonsVisible: 3
|
16
|
-
},
|
17
|
-
moreParagraph: {
|
18
|
-
buttons: ['alignLeft', 'alignCenter', 'formatOLSimple', 'alignRight', 'alignJustify', 'formatOL', 'formatUL', 'paragraphFormat', 'paragraphStyle', 'lineHeight', 'outdent', 'indent', 'quote'],
|
19
|
-
align: 'left',
|
20
|
-
buttonsVisible: 3
|
21
|
-
},
|
22
|
-
moreRich: {
|
23
|
-
buttons: ['insertLink', 'insertTable', 'emoticons', 'specialCharacters', 'insertHR'],
|
24
|
-
align: 'left',
|
25
|
-
buttonsVisible: 2
|
1
|
+
(function () {
|
2
|
+
'use strict'
|
3
|
+
|
4
|
+
// --- functions -------------------------------------------------------------
|
5
|
+
function initFroalaEditors() {
|
6
|
+
$('[data-aa-froala-editor]').each(function () {
|
7
|
+
if (!$(this).hasClass('froala-editor--active')) {
|
8
|
+
let name = $(this).attr('name');
|
9
|
+
if (name) {
|
10
|
+
let options = {
|
11
|
+
quickInsertButtons: ['table', 'ol', 'ul', 'hr'],
|
12
|
+
requestHeaders: {
|
13
|
+
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
26
14
|
},
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
15
|
+
toolbarButtons: {
|
16
|
+
moreText: {
|
17
|
+
buttons: ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'textColor', 'backgroundColor', 'inlineClass', 'inlineStyle', 'clearFormatting'],
|
18
|
+
align: 'left',
|
19
|
+
buttonsVisible: 3
|
20
|
+
},
|
21
|
+
moreParagraph: {
|
22
|
+
buttons: ['alignLeft', 'alignCenter', 'formatOLSimple', 'alignRight', 'alignJustify', 'formatOL', 'formatUL', 'paragraphFormat', 'paragraphStyle', 'lineHeight', 'outdent', 'indent', 'quote'],
|
23
|
+
align: 'left',
|
24
|
+
buttonsVisible: 3
|
25
|
+
},
|
26
|
+
moreRich: {
|
27
|
+
buttons: ['insertLink', 'insertTable', 'emoticons', 'specialCharacters', 'insertHR'],
|
28
|
+
align: 'left',
|
29
|
+
buttonsVisible: 2
|
30
|
+
},
|
31
|
+
moreMisc: {
|
32
|
+
buttons: ['undo', 'redo', 'print'],
|
33
|
+
align: 'right',
|
34
|
+
buttonsVisible: 3
|
35
|
+
}
|
31
36
|
}
|
32
37
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
options = $.extend({}, options, $(this).data('options'))
|
39
|
+
new FroalaEditor('[data-aa-froala-editor][name="' + name + '"]', options)
|
40
|
+
$(this).addClass('froala-editor--active')
|
41
|
+
}
|
37
42
|
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
43
|
+
})
|
44
|
+
}
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
// --- events ----------------------------------------------------------------
|
47
|
+
$(document).ready(() => {
|
48
|
+
initFroalaEditors()
|
49
|
+
})
|
45
50
|
|
46
|
-
$(document).
|
47
|
-
|
48
|
-
})
|
51
|
+
$(document).on('has_many_add:after', '.has_many_container', () => {
|
52
|
+
initFroalaEditors()
|
53
|
+
})
|
54
|
+
})()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_froala_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|