2.0.0 • Published 12 months ago

@bitheral/vue-easymde v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Vue-EasyMDE

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

npm package npm downloads

readme на русском

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
update:modelValueTriggered when the Input value changesvalue
blurTriggered when the Input loses focusvalue
initializedTriggered when initialization is completeeasymde

Methods

this.$refs.markdownEditor.easymde.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