Programmatically insert images with the aloha editor

97 Views Asked by At

I want to include images in an aloha editable after a drop event, thus not using the toolbar button.

While some aloha commands may be executed programmatically, there is not so much doc about it and one must look into the code.

With the debugger i found that the relevant function is here so now i would go for copying the insertImg function body somewhere in my code and build my function.

On the other hand it would be much cleaner to reuse that code calling something like

Aloha.plugins.image.insertImg();

In a way similar to how it is done here. Is it possible to do such a thing?

1

There are 1 best solutions below

0
On

A colleague explained me that there is nothing special required in order to insert an image. The function used by aloha is just a way to substitute jQuery and is not necessary.

Once the common/image plugin is loaded, it is sufficient to append an <img> tag inside the editable, also with jQuery, and the plugin will be triggered on it, adding the resize handle and showing the image toolbar when needed.