Migrating angular tinymce from v6 to v8 resolve is not working

Discussão em 'Angular' iniciado por Shoaib Shahid, Abril 30, 2025.

  1. I am igrating my application from angular v15 to angular v18 for that I have also updated my tinymce package. But now stuck at below. image uploader is not working

    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 a bug

    Environment

    "@tinymce/tinymce-angular": "^8.0.1",

    "@angular/cdk": "^18.2.14",

    "@angular/common": "^18.2.13",

    "@angular/compiler": "^18.2.13",

    "@angular/core": "^18.2.13",

    "@angular/forms": "^18.2.13",

    "@angular/material": "^18.2.14",

    Continue reading...

Compartilhe esta Página