rn-shiki 0.0.37-11 → 0.0.37-13
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -23,8 +23,6 @@ const styles = StyleSheet.create({
|
|
23
23
|
})
|
24
24
|
|
25
25
|
const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, languageId, theme }) => {
|
26
|
-
console.log('Received theme:', theme)
|
27
|
-
|
28
26
|
const stylesheet = useMemo(() => {
|
29
27
|
const styles = getRNStylesFromShikiStyle(theme as ReactStyle)
|
30
28
|
console.log('Generated stylesheet:', styles)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CSSProperties } from 'react'
|
2
2
|
import type { TextStyle } from 'react-native'
|
3
|
-
import transform from 'css-to-react-native'
|
3
|
+
import transform, { type StyleTuple } from 'css-to-react-native'
|
4
4
|
|
5
5
|
export interface HighlighterStyleSheet {
|
6
6
|
[key: string]: TextStyle
|
@@ -16,18 +16,15 @@ const ALLOWED_STYLE_PROPERTIES: Record<string, boolean> = {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
export function getRNStylesFromShikiStyle(shikiStyle: ReactStyle): HighlighterStyleSheet {
|
19
|
-
return Object.fromEntries(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
return Object.fromEntries(Object.entries(shikiStyle).map(([className, style]) => [className, cleanStyle(style)]))
|
20
|
+
}
|
21
|
+
|
22
|
+
export function cleanStyle(style: CSSProperties) {
|
23
|
+
const styles = Object.entries(style)
|
24
|
+
.filter(([key]) => ALLOWED_STYLE_PROPERTIES[key])
|
25
|
+
.map<StyleTuple>(([key, value]) => [key, value])
|
26
26
|
|
27
|
-
|
28
|
-
const rnStyle: TextStyle = transform(Object.entries(filteredStyle)) as TextStyle
|
27
|
+
console.log('Filtered styles:', styles) // Add this line
|
29
28
|
|
30
|
-
|
31
|
-
}),
|
32
|
-
)
|
29
|
+
return transform(styles)
|
33
30
|
}
|