markdown editor_最强Markdown,tui.editor+vue

前言

自建博客我觉得最痛苦的事就是选用哪个Markdown,找一个符合自己并且集成在里面非常不容易,当前我使用的是editor.md这款,其实非常不错,地址:https://pandao.github.io/editor.md,但是他有几个缺点,让我萌生换一个的想法。

3020258ccc21fc61aa1b86cdfb7aeead.png

于是闲下时间重新找了一款,那就是tui.editor。tui.editor和editor.md的star都挺高,另外editor.md是国产的。

573965775e044c7ce5fbc9a723064968.png
bf29969b0b7fc5b75beea34f1df6d290.png

下面将演示tui.editor与Vue集成。

tui.editor与Vue

  1. 下载
npm install --save @toast-ui/vue-editor
  1. 新建vue,引入组件。
<div><editor:initialValue="editorText":options="editorOptions"height="500px"initialEditType="wysiwyg"previewStyle="vertical"
    />div>template><script>import "codemirror/lib/codemirror.css";import "@toast-ui/editor/dist/toastui-editor.css";import { Editor } from "@toast-ui/vue-editor";export default {
  data() {return {editorText:"#asd"
    };
  },components: {editor: Editor
  },
  created() {
  },methods: {
  }
};script><style lang="less" scoped>style>
e518ac78da5cfe82385d4d92eb5f51f5.png
  1. 运行
npm run serve
96b14ef9fd8af6ebea9f97dfd958493a.png

但是上述缺点是不能代码高亮,如果要代码高亮,需要增加插件,而这种方式引入具体我也不知道怎么设置。

只预览

class="container">
"editor">




效果如下,支持代码高亮。

c8e5d38116db9b6cd423aefd4aaa96ad.png

API

tui.editor提供了非常多个API,可以到https://nhn.github.io/tui.editor/latest/下查看。

2d63cc02c798ebbe91c889d037b50e80.png

另外代码风格可以到https://github.com/highlightjs/highlight.js/tree/master/src/styles下载,只需要替换如下位置即可

import "highlight.js/styles/{风格}.css";
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值