Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ·
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-08-28 15:36:17 +03:00
π 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
ΠΡΠΎΡ ΠΊΠΎΠΌΠΌΠΈΡ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡΡΡ Π²:
73
.rubocop.yml
ΠΠ±ΡΡΠ½ΡΠΉ ΡΠ°ΠΉΠ»
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
Gemfile
1
Gemfile
@@ -1,4 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
|
||||
## Install
|
||||
|
||||
- Update your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
|
||||
- For ActiveAdmin2 alpha use: `gem 'activeadmin_quill_editor', git: 'https://github.com/blocknotes/activeadmin_quill_editor', branch: 'aa2'`
|
||||
- Add at the end of your ActiveAdmin styles (_app/assets/stylesheets/active_admin.scss_):
|
||||
```css
|
||||
@import 'activeadmin/quill_editor_input';
|
||||
|
||||
4
Rakefile
4
Rakefile
@@ -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', '~> 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 +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
|
||||
|
||||
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅
Block a user