[Question]: Custom asset manager background-image in Style Manager
Question
Hello,
i want to use custom Asset Manager
i am used this solution,
`
var assettarget ='';
editor.Commands.add('open-assets', {
run(editor, sender, opts = {}) {
const modal = editor.Modal;
const styleManager = editor.styleManager;
assettarget = opts.target;
modal.setTitle('Add new image');
var $test = $("<iframe style='width: 100%; height: calc(100vh - 60px);' src='http://192.168.0.227:45678/weby/fb/filemanager/dialog.php?editor=tinymce&type=1&lang=cs&popup=0&crossdomain=0&relative_url=0&akey=key&fldr=%2F&5ba947c59de97'>test</iframe>");
$test.on("load", function () {
var iframe = $(this).contents();
iframe.find('.file').on("click",function(event){
var path = $(this).find("img").attr("data-src");
path = path.replace("../","./");
assettarget.set('src', path);
});
})
modal.setContent($test);
modal.open();
}
});
and it works, but now i **am not able to asset background-image in Style Manager**.
It use custom function spreadUrl(), but i dont know how to call it without modify Grapesjs core.
Thanks for help!Answers (2)
@Stejsi inside opts you have onSelect callback which should update stuff in Style Manager. Unfortunately, it only accepts asset (object) as the argument (my bad, I'll make it also understand strings) so, for now you have to do this
const fakeAsset = { get: () => path };
opts.onSelect(fakeAsset);
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.
Issue #1241
[Question]: new style is not reflected in panel
Hello, In my project I have replaced the AssetManager by my own. However, when I use the new manager to update a components background-imag...
Issue #930
[Question] Update resizer after asset changed
Hi! I trying to change default assets manager with ours custom manager. On double click the selected image is replaced with a new one with...
Issue #1881
Commands with a stop method, never programmatically stoped don`t run again!
Problem When you add a custom command with stop and dont stop will not run again if I dont set force: 1 as a parameter when running. When y...
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.