15 Коммитов

Автор SHA1 Сообщение Дата
Mattia Roccoberton
2d5429718c Bump to version 0.3.4 2021-03-16 08:32:57 +01:00
Mattia Roccoberton
78126d0cd7 Fix editor loading with Turbolinks 2021-03-14 16:05:21 +01:00
Mattia Roccoberton
3190134973 Small update to the README 2021-03-14 15:42:14 +01:00
Mattia Roccoberton
8d6b05297a Bump to version 0.3.2 2021-03-14 15:30:59 +01:00
Mattia Roccoberton
5d9b6f70fd Improve specs
- Add test examples for bold and italic content
- Move some test examples
- Adjust RSpec options
2021-03-14 15:26:24 +01:00
Mattia Roccoberton
6fa021c0c7 Update README 2021-03-14 14:35:51 +01:00
Mattia Roccoberton
357ef382d6 Update dependencies to test on Rails 6.1 2021-03-14 12:44:55 +01:00
Mattia Roccoberton
43ae70c7c9 Update NPM package files list 2020-10-06 22:37:25 +02:00
Mattia Roccoberton
6daf6f6bc8 Set word-break: break-all to prevent editor overflow 2020-10-06 22:30:16 +02:00
Mattia Roccoberton
98c235d346 Create brakeman-analysis.yml 2020-10-01 22:22:41 +02:00
Mattia Roccoberton
e6e6742753 Merge pull request #15 from blocknotes/feature/webpacker-support
Webpacker support
2020-10-01 07:56:57 +02:00
Mattia Roccoberton
c2c8d48795 Webpacker support 2020-10-01 07:56:03 +02:00
Mattia Roccoberton
72062c1a30 v0.2.14 2020-09-10 07:40:35 +02:00
Mattia Roccoberton
c4aa91225b Minor specs improvement 2020-09-09 12:58:14 +02:00
Mattia Roccoberton
3cc6edb302 JS strict directive 2020-09-09 07:48:45 +02:00
13 изменённых файлов: 141 добавлений и 31 удалений

44
.github/workflows/brakeman-analysis.yml поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,44 @@
# This workflow integrates Brakeman with GitHub's Code Scanning feature
# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications
name: Brakeman Scan
# This section configures the trigger for the workflow. Feel free to customize depending on your convention
on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
jobs:
brakeman-scan:
name: Brakeman Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
# Customize the ruby version depending on your needs
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Setup Brakeman
env:
BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+
run: |
gem install brakeman --version $BRAKEMAN_VERSION
# Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis
- name: Scan
continue-on-error: true
run: |
brakeman -f sarif -o output.sarif.json .
# Upload the SARIF file generated in the previous step
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: output.sarif.json

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

@@ -1,3 +1,2 @@
--require rails_helper
--format documentation
--profile

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

