-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Chore: Migrate Markdown to Typescript #3558
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b184147
Chore: Migrate Markdown to TS
reinaldonetof 7ed8fa0
Chore: Migrate Markdown to TS
reinaldonetof e74cb27
Merge branch 'chore.ts-markdown' of https://github.com/RocketChat/Roc…
reinaldonetof 1b586c3
minor tweak
reinaldonetof e621168
added preview where markdown was preview and fixed params within mark…
reinaldonetof 1963fd3
removed ts-ignore
reinaldonetof a038877
fix lint
reinaldonetof c3ca845
removed numbersofline={0} and default value to numberOfLines=1
reinaldonetof d4778d7
change how to import markdown preview and remove numberOfLines
reinaldonetof 796a072
using useTheme inside markdownPreview and remove theme from components
reinaldonetof 962fc5e
minor tweak on interfaces
reinaldonetof 3e0a4ee
isNewMarkdown return as boolean
reinaldonetof 12660f6
minor tweaks
reinaldonetof 80531c7
minor tweaks
reinaldonetof f2158be
removed unused component
reinaldonetof d75e501
fixed markdown stories
reinaldonetof 22ad55d
updated snapshot because removed numberOfLines={0} from message/content
reinaldonetof 29ef469
create IEmoji.ts in definitions and refactor all places where getCust…
reinaldonetof 901da12
onLinkPress typed
reinaldonetof bfd2796
todo: refactor navtoroominfo
reinaldonetof 9e043cc
formatText.test.ts
reinaldonetof d004018
markdown stories to typescript too
reinaldonetof 0663b44
minor tweak
reinaldonetof 9f02b40
IMessage definition
reinaldonetof f9131ac
Merge branch 'develop' into chore.ts-markdown
AlexAlexandre e82ea64
refactor: update new types and interfaces for use ISubscription
AlexAlexandre 4f92934
Merge branch 'develop' into chore.ts-markdown
AlexAlexandre 6e1b4fb
refactor: update threadItem for use new MarkdownPreview
AlexAlexandre f58567b
refactor: rollback wrong file commited
AlexAlexandre fde7c0d
Merge branch 'develop' into chore.ts-markdown
reinaldonetof 3233cee
formatHyperlink
reinaldonetof 94aa322
Merge branch 'develop' into chore.ts-markdown
reinaldonetof d9608ff
fix lint
reinaldonetof ecc3e6d
updated item story shot
reinaldonetof a8a3d4f
Merge branch 'develop' into chore.ts-markdown
reinaldonetof 01cf44c
refactor and refactor some types
reinaldonetof ddbbdfb
Remove non-null assertion
diegolmello ad59a7a
Minor change on useRealName
diegolmello d6768d7
Merge branch 'develop' into chore.ts-markdown
reinaldonetof 384fe68
tweak
reinaldonetof 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import React from 'react'; | ||
| import { Text, TextStyle } from 'react-native'; | ||
| import { Text, TextStyle, StyleProp } from 'react-native'; | ||
|
|
||
| import { themes } from '../../constants/colors'; | ||
| import { useTheme } from '../../theme'; | ||
|
|
@@ -8,8 +8,8 @@ import styles from './styles'; | |
| interface IHashtag { | ||
| hashtag: string; | ||
| navToRoomInfo: Function; | ||
| style?: TextStyle[]; | ||
| channels: { | ||
| style?: StyleProp<TextStyle>[]; | ||
| channels?: { | ||
| [index: number]: string | number; | ||
| name: string; | ||
| _id: number; | ||
|
|
@@ -23,7 +23,7 @@ const Hashtag = React.memo(({ hashtag, channels, navToRoomInfo, style = [] }: IH | |
| const index = channels?.findIndex(channel => channel.name === hashtag); | ||
| const navParam = { | ||
| t: 'c', | ||
| rid: channels[index]._id | ||
| rid: channels?.[index!]._id | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might crash our app. |
||
| }; | ||
| navToRoomInfo(navParam); | ||
| }; | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
| import React from 'react'; | ||
| import { StyleProp, Text, TextStyle } from 'react-native'; | ||
| import removeMarkdown from 'remove-markdown'; | ||
|
|
||
| import shortnameToUnicode from '../../utils/shortnameToUnicode'; | ||
| import { themes } from '../../constants/colors'; | ||
| import { formatText } from './formatText'; | ||
| import styles from './styles'; | ||
|
|
||
| interface IPreview { | ||
| msg: string; | ||
| numberOfLines: number; | ||
| theme: string; | ||
| testID?: string; | ||
| style?: StyleProp<TextStyle>[]; | ||
| } | ||
|
|
||
| const Preview = ({ msg, numberOfLines, testID, theme, style = [] }: IPreview): JSX.Element => { | ||
|
reinaldonetof marked this conversation as resolved.
Outdated
reinaldonetof marked this conversation as resolved.
Outdated
|
||
| if (!msg) { | ||
| return <></>; | ||
| } | ||
|
|
||
| let m = formatText(msg); | ||
|
|
||
| // Ex: '[ ](https://open.rocket.chat/group/test?msg=abcdef) Test' | ||
| // Return: 'Test' | ||
| m = m.replace(/^\[([\s]*)\]\(([^)]*)\)\s/, '').trim(); | ||
|
reinaldonetof marked this conversation as resolved.
Outdated
|
||
| m = shortnameToUnicode(m); | ||
| // Removes sequential empty spaces | ||
| m = m.replace(/\s+/g, ' '); | ||
| m = removeMarkdown(m); | ||
| m = m.replace(/\n+/g, ' '); | ||
| return ( | ||
| <Text | ||
| accessibilityLabel={m} | ||
| style={[styles.text, { color: themes[theme].bodyText }, ...style]} | ||
| numberOfLines={numberOfLines} | ||
| testID={testID}> | ||
| {m} | ||
| </Text> | ||
| ); | ||
| }; | ||
|
|
||
| export default Preview; | ||
|
reinaldonetof marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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,6 @@ | ||
| // Support <http://link|Text> | ||
| export const formatText = (text: string) => | ||
|
dnlsilva marked this conversation as resolved.
Outdated
|
||
| text.replace( | ||
| new RegExp('(?:<|<)((?:https|http):\\/\\/[^\\|]+)\\|(.+?)(?=>|>)(?:>|>)', 'gm'), | ||
| (match, url, title) => `[${title}](${url})` | ||
| ); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.