Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Feature Request 💡
url: https://github.com/software-mansion/react-native-enriched/discussions/new?category=ideas
url: https://github.com/software-mansion/react-native-enriched-html/discussions/new?category=ideas
about: If you have a feature request, please create a new discussion on GitHub.
- name: Discussions on GitHub 💬
url: https://github.com/software-mansion/react-native-enriched/discussions
url: https://github.com/software-mansion/react-native-enriched-html/discussions
about: If this library works as promised but you need help, please ask questions there.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: software-mansion/npm-package-publish@1bb885ec49bed729c8c1ec95a11a285d89f1bf45
with:
package-name: 'react-native-enriched'
package-name: 'react-native-enriched-html'
package-json-path: 'package.json'
install-dependencies-command: 'yarn install --immutable'
release-type: ${{ inputs.release-type }}
Expand All @@ -59,7 +59,7 @@ jobs:
if: ${{ github.event_name == 'schedule' }}
uses: software-mansion/npm-package-publish@1bb885ec49bed729c8c1ec95a11a285d89f1bf45
with:
package-name: 'react-native-enriched'
package-name: 'react-native-enriched-html'
package-json-path: 'package.json'
install-dependencies-command: 'yarn install --immutable'
release-type: 'nightly'
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ The [example app](/apps/example/) demonstrates usage of the library. You need to

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

If you want to use Android Studio or Xcode to edit the native code, you can open the `apps/example/android` or `apps/example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `apps/example/ios/EnrichedTextInputExample.xcworkspace` in Xcode and find the source files at `Pods > Development Pods > ReactNativeEnriched`.
If you want to use Android Studio or Xcode to edit the native code, you can open the `apps/example/android` or `apps/example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `apps/example/ios/EnrichedTextInputExample.xcworkspace` in Xcode and find the source files at `Pods > Development Pods > ReactNativeEnrichedHtml`.

To edit the Java or Kotlin files, open `apps/example/android` in Android studio and find the source files at `react-native-enriched` under `Android`.
To edit the Java or Kotlin files, open `apps/example/android` in Android studio and find the source files at `react-native-enriched-html` under `Android`.

You can use various commands from the root directory to work with the project.

Expand Down
55 changes: 27 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<img src="https://github.com/user-attachments/assets/c8ba03bc-4ea8-48f4-9566-02ebac0c19d3" alt="react-native-enriched by Software Mansion" width="100%">
<img src="https://github.com/user-attachments/assets/c8ba03bc-4ea8-48f4-9566-02ebac0c19d3" alt="react-native-enriched-html by Software Mansion" width="100%">

