55 <button
66 type =" button"
77 @click =" copyUrlToClipboard"
8- class =" inline-flex justify-center px-4 py-2 text-white transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
8+ class =" inline-flex justify-center px-4 py-2 transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
99 v-bind:class =" {
1010 'bg-blue-600 text-white': !copied,
1111 'bg-green-500 text-gray-800': copied,
5151 <main >
5252 <div class =" flex items-start w-full gap-4" >
5353 <div
54- class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm max-h-screen--nav line-numbers min-h-80"
54+ class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm max-h-screen--nav line-number-gutter min-h-80"
5555 >
5656 <RTStickyCopyButton :clickHandler =" copyTextToClipboard" />
57- <p v-for =" (lineDiff, index) in lhsDiff" :key =" index" >
58- <span v-html =" lineDiff" ></span >
59- </p >
57+ <div v-for =" (lineDiff, index) in lhsDiff" :key =" index" >
58+ <p
59+ class =" font-mono break-all whitespace-pre-wrap"
60+ v-html =" lineDiff"
61+ ></p >
62+ </div >
6063 </div >
6164 <div
62- class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm min-h-80 line-numbers max-h-screen--nav"
65+ class =" relative flex-1 px-4 py-2 overflow-y-auto border-2 rounded-sm min-h-80 line-number-gutter max-h-screen--nav"
6366 >
6467 <RTStickyCopyButton :clickHandler =" copyTextToClipboard" />
65- <p v-for =" (lineDiff, index) in rhsDiff" :key =" index" >
66- <span v-html =" lineDiff" ></span >
67- </p >
68+ <div v-for =" (lineDiff, index) in rhsDiff" :key =" index" >
69+ <p
70+ class =" font-mono break-all whitespace-pre-wrap"
71+ v-html =" lineDiff"
72+ ></p >
73+ </div >
6874 </div >
6975 </div >
7076 </main >
@@ -81,33 +87,29 @@ export default {
8187 const gunzip = pako .ungzip (Buffer .from (undoUrlSafeBase64 (_diff), ' base64' ))
8288 const diff = JSON .parse (Buffer .from (gunzip).toString (' utf8' ))
8389 this .lhsDiff = diff
84- .map ((lineDiff ) => {
85- return lineDiff
86- .map ((item ) => {
87- if (item[0 ] === - 1 || item[0 ] === 0 ) {
88- const className = item[0 ] === - 1 ? ' bg-red-300' : ' '
89- return ` <span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${ className} ">${ item[1 ]} </span>`
90- }
91- return ' '
92- })
93- .filter (Boolean )
94- .join (' \n ' )
90+ .map ((item ) => {
91+ const hunkState = item[0 ]
92+ if (hunkState === - 1 || hunkState === 0 ) {
93+ const className = hunkState === - 1 ? ' bg-red-400' : ' '
94+ return ` <span class="font-mono break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
95+ }
96+ return false
9597 })
9698 .filter (Boolean )
99+ .join (' ' )
100+ .split (' \n ' )
97101 this .rhsDiff = diff
98- .map ((lineDiff ) => {
99- return lineDiff
100- .map ((item ) => {
101- if (item[0 ] === 1 || item[0 ] === 0 ) {
102- const className = item[0 ] === 1 ? ' bg-green-300' : ' '
103- return ` <span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${ className} ">${ item[1 ]} </span>`
104- }
105- return ' '
106- })
107- .filter (Boolean )
108- .join (' \n ' )
102+ .map ((item ) => {
103+ const hunkState = item[0 ]
104+ if (hunkState === 1 || hunkState === 0 ) {
105+ const className = hunkState === 1 ? ' bg-green-400' : ' '
106+ return ` <span class="font-mono break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
107+ }
108+ return false
109109 })
110110 .filter (Boolean )
111+ .join (' ' )
112+ .split (' \n ' )
111113 const maxLineCount =
112114 this .lhsDiff .length > this .rhsDiff .length
113115 ? this .lhsDiff .length
@@ -177,19 +179,22 @@ export default {
177179}
178180
179181/* line numbers in diff view */
180- .line-numbers {
182+ .line-number-gutter {
181183 counter-reset : line- numbers;
184+
185+ --line-number-gutter-width : calc (var (--max-line-number-characher ) + 10px );
182186 @apply relative ;
183187 p {
184- padding-left : calc (var (--max-line-number-characher ) - 4px );
188+ padding-left : calc (var (--line-number-gutter-width ) - 10px );
189+ line-height : 1.65 ;
185190 @apply relative ;
186191 & :hover {
187192 @apply bg-gray- 200;
188193 }
189194 & ::before {
190195 counter-increment : line- numbers;
191196 content : counter (line-numbers );
192- width : calc ( var (--max- line-number-characher ) + 4 px );
197+ width : var (--line-number-gutter-width );
193198 @apply absolute left-0 top-0 -mx- 4 bottom-0 text-center bg-gray-200 text-gray-500 flex justify-center items-center text-sm ;
194199 }
195200 & :first-of-type {
0 commit comments