-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[$1000] Copying code blocks from chat is broken #7644
Comments
Triggered auto assignment to @aldo-expensify ( |
Triggered auto assignment to @kevinksullivan ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane ( |
Triggered auto assignment to @iwiznia ( |
Hey, |
👋 @ihamzanizami , I suggest you read https://github.com/Expensify/App/blob/main/CONTRIBUTING.md to learn how contributors can participate and propose solutions. |
I don't understand this issue. I see that the code is pasted correctly in that video. Can someone explain the problem in more detail please? |
I understand that the problem are the line breaks. When I copy code blocks, I always have to fix line breaks manually. |
Oh, I see. FWIW it works properly if you CMD+SHIFT+V (paste without format) |
Proposalissue happend on htmlconverter . since the code block is formated with html . we can fix this by just parsing the div as new line in
+ const fixHtml = html.replaceAll('<div>', '').replaceAll('</div>', '<br/>');
- const markdownText = parser.htmlToMarkdown(html);
+ const markdownText = parser.htmlToMarkdown(fixHtml); we can fix this from the library also by edit this.
to pre: inputString => inputString .replaceAll('<div>', '').replaceAll('</div>', '<br/>')replace('<br></br>', '<br/>').replace('<br><br/>', '<br/>')
.replace(SLACK_SPAN_NEW_LINE_TAG + SLACK_SPAN_NEW_LINE_TAG, '<br/><br/><br/>').replace(SLACK_SPAN_NEW_LINE_TAG, '<br/><br/>'), |
@ahmdshrif that didn't work for me. |
We just modified the pre with this not all object |
you can apply the changes on https://github.com/Expensify/expensify-common/blob/main/lib/ExpensiMark.js#L197 {
name: 'newline',
// Replaces open and closing <br><br/> tags with a single <br/>
// Slack uses special <span> tag for empty lines instead of <br> tag
- pre: inputString => inputString.replace('<br></br>', '<br/>').replace('<br><br/>', '<br/>')
+ pre: inputString => inputString .replaceAll('<div>', '').replaceAll('</div>', '<br/>').replace('<br></br>', '<br/>').replace('<br><br/>', '<br/>')
.replace(SLACK_SPAN_NEW_LINE_TAG + SLACK_SPAN_NEW_LINE_TAG, '<br/><br/><br/>').replace(SLACK_SPAN_NEW_LINE_TAG, '<br/><br/>'),
// Include the immediately followed newline as `<br>\n` should be equal to one \n.
regex: /<br(?:"[^"]*"|'[^']*'|[^'"><])*>\n?/gi,
replacement: '\n'
},
sure we will not edit on node module but we will add the changes on expensify-common library repo but you can test on by change on node module |
@ahmdshrif yep, that's exactly what I tried. It didn't work. Btw, I'm testing by pasting this text - App/src/components/TextInputFocusable/index.js Lines 263 to 267 in 403fc28
|
@rushatgabhane ok, GitHub uses pre: inputString => inputString.replaceAll('<div>', '').replaceAll('</div>', '<br/>').replaceAll('</td></tr>', '<br/>').replace('<br></br>', '<br/>').replace('<br><br/>', '<br/>')
.replace(SLACK_SPAN_NEW_LINE_TAG + SLACK_SPAN_NEW_LINE_TAG, '<br/><br/><br/>').replace(SLACK_SPAN_NEW_LINE_TAG, '<br/><br/>'), |
@ahmdshrif thanks, that fixed it for copying form github. |
@ahmdshrif could you please repost your proposal here? And slightly customize it for this issue. |
sure @rushatgabhane so I add the regex before here and it work fine but did not work on the second issue so I replace it with some logic explained here #7352 (comment) to work with both. but we still have here another issue here when copy code form github . github use I also explain this regex and the first regex (we replace it ) on this comment #7644 (comment) as summary we will fix mapping dev on the second issue but we still need to fix copy form github buy use this regex thanks . |
🎀 👀 🎀 C+ reviewed @iwiznia I know this isn't very pretty, but the only other alternative is to use a third party markdown-html parser. But as Rory and I discussed, it's a very long term project that may or may not come into fruition. I recommend @ahmdshrif's proposal. |
Where exactly will that code go? (sorry if it is linked somewhere, but could not find it following the linked comments) Wouldn't those regexes also match other things? Like what if I am pasting an HTML string? Ie: what if what I am pasting is |
sorry @iwiznia for making it confusing when past text we check if it contains HTML format and if yes we pare it with htmlToMarkdown
so the library has its own mechanism to just pares the HTML style tags. but the issue in the library is it only maps {
name: 'newline',
// Replaces open and closing <br><br/> tags with a single <br/>
// Slack uses special <span> tag for empty lines instead of <br> tag
pre: inputString => inputString.replace('<br></br>', '<br/>').replace('<br><br/>', '<br/>')
+ .replaceAll(/(<tr.*?<\/tr>)/g,"$1<br/>")
.replace(SLACK_SPAN_NEW_LINE_TAG + SLACK_SPAN_NEW_LINE_TAG, '<br/><br/><br/>').replace(SLACK_SPAN_NEW_LINE_TAG, '<br/><br/>'),
// Include the immediately followed newline as `<br>\n` should be equal to one \n.
regex: /<br(?:"[^"]*"|'[^']*'|[^'"><])*>\n?/gi,
replacement: '\n'
},
for div handling l already implement it on this PR https://github.com/Expensify/expensify-common/pull/436/files copy form github |
Got it, thanks for clarifying! The proposal makes sense @jboniface please hire @ahmdshrif |
@jboniface the link does not work |
@ahmdshrif oops, i sent you the link for the proposal reviews 😵💫 |
no problem @jboniface 😄 |
pr ready here Expensify/expensify-common#436 |
Review almost done |
All set here, PR merged |
PR #8743 hit production 2 days ago. |
Bump @jboniface |
@rushatgabhane please apply for the C+ payment https://www.upwork.com/jobs/~0103d56637d4154cbd |
@jboniface unfortunately, that job is no longer available. |
@rushatgabhane ok, let's use this one https://www.upwork.com/jobs/~01b9b2c4c22ea68332 |
Thanks! |
@ahmdshrif has been paid (by Jeremy), is there a reason he wasn't assigned to this issue? |
@ahmdshrif was given the approval, so it's proly a small boo boo @mallenexpensify accepted, thank you! |
Paid @rushatgabhane $1k for C+ Thanks for the help y'all! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
User should be able to copy and paste code blocks
Actual Result:
What ends up being copied to your clipboard is not the content that is highlighted
Workaround:
unknown
Platform:
Where is this issue occurring?
Version Number: 1.1.37-0
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Recording.391.mp4
Expensify/Expensify Issue URL:
Issue reported by: @puneetlath
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1643914668204029
Job Post https://www.upwork.com/jobs/~0103d56637d4154cbd
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: