Changeset View
Changeset View
Standalone View
Standalone View
native/markdown/rules.react.js
// @flow | // @flow | ||||
import _memoize from 'lodash/memoize'; | import _memoize from 'lodash/memoize'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Text, View } from 'react-native'; | import { Text, View } from 'react-native'; | ||||
import { createSelector } from 'reselect'; | import { createSelector } from 'reselect'; | ||||
import * as SimpleMarkdown from 'simple-markdown'; | import * as SimpleMarkdown from 'simple-markdown'; | ||||
import { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors'; | import { relativeMemberInfoSelectorForMembersOfThread } from 'lib/selectors/user-selectors'; | ||||
import * as SharedMarkdown from 'lib/shared/markdown'; | import * as SharedMarkdown from 'lib/shared/markdown'; | ||||
import type { RelativeMemberInfo } from 'lib/types/thread-types'; | import type { RelativeMemberInfo } from 'lib/types/thread-types'; | ||||
import { useSelector } from '../redux/redux-utils'; | import { useSelector } from '../redux/redux-utils'; | ||||
import MarkdownLink from './markdown-link.react'; | import MarkdownLink from './markdown-link.react'; | ||||
import MarkdownParagraph from './markdown-paragraph.react'; | |||||
import MarkdownSpoiler from './markdown-spoiler.react'; | import MarkdownSpoiler from './markdown-spoiler.react'; | ||||
import { getMarkdownStyles } from './styles'; | import { getMarkdownStyles } from './styles'; | ||||
export type MarkdownRules = { | export type MarkdownRules = { | ||||
+simpleMarkdownRules: SharedMarkdown.ParserRules, | +simpleMarkdownRules: SharedMarkdown.ParserRules, | ||||
+emojiOnlyFactor: ?number, | +emojiOnlyFactor: ?number, | ||||
// We need to use a Text container for Entry because it needs to match up | // We need to use a Text container for Entry because it needs to match up | ||||
// exactly with TextInput. However, if we use a Text container, we can't | // exactly with TextInput. However, if we use a Text container, we can't | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | paragraph: { | ||||
}; | }; | ||||
}, | }, | ||||
// eslint-disable-next-line react/display-name | // eslint-disable-next-line react/display-name | ||||
react: ( | react: ( | ||||
node: SharedMarkdown.SingleASTNode, | node: SharedMarkdown.SingleASTNode, | ||||
output: SharedMarkdown.Output<SharedMarkdown.ReactElement>, | output: SharedMarkdown.Output<SharedMarkdown.ReactElement>, | ||||
state: SharedMarkdown.State, | state: SharedMarkdown.State, | ||||
) => ( | ) => ( | ||||
<MarkdownParagraph key={state.key} style={state.textStyle}> | <Text key={state.key} style={state.textStyle}> | ||||
{output(node.content, state)} | {output(node.content, state)} | ||||
</MarkdownParagraph> | </Text> | ||||
), | ), | ||||
}, | }, | ||||
// This is the leaf node in the AST returned by the parse phase | // This is the leaf node in the AST returned by the parse phase | ||||
text: SimpleMarkdown.defaultRules.text, | text: SimpleMarkdown.defaultRules.text, | ||||
}; | }; | ||||
return { | return { | ||||
simpleMarkdownRules, | simpleMarkdownRules, | ||||
emojiOnlyFactor: null, | emojiOnlyFactor: null, | ||||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |