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>
posted @   黑人的乔丹鞋  阅读(477)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示