├── .browserslistrc ├── src ├── index.js └── components │ ├── CodeDiffChunk.vue │ └── CodeDiffViewer.vue ├── babel.config.js ├── demo ├── assets │ └── logo.png ├── main.js ├── App.vue └── utils.js ├── public ├── favicon.ico └── index.html ├── postcss.config.js ├── screenshots ├── modify.png ├── code_diff.png └── add_delete.png ├── .editorconfig ├── vue.config.js ├── .gitignore ├── README.md ├── package.json └── .eslintrc.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./components/CodeDiffViewer.vue'); 2 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | }; 6 | -------------------------------------------------------------------------------- /demo/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeDebugTest/vue-diff-view/HEAD/demo/assets/logo.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeDebugTest/vue-diff-view/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /screenshots/modify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeDebugTest/vue-diff-view/HEAD/screenshots/modify.png -------------------------------------------------------------------------------- /screenshots/code_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeDebugTest/vue-diff-view/HEAD/screenshots/code_diff.png -------------------------------------------------------------------------------- /screenshots/add_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeDebugTest/vue-diff-view/HEAD/screenshots/add_delete.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 4 4 | end_of_line = lf 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | -------------------------------------------------------------------------------- /demo/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | 4 | Vue.config.productionTip = false; 5 | 6 | new Vue({ 7 | render: h => h(App) 8 | }).$mount('#app'); 9 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | outputDir: 'demo-dist', 3 | pages: { 4 | index: { 5 | entry: 'demo/main.js', 6 | template: 'public/index.html' 7 | } 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | vue-diff-view 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-diff-view 2 | > a git diff component for Vue.js 3 | 4 | ## Usage 5 | ```vue 6 | 11 | 12 | 28 | ``` 29 | 30 | ## DEMO 31 | 32 | ### overview 33 | ![code diff](https://github.com/codeDebugTest/vue-diff-view/blob/master/screenshots/code_diff.png); 34 | 35 | ![modify file](https://github.com/codeDebugTest/vue-diff-view/raw/master/screenshots/modify.png) 36 | 37 | ### run demo case 38 | ```command line 39 | npm run serve 40 | ``` 41 | 42 | ## todo 43 | when select code, not trigger line number. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-diff-view", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "dev": "npm run serve", 8 | "build": "vue-cli-service build", 9 | "lint": "vue-cli-service lint" 10 | }, 11 | "author": "liuye (liuye6y@gmail.com)", 12 | "license": "MIT", 13 | "dependencies": { 14 | "diff": "^3.5.0" 15 | }, 16 | "devDependencies": { 17 | "@vue/cli-plugin-babel": "^4.2.0", 18 | "@vue/cli-plugin-eslint": "^4.2.0", 19 | "@vue/cli-service": "^4.2.0", 20 | "@vue/eslint-config-standard": "^5.1.0", 21 | "babel-eslint": "^10.0.3", 22 | "eslint": "^6.8.0", 23 | "eslint-plugin-import": "^2.20.1", 24 | "eslint-plugin-node": "^11.0.0", 25 | "eslint-plugin-promise": "^4.2.1", 26 | "eslint-plugin-standard": "^4.0.0", 27 | "eslint-plugin-vue": "^6.1.2", 28 | "less": "^3.9.0", 29 | "less-loader": "^4.1.0", 30 | "rollup": "^2.2.0", 31 | "rollup-plugin-babel": "^4.4.0", 32 | "rollup-plugin-terser": "^5.3.0", 33 | "vue": "^2.6.11", 34 | "vue-template-compiler": "^2.6.11", 35 | "webpack-dev-server": ">=3.1.11" 36 | }, 37 | "peerDependencies": { 38 | "vue": "^2.6.11" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | browser: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/essential', 8 | '@vue/standard' 9 | ], 10 | rules: { 11 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 13 | // allow paren-less arrow functions 14 | 'arrow-parens': 0, 15 | // allow async-await 16 | 'generator-star-spacing': 0, 17 | // fix unused var error for JSX custom tags 18 | 'vue/jsx-uses-vars': 2, 19 | 'no-throw-literal': 0, 20 | 21 | 'semi': ['error', 'always'], 22 | 'indent': ['error', 4, {SwitchCase: 1}], 23 | 'space-before-function-paren': ['error', { 24 | anonymous: 'always', 25 | named: 'never', 26 | asyncArrow: 'always' 27 | }], 28 | 'brace-style': ['error', 'stroustrup'], 29 | 'operator-linebreak': ['error', 'before'], 30 | 'eol-last': 'error', 31 | 'no-new': 0, 32 | 'no-else-return': 0, 33 | 'padded-blocks': 0, 34 | 'no-fallthrough': 'off', 35 | 'default-case': 'error', 36 | 'object-curly-spacing': 'off' 37 | }, 38 | parserOptions: { 39 | parser: 'babel-eslint' 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /demo/App.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 38 | 39 | 48 | -------------------------------------------------------------------------------- /src/components/CodeDiffChunk.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 30 | 31 | 101 | -------------------------------------------------------------------------------- /demo/utils.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export default [ 3 | { 4 | fileName: 'src/components/image.html', 5 | current: "\n
\n \n \n \n\n \n\n \n \n \n
\n\n\n
width: ${imgWidth}; margin: 0 auto;\">\n
${imgRatioClass} ${.ctn}\" style=\" height: 0; padding-bottom: ${imgRatio}; \">\n \n \n \n \n \n
${imgText}
\n \n
\n
\n\n
${titleClass}\" style=\"margin:${titleMargin};\">\n \n ${mainTitleGap} ${mainTitleFont} ${mainLineClamp} ${.title-main}\">\n ${imgTitleMain}\n
\n \n \n
${subTitleGap} ${subTitleFont}\n ${subLineClamp} ${.title-sub}\">\n ${imgTitleSub}\n
\n \n\n\n", 6 | last: "\n
\n \n \n \n\n \n\n \n \n \n
\n\n\n
width: ${imgWidth}; margin: 0 auto;\">\n
${imgRatioClass} ${.ctn}\" style=\" height: 0; padding-bottom: ${imgRatio}; \">\n \n \n \n \n \n
${imgText}
\n \n
\n
\n\n
${titleClass}\" style=\"margin:${titleMargin};\">\n \n ${mainTitleGap} ${mainTitleFont} ${mainLineClamp} ${.title-main}\">\n ${imgTitleMain}\n
\n \n \n
${subTitleGap} ${subTitleFont}\n ${subLineClamp} ${.title-sub}\">\n ${imgTitleSub}\n
\n \n\n\n" 7 | }, 8 | { 9 | fileName: "src/components/image.less", 10 | current: ".ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}\n.ec-pl-image-title-top {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n margin-left: 10px;\n margin-right: 10px;\n padding: 10px;\n}\n.ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}\n.ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}", 11 | last: ".ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}\n.ec-pl-image-title-top {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n margin: 10px;\n}\n.ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 20%;\n border: 2px;\n transform: translate(-50%, -50%);\n }\n}\n.ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}" 12 | }, 13 | { 14 | fileName: "src/components/ImageDelete.less", 15 | current: "", 16 | last: ".ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}\n.ec-pl-image-title-top {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n margin: 10px;\n}\n" 17 | }, 18 | { 19 | fileName: "src/components/TestAdd.less", 20 | last: "", 21 | current: ".ec-image {\n &-icon {\n position: absolute;\n left: 50%;\n top: 50%;\n color: #fff;\n background-color: rgba(0, 0, 0, .3);\n border-radius: 50%;\n transform: translate(-50%, -50%);\n }\n}\n.ec-pl-image-title-top {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n margin: 10px;\n}\n" 22 | } 23 | ]; -------------------------------------------------------------------------------- /src/components/CodeDiffViewer.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 219 | 220 | 249 | --------------------------------------------------------------------------------