Template loaded via remote storage is not displayed in the editor
Hi,
I am trying to load a default template from remote storage into the editor but nothing is displayed.
As part of of the initialization I have this code:
storageManager: {
type: "remote",
autosave: true,
autoload: true,
stepsBeforeSave: 3,
urlStore: "https://myendpoint/lib/remote_storage_load_template.php",
urlLoad: "https://myendpoint/lib/remote_storage_load_template.php",
params: {},
contentTypeJson: true,
},
This is the PHP code from my urlLoad:
header('Content-Type: application/json');
$html = '
//echo htmlentities(json_encode($arr)); echo json_encode($arr);
This is the JSON that grapesjs loads from my endpoint:
editor.on('storage:load', obj => console.log('Loaded ', obj));

When I make a GET request to my endpoint directly, this is what I get:
{"gjs-html":"<div class = \"hero\">Hello world<\/div>","gjs-css":"*{color:red;} body{width:100%;}","gjs-assets":[],"gjs-styles":[],"gjs-components":[]}
Am I missing something obvious?
Thanks for your help
Hi @jamejillagit !
According to how DOM Components are loaded, it seems like GrapesJS will prioritize loading from the gjs-components property over the gjs-html one as long as it is defined & valid (array, object or JSON string).
If you explicitly want to load from gjs-html, I think your endpoint should not return a valid value for the gjs-components property.
Cheers !
@jamejillagit be sure to have read this https://grapesjs.com/docs/modules/Storage.html If you're loading back the HTML to update the template, you'll face issues