react-native-markdown-native 1.0.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/MarkdownNative.podspec +19 -0
  3. package/README.md +109 -0
  4. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  6. package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/8.9/gc.properties +0 -0
  10. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  11. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  12. package/android/.gradle/vcs-1/gc.properties +0 -0
  13. package/android/build.gradle +36 -0
  14. package/android/src/main/AndroidManifest.xml +2 -0
  15. package/android/src/main/java/com/markdownnative/MarkdownPackage.java +25 -0
  16. package/android/src/main/java/com/markdownnative/MarkdownView.java +516 -0
  17. package/android/src/main/java/com/markdownnative/MarkdownViewManager.java +107 -0
  18. package/ios/MarkdownView.swift +771 -0
  19. package/ios/MarkdownViewManager.m +27 -0
  20. package/ios/MarkdownViewManager.swift +20 -0
  21. package/lib/commonjs/index.js +97 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/commonjs/package.json +1 -0
  24. package/lib/commonjs/types.js +154 -0
  25. package/lib/commonjs/types.js.map +1 -0
  26. package/lib/index.d.ts +26 -0
  27. package/lib/index.js +97 -0
  28. package/lib/module/index.js +80 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/types.js +153 -0
  31. package/lib/module/types.js.map +1 -0
  32. package/lib/typescript/index.d.ts +30 -0
  33. package/lib/typescript/index.d.ts.map +1 -0
  34. package/lib/typescript/types.d.ts +80 -0
  35. package/lib/typescript/types.d.ts.map +1 -0
  36. package/package.json +92 -0
  37. package/react-native.config.js +11 -0
  38. package/src/index.tsx +117 -0
  39. package/src/types.ts +205 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sandeep Mansotra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "MarkdownNative"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "15.0" }
