activeadmin_quill_editor 0.2.10 → 0.3.4

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: bf8cb33be21c875ee835f3e8b1fa4cb831ef0d46658122bb29aa0c6aba1d1a54
4
- data.tar.gz: 4ca4db51f40f7c091e6373214131a9352cc931563e77b161a8198a3ed0462361
3
+ metadata.gz: 57830dc898984bfede040d03d6892506900a7ea931d7af281bb8580ba2a4177f
4
+ data.tar.gz: fdb6f426cda6f9d90e23dbb3afa4f95d618c6aff12e41e1213390b7588613ed8
5
5
  SHA512:
6
- metadata.gz: b24f32b38c090be210d3d348db347c32daeb46fcdcb205b072d9b57095fbfd657f262f54754f001d46307d91ca9f1f784cd36c8b79ccc3ac89490f9b0d243d42
7
- data.tar.gz: 8ff0c6ddbc5b35da1642166c4d27d72cd2475ba2fba8592855088d2633e78dabe8972cf52b2272962c16104bb1f8114d297adf83bb13fb6b89198e9b4e68332c
6
+ metadata.gz: 35cb65aa5019a592b3c000aa94149cc101242cee56529a045af93826bfeb64f9db4ce2d22423a8e181c6866a5360c06b28db9ceffbb647a72685324ff784d116
7
+ data.tar.gz: c24d150941cb23118d55ce224dab457834d1d4408e252bf7fdcd4cdf5c6b94e50e08cada7a668f3dbd69a4daedf0db5c9723a10a1cadfc303190362eeb5916e7
data/README.md CHANGED
@@ -5,7 +5,10 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
5
5
  ![screenshot](screenshot.png)
6
6
 
7
7
  ## Install
8
- - After installing Active Admin, add to your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
8
+ After installing Active Admin, add to your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
9
+
10
+ If you installed Active Admin without Webpacker support (default for now):
11
+
9
12
  - Add at the end of your Active Admin styles (_app/assets/stylesheets/active_admin.scss_):
10
13
  ```scss
11
14
  @import 'activeadmin/quill_editor/quill.snow';
@@ -16,13 +19,23 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
16
19
  //= require activeadmin/quill_editor/quill
17
20
  //= require activeadmin/quill_editor_input
18
21
  ```
19
- - Use the input with `as: :quill_editor` in Active Admin model conf
20
-
21
- Why 2 separated scripts/styles? In this way you can include a different version of *quill editor* if you like.
22
22
 
23
23
  > **UPDATE FROM VERSION <= 2.0**: please add to your _app/assets/stylesheets/active_admin.scss_ the line `@import 'activeadmin/quill_editor/quill.snow';`
24
24
 
25
- ## Options
25
+ If you installed Active Admin with Webpacker support:
26
+
27
+ - Execute in your project root:
28
+ ```sh
29
+ yarn add blocknotes/activeadmin_quill_editor
30
+ ```
31
+ - Add to your *app/javascript/packs/active_admin.js*:
32
+ ```js
33
+ require('activeadmin_quill_editor')
34
+ ```
35
+
36
+ ## Usage
37
+ In your Active Admin models, form configuration, set the text inputs with `as: :quill_editor` where needed.
38
+
26
39
  **data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/configuration/)
27
40
 
28
41
  ## Examples
@@ -74,9 +87,9 @@ the *upload_admin_post_path*) and it doesn't provide a way to remove images (jus
74
87
  the editor will not destroy them, you'll need to implement a purge logic for that).
75
88
 
76
89
  ## Do you like it? Star it!
77
- If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
90
+ If you use this component just star it. A developer is more motivated to improve a project when there is some interest. My other [Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source).
78
91
 
79
- Take a look at [other Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) that I made if you are curious.
92
+ Or consider offering me a coffee, it's a small thing but it is greatly appreciated: [about me](https://www.blocknot.es/about-me).
80
93
 
81
94
  ## Contributors
