Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Stejsi opened this issue Sep 25, 2018 · 2 comments
Closed

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

Stejsi opened this issue Sep 25, 2018 · 2 comments

Comments

@Stejsi
Copy link

Stejsi commented Sep 25, 2018

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!

@artf
Copy link
Member

artf commented Oct 2, 2018

@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);

@artf artf added this to To do in Release v0.14.40 via automation Oct 2, 2018
@artf artf moved this from To do to In progress in Release v0.14.40 Oct 2, 2018
@artf artf moved this from In progress to Ready in Release v0.14.40 Oct 2, 2018
@artf artf closed this as completed in 6900f3b Oct 12, 2018
Release v0.14.40 automation moved this from Ready to Done Oct 12, 2018
@lock
Copy link

lock bot commented Oct 12, 2019

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.

@lock lock bot added the outdated label Oct 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Development

No branches or pull requests

2 participants