Code Monkey home page Code Monkey logo

vditor-react's Introduction

English version | 简体中文

Vditor for React

Vditor is the next-generation Markdown editor open-sourced by B3log. This project is the React wrapper of it.

Installation

npm install vditor-react --save

Usage

import ReactDOM from 'react-dom'
import Vditor from 'react-vditor'

ReactDOM.render(
	<Vditor height={700} />, 
	document.getElementById('node')
);

Then include the specific div tag in the HTML file:

<div id="node" />

API

vditor-react maps most of its props into options of the original Vditor APIs, which you can access here (Chinese version only).

vditor-react also provides some props to improve the React practice, which are as follow:

Name Definition Default Description Deprecated Vditor API
onInit (text: String) => {} () => {} Called after the editor UI has been loaded, with the initial text. options.after
onSelect (selection: String, text: String) => {} () => {} Called when the text selection is updated, with the selected text and the full text. options.select
onInput (text: String) => {} () => {} Called shortly after text inputs, with the full text. It won’t be called during an IME composition. options.input
darkMode Boolean false Whether the editor UI is in dark mode. options.theme
disabled Boolean false Whether to disable the editor. disabled() enable()

You can also extend this component and access the Vditor instance as this.editor.

Example

There is a demo under demo/ with full functionalities of vditor-react, and it also implements system-wide (browser-wide) Dark Mode support and an 'Enable/Disable' switch with React Hooks.

You can start the demo by the following command:

npm run dev

Then open the browser and check it out in http://127.0.0.1:8081.

vditor-react's People

Contributors

stevapple avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

rpdg arvin-he

vditor-react's Issues

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.