activeadmin_quill_editor icon indicating copy to clipboard operation
activeadmin_quill_editor copied to clipboard

Feature: How to add 'Show HTML' button

Open frobert opened this issue 3 years ago • 2 comments

Hi, forst of all, great plugin. Is there any way to add 'show HTML' button to editor, so users can se HTML source code when writing texs?

Thanks

frobert avatar Jun 17 '21 12:06 frobert

Hi @frobert I made some searches but I think that QuillJS doesn't provide a "Show HTML" / "Show source" feature unfortunately. Perhaps the best solution would be to create a custom editor module.

BTW, I'll think about it to see if there could be some workaround.

blocknotes avatar Jun 18 '21 07:06 blocknotes

@blocknotes Yeah, that is weird, usually all HTML editors have thew 'Show source' option...

Yeas there are some custom modules, but is difficult to inject them into activeadmin_quill_editor gem just like that. It would be great if you could implement this feature to the gem so it works out of the box.

Thanks.

frobert avatar Jun 18 '21 09:06 frobert

I know this is an older issue, but I wanted to share how I was able to accomplish this.

I used this quill-html-edit-button plugin.

In the javascript used to import the activeadmin_quill_editorlibrary, I also import and then register the htmlEditButton plugin.

import 'activeadmin_quill_editor'
import htmlEditButton from "quill-html-edit-button";
Quill.register("modules/htmlEditButton", htmlEditButton);

And then in the active admin form, I specify the quill editor type and use the data-* options to specify the modules.

f.input :content, as: :quill_editor, input_html: { data: { options: { modules: { htmlEditButton: {} } } } }

That adds the "Edit HTML" button at the end of my toolbar. I had to do some CSS tweaking to get it to display properly (it doesn't have SVG icons like the stock Quill editor icons, so it was inheriting some other styles that were undesirable.)

Screenshot 2023-06-09 at 9 13 19 AM

TheBrockEllis avatar Jun 09 '23 14:06 TheBrockEllis

Thank you for your feedback @TheBrockEllis!

I didn't have chance to make experiments on this side but it looks like a nice solution.

Closing the issue for now.

blocknotes avatar Jun 24 '23 08:06 blocknotes