Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit af3412b

Browse files
authored
Merge pull request #7 from hoiheart/develop
Develop
2 parents 51824a7 + f201da7 commit af3412b

File tree

7 files changed

+47
-33
lines changed

7 files changed

+47
-33
lines changed

.github/workflows/release.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ jobs:
1818
node-version: 12
1919
- name: Install dependencies
2020
run: npm ci
21-
- name: Lint
22-
run: npm run lint
23-
- name: Test
24-
run: npm run test
2521
- name: Build
2622
run: npm run build
2723
- name: Demo

.github/workflows/test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
jobs:
7+
test:
8+
name: test
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 12
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Lint
22+
run: npm run lint
23+
- name: Test
24+
run: npm run test

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vue-diff
22

3-
Vue diff viewer plugin
3+
Vue diff viewer plugin for Vue@3
44
<a href="https://hoiheart.github.io/vue-diff/demo/index.html" target="_blank">demo</a>
55

66
> ⚠️ This plugin does not support Vue2
@@ -32,23 +32,22 @@ Here is the <a href="https://hoiheart.github.io/vue-diff/demo/index.html" target
3232

3333
## Features
3434

35-
* [x] Support split / unified mode
36-
* [x] Support multiple languages and can be extended
37-
* [X] Support two themes (dark / light) and can be customized
38-
* [X] Virtual scroll for large text comparison (*Performance improvements are still needed.*)
39-
* [ ] Support IE11 (IE 11 support for Vue@3 is still pending)
35+
* Support split / unified mode
36+
* Support multiple languages and can be extended
37+
* Support two themes (dark / light) and can be customized
38+
* Virtual scroll for large text comparison
4039

4140
## Install plugin
4241

4342
```bash
4443
npm install vue-diff
4544
```
4645

47-
install plugin in vue application
46+
And install plugin in vue application
4847

4948
```ts
5049
import VueDiff from 'vue-diff'
51-
// import VueDiff from 'vue-diff/dist/index.es5' // If need to use es5 build
50+
5251
import 'vue-diff/dist/index.css'
5352

5453
app.use(VueDiff)
@@ -71,6 +70,9 @@ Insert the diff component with props.
7170
### Settings with default props
7271
```vue
7372
<template>
73+
<!-- If the changed componentName
74+
<VueDiff>
75+
-->
7476
<Diff
7577
:mode="mode"
7678
:theme="theme"

dev/App.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
:language="selected.language"
3939
:prev="prev"
4040
:current="current"
41-
:input-delay="0"
42-
:virtual-scroll="{ height: 500, lineMinHeight: 24, delay: 100 }"
41+
:input-delay="selected.inputDelay"
42+
:virtual-scroll="selected.virtualScroll"
4343
/>
4444
</section>
4545
</div>
4646
</template>
4747

4848
<script lang="ts">
49-
import { defineComponent, onMounted, ref, watch } from 'vue'
49+
import { defineComponent, ref, watch } from 'vue'
5050
5151
import template from './template'
5252
@@ -112,13 +112,6 @@ export default defineComponent({
112112
immediate: true
113113
})
114114
115-
onMounted(() => {
116-
const script = document.createElement('script')
117-
script.async = true
118-
script.defer = true
119-
document.body.appendChild(script)
120-
})
121-
122115
return {
123116
modes,
124117
mode,

rollup.config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import autoprefixer from 'autoprefixer'
77
import typescript from 'rollup-plugin-typescript2'
88
import scss from 'rollup-plugin-scss'
99
import css from 'rollup-plugin-css-only'
10-
import babel from '@rollup/plugin-babel'
10+
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
1111

1212
const options = {
1313
input: 'src/index.ts',
@@ -45,7 +45,11 @@ export default [
4545
output: {
4646
file: 'dist/index.js',
4747
format: 'esm'
48-
}
48+
},
49+
plugins: [
50+
...options.plugins,
51+
getBabelOutputPlugin({ plugins: ['@babel/plugin-proposal-optional-chaining'] })
52+
]
4953
},
5054
// es5 build
5155
{

src/Diff.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
</template>
2929

3030
<script lang="ts">
31-
import {
32-
computed,
33-
defineComponent,
34-
ref,
35-
toRaw
36-
} from 'vue'
31+
import { computed, defineComponent, ref, toRaw } from 'vue'
3732
import { useVirtualScroll, useRender } from './hooks'
3833
import Line from './Line.vue'
3934
@@ -89,7 +84,7 @@ export default defineComponent({
8984
const { minHeight } = useVirtualScroll(props, viewer, scrollOptions, meta)
9085
9186
const setLineHeight = (index: number, height: number) => {
92-
if (meta.value[index]) {
87+
if (meta.value[index] && meta.value[index].height !== height) {
9388
meta.value[index].height = height
9489
}
9590
}

src/Line.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ export default defineComponent({
103103
}
104104
105105
const rendered = () => {
106-
if (!line.value) return
106+
if (!line.value || props.meta.height === line.value.offsetHeight) return
107107
emit('setLineHeight', props.meta.index, line.value.offsetHeight)
108108
}
109109
110110
if (props.scrollOptions) {
111111
useResizeObserver(line, useThrottleFn(() => {
112-
if (!line.value) return
112+
if (!line.value || props.meta.height === line.value.offsetHeight) return
113113
emit('setLineHeight', props.meta.index, line.value.offsetHeight)
114114
}, props.scrollOptions.delay))
115115
}

0 commit comments

Comments
 (0)