activeadmin_quill_editor 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +73 -19
- data/Rakefile +13 -0
- data/app/assets/javascripts/activeadmin/quill.imageUploader.min.js +1 -0
- data/app/assets/javascripts/activeadmin/quill_editor/quill.core.js +81 -9
- data/app/assets/javascripts/activeadmin/quill_editor/quill.js +83 -10
- data/app/assets/javascripts/activeadmin/quill_editor/quill.min.js +2 -2
- data/app/assets/javascripts/activeadmin/quill_editor_input.js +86 -40
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.scss +56 -0
- data/app/assets/stylesheets/activeadmin/quill.imageUploader.min.css +33 -0
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.bubble.css +1 -1
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.core.css +1 -1
- data/app/assets/stylesheets/activeadmin/quill_editor/quill.snow.css +1 -1
- data/lib/activeadmin/quill_editor/version.rb +2 -1
- data/lib/formtastic/inputs/quill_editor_input.rb +2 -2
- metadata +33 -18
- data/.gitignore +0 -3
- data/.rubocop.yml +0 -73
- data/Gemfile +0 -3
- data/activeadmin_quill_editor.gemspec +0 -21
- data/app/assets/stylesheets/activeadmin/_quill_editor_input.sass +0 -24
- data/screenshot.jpg +0 -0
@@ -1,45 +1,91 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
(function () {
|
2
|
+
'use strict'
|
3
|
+
|
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 = {}
|
18
|
+
|
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)
|
38
|
+
}
|
39
|
+
|
40
|
+
// Init editor
|
41
|
+
editors[i]['_quill-editor'] = new Quill(content, options)
|
42
|
+
editors[i].classList += ' quill-editor--active'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
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
|
+
}
|
56
|
+
}
|
57
|
+
};
|
33
58
|
}
|
34
59
|
}
|
35
60
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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)
|
67
|
+
|
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
|
+
})
|
82
|
+
})
|
42
83
|
}
|
43
|
-
}
|
84
|
+
}
|
44
85
|
}
|
45
|
-
|
86
|
+
|
87
|
+
// --- events ------------------------------------------------------------------
|
88
|
+
$(document).ready(initQuillEditors)
|
89
|
+
$(document).on('has_many_add:after', '.has_many_container', initQuillEditors)
|
90
|
+
$(document).on('turbolinks:load', initQuillEditors)
|
91
|
+
})()
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// reset internal elements
|
2
|
+
.ql-editor * {
|
3
|
+
margin: initial;
|
4
|
+
padding: initial;
|
5
|
+
text-align: initial;
|
6
|
+
}
|
7
|
+
|
8
|
+
body.active_admin [data-aa-quill-editor] {
|
9
|
+
display: inline-block;
|
10
|
+
width: calc(80% - 2px);
|
11
|
+
|
12
|
+
button {
|
13
|
+
text-shadow: none;
|
14
|
+
box-shadow: none;
|
15
|
+
|
16
|
+
&:hover {
|
17
|
+
background-image: none;
|
18
|
+
background-color: transparent;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
.ql-container {
|
23
|
+
border: 1px solid #c9d0d6;
|
24
|
+
border-radius: 0 0 3px 3px;
|
25
|
+
}
|
26
|
+
|
27
|
+
.ql-editor {
|
28
|
+
background-color: #fff;
|
29
|
+
max-height: 300px;
|
30
|
+
min-height: 150px;
|
31
|
+
padding: 10px;
|
32
|
+
word-break: break-all;
|
33
|
+
|
34
|
+
ol {
|
35
|
+
list-style-type: decimal;
|
36
|
+
}
|
37
|
+
|
38
|
+
p {
|
39
|
+
margin-bottom: 1em;
|
40
|
+
}
|
41
|
+
|
42
|
+
ul {
|
43
|
+
list-style-type: disc;
|
44
|
+
}
|
45
|
+
|
46
|
+
ul, ol {
|
47
|
+
margin: 0 1.5em 1.5em 0;
|
48
|
+
padding-left: 1.5em;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
.ql-toolbar {
|
53
|
+
border: 1px solid #c9d0d6;
|
54
|
+
border-radius: 3px 3px 0 0;
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
.image-uploading {
|
2
|
+
position: relative;
|
3
|
+
display: inline-block;
|
4
|
+
}
|
5
|
+
|
6
|
+
.image-uploading img {
|
7
|
+
max-width: 98% !important;
|
8
|
+
filter: blur(5px);
|
9
|
+
opacity: 0.3;
|
10
|
+
}
|
11
|
+
|
12
|
+
.image-uploading::before {
|
13
|
+
content: "";
|
14
|
+
box-sizing: border-box;
|
15
|
+
position: absolute;
|
16
|
+
top: 50%;
|
17
|
+
left: 50%;
|
18
|
+
width: 30px;
|
19
|
+
height: 30px;
|
20
|
+
margin-top: -15px;
|
21
|
+
margin-left: -15px;
|
22
|
+
border-radius: 50%;
|
23
|
+
border: 3px solid #ccc;
|
24
|
+
border-top-color: #1e986c;
|
25
|
+
z-index: 1;
|
26
|
+
animation: spinner 0.6s linear infinite;
|
27
|
+
}
|
28
|
+
|
29
|
+
@keyframes spinner {
|
30
|
+
to {
|
31
|
+
transform: rotate(360deg);
|
32
|
+
}
|
33
|
+
}
|
@@ -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,47 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_quill_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.4'
|
27
41
|
description: An Active Admin plugin to use Quill Rich Text Editor
|
28
42
|
email: mat@blocknot.es
|
29
43
|
executables: []
|
30
44
|
extensions: []
|
31
45
|
extra_rdoc_files: []
|
32
46
|
files:
|
33
|
-
- ".gitignore"
|
34
|
-
- ".rubocop.yml"
|
35
|
-
- Gemfile
|
36
47
|
- LICENSE.txt
|
37
48
|
- README.md
|
38
49
|
- Rakefile
|
39
|
-
-
|
50
|
+
- app/assets/javascripts/activeadmin/quill.imageUploader.min.js
|
40
51
|
- app/assets/javascripts/activeadmin/quill_editor/quill.core.js
|
41
52
|
- app/assets/javascripts/activeadmin/quill_editor/quill.js
|
42
53
|
- app/assets/javascripts/activeadmin/quill_editor/quill.min.js
|
43
54
|
- app/assets/javascripts/activeadmin/quill_editor_input.js
|
44
|
-
- app/assets/stylesheets/activeadmin/_quill_editor_input.
|
55
|
+
- app/assets/stylesheets/activeadmin/_quill_editor_input.scss
|
56
|
+
- app/assets/stylesheets/activeadmin/quill.imageUploader.min.css
|
45
57
|
- app/assets/stylesheets/activeadmin/quill_editor/quill.bubble.css
|
46
58
|
- app/assets/stylesheets/activeadmin/quill_editor/quill.core.css
|
47
59
|
- app/assets/stylesheets/activeadmin/quill_editor/quill.snow.css
|
@@ -50,12 +62,15 @@ files:
|
|
50
62
|
- lib/activeadmin/quill_editor/version.rb
|
51
63
|
- lib/activeadmin_quill_editor.rb
|
52
64
|
- lib/formtastic/inputs/quill_editor_input.rb
|
53
|
-
- screenshot.jpg
|
54
65
|
homepage: https://github.com/blocknotes/activeadmin_quill_editor
|
55
66
|
licenses:
|
56
67
|
- MIT
|
57
|
-
metadata:
|
58
|
-
|
68
|
+
metadata:
|
69
|
+
homepage_uri: https://github.com/blocknotes/activeadmin_quill_editor
|
70
|
+
changelog_uri: https://github.com/blocknotes/activeadmin_quill_editor/blob/master/CHANGELOG.md
|
71
|
+
source_code_uri: https://github.com/blocknotes/activeadmin_quill_editor
|
72
|
+
rubygems_mfa_required: 'true'
|
73
|
+
post_install_message:
|
59
74
|
rdoc_options: []
|
60
75
|
require_paths:
|
61
76
|
- lib
|
@@ -63,15 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
78
|
requirements:
|
64
79
|
- - ">="
|
65
80
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
81
|
+
version: 2.6.0
|
67
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
83
|
requirements:
|
69
84
|
- - ">="
|
70
85
|
- !ruby/object:Gem::Version
|
71
86
|
version: '0'
|
72
87
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
74
|
-
signing_key:
|
88
|
+
rubygems_version: 3.1.6
|
89
|
+
signing_key:
|
75
90
|
specification_version: 4
|
76
91
|
summary: Quill Editor for ActiveAdmin
|
77
92
|
test_files: []
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-rspec
|
3
|
-
|
4
|
-
Rails:
|
5
|
-
Enabled: true
|
6
|
-
|
7
|
-
AllCops:
|
8
|
-
TargetRubyVersion: 2.3.8
|
9
|
-
TargetRailsVersion: 5.2
|
10
|
-
Exclude:
|
11
|
-
- db/schema.rb
|
12
|
-
- bin/*
|
13
|
-
- node_modules/**/*
|
14
|
-
# Temporary files
|
15
|
-
- tmp/**/*
|
16
|
-
|
17
|
-
Rails/InverseOf:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Style/Documentation:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Metrics/ClassLength:
|
24
|
-
# Default value is 100
|
25
|
-
Max: 150
|
26
|
-
|
27
|
-
Metrics/LineLength:
|
28
|
-
# Default is 80
|
29
|
-
Max: 120
|
30
|
-
|
31
|
-
Metrics/ModuleLength:
|
32
|
-
# Default is 100
|
33
|
-
Max: 150
|
34
|
-
|
35
|
-
Metrics/ParameterLists:
|
36
|
-
# Default is 5
|
37
|
-
Max: 6
|
38
|
-
|
39
|
-
RSpec/ExampleLength:
|
40
|
-
# Default is 10
|
41
|
-
Max: 20
|
42
|
-
|
43
|
-
Style/FrozenStringLiteralComment:
|
44
|
-
# Deface DOES edit strings in place
|
45
|
-
Exclude:
|
46
|
-
- 'app/overrides/**/*'
|
47
|
-
|
48
|
-
RSpec/MultipleExpectations:
|
49
|
-
# Default is 3
|
50
|
-
Max: 5
|
51
|
-
|
52
|
-
RSpec/NestedGroups:
|
53
|
-
# Default is 3
|
54
|
-
Max: 6
|
55
|
-
|
56
|
-
Metrics/AbcSize:
|
57
|
-
Max: 25
|
58
|
-
|
59
|
-
Metrics/BlockLength:
|
60
|
-
# This value double the rubocop default
|
61
|
-
Max: 50
|
62
|
-
|
63
|
-
Metrics/CyclomaticComplexity:
|
64
|
-
# This value double the rubocop default
|
65
|
-
Max: 12
|
66
|
-
|
67
|
-
Metrics/MethodLength:
|
68
|
-
# This value double the rubocop default
|
69
|
-
Max: 20
|
70
|
-
|
71
|
-
Metrics/PerceivedComplexity:
|
72
|
-
# Default is 7
|
73
|
-
Max: 10
|
data/Gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'activeadmin/quill_editor/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = 'activeadmin_quill_editor'
|
9
|
-
spec.version = ActiveAdmin::QuillEditor::VERSION
|
10
|
-
spec.summary = 'Quill Editor for ActiveAdmin'
|
11
|
-
spec.description = 'An Active Admin plugin to use Quill Rich Text Editor'
|
12
|
-
spec.license = 'MIT'
|
13
|
-
spec.authors = ['Mattia Roccoberton']
|
14
|
-
spec.email = 'mat@blocknot.es'
|
15
|
-
spec.homepage = 'https://github.com/blocknotes/activeadmin_quill_editor'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.require_paths = ['lib']
|
19
|
-
|
20
|
-
spec.add_runtime_dependency 'activeadmin', '>= 1.0'
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
@import 'activeadmin/quill_editor/quill.snow'
|
2
|
-
|
3
|
-
body.active_admin form .quill-editor
|
4
|
-
display: inline-block
|
5
|
-
width: calc(80% - 22px)
|
6
|
-
.ql-editor
|
7
|
-
background-color: #fff
|
8
|
-
max-height: 300px
|
9
|
-
min-height: 150px
|
10
|
-
padding: 10px
|
11
|
-
// reset internal elements
|
12
|
-
*
|
13
|
-
margin: initial
|
14
|
-
padding: initial
|
15
|
-
text-align: initial
|
16
|
-
p
|
17
|
-
margin-bottom: 1em
|
18
|
-
ol
|
19
|
-
list-style-type: decimal
|
20
|
-
ul
|
21
|
-
list-style-type: disc
|
22
|
-
ul, ol
|
23
|
-
margin: 0 1.5em 1.5em 0
|
24
|
-
padding-left: 1.5em
|
data/screenshot.jpg
DELETED
Binary file
|