effective_bootstrap 0.0.27 → 0.0.28
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/app/assets/javascripts/effective_editor/initialize.js.coffee +22 -5
- data/app/assets/javascripts/effective_editor/quill.js +1 -1
- data/app/assets/stylesheets/effective_editor/overrides.scss +13 -1
- data/app/helpers/effective_editor_helper.rb +9 -0
- data/app/models/effective/form_inputs/editor.rb +15 -5
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c86bfcfaf09f0b377e597a73666b33345fe4cbfb
|
4
|
+
data.tar.gz: 903be952705a11736f591a3cf7dacf78ed9a3979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba71de31350daf7d706034f2bf39837b893446573ab616be7ae962ef7e798901eeb0a72826da659dfc9e4bf79cacfa7a85557f05f24f184eaf22ff2ff9785efb
|
7
|
+
data.tar.gz: 4983d532de3560846fdb43667bf845feb0ec2aff2805e2cd384eb1734e6c100696cded837d112402172bee362d4eef1f6fdacaa9a2e56c80435d77345ccacc93
|
@@ -3,12 +3,29 @@
|
|
3
3
|
(this.EffectiveBootstrap || {}).effective_editor = ($element, options) ->
|
4
4
|
editor = '#' + $element.attr('id') + '_editor'
|
5
5
|
|
6
|
+
delta = options['delta']
|
7
|
+
delete options['delta']
|
8
|
+
|
6
9
|
quill = new Quill(editor, options)
|
7
|
-
|
10
|
+
content = $element.val() || ''
|
11
|
+
|
12
|
+
if content.length > 0
|
13
|
+
if content.startsWith('{') then quill.setContents(JSON.parse(content)) else quill.pasteHTML(content)
|
8
14
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
if delta
|
16
|
+
quill.on 'text-change', (delta, old, source) ->
|
17
|
+
$element.val(JSON.stringify(quill.getContents()))
|
18
|
+
else
|
19
|
+
quill.on 'text-change', (delta, old, source) ->
|
20
|
+
html = $(editor).children('.ql-editor').html()
|
21
|
+
html = '' if html == '<p><br></p>' || html == '<p></p>'
|
22
|
+
$element.val(html)
|
13
23
|
|
14
24
|
$element.on 'quill:focus', (event) -> quill.focus()
|
25
|
+
|
26
|
+
# This is the read only region. Always delta.
|
27
|
+
(this.EffectiveBootstrap || {}).effective_editor_tag = ($element, options) ->
|
28
|
+
quill = new Quill('#' + $element.attr('id'), options)
|
29
|
+
|
30
|
+
if $element.data('delta')
|
31
|
+
quill.setContents($element.data('delta'))
|
@@ -4162,7 +4162,7 @@ var Scroll = function (_Parchment$Scroll) {
|
|
4162
4162
|
}, {});
|
4163
4163
|
}
|
4164
4164
|
// Some reason fixes composition issues with character languages in Windows/Chrome, Safari
|
4165
|
-
// _this.domNode.addEventListener('DOMNodeInserted', function () {});
|
4165
|
+
// matt: _this.domNode.addEventListener('DOMNodeInserted', function () {});
|
4166
4166
|
_this.optimize();
|
4167
4167
|
_this.enable();
|
4168
4168
|
return _this;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.
|
1
|
+
.effective_editor { height: 0; width: 0; padding: 0; margin: 0; visibility: hidden; }
|
2
2
|
|
3
3
|
// Bootstrap 4 Feedback client side
|
4
4
|
.was-validated .form-control:invalid ~ .ql-container, { border-color: #dc3545; }
|
@@ -11,3 +11,15 @@
|
|
11
11
|
.form-control.is-invalid ~ .ql-toolbar { border-color: #dc3545; }
|
12
12
|
.form-control.is-valid ~ .ql-container { border-color: #28a745; }
|
13
13
|
.form-control.is-valid ~ .ql-toolbar { border-color: #28a745; }
|
14
|
+
|
15
|
+
.ql-effective.ql-container {
|
16
|
+
font-family: inherit;
|
17
|
+
font-size: inherit;
|
18
|
+
}
|
19
|
+
|
20
|
+
// Now for the editor itself
|
21
|
+
.effective_editor_content.ql-container {
|
22
|
+
border: none;
|
23
|
+
|
24
|
+
.ql-editor { padding: 0; }
|
25
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EffectiveEditorHelper
|
2
|
+
|
3
|
+
def effective_editor_tag(delta)
|
4
|
+
input_js = { method_name: 'effective_editor_tag', theme: 'snow', readOnly: true, modules: { toolbar: false } }
|
5
|
+
|
6
|
+
content_tag(:div, '', id: "ql-#{delta.object_id}", class: 'effective_editor_content ql-effective', data: { 'input-js-options': input_js, 'delta': delta.presence || '{}'})
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -10,23 +10,33 @@ module Effective
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def input_html_options
|
13
|
-
{ class: '
|
13
|
+
{ class: 'effective_editor form-control', id: unique_id }
|
14
14
|
end
|
15
15
|
|
16
16
|
def input_js_options
|
17
|
-
{ modules: { toolbar: toolbar }, theme: 'snow', placeholder: "Add #{name.to_s.pluralize}..." }
|
17
|
+
{ modules: { toolbar: toolbar }, theme: 'snow', placeholder: "Add #{name.to_s.pluralize}...", delta: delta? }
|
18
18
|
end
|
19
19
|
|
20
20
|
def toolbar
|
21
21
|
[
|
22
|
-
[{
|
22
|
+
[{'header': [1, 2, 3, 4, false] }],
|
23
23
|
['bold', 'italic', 'underline'],
|
24
24
|
['link', 'image', 'video', 'code-block'],
|
25
|
-
[{
|
26
|
-
[{
|
25
|
+
[{'list': 'ordered'}, { 'list': 'bullet' }],
|
26
|
+
[{'align': [] }, 'clean'],
|
27
27
|
]
|
28
28
|
end
|
29
29
|
|
30
|
+
def delta? # default false
|
31
|
+
return @delta unless @delta.nil?
|
32
|
+
|
33
|
+
if options.key?(:html)
|
34
|
+
@delta = (options.delete(:html) == false)
|
35
|
+
else
|
36
|
+
@delta = (options.delete(:delta) || false)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
30
40
|
end
|
31
41
|
end
|
32
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -421,6 +421,7 @@ files:
|
|
421
421
|
- app/assets/stylesheets/effective_select/select2.css
|
422
422
|
- app/assets/stylesheets/effective_time/input.scss
|
423
423
|
- app/helpers/effective_bootstrap_helper.rb
|
424
|
+
- app/helpers/effective_editor_helper.rb
|
424
425
|
- app/helpers/effective_form_builder_helper.rb
|
425
426
|
- app/helpers/effective_icons_helper.rb
|
426
427
|
- app/models/effective/access_denied.rb
|