Markdown Editor component for Vue.js

栏目: IT技术 · 发布时间: 4年前

内容简介:☞☞☞

Vue Markdown Editor component for Vue.js

What's new in Bootstrap 5)

Vue.JS Tutorial: Learn Vue.js from Scratch

Javascript Tutorial for Absolute Beginners

Markdown Editor component for Vue.js

Demo

Markdown Editor

Install

npm install v-markdown-editor
import 'v-markdown-editor/dist/v-markdown-editor.css';

import Vue from 'vue'
import Editor from 'v-markdown-editor'

// global register
Vue.use(Editor);

Use CDN

<link href="https://cdn.jsdelivr.net/npm/v-markdown-editor/dist/v-markdown-editor.css" rel="stylesheet">

<script src="https://cdn.jsdelivr.net/npm/v-markdown-editor/dist/v-markdown-editor.min.js" type="text/javascript"></script>
<link href="https://unpkg.com/v-markdown-editor/dist/v-markdown-editor.css" rel="stylesheet">

<script src="https://unpkg.com/v-markdown-editor/dist/v-markdown-editor.min.js" type="text/javascript"></script>

Change

1.2.0
- Support Fontawsome &  Material Design Icons 
- Remove jQuery

Example

<template>
    <div>
        <markdown-editor :options="options"></markdown-editor>
    </div>
</template>


<script>
   
    export default {

        data() {
            return {
                // default options, see more options at: http://codemirror.net/doc/manual.html#config
                options: {                   
                    // lineNumbers: true,
                    // styleActiveLine: true,
                    // styleSelectedText: true,
                    // lineWrapping: true,
                    // indentWithTabs: true,
                    // tabSize: 2,
                    // indentUnit: 2
                }

            }

        }

    }

</script>

v-model

<template>
    <div>
        <markdown-editor v-model="value"></markdown-editor>
    </div>
</template>


<script>
   
    export default {

        data() {
            return {
                value: 'Hello world!'
            }

        }

    }

</script>

Toolbar

// full toolbar: clipboard redo undo | bold italic strikethrough heading | image link | numlist bullist code quote | preview fullscreen

<template>
    <div>
       <markdown-editor toolbar="bold italic heading | image link | numlist bullist code quote | preview fullscreen"></markdown-editor>
    </div>
</template>

add custom button

<template>
    <div>
       <markdown-editor toolbar="bold italic heading | image link | numlist bullist code quote | preview fullscreen | upload" :extend="custom"></markdown-editor>
    </div>
</template>

<script>

    export default {
        data() {
            return {              

                custom: {
                    'upload': {
                        cmd: 'upload',
                        ico: 'fas fa-upload',
                        title: 'Upload File'
                    }
                }
            }
        },       


        created() {
            this.$root.$on('markdown-editor:upload', function (md) {
                md.drawImage({url:'https://i.imgur.com/CbCXhBe.png', title:'this image title'});
            });

        }


    }

</script>

Handle editor

<template>
    <div>
       <markdown-editor ref="md"></markdown-editor>

         <button @click="replace">Handle</button>

    </div>
</template>


<script>

    export default {
       
        methods: {          

            replace(){

                // more info: https://codemirror.net/doc/manual.html#api

                this.$refs.md.editor.replaceSelection("Handle editor");
            }
        },  


    }

</script>

Auto resize

<markdown-editor height="auto"></markdown-editor>

Button Theme

<markdown-editor theme="primary"></markdown-editor>

以上所述就是小编给大家介绍的《Markdown Editor component for Vue.js》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

冒号课堂

冒号课堂

郑晖 / 电子工业出版社 / 2009-10 / 65.00元

《冒号课堂》以课堂对话的形式,借六位师生之口讲述编程要义。上篇对编程范式作了入门性的介绍,并对一些流行的编程语言进行了简评;下篇侧重阐发软件设计思想,其中在范式上以OOP为主,在语言上以C++、Java和C#为主。全书寓庄于谐,深入浅出,既可开阔眼界,又能引发思考,值得编程爱好者品读。一起来看看 《冒号课堂》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换