Code Monkey home page Code Monkey logo

vue-vditor's Introduction

Vue Vditor

npm npm NPM build GitHub stars

一款基于vditor实现的vue版本的markdown编辑器,支持在Vue2.0和Vue3.0中使用。

Vditor预览地址

功能需求

  • 支持 Markdown 语法、兼容 HTML
  • 支持多种编辑模式,需要有即时渲染、分屏预览模式
  • 支持 xss 安全过滤
  • 支持主题切换并提供多套主题
  • 针对不同应用场景可支持简洁模式、全功能模式切换
  • 预留文件在线预览功能(需后台功能支持)
  • 支持附件上传(需提供文件服务),并对常见格式附件图标渲染
  • 支持图片全屏预览功能

使用方法

安装

# Vue3 不用安装 @vue/composition-api
npm install -S vue-vditor vditor @vue/composition-api

使用

import 'vditor/dist/index.css';
import VueVditor from 'vue-vditor';

Vue.use(VueVditor);
<VueVditor v-model="content" :options="options" @after="handleAfter" class="editor"></VueVditor>

配置

  • Props
属性 必须 说明 类型 默认值
mode false 编辑器模式,支持完整(full)、简洁(simple)、移动端模式(mobile) String 'full'
v-model false 内容,响应式的 String ''
options false 编辑器配置,详细请看Vditor API Object
  • Events
名字 说明
after(editor: Vditor) 编辑器异步渲染完成后的回调方法,可通过参数获取编辑器实例,调用编辑器method
input(value: string) 输入后触发
focus(value: string) 聚焦后触发
blur(value: string) 失焦后触发
esc(value: string) esc 按下后触发
ctrlEnter(value: string) ⌘/ctrl+enter 按下后触发
select(value: string) 编辑器中选中文字后触发
  • Methods

支持Vditor全部Methods,可通过after获取到Vditor实例,然后调用其method:

<VueVditor v-model="content"  @after="handleAfter"></VueVditor>
let vueEditor = null;
function handleAfter(editor: Vditor) {
  vueEditor = editor;
}
// 插入内容
vueEditor.insertValue('![](https://gitee.com/letwrong/Picture/raw/master/20210331155321.jpg)');
// 获取内容
vueEditor.getValue()
// ...更多method请查看Vditor文档

vue-vditor's People

Contributors

bwrong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zsh2517

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.