-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Live Markdown Preview #34292
Merged
thienlnam
merged 7 commits into
Expensify:main
from
software-mansion-labs:@tomekzaw/live-markdown
Feb 1, 2024
Merged
Live Markdown Preview #34292
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
50c5f81
Live Markdown Preview
tomekzaw 5ed7798
Merge branch 'main' into @tomekzaw/live-markdown
tomekzaw 908dbb9
Re-run tests
tomekzaw f3f778f
Merge branch 'main' into @tomekzaw/live-markdown
tomekzaw f475b98
Merge branch 'main' into @tomekzaw/live-markdown
tomekzaw d768bee
Merge branch 'main' into @tomekzaw/live-markdown
tomekzaw e8c51e2
Merge branch 'main' into @tomekzaw/live-markdown
tomekzaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
}, | ||
"dependencies": { | ||
"@dotlottie/react-player": "^1.6.3", | ||
"@expensify/react-native-live-markdown": "git+ssh://[email protected]/Expensify/react-native-live-markdown.git#c316611781f19815caebfed5540e0faf2a274785", | ||
"@expo/metro-runtime": "~3.1.1", | ||
"@formatjs/intl-datetimeformat": "^6.10.0", | ||
"@formatjs/intl-getcanonicallocales": "^2.2.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type {MarkdownStyle} from '@expensify/react-native-live-markdown'; | ||
import {useMemo} from 'react'; | ||
import FontUtils from '@styles/utils/FontUtils'; | ||
import variables from '@styles/variables'; | ||
import useTheme from './useTheme'; | ||
|
||
function useMarkdownStyle(): MarkdownStyle { | ||
const theme = useTheme(); | ||
|
||
const markdownStyle = useMemo( | ||
() => ({ | ||
syntax: { | ||
color: theme.syntax, | ||
}, | ||
link: { | ||
color: theme.link, | ||
}, | ||
h1: { | ||
fontSize: variables.fontSizeh1, | ||
}, | ||
blockquote: { | ||
borderColor: theme.border, | ||
borderWidth: 4, | ||
marginLeft: 0, | ||
paddingLeft: 6, | ||
}, | ||
code: { | ||
fontFamily: FontUtils.fontFamily.platform.MONOSPACE, | ||
color: theme.text, | ||
backgroundColor: 'transparent', | ||
}, | ||
pre: { | ||
fontFamily: FontUtils.fontFamily.platform.MONOSPACE, | ||
color: theme.text, | ||
backgroundColor: 'transparent', | ||
}, | ||
mentionHere: { | ||
color: theme.ourMentionText, | ||
backgroundColor: theme.ourMentionBG, | ||
}, | ||
mentionUser: { | ||
color: theme.mentionText, | ||
backgroundColor: theme.mentionBG, | ||
}, | ||
}), | ||
[theme], | ||
); | ||
|
||
return markdownStyle; | ||
} | ||
|
||
export default useMarkdownStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Blockquote element has style of
inline-block
which is forcing cursor to be inside of this block and overlap with characters. We solved this by addingpadding-right
so that cursor has some space for itselfThere 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.
FYI
paddingRight
is a no-op on mobile (Android & iOS), it works only on web.