rn-shiki 0.0.37-14 → 0.0.37-15
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CSSProperties } from 'react'
|
2
2
|
import type { TextStyle } from 'react-native'
|
3
|
-
import transform
|
3
|
+
import transform from 'css-to-react-native'
|
4
4
|
|
5
5
|
export interface HighlighterStyleSheet {
|
6
6
|
[key: string]: TextStyle
|
@@ -16,15 +16,20 @@ const ALLOWED_STYLE_PROPERTIES: Record<string, boolean> = {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
export function getRNStylesFromShikiStyle(shikiStyle: ReactStyle): HighlighterStyleSheet {
|
19
|
-
return Object.fromEntries(
|
20
|
-
|
19
|
+
return Object.fromEntries(
|
20
|
+
Object.entries(shikiStyle)
|
21
|
+
.map(([className, style]) => {
|
22
|
+
// Filter the styles based on allowed properties
|
23
|
+
const filteredStyle = Object.fromEntries(
|
24
|
+
Object.entries(style).filter(([property]) => ALLOWED_STYLE_PROPERTIES[property]),
|
25
|
+
)
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
.filter(([key]) => ALLOWED_STYLE_PROPERTIES[key])
|
25
|
-
.map<StyleTuple>(([key, value]) => [key, value])
|
27
|
+
// Convert the filtered style to React Native style
|
28
|
+
const rnStyle: TextStyle = transform(Object.entries(filteredStyle)) as TextStyle
|
26
29
|
|
27
|
-
|
30
|
+
console.log(`Converted style for ${className}:`, rnStyle)
|
28
31
|
|
29
|
-
|
32
|
+
return [className, rnStyle] // Return the class name and the converted style
|
33
|
+
}),
|
34
|
+
)
|
30
35
|
}
|