Fix article editor
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user