vue中使用web-editor-markdown在线编辑浏览markdown
web-editor-markdown
是Web浏览器中的Markdown编辑器,用于实时渲染,如.它基于 TypeScript 和 JavaScript,不依赖于任何第三方框架。它支持中文友好,可以轻松扩展并连接到原生JavaScript,Vue,React,Angular和其他应用程序。它提供四种渲染模式:、 和 。如有必要,其底层还支持协同编辑的能力,并提供原子来扩展协作编辑。Typora
SOURCE
SOURCE_AND_PREVIEW
RENDER
PREVIEW
Operation
github https://github.com/Ben-love-zy/web-editor-markdown
npm install web-editor-markdown --save
<template>
<button @click="print">print</button>
{{text}}
<div id="box"></div>
</template>
<script setup lang="ts">
import { onMounted,ref } from "vue";
import { Editor, withUndoRedo } from "web-editor-markdown";
let text = ref<string>('');
let editor:Editor;
onMounted(() => {
editor = new Editor(document.querySelector("#box") as HTMLElement);
editor = withUndoRedo(editor);
editor.insertTextAtCursor('# 标题');
});
const print = ()=> {
text.value = editor.getContent();
}
</script>
<style scoped></style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)