[HOLD for payment 2022-07-15] [$250] When sending text that NewDot thinks is a link, it adds the link markdown automatically and doesn't allow to edit
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Open any chat
- send safe.directory/link message
- Edit the message to remove the link
Expected Result:
User would expect it to save the text as-is and be able to remove the link
Actual Result:
App won't let user to remove the link. If I remove the [] and (http://safe.directory/) from the message and hit Save, it adds them back.
Workaround:
unknown
Platform:
Where is this issue occurring?
- Web
- iOS
- Android
- Desktop App
- Mobile Web
Version Number: 1.1.63-0 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation
https://user-images.githubusercontent.com/43995119/169213256-805d3d4e-c468-46c9-a0ca-4daddc5b9261.mp4
Expensify/Expensify Issue URL: Issue reported by: @rafecolton Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1652808490521729
Triggered auto assignment to @luacmartins (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
I think this can be external
Triggered auto assignment to @kadiealexander (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
Posted to Upwork!
https://www.upwork.com/ab/applicants/1527523209823019008/job-details https://www.upwork.com/jobs/~012f7992db0fb8f099
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (Exported)
Current assignee @luacmartins is eligible for the Exported assigner, not assigning anyone new.
https://user-images.githubusercontent.com/4989101/169474379-25c795a4-cb36-4dac-a11d-e43261cd9b3a.mov
Hi, I would like to work on this issue! The text won't be converted to link automatically!
We can skip the parsing
const parser = new ExpensiMark();
if its in editMode! Is this the expected behaviour?
@NehaSantani Thanks for the proposal. However, I think that skipping the parser would affect other styles as well (code blocks, quotes, etc) and we wouldn't want that. Let me know if that doesn't answer your question and I can try to clarify any remaining concerns.
@luacmartins Hi, I want a bit clarification on this issue!
- 1.) Do you want to remove the hyperlink styling on text after edit? Or
- 2.) you want to avoid mdText that is being displayed in input while edit is clicked.
If its a yes for 2 : Then My Proposed solution to this problem is use parser.htmlToText instead of parser.htmlToMarkdown ! Is there any specific reason we are using below line in ReportActionItemMessageEdit.js file at line no - 77
const draftMessage = parser.htmlToMarkdown(this.props.draftMessage);
Instead we can use
const draftMessage = parser.htmlToText(this.props.draftMessage);
And if its a yes for 1 : I will propose another solution for it soon!
Have attached the output for 2!
https://user-images.githubusercontent.com/4989101/169580760-31b66f41-1f17-4e5a-b5dc-1e4facbdbeca.mov
Hey @NehaSantani! Thanks for the questions.
I think the intention is 1. We want to be able to:
- Edit the comment
- Remove the link md
- When we save the edited comment, the link should be display as text (since we removed the link md).
What we have right now is that after editing, the link md is added back and the link is shown as a link instead of text.
Proposal
We should change the following: https://github.com/Expensify/App/blob/56213d07d5e10b5ecf1cb2fae2d82aff9360bb5a/src/libs/actions/Report.js#L1391-L1393 to
function editReportComment(reportID, originalReportAction, textForNewComment) {
const parser = new ExpensiMark();
const htmlForNewComment = parser.replace(textForNewComment, ["autoLink"]);
This will not run the link rule of the parser. We'll also need to change the expensify-common library so that the parser.replace function accepts a second argument with an array of rules to skip.
Following changes: https://github.com/Expensify/expensify-common/blob/237fb782678fec9542d0a2608ea18ef2302995fd/lib/ExpensiMark.js#L297-L301 to
replace(text, skippedRules = []) {
// This ensures that any html the user puts into the comment field shows as raw html
let replacedText = Str.safeEscape(text);
this.rules.filter((rule) => !skippedRules.includes(rule.name)).forEach((rule) => {
@allroundexperts the library can be found here and I believe you have access to it. Let me know if that's not the case.
@luacmartins I can access it. I'll update my proposal.
@luacmartins Updated.
Cause
We cant detect url changes.
Solution
If the original text is changed but the output is not affected, we can ignore the link conversion.
It is active only if the link has been updated and is the same as the old one.
When we add this code to line 1394, we can achieve this. let htmlForNewComment of course.
https://github.com/Expensify/App/blob/56213d07d5e10b5ecf1cb2fae2d82aff9360bb5a/src/libs/actions/Report.js#L1391-L1394
if (htmlForNewComment === originalReportAction.message[0].html && textForNewComment === originalReportAction.message[0].text) {
//alert('link not present anymore and same text show up');
parser.rules = parser.rules.map(rule => rule.name !== 'link');
htmlForNewComment = parser.replace(textForNewComment);
}
https://user-images.githubusercontent.com/6093207/169603919-37c80004-0297-4719-b1de-44ae5486c6bf.mp4
note : I just realized that he mentioned this approach actually @allroundexperts . It would be nicer if it was detected and done in this way, in my humble opinion.
You can think of it as if I didn't do proposal @luacmartins 😅 . I wrote it so that maybe I can contribute to the solution 👼 .
@NehaSantani Thanks for the proposal. However, I think that skipping the parser would affect other styles as well (code blocks, quotes, etc) and we wouldn't want that. Let me know if that doesn't answer your question and I can try to clarify any remaining concerns.
@luacmartins As directed by you, have skipped only "autolink" style while editing and not affecting other styles! However to achieve this, we need to update
-
ExpensiMark.js library file with following code
//Previously called method
replace(text) {return this.replaceSkipRules(text,[]);}
// Updated method
replaceSkipRules(text,skipRules) {
// This ensures that any html the user puts into the comment field shows as raw html
let replacedText = Str.safeEscape(text);
this.rules.forEach((rule) => {
if(skipRules.length && skipRules.includes(rule.name))
return true;
// Pre-process text before applying regex
if (rule.pre) {
replacedText = rule.pre(replacedText);
-
Call above method from Report.js as follows
function editReportComment(reportID, originalReportAction, textForNewComment) {
const parser = new ExpensiMark();
const htmlForNewComment = parser.replaceSkipRules(textForNewComment,["autolink"]);
Proposed Output :
https://user-images.githubusercontent.com/4989101/169616521-0712ca76-5b1f-4262-9c18-6f7550498322.mov
I'll try to evaluate the proposals today!
@luacmartins I going OOO on next week, so I am happy to defer this to another C+. Can you reapply exported, I am un-assigning myself here.
Current status: Proposals yet to be reviewed!
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (Exported)