Not seeing Quill editor in active admin form.
followed all instructions from here and the whole description box doesn't diplay. same happened to other editors i tried.
form title: "Drinks" do |f|
f.inputs "Drinks" do
f.input :title
f.input :description, as: :quill_editor
f.input :steps
f.input :source
end
f.actions
end
Please ensure you have included active_admin/base to your app/assets/javascripts/active_admin.js file:
//= require active_admin/base
//= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
This is what was causing the issue for me.
I have implemented Quill Rich Text Editor in Active Admin by following the below steps in Rails 6 application:
Add the gems:
gem 'activeadmin_quill_editor'
gem 'sassc'
Add below js code in app/assets/javascripts/active_admin.js:
//= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
Add below css code in app/assets/stylesheets/active_admin.scss
#import 'activeadmin/quill_editor/quill.snow';
#import 'activeadmin/quill_editor_input';
For defualt toolbar options use the below syntax:
form do |f|
f.inputs 'Notices' do
f.input :description, as: :quill_editor
end
f.actions
end
For customized toolbar options the use below syntax:
form do |f|
f.inputs 'Notices' do
f.input :description, as: :quill_editor, input_html: { data: { options: { modules: { toolbar: [ ['bold', 'italic', 'underline', 'strike'],['blockquote', 'code-block'], [{ 'header': 1 }, { 'header': 2 }], [{ 'list': 'ordered'}, { 'list': 'bullet' }], [{ 'script': 'sub'}, { 'script': 'super' }], [{ 'indent': '-1'}, { 'indent': '+1' }], [{ 'direction': 'rtl' }], [{ 'size': ['small', false, 'large', 'huge'] }], [{ 'header': [1, 2, 3, 4, 5, 6, false] }], [{ 'color': [] }, { 'background': [] }], [{ 'font': [] }], [{ 'align': [] }], ['clean'] ] }, theme: 'snow' } } }
end
f.actions
end
For more information visit:
https://github.com/blocknotes/activeadmin_quill_editor
https://quilljs.com/docs/modules/toolbar/
Related
How can I add an input where a user can add the specific title tag to a link in the ckeditor5?
So for example my config file looks like this...
const config = {
toolbar: {
items: [
'bold',
'italic',
'link',
'|',
'bulletedList',
'numberedList',
'|',
'heading',
'|',
'undo',
'redo'
]
},
link: {
addTargetToExternalLinks: true,
decorators: {
openInNewTab: {
mode: 'manual',
label: 'Open in a new tab',
defaultValue: true,
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
}
}, title: {
mode: 'manual',
label: 'Set a title',
defaultValue: ''
}
}
}
}
But I want to add a decorator that is like...
addTitleTag: {
mode: 'manual',
label: 'Add a title tag',
defaultValue: '', // Here the user have an input to add a title text
attributes: {
title: 'value'
}
}
But instead of a checkbox, it's text input. Is this possible?
Unfortunately, this can't be achieved using decorators and is not supported by any means by the original plugin you have to modify the plugin in order to do so. I had the same need and modified the plugin.
I tried to add Quill Emojis to editor but I am getting console error as
Uncaught ReferenceError: Quill is not defined
I am using Laravel 5.6 and vue js and definately new to vue and its components so I may sound silly to you but for the past 3 days I am searching on the google for the solution and even contacted author of vue2editor on github here is the link
This is what I have tried so far:
vue2editor.vue
<template>
<div id="app">
<vue-editor v-model="content"></vue-editor>
</div>
</template>
<script>
import { VueEditor, Quill } from 'vue2-editor';
import Emoji from 'quill-emoji/dist/quill-emoji';
Quill.register('modules/quill-emoji', Emoji);
export default {
name: 'vue2editor',
components: { VueEditor },
data() {
return {
content: "<h1>Some initial content</h1>",
editorSettings: {
modules: {
toolbar: {
container: [
[{'size': ['small', false, 'large']}],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }],
[{ 'align': [] }],
['clean'],
['link', 'image', 'video'],
['emoji'],
],
handlers: {
'emoji': function () {}
},
},
toolbar_emoji: true,
short_name_emoji: true,
textarea_emoji:true,
},
},
text: null,
};
},
};
</script>
I even tried the method mentioned by one of the user on github for Quill-Emoji, here is the link.
I came here with lots of hopes; if anyone here is to help me out, at least tell me what I am missing will be more than a help for me.
Quill.register({
'formats/emoji': Emoji.EmojiBlot,
'modules/short_name_emoji': Emoji.ShortNameEmoji,
'modules/toolbar_emoji': Emoji.ToolbarEmoji,
'modules/textarea_emoji': Emoji.TextAreaEmoji}, true);
you need register the model, add the up code to you code.
Edit:
//1) Add plugin to laravel mix
const mix = require('laravel-mix')
mix.webpackConfig(webpack => {
return {
plugins: [
new webpack.ProvidePlugin({
"window.Quill": "quill/dist/quill.js",
Quill: "quill/dist/quill.js"
})
]
};
});
//2 example vue file
<template>
<div class="mt-1">
<vue-editor
ref="editor"
v-model="content"
:editor-toolbar="customToolbar"
:editorOptions="editorSettings"
/>
</div>
</template>
<script>
import { VueEditor, Quill } from "vue2-editor";
import Emoji from "quill-emoji/dist/quill-emoji";
Quill.register("modules/emoji", Emoji);
export default {
components: {
VueEditor,
},
props: {
bubble: Object,
contentCol: {
type: String,
},
},
data() {
return {
edit: false,
content: "<b>Content is here</b>",
customToolbar: [["bold", "italic", "underline"], ["link"], ["emoji"]],
editorSettings: {
modules: {
"emoji-toolbar": true,
"emoji-textarea": true,
"emoji-shortname": true,
},
},
};
},
beforeDestroy() {},
};
</script>
<style src="quill-emoji/dist/quill-emoji.css"/>
I'm trying to create a unique field for embedded documents:
class Chapter
include Mongoid::Document
field :title
end
class Book
include Mongoid::Document
field :name
embeds_many :chapters
index({ 'name' => 1 }, { unique: true })
index({ 'name' => 1, 'chapters.title' => 1 }, { unique: true, sparse: true })
# index({ 'name' => 1, 'chapters.title' => 1 }, { unique: true })
end
I run the task: rake db:mongoid:create_indexes
I, [2017-02-22T08:56:47.087414 #94935] INFO -- : MONGOID: Created indexes on Book:
I, [2017-02-22T08:56:47.087582 #94935] INFO -- : MONGOID: Index: {:name=>1}, Options: {:unique=>true}
I, [2017-02-22T08:56:47.087633 #94935] INFO -- : MONGOID: Index: {:name=>1, :"chapters.title"=>1}, Options: {:unique=>true, :sparse=>true}
But it doesn't work as I would expect...
Book.new( name: 'A book', chapters: [ { title: 'title1' }, { title: 'title1' }, { title: 'title2' } ] ).save # no errors
Book.new( name: 'Another book', chapters: [ { title: 'title2' } ] ).save
b = Book.last
b.chapters.push( Chapter.new( { title: 'title2' } ) )
b.save # no errors
Any idea?
UPDATE: Ruby 2.4.0, Mongo 3.2.10, Mongoid 5.2.0 | 6.0.3 (trying both)
UPDATE2: I add also the tests I made directly with mongo client:
use books
db.books.ensureIndex({ title: 1 }, { unique: true })
db.books.ensureIndex({ "title": 1, "chapters.title": 1 }, { unique: true, sparse: true, drop_dups: true })
db.books.insert({ title: "Book1", chapters: [ { title: "Ch1" }, { title: "Ch1" } ] }) # allowed?!
db.books.insert({ title: "Book1", chapters: [ { title: "Ch1" } ] })
b = db.books.findOne( { title: 'Book1' } )
b.chapters.push( { "title": "Ch1" } )
db.books.save( b ) # allowed?!
db.books.findOne( { title: 'Book1' } )
db.books.insert({ title: "Book2", chapters: [ { title: "Ch1" } ] })
UPDATE3: I made more tests but I didn't succeed, this link helped but the problem remains
You should use drop_dups
class Category
include Mongoid::Document
field :title, type: String
embeds_many :posts
index({"posts.title" => 1}, {unique: true, drop_dups: true, name: 'unique_drop_dulp_idx'})
end
class Post
include Mongoid::Document
field :title, type: String
end
Rails console:
irb(main):032:0> Category.first.posts.create(title: 'Honda S2000')
=> #<Post _id: 58adb923cacaa6f778215a26, title: "Honda S2000">
irb(main):033:0> Category.first.posts.create(title: 'Honda S2000')
Mongo::Error::OperationFailure: E11000 duplicate key error collection: mo_development.posts index: title_1 dup key: { : "Honda S2000" } (11000)
I am using the search dialog box in jqgrid. The columns which has search attribute set as true will appear in the search dialog box.Can we have just column names instead of select drop down of columns in the search dialog box of JQGRID ?
In the pager add those lines
jQuery("#list").jqGrid('navGrid', '#pager',
{ edit: false, add: false, del: false, search: true, refresh: true },
{},
{
},
{
},
{
multipleGroup: true,
closeOnEscape: true,
caption: "Search...",
multipleSearch: true,
Find: "Find",
Reset: "Reset",
odata: [{ oper: 'eq', text: 'equal' }, { oper: 'ne', text: 'not equal' }, { oper: 'lt', text: 'less' }, { oper: 'le', text: 'less or equal' }, { oper: 'gt', text: 'greater' }, { oper: 'ge', text: 'greater or equal' }, { oper: 'bw', text: 'begins with' }, { oper: 'bn', text: 'does not begin with' }, { oper: 'in', text: 'is in' }, { oper: 'ni', text: 'is not in' }, { oper: 'ew', text: 'ends with' }, { oper: 'en', text: 'does not end with' }, { oper: 'cn', text: 'contains' }, { oper: 'nc', text: 'does not contain' }],
groupOps: [{ op: "AND", text: "all" }, { op: "OR", text: "any" }],
}
);
I have a nested hash like this:
LANGUAGE_DETAILS = {
BG: {
Name: 'Български',
Flag: ''
},
EN: {
Name: 'English',
Flag: ''
},
RU: {
Name: 'Руский',
Flag: ''
},
UK: {
Name: 'Украински',
Flag: ''
}
}
and need to format it like the following hash:
{
BG: 'Български',
EN: 'English',
RU: 'Руский',
UK: 'Украински'
}
in order to use it as simple_form input parameter like this:
<%= f.input :language_code, collection: SecurityUser::LANGUAGE_DETAILS,
label_method: :last,
value_method: :first,
as: :radio_buttons , label: 'Choose language' %>
Is there a way to transform the SecurityUser::LANGUAGE_DETAILS hash into new one in this context or I should create the hash on hand in the model?
You can do it like this:
Hash[LANGUAGE_DETAILS.map{|k, h| [k, h[:Name]]}]