GithubHelp home page GithubHelp logo

kunall17 / react-native-markdown-editor Goto Github PK

View Code? Open in Web Editor NEW
95.0 4.0 37.0 255 KB

A markdown editor like github comment editor (contains preview, helper buttons)

Home Page: https://npmjs.com/package/react-native-markdown-editor

License: MIT License

Java 4.01% JavaScript 77.73% Objective-C 13.09% Starlark 5.16%
react-native markdown editor npm package

react-native-markdown-editor's Introduction

react-native-markdown-editor

npm version Build Status

This is a library for rendering a markdown editor for the markdown with helper buttons to easily write markdown. With live preview markdown as well (thanks to https://github.com/Benjamin-Dobell/react-native-markdown-view)

Index

Getting Started

Install the node module:

yarn add react-native-markdown-editor

or with npm:

npm install --save react-native-markdown-editor

Then see Usage for futher details

Screenshots

Screenshot:

Features

  • Multiline textinput for writing markdown
  • Live preview of the markdown written (can be hidden)
  • Helper buttons to write the syntax for the markdown (like github)
Markdown where editor helps (in order for the default format)

Bold Text

Italic Text

Underline text

Strikethrough

Inline code

  • Item 1
  • Item 2

Url Links:

GitHub

function codeExample(arg) {
}

This is an < h1 > tag

Usage

Import the editor through

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

And use like this this in the jsx

<MarkdownEditor />

And pass a function onMarkdownChange which will be callback when markdown is changed

 <MarkdownEditor onMarkdownChange={this.onTextChange} />

It can be used with a toolbar and have a submit menu option there!

Customizing

Your own custom formats

You can give a custom list of buttons you want to give the default is Formats by speicifying

   <MarkdownEditor Formats={YOUR_CUSTOM_Formats} />

Customize the helper button

You can customize the helper button using the markdownButton prop. The buttons are rendered using a FlatList and the data passed is the Formats

markdownButton can be method like

const defaultMarkdownButton = ({ item, getState, setState }) =>
  <Button
    title={item.key}
    onPress={() => item.onPress({ getState, setState, item })}
    color={FOREGROUND_COLOR}
    style={inlinePadding}
  />

Where item is an each object in the Formats list

You can also import the methods used in Formats by using

import { applyWrapFormatNewLines, applyWrapFormat, applyWebLinkFormat, applyListFormat } from 'react-native-markdown-editor';

Customize the renderButton styles

You can add a style key in the Formats.js and this will be used while rendering the button

{ key: 'B', wrapper: '**', onPress: applyWrapFormat, style: { fontWeight: 'bold' } },

Props

Name Type Default Description
Formats Array Formats Elements for the markdown buttons
markdownButton function defaultMarkdownButton A custom function to render the markdown buttons
onMarkdownChange function Callback function, calls when markdown is typed
showPreview boolean false To show the markdown preview by Default

Contributing

PR's/Issues/Bugs or suggestions are welcomed. Please post them at https://github.com/kunall17/react-native-markdown-editor/issues.

License

The MIT License.

See LICENSE

react-native-markdown-editor's People

Contributors

anzeblabla avatar kethan1 avatar kevindoole avatar kunall17 avatar tjcages avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-markdown-editor's Issues

react-native-markdown-editor not found

the package */node_modules/react-native-markdown-editor/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (*/node_modules/react-native-markdown-editor/main.js. Indeed, none of these files exist...

RN 0.72.3 + Expo 49 Typescript - Is it still maintained or abandoned?

I am trying to install it:

PS D:\XXXXXXXXXXXXXX> npm install --save react-native-markdown-editor
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.0.0-alpha.12" from [email protected]
npm ERR! node_modules/react-native-markdown-editor
npm ERR!   react-native-markdown-editor@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!

Packages:

{
  //other...
  "dependencies": {
     //other...
    "@types/react-dom": "^18.2.18",
    "expo": "49.0.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-native": "0.72.3",
    "react-native-webview": "^13.6.3",
  },
  "devDependencies": {
     //other...
    "@babel/core": "7.19.3",
    "@types/react": "^18.2.45",
    "@types/react-native": "0.72.2",
    "typescript": "5.0.2"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.