The template manager uses a hardcoded(?) ID prefix
Closed this issue · 2 comments
Biont commented
I wanted to get rid of the gjs-
-prefix in the payloads, so I set up my storage manager like this:
{
storageManager: {
id: '',
type: 'rest-api',
stepsBeforeSave: 3,
urlStore: 'api/grapesjs',
urlLoad: 'api/grapesjs',
urlDelete: 'api/grapesjs',
},
}
If I save a document like this and then open the template manager modal, I see the following error:
Error SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at grapesjs-project-manager.min.js:2
at Array.map (<anonymous>)
at n.value (grapesjs-project-manager.min.js:2)
at n.value (grapesjs-project-manager.min.js:2)
at n.value (grapesjs-project-manager.min.js:2)
at grapesjs-project-manager.min.js:2
at r.onResponse (grapes.min.js:2)
at grapes.min.js:2
That's because it is still trying to access the "pages"
property using the "gjs-"
prefix:
I would expect this to respect the prefix I configured in the storeManager
. Did I miss something here?
I am using the latest releases of everything:
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"grapesjs": "^0.17.25",
"grapesjs-preset-webpage": "^0.1.11",
"grapesjs-project-manager": "^1.0.9"
},
Ju99ernaut commented
Good catch, the prefix isn't hardcoded but it defaults to gjs-
since an empty string is falsy. Should be matter of properly handling the assignment of this.id
.
I'll work on a fix for this but a PR is also welcome.
Ju99ernaut commented
Probably there's no need to add || 'gjs-'
, it can just be:
this.id = editor.Storage.getConfig().id;