-
Notifications
You must be signed in to change notification settings - Fork 65
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
Implement code and pre blocks support on web #341
Conversation
@@ -49,12 +52,17 @@ function addStyling(targetElement: HTMLElement, type: MarkdownType, markdownStyl | |||
}); | |||
break; | |||
case 'code': | |||
Object.assign(node.style, markdownStyle.code); | |||
Object.assign(node.style, {...markdownStyle.code, lineHeight: 1.4}); |
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 believe this is something we should discuss. We can't set the display to inline-block
or block
because it will break how we are positioning inline-code blocks.
Since we're not able to do so margin won't work on inline-code block. That's why I decided to set the line-height to 1.4 - In my opinion it looks alright but let me know what do you think 😄
Found a couple of bugs while testing: 1. It's impossible to remove the newline between the first syntax `backticks` and `code block`Screen.Recording.2024-05-09.at.09.35.48.mov2. After removing whole content from code block, there are some new lines addedScreen.Recording.2024-05-09.at.09.44.26.mov3. Strange selection behavior when trying to select whole `codeblock`Screen.Recording.2024-05-09.at.09.46.43.mov4. Cursor is wrongly positioned when removing syntax backticks at the end of `codeblock`Screen.Recording.2024-05-09.at.09.51.02.mov |
The bugs that I previously reported have been fixed, thank you! After your changes I've only found the problem with cursor positioning when entering newline after first backticks: Videohttps://github.com/Expensify/react-native-live-markdown/assets/39538890/beeed721-10ae-49a6-8727-cda96d746bfd |
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.
Left some questions and comments, but overall looks good
Hi, when testing I found a problem with cursor positioning when writing on Firefox: Screen.Recording.2024-06-04.at.09.09.35.mov |
Firefox: after pasting code block text is still highlighted Test string
Screen.Recording.2024-06-04.at.09.29.51.mov |
This is related to a regression caused by another PR - we'll work on solving it in another issue |
Details
Adds support for displaying and customising code and pre blocks on web.
Related Issues
GH_LINK
Manual Tests
codeFence
in ExpensiMark to /(```(?:\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?```(?!`))[\S])+\s*?(?:\r\n|\n))(```)/gnpm run build
in/parser
Linked PRs