Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[QUESTION] event imageDelete #43

Closed
andeersonluiz opened this issue May 18, 2021 · 2 comments
Closed

[QUESTION] event imageDelete #43

andeersonluiz opened this issue May 18, 2021 · 2 comments
Labels
question Further information is requested

Comments

@andeersonluiz
Copy link

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

@andeersonluiz andeersonluiz added the question Further information is requested label May 18, 2021
@tneotia
Copy link
Owner

tneotia commented May 18, 2021

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.

@andeersonluiz
Copy link
Author

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants