@novastera-oss/react-native-markdown-display 8.0.1 → 8.1.0

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/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # React Native Markdown Display
2
2
 
3
- It a 100% compatible CommonMark renderer, a react-native markdown renderer done right. This is __not__ a web-view markdown renderer but a renderer that uses native components for all its elements. These components can be overwritten and styled as needed.
4
-
5
- ### Compatibility with react-native-markdown-renderer
6
-
7
- This is intended to be a replacement for react-native-markdown-renderer, with a variety of bug fixes and enhancements - **Due to how the new style rules work, there may be some tweaking needed**, [see how to style stuff section below](#How-to-style-stuff)
3
+ It is a CommonMark-compatible React Native markdown renderer that uses native components rather than a web view. Maintained by Novastera, an open-source CRM/ERP platform, it is designed to be easy to theme and extend.
8
4
 
9
5
  ### Install
10
6
 
@@ -37,7 +33,7 @@ const copy = `# h1 Heading 8-)
37
33
  This is normal text
38
34
  `;
39
35
 
40
- const App: () => React$Node = () => {
36
+ const App: () => React.ReactNode = () => {
41
37
  return (
42
38
  <>
43
39
  <StatusBar barStyle="dark-content" />
@@ -66,9 +62,9 @@ The `<Markdown>` object takes the following common props:
66
62
  | Property | Default | Required | Description
67
63
  | --- | --- | --- | ---
68
64
  | `children` | N/A | `true` | The markdown string to render, or the [pre-processed tree](#pre-processing)
69
- | `style` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/styles.js) | `false` | An object to override the styling for the various rules, [see style section below](#rules-and-styles) for more info
65
+ | `style` | [source](https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/styles.ts) | `false` | An object to override the styling for the various rules, [see style section below](#rules-and-styles) for more info
70
66
  | `mergeStyle` | `true` | `false` | If true, when a style is supplied, the individual items are merged with the default styles instead of overwriting them
71
- | `rules` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js) | `false` | An object of rules that specify how to render each markdown item, [see rules section below](#rules) for more info
67
+ | `rules` | [source](https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx) | `false` | An object of rules that specify how to render each markdown item, [see rules section below](#rules) for more info
72
68
  | `onLinkPress` | `import { Linking } from 'react-native';` and `Linking.openURL(url);` | `false` | A handler function to change click behaviour, [see handling links section below](#handling-links) for more info
73
69
  | `debugPrintTree` | `false` | `false` | Will print the AST tree to the console to help you see what the markdown is being translated to
74
70
 
@@ -101,7 +97,7 @@ And some additional, less used options:
101
97
 
102
98
  | iOS | Android
103
99
  | --- | ---
104
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-1.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-1.png"/>
100
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-1.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-1.png"/>
105
101
 
106
102
  </p>
107
103
  </details>
@@ -123,7 +119,7 @@ And some additional, less used options:
123
119
 
124
120
  | iOS | Android
125
121
  | --- | ---
126
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-2.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-2.png"/>
122
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-2.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-2.png"/>
127
123
 
128
124
 
129
125
  </p>
@@ -148,7 +144,7 @@ And some additional, less used options:
148
144
 
149
145
  | iOS | Android
150
146
  | --- | ---
151
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-4.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-4.png"/>
147
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-4.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-4.png"/>
152
148
 
153
149
  </p>
154
150
  </details>
@@ -165,7 +161,7 @@ And some additional, less used options:
165
161
 
166
162
  | iOS | Android
167
163
  | --- | ---
168
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-5.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-5.png"/>
164
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-5.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-5.png"/>
169
165
 
170
166
  </p>
171
167
  </details>
@@ -199,7 +195,7 @@ And some additional, less used options:
199
195
 
200
196
  | iOS | Android
201
197
  | --- | ---
202
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-6.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-6.png"/>
198
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-6.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-6.png"/>
203
199
 
204
200
  </p>
205
201
  </details>
@@ -238,7 +234,7 @@ And some additional, less used options:
238
234
 
239
235
  | iOS | Android
240
236
  | --- | ---
241
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-7.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-7.png"/>
237
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-7.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-7.png"/>
242
238
 
243
239
  </p>
244
240
  </details>
@@ -265,7 +261,7 @@ And some additional, less used options:
265
261
 
266
262
  | iOS | Android
267
263
  | --- | ---
268
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-8.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-8.png"/>
264
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-8.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-8.png"/>
269
265
 
270
266
  </p>
271
267
  </details>
@@ -283,7 +279,7 @@ And some additional, less used options:
283
279
 
284
280
  | iOS | Android
285
281
  | --- | ---
286
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-9.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-9.png"/>
282
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-9.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-9.png"/>
287
283
 
288
284
  </p>
289
285
  </details>
@@ -291,6 +287,8 @@ And some additional, less used options:
291
287
  <details><summary>Images</summary>
292
288
  <p>
293
289
 
290
+ You can pass image attributes (e.g. `width`, `height`, `contentFit`, `contentPosition`) via markdown-it attributes or HTML to map onto Expo Image props.
291
+
294
292
  ```
295
293
  ![Minion](https://octodex.github.com/images/minion.png)
296
294
  ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg "The Stormtroopocat")
@@ -306,7 +304,7 @@ And some additional, less used options:
306
304
 
307
305
  | iOS | Android
308
306
  | --- | ---
309
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-10.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-10.png"/>
307
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-10.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-10.png"/>
310
308
 
311
309
  </p>
312
310
  </details>
@@ -329,7 +327,7 @@ And some additional, less used options:
329
327
 
330
328
  | iOS | Android
331
329
  | --- | ---
332
- | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-3.png"/> | <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-3.png"/>
330
+ | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/ios-3.png"/> | <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/android-3.png"/>
333
331
 
334
332
  </p>
335
333
  </details>
@@ -365,7 +363,7 @@ const copy = `
365
363
  @[youtube](lJIrF4YjHfQ)
366
364
  `;
367
365
 
368
- const App: () => React$Node = () => {
366
+ const App: () => React.ReactNode = () => {
369
367
  return (
370
368
  <>
371
369
  <StatusBar barStyle="dark-content" />
@@ -431,7 +429,7 @@ const copy = `
431
429
  @[youtube](lJIrF4YjHfQ)
432
430
  `;
433
431
 
434
- const App: () => React$Node = () => {
432
+ const App: () => React.ReactNode = () => {
435
433
  return (
436
434
  <>
437
435
  <StatusBar barStyle="dark-content" />
@@ -729,7 +727,7 @@ Think of the implementation like applying styles in CSS. changes to the `body` e
729
727
  <details><summary>Example</summary>
730
728
  <p>
731
729
 
732
- <img src="https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/style-example.png"/>
730
+ <img src="https://github.com/novastera/react-native-markdown-display/raw/master/doc/images/style-example.png"/>
733
731
 
734
732
  ```jsx
735
733
  import React from 'react';
@@ -755,7 +753,7 @@ and some more small text
755
753
  ### this is a h3
756
754
  `;
757
755
 
758
- const App: () => React$Node = () => {
756
+ const App: () => React.ReactNode = () => {
759
757
  return (
760
758
  <>
761
759
  <StatusBar barStyle="dark-content" />
@@ -844,7 +842,7 @@ const copy = `
844
842
  | ext | extension to be used for dest files. |
845
843
  `;
846
844
 
847
- const App: () => React$Node = () => {
845
+ const App: () => React.ReactNode = () => {
848
846
  return (
849
847
  <>
850
848
  <StatusBar barStyle="dark-content" />
@@ -872,7 +870,7 @@ export default App;
872
870
 
873
871
  ### Rules
874
872
 
875
- Rules are used to specify how you want certain elements to be displayed. The existing implementation is [here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)
873
+ Rules are used to specify how you want certain elements to be displayed. The existing implementation is here: https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx
876
874
 
877
875
  <details><summary>Example Implementation</summary>
878
876
  <p>
@@ -910,7 +908,7 @@ const copy = `
910
908
  | ext | extension to be used for dest files. |
911
909
  `;
912
910
 
913
- const App: () => React$Node = () => {
911
+ const App: () => React.ReactNode = () => {
914
912
  return (
915
913
  <>
916
914
  <StatusBar barStyle="dark-content" />
@@ -992,7 +990,7 @@ import { SafeAreaView, ScrollView, StatusBar } from 'react-native';
992
990
 
993
991
  import Markdown from '@novastera-oss/react-native-markdown-display';
994
992
 
995
- const copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;
993
+ const copy = `[This is a link!](https://novastera.com)`;
996
994
 
997
995
  const onLinkPress = (url) => {
998
996
  if (url) {
@@ -1005,7 +1003,7 @@ const onLinkPress = (url) => {
1005
1003
  return true
1006
1004
  }
1007
1005
 
1008
- const App: () => React$Node = () => {
1006
+ const App: () => React.ReactNode = () => {
1009
1007
  return (
1010
1008
  <>
1011
1009
  <StatusBar barStyle="dark-content" />
@@ -1034,7 +1032,7 @@ export default App;
1034
1032
  <details><summary>Using a Custom Rule</summary>
1035
1033
  <p>
1036
1034
 
1037
- You will need to overwrite one or both of `link` and `blocklink`, the original defenitions can be [found here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)
1035
+ You will need to overwrite one or both of `link` and `blocklink`, the original definitions can be found here: https://github.com/novastera/react-native-markdown-display/blob/master/src/lib/renderRules.tsx
1038
1036
 
1039
1037
  Something like this with `yourCustomHandlerFunctionOrLogicHere`:
1040
1038
 
@@ -1044,7 +1042,7 @@ import { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';
1044
1042
 
1045
1043
  import Markdown from '@novastera-oss/react-native-markdown-display';
1046
1044
 
1047
- const copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;
1045
+ const copy = `[This is a link!](https://novastera.com)`;
1048
1046
 
1049
1047
  const rules = {
1050
1048
  link: (node, children, parent, styles) => {
@@ -1056,7 +1054,7 @@ const rules = {
1056
1054
  },
1057
1055
  };
1058
1056
 
1059
- const App: () => React$Node = () => {
1057
+ const App: () => React.ReactNode = () => {
1060
1058
  return (
1061
1059
  <>
1062
1060
  <StatusBar barStyle="dark-content" />
@@ -1085,7 +1083,7 @@ export default App;
1085
1083
 
1086
1084
  # Disabling Specific Types of Markdown
1087
1085
 
1088
- You can dissable any type of markdown you want, which is very useful in a mobile environment, by passing the markdownit property like below. Note that for convenience we also export the `MarkdownIt` instance so you don't have to include it as a project dependency directly just to remove some types of markdown.
1086
+ You can disable any type of markdown you want, which is very useful in a mobile environment, by passing the markdownit property like below. Note that for convenience we also export the `MarkdownIt` instance so you don't have to include it as a project dependency directly just to remove some types of markdown.
1089
1087
 
1090
1088
  This example will stop images and links.
1091
1089
 
@@ -1101,7 +1099,7 @@ const copy = `
1101
1099
  [but this link will just](be displayed as this text)
1102
1100
  `;
1103
1101
 
1104
- const App: () => React$Node = () => {
1102
+ const App: () => React.ReactNode = () => {
1105
1103
  return (
1106
1104
  <>
1107
1105
  <StatusBar barStyle="dark-content" />
@@ -1126,12 +1124,12 @@ const App: () => React$Node = () => {
1126
1124
  export default App;
1127
1125
  ```
1128
1126
 
1129
- A full list of things you can turn off is [here](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js)
1127
+ A full list of things you can turn off lives in the markdown-it CommonMark preset (the preset list may move across releases). You can also configure this renderer by supplying your own markdown-it instance; see the markdown-it docs for preset and rule options: https://github.com/markdown-it/markdown-it
1130
1128
 
1131
1129
 
1132
1130
  ### Pre Processing
1133
1131
 
1134
- It is possible to need to pre-process the data outside of this library ([related discussion here](https://github.com/iamacup/react-native-markdown-display/issues/79)). As a result, you can pass an AST tree directly as the children like this:
1132
+ It is possible to need to pre-process the data outside of this library. As a result, you can pass an AST tree directly as the children like this:
1135
1133
 
1136
1134
  ```jsx
1137
1135
  import React from 'react';
@@ -1149,7 +1147,7 @@ This is some text with **BOLD!**
1149
1147
 
1150
1148
  const ast = tokensToAST(stringToTokens(copy, markdownItInstance))
1151
1149
 
1152
- const App: () => React$Node = () => {
1150
+ const App: () => React.ReactNode = () => {
1153
1151
  return (
1154
1152
  <>
1155
1153
  <StatusBar barStyle="dark-content" />
@@ -1174,11 +1172,11 @@ export default App;
1174
1172
 
1175
1173
  ### Other Notes
1176
1174
 
1177
- This is a fork of [react-native-markdown-renderer](https://github.com/mientjan/react-native-markdown-renderer), a library that unfortunately has not been updated for some time so i took all of the outstanding pull requests from that library and tested + merged as necessary.
1175
+ See [iamacup/react-native-markdown-display](https://github.com/iamacup/react-native-markdown-display) for the legacy fork lineage. This project removes unmaintained libraries and uses TypeScript.
1178
1176
 
1179
1177
  ## About Novastera
1180
1178
 
1181
- This library is part of the Novastera open-source ecosystem, a modern CRM/ERP
1179
+ This library is part of the Novastera CRM/ERP open-source ecosystem, a modern
1182
1180
  platform designed for the next generation of business applications. Novastera
1183
1181
  combines AI capabilities with comprehensive business management tools, enabling
1184
1182
  organizations to leverage on-device AI for enhanced productivity and data
@@ -22,10 +22,7 @@ class AstRenderer {
22
22
  const renderFunction = this.getRenderFunction(node.type);
23
23
  const parents = [...parentNodes];
24
24
  if (this._debugPrintTree === true) {
25
- let str = '';
26
- for (let a = 0; a < parents.length; a++) {
27
- str = str + '-';
28
- }
25
+ const str = '-'.repeat(parents.length);
29
26
  console.log(`${str}${node.type}`);
30
27
  }
31
28
  parents.unshift(node);
@@ -109,30 +109,46 @@ const renderRules = {
109
109
  blocklink: linkRule((node, children, parent, styles, onLinkPress) => ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { onPress: () => (0, openUrl_1.default)(node.attributes.href, onLinkPress), style: styles.blocklink, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.image, children: children }) }, node.key))),
110
110
  // Images
111
111
  image: imageRule((node, children, parent, styles, allowedImageHandlers, defaultImageHandler) => {
112
- const { src, alt } = node.attributes;
112
+ const { src, alt, width, height, contentFit, contentPosition, } = node.attributes;
113
113
  if (!src) {
114
114
  return null;
115
115
  }
116
+ const srcValue = String(src);
116
117
  // we check that the source starts with at least one of the elements in allowedImageHandlers
117
118
  const show = allowedImageHandlers.filter((value) => {
118
- return src.toLowerCase().startsWith(value.toLowerCase());
119
+ return srcValue.toLowerCase().startsWith(value.toLowerCase());
119
120
  }).length > 0;
120
121
  if (show === false && defaultImageHandler === null) {
121
122
  return null;
122
123
  }
123
- const imageUri = show === true ? src : `${defaultImageHandler !== null && defaultImageHandler !== void 0 ? defaultImageHandler : ''}${src}`;
124
+ const imageUri = show === true ? srcValue : `${defaultImageHandler !== null && defaultImageHandler !== void 0 ? defaultImageHandler : ''}${srcValue}`;
125
+ const widthValue = typeof width === 'number' ? width : width ? Number(width) : undefined;
126
+ const heightValue = typeof height === 'number' ? height : height ? Number(height) : undefined;
127
+ const sizeStyle = Number.isFinite(widthValue) || Number.isFinite(heightValue)
128
+ ? {
129
+ ...(Number.isFinite(widthValue) ? { width: widthValue } : {}),
130
+ ...(Number.isFinite(heightValue) ? { height: heightValue } : {}),
131
+ }
132
+ : undefined;
124
133
  const imageProps = {
125
- key: node.key,
126
- style: styles._VIEW_SAFE_image,
134
+ style: sizeStyle
135
+ ? [styles._VIEW_SAFE_image, sizeStyle]
136
+ : styles._VIEW_SAFE_image,
127
137
  source: {
128
138
  uri: imageUri,
129
139
  },
130
140
  };
131
- if (alt) {
141
+ if (typeof contentFit === 'string') {
142
+ imageProps.contentFit = contentFit;
143
+ }
144
+ if (typeof contentPosition === 'string') {
145
+ imageProps.contentPosition = contentPosition;
146
+ }
147
+ if (typeof alt === 'string' && alt.length > 0) {
132
148
  imageProps.accessible = true;
133
149
  imageProps.accessibilityLabel = alt;
134
150
  }
135
- return (0, jsx_runtime_1.jsx)(expo_image_1.Image, { ...imageProps });
151
+ return (0, jsx_runtime_1.jsx)(expo_image_1.Image, { ...imageProps }, node.key);
136
152
  }),
137
153
  // Text Output
138
154
  text: baseRule((node, children, parent, styles, inheritedStyles = {}) => ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [inheritedStyles, styles.text], children: node.content }, node.key))),
@@ -17,10 +17,7 @@ export default class AstRenderer {
17
17
  const renderFunction = this.getRenderFunction(node.type);
18
18
  const parents = [...parentNodes];
19
19
  if (this._debugPrintTree === true) {
20
- let str = '';
21
- for (let a = 0; a < parents.length; a++) {
22
- str = str + '-';
23
- }
20
+ const str = '-'.repeat(parents.length);
24
21
  console.log(`${str}${node.type}`);
25
22
  }
26
23
  parents.unshift(node);
@@ -104,30 +104,46 @@ const renderRules = {
104
104
  blocklink: linkRule((node, children, parent, styles, onLinkPress) => (_jsx(TouchableWithoutFeedback, { onPress: () => openUrl(node.attributes.href, onLinkPress), style: styles.blocklink, children: _jsx(View, { style: styles.image, children: children }) }, node.key))),
105
105
  // Images
106
106
  image: imageRule((node, children, parent, styles, allowedImageHandlers, defaultImageHandler) => {
107
- const { src, alt } = node.attributes;
107
+ const { src, alt, width, height, contentFit, contentPosition, } = node.attributes;
108
108
  if (!src) {
109
109
  return null;
110
110
  }
111
+ const srcValue = String(src);
111
112
  // we check that the source starts with at least one of the elements in allowedImageHandlers
112
113
  const show = allowedImageHandlers.filter((value) => {
113
- return src.toLowerCase().startsWith(value.toLowerCase());
114
+ return srcValue.toLowerCase().startsWith(value.toLowerCase());
114
115
  }).length > 0;
115
116
  if (show === false && defaultImageHandler === null) {
116
117
  return null;
117
118
  }
118
- const imageUri = show === true ? src : `${defaultImageHandler !== null && defaultImageHandler !== void 0 ? defaultImageHandler : ''}${src}`;
119
+ const imageUri = show === true ? srcValue : `${defaultImageHandler !== null && defaultImageHandler !== void 0 ? defaultImageHandler : ''}${srcValue}`;
120
+ const widthValue = typeof width === 'number' ? width : width ? Number(width) : undefined;
121
+ const heightValue = typeof height === 'number' ? height : height ? Number(height) : undefined;
122
+ const sizeStyle = Number.isFinite(widthValue) || Number.isFinite(heightValue)
123
+ ? {
124
+ ...(Number.isFinite(widthValue) ? { width: widthValue } : {}),
125
+ ...(Number.isFinite(heightValue) ? { height: heightValue } : {}),
126
+ }
127
+ : undefined;
119
128
  const imageProps = {
120
- key: node.key,
121
- style: styles._VIEW_SAFE_image,
129
+ style: sizeStyle
130
+ ? [styles._VIEW_SAFE_image, sizeStyle]
131
+ : styles._VIEW_SAFE_image,
122
132
  source: {
123
133
  uri: imageUri,
124
134
  },
125
135
  };
126
- if (alt) {
136
+ if (typeof contentFit === 'string') {
137
+ imageProps.contentFit = contentFit;
138
+ }
139
+ if (typeof contentPosition === 'string') {
140
+ imageProps.contentPosition = contentPosition;
141
+ }
142
+ if (typeof alt === 'string' && alt.length > 0) {
127
143
  imageProps.accessible = true;
128
144
  imageProps.accessibilityLabel = alt;
129
145
  }
130
- return _jsx(Image, { ...imageProps });
146
+ return _jsx(Image, { ...imageProps }, node.key);
131
147
  }),
132
148
  // Text Output
133
149
  text: baseRule((node, children, parent, styles, inheritedStyles = {}) => (_jsx(Text, { style: [inheritedStyles, styles.text], children: node.content }, node.key))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novastera-oss/react-native-markdown-display",
3
- "version": "8.0.1",
3
+ "version": "8.1.0",
4
4
  "description": "Markdown renderer for react-native, with CommonMark spec support. Maintained by Novastera.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",