diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.native.tsx
similarity index 78%
rename from src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer.tsx
rename to src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.native.tsx
index 57ce739d9cc5..91c2fda556b4 100644
--- a/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer.tsx
+++ b/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.native.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import {View} from 'react-native';
import {splitBoxModelStyle} from 'react-native-render-html';
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
import * as HTMLEngineUtils from '@components/HTMLEngineProvider/htmlEngineUtils';
@@ -32,13 +33,15 @@ function CodeRenderer({TDefaultRenderer, key, style, ...defaultRendererProps}: C
};
return (
-
+
+
+
);
}
diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.tsx
new file mode 100644
index 000000000000..e150a0123ef4
--- /dev/null
+++ b/src/components/HTMLEngineProvider/HTMLRenderers/CodeRenderer/index.tsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import { splitBoxModelStyle } from 'react-native-render-html';
+import type { CustomRendererProps, TPhrasing, TText } from 'react-native-render-html';
+import * as HTMLEngineUtils from '@components/HTMLEngineProvider/htmlEngineUtils';
+import InlineCodeBlock from '@components/InlineCodeBlock';
+import useStyleUtils from '@hooks/useStyleUtils';
+import FontUtils from '@styles/utils/FontUtils';
+
+type CodeRendererProps = CustomRendererProps & {
+ /** Key of the element */
+ key?: string;
+};
+
+function CodeRenderer({ TDefaultRenderer, key, style, ...defaultRendererProps }: CodeRendererProps) {
+ const StyleUtils = useStyleUtils();
+ // We split wrapper and inner styles
+ // "boxModelStyle" corresponds to border, margin, padding and backgroundColor
+ const { boxModelStyle, otherStyle: textStyle } = splitBoxModelStyle(style ?? {});
+
+ /** Get the default fontFamily variant */
+ const font = FontUtils.fontFamily.platform.MONOSPACE.fontFamily;
+
+ // Determine the font size for the code based on whether it's inside an H1 element.
+ const isInsideH1 = HTMLEngineUtils.isChildOfH1(defaultRendererProps.tnode);
+
+ const fontSize = StyleUtils.getCodeFontSize(isInsideH1);
+
+ const textStyleOverride = {
+ fontSize,
+ fontFamily: font,
+ };
+
+ return (
+
+ );
+}
+
+CodeRenderer.displayName = 'CodeRenderer';
+
+export default CodeRenderer;
diff --git a/src/components/InlineCodeBlock/index.native.tsx b/src/components/InlineCodeBlock/index.native.tsx
index 7a896dc25088..290952d690d3 100644
--- a/src/components/InlineCodeBlock/index.native.tsx
+++ b/src/components/InlineCodeBlock/index.native.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import {View} from 'react-native';
import type {TDefaultRendererProps} from 'react-native-render-html';
import Text from '@components/Text';
import type InlineCodeBlockProps from './types';
@@ -27,7 +28,9 @@ function InlineCodeBlock({TDefaultRenderer,
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
>
- {data}
+
+ {data}
+
);
}