A Vue.js Component for editing and previewing markdown using Vuetify.js and command line rendering utility.
npm install vuetify-markdown-editor
Since this component is based on Vuetify, it is required to install and configure Vuetify. For installing Vuetify, please visit https://vuetifyjs.com/en/getting-started/quick-start.
This package also provides a command line utility to render markdown files.
Install globally:
npm install -g vuetify-markdown-editor
Or install locally and use npx
to run:
npm install vuetify-markdown-editor
npx render-cli input.md [output.html]
Usage:
render-cli input.md [output.html]
To use the rendered html, remember to add css files for Katex and highlight.js:
text-html-basic
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css"
integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.8/styles/default.min.css"
/>
\\[
and \\]
for formula block, and \\(
and \\)
for inline formula)This package can be used in Node.js module:
text-html-basic
<template>
<v-app>
<Editor
mode="Rendered"
ref="editor"
hint="Test"
nativeEmoji
:outline="false"
:preview="true"
v-model="text"
/>
</v-app>
</template>
<script>
import { Editor } from 'vuetify-markdown-editor';
export default {
name: 'app',
components: {
Editor
},
data() {
return {
text: ''
};
},
mounted() {
// Access properties or methods using $refs
this.$refs.editor.focus();
// this.$refs.editor.upload();
// Dark theme
//this.$vuetify.theme.dark = true;
}
};
</script>
Prop | Default | Description |
---|---|---|
value | '' |
String that binds to the textarea |
mode | 'Rendered' |
When set to ‘Source’, the preview will display html source code |
outline | false |
The border will be outlined instead of card style |
color | undefined |
The outline and icon’s color |
preview | true |
Add the responsive preview |
nativeEmoji | false |
Use native emoji instead of pictures |
emoji | true |
Enable emoji input |
image | true |
Enable image upload |
hint | '' |
Add description at the bottom |
fileTarget | / |
Image upload target uri |
fileFilter | file => file.type.startsWith('image') |
Allow only specific files. Return true to allow, false to reject |
Method | Description |
---|---|
upload() | Start or resume uploading all files in list |
pause() | Pause uploading |
resume() | Resume uploading |
focus() | Focus on the editor |
Property | Description |
---|---|
files | Get all files in list in FlowFile format |
Clone this repository, and then run:
npm install
npm run serve
Then open http://localhost:8080 in browser to test.
Solo mode: <Editor v-model="text" />
Outline mode: <Editor outline v-model="text" />
Dark mode: this.$vuetify.theme.dark = true;
Emoji:
DCsunset/vuetify-markdown-editor
#vuejs #javascript #Markdown #vue-js