This commit is contained in:
Adrian Amaglio 2023-07-31 13:26:59 +02:00
commit 72f625e62a
3 changed files with 59 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "grapesjs"]
path = grapesjs
url = https://github.com/GrapesJS/grapesjs

1
grapesjs Submodule

@ -0,0 +1 @@
Subproject commit f8b66a1d7e28b6c156cb7d6c61d2951872e9675f

55
index.html Normal file
View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<link rel="stylesheet" href="grapesjs/dist/css/grapes.min.css">
<script src="grapesjs/dist/grapes.min.js"></script>
<script type="importmap">
{
"imports": {
"fr_locale": "./grapesjs/src/i18n/locale/fr.js"
}
}
</script>
</head>
<body>
<div id="gjs"></div>
<script type="module">
import fr from "fr_locale";
//const projectID = window.location.hash.substr(1);
const projectID = 1;
if (projectID == '' || isNaN(projectID)) {
alert("LID de projet est invalide. Cette application ne va pas fonctionner.");
} else {
const projectEndpoint = `/projects/${projectID}`;
var editor = grapesjs.init({
container : '#gjs',
components: '<div style="color: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,
}
}
}
});
}
</script>
</body>
</html>