fae icon indicating copy to clipboard operation
fae copied to clipboard

Support rich text with embedded images in a textarea.

Open 6temes opened this issue 9 years ago • 8 comments

I need to allow users to create "posts" with embedded images. I am thinking about adding a JavaScript WYSIWYG editor such as Trumbowyg and store the HTML in the database. Also, the images should be uploaded to the server via Ajax when they are inserted in the text editor.

It looks like a sizable task, so I wanted to ask here first in case anyone thought about this before. Also, how likely is that FAE would incorporate this feature if it gets coded.

6temes avatar Apr 12 '17 06:04 6temes

Thanks for the feature request, @6temes. We currently use the rich text editor SimpleMDE which supports Markdown and highlights formatting live. It's enabled by using the markdown option.

fae_input f, :some_text_area, markdown: true

It currently lacks the ability to directly upload and embed images, however we have customized one of our apps to include such a feature. I think I'd only consider a PR if the feature is built on top of SimpleMDE. I'll leave this open as a feature request and look into what it would take to port over our previous integration.

thanks

jamesmk avatar Apr 12 '17 22:04 jamesmk

Yeah please support this i need it also 👍 thanks

ferryphang avatar Apr 13 '17 07:04 ferryphang

I guess that there two different subjects here:

First is how to upload images and include them in a rich text field. Should those images belong to the model parent model or it is better just have a generic EmbeddedImage model and throw them there?

Second is if it could be possible to support raw HTML in rich text fields.

6temes avatar Apr 13 '17 07:04 6temes

I prefer the EmbeddedImage way and anyway please add an optional instead of using markdown editor we can use the wysiwyg editor it more common for not tech savy user. God bless

ferryphang avatar Apr 13 '17 09:04 ferryphang

@6temes: For our integration we enabled the image button on SimpleMDE and coded it to open a modal with an image uploader. Once an image was uploaded, it'd embed the md code with the location of the uploaded image. The image doesn't need it's own object, we just used Fae::Image as there's no real association other than a hardcoded link in the markdown.

screen shot 2017-04-13 at 4 38 11 pm

Second is if it could be possible to support raw HTML in rich text fields.

Fae doesn't have any built in helpers to output HTML in the textareas, but you can put whatever content in the textareas you want, including HTML. It's up to the frontend to determine how it's parsed.

@ferryphang: I'm sorry but we won't be developing a wysiwyg integration other that the current SimpleMDE. PRs would be considered :)

jamesmk avatar Apr 14 '17 00:04 jamesmk

despite us devs prefering MD, a WYSIWYG editor with good image integration is vital to get other team members / clients to think about adopting a cms.

asecondwill avatar Apr 14 '17 20:04 asecondwill

fixed in #224, thanks @6temes!

jamesmk avatar May 18 '17 08:05 jamesmk

This is great news! thanks @6temes

asecondwill avatar May 18 '17 13:05 asecondwill