activeadmin_froala_editor 0.2.4 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9749605f9f60196e6c2a7c5c4896dd542d0090d413efc70114005efa50756e8f
4
- data.tar.gz: 31dd928db47987a934d114c200f6956a182191a009c8ba8e270f197f8294ea13
3
+ metadata.gz: e66d66d41a835a90bea94e459269eda888b2827a79212ee15e8ad19599601505
4
+ data.tar.gz: 2d4e2b1d9298f6694641564cdd599f5b5297b9d81c9e3672505c1d8e68c87ce7
5
5
  SHA512:
6
- metadata.gz: '084f552b2767fd5266427a42ee7b480ff57ae7ab6115bea21603936e9d636e31f2557b6ea3e6cda1976803f88043822abbd7136290362676ab7555198cc07779'
7
- data.tar.gz: 0740ba637e5b9cf2bf7403423775243db8132afd8f9e148196c8f3454c5081bc1f36100e7d557349e3644ea08bbd2cfd4cd63fecdd3c6d13b0237b457eaf0aae
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
- ## Options
27
- **data-options**: permits to set *froala editor* options directly - see [options list](https://www.froala.com/wysiwyg-editor/docs/options)
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: for the relevant files of an upload example see [here](examples/upload_plugin_using_activestorage/).
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
- - The gem is available as open-source under the terms of the [MIT](LICENSE.txt)
69
- - For Froala editor License: see [Froala website](https://froala.com/wysiwyg-editor/)
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 initFroalaEditors() {
2
- $('.froala-editor').each(function () {
3
- if(!$(this).hasClass('froala-editor--active')) {
4
- var name = $(this).attr('name');
5
- if(name) {
6
- var options = {
7
- quickInsertButtons: ['table', 'ol', 'ul', 'hr'],
8
- requestHeaders: {
9
- 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
10
- },
11
- toolbarButtons: {
12
- moreText: {
13
- buttons: ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'textColor', 'backgroundColor', 'inlineClass', 'inlineStyle', 'clearFormatting'],
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
- moreMisc: {
28
- buttons: ['undo', 'redo', 'print'],
29
- align: 'right',
30
- buttonsVisible: 3
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
- options = $.extend({}, options, $(this).data('options'));
35
- new FroalaEditor('.froala-editor[name="' + name + '"]', options);
36
- $(this).addClass('froala-editor--active');
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
- $(document).on('has_many_add:after', function () {
43
- initFroalaEditors();
44
- });
46
+ // --- events ----------------------------------------------------------------
47
+ $(document).ready(() => {
48
+ initFroalaEditors()
49
+ })
45
50
 
46
- $(document).ready( function() {
47
- initFroalaEditors();
48
- });
51
+ $(document).on('has_many_add:after', '.has_many_container', () => {
52
+ initFroalaEditors()
53
+ })
54
+ })()
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module FroalaEditor
5
- VERSION = '0.2.4'
5
+ VERSION = '0.2.8'
6
6
  end
7
7
  end
@@ -4,7 +4,7 @@ module Formtastic
4
4
  module Inputs
5
5
  class FroalaEditorInput < Formtastic::Inputs::TextInput
6
6
  def input_html_options
7
- super.merge( class: 'froala-editor' )
7
+ super.merge('data-aa-froala-editor': '1')
8
8
  end
9
9
  end
10
10
  end
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
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-03 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin