Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Latest version not replacing url on resolve of image uploader

Aperta
#413 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
angular, typescript
Ambito
frontend

Direzione di ricerca

Start with the image uploader callback shown in the issue and compare the earlier success/failure handler with the newer Promise-based handler. Verify how the resolved URL is consumed by the TinyMCE Angular integration, using the logged response URL and the hard-coded resolved URL as test cases. Done means the uploaded image URL is placed in the editor after the Promise resolves.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

the below function was working fine

function (blobInfo, success, failure) {
const xhr = new XMLHttpRequest();
xhr.open('POST', ${environment.SITE_BASE_URL}filemanager/filemanager/upload.php);
xhr.onload = function () {
if (xhr.status !== 200) {
failure('HTTP Error: ' + xhr.status);
return;
}
const json = JSON.parse(xhr.responseText);
if (!json?.files[0]?.url) {
failure('Invalid JSON: ' + xhr.responseText);
return;
}
success(json?.files[0]?.url);
};
xhr.onerror = function () {
failure('Image upload failed due to a XHR error');
};

    const formData = new FormData();
    formData.append('files[]', blobInfo.blob(), blobInfo.filename());
    formData.append('fldr', '');
    xhr.withCredentials = true;
    xhr.send(formData);
  }

In latest version I replace the above with below

(blobInfo, progress) => new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', ${environment.SITE_BASE_URL}filemanager/filemanager/upload.php);

      xhr.onload = () => {
        if (xhr.status !== 200) {
          reject('HTTP Error: ' + xhr.status);
          return;
        }

        const json = JSON.parse(xhr.responseText);
        console.log(json);
        if (!json?.files[0]?.url) {
          reject('Invalid JSON: ' + xhr.responseText);
          return;
        }

        console.log(json?.files[0]?.url);
        resolve('https://apiss.kualiteestaging.com/files/mceclip1.png');
      };

      xhr.onerror = (error) => {
        console.log(error);
        reject('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
      };

      const formData = new FormData();
      formData.append('fldr', '');
      formData.append('files[]', blobInfo.blob(), blobInfo.filename());

      xhr.send(formData);
    })

but on resolving the url is not getting placed but it was happening with first version. Is I am doing something wrong or missing or its abug

Lingua principale
TypeScript
Stelle
346
Fork
94
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tinymce/tinymce-angular

Tutte le issue di tinymce/tinymce-angular

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.