Issue #1929Opened March 27, 2019by sakshigarg92 reactions

Loads asset manager, but assets not working

Question

I'm using the pencil icon to trigger the asset manager. The triggering works fine but when I click on any of the images, no change is reflected in my image component. It shows me the existing photo even if I select a different image.

 domc.addType("image", {
    model: {
      initToolbar() {
        typeImage.prototype.initToolbar.apply(this, arguments);
        const tb = this.get("toolbar");
        const tbExists = tb.some(item => item.command === "open-assets");

        if (!tbExists) {
          tb.unshift({
            command: "open-assets",
            label: toolbarIcon
          });
          this.set("toolbar", tb);
        }
      },
      }
    }
  });

Answers (3)

prashant2018March 28, 20191 reactions

Click on the image you want to be replaced, in developer console write the following code snippet:

editor.runCommand('open-assets', {
    target: editor.getSelected()
});

You will see the selected image gets changed. The key here is target: editor.getSelected() , the selected image is treated as the target for the new image to take it's place. You need to trigger the above code when the pencil icon is clicked.

artfMarch 30, 20191 reactions
tb.unshift({
	command: editor => editor.runCommand('open-assets', {
    	target: editor.getSelected(),
	}),
    label: toolbarIcon
});
lock[bot]April 2, 20200 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.