Fix article editor

This commit is contained in:
2026-03-26 17:34:10 -04:00
parent 3687003935
commit bc9000aad9
7 changed files with 390 additions and 26 deletions
+3 -2
View File
@@ -246,7 +246,7 @@ tinymce.init({
images_upload_handler: (blobInfo, progress) => new Promise((resolve, reject) => {
const fd = new FormData();
fd.append('file', blobInfo.blob(), blobInfo.filename());
fetch('/admin/kb/upload-image', { method: 'POST', credentials: 'same-origin', body: fd })
fetch('/admin/kb/upload-image', { method: 'POST', credentials: 'same-origin', headers: { 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content }, body: fd })
.then(r => { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
.then(j => { if (j.location) resolve(j.location); else reject({ message: j.error || 'Upload failed', remove: true }); })
.catch(err => reject({ message: String(err), remove: true }));
@@ -374,7 +374,7 @@ function deleteAtt(attId, deleteUrl, filename) {
const row = document.getElementById('att-row-' + attId);
if (row) { row.style.opacity = '0.4'; row.style.pointerEvents = 'none'; }
fetch(deleteUrl, { method: 'POST', credentials: 'same-origin' })
fetch(deleteUrl, { method: 'POST', credentials: 'same-origin', headers: { 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content } })
.then(r => r.json())
.then(data => {
if (data.ok) {
@@ -445,6 +445,7 @@ function doSave(asDraft) {
const xhr = new XMLHttpRequest();
xhr.open('POST', window.location.pathname);
xhr.withCredentials = true;
xhr.setRequestHeader('X-CSRFToken', document.querySelector('meta[name="csrf-token"]').content);
xhr.upload.onprogress = ev => {
if (ev.lengthComputable && pendingFiles.length > 0) {