tneotia/html-editor-enhanced

[QUESTION] event imageDelete

andeersonluiz opened this issue ยท 2 comments

Hello, i would like to know if the widget HtmlEditor has the limageDelete event.

It doesn't have this because Summernote does not have this in the Javascript. However maybe if you use the onBeforeCommand & onChange callback and the diff function you can get the same thing?

Basically compare the text before the change and after the change, if the difference has an <img> tag inside then you know an image has been added or deleted, then just check which string had your <img> tag. If the text before had it, then you know it was deleted.

Like this:

String before;

HtmlEditor(
   callbacks: Callbacks(
      onBeforeCommand: (String beforeCommand) => before = beforeCommand,
      onChange: (String changed) {
            //check diff here using the changed and before variables and perform actions
      }
   )
)

Don't know for sure if it will work but you can try it, I haven't tested it.

Great, worked perfectly for me, thanks for the support!!