Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom field and ckeditor #342

Closed
masciugo opened this issue Dec 15, 2015 · 10 comments
Closed

custom field and ckeditor #342

masciugo opened this issue Dec 15, 2015 · 10 comments

Comments

@masciugo
Copy link
Contributor

thanks to #326 (wonderful) I was able to add ckeditor in a custom field this way:

#/app/views/fields/html_field/_form.html.erb
<%= f.label field.attribute %>
<%= f.cktext_area field.attribute, :ckeditor => {:toolbar => 'super_mini'} %>

I was not able to find a way to prevent the editor from overlapping the label:
screen shot 2015-12-15 at 18 16 52
I know it's not very related to administrate which is moreover under heavy development but I thought my problem might be of general interest. Thanks a lot

@c-lliope
Copy link
Contributor

hm... that's interesting. I'm not able to look into this yet, but let me know if you figure out the problem! A CKEditor plugin would be a great addition after we figure out #123.

@rikkipitt
Copy link
Contributor

I built a ckeditor plugin a long while ago and encountered this. I forget why it happens, but I can look into it soon.

@masciugo
Copy link
Contributor Author

@rikkipitt thank you!

@taylorscollon
Copy link

@masciugo did you have to do anything else to get your ckeditor working? I got a paperclip field working, and replicated that setup along with your _form.html.erb partial but no luck. I end up with a div with a class of 'form-field--ck-editor-field' but no toolbar.

@joshnolan
Copy link

It has to do with the CKEditor generated HTML code.
If you wrap the CKEditor in a DIV and do the following the layout will be fixed (same issue occurred when using ActiveAdmin)

<%= f.label field.attribute %>
<div style='display:table; margin-bottom: 20px;'>
<%= f.cktext_area field.attribute, :ckeditor => {:toolbar => 'super_mini'} %>
</div>

@masciugo
Copy link
Contributor Author

masciugo commented Jan 8, 2016

@joshnolan thank you, it works. I had tried to wrap it in a DIV but without applying the display:table; style which actually does the trick. Does it have an easy explanation? thanks again

@masciugo masciugo closed this as completed Jan 8, 2016
@macowie
Copy link

macowie commented Feb 15, 2016

For reference, I always use this rule to fix this issue

.cke_chrome {
  overflow: hidden;
}

@c-lliope
Copy link
Contributor

c-lliope commented Mar 7, 2016

@masciugo - We're starting to extract custom fields into separate gems - if you'd like to do that for this plugin, you should check out #476 as a starting point.

@c-lliope
Copy link
Contributor

@masciugo - we just released version 0.2.0, which supports plugins! Feel free to create your own administrate-field-ckeditor gem and share it with the world!

The administrate-field-image gem at https://github.com/graysonwright/administrate-field-image is a good starting place – that repository demonstrates the file structure that Administrate requires for plugins.

After you've built your plugin, let me know where it lives (on GitHub and on rubygems.org) so I can share it with others.

Happy developing!

@rikkipitt
Copy link
Contributor

As mentioned in #123, using the new plugin structure, I've created a ckeditor plugin for Administrate:

https://github.com/jemcode/administrate-field-ckeditor
https://rubygems.org/gems/administrate-field-ckeditor

Let me know what you guys think, there is much scope for adding in custom ckeditor config.js support etc! Pull requests much appreciated!

Rikki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants