npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-markdown-content-editor

v1.1.3

Published

A React Native component for editing and viewing markdown content with LaTeX support.

Downloads

314

Readme

React Native Markdown Editor with LaTeX Support

A professional-grade React Native component for editing and rendering Markdown with full LaTeX support, designed for educational, scientific, and technical documentation applications.

Features

  • Markdown Editing & Rendering: Switch between rich text editing and Markdown viewing seamlessly.
  • LaTeX Support: Render inline and block LaTeX equations with high fidelity.
  • Customization Options: Tailor the editor's behavior and appearance with custom styles and plugins.
  • Read-Only Mode: Disable editing to use the component as a viewer for Markdown and LaTeX content.
  • HTML to Markdown Conversion: Automatically convert HTML to Markdown when switching between editor and viewer.
  • Customizable Toolbar: Easily configure the toolbar with your desired actions and styles.

Screenshots

Here are some screenshots of the Markdown Editor in action:

Screenshot Collage

Installation

Install the package via NPM:

npm install react-native-markdown-editor

Required Peer Dependencies

Make sure to install the required peer dependencies for seamless functionality:

npm install react-native-pell-rich-editor react-native-markdown-display react-native-math-view react-native-webview markdown-it markdown-it-mathjax3

Usage

The MarkdownEditor component provides a flexible interface for rendering and editing Markdown with LaTeX support. Below is a quick-start example.

import React from 'react';
import { View } from 'react-native';
import { MarkdownEditor } from 'react-native-markdown-editor';

const App = () => {
  const handleContentChange = (content) => {
    console.log('Updated Content:', content);
  };

  return (
    <View style={{ flex: 1, padding: 20 }}>
      <MarkdownEditor
        initialContent={`# Welcome to Markdown Editor with LaTeX
This editor supports inline equations, such as $E=mc^2$, and block equations like below:
$$
        \frac{a}{b} = \frac{1}{2}
$$`}
        onContentChange={handleContentChange}
        editorStyles={{ backgroundColor: '#ffffff', padding: 10 }}
        markdownStyles={{ body: { color: '#333' } }}
        toolbar={true}
        toolbarActions={['bold', 'italic', 'underline', 'bulletList', 'orderedList']}
        toolbarStyles={{ backgroundColor: '#e0e0e0', borderRadius: 8, padding: 10 }}
      />
    </View>
  );
};

export default App;

Props

initialContent

  • Type: string
  • Description: Initial markdown content to be displayed in the editor. Accepts any valid Markdown and LaTeX syntax.

onContentChange

  • Type: (content: string) => void
  • Description: Callback function that provides the updated content whenever changes are made in the editor.

editorStyles

  • Type: object
  • Description: Custom styles for the rich text editor. Can be used to style the background, font, padding, etc.

markdownStyles

  • Type: object
  • Description: Custom styles for the Markdown display. Allows you to customize text color, background, font size, and more.

readOnly

  • Type: boolean
  • Default: false
  • Description: Set to true to enable read-only mode, where the component is used solely for viewing content.

toolbar

  • Type: boolean
  • Default: true
  • Description: Set to true to display the toolbar, and false to hide it.

toolbarActions

  • Type: string[]
  • Description: Array of actions for the toolbar. Customize the toolbar with actions like 'bold', 'italic', 'underline', etc.

toolbarStyles

  • Type: object
  • Description: Custom styles for the toolbar. You can style the background, padding, alignment, and more.

markdownItPlugins

  • Type: Array<(md: any) => void>
  • Description: Array of functions to add plugins to the markdown-it instance, enabling advanced Markdown extensions such as footnotes, tables, and more.

Advanced Customization

Adding Markdown-It Plugins

To extend markdown-it functionality, use the markdownItPlugins prop to pass in additional plugins. For example:

import markdownItEmoji from 'markdown-it-emoji';

<MarkdownEditor markdownItPlugins={[markdownItEmoji]} />

Issues & Troubleshooting

iOS Configuration for react-native-svg

If you encounter issues with react-native-svg not being linked properly on iOS, follow these steps:

  1. Add the Pod Entry: In your Podfile, ensure RNSVG is added with the correct path:

    pod 'RNSVG', :path => '../node_modules/react-native-svg'
  2. Install Pods: After adding the entry, run the following commands in your project's ios directory:

    cd ios
    pod install
    cd ..
  3. Rebuild Project: In Xcode, go to Product > Clean Build Folder, then rebuild the project.

Dependency Warnings

For any warnings related to dependency.assets, verify that all dependencies are up-to-date, especially if using older packages with newer versions of React Native.

Roadmap & Upcoming Features

  • Image Upload Support: Integrated image uploading directly in the editor.
  • Autosave Functionality: Autosave with adjustable debounce timing.

License

MIT License. Please refer to the LICENSE file for more details.