I'm using the best_in_place
gem to do in-place editing in a Rails application. However, I need (X)HTML editing on some of the text areas, so I need a rich-text editor. TinyMCE is being used elsewhere on the site.
However, it's not trivial to add an editor to best_in_place
. To grossly oversimplify, the gem uses jQuery to insert the textarea
tag on the fly, and TinyMCE initializes at page load, replacing available textarea
s with an editor, so when best_in_place
puts in its textarea
, TinyMCE has already come and gone. I've tried re-initializing TinyMCE after best_in_place
inserts its textarea, but I don't think I've found the correct place(s) in the code to do that, because so far it hasn't worked.
There's a rumor that this integration is possible, but no documentation was visible in my web searches, so pointers are welcome. (Likewise this answer is unhelpful, pointing to two broken links.) I think my preferred order of solutions would be something like
- Here's how to integrate TinyMCE with
best_in_place
- It can't be done with TinyMCE but here's how to do it with another rich-text editor
- It can't be done with
best_in_place
but here's another rich-text edit-in-place solution for Rails 3.2.x.
I gave up trying to do this with best_in_place
, so this question as written is still open to a better answer. However, for those who might find this question later and wonder what I eventually came up with, here's what I did in the end:
- Junked
best_in_place
. - Forked the jeditable-rails plugin to get Jeditable as an in-place editor.
- Adapted the plugin to provide Jeditable, jWYSIWYG, and the Jeditable-jWYSIWYG custom input as assets for the Rails asset pipeline (along with related CSS and images for jWYSIWYG).
- Profit! (Not really.)
Anyway, if you're trying to do rich-text in-place editing in Rails 3.2, try the jeditable-wysiwyg-rails plugin. It's providing the assets for the markItUp editor as well, although because I'm not using it I'm not sure they're all there and/or arranged properly.
来源:https://stackoverflow.com/questions/13076653/using-best-in-place-with-rich-text-editor-like-tinymce