Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

milkdown-vue-lxg

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

milkdown-vue-lxg

milkdown vue 二次封装

latest
npmnpm
Version
1.0.7
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

milkdown-vue-lxg

基于milkdown的封装,整合了所有常用插件的Vue3组件 。

Demo

安装

npm install milkdown-vue-lxg
# 或者
yarn add milkdown-vue-lxg
# 或者
pnpm add milkdown-vue-lxg

Usage

模板代码

<editor v-model="doc" ref="editorRef" :config="config" :uploader="uploader" @save="save" />

Props

1、 v-model: markdown内容 2、 config: 组件配置相关

属性类型默认值说明
readonlyBooleanfalse是否为只读
menuBooleanfalse是否展示菜单
themeStringauto主题样式auto、dark, light

3、uploader: 图片上传自定义方法,接收原始图片文件,许返回包含图片地址的对象数组。

[{
  "url": "图片地址",
  "name": "名称"
}]

Event

save: 使用保存快捷键Mod+s时,接收value值的回调

快捷键

参考preset-gfm插件的快捷键。

这里新增加了Mod+/快捷键,可在不同的窗口编辑模式中切换

vue setup示例

// 组件引入
import Editor from 'milkdown-vue-lxg'
import { ref } from 'vue'
const editorRef = ref(null)
const config = ref({
  // 是否为只读模式
  readonly: false,
  // 是否展示菜单
  menu: true,
  // 主题样式auto、dark, light
  theme: 'auto'
})

const doc = ref('')

const save = v => {
  // markdown 内容字符串
  console.log(v)
}

// 自定义上传
const uploader = (images) => {
  // 图片原始文件数组对象
  console.log(images)
  // 返回上传后的地址和名称
  return [{
    url: "https://cyyjs.top/_nuxt/img/qrcode.5c9aef0.jpg",
    name: "head"
  }]
}

// 获取html内容
const getHtml = () => {
  console.log(editorRef.value.getHtml())
}
// 获取目录结构
const getOutline = () => {
  console.log(editorRef.value.getOutline())
}
// 设置markdown 内容
const setValue = (v) => {
  editorRef.value.setValue(v)
}

Keywords

markdown

FAQs

Package last updated on 23 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts