Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 107 additions & 107 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,110 +57,110 @@ jobs:
- name: Build package
run: yarn prepare

build-android:
runs-on: ubuntu-latest

env:
TURBO_CACHE_DIR: .turbo/android

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for Android
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-

- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi

- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: 'zulu'
java-version: '17'

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"

- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build example for Android
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"

build-ios:
runs-on: macos-latest

env:
XCODE_VERSION: 16.3
TURBO_CACHE_DIR: .turbo/ios
RCT_USE_RN_DEP: 1
RCT_USE_PREBUILT_RNCORE: 1

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for iOS
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-

- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi

- name: Use appropriate Xcode version
if: env.turbo_cache_hit != 1
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: ${{ env.XCODE_VERSION }}

- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example
bundle install
bundle exec pod repo update --verbose
bundle exec pod install --project-directory=ios

- name: Build example for iOS
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
# build-android:
# runs-on: ubuntu-latest

# env:
# TURBO_CACHE_DIR: .turbo/android

# steps:
# - name: Checkout
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# - name: Setup
# uses: ./.github/actions/setup

# - name: Cache turborepo for Android
# uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
# with:
# path: ${{ env.TURBO_CACHE_DIR }}
# key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-turborepo-android-

# - name: Check turborepo cache for Android
# run: |
# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")

# if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
# echo "turbo_cache_hit=1" >> $GITHUB_ENV
# fi

# - name: Install JDK
# if: env.turbo_cache_hit != 1
# uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
# with:
# distribution: 'zulu'
# java-version: '17'

# - name: Finalize Android SDK
# if: env.turbo_cache_hit != 1
# run: |
# /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"

# - name: Cache Gradle
# if: env.turbo_cache_hit != 1
# uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
# with:
# path: |
# ~/.gradle/wrapper
# ~/.gradle/caches
# key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-

# - name: Build example for Android
# env:
# JAVA_OPTS: '-XX:MaxHeapSize=6g'
# run: |
# yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"

# build-ios:
# runs-on: macos-latest

# env:
# XCODE_VERSION: 16.3
# TURBO_CACHE_DIR: .turbo/ios
# RCT_USE_RN_DEP: 1
# RCT_USE_PREBUILT_RNCORE: 1

# steps:
# - name: Checkout
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# - name: Setup
# uses: ./.github/actions/setup

# - name: Cache turborepo for iOS
# uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
# with:
# path: ${{ env.TURBO_CACHE_DIR }}
# key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-turborepo-ios-

# - name: Check turborepo cache for iOS
# run: |
# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")

# if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
# echo "turbo_cache_hit=1" >> $GITHUB_ENV
# fi

# - name: Use appropriate Xcode version
# if: env.turbo_cache_hit != 1
# uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
# with:
# xcode-version: ${{ env.XCODE_VERSION }}

# - name: Install cocoapods
# if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
# run: |
# cd example
# bundle install
# bundle exec pod repo update --verbose
# bundle exec pod install --project-directory=ios

# - name: Build example for iOS
# run: |
# yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "shared/MD4C"]
path = shared/MD4C
url = https://github.com/mity/md4c.git
38 changes: 37 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,27 @@ This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/f

To get started with the project, make sure you have the correct version of [Node.js](https://nodejs.org/) installed. See the [`.nvmrc`](./.nvmrc) file for the version used in this project.

Run `yarn` in the root directory to install the required dependencies for each package:
### Cloning the Repository

When cloning this repository, make sure to include submodules:

```sh
# Clone with submodules (recommended)
git clone --recurse-submodules https://github.com/software-mansion-labs/react-native-rich-text.git

# Or if you've already cloned without submodules:
git clone https://github.com/software-mansion-labs/react-native-rich-text.git
cd react-native-rich-text
git submodule add https://github.com/mity/md4c.git shared/MD4C
```

## Initial Setup

This project uses git submodules for native dependencies. You need to initialize the submodules before installing dependencies:

```sh

# Install dependencies
yarn
```

Expand Down Expand Up @@ -76,6 +94,20 @@ Remember to add tests for your change if possible. Run the unit tests by:
yarn test
```

### Testing MD4C Integration

This project includes native markdown parsing capabilities using the MD4C library. To test the MD4C integration:

```sh
# Run MD4C integration tests
./scripts/test-md4c.sh
```

This will test:

- MD4C compilation and execution
- iOS podspec configuration

### Commit message convention

We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
Expand Down Expand Up @@ -119,6 +151,10 @@ The `package.json` file contains various scripts for common tasks:
- `yarn example android`: run the example app on Android.
- `yarn example ios`: run the example app on iOS.

Additional scripts for native development:

- `./scripts/test-md4c.sh`: test MD4C integration and native setup.

### Sending a pull request

> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
Expand Down
7 changes: 6 additions & 1 deletion RichText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ Pod::Spec.new do |s|
s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/software-mansion-labs/react-native-rich-text.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,cpp}"
s.source_files = "ios/**/*.{h,m,mm,cpp}", "shared/MD4C/src/md4c.c", "shared/MD4C/src/entity.c"
s.private_header_files = "ios/**/*.h"

# Set header search paths to submodule
s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/shared/MD4C/src'
}


install_modules_dependencies(s)
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: 3eb9096cb139eb433965693bbe541d96eb3d3ec9
ReactCodegen: 4d203eddf6f977caa324640a20f92e70408d648b
ReactCommon: ce5d4226dfaf9d5dacbef57b4528819e39d3a120
RichText: bc45c6536e044f3c57b4f4f0aaa0dab911395d2f
RichText: c5ea51a2a21a79d2b3e670f73a75c25627a31181
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 11c9686a21e2cd82a094a723649d9f4507200fb0

Expand Down
74 changes: 64 additions & 10 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
import { View, StyleSheet } from 'react-native';
import {
StyleSheet,
ScrollView,
SafeAreaView,
Alert,
Linking,
} from 'react-native';
import { RichTextView } from 'react-native-rich-text';
import type { HeaderConfig } from 'react-native-rich-text';

const HEADER_CONFIG: HeaderConfig = {
scale: 2.0,
isBold: true,
};

const sampleMarkdown = `#### Welcome to the React Native Markdown component!

This is a simple text with links.

Check out this [link to React Native](https://reactnative.dev) and this [GitHub repository](https://github.com/facebook/react-native).

Built with ❤️ using React Native Fabric Architecture`;

export default function App() {
const handleLinkPress = (event: { nativeEvent: { url: string } }) => {
const { url } = event.nativeEvent;
Alert.alert('Link Pressed!', `You tapped on: ${url}`, [
{
text: 'Open in Browser',
onPress: () => {
Linking.openURL(url);
},
},
{
text: 'Cancel',
style: 'cancel',
},
]);
};

return (
<View style={styles.container}>
<RichTextView color="#32a852" style={styles.box} />
</View>
<SafeAreaView style={styles.container}>
<ScrollView
style={styles.scrollView}
contentContainerStyle={styles.content}
>
<RichTextView
markdown={sampleMarkdown}
style={styles.markdown}
fontSize={18}
fontFamily="Helvetica"
headerConfig={HEADER_CONFIG}
textColor="#F54927"
onLinkPress={handleLinkPress}
/>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 60,
height: 60,
marginVertical: 20,
scrollView: {
flex: 1,
},
content: {
padding: 20,
},
markdown: {
flex: 1,
padding: 10,
borderRadius: 8,
minHeight: 250,
},
});
Loading