From 94bfaf34e92d3b13c722663b9895f20a91c57acf Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Mon, 31 Jul 2023 14:16:22 +0200 Subject: [PATCH] removed inline script --- index.html | 45 +-------------------------------------------- js/main.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 44 deletions(-) create mode 100644 js/main.js diff --git a/index.html b/index.html index dd59225..3b363bb 100644 --- a/index.html +++ b/index.html @@ -4,52 +4,9 @@ - -
- - + diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..0920a9b --- /dev/null +++ b/js/main.js @@ -0,0 +1,33 @@ +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: '
Le chargement du projet est en cours. Si ce message ne disparait pas, le chargement a sans doutes échoué…
', + 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, + } + } + } + }); + }