### Start Metro Server for Example App Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/CONTRIBUTING.md Starts the Metro bundler, which is required to run the example application. This command is used to serve the JavaScript bundle for the React Native app. ```shell yarn example start ``` -------------------------------- ### Start Metro Bundler (npm/Yarn) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/example/README.md Starts the Metro JavaScript bundler, which is essential for developing React Native applications. This command can be executed using either npm or Yarn. ```sh npm start ``` ```sh yarn start ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/CONTRIBUTING.md Builds and runs the example application on a connected iOS device or simulator. This allows testing changes against a native iOS environment. ```shell yarn example ios ``` -------------------------------- ### Install CocoaPods Dependencies (Ruby) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/example/README.md Installs the necessary dependencies for the iOS platform using CocoaPods. This is crucial after cloning the project or updating native dependencies. ```ruby bundle install ``` ```ruby bundle exec pod install ``` -------------------------------- ### Run Example App on Android Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/CONTRIBUTING.md Builds and runs the example application on an connected Android device or emulator. This allows testing changes against a native Android environment. ```shell yarn example android ``` -------------------------------- ### Install Project Dependencies with Yarn Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/CONTRIBUTING.md Installs all necessary dependencies for the monorepo using Yarn workspaces. This is a prerequisite for any development work. ```shell yarn ``` -------------------------------- ### Install react-native-enriched (Bare React Native) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Installs the react-native-enriched library using Yarn for bare React Native projects. ```sh yarn add react-native-enriched ``` -------------------------------- ### Install iOS Dependencies (Bare React Native) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Installs native iOS dependencies for react-native-enriched using Bundler and Pod install. Requires rebuilding the native app. ```sh cd ios && bundler install && bundler exec pod install ``` -------------------------------- ### Build and Run iOS App (npm/Yarn) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/example/README.md Builds and runs the React Native application on an iOS simulator or device. This command can be executed using either npm or Yarn. ```sh npm run ios ``` ```sh yarn ios ``` -------------------------------- ### Build and Run Android App (npm/Yarn) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/example/README.md Builds and runs the React Native application on an Android device or emulator. This command utilizes either npm or Yarn for execution. ```sh npm run android ``` ```sh yarn android ``` -------------------------------- ### Install react-native-enriched (Expo) Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Installs the react-native-enriched library using npx for Expo projects. ```sh npx expo install react-native-enriched ``` -------------------------------- ### Start Mention Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Initiates a mention at the current cursor or selection position using a provided indicator. ```APIDOC ## startMention() ### Description Starts a mention with the given indicator. It gets put at the cursor/selection. ### Method APIDOC ### Endpoint APIDOC ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **indicator** (string) - The indicator that starts the new mention. ### Request Example ```json { "indicator": "#" } ``` ### Response #### Success Response (200) N/A (This is a method call, not an API endpoint) #### Response Example N/A ``` -------------------------------- ### Starting a Mention Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Mentions can be initiated by typing specific indicator characters or by programmatically calling the startMention method on the input's ref. This functionality is key for user tagging or referencing entities within the text. ```javascript inputRef.current.startMention(); ``` -------------------------------- ### Start Mention in react-native-enriched Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Initiates a mention at the current cursor or selection position using a provided indicator. ```typescript startMention: (indicator: string) => void; ``` -------------------------------- ### Fix Formatting Errors with ESLint Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/CONTRIBUTING.md Automatically fixes code formatting issues detected by ESLint. This command should be run to ensure code adheres to the project's style guide. ```shell yarn lint --fix ``` -------------------------------- ### Mention Management Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md APIs for starting, editing, and completing mentions within the enriched text input. ```APIDOC ## Mention Management This section details the methods and events related to handling mentions in the `react-native-enriched` component. ### Starting a Mention Mentions can be initiated by typing specific `mentionIndicators` or by programmatically calling the `startMention` method. ### Mention Events - **onStartMention**: Emitted when a mention is started or when the cursor returns to an unfinished mention. Useful for opening mention selection UIs. - **onChangeMention**: Emitted when characters are added or removed within an active mention. Useful for filtering suggestions based on typed text. - **onEndMention**: Emitted when the user finishes editing a mention (e.g., by typing a space or moving the cursor). Useful for hiding mention editing UIs. ### Completing a Mention - **setMention**: Completes the currently edited mention, typically after a user selects an option from a mention editor. This method is called on the input ref. ``` -------------------------------- ### Set Link Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Sets a link within the text at specified start and end indices with custom display text and URL. It can also replace existing text in that range. ```APIDOC ## setLink() ### Description Sets the link at the given place with a given displayed text and URL. Link will replace any text if there was some between `start` and `end` indexes. Setting a link with `start` equal to `end` will just insert it in place. ### Method APIDOC ### Endpoint APIDOC ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **start** (number) - The starting index where the link should be. - **end** (number) - First index behind the new link's ending index. - **text** (string) - Displayed text of the link. - **url** (string) - URL of the link. ### Request Example ```json { "start": 0, "end": 5, "text": "example.com", "url": "https://example.com" } ``` ### Response #### Success Response (200) N/A (This is a method call, not an API endpoint) #### Response Example N/A ``` -------------------------------- ### Set Link in react-native-enriched Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Sets a hyperlink within the text content. It takes start and end indices, the display text, and the URL. Links can replace existing text or be inserted at a specific point. ```typescript setLink: ( start: number, end: number, text: string, url: string ) => void; ``` -------------------------------- ### onChangeSelection Callback - React Native Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md Fired when the user changes the text selection or moves the cursor. It returns the start and end indices of the selection, along with the selected text. This is crucial for implementing selection-based features. ```TypeScript interface OnChangeSelectionEvent { start: Int32; end: Int32; text: string; } // Usage example: (event: NativeSyntheticEvent) => void ``` -------------------------------- ### Toggle Bold Style in Enriched Text Input Source: https://github.com/software-mansion-labs/react-native-enriched/blob/main/README.md This example shows how to use the EnrichedTextInput component to toggle bold styling on text. It utilizes a ref to imperatively call the toggleBold method and displays the active bold state via button color. ```tsx import { EnrichedTextInput } from 'react-native-enriched'; import type { EnrichedTextInputInstance, OnChangeStateEvent, } from 'react-native-enriched'; import { useState, useRef } from 'react'; import { View, Button, StyleSheet } from 'react-native'; export default function App() { const ref = useRef(null); const [stylesState, setStylesState] = useState(); return ( setStylesState(e.nativeEvent)} style={styles.input} />