Gathering detailed insights and metrics for @zhennann/mavon-editor
Gathering detailed insights and metrics for @zhennann/mavon-editor
Gathering detailed insights and metrics for @zhennann/mavon-editor
Gathering detailed insights and metrics for @zhennann/mavon-editor
mavonEditor - A markdown editor based on Vue that supports a variety of personalized features
npm install @zhennann/mavon-editor
Typescript
Module System
Node Version
NPM Version
Vue (96.26%)
Stylus (3.74%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
6,552 Stars
564 Commits
915 Forks
85 Watchers
10 Branches
41 Contributors
Updated on Jul 12, 2025
Latest Version
4.0.0
Package Id
@zhennann/mavon-editor@4.0.0
Unpacked Size
5.33 MB
Size
2.24 MB
File Count
693
NPM Version
6.14.11
Node Version
12.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
78
基于Vue的markdown编辑器
$ npm install mavon-editor --save
index.js
:
1 // 全局注册 2 // import with ES6 3 import Vue from 'vue' 4 import mavonEditor from 'mavon-editor' 5 import 'mavon-editor/dist/css/index.css' 6 // use 7 Vue.use(mavonEditor) 8 new Vue({ 9 'el': '#main', 10 data() { 11 return { value: '' } 12 } 13 })
index.html
1<div id="main"> 2 <mavon-editor v-model="value"/> 3</div>
name 名称 | type 类型 | default 默认值 | describe 描述 |
---|---|---|---|
value | String | 初始值 | |
language | String | zh-CN | 语言选择,暂支持 zh-CN: 中文简体 , en: 英文 , fr: 法语, pt-BR: 葡萄牙语, ru: 俄语 |
fontSize | String | 15px | 编辑区域文字大小 |
scrollStyle | Boolean | true | 开启滚动条样式(暂时仅支持chrome) |
boxShadow | Boolean | true | 开启边框阴影 |
subfield | Boolean | true | true: 双栏(编辑预览同屏), false: 单栏(编辑预览分屏) |
defaultOpen | String | edit: 默认展示编辑区域 , preview: 默认展示预览区域 , 其他 = edit | |
placeholder | String | 开始编辑... | 输入框为空时默认提示文本 |
editable | Boolean | true | 是否允许编辑 |
codeStyle | String | code-github | markdown样式: 默认github, 可选配色方案 |
toolbarsFlag | Boolean | true | 工具栏是否显示 |
navigation | Boolean | false | 默认展示目录 |
ishljs | Boolean | true | 代码高亮 |
imageFilter | function | null | 图片过滤函数,参数为一个File Object ,要求返回一个Boolean , true 表示文件合法,false 表示文件不合法 |
imageClick | function | null | 图片点击事件,默认为预览,可覆盖 |
toolbars | Object | 如下例 | 工具栏 |
1 /* 2 默认工具栏按钮全部开启, 传入自定义对象 3 例如: { 4 bold: true, // 粗体 5 italic: true,// 斜体 6 header: true,// 标题 7 } 8 此时, 仅仅显示此三个功能键 9 */ 10toolbars: { 11 bold: true, // 粗体 12 italic: true, // 斜体 13 header: true, // 标题 14 underline: true, // 下划线 15 strikethrough: true, // 中划线 16 mark: true, // 标记 17 superscript: true, // 上角标 18 subscript: true, // 下角标 19 quote: true, // 引用 20 ol: true, // 有序列表 21 ul: true, // 无序列表 22 link: true, // 链接 23 imagelink: true, // 图片链接 24 code: true, // code 25 table: true, // 表格 26 fullscreen: true, // 全屏编辑 27 readmodel: true, // 沉浸式阅读 28 htmlcode: true, // 展示html源码 29 help: true, // 帮助 30 /* 1.3.5 */ 31 undo: true, // 上一步 32 redo: true, // 下一步 33 trash: true, // 清空 34 save: true, // 保存(触发events中的save事件) 35 /* 1.4.2 */ 36 navigation: true, // 导航目录 37 /* 2.1.8 */ 38 alignleft: true, // 左对齐 39 aligncenter: true, // 居中 40 alignright: true, // 右对齐 41 /* 2.2.1 */ 42 subfield: true, // 单双栏模式 43 preview: true, // 预览 44 }
name 方法名 | params 参数 | describe 描述 |
---|---|---|
change | String: value , String: render | 编辑区发生变化的回调事件(render: value 经过markdown解析后的结果) |
save | String: value , String: render | ctrl + s 的回调事件(保存按键,同样触发该回调) |
fullScreen | Boolean: status , String: value | 切换全屏编辑的回调事件(boolean: 全屏开启状态) |
readModel | Boolean: status , String: value | 切换沉浸式阅读的回调事件(boolean: 阅读开启状态) |
htmlCode | Boolean: status , String: value | 查看html源码的回调事件(boolean: 源码开启状态) |
subfieldToggle | Boolean: status , String: value | 切换单双栏编辑的回调事件(boolean: 双栏开启状态) |
previewToggle | Boolean: status , String: value | 切换预览编辑的回调事件(boolean: 预览开启状态) |
helpToggle | Boolean: status , String: value | 查看帮助的回调事件(boolean: 帮助开启状态) |
navigationToggle | Boolean: status , String: value | 切换导航目录的回调事件(boolean: 导航开启状态) |
imgAdd | String: filename, File: imgfile | 图片文件添加回调事件(filename: 写在md中的文件名, File: File Object) |
imgDel | String: filename | 图片文件删除回调事件(filename: 写在md中的文件名) |
如不需要hightlight代码高亮显示,你应该设置ishljs为false
开启代码高亮props
1 // ishljs默认为true 2 <mavon-editor :ishljs = "true"></mavon-editor>
为优化插件体积,从v2.4.2起以下文件将默认使用cdnjs
外链:
highlight.js
github-markdown-css
katex
(v2.4.7)代码高亮highlight.js
中的语言解析文件和代码高亮样式将在使用时按需加载.
github-markdown-css
和katex
仅会在mounted
时加载
Notice: 可选配色方案 和 支持的语言 是从 highlight.js/9.12.0 导出的
1<template> 2 <mavon-editor ref=md @imgAdd="$imgAdd" @imgDel="$imgDel"></mavon-editor> 3</template> 4exports default { 5 methods: { 6 // 绑定@imgAdd event 7 $imgAdd(pos, $file){ 8 // 第一步.将图片上传到服务器. 9 var formdata = new FormData(); 10 formdata.append('image', $file); 11 axios({ 12 url: 'server url', 13 method: 'post', 14 data: formdata, 15 headers: { 'Content-Type': 'multipart/form-data' }, 16 }).then((url) => { 17 // 第二步.将返回的url替换到文本原位置 ->  18 /** 19 * $vm 指为mavonEditor实例,可以通过如下两种方式获取 20 * 1. 通过引入对象获取: `import {mavonEditor} from ...` 等方式引入后,`$vm`为`mavonEditor` 21 * 2. 通过$refs获取: html声明ref : `<mavon-editor ref=md ></mavon-editor>,`$vm`为 `this.$refs.md` 22 */ 23 $vm.$img2Url(pos, url); 24 }) 25 } 26 } 27}
key | keycode | 功能 |
---|---|---|
F8 | 119 | 开启/关闭导航 |
F9 | 120 | 预览/编辑切换 |
F10 | 121 | 开启/关闭全屏 |
F11 | 122 | 开启/关闭阅读模式 |
F12 | 123 | 单栏/双栏切换 |
TAB | 9 | 缩进 |
CTRL + S | 17 + 83 | 触发保存 |
CTRL + D | 17 + 68 | 删除选中行 |
CTRL + Z | 17 + 90 | 上一步 |
CTRL + Y | 17 + 89 | 下一步 |
CTRL + BreakSpace | 17 + 8 | 清空编辑 |
CTRL + B | 17 + 66 | 加粗 |
CTRL + I | 17 + 73 | 斜体 |
CTRL + H | 17 + 72 | # 标题 |
CTRL + 1 | 17 + 97 or 49 | # 标题 |
CTRL + 2 | 17 + 98 or 50 | ## 标题 |
CTRL + 3 | 17 + 99 or 51 | ### 标题 |
CTRL + 4 | 17 + 100 or 52 | #### 标题 |
CTRL + 5 | 17 + 101 or 53 | ##### 标题 |
CTRL + 6 | 17 + 102 or 54 | ###### 标题 |
CTRL + U | 17 + 85 | ++下划线++ |
CTRL + M | 17 + 77 | ==标记== |
CTRL + Q | 17 + 81 | > 引用 |
CTRL + O | 17 + 79 | 1. 有序列表 |
CTRL + L | 17 + 76 | 链接 |
CTRL + ALT + S | 17 + 18 + 83 | ^上角标^ |
CTRL + ALT + U | 17 + 18 + 85 | - 无序列表 |
CTRL + ALT + C | 17 + 18 + 67 | ``` 代码块 |
CTRL + ALT + L | 17 + 18 + 76 | |
CTRL + ALT + T | 17 + 18 + 84 | 表格 |
CTRL + SHIFT + S | 17 + 16 + 83 | |
CTRL + SHIFT + D | 17 + 16 + 68 | |
CTRL + SHIFT + C | 17 + 16 + 67 | 居中 |
CTRL + SHIFT + L | 17 + 16 + 76 | 居左 |
CTRL + SHIFT + R | 17 + 16 + 82 | 居右 |
SHIFT + TAB | 16 + 9 | 取消缩进 |
mavonEditor is open source and released under the MIT Licence.
Copyright (c) 2017 hinesboy
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 12/19 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
99 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More