1.0.0 • Published 4 years ago

vue-easymde2 v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Vue-EasyMDE

На русском

Markdown Editor component for Vue.js. Support only Vue2.x.

npm package npm downloads

Use Setup

No longer support Vue1.x, you can modify to use

Install

npm install vue-easymde --save

yarn add vue-easymde

Use

  • Internal reference in a single component
<template>
 <vue-easymde v-model="content" ref="markdownEditor" />
</template>

<script>
 import VueEasymde from "vue-easymde";

 export default {
  components: {
    VueEasymde
  }
 };
</script>

<style>
 @import "~easymde/dist/easymde.min.css";
</style>
  • Global reference
import Vue from "vue";
import VueEasymde from "vue-easymde";
import "easymde/dist/easymde.min.css";

Vue.component('vue-easymde', VueEasymde)

Props

propertytypedefaultdescribe
valueStringNoneInitial value, v-model binding can be used
nameStringNoneThe name of the control.
preview-classStringNoneCustom preview style class
autoinitBooleantrueAutomatic initialization
highlightBooleanfalseIs it open to highlight
sanitizeBooleanfalseHTML that does not render input after opening
configsObject{}EasyMDE's config
previewRenderFunction-configs.previewRender

Events

eventdescribearguments
inputTriggered when the Input value changesvalue
blurTriggered when the Input loses focusvalue
initializedTriggered when initialization is completesimplemde

Methods

this.$refs.markdownEditor.simplemde.togglePreview();

examples/index.vue

simplemde.js

Markdown style

e.g. use Github's markdown style

github-markdown-css

install

$ npm install --save github-markdown-css

$ yarn add github-markdown-css

use

<template>
 <vue-easymde preview-class="markdown-body" />
</template>

<style>
 @import "~easymde/dist/easymde.min.css";
 @import "~github-markdown-css";
</style>

Highlight

install

$ npm install --save highlight.js

$ yarn add highlight.js

use

<template>
 <vue-easymde :highlight="true" />
</template>

<script>
 import hljs from "highlight.js";

 window.hljs = hljs;
</script>

<style>
 @import "~easymde/dist/easymde.min.css";
 @import "~highlight.js/styles/atom-one-dark.css";
 /* Highlight theme list: https://github.com/isagalaev/highlight.js/tree/master/src/styles */
</style>

Editor Theme (simplemde-theme-base)

e.g. use simplemde-theme-base theme

install

$ npm install --save simplemde-theme-base

$ yarn add simplemde-theme-base

use

<style>
  @import "~simplemde-theme-base/dist/simplemde-theme-base.min.css";
  /* no need import simplemde.min.css */
</style>

Configuration

Configuration is based on EasyMDE config

Examples

Dependencies

Licence

vue-easymde is open source and released under the MIT Licence.

Copyright (c) 2018 F-loat

Copyright (c) 2019 Ilya Nikulin