Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/herberthe/react-vditor

Vditor Components for React!
https://github.com/herberthe/react-vditor

lute markdown markdown-editor react reactjs vditor

Last synced: about 1 month ago
JSON representation

Vditor Components for React!

Awesome Lists containing this project

README

        

# react-vditor

[![version](https://img.shields.io/npm/v/react-vditor.svg)](https://www.npmjs.com/package/react-vditor)
[![download](https://img.shields.io/npm/dm/react-vditor.svg)](https://www.npmjs.com/package/react-vditor)
[![cnpmVersion](https://cnpmjs.org/badge/v/react-vditor.svg)](https://cnpmjs.org/package/react-vditor)
[![cnpmDownload](https://cnpmjs.org/badge/d/react-vditor.svg)](https://cnpmjs.org/package/react-vditor)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FHerbertHe%2Freact-vditor.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FHerbertHe%2Freact-vditor?ref=badge_shield)

[English](./README.md) | [简体中文](./README.zh_CN.md)

Vditor Components for React!

> About Vditor, see [Vanessa219/vditor](https://github.com/Vanessa219/vditor)

## Usage

- Add dependencies

```bash
npm install vditor react-vditor
# or
yarn add vditor react-vditor
# or
pnpm install vditor react-vditor
```

- Import component

```ts
import React, { FC, useState, useEffect } from "react"
import Vditor from "vditor"
import { VditorEditor } from "react-vditor"

const TestVditorEditor: FC = () => {
const [vditor, setVditor] = useState()
useEffect(() => {
if (!!vditor) {
console.log(`Update Default Vditor:`)
console.log(vditor)
}
}, [vditor])
return
}

export default TestVditorEditor
```

> see [demo](./__test__/) for more

## What is react-vditor?

react-vditor is a wrapper of Vditor. Due to the reason that the Vditor is independent of frameworks, and we always need to initialize the Vditor in the lifecycle! Repeated operations are always boring! Thus, react-vditor provides some components for React that cover commonly used Vditor editors, makes it easy to use in React.

What's more, the react-vditor is well compatible with Vditor and provides some custom props for better development experience.

## Vditor Components of react-vditor

| components | description |
| ------------------------- | :----------------------------------- |
| `` | Basic Vditor editor |
| `` | Vditor IR editor (Syntax Sugar) |
| `` | Vditor SV editor (Syntax Sugar) |
| `` | Vditor WYSIWYG editor (Syntax Sugar) |
| `` | Vditor markdown preview component |

## Props of Vditor Components

| props | type | required | description |
| ---------- | ------------------------------------------ | -------- | :---------------------------- |
| keyID | string | √ | ID of editor |
| options | [IOptions](./src/types/options/options.ts) | × | Vditor options |
| bindVditor | (vditor: Vditor): void | × | Bind Vditor instance to state |

- Props of VditorPreview

| props | type | required | description |
| ----------- | ------------------------------------------------- | -------- | :----------------------------- |
| markdown | string | √ | markdown content |
| options | [IPreviewOptions](./src/types/options/preview.ts) | × | Vditor preview options |
| customClass | string | × | custom preview component class |

## Development

- The project packages are managed by pnpm

```bash
npm install -g pnpm

pnpm install

# for dev
pnpm dev

# for build
pnpm build
```

- Preivew Changes

```bash
cd __test__

pnpm install

pnpm link ..
```

## License

MIT © [Herbert He](https://github.com/HerbertHe)

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FHerbertHe%2Freact-vditor.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FHerbertHe%2Freact-vditor?ref=badge_large)