@draftbit/core 50.0.2 → 50.0.3-5e5617.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "50.0.2",
3
+ "version": "50.0.3-5e5617.2+5e56173",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "types": "lib/typescript/src/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "50.0.2",
44
+ "@draftbit/types": "^50.0.3-5e5617.2+5e56173",
45
45
  "@expo/vector-icons": "^14.0.0",
46
46
  "@gorhom/bottom-sheet": "5.0.0-alpha.7",
47
47
  "@material-ui/core": "^4.11.0",
@@ -114,5 +114,5 @@
114
114
  ],
115
115
  "testEnvironment": "node"
116
116
  },
117
- "gitHead": "9e22f20c66aac16f2758fdae149f4b6d0e69f47c"
117
+ "gitHead": "5e561735e52646c219f81cfe1c8cea40dadfe948"
118
118
  }
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
- import { StyleSheet } from "react-native";
2
+ import { Text, StyleSheet, } from "react-native";
3
3
  import MarkdownComponent from "react-native-markdown-display";
4
+ import { extractStyles } from "../utilities";
4
5
  const childToString = (child) => {
5
6
  if (typeof child === "undefined" ||
6
7
  child === null ||
@@ -15,10 +16,18 @@ const childToString = (child) => {
15
16
  const Markdown = ({ children: childrenProp, style, }) => {
16
17
  const children = React.Children.toArray(childrenProp);
17
18
  const text = children.map(childToString).join("");
19
+ const bodyStyle = StyleSheet.flatten(style);
20
+ const { textStyles } = extractStyles(bodyStyle);
18
21
  return (
19
22
  //'body' style applies to all markdown components
20
23
  //@ts-ignore TS does not like the type of this named style for some reason
21
- React.createElement(MarkdownComponent, { style: { body: StyleSheet.flatten(style) } }, text));
24
+ React.createElement(MarkdownComponent, { style: { body: bodyStyle }, rules: {
25
+ // By default, strong does not work with custom fonts on iOS. This addresses the issue
26
+ strong: (node) => (React.createElement(Text, { key: node.key, style: {
27
+ ...textStyles,
28
+ fontWeight: "bold",
29
+ } }, node.children[0].content)),
30
+ } }, text));
22
31
  };
23
32
  export default Markdown;
24
33
  //# sourceMappingURL=Markdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.js","sourceRoot":"","sources":["Markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAM9D,MAAM,aAAa,GAAG,CAAC,KAAuB,EAAU,EAAE;IACxD,IACE,OAAO,KAAK,KAAK,WAAW;QAC5B,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,SAAS,EAC1B;QACA,OAAO,EAAE,CAAC;KACX;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QAClC,OAAO,EAAE,CAAC;KACX;IAED,OAAQ,KAAyB,CAAC,QAAQ,EAAE,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAqD,CAAC,EAClE,QAAQ,EAAE,YAAY,EACtB,KAAK,GACN,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAElD,OAAO;IACL,iDAAiD;IACjD,0EAA0E;IAC1E,oBAAC,iBAAiB,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAC1D,IAAI,CACa,CACrB,CAAC;AACJ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C,IAAI,IACH,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,KAAK,EAAE;oBACL,GAAG,UAAU;oBACb,UAAU,EAAE,MAAM;iBACnB,IAEA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CACpB,CACR;SACF,IAEA,IAAI,CACa,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,9 +1,16 @@
1
1
  import * as React from "react";
2
- import { StyleProp, ViewStyle, StyleSheet } from "react-native";
2
+ import {
3
+ Text,
4
+ StyleProp,
5
+ ViewStyle,
6
+ TextStyle,
7
+ StyleSheet,
8
+ } from "react-native";
3
9
  import MarkdownComponent from "react-native-markdown-display";
10
+ import { extractStyles } from "../utilities";
4
11
 
5
12
  type MarkdownProps = {
6
- style?: StyleProp<ViewStyle>;
13
+ style?: StyleProp<ViewStyle & TextStyle>;
7
14
  };
8
15
 
9
16
  const childToString = (child?: React.ReactNode): string => {
@@ -29,10 +36,29 @@ const Markdown: React.FC<React.PropsWithChildren<MarkdownProps>> = ({
29
36
  const children = React.Children.toArray(childrenProp);
30
37
  const text = children.map(childToString).join("");
31
38
 
39
+ const bodyStyle = StyleSheet.flatten(style);
40
+ const { textStyles } = extractStyles(bodyStyle);
41
+
32
42
  return (
33
43
  //'body' style applies to all markdown components
34
44
  //@ts-ignore TS does not like the type of this named style for some reason
35
- <MarkdownComponent style={{ body: StyleSheet.flatten(style) }}>
45
+ <MarkdownComponent
46
+ style={{ body: bodyStyle }}
47
+ rules={{
48
+ // By default, strong does not work with custom fonts on iOS. This addresses the issue
49
+ strong: (node) => (
50
+ <Text
51
+ key={node.key}
52
+ style={{
53
+ ...textStyles,
54
+ fontWeight: "bold",
55
+ }}
56
+ >
57
+ {node.children[0].content}
58
+ </Text>
59
+ ),
60
+ }}
61
+ >
36
62
  {text}
37
63
  </MarkdownComponent>
38
64
  );