@idealyst/markdown 1.2.56 → 1.2.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/Markdown/Markdown.web.tsx +2 -1
- package/src/flattenStyle.ts +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/markdown",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.58",
|
|
4
4
|
"description": "Cross-platform markdown renderer and editor for React and React Native with theme integration",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@10play/tentap-editor": ">=0.5.0",
|
|
44
|
-
"@idealyst/theme": "^1.2.
|
|
44
|
+
"@idealyst/theme": "^1.2.58",
|
|
45
45
|
"@tiptap/extension-link": ">=2.0.0",
|
|
46
46
|
"@tiptap/extension-placeholder": ">=2.0.0",
|
|
47
47
|
"@tiptap/extension-task-item": ">=2.0.0",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@10play/tentap-editor": "^0.5.0",
|
|
117
|
-
"@idealyst/theme": "^1.2.
|
|
117
|
+
"@idealyst/theme": "^1.2.58",
|
|
118
118
|
"@tiptap/extension-link": "^2.11.0",
|
|
119
119
|
"@tiptap/extension-placeholder": "^2.11.0",
|
|
120
120
|
"@tiptap/extension-task-item": "^2.11.0",
|
|
@@ -5,6 +5,7 @@ import { getWebProps } from 'react-native-unistyles/web';
|
|
|
5
5
|
import { markdownStyles } from './Markdown.styles';
|
|
6
6
|
import { createWebRenderers } from '../renderers/web';
|
|
7
7
|
import type { MarkdownProps } from './types';
|
|
8
|
+
import { flattenStyle } from '../flattenStyle';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Cross-platform Markdown renderer for web.
|
|
@@ -64,7 +65,7 @@ const Markdown = forwardRef<HTMLDivElement, MarkdownProps>(
|
|
|
64
65
|
// Get web props for the container
|
|
65
66
|
const containerStyleArray = [
|
|
66
67
|
(markdownStyles.container as any)({ size, linkIntent }),
|
|
67
|
-
style,
|
|
68
|
+
flattenStyle(style),
|
|
68
69
|
];
|
|
69
70
|
const webProps = getWebProps(containerStyleArray);
|
|
70
71
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StyleProp } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Flattens a style prop (which can be a single style, an array of styles,
|
|
5
|
+
* or nested arrays) into a single style object.
|
|
6
|
+
*/
|
|
7
|
+
export function flattenStyle<T extends object>(
|
|
8
|
+
style: StyleProp<T> | React.CSSProperties | undefined
|
|
9
|
+
): React.CSSProperties {
|
|
10
|
+
if (!style) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(style)) {
|
|
15
|
+
return style.reduce<React.CSSProperties>((acc, s) => {
|
|
16
|
+
return { ...acc, ...flattenStyle(s as StyleProp<T>) };
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return style as React.CSSProperties;
|
|
21
|
+
}
|