14
+ s.source = { :git => "https://github.com/sandeepmansotra/react-native-markdown-native.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ s.dependency "React-Core"
19
+ end
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # React Native Markdown Native
2
+
3
+ A high-performance, native Markdown rendering library for React Native that uses native `TextView` (Android) and `UITextView` (iOS 15+) for superior text handling, selection, and accessibility.
4
+
5
+ ## Features
6
+
7
+ - ๐Ÿš€ **Native Performance**: Uses native text components instead of WebViews or complex JS view hierarchies.
8
+ - ๐Ÿ“ฑ **Native Text Selection**: Supports standard OS text selection, copy/paste, and context menus.
9
+ - ๐ŸŽจ **Full Styling Control**: Customizable fonts, colors, spacing, and layout.
10
+ - ๐Ÿ”— **Link Handling**: Native handling of links with customizable colors.
11
+ - ๐Ÿงต **Complex Layouts**: Supports lists, paragraphs, and standard markdown formatting.
12
+ - โšก **Autolinking**: Easy installation with React Native autolinking.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install react-native-markdown-native
18
+ # or
19
+ yarn add react-native-markdown-native
20
+ ```
21
+
22
+ ### iOS Setup
23
+
24
+ Requires iOS 15.0 or higher.
25
+ Run `pod install` in your `ios` directory.
26
+
27
+ ### Android Setup
28
+
29
+ The library supports React Native autolinking. No manual configuration is required in `settings.gradle` or `build.gradle`.
30
+
31
+ ## Usage
32
+
33
+ ```tsx
34
+ import { MarkdownView } from 'react-native-markdown-native';
35
+
36
+ const MyComponent = () => {
37
+ return (
38
+ <MarkdownView
39
+ markdownText="# Hello World\nThis is **bold** and *italic* text."
40
+ style={{ width: '100%', height: 200 }}
41
+ markdownFontSize={16}
42
+ markdownColor="#000000"
43
+ />
44
+ );
45
+ };
46
+ ```
47
+
48
+ ## Props API
49
+
50
+ | Prop | Type | Default | Description |
51
+ | -------------------------- | ---------- | ------------ | ------------------------------------------------------------------------ |
52
+ | `markdownText` | `string` | **Required** | The markdown content to render. |
53
+ | `markdownFontSize` | `number` | `16` | Font size in points. |
54
+ | `markdownColor` | `string` | `#000000` | Text color (hex code). |
55
+ | `markdownFontFamily` | `string` | `undefined` | Font family name. Must be linked in your app. |
56
+ | `markdownLinkColor` | `string` | `#007AFF` | Color of links. |
57
+ | `markdownSelectionColor` | `string` | `#ACCEF7` | Background color for selected text. |
58
+ | `markdownSelectable` | `boolean` | `true` | Enables/disables text selection. |
59
+ | `markdownScrollEnabled` | `boolean` | `false` | Enables/disables internal scrolling (useful for long content). |
60
+ | `markdownLineSpacing` | `number` | `0` | Extra spacing between lines. |
61
+ | `markdownParagraphSpacing` | `number` | `0` | Spacing between paragraphs. |
62
+ | `onNativeSizeChange` | `function` | `undefined` | Callback when content size changes `{ nativeEvent: { width, height } }`. |
63
+
64
+ ### List Styling
65
+
66
+ | Prop | Type | Default | Description |
67
+ | --------------------------- | -------- | ------- | -------------------------------- |
68
+ | `markdownBulletIndent` | `number` | `20` | Indentation for bullet points. |
69
+ | `markdownListLeftInset` | `number` | `10` | Left margin for the entire list. |
70
+ | `markdownListSpacingBefore` | `number` | `0` | Spacing before a list block. |
71
+ | `markdownListSpacingAfter` | `number` | `0` | Spacing after a list block. |
72
+
73
+ ## Platform Differences
74
+
75
+ ### iOS
76
+
77
+ - Uses `UITextView` with `try AttributedString(markdown: options:)`.
78
+ - Requires iOS 15+.
79
+ - Supports native data detectors (links, phone numbers, etc).
80
+
81
+ ### Android
82
+
83
+ - Uses `TextView` with `Markwon` library.
84
+ - Supports smart touch handling for seamless integration with `FlatList` and `ScrollView`.
85
+ - **Note**: When using inside a `FlatList`, ensure `removeClippedSubviews={false}` is set on the FlatList to allow the selection context menu to appear correctly.
86
+
87
+ ## Troubleshooting
88
+
89
+ ### Text Selection in FlatList (Android)
90
+
91
+ If you are using `MarkdownView` inside a `FlatList` on Android, the text selection context menu might not appear if `removeClippedSubviews` is true.
92
+
93
+ **Fix:**
94
+
95
+ ```tsx
96
+ <FlatList
97
+ removeClippedSubviews={false} // REQUIRED for Android selection menu
98
+ nestedScrollEnabled={true}
99
+ // ... other props
100
+ />
101
+ ```
102
+
103
+ ### Autolinking Issues
104
+
105
+ If the native module is not found:
106
+
107
+ 1. Ensure `react-native.config.js` exists in the module root.
108
+ 2. Run `npx react-native config` to verify the module is detected.
109
+ 3. Clean build: `cd android && ./gradlew clean`.
File without changes
@@ -0,0 +1,2 @@
1
+ #Thu Mar 19 13:26:55 ICT 2026
2
+ gradle.version=8.9
File without changes
@@ -0,0 +1,36 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath 'com.android.tools.build:gradle:7.3.1'
8
+ }
9
+ }
10
+
11
+ apply plugin: 'com.android.library'
12
+
13
+ android {
14
+ namespace 'com.markdownnative'
15
+ compileSdkVersion 33
16
+
17
+ defaultConfig {
18
+ minSdkVersion 21
19
+ targetSdkVersion 33
20
+ }
21
+
22
+ lintOptions {
23
+ abortOnError false
24
+ }
25
+ }
26
+
27
+ repositories {
28
+ mavenCentral()
29
+ google()
30
+ }
31
+
32
+ dependencies {
33
+ implementation 'com.facebook.react:react-native:+'
34
+ implementation 'io.noties.markwon:core:4.6.2'
35
+ implementation 'io.noties.markwon:html:4.6.2'
36
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,25 @@
1
+ package com.markdownnative;
2
+
3
+ import com.facebook.react.ReactPackage;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.uimanager.ViewManager;
7
+
8
+ import java.util.ArrayList;
9
+ import java.util.Collections;
10
+ import java.util.List;
11
+
12
+ public class MarkdownPackage implements ReactPackage {
13
+
14
+ @Override
15
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
16
+ List<ViewManager> viewManagers = new ArrayList<>();
17
+ viewManagers.add(new MarkdownViewManager());
18
+ return viewManagers;
19
+ }
20
+
21
+ @Override
22
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
23
+ return Collections.emptyList();
24
+ }
25
+ }