activeadmin_quill_editor 0.2.10 → 0.3.4
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 +20 -7
- data/Rakefile +4 -1
- data/app/assets/javascripts/activeadmin/quill_editor_input.js +77 -77
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.scss +2 -1
- data/lib/activeadmin/quill_editor/version.rb +1 -1
- data/lib/formtastic/inputs/quill_editor_input.rb +2 -2
- metadata +49 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57830dc898984bfede040d03d6892506900a7ea931d7af281bb8580ba2a4177f
|
4
|
+
data.tar.gz: fdb6f426cda6f9d90e23dbb3afa4f95d618c6aff12e41e1213390b7588613ed8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|

|
6
6
|
|
7
7
|
## Install
|
8
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
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
|
-
|
90
|
-
|
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
|
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;
|
@@ -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(
|
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,
|
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.
|
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:
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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.
|
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
|
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
|
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.
|
224
|
+
rubygems_version: 3.1.4
|
197
225
|
signing_key:
|
198
226
|
specification_version: 4
|
199
227
|
summary: Quill Editor for ActiveAdmin
|