Issue #2516✓ SolvedOpened January 20, 2020by pradeeshattlee7 reactions

Asset manager alert

快速解答by pouyamiralayi3

Hi @pradeeshattlee place the below code inside a plugin: for more on extending asset manager, check out this link cheers!

Read full answer below ↓

Question

Hi, thanks for the wonderful editor, I Tried to integrate the editor and everything is Fine. When the user selects an image from the asset manager there is no action if an alert is shown that image has been replaced or image selected successfully how can an alert be achieved is there any options for That. Couldn't find a way to add an alert please let me know if there is a way to achieve this

Answers (3)

👍 Most helpfulpouyamiralayiJanuary 20, 2020

Hi @pradeeshattlee place the below code inside a plugin:

        const am = editor.AssetManager;
        am.addType('image', {
            view: {
                onDblClick(){
                    alert('Selected Successfully!');
                    this.em.get('Modal').close();
                },
            }
        })

for more on extending asset manager, check out this link cheers!

artfFebruary 3, 2020

I tried the bellow code the alert is shown on a single click but the image doesn't get replaced

This happens because you overwrite the original method, to extend it correctly you should do this:

const am = editor.AssetManager;
const tImageView = am.getType('image').view;

am.addType('image', {
        view: {
            onClick(){
				tImageView.prototype.onClick.apply(this);
                alert('Selected Successfully!');
                this.em.get('Modal').close();
            },
        }
})
pradeeshattleeFebruary 4, 2020

Thanks @artf this works like a charm.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.