Issue #1457Opened September 25, 2018by Stejsi2 reactions

[Question]: Custom asset manager background-image in Style Manager

Question

Code SnippetTEXT
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)

artfOctober 2, 20182 reactions

@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);
lock[bot]October 12, 20190 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.