Mise en place tinymce dans accueil blog avec clé et domaine

This commit is contained in:
ben
2025-12-11 11:04:42 +01:00
parent 8fe2e99953
commit a0e14bfa92
2 changed files with 27 additions and 6 deletions

View File

@@ -17,8 +17,9 @@ form.addEventListener('submit', function(e) {
const titre = titleField.value.trim().toLowerCase();
const fichierImage = imgField.files[0];
const contenu = tinymce.get("articleContent").getContent(); // ← CORRECTION IMPORTANTE
const contenu = tinymce.get("articleContent").getContent();
const categorie = categoryField.value;
const published = publishedField.checked; // ← récupère la case cochée
// Reset messages
errorEmpty.classList.add('d-none');
@@ -62,9 +63,30 @@ form.addEventListener('submit', function(e) {
}
}
// Simuler enregistrement
// Simuler enregistrement (ancienne logique)
titreExistants.push(titre);
// -------------------------------
// 📌 CRÉATION DE L'ARTICLE
// -------------------------------
const nouvelArticle = {
id: Date.now(),
titre: titleField.value.trim(),
contenu: contenu,
categorie: categorie,
published: published, // ← valeur TRUE/FALSE pour afficher le badge Facebook
date: new Date().toISOString()
};
// --------------------------------
// 📌 SAUVEGARDE DANS LOCALSTORAGE
// --------------------------------
let articles = JSON.parse(localStorage.getItem("articles")) || [];
articles.push(nouvelArticle);
localStorage.setItem("articles", JSON.stringify(articles));
console.log("Article enregistré :", nouvelArticle);
// Succès
successMsg.classList.remove('d-none');
@@ -74,11 +96,11 @@ form.addEventListener('submit', function(e) {
}, 1000);
});
// TinyMCE
// TinyMCE INIT
tinymce.init({
selector: '#articleContent',
height: 400,
language: 'fr',
plugins: 'lists fullscreen',
toolbar: 'undo redo | bold italic underline | bullist numlist | fullscreen',
toolbar: 'undo redo | bold italic underline | bullist numlist | fullscreen'
});

3
package-lock.json generated
View File

@@ -76,8 +76,7 @@
"node_modules/scheduler": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
"peer": true
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="
},
"node_modules/tinymce": {
"version": "8.2.2",