-
Notifications
You must be signed in to change notification settings - Fork 72
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
try fix 41908 #382
try fix 41908 #382
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
@badeggg Thanks for the PR! What's the expected behavior when there are spaces before the blockquote but the quote itself takes more than one line of text? Here's how it works 98d50fa and it doesn't look correctly: Screen.Recording.2024-06-12.at.12.07.11.movI think the proposed behavior of the blockquote ribbon will be difficult to implement correctly because there are numerous edge cases, e.g. nested blockquotes. Instead of that, how about we don't change the position of the blockquote ribbon and just place the additional spaces before the |
Maybe consult design team about choosing what behavior? The video you posted looks fine to me. Leading spaces that is not in blockquote line should have no effect to blockquote. I'll recheck the code logic and behavior. Thank you very much for reviewing my pr. |
cc @thienlnam @shawnborton How do you think this should behave? |
Interesting... I'm not too sure what to think, so tapping the @Expensify/design team for a second opinion. Would it make sense to only use the block quote style if the |
That's actually what we currently do and this is the exact problem reported in the original issue: Expensify/App#41908 If you type Currently, the live markdown preview doesn't recognize Also, we can't just trim the message and not convert into a blockquote, because once the message is edited, it would be converted into a blockquote even if the actual characters did not change. So, we still need to recognize the input From the technical perspective, we can't place the space characters "before" the blockquote ribbon, also this would be pretty bad UX. So the recommended solution is to place the spaces "between" the blockquote ribbon and |
Hmm but taking a step back, what is the actual use case where a user would want to put spaces before the block quote? For example, if I type |
There's no use case for adding spaces before blockquote but it doesn't mean it can't happen. The user can just type |
So I was just trying to test these situations in Slack and Github (where I use markdown the most) and I honestly don't even know what to think anymore! CleanShot.2024-06-13.at.09.34.31.mp4CleanShot.2024-06-13.at.09.35.07.mp4
Should we just keep this simple? What would be the simplest way to handle this? |
I personally think Slack's approach is the most intuitive and simplest way to handle it. |
I'm good with that. Essentially what you see is what you get. So if you start a line with |
That's what I would expect, yup! |
@dannymcclain @shawnborton Hello guys. This behavior is actually what expensify-app currently doing when the comment is in composer box, the problem is we will trim leading and trailing spaces when hit enter key. So the comment will be formatted as block quote after being sent, while not being formatted as block quote in composer box. This seems not fine. |
I thought the whole point of live markdown is that it's basically WYSIWYG - if we don't show the blockquote in the composer, let's not show it when the message is sent either. |
Should we not trim leading and trailing spaces when sending, if the comment content includes non-spaces chars? |
Make sense to me |
I'm not saying to not trim the spaces. Slack does indeed trim the spaces before hand. But it just doesn't turn it into a blockquote - it trims the spaces and then just renders the CleanShot.2024-06-13.at.17.21.19.mp4 |
If you type > Hello, once the message is sent, it will be trimmed to > Hello and converted into a blockquote. Currently, the live markdown preview doesn't recognize > Hello as a blockquote which is inconsistent with the output in chat history. Additionally, this is against our principle of not modifying the user input. I agree with others about handling it the same way slack does - if it has pre-pended spaces it will show as regular text |
This sounds good but it breaks when you consider that the message can be edited. Here's the case: Assume that the user types: " According to your idea, let's assume that we don't convert this message into a blockquote, we just trim all the leading spaces. Sent message is: "> Hello" Now, the user edits this message. It starts from ">" and there are no leading spaces so it is recognized by Live Markdown as a blockquote which is inconsistent with the sent message. The user just hits Enter without making any changes. The edited message is a blockquote so it's different than the original message, even though the user did not make any changes. When we trim the spaces before the blockquote, we lose the context. Slack stores messages as rich text so the formatting is an additional context on top of the actual text. On Slack, you can send a message "Hello world" with no asterisks and still get bold formatting. In Expensify, the messages are live markdown formatted, so there is no additional data apart from the actual text. The formatting is implied from the actual text so if the message starts with a ">", it is a blockquote. There's no way to tell that it's not a blockquote. There's no way that the same string will be recognized as two different possible formattings: Case #1: "> Hello" (as a regular string) (Actually, it's possible to distinguish these two cases in HTML which Expensify uses in the database, but the user types the message in Markdown and the messages are converted HTML->MD when they are edited and MD->HTML when they are being sent). @badeggg is right in this comment: #382 (comment) |
Let's just prevent that case from happening.
I find this a bit hard to believe personally. You are telling me that there is absolutely no way we could detect that if a user was editing a message that already started with a plain |
My proposal is that we just stop doing this since that is modifying the user input. Granted, there might be other concerns with doing this (allowing a bunch of whitespace before and after any text is sent) but it seems like that would solve the other problems here |
Agree with @thienlnam , maybe we should not trim spaces anymore, at least not trim leading spaces. Although we still need check all-spaces-comment case. |
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.
@badeggg ts is failing and there are conflicts
@luacmartins Hi, I think we should decide the expected behavior first. Seems the code changes I made is not the wanted behavior. Can you check comment history in this pr and help make a decision? |
WRT this comment, we can't just prevent it from happening for the reasons @tomekzaw described here. We can certainly prevent the no edits case, but if the user edited the message, let's say to add a
As @tomekzaw pointed out, we store the messages as plain text and html. We cannot differentiate them from plain text alone, we'd have to use the html but that comes with its own set of problems as @tomekzaw also pointed out since the user types the message in markdown, not html. I agree with @thienlnam. I think we should stop trimming spaces from messages |
Okay, to go with that solution we'll need to do a couple things
@badeggg Could you please update this PR or just create a new one with our new agreed solution, and then I will spin up a PR for you to test with? |
Agree on the steps above. |
Ok, I will check how to prevent stripping the message in the FE tomorrow. Seems we need change Expensify-App code to prevent trimming, I'll need start a new pr. |
@thienlnam @luacmartins and every one here, I have made a new pr: Expensify/App#44060 |
Can we close this PR then? @badeggg |
Ok, closing |
Details
Related Issues
$ Expensify/App#41908
proposal: Expensify/App#41908 (comment)
Manual Tests
Test in react-native-live-markdown
yarn install
cd WebExample
npm run web
yarn example start
yarn example android
yarn example start
yarn example ios
# header
, verify header style ok> quote content
, verify quote style okTest in expensify app
yarn install
npm run prepare
npm install
tmp
filetmp
file:tmp
file, change/Users/zhaoxuxu/expensify
toyour path to react-native-live-markdown
bash tmp
to copy built live-markdown files to expensify-app dependencyLinked PRs
Need change package.json version of expensify app. No pr created yet, need build react-native-live-markdown by hand and copy related files to node_modules of Expensify-App to verify.
Video evidences
ios:
ios.mov
android:
android-compressed.mov
web:
web.mov
ios-expensify:
ios-expen.mov
android-expensify:
android-expen.mov
web-expensify:
web-expen-compressed.mov