-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-diff-display.html
More file actions
150 lines (141 loc) · 4.38 KB
/
test-diff-display.html
File metadata and controls
150 lines (141 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Diff Display</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
.diff-container {
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin: 20px 0;
}
.added {
background-color: #d4edda;
color: #155724;
padding: 2px 4px;
border-radius: 3px;
}
.removed {
background-color: #f8d7da;
color: #721c24;
padding: 2px 4px;
border-radius: 3px;
text-decoration: line-through;
}
.paragraph {
margin: 10px 0;
line-height: 1.5;
}
.paragraph.added {
border-left: 4px solid #28a745;
padding-left: 12px;
background-color: #f8fff9;
}
.paragraph.removed {
border-left: 4px solid #dc3545;
padding-left: 12px;
background-color: #fff8f8;
}
.paragraph.modified {
border-left: 4px solid #ffc107;
padding-left: 12px;
background-color: #fffdf5;
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.summary {
background: #e9ecef;
padding: 10px;
border-radius: 4px;
margin-bottom: 20px;
}
.summary .added-count {
color: #28a745;
font-weight: bold;
}
.summary .removed-count {
color: #dc3545;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Diff Display Test</h1>
<div class="summary">
<strong>Changes:</strong>
<span class="added-count">+1 added</span>,
<span class="removed-count">-1 removed</span>
</div>
<div class="diff-container">
<h2>Current Implementation (Raw Operations)</h2>
<div id="raw-operations"></div>
</div>
<div class="diff-container">
<h2>Processed Diff Display</h2>
<div id="processed-diff"></div>
</div>
<script>
// Sample diff operations from the API
const diffOperations = [
{ type: "equal", text: "Title", start: 0 },
{ type: "equal", text: " ", start: 5 },
{ type: "remove", text: "1", start: 6 },
{ type: "add", text: "2", start: 6 }
];
// Display raw operations
const rawContainer = document.getElementById('raw-operations');
diffOperations.forEach(op => {
const span = document.createElement('span');
span.textContent = op.text;
if (op.type === 'add') {
span.className = 'added';
} else if (op.type === 'remove') {
span.className = 'removed';
}
rawContainer.appendChild(span);
});
// Simulate processed diff content (what our processor should create)
const processedContent = [
{
type: 'paragraph',
children: [
{ text: 'Title ' },
{ text: '1', removed: true },
{ text: '2', added: true }
],
diffType: 'modified'
}
];
// Display processed diff
const processedContainer = document.getElementById('processed-diff');
processedContent.forEach(paragraph => {
const div = document.createElement('div');
div.className = `paragraph ${paragraph.diffType}`;
paragraph.children.forEach(child => {
const span = document.createElement('span');
span.textContent = child.text;
if (child.added) {
span.className = 'added';
} else if (child.removed) {
span.className = 'removed';
}
div.appendChild(span);
});
processedContainer.appendChild(div);
});
</script>
</body>
</html>