-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Desktop: Fixes #6211: Try to replace the external link with internal link when attachment file is pasted in Markdown editor #6865
Conversation
|
This comment was marked as resolved.
This comment was marked as resolved.
We need a clear description of what's been fixed, and a working pr. |
I have updated the title and description of this PR. Are they correct? |
void Note.replaceResourceExternalToInternalLinks(clipboard.readText(), { useAbsolutePaths: true }) | ||
.then((modifiedMd) => { | ||
editorRef.current.replaceSelection(modifiedMd); | ||
}); |
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.
Don't use .then(), use async/await
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 don't know if my code in d9d8f60 is right. It passed the CI test, then I tested it on Ubuntu and it works as expected.
@laurent22 Hi. Is there anything I need to do? |
Thanks for fixing this, and I think that's the right fix, but I wonder if we want to support this kind of copy and paste between wysiwyg and markdown editor? Lots of other things probably don't work, such as copying tables, and it feels like the solution is simply to not do it. Why would someone want to copy from one editor to another anyway? Why not stay on the same one? |
I guess this PR can be applied to more situations. Any external links referring to something in profile(resources) directory can be converted into the internal links.
I don't know why these things won't work after merging this PR. Could you please give me more information or examples? |
Another solution is to find the resource parts in the clipboard which look like |
I mainly use WYSIWYG, but I also switch between the two when I want to add formatting that isn't available in the top bar (e.g. H4/5/6 or straight-up HTML code), and if I happen to have an image that I want to insert copied to clipboard already, I may as well paste it in the Markdown editor as well. The main problem here is probably that the non-technical user isn't really aware that such a link is absolute and device specific. With tables and other complex formatting, the user can immediately see when something isn't right. With these images, it's only after they've synced their data to another machine when they discover that the links are broken. In the worst case scenario, at that point they may not even have the original images anymore. |
I think this problem is easier to be triggered than we expected. |
Yeah, and I think another aspect which hasn't been pointed enough yet is that this issue literally causes the user to lose data (e.g. when they no longer have access to the original device and/or file). The user who has lost data due to a bug is usually a very unhappy user. |
recheck |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
Ok let's merge, this change seems relatively safe and still an improvement. Thanks for implementing this @wh201906! |
This will fix #6211. When the user copies an image from WYSIWYG editor, the clipboard will hold the absolute path of the image. The bug is when pasting it to Markdown editor, the absolute path will be pasted. Codes in this PR will try to replace the absolute path with the internal link if possible, just like copying and pasting an image in WYSIWYG editor.
I tested it on Ubuntu and the bug is fixed.
I have no idea about how to call an async function in an sync function. I just imitated the existing code. Please tell me if my code is wrong or not appropriate and I will fix it.