82
95
  - [Mattia Roccoberton](http://blocknot.es): author
data/Rakefile CHANGED
@@ -5,7 +5,10 @@ require 'bundler/gem_tasks'
5
5
  begin
6
6
  require 'rspec/core/rake_task'
7
7
 
8
- RSpec::Core::RakeTask.new(:spec)
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ # t.ruby_opts = %w[-w]
10
+ t.rspec_opts = ['--color', '--format documentation']
11
+ end
9
12
 
10
13
  task default: :spec
11
14
  rescue LoadError
@@ -1,91 +1,91 @@
1
- // --- functions ---------------------------------------------------------------
2
- function initQuillEditors() {
3
- var default_theme = 'snow';
4
- var default_toolbar = [
5
- ['bold', 'italic', 'underline'],
6
- ['link', 'blockquote', 'code-block'],
7
- [{ 'script': 'sub'}, { 'script': 'super' }],
8
- [{ 'align': [] }, { list: 'ordered' }, { list: 'bullet' }],
9
- [{ 'color': [] }, { 'background': [] }],
10
- ['image'],
11
- ['clean'],
12
- ];
13
- var editors = document.querySelectorAll('.quill-editor');
14
- var registered_plugins = {};
1
+ (function () {
2
+ 'use strict'
15
3
 
16
- for(var i = 0; i < editors.length; i++) {
17
- var content = editors[i].querySelector('.quill-editor-content');
18
- var isActive = editors[i].classList.contains('quill-editor--active');
19
- if(content && !isActive) {
20
- // Setup editor options
21
- var options = editors[i].getAttribute('data-options') ? JSON.parse(editors[i].getAttribute('data-options')) : {};
22
- if(!options.theme) options.theme = default_theme;
23
- if(!options.modules) options.modules = {};
24
- if(!options.modules.toolbar) options.modules.toolbar = default_toolbar;
4
+ // --- functions ---------------------------------------------------------------
5
+ function initQuillEditors() {
6
+ let default_theme = 'snow'
7
+ let default_toolbar = [
8
+ ['bold', 'italic', 'underline'],
9
+ ['link', 'blockquote', 'code-block'],
10
+ [{ 'script': 'sub' }, { 'script': 'super' }],
11
+ [{ 'align': [] }, { list: 'ordered' }, { list: 'bullet' }],
12
+ [{ 'color': [] }, { 'background': [] }],
13
+ ['image'],
14
+ ['clean'],
15
+ ]
16
+ let editors = document.querySelectorAll('[data-aa-quill-editor]')
17
+ let registered_plugins = {}
25
18
 
26
- // Setup plugin options
27
- var plugin_options = editors[i].getAttribute('data-plugins') ? JSON.parse(editors[i].getAttribute('data-plugins')) : {};
28
- if(plugin_options.image_uploader && plugin_options.image_uploader.server_url) {
29
- if(!registered_plugins.image_uploader) {
30
- Quill.register('modules/imageUploader', ImageUploader);
31
- registered_plugins.image_uploader = true;
19
+ for (let i = 0; i < editors.length; i++) {
20
+ let content = editors[i].querySelector('[data-aa-quill-content]')
21
+ let isActive = editors[i].classList.contains('quill-editor--active')
22
+ if (content && !isActive) {
23
+ // Setup editor options
24
+ let options = editors[i].getAttribute('data-options') ? JSON.parse(editors[i].getAttribute('data-options')) : {}
25
+ if (!options.theme) options.theme = default_theme
26
+ if (!options.modules) options.modules = {}
27
+ if (!options.modules.toolbar) options.modules.toolbar = default_toolbar
28
+
29
+ // Setup plugin options
30
+ let plugin_options = editors[i].getAttribute('data-plugins') ? JSON.parse(editors[i].getAttribute('data-plugins')) : {}
31
+ if (plugin_options.image_uploader && plugin_options.image_uploader.server_url) {
32
+ if (!registered_plugins.image_uploader) {
33
+ Quill.register('modules/imageUploader', ImageUploader)
34
+ registered_plugins.image_uploader = true
35
+ }
36
+ let opts = plugin_options.image_uploader
37
+ options.modules.imageUploader = setupImageUploader(opts.server_url, opts.field_name)
32
38
  }
33
- var opts = plugin_options.image_uploader;
34
- options.modules.imageUploader = setupImageUploader(opts.server_url, opts.field_name);
35
- }
36
39
 
37
- // Init editor
38
- editors[i]['_quill-editor'] = new Quill(content, options);
39
- editors[i].classList += ' quill-editor--active';
40
+ // Init editor
41
+ editors[i]['_quill-editor'] = new Quill(content, options)
42
+ editors[i].classList += ' quill-editor--active'
43
+ }
40
44
  }
41
- }
42
45
 
43
- var formtastic = document.querySelector('form.formtastic');
44
- if(formtastic) {
45
- formtastic.onsubmit = function() {
46
- for(var i = 0; i < editors.length; i++) {
47
- var input = editors[i].querySelector('input[type="hidden"]');
48
- if (editors[i]['_quill-editor'].editor.isBlank()) {
49
- input.value = '';
50
- } else {
51
- input.value = editors[i]['_quill-editor'].root.innerHTML;
46
+ let formtastic = document.querySelector('form.formtastic')
47
+ if (formtastic) {
48
+ formtastic.onsubmit = () => {
49
+ for (let i = 0; i < editors.length; i++) {
50
+ let input = editors[i].querySelector('input[type="hidden"]')
51
+ if (editors[i]['_quill-editor'].editor.isBlank()) {
52
+ input.value = ''
53
+ } else {
54
+ input.value = editors[i]['_quill-editor'].root.innerHTML
55
+ }
52
56
  }
53
- }
54
- };
57
+ };
58
+ }
55
59
  }
56
- }
57
60
 
58
- function setupImageUploader(server_url, field_name) {
59
- return {
60
- upload: file => {
61
- return new Promise((resolve, reject) => {
62
- const formData = new FormData();
63
- formData.append(field_name || 'file_upload', file);
61
+ function setupImageUploader(server_url, field_name) {
62
+ return {
63
+ upload: file => {
64
+ return new Promise((resolve, reject) => {
65
+ const formData = new FormData()
66
+ formData.append(field_name || 'file_upload', file)
64
67
 
65
- fetch(server_url, {
66
- body: formData,
67
- headers: {
68
- 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
69
- },
70
- method: 'POST'
71
- }).then(response => response.json())
72
- .then(result => {
73
- resolve(result.url);
68
+ fetch(server_url, {
69
+ body: formData,
70
+ headers: {
71
+ 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
72
+ },
73
+ method: 'POST'
74
+ }).then(response => response.json())
75
+ .then(result => {
76
+ resolve(result.url);
77
+ })
78
+ .catch(error => {
79
+ reject('Upload failed')
80
+ console.error('Error: ', error)
81
+ })
74
82
  })
75
- .catch(error => {
76
- reject('Upload failed');
77
- console.error('Error: ', error);
78
- });
79
- });
83
+ }
80
84
  }
81
85
  }
82
- }
83
-
84
- // --- events ------------------------------------------------------------------
85
- $(document).ready( function() {
86
- initQuillEditors();
87
- });
88
86
 
89
- $(document).on('has_many_add:after', function() {
90
- initQuillEditors();
91
- });
87
+ // --- events ------------------------------------------------------------------
88
+ $(document).ready(initQuillEditors)
89
+ $(document).on('has_many_add:after', '.has_many_container', initQuillEditors)
90
+ $(document).on('turbolinks:load', initQuillEditors)
91
+ })()
@@ -5,7 +5,7 @@
5
5
  text-align: initial;
6
6
  }
7
7
 
8
- body.active_admin .quill-editor {
8
+ body.active_admin [data-aa-quill-editor] {
9
9
  display: inline-block;
10
10
  width: calc(80% - 2px);
11
11
 
@@ -29,6 +29,7 @@ body.active_admin .quill-editor {
29
29
  max-height: 300px;
30
30
  min-height: 150px;
31
31
  padding: 10px;
32
+ word-break: break-all;
32
33
 
33
34
  ol {
34
35
  list-style-type: decimal;
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module QuillEditor
5
- VERSION = '0.2.10'
5
+ VERSION = '0.3.4'
6
6
  end
7
7
  end
@@ -6,9 +6,9 @@ module Formtastic
6
6
  def to_html
7
7
  input_wrapping do
8
8
  label_html <<
9
- template.content_tag(:div, input_html_options.merge(class: 'quill-editor')) do
9
+ template.content_tag(:div, input_html_options.merge('data-aa-quill-editor': '1')) do
10
10
  builder.hidden_field(input_name) <<
11
- template.content_tag(:div, class: 'quill-editor-content') do
11
+ template.content_tag(:div, 'data-aa-quill-content': '1') do
12
12
  object.send(method).try :html_safe
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_quill_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.4
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-05 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -30,126 +30,154 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.3.2
33
+ version: '6.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.0.3.2
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: capybara
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.33.0
47
+ version: '3.33'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.33.0
54
+ version: '3.33'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.13.1
61
+ version: '0.13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.13.1
68
+ version: '0.13'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: puma
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 4.3.5
75
+ version: '4.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 4.3.5
82
+ version: '4.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec_junit_formatter
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.4.1
89
+ version: '0.4'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.4.1
96
+ version: '0.4'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 4.0.1
103
+ version: '4.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 4.0.1
110
+ version: '4.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.90.0
117
+ version: '0.90'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.90.0
124
+ version: '0.90'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sassc
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.4'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: selenium-webdriver
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 3.142.7
145
+ version: '3.142'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.142'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sprockets-rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.2'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: 3.142.7
166
+ version: '3.2'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: sqlite3
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - "~>"
144
172
  - !ruby/object:Gem::Version
145
- version: 1.4.2
173
+ version: '1.4'
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
178
  - - "~>"
151
179
  - !ruby/object:Gem::Version
152
- version: 1.4.2
180
+ version: '1.4'
153
181
  description: An Active Admin plugin to use Quill Rich Text Editor
154
182
  email: mat@blocknot.es
155
183
  executables: []
@@ -193,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
221
  - !ruby/object:Gem::Version
194
222
  version: '0'
195
223
  requirements: []
196
- rubygems_version: 3.0.3
224
+ rubygems_version: 3.1.4
197
225
  signing_key:
198
226
  specification_version: 4
199
227
  summary: Quill Editor for ActiveAdmin