зеркало из
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-09-03 18:25:51 +03:00
Сравнить коммиты
4 Коммитов
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
9ecfceaa9a | ||
|
|
598b2d75cf | ||
|
|
54026744c4 | ||
|
|
5d35feedd8 |
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'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Why 2 separated scripts? In this way you can include a different version of *qui
|
|||||||
|
|
||||||
## Options
|
## 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
|
## Examples
|
||||||
|
|
||||||
|
|||||||
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)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
require 'activeadmin/quill_editor/version'
|
require 'activeadmin/quill_editor/version'
|
||||||
|
|
||||||
@@ -15,5 +17,5 @@ Gem::Specification.new do |spec|
|
|||||||
spec.files = `git ls-files -z`.split("\x0")
|
spec.files = `git ls-files -z`.split("\x0")
|
||||||
spec.require_paths = ['lib']
|
spec.require_paths = ['lib']
|
||||||
|
|
||||||
spec.add_runtime_dependency 'activeadmin', '2.0.0.alpha' # '~> 1.0'
|
spec.add_runtime_dependency 'activeadmin', '>= 1.0'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
window.onload = function () {
|
window.onload = function() {
|
||||||
initQuillEditors();
|
initQuillEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ $(document).on('has_many_add:after', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var initQuillEditors = function() {
|
var initQuillEditors = function() {
|
||||||
var editors = document.querySelectorAll( '.quill-editor' );
|
var editors = document.querySelectorAll('.quill-editor');
|
||||||
var default_options = {
|
var default_options = {
|
||||||
modules: {
|
modules: {
|
||||||
toolbar: [
|
toolbar: [
|
||||||
@@ -17,32 +17,28 @@ var initQuillEditors = function() {
|
|||||||
[{ 'align': [] }, { list: 'ordered' }, { list: 'bullet' }],
|
[{ 'align': [] }, { list: 'ordered' }, { list: 'bullet' }],
|
||||||
[{ 'color': [] }, { 'background': [] }],
|
[{ 'color': [] }, { 'background': [] }],
|
||||||
['clean'],
|
['clean'],
|
||||||
// [{ 'size': ['small', false, 'large', 'huge'] }],
|
|
||||||
// [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
theme: 'snow'
|
theme: 'snow'
|
||||||
};
|
};
|
||||||
|
|
||||||
for( var i = 0; i < editors.length; i++ ) {
|
for(var i = 0; i < editors.length; i++) {
|
||||||
var content = editors[i].querySelector( '.quill-editor-content' );
|
var content = editors[i].querySelector('.quill-editor-content');
|
||||||
var isActive = editors[i].classList.contains('quill-editor--active');
|
var isActive = editors[i].classList.contains('quill-editor--active');
|
||||||
if( content && !isActive) {
|
if(content && !isActive) {
|
||||||
var options = editors[i].getAttribute( 'data-options' ) ? JSON.parse( editors[i].getAttribute( 'data-options' ) ) : default_options;
|
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]['_quill-editor'] = new Quill(content, options);
|
||||||
editors[i].classList += ' quill-editor--active';
|
editors[i].classList += ' quill-editor--active';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var formtastic = document.querySelector( 'form.formtastic' );
|
var formtastic = document.querySelector('form.formtastic');
|
||||||
if( formtastic ) {
|
if(formtastic) {
|
||||||
formtastic.onsubmit = function() {
|
formtastic.onsubmit = function() {
|
||||||
for( var i = 0; i < editors.length; i++ ) {
|
for(var i = 0; i < editors.length; i++) {
|
||||||
var input = editors[i].querySelector( 'input[type="hidden"]' );
|
var input = editors[i].querySelector('input[type="hidden"]');
|
||||||
input.value = editors[i]['_quill-editor'].root.innerHTML;
|
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
|
body.active_admin form .quill-editor
|
||||||
display: inline-block
|
display: inline-block
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'activeadmin/quill_editor/engine'
|
require 'activeadmin/quill_editor/engine'
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'active_admin'
|
require 'active_admin'
|
||||||
|
|
||||||
module ActiveAdmin
|
module ActiveAdmin
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ActiveAdmin
|
module ActiveAdmin
|
||||||
module QuillEditor
|
module QuillEditor
|
||||||
VERSION = '0.1.4'
|
VERSION = '0.2.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'activeadmin/quill_editor'
|
require 'activeadmin/quill_editor'
|
||||||
|
|
||||||
require 'formtastic/inputs/quill_editor_input'
|
require 'formtastic/inputs/quill_editor_input'
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Formtastic
|
module Formtastic
|
||||||
module Inputs
|
module Inputs
|
||||||
class QuillEditorInput < Formtastic::Inputs::TextInput
|
class QuillEditorInput < Formtastic::Inputs::TextInput
|
||||||
def to_html
|
def to_html
|
||||||
input_wrapping do
|
input_wrapping do
|
||||||
label_html <<
|
label_html <<
|
||||||
template.content_tag( :div, input_html_options.merge( class: 'quill-editor' ) ) do
|
template.content_tag(:div, input_html_options.merge(class: 'quill-editor')) do
|
||||||
builder.hidden_field( input_name ) <<
|
builder.hidden_field(input_name) <<
|
||||||
template.content_tag( :div, class: 'quill-editor-content' ) do
|
template.content_tag(:div, class: 'quill-editor-content') do
|
||||||
object.send( method ).try :html_safe
|
object.send(method).try :html_safe
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user