editor.getSelected() in run:open-assets
Question
Hello!
I want without having to create a new block button, and stopping the event associated to the image that this run:open-assets get the area created by the editor in the canvas and add there the image that I got with my personalized modal image.
I want to clarify that when I double-click on the image inside the canvas and select the image from my image manager it is updated correctly with editor.getSelected(), but when I add it from the block panel, it doesn't get the select object and gives me an error: don't find the getSelected function.
editor.on('run:open-assets', function(){
editor.Modal.close();
window.send_to_editor = function(src) {
editor.getSelected().set('src',src)
editor.getSelected().set('srcset',src)
tb_remove();
}
});
Is there any other way to solve this?
Answers (3)
Pay attention to the current command Your command should be something like this
editor.Commands.add('open-assets', {
run(editor, sender, opts = {}) {
// Here you call your custom asset manager, for example
someCustomeManager.open({
onImageSelect(url) {
// update the selected component
opts.target.set('src', url);
...
}
})
}
});
Apologize @chiqui3d but try to elaborate better, because I didn't get a single statement of what you're asking
Yes @artf , you're right, I just updated it, I hope it's understood now.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1661
I've created html table and cannot drag new elements to table cells
Hello. if I create html table with next block of code, everything works, I'm able to drop a Quote, for example, to any cell: But next code...
Issue #2014
[BUG] - Not able to get content of a link block
Hello all, I am using grapesjs version 0.14.52. I am having the following issue: When I drop a link block inside the canvas, I can use the...
Issue #2013
[BUG] - Not able to get content of a link block
Hello all, I am using grapesjs version 0.14.52. I am having the following issue: When I drop a link block inside the canvas, I can use the...
Issue #1831
[Question] How to run command for a block component?
I'd like to do something like this. so once a user drops the test component into the canvas, I'd like to open up asset manager modal where...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.