diff options
| -rw-r--r-- | public/index.php | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/public/index.php b/public/index.php index db73276..d32dfff 100644 --- a/public/index.php +++ b/public/index.php | |||
| @@ -239,6 +239,13 @@ elseif(isset($_GET['action']) && $_GET['action'] == 'upload_image_base64'){ | |||
| 239 | menubar: false, | 239 | menubar: false, |
| 240 | toolbar_mode: 'wrap', | 240 | toolbar_mode: 'wrap', |
| 241 | statusbar: false, | 241 | statusbar: false, |
| 242 | link_title: false, // supprime le champ compliqué "titre" (apparaît au survol du lien) dans la fenêtre "link" | ||
| 243 | /*link_attributes_postprocess: (attrs) => { // modifier les attributs des liens créés | ||
| 244 | console.log(attrs); | ||
| 245 | if (attrs.rel) { | ||
| 246 | attrs.rel += 'noreferrer'; // cacher la page d'où on vient | ||
| 247 | } | ||
| 248 | },*/ | ||
| 242 | //paste_data_images: true, | 249 | //paste_data_images: true, |
| 243 | setup: function (editor) { | 250 | setup: function (editor) { |
| 244 | editor.on('init', function () { | 251 | editor.on('init', function () { |
| @@ -348,27 +355,7 @@ elseif(isset($_GET['action']) && $_GET['action'] == 'upload_image_base64'){ | |||
| 348 | }); | 355 | }); |
| 349 | }, | 356 | }, |
| 350 | // upload d'image natif de tinymce avec le bouton "Insérer une image" | 357 | // upload d'image natif de tinymce avec le bouton "Insérer une image" |
| 351 | images_upload_handler: (blobInfo, progress) => new Promise((resolve, reject) => { | 358 | images_upload_handler: images_upload_handler, // = fonction fléchée |
| 352 | const formData = new FormData(); | ||
| 353 | formData.append("file", blobInfo.blob()); | ||
| 354 | |||
| 355 | fetch('index.php?action=upload_image', { | ||
| 356 | method: 'POST', | ||
| 357 | body: formData | ||
| 358 | }) | ||
| 359 | .then(response => response.json()) | ||
| 360 | .then(data => { | ||
| 361 | if(data.location) { | ||
| 362 | resolve(data.location); | ||
| 363 | } | ||
| 364 | else { | ||
| 365 | reject("Erreur: Chemin d'image invalide"); | ||
| 366 | } | ||
| 367 | }) | ||
| 368 | .catch(error => { | ||
| 369 | reject("Erreur lors de l'upload"); | ||
| 370 | }); | ||
| 371 | }), | ||
| 372 | image_caption: true | 359 | image_caption: true |
| 373 | }); | 360 | }); |
| 374 | 361 | ||
| @@ -376,6 +363,28 @@ elseif(isset($_GET['action']) && $_GET['action'] == 'upload_image_base64'){ | |||
| 376 | document.getElementById(articleId).innerHTML = articleContent; | 363 | document.getElementById(articleId).innerHTML = articleContent; |
| 377 | } | 364 | } |
| 378 | 365 | ||
| 366 | const images_upload_handler = (blobInfo, progress) => new Promise((resolve, reject) => { | ||
| 367 | const formData = new FormData(); | ||
| 368 | formData.append("file", blobInfo.blob()); | ||
| 369 | |||
| 370 | fetch('index.php?action=upload_image', { | ||
| 371 | method: 'POST', | ||
| 372 | body: formData | ||
| 373 | }) | ||
| 374 | .then(response => response.json()) | ||
| 375 | .then(data => { | ||
| 376 | if(data.location) { | ||
| 377 | resolve(data.location); | ||
| 378 | } | ||
| 379 | else { | ||
| 380 | reject("Erreur: Chemin d'image invalide"); | ||
| 381 | } | ||
| 382 | }) | ||
| 383 | .catch(error => { | ||
| 384 | reject("Erreur lors de l'upload"); | ||
| 385 | }); | ||
| 386 | }); | ||
| 387 | |||
| 379 | function deleteArticle(articleId) { | 388 | function deleteArticle(articleId) { |
| 380 | if (confirm('Voulez-vous vraiment supprimer cet article ?')) { | 389 | if (confirm('Voulez-vous vraiment supprimer cet article ?')) { |
| 381 | // Envoyer une requête au serveur pour supprimer l'article | 390 | // Envoyer une requête au serveur pour supprimer l'article |
