4 Коммитов
aa2 ... v0.2.0

Автор SHA1 Сообщение Дата
Mattia Roccoberton
9ecfceaa9a 🎉 Support ActiveAdmin 2.x and code style improvements
- Add support ActiveAdmin for 2.x
- Add rubocop config
- Add frozen_string_literal to ruby files
- Apply changes to respect rubocop alerts
2019-06-15 19:55:45 +02:00
Mattia Roccoberton
598b2d75cf Merge pull request #6 from seanfcarroll/patch-1
Correct Quill options list link
2018-11-24 17:37:57 +01:00
Sean
54026744c4 Correct Quill options list link 2018-11-16 13:39:41 +01:00
mat@blocknot.es
5d35feedd8 v0.1.4: PR4 + Quill Editor 1.3.6 2018-11-03 18:44:54 +01:00
12 изменённых файлов: 108 добавлений и 28 удалений

73
.rubocop.yml Обычный файл
Просмотреть файл

@@ -0,0 +1,73 @@
require:
- rubocop-rspec
Rails:
Enabled: true
AllCops:
TargetRubyVersion: 2.3.8
TargetRailsVersion: 5.2
Exclude:
- db/schema.rb
- bin/*
- node_modules/**/*
# Temporary files
- tmp/**/*
Rails/InverseOf:
Enabled: false
Style/Documentation:
Enabled: false
Metrics/ClassLength:
# Default value is 100
Max: 150
Metrics/LineLength:
# Default is 80
Max: 120
Metrics/ModuleLength:
# Default is 100
Max: 150
Metrics/ParameterLists:
# Default is 5
Max: 6
RSpec/ExampleLength:
# Default is 10
Max: 20
Style/FrozenStringLiteralComment:
# Deface DOES edit strings in place
Exclude:
- 'app/overrides/**/*'
RSpec/MultipleExpectations:
# Default is 3
Max: 5
RSpec/NestedGroups:
# Default is 3
Max: 6
Metrics/AbcSize:
Max: 25
Metrics/BlockLength:
# This value double the rubocop default
Max: 50
Metrics/CyclomaticComplexity:
# This value double the rubocop default
Max: 12
Metrics/MethodLength:
# This value double the rubocop default
Max: 20
Metrics/PerceivedComplexity:
# Default is 7
Max: 10

Просмотреть файл

@@ -1,4 +1,3 @@
source 'https://rubygems.org'
gemspec

Просмотреть файл

@@ -22,7 +22,7 @@ Why 2 separated scripts? In this way you can include a different version of *qui
## Options
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/quickstart/)
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/configuration/)
## Examples

Просмотреть файл

@@ -1,3 +1,3 @@
# encoding: utf-8
# frozen_string_literal: true
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

Просмотреть файл

@@ -1,4 +1,6 @@
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'activeadmin/quill_editor/version'
@@ -15,5 +17,5 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files -z`.split("\x0")
spec.require_paths = ['lib']
spec.add_runtime_dependency 'activeadmin', '2.0.0.alpha' # '~> 1.0'
spec.add_runtime_dependency 'activeadmin', '>= 1.0'
end

Просмотреть файл

@@ -1,4 +1,4 @@
window.onload = function () {
window.onload = function() {
initQuillEditors();
}
@@ -7,7 +7,7 @@ $(document).on('has_many_add:after', function() {
});
var initQuillEditors = function() {
var editors = document.querySelectorAll( '.quill-editor' );
var editors = document.querySelectorAll('.quill-editor');
var default_options = {
modules: {
toolbar: [
@@ -17,32 +17,28 @@ var initQuillEditors = function() {
[{ 'align': [] }, { list: 'ordered' }, { list: 'bullet' }],
[{ 'color': [] }, { 'background': [] }],
['clean'],
// [{ 'size': ['small', false, 'large', 'huge'] }],
// [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
]
},
placeholder: '',
theme: 'snow'
};
for( var i = 0; i < editors.length; i++ ) {
var content = editors[i].querySelector( '.quill-editor-content' );
for(var i = 0; i < editors.length; i++) {
var content = editors[i].querySelector('.quill-editor-content');
var isActive = editors[i].classList.contains('quill-editor--active');
if( content && !isActive) {
var options = editors[i].getAttribute( 'data-options' ) ? JSON.parse( editors[i].getAttribute( 'data-options' ) ) : default_options;
editors[i]['_quill-editor'] = new Quill( content, options );
if(content && !isActive) {
var options = editors[i].getAttribute('data-options') ? JSON.parse(editors[i].getAttribute('data-options')) : default_options;
editors[i]['_quill-editor'] = new Quill(content, options);
editors[i].classList += ' quill-editor--active';
}
}
var formtastic = document.querySelector( 'form.formtastic' );
if( formtastic ) {
var formtastic = document.querySelector('form.formtastic');
if(formtastic) {
formtastic.onsubmit = function() {
for( var i = 0; i < editors.length; i++ ) {
var input = editors[i].querySelector( 'input[type="hidden"]' );
for(var i = 0; i < editors.length; i++) {
var input = editors[i].querySelector('input[type="hidden"]');
input.value = editors[i]['_quill-editor'].root.innerHTML;
// input.value = editors[i]['_quill-editor'].getContents();
// input.value = editors[i].querySelector( '.quill-editor-content' ).innerHTML;
}
};
}

Просмотреть файл

@@ -1,4 +1,4 @@
@import 'activeadmin/quill_editor/quill.snow.css'
@import 'activeadmin/quill_editor/quill.snow'
body.active_admin form .quill-editor
display: inline-block

Просмотреть файл

@@ -1 +1,3 @@
# frozen_string_literal: true
require 'activeadmin/quill_editor/engine'

Просмотреть файл

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'active_admin'
module ActiveAdmin

Просмотреть файл

@@ -1,5 +1,7 @@
# frozen_string_literal: true
module ActiveAdmin
module QuillEditor
VERSION = '0.1.4'
VERSION = '0.2.0'
end
end

Просмотреть файл

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'activeadmin/quill_editor'
require 'formtastic/inputs/quill_editor_input'

Просмотреть файл

@@ -1,15 +1,17 @@
# frozen_string_literal: true
module Formtastic
module Inputs
class QuillEditorInput < Formtastic::Inputs::TextInput
def to_html
input_wrapping do
label_html <<
template.content_tag( :div, input_html_options.merge( class: 'quill-editor' ) ) do
builder.hidden_field( input_name ) <<
template.content_tag( :div, class: 'quill-editor-content' ) do
object.send( method ).try :html_safe
template.content_tag(:div, input_html_options.merge(class: 'quill-editor')) do
builder.hidden_field(input_name) <<
template.content_tag(:div, class: 'quill-editor-content') do
object.send(method).try :html_safe
end
end
end
end
end
end