Diff Viewer Plugin For Vue.js 3

Description:

A Vue.js diff viewer plugin that can be used to compare the difference between the two code snippets.

Supported languages:

  • css
  • xml: xml, html, xhtml, rss, atom, xjb, xsd, xsl, plist, svg
  • markdown: markdown, md, mkdown, mkd
  • javascript: javascript, js, jsx
  • json
  • plaintext: plaintext, txt, text
  • typescript: typescript, ts

How to use it:

1. Import and register the diff viewer.

import VueDiff from 'vue-diff'
import 'vue-diff/dist/index.css'
app.use(VueDiff);

2. Add the component to the template.

<Diff />

3. Available component props.

mode: {
  type: String as PropType<Mode>,
  default: 'split' // or unified
},
theme: {
  type: String as PropType<Theme>,
  default: 'dark' // or light
},
language: {
  type: String,
  default: 'plaintext'
},
prev: {
  type: String,
  default: ''
},
current: {
  type: String,
  default: ''
},
inputDelay: {
  type: Number,
  default: 0
},
virtualScroll: {
  type: [Boolean, Object] as PropType<boolean|VirtualScroll>,
  default: false
}

4. Extend the plugin with highlight.js.

// register a new language
import yaml from 'highlight.js/lib/languages/yaml'
VueDiff.hljs.registerLanguage('yaml', yaml)

Preview:

Diff Viewer Plugin For Vue.js

Download Details:

Author: hoiheart

Live Demo: https://hoiheart.github.io/vue-diff/demo/index.html

Download Link: https://github.com/hoiheart/vue-diff/archive/refs/heads/master.zip

Official Website: https://github.com/hoiheart/vue-diff

Install & Download:

# NPM
$ npm i vue-diff --save

You Might Be Interested In:

Add Comment