Latest version not replacing url on resolve of image uploader

Đang mở
#413 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
angular, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
346
Fork
94
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tinymce/tinymce-angular

Tất cả issue của tinymce/tinymce-angular

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.