Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import React from 'react';
import type {StyleProp, TextStyle} from 'react-native';
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
import {TNodeChildrenRenderer} from 'react-native-render-html';
import * as HTMLEngineUtils from '@components/HTMLEngineProvider/htmlEngineUtils';
import Text from '@components/Text';
import useThemeStyles from '@hooks/useThemeStyles';

function StrongRenderer({tnode}: CustomRendererProps<TText | TPhrasing>) {
function StrongRenderer({tnode, TDefaultRenderer, style, ...props}: CustomRendererProps<TText | TPhrasing>) {
const styles = useThemeStyles();
const isChildOfTaskTitle = HTMLEngineUtils.isChildOfTaskTitle(tnode);

return 'data' in tnode ? (
<Text style={[styles.webViewStyles.baseFontStyle, styles.strong, isChildOfTaskTitle && styles.taskTitleMenuItem]}>{tnode.data}</Text>
) : (
<TNodeChildrenRenderer
return (
<TDefaultRenderer
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
tnode={tnode}
renderChild={(props) => {
return (
<Text
style={[styles.webViewStyles.baseFontStyle, styles.strong, isChildOfTaskTitle && styles.taskTitleMenuItem]}
key={props.key}
>
{props.childElement}
</Text>
);
}}
style={[style as StyleProp<TextStyle>, isChildOfTaskTitle && styles.taskTitleMenuItem, {fontStyle: (style.fontStyle as TextStyle['fontStyle']) ?? 'normal'}]}
/>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ const webViewStyles = (theme: ThemeColors) =>
fontStyle: FontUtils.fontFamily.platform.EXP_NEUE_ITALIC.fontStyle,
},

strong: {
// We set fontFamily and fontWeight directly in order to avoid overriding fontStyle.
fontFamily: FontUtils.fontFamily.platform.EXP_NEUE_BOLD.fontFamily,
fontWeight: FontUtils.fontFamily.platform.EXP_NEUE_BOLD.fontWeight,
},

del: {
textDecorationLine: 'line-through',
textDecorationStyle: 'solid',
Expand Down