fix: prevent script diff indentation and add scroll
This commit is contained in:
parent
a6b1a8913b
commit
75a87a77ae
@ -262,32 +262,38 @@
|
||||
View
|
||||
</summary>
|
||||
|
||||
<div class="mt-2 overflow-x-auto font-mono text-xs text-gray-800 dark:text-gray-200 whitespace-pre">
|
||||
@php
|
||||
$count = count($ops);
|
||||
@endphp
|
||||
<pre class="mt-2 max-h-96 overflow-auto font-mono text-xs text-gray-800 dark:text-gray-200 whitespace-pre">@php
|
||||
$count = count($ops);
|
||||
|
||||
@for ($i = 0; $i < $count; $i++)
|
||||
@php
|
||||
$op = $ops[$i];
|
||||
$next = $ops[$i + 1] ?? null;
|
||||
@endphp
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$op = $ops[$i];
|
||||
$next = $ops[$i + 1] ?? null;
|
||||
$type = $op['type'] ?? null;
|
||||
$line = (string) ($op['line'] ?? '');
|
||||
|
||||
@if ($op['type'] === 'equal')
|
||||
{{ $op['line'] }}
|
||||
@elseif ($op['type'] === 'delete' && is_array($next) && ($next['type'] ?? null) === 'insert')
|
||||
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $next['line'] }}</span>
|
||||
@php
|
||||
$i++;
|
||||
@endphp
|
||||
@elseif ($op['type'] === 'delete')
|
||||
<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- {{ $op['line'] }}</span>
|
||||
@elseif ($op['type'] === 'insert')
|
||||
<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ {{ $op['line'] }}</span>
|
||||
@endif
|
||||
@endfor
|
||||
</div>
|
||||
if ($type === 'equal') {
|
||||
echo e($line)."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'delete' && is_array($next) && ($next['type'] ?? null) === 'insert') {
|
||||
echo '<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- '.e($line)."</span>\n";
|
||||
echo '<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ '.e((string) ($next['line'] ?? ''))."</span>\n";
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'delete') {
|
||||
echo '<span class="block bg-danger-50 text-danger-700 dark:bg-danger-950/40 dark:text-danger-200">- '.e($line)."</span>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'insert') {
|
||||
echo '<span class="block bg-success-50 text-success-700 dark:bg-success-950/40 dark:text-success-200">+ '.e($line)."</span>\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@endphp</pre>
|
||||
</details>
|
||||
</div>
|
||||
@else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user