vue3 markdown编辑器推荐(maven-editor vditor tiptap )

news/2024/10/18 0:36:14/

最近项目需要用到markdown编辑器,使用了三种

  1. maven-editor (http://www.mavoneditor.com/?spm=a2c6h.12873639.article-detail.9.aaad62affAKmTV)
  2. vditor (https://b3log.org/vditor/demo/index.html?utm_source=ld246.com)
  3. tiptap (https://github.com/ueberdosis/tiptap/blob/main/docs/api/commands.md#content)

经过多次的踩坑之后

优缺点分析

  • 最推荐使用的是 maven-editor
  • 如果想要所见即所得的效果的话 只有vditor支持,但是vditor是不支持 ==标记== x^2^
    H~2~0这种的markdown语言的,有需要的可以斟酌一下
  • 如果需要html内容的话 maven-editor和vditor都是可以支持的

简单用法

maven-editor

下载

npm install mavon-editor --save

引入 main.js

import Vue from 'vue'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
// use
Vue.use(mavonEditor)

页面中使用

基础使用

<mavon-editor v-model="value"/>

自定义操作框 其中@save是点击保存按钮的时候调取的函数

<mavon-editorref="mavonEditorContinue":toolbars="toolBar"v-model="continueValue":ishljs="true"@save="saveContinue"/>const toolBar = ref({bold: true, // 粗体italic: true, // 斜体header: true, // 标题underline: true, // 下划线strikethrough: false, // 中划线mark: false, // 标记superscript: false, // 上角标subscript: false, // 下角标quote: false, // 引用ol: true, // 有序列表ul: true, // 无序列表link: false, // 链接imagelink: false, // 图片链接code: true, // codetable: true, // 表格fullscreen: false, // 全屏编辑readmodel: false, // 沉浸式阅读htmlcode: false, // 展示html源码help: false, // 帮助/* 1.3.5 */undo: true, // 上一步redo: true, // 下一步trash: false, // 清空save: true, // 保存(触发events中的save事件)/* 1.4.2 */navigation: false, // 导航目录/* 2.1.8 */alignleft: false, // 左对齐aligncenter: false, // 居中alignright: false, // 右对齐/* 2.2.1 */subfield: false, // 单双栏模式preview: false // 预览
})

如果想获得html的内容怎么办

<mavon-editorref="mavonEditorRef"v-model="testContent" 
/>
const mavonEditorRef = ref()
mavonEditorRef.value.d_render

vditor

下载

npm i vditor --save

引入

import Vditor from 'vditor'
import 'vditor/dist/index.css'

使用

<div id="vditor"></div>

这里cdn注意一下 他的不是很稳定 建议将他的包下载到本地 否则很容易出现白屏

vditor.value = new Vditor('vditor', {cdn: window.location.origin + '/cdn',mode: 'sv',minHeight: 200,// 工具栏toolbar: ['headings','table','bold','code','|','ordered-list','list','|','insert-before','insert-after','|','undo','redo','|',{name: '保存',tip: '保存',icon: '<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1700206010742" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4033" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M925.248 356.928l-258.176-258.176a64 64 0 0 0-45.248-18.752H144a64 64 0 0 0-64 64v736a64 64 0 0 0 64 64h736a64 64 0 0 0 64-64V402.176a64 64 0 0 0-18.752-45.248zM288 144h192V256H288V144z m448 736H288V736h448v144z m144 0H800V704a32 32 0 0 0-32-32H256a32 32 0 0 0-32 32v176H144v-736H224V288a32 32 0 0 0 32 32h256a32 32 0 0 0 32-32V144h77.824l258.176 258.176V880z" p-id="4034"></path></svg>',click() {markedResStr.value[ele] = vditor.value.getValue()vditorShow.value = falsevditor.value?.destroy()//   document.getElementById('vditor').innerHTML = ''}}],// 计数counter: { enable: true, type: 'text' },after: () => {if (content) {vditor.value.setValue(content)} else {vditor.value.setValue('')}}})

http://www.ppmy.cn/news/1341732.html

相关文章

网络安全之SSL证书加密

简介 SSL证书是一种数字证书&#xff0c;遵守SSL协议&#xff0c;由受信任的数字证书颁发机构&#xff08;CA&#xff09;验证服务器身份后颁发。它具有服务器身份验证和数据传输加密的功能&#xff0c;能够确保数据在传输过程中的安全性和完整性。 具体来说&#xff0c;SSL证…

QT 应用中集成 Sentry

QT 应用中集成 Sentry QT应用中集成 SentrySentry SDK for C/C注册 Sentry 账号QT 应用中集成 Sentry触发 Crash 上报 QT应用中集成 Sentry Sentry 是一个开源的错误监控和日志记录平台&#xff0c;旨在帮助开发团队实时捕获、跟踪和解决软件应用程序中的错误和异常。它提供了…

结构体的学习

结构体与共用体&#xff0c;枚举 1.数据类型复习&#xff1a; 2结构体. eg&#xff1b;统计全校同学信息 需要记录的点--- 姓名&#xff0c;班级&#xff0c;性别&#xff0c;成绩&#xff0c;年龄 统计名字&#xff1a;char s[ ] [ 100 ] { "Tmo" } …

02 使用jdk运行第一个java程序:HelloWorld

使用jdk运行第一个java程序 1 HelloWorld小案例1.1 编写流程1.2 错误示例 首先在CMD命令行里面&#xff0c;使用javac xxxx.java&#xff0c; 进行编译&#xff0c;其中会有报错&#xff1b; 然后生成xxxx.class 文件&#xff0c;然后使用java xxxx.class 进行运行。 1 HelloWo…

gRPC使用详解

起源特点主要优缺点应用场景组成部分使用方法SpringBoot集成gRPCVert.x集成gRPCNacos集成gRPC监控gRPC调用过程Java使用示例 起源 gRPC的起源可以追溯到2015年&#xff0c;当时谷歌发布了一款开源RPC框架&#xff0c;名为gRPC。gRPC的设计初衷是为了提供一种标准化、可通用和跨…

记录解决报错--vue前后端分离,接口401(Unauthorized)

1.场景 前端访问不了后端接口。报错401。 2.解决步骤 ①在页面console.log(111)查看走到代码的位置没有。&#xff08;走到了&#xff0c;没问题&#xff09; ②查看vue.config.js配置。这段配置就是vue访问api的url。&#xff08;没问题&#xff09; devServer: {port: 80…

[每周一更]-(第86期):NLP-实战操作-文本分类

NLP文本分类的应用场景 医疗领域 - 病历自动摘要&#xff1a; 应用&#xff1a; 利用NLP技术从医疗文档中自动生成病历摘要&#xff0c;以帮助医生更快速地了解患者的状况。 法律领域 - 法律文件分类&#xff1a; 应用&#xff1a; 使用文本分类技术自动分类法律文件&#xf…

openssl3.2 - .pod文件的查看方法

文章目录 .pod文件的查看方法概述笔记初步的解决方法备注 - pod2html.bat的详细用法好像Perl就自带这个BATEND .pod文件的查看方法 概述 看到openssl源码目录下有很多.pod文件, 软件发布的帮助内容都在里面. 当make install后, 大部分的.pod都会转成html文件, 但是有一部分…