Latest version not replacing url on resolve of image uploader
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- angular, typescript
- Domain
- frontend
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 346
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tinymce/tinymce-angular
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
tinymce/tinymce-angular#425 · 4 comments ·
-
Excessive nested span tags generated when repeatedly copy-pasting text with white background color Openneeds: more info
Difficulty 4/5 3-5 days Newbie friendliness 38/100
tinymce/tinymce-angular#420 · 1 comment ·
-
needs: more info
Difficulty 4/5 3-5 days Newbie friendliness 42/100
tinymce/tinymce-angular#412 · 3 comments ·
-
GitHub status: escalated
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tinymce/tinymce-angular#167 · 11 comments · 1 reaction ·
All issues in tinymce/tinymce-angular
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·