1
1
<script setup lang="ts">
2
2
import { ref , computed , watch } from " vue" ;
3
- import * as diff from " diff" ;
3
+ import { diffLines , diffWords , diffWordsWithSpace , diffChars , diffTrimmedLines , diffSentences , diffCss } from " diff" ;
4
4
5
5
// Types needed for the diff viewer
6
6
interface DiffChange {
@@ -67,7 +67,7 @@ const props = withDefaults(defineProps<Props>(), {
67
67
68
68
// Component state
69
69
const lineInformation = ref <LineInformation []>([]);
70
- const diffLines = ref <number []>([]);
70
+ const diffLineIndexes = ref <number []>([]);
71
71
const expandedBlocks = ref <number []>([]);
72
72
73
73
// Compute diff when inputs change
@@ -92,34 +92,34 @@ const computeDiff = (): void => {
92
92
});
93
93
94
94
lineInformation .value = result ;
95
- diffLines .value = [];
95
+ diffLineIndexes .value = [];
96
96
return ;
97
97
}
98
98
99
99
// Generate diff based on selected method
100
100
let diffOutput: DiffChange [];
101
101
switch (compareMethod ) {
102
102
case " diffChars" :
103
- diffOutput = diff . diffChars (oldValue , newValue );
103
+ diffOutput = diffChars (oldValue , newValue );
104
104
break ;
105
105
case " diffWords" :
106
- diffOutput = diff . diffWords (oldValue , newValue );
106
+ diffOutput = diffWords (oldValue , newValue );
107
107
break ;
108
108
case " diffWordsWithSpace" :
109
- diffOutput = diff . diffWordsWithSpace (oldValue , newValue );
109
+ diffOutput = diffWordsWithSpace (oldValue , newValue );
110
110
break ;
111
111
case " diffTrimmedLines" :
112
- diffOutput = diff . diffTrimmedLines (oldValue , newValue );
112
+ diffOutput = diffTrimmedLines (oldValue , newValue );
113
113
break ;
114
114
case " diffSentences" :
115
- diffOutput = diff . diffSentences (oldValue , newValue );
115
+ diffOutput = diffSentences (oldValue , newValue );
116
116
break ;
117
117
case " diffCss" :
118
- diffOutput = diff . diffCss (oldValue , newValue );
118
+ diffOutput = diffCss (oldValue , newValue );
119
119
break ;
120
120
case " diffLines" :
121
121
default :
122
- diffOutput = diff . diffLines (oldValue , newValue );
122
+ diffOutput = diffLines (oldValue , newValue );
123
123
break ;
124
124
}
125
125
@@ -170,7 +170,7 @@ const computeDiff = (): void => {
170
170
});
171
171
172
172
lineInformation .value = result ;
173
- diffLines .value = diffLinesArray ;
173
+ diffLineIndexes .value = diffLinesArray ;
174
174
175
175
// Reset expanded blocks when diff changes
176
176
expandedBlocks .value = [];
@@ -194,7 +194,7 @@ const renderDiff = computed<DiffItem[]>(() => {
194
194
const result: DiffItem [] = [];
195
195
196
196
// Create a mutable copy of diffLines for manipulation in the loop
197
- const currentDiffLines = [... diffLines .value ];
197
+ const currentDiffLines = [... diffLineIndexes .value ];
198
198
199
199
lineInformation .value .forEach ((line , i ) => {
200
200
const diffBlockStart = currentDiffLines [0 ];
0 commit comments