@@ -5,7 +5,10 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
![screenshot](screenshot.png)
## Install
- After installing Active Admin, add to your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
After installing Active Admin, add to your Gemfile: `gem 'activeadmin_quill_editor'` (and execute *bundle*)
If you installed Active Admin without Webpacker support (default for now):
- Add at the end of your Active Admin styles (_app/assets/stylesheets/active_admin.scss_):
```scss
@import 'activeadmin/quill_editor/quill.snow';
@@ -16,13 +19,23 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
//= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
```
- Use the input with `as: :quill_editor` in Active Admin model conf
Why 2 separated scripts/styles? In this way you can include a different version of *quill editor* if you like.
> **UPDATE FROM VERSION <= 2.0**: please add to your _app/assets/stylesheets/active_admin.scss_ the line `@import 'activeadmin/quill_editor/quill.snow';`
## Options
If you installed Active Admin with Webpacker support:
- Execute in your project root:
```sh
yarn add blocknotes/activeadmin_quill_editor
```
- Add to your *app/javascript/packs/active_admin.js*:
```js
require('activeadmin_quill_editor')
```
## Usage
In your Active Admin models, form configuration, set the text inputs with `as: :quill_editor` where needed.
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/configuration/)
## Examples
@@ -74,9 +87,9 @@ the *upload_admin_post_path*) and it doesn't provide a way to remove images (jus
the editor will not destroy them, you'll need to implement a purge logic for that).
## Do you like it? Star it!
If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
If you use this component just star it. A developer is more motivated to improve a project when there is some interest. My other [Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source).
Take a look at [other Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) that I made if you are curious.
Or consider offering me a coffee, it's a small thing but it is greatly appreciated: [about me](https://www.blocknot.es/about-me).
## Contributors
- [Mattia Roccoberton](http://blocknot.es): author

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

@@ -5,7 +5,10 @@ require 'bundler/gem_tasks'
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |t|
# t.ruby_opts = %w[-w]
t.rspec_opts = ['--color', '--format documentation']
end
task default: :spec
rescue LoadError

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

@@ -19,13 +19,15 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'activeadmin', '~> 2.0'
spec.add_development_dependency 'activestorage', '~> 6.0.3.2'
spec.add_development_dependency 'capybara', '~> 3.33.0'
spec.add_development_dependency 'pry', '~> 0.13.1'
spec.add_development_dependency 'puma', '~> 4.3.5'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
spec.add_development_dependency 'rspec-rails', '~> 4.0.1'
spec.add_development_dependency 'rubocop', '~> 0.90.0'
spec.add_development_dependency 'selenium-webdriver', '~> 3.142.7'
spec.add_development_dependency 'sqlite3', '~> 1.4.2'
spec.add_development_dependency 'activestorage', '~> 6.0'
spec.add_development_dependency 'capybara', '~> 3.33'
spec.add_development_dependency 'pry', '~> 0.13'
spec.add_development_dependency 'puma', '~> 4.3'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4'
spec.add_development_dependency 'rspec-rails', '~> 4.0'
spec.add_development_dependency 'rubocop', '~> 0.90'
spec.add_development_dependency 'sassc', '~> 2.4'
spec.add_development_dependency 'selenium-webdriver', '~> 3.142'
spec.add_development_dependency 'sprockets-rails', '~> 3.2'
spec.add_development_dependency 'sqlite3', '~> 1.4'
end

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

@@ -1,4 +1,6 @@
(function () {
'use strict'
// --- functions ---------------------------------------------------------------
function initQuillEditors() {
let default_theme = 'snow'
@@ -83,11 +85,7 @@
}
// --- events ------------------------------------------------------------------
$(document).ready(() => {
initQuillEditors()
})
$(document).on('has_many_add:after', '.has_many_container', () => {
initQuillEditors()
})
$(document).ready(initQuillEditors)
$(document).on('has_many_add:after', '.has_many_container', initQuillEditors)
$(document).on('turbolinks:load', initQuillEditors)
})()

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

@@ -29,6 +29,7 @@ body.active_admin [data-aa-quill-editor] {
max-height: 300px;
min-height: 150px;
padding: 10px;
word-break: break-all;
ol {
list-style-type: decimal;

7
index.js Обычный файл
Просмотреть файл

@@ -0,0 +1,7 @@
// Styles
import 'activeadmin_quill_editor/app/assets/stylesheets/activeadmin/quill_editor/quill.snow'
import 'activeadmin_quill_editor/app/assets/stylesheets/activeadmin/_quill_editor_input'
// JS
window.Quill = require('activeadmin_quill_editor/app/assets/javascripts/activeadmin/quill_editor/quill')
require('activeadmin_quill_editor/app/assets/javascripts/activeadmin/quill_editor_input')

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

@@ -2,6 +2,6 @@
module ActiveAdmin
module QuillEditor
VERSION = '0.2.12'
VERSION = '0.3.4'
end
end

13
package.json Обычный файл
Просмотреть файл

@@ -0,0 +1,13 @@
{
"name": "activeadmin_quill_editor",
"version": "0.3.4",
"description": "Quill Editor for ActiveAdmin",
"author": "Mattia Roccoberton <mat@blocknot.es>",
"license": "MIT",
"homepage": "https://github.com/blocknotes/activeadmin_quill_editor",
"main": "index.js",
"files": [
"app/**/*",
"index.js"
]
}

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

@@ -38,10 +38,11 @@ ActiveAdmin.register Post do
end
form do |f|
toolbar = %w[bold italic underline link]
f.inputs 'Post' do
f.input :author
f.input :title
f.input :description, as: :quill_editor
f.input :description, as: :quill_editor, input_html: { data: { options: { modules: { toolbar: toolbar } } } }
f.input :category
f.input :dt
f.input :position

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

@@ -1,6 +1,7 @@
require_relative 'boot'
require 'rails/all'
require 'sprockets/railtie'
Bundler.require(*Rails.groups)

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

@@ -9,22 +9,50 @@ RSpec.describe 'Quill editor', type: :system do
end
after do
Post.destroy_all
author.destroy
Post.delete_all
author.delete
end
context 'with a Quill editor' do
it 'updates some HTML content' do
it 'initialize the editor' do
visit "/admin/posts/#{post.id}/edit"
%w[bold italic underline link].each do |button|
expect(page).to have_css(".ql-toolbar button.ql-#{button}")
end
expect(page).to have_css('#post_description[data-aa-quill-editor]')
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
end
it 'adds some text to the description' do
visit "/admin/posts/#{post.id}/edit"
find('#post_description_input .ql-editor').click
find('#post_description_input .ql-editor').base.send_keys('more text')
find('[type="submit"]').click
expect(page).to have_content('was successfully updated')
expect(post.reload.description).to eq '<p>Some content...more text</p>'
end
it 'adds some bold text to the description' do
visit "/admin/posts/#{post.id}/edit"
find('#post_description_input .ql-editor').click
find('#post_description_input .ql-toolbar .ql-bold').click
find('#post_description_input .ql-editor').base.send_keys('more text')
find('[type="submit"]').click
expect(post.reload.description).to eq '<p>Some content...<strong>more text</strong></p>'
end
it 'adds some italic text to the description' do
visit "/admin/posts/#{post.id}/edit"
find('#post_description_input .ql-editor').click
find('#post_description_input .ql-toolbar .ql-italic').click
find('#post_description_input .ql-editor').base.send_keys('more text')
find('[type="submit"]').click
expect(post.reload.description).to eq '<p>Some content...<em>more text</em></p>'
end
end
context 'with a Quill editor in a nested resource' do