mjawad096 / laravel-grapesjs

This package provide an esay way to integrate GrapesJS into your laravel proejct.
MIT License
107 stars 54 forks source link

image editor returns black screen #47

Closed joukhar closed 1 year ago

joukhar commented 1 year ago

in config

    'default' => [
            'basic_blocks' => true,
            'bootstrap4_blocks' => false,
            'code_editor' => true,
            'image_editor' => true,
            'custom_fonts' => [],
            'templates' => true
        ],

screenshot : https://prnt.sc/WggH-yulJCBa

ghost commented 1 year ago

Hello there, Have you removed the image editor from the custom plugins in the config? If so, please try a hard refresh or incognito window

joukhar commented 1 year ago

ok i will try.

joukhar commented 1 year ago

it doesn't work

in the console :

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Error loading http://127.0.0.1:8000/laravel-grapesjs/asset/proxy?file=http://127.0.0.1:8000/storage/editor/media/Screenshot%202022-09-05%20235720.png

Uncaught TypeError: Cannot read properties of null (reading 'getElement')
    at tui-image-editor.js:15341:33
    at klass.<anonymous> (fabric.js:6411:23)
    at img.onerror (fabric.js:642:30)
ghost commented 1 year ago

Can you please open this link http://127.0.0.1:8000/storage/editor/media/Screenshot%202022-09-05%20235720.png in your browser and let me know if it returning the image or not?

If it shows an error page instead of an image, you might be not created the storage link.

joukhar commented 1 year ago

it returns image.

ghost commented 1 year ago

Have you tried with a different image?

joukhar commented 1 year ago

yes

joukhar commented 1 year ago

hi sir , if u don't have free time just leave it , until you have some of it , and thanks for ur efforts 💙

OmarAlwabsi commented 1 year ago

Hi I think the problem is caused by using a Fake domain for example: http://laravel-grapesjs.test

The problem is in: Dotlogics\Grapesjs\App\Http\Controllers\AssetController

private function replaceLocalUrlToFilePath($url)
{
    $urlParts = parse_url($url);
    if ($urlParts['host'] == 'localhost') {
        return [public_path($urlParts['path']), true];
    }

    return [$url, false];
}

the solution :

private function replaceLocalUrlToFilePath($url)
{
    $urlParts = parse_url($url);
    // if ($urlParts['host'] == 'localhost') {
    //     return [public_path($urlParts['path']), true];
    // }

    if ($urlParts['host'] == request()->getHttpHost()) {
        return [public_path($urlParts['path']), true];
    }

    return [$url, false];
}
joukhar commented 1 year ago

thanks , finally it works