removed inline script
This commit is contained in:
parent
d73e9bec5d
commit
94bfaf34e9
45
index.html
45
index.html
@ -4,52 +4,9 @@
|
||||
<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("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 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>
|
||||
<script type="module" src="./js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
33
js/main.js
Normal file
33
js/main.js
Normal file
@ -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: '<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,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user