-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add thumbnail to dropzone when pasting images in to comments #20147
Conversation
Codecov Report
@@ Coverage Diff @@
## main #20147 +/- ##
=======================================
Coverage ? 46.93%
=======================================
Files ? 973
Lines ? 134788
Branches ? 0
=======================================
Hits ? 63265
Misses ? 63772
Partials ? 7751 Continue to review full report at Codecov.
|
Doesn't describe what this PR is doing and what it is fixing. Please update your description to make this clearer. I've done this for you. |
Thank you very much |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take a look at this later (and make some changes). For exmplae:
this.element.parentElement.parentElement.querySelector('textarea')._data_easyMDE;
, is not ideal to access the internal member, there was a helper function (getAttachedEasyMDE
).
And the duplicate code like dropzone.dropzone.emit
could be removed after #19776 .
And there are two different editors, one is EasyMDE, one is textarea, I do not think editor.value(editor.value().replace(oldval, ''));
is suitable for both of them (maybe it's suitable, I will confirm later ... 😊)
I made some changes:
Although there are still TODOs, I have left comments there. I think this PR has done what it should do. |
# Conflicts: # web_src/js/features/comp/ImagePaste.js # web_src/js/features/repo-legacy.js
Hmm ... still some tricky bugs. I think I have fixed most of them and tested these pages: comment (new/edit), pull-request (new/edit/approve), release edit. Almost done from my side. If no objection, I could vote a L-G-T-M after several days. |
gitea/web_src/js/features/repo-legacy.js Line 414 in f07b0de
Maybe this is the event that triggers the removal of the file. If the pages are all refreshed, is this reload required? |
Some Some trivial logics here are still not 100% correct, but they were there and could be considered as out scope of this PR, so I think this PR is enough at the moment. Feel free to do more tests to see whether everything works. FYI, the editor related pages are (IIRC):
(and every EasyMDE editor has simple textarea mode) |
I tried to change it to use the dropzone upload method directly, and at the same time add a drag and drop event in the input window, and attach the demo video and patch Screen.Recording.2022-06-29.at.23.13.18.mov |
Hi @wxiaoguang any suggestions? |
I haven't got time to test your new patch. Since the insert code changes again, have you tested it with simple textarea mode? Update: maybe you can propose a new PR (to replace this one) for supporting dragdrop uploading and use it to replace legacy pasting uploading. |
The simple text area mode can be uploaded normally, but the link of the attachment is not pasted to text area, I am researching this problem, thank you |
So don't want this PR anymore? close it? |
I created a new PR #20263, so close this |
Maybe we can take this one first, IIRC I might have fixed the bug in this PR: The new PR (#20263 (comment)) is much more complex and I'm afraid it will be too difficult to maintain in the future, and I haven't got time to test or optimize it. |
Close #24195 Some of the changes are taken from my another fix f07b0de in #20147 (although that PR was discarded ....) The bug is: 1. The old code doesn't handle `removedfile` event correctly 2. The old code doesn't provide attachments for type=CommentTypeReview This PR doesn't intend to refactor the "upload" code to a perfect state (to avoid making the review difficult), so some legacy styles are kept. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
When pasting images into comment with an attached dropzone, add a thumbnail into the dropzone area.
Closes #20130