34 lines
1.6 KiB
JavaScript
34 lines
1.6 KiB
JavaScript
import fr from "../grapesjs/src/i18n/locale/fr.js";
|
||
//const projectID = window.location.hash.substr(1);
|
||
const projectID = 1;
|
||
|
||
if (projectID == '' || isNaN(projectID)) {
|
||
alert("L’ID de projet est invalide. Cette application ne va pas fonctionner.");
|
||
} else {
|
||
const projectEndpoint = `/projects/${projectID}`;
|
||
var editor = grapesjs.init({
|
||
container : '#gjs',
|
||
components: '<div class="red">Le chargement du projet est en cours. Si ce message ne disparait pas, le chargement a sans doutes échoué…</div>',
|
||
i18n: {
|
||
locale: 'fr', // default locale
|
||
detectLocale: false, // by default, the editor will detect the language
|
||
//localeFallback: 'en', // default fallback
|
||
messages: {fr},
|
||
},
|
||
storageManager: {
|
||
type: 'remote',
|
||
stepsBeforeSave: 1,
|
||
autosave: true,
|
||
options: {
|
||
remote: {
|
||
urlLoad: projectEndpoint,
|
||
urlStore: projectEndpoint,
|
||
fetchOptions: opts => (opts.method === 'POST' ? { method: 'PATCH' } : {}),
|
||
onStore: data => ({ id: projectID, data }),
|
||
onLoad: result => result.data,
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|