You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-08-30] [$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy #23659
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Now use the copy to clipboard option, and copy the sent message
Paste the message in the composer and send it again (notice that there are no difference in both messages)
Now select the sent message text by cursor and press cmd+c
Paste the text in the composer and send the message.
Notice that the markdown message has an extra line in the code snippet part.
Expected Result:
Message copied from selection should be the same that that copied from context menu
Actual Result:
Message copied from selection has an extra line
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
MacOS / Chrome / Safari
MacOS / Desktop
Version Number: 1.3.45-8 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation
changed the title [-]Web - Markdown pasted from selection-copy is different from clipboard-copy[/-][+][$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/+]on Jul 27, 2023
If we paste it in the composer, above html texts will be parsed by handlePastedHTML function of ExpensiMark class and parsed text will be shown in the composer.
But through rendering of HTML content, <div> tag is appended inside <pre> and also <br> tag is inside of <div> tag.
So the end new line character won't be removed and we will see an extra line in markdown text.
What changes do you think we should make in order to solve the problem?
We should parse selection in advance, before saving it to clipboard & parsing it using htmlToMarkdown function.
We should remove the child <div> tag inside <pre> tag and the problem will be fixed.
function parseSelectionHtml(html) {
return html.replace(/<pre><div>(.*?)<\/div><\/pre>/g, (match, g1) => `<pre>${g1}</pre>`);
}
We might update this parser function for further updates related to selection, or we can add it to ExpensiMark class.
What alternative solutions did you explore? (Optional)
We can add new rule to htmlToMarkdownRules of ExpensifyMark.js directly.
So we can remove the nested tag inside <pre> tag while html selection is being parsed using htmlToMarkdown function.
📣 @akamefi202 You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
@puneetlath@mollfpr@akamefi202 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
changed the title [-][$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/-][+][HOLD for payment 2023-08-30] [$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/+]on Aug 27, 2023
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Activity
melvin-bot commentedon Jul 26, 2023
Triggered auto assignment to @puneetlath (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jul 26, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)[-]Web - Markdown pasted from selection-copy is different from clipboard-copy[/-][+][$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/+]melvin-bot commentedon Jul 27, 2023
Job added to Upwork: https://www.upwork.com/jobs/~019c94943755b5fa6d
melvin-bot commentedon Jul 27, 2023
Current assignee @puneetlath is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Jul 27, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr (
External)akamefi202 commentedon Jul 28, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
An extra line is added to the markdown text when the user copy & paste the message which contains code snippet using selection & keyboard shortcut.
What is the root cause of that problem?
If we add above message and copy it using clipboard button and keyboard shortcut each other, different html contents are saved in clipboard.
App/src/components/Composer/index.js
Lines 298 to 301 in 34d1d95
If we paste it in the composer, above html texts will be parsed by
handlePastedHTMLfunction ofExpensiMarkclass and parsed text will be shown in the composer.https://github.com/Expensify/expensify-common/blob/9940dd127c2d44809c98ee628a8057f08c93bfc9/lib/ExpensiMark.js#L322-L324
For parsing of code snippet,
handlePastedHTMLfunction adds head & tail line breaks.And it removes the new line character at the end of
<pre>tag if it exists, for preventing addition of new line characters.But through rendering of HTML content,
<div>tag is appended inside<pre>and also<br>tag is inside of<div>tag.So the end new line character won't be removed and we will see an extra line in markdown text.
What changes do you think we should make in order to solve the problem?
App/src/hooks/useCopySelectionHelper.js
Lines 8 to 9 in 975146f
We should parse
selectionin advance, before saving it to clipboard & parsing it usinghtmlToMarkdownfunction.We should remove the child
<div>tag inside<pre>tag and the problem will be fixed.We might update this parser function for further updates related to selection, or we can add it to
ExpensiMarkclass.What alternative solutions did you explore? (Optional)
We can add new rule to
htmlToMarkdownRulesofExpensifyMark.jsdirectly.So we can remove the nested tag inside
<pre>tag while html selection is being parsed usinghtmlToMarkdownfunction.puneetlath commentedon Jul 28, 2023
@mollfpr please review when you get a chance, thanks!
25 remaining items
melvin-bot commentedon Aug 8, 2023
📣 @mollfpr 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!
Offer link
Upwork job
melvin-bot commentedon Aug 8, 2023
📣 @akamefi202 You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
melvin-bot commentedon Aug 8, 2023
📣 @huzaifa-99 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!
Offer link
Upwork job
akamefi202 commentedon Aug 8, 2023
I applied to the Upwork job and I believe that the PR will be ready by tomorrow.
akamefi202 commentedon Aug 9, 2023
I updated proposal.
I added the discussed solution as alternative solution.
akamefi202 commentedon Aug 9, 2023
@mollfpr @puneetlath
PR is ready.
melvin-bot commentedon Aug 9, 2023
@puneetlath @mollfpr @akamefi202 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
melvin-bot commentedon Aug 17, 2023
Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:
On to the next one 🚀
[-][$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/-][+][HOLD for payment 2023-08-30] [$1000] Web - Markdown pasted from selection-copy is different from clipboard-copy[/+]akamefi202 commentedon Aug 30, 2023
@puneetlath @mollfpr It's Aug 30th. Could you please help me with payment? And can we close this issue now?
puneetlath commentedon Aug 30, 2023
All paid. Thanks everyone!