[![Ad](https://swm-delivery.com/www/images/zone-gh-react-native-enriched-1?n=1)](https://swm-delivery.com/www/delivery/ck-slug.php?zoneid=zone-gh-react-native-enriched-1&n=1)
Comment thread
szydlovsky marked this conversation as resolved.
[![Ad](https://swm-delivery.com/www/images/zone-gh-react-native-enriched-2?n=1)](https://swm-delivery.com/www/delivery/ck-slug.php?zoneid=zone-gh-react-native-enriched-2&n=1)
[![Ad](https://swm-delivery.com/www/images/zone-gh-react-native-enriched-3?n=1)](https://swm-delivery.com/www/delivery/ck-slug.php?zoneid=zone-gh-react-native-enriched-3&n=1)

# react-native-enriched
# react-native-enriched-html

`react-native-enriched` is a powerful React Native library that exposes a rich text editor component:
`react-native-enriched-html` is a powerful React Native Rich Text solution:

- ⚡ Fully native text input component
- 🕹️ Synchronous text styling
- 🔍 Live styling detection and HTML parsing
- 🎨 Customizable styles
- 📱 Mobile platforms support
- 🏛 Supports only the New Architecture
- ⚡ Fully native input and display components (Supports New Architecture only)
- 💻 HTML-based parsing with live, synchronous text styling
- 🎨 Fully customizable styles for seamless UI integration
- 🌐 Solid mobile support with an experimental Web implementation

`EnrichedTextInput`, the rich text editor component is an uncontrolled input. This means that it doesn't use any state or props to store its value, but instead directly interacts with the underlying platform-specific components. Thanks to this, the component is really performant and simple to use while offering complex and advanced features no other solution has.
`EnrichedTextInput`, the rich text input component is an uncontrolled input. This means that it doesn't use any state or props to store its value, but instead directly interacts with the underlying platform-specific components. Thanks to this, the component is really performant and simple to use while offering complex and advanced features no other solution has.

![react-native-enriched-demo](https://github.com/user-attachments/assets/a2c968c0-9b85-492f-ac71-af64ef231fbf)
`EnrichedText` is the display component designed to work seamlessly with `EnrichedTextInput`. It flawlessly renders any HTML generated by the input, while a shared, customizable styling API guarantees perfect 1:1 visual consistency between editing and displaying.

![react-native-enriched-html-demo](https://github.com/user-attachments/assets/a2c968c0-9b85-492f-ac71-af64ef231fbf)

Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues.
We can help you build your next dream product –
[Hire us](https://swmansion.com/contact/projects?utm_source=react-native-enriched&utm_medium=readme).
[Hire us](https://swmansion.com/contact/projects?utm_source=react-native-enriched-html&utm_medium=readme).

## Table of Contents

Expand All @@ -46,9 +46,8 @@ We can help you build your next dream product –

## Prerequisites

- `react-native-enriched` currently supports only Android and iOS platforms
- `react-native-enriched-html` currently supports Android and iOS, Web implementation is still experimental.
- It works only with [the React Native New Architecture (Fabric)](https://reactnative.dev/architecture/landing-page) and supports following React Native releases: `0.81`, `0.82`, `0.83`, `0.84` and `0.85`.
- If you would like to use `react-native-enriched` in React Native `0.79` or `0.80` use `react-native-enriched 0.4.x`.
Comment thread
szydlovsky marked this conversation as resolved.

## Installation

Expand All @@ -57,14 +56,14 @@ We can help you build your next dream product –
#### 1. Install the library

```sh
yarn add react-native-enriched
yarn add react-native-enriched-html
```

> [!TIP]
> To try the latest features before they land in a stable release, install the nightly build:
>
> ```sh
> yarn add react-native-enriched@nightly
> yarn add react-native-enriched-html@nightly
> ```
>
> Nightly versions are published to npm automatically and may contain breaking changes.
Expand All @@ -82,7 +81,7 @@ cd ios && bundler install && bundler exec pod install
#### 1. Install the library

```sh
npx expo install react-native-enriched
npx expo install react-native-enriched-html
```

#### 2. Run prebuild
Expand All @@ -101,11 +100,11 @@ npx expo prebuild
Here's a simple example of an input that lets you toggle bold on its text and shows whether bold is currently active via the button color.

```tsx
import { EnrichedTextInput } from 'react-native-enriched';
import { EnrichedTextInput } from 'react-native-enriched-html';
import type {
EnrichedTextInputInstance,
OnChangeStateEvent,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { useState, useRef } from 'react';
import { View, Button, StyleSheet } from 'react-native';

Expand Down Expand Up @@ -157,7 +156,7 @@ Summary of what happens here:

## Supported Tags

`react-native-enriched` uses both standard and custom HTML tags in its output and accepts them as input.
`react-native-enriched-html` uses both standard and custom HTML tags in its output and accepts them as input.

Not all styles can be combined freely. There are two kinds of restrictions:

Expand Down Expand Up @@ -235,7 +234,7 @@ The links are here, just like in any other editor, a piece of text with a URL at

### Automatic links detection

`react-native-enriched` automatically detects words that appear to be some URLs and makes them links.
`react-native-enriched-html` automatically detects words that appear to be some URLs and makes them links.
You can customize this behavior by providing your own regular expression via [linkRegex](docs/INPUT_API_REFERENCE.md#linkregex) prop.

### Applying links manually
Expand All @@ -262,7 +261,7 @@ There are two ways in which a mention can be started; either by typing one of th

### Mention related events

`react-native-enriched` emits 3 different events that help handling mentions' editing:
`react-native-enriched-html` emits 3 different events that help handling mentions' editing:

- [onStartMention](docs/INPUT_API_REFERENCE.md#onstartmention) is emitted whenever mention is started in one of the ways from the [previous section](#starting-a-mention) or the user has come back (moved selection) to some unfinished mention they have started. It can be used for opening proper tools you use in the app to edit a mention (e.g. a list for choosing from users or channels that the mention will affect).
- [onChangeMention](docs/INPUT_API_REFERENCE.md#onchangemention) is emitted whenever user put or removed some characters after a mention indicator. This way you can react to active mention editing by, for example, filtering users in your displayed list based on the typed text.
Expand All @@ -286,7 +285,7 @@ You can find some examples in the [usage section](#usage) or in the example app.

## Other Events

`react-native-enriched` emits a few more events that may be of use:
`react-native-enriched-html` emits a few more events that may be of use:

- [onFocus](docs/INPUT_API_REFERENCE.md#onfocus) - emits whenever input focuses.
- [onBlur](docs/INPUT_API_REFERENCE.md) - emits whenever input blurs.
Expand Down Expand Up @@ -323,18 +322,18 @@ You can extend the native text editing menu with custom items using the [context

## Customizing \<EnrichedTextInput /> styles

`react-native-enriched` allows customizing styles of the `<EnrichedTextInput />` component. See [htmlStyle](docs/INPUT_API_REFERENCE.md#htmlstyle) prop.
`react-native-enriched-html` allows customizing styles of the `<EnrichedTextInput />` component. See [htmlStyle](docs/INPUT_API_REFERENCE.md#htmlstyle) prop.

## EnrichedText component

`react-native-enriched` provides an `EnrichedText` component that renders the HTML output of `EnrichedTextInput` with all supported styles, interactive links, and mentions.
`react-native-enriched-html` provides an `EnrichedText` component that renders the HTML output of `EnrichedTextInput` with all supported styles, interactive links, and mentions.

```tsx
import { EnrichedText } from 'react-native-enriched';
import { EnrichedText } from 'react-native-enriched-html';
import type {
OnLinkPressEvent,
OnMentionPressEvent,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { StyleSheet } from 'react-native';

export default function App() {
Expand Down Expand Up @@ -390,7 +389,7 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the

## License

`react-native-enriched` library is licensed under [The MIT License](./LICENSE).
`react-native-enriched-html` library is licensed under [The MIT License](./LICENSE).

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
s.name = "ReactNativeEnriched"
s.name = "ReactNativeEnrichedHtml"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/software-mansion/react-native-enriched.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/software-mansion/react-native-enriched-html.git", :tag => "#{s.version}" }

s.source_files = ["ios/**/*.{h,m,mm,cpp}", "cpp/**/*.{h,hpp,c,cpp}"]
s.exclude_files = ["cpp/tests/**"]
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeEnriched_' + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeEnrichedHtml_' + name]
}

repositories {
Expand All @@ -27,7 +27,7 @@ apply plugin: "com.facebook.react"
apply from: "lint.gradle"

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeEnriched_" + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeEnrichedHtml_" + name]).toInteger()
}

def supportsNamespace() {
Expand Down Expand Up @@ -101,6 +101,6 @@ dependencies {

react {
jsRootDir = file("../src/")
libraryName = "ReactNativeEnriched"
libraryName = "ReactNativeEnrichedHtml"
codegenJavaPackageName = "com.swmansion.enriched"
}
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ReactNativeEnriched_kotlinVersion=2.0.21
ReactNativeEnriched_minSdkVersion=24
ReactNativeEnriched_targetSdkVersion=34
ReactNativeEnriched_compileSdkVersion=35
ReactNativeEnriched_ndkVersion=27.1.12297006
ReactNativeEnrichedHtml_kotlinVersion=2.0.21
ReactNativeEnrichedHtml_minSdkVersion=24
ReactNativeEnrichedHtml_targetSdkVersion=34
ReactNativeEnrichedHtml_compileSdkVersion=35
ReactNativeEnrichedHtml_ndkVersion=27.1.12297006
4 changes: 2 additions & 2 deletions apps/example-web/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React Native Enriched Web Example
# React Native Enriched Html Web Example

This is a [**Vite**](https://vite.dev) + [**React**](https://react.dev) web example for the React Native Enriched text input component, bootstrapped with Vite's React template.
This is a [**Vite**](https://vite.dev) + [**React**](https://react.dev) web example for the React Native Enriched Html text input component, bootstrapped with Vite's React template.
Comment thread
szydlovsky marked this conversation as resolved.

# Getting Started

Expand Down
22 changes: 10 additions & 12 deletions apps/example-web/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Native Enriched Html Web Example</title>
Comment thread
szydlovsky marked this conversation as resolved.
</head>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Native Enriched Web Example</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion apps/example-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type OnSubmitEditing,
type OnChangeMentionEvent,
type OnMentionDetected,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { WEB_DEFAULT_HTML_STYLE } from './defaultHtmlStyle';
import type { NativeSyntheticEvent } from 'react-native';
import { EditorActions } from './components/EditorActions';
Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './Toolbar.css';
import type {
EnrichedTextInputInstance,
OnChangeStateEvent,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import type { RefObject } from 'react';
import { useDragScroll } from '../hooks/useDragScroll';

Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/defaultHtmlStyle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HtmlStyle } from 'react-native-enriched';
import type { HtmlStyle } from 'react-native-enriched-html';

export const WEB_DEFAULT_HTML_STYLE: HtmlStyle = {
h1: {
Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/testScreens/TestLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type EnrichedInputStyle,
type EnrichedTextInputInstance,
type OnLinkDetected,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { WEB_DEFAULT_HTML_STYLE } from '../defaultHtmlStyle';

function toInteger(value: string): number {
Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/testScreens/TestMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
EnrichedTextInput,
type EnrichedInputStyle,
type EnrichedTextInputInstance,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { WEB_DEFAULT_HTML_STYLE } from '../defaultHtmlStyle';

export function TestMentions() {
Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/testScreens/TestSetSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
EnrichedTextInput,
type EnrichedTextInputInstance,
type OnChangeSelectionEvent,
} from 'react-native-enriched';
} from 'react-native-enriched-html';

const SAMPLE_HTML = '<p>AAAA</p><br><br><p>BBBB</p><p>CCCC</p>';

Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/testScreens/TestSubmitProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type EnrichedTextInputInstance,
type EnrichedTextInputProps,
type OnSubmitEditing,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import type { NativeSyntheticEvent, ReturnKeyTypeOptions } from 'react-native';

const editorWrapStyle = {
Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/src/testScreens/VisualRegression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type EnrichedTextInputInstance,
type HtmlStyle,
type OnChangeStateEvent,
} from 'react-native-enriched';
} from 'react-native-enriched-html';
import { Toolbar } from '../components/Toolbar';
import { WEB_DEFAULT_HTML_STYLE } from '../defaultHtmlStyle';

Expand Down
2 changes: 1 addition & 1 deletion apps/example-web/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"types": ["vite/client"],
"baseUrl": ".",
"paths": {
"react-native-enriched": ["../../src/index.tsx"]
"react-native-enriched-html": ["../../src/index.tsx"]
}
},
"include": ["src"]
Expand Down
5 changes: 4 additions & 1 deletion apps/example-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'react-native-enriched': path.resolve(__dirname, '../../src/index.tsx'),
'react-native-enriched-html': path.resolve(
__dirname,
'../../src/index.tsx'
),
'react': path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
},
Expand Down
2 changes: 1 addition & 1 deletion apps/example/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is an example React Native app that lets you develop and test `react-native-enriched`.
This is an example React Native app that lets you develop and test `react-native-enriched-html`.

# Getting Started

Expand Down
Loading
Loading