normalisation blog + gestion images

This commit is contained in:
2025-12-14 11:42:13 +01:00
parent 1950fd3902
commit b4e037f11d
12 changed files with 367 additions and 289 deletions

View File

@@ -2,6 +2,7 @@ const form = document.getElementById("ajouterArticleForm");
const messages = document.getElementById("messages");
const imgField = document.getElementById("articleImage");
const imgPreview = document.getElementById("imagePreview");
const titleField = document.getElementById("articleTitle");
const categoryField = document.getElementById("articleCategory");
const publishedField = document.getElementById("articlePublished");
@@ -26,6 +27,9 @@ function imageValide(file) {
return ["image/jpeg", "image/png"].includes(file.type);
}
// Preview image on selection via generic loader (global)
const imgLoader = window.initImagePreview && window.initImagePreview("articleImage", "articleImagePreview", ["image/jpeg", "image/png"]);
form.addEventListener("submit", function (e) {
e.preventDefault();
@@ -91,6 +95,9 @@ form.addEventListener("submit", function (e) {
// Reset
form.reset();
tinymce.get("articleContent").setContent("");
if (imgLoader && typeof imgLoader.reset === "function") {
imgLoader.reset();
}
// Redirection
setTimeout(() => {
@@ -98,13 +105,4 @@ form.addEventListener("submit", function (e) {
}, 1500);
});
/* =========================
TinyMCE
========================= */
tinymce.init({
selector: "#articleContent",
height: 400,
language: "fr",
plugins: "lists fullscreen",
toolbar: "undo redo | bold italic underline | bullist numlist | fullscreen"
});