Issue #795Opened January 25, 2018by chiqui3d3 reactions

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)

artfJanuary 25, 20183 reactions

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);
                    ...
                 } 
          })
     }
});
artfJanuary 25, 20180 reactions

Apologize @chiqui3d but try to elaborate better, because I didn't get a single statement of what you're asking

chiqui3dJanuary 25, 20180 reactions

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.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.