зеркало из
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-09-03 10:16:18 +03:00
Сравнить коммиты
5 Коммитов
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
e6e6742753 | ||
|
|
c2c8d48795 | ||
|
|
72062c1a30 | ||
|
|
c4aa91225b | ||
|
|
3cc6edb302 |
23
README.md
23
README.md
@@ -5,7 +5,10 @@ An Active Admin plugin to use [Quill Rich Text Editor](https://github.com/quillj
|
|||||||

|

|
||||||
|
|
||||||
## Install
|
## 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_):
|
- Add at the end of your Active Admin styles (_app/assets/stylesheets/active_admin.scss_):
|
||||||
```scss
|
```scss
|
||||||
@import 'activeadmin/quill_editor/quill.snow';
|
@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/quill
|
||||||
//= require activeadmin/quill_editor_input
|
//= 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';`
|
> **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/)
|
**data-options**: permits to set *quill editor* options directly - see [options list](https://quilljs.com/docs/configuration/)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
(function () {
|
(function () {
|
||||||
|
'use strict'
|
||||||
|
|
||||||
// --- functions ---------------------------------------------------------------
|
// --- functions ---------------------------------------------------------------
|
||||||
function initQuillEditors() {
|
function initQuillEditors() {
|
||||||
let default_theme = 'snow'
|
let default_theme = 'snow'
|
||||||
|
|||||||
7
index.js
Обычный файл
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 ActiveAdmin
|
||||||
module QuillEditor
|
module QuillEditor
|
||||||
VERSION = '0.2.12'
|
VERSION = '0.3.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
9
package.json
Обычный файл
9
package.json
Обычный файл
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "activeadmin_quill_editor",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "Quill Editor for ActiveAdmin",
|
||||||
|
"author": "Mattia Roccoberton <mat@blocknot.es>",
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/blocknotes/activeadmin_quill_editor",
|
||||||
|
"main": "index.js"
|
||||||
|
}
|
||||||
@@ -38,10 +38,11 @@ ActiveAdmin.register Post do
|
|||||||
end
|
end
|
||||||
|
|
||||||
form do |f|
|
form do |f|
|
||||||
|
toolbar = %w[bold italic underline link]
|
||||||
f.inputs 'Post' do
|
f.inputs 'Post' do
|
||||||
f.input :author
|
f.input :author
|
||||||
f.input :title
|
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 :category
|
||||||
f.input :dt
|
f.input :dt
|
||||||
f.input :position
|
f.input :position
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ RSpec.describe 'Quill editor', type: :system do
|
|||||||
it 'updates some HTML content' do
|
it 'updates some HTML content' do
|
||||||
visit "/admin/posts/#{post.id}/edit"
|
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...')
|
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
|
||||||
find('#post_description_input .ql-editor').click
|
find('#post_description_input .ql-editor').click
|
||||||
find('#post_description_input .ql-editor').base.send_keys('more text')
|
find('#post_description_input .ql-editor').base.send_keys('more text')
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user