Skip to content

Commit 4725808

Browse files
committed
Merge pull request #81 from danvk/perceptual
Show perceptual diff boxes; update React, codediff.js
2 parents fafb453 + 6ca3d08 commit 4725808

File tree

11 files changed

+594
-383
lines changed

11 files changed

+594
-383
lines changed

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"jquery": "~2.1.1",
1919
"highlightjs": "~8.0.0",
2020
"underscore": "~1.6.0",
21-
"react": "~0.11.1",
22-
"react-router": "~0.10.2"
21+
"react": "~0.12.2",
22+
"react-router": "~0.11.6",
23+
"resemblejs": "danvk/Resemble.js#master"
2324
}
2425
}

tests/runner.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<script src="../webdiff/static/components/react/react.js"></script>
1919
<script src="../webdiff/static/components/react/JSXTransformer.js"></script>
2020
<script src="../webdiff/static/components/react-router/dist/react-router.js"></script>
21+
<script src="../webdiff/static/components/resemblejs/resemble.js"></script>
2122

2223
<script src="../webdiff/static/codediff.js/difflib.js"></script>
2324
<script src="../webdiff/static/codediff.js/codediff.js"></script>

tests/travis-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set -o errexit
44

55
nosetests tests
6-
grunt test --verbose --force
6+
grunt test --verbose

webdiff/static/codediff.js/codediff.css

Lines changed: 82 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,64 @@
22
box-sizing: border-box;
33
}
44

5-
.diff-column-width {
6-
max-width: 101ch;
7-
min-width: 40ch;
8-
width: 100%;
9-
}
10-
.diff-column {
11-
max-width: 50%;
5+
div.diff {
6+
max-width: 100%;
7+
display: table;
128
}
139

14-
.diff-header, .line-no-header {
15-
font-weight: bold;
16-
border-bottom: 1px solid #ddd;
17-
padding: 2px;
10+
table.diff {
11+
width: 100%;
12+
border-spacing: 0;
1813
}
1914

20-
.diff-line-no {
21-
display: table; /* shrink to fit longest line number */
15+
td.code {
16+
/* this is the max width of each column of code. */
17+
/* for table cells, `width` behaves more like `max-width`. */
18+
width: 61ch;
19+
white-space: pre-wrap;
20+
word-wrap: break-word;
2221
}
23-
.diff-left .diff-line-no {
24-
float: left;
25-
}
26-
.diff-right .diff-line-no {
27-
float: right;
28-
}
29-
.diff-remainder {
30-
overflow: hidden; /* see http://stackoverflow.com/questions/5540485/how-to-make-an-inline-block-element-fill-the-remainder-of-the-line */
22+
23+
table.diff td {
24+
vertical-align: top;
3125
}
3226

27+
/* Line numbers with thin vertical bars to indicate wrapped lines. */
3328
.line-no {
3429
color: #999;
3530
background-color: #f7f7f7;
3631
}
32+
.line-no:first-child {
33+
background-image:
34+
linear-gradient(to left, #f7f7f7, #f7f7f7 3px, transparent, transparent 6px, #f7f7f7 6px),
35+
linear-gradient(#f7f7f7, #f7f7f7 1.4em, #aaa 1.4em);
36+
}
37+
.line-no:last-child {
38+
background-image:
39+
linear-gradient(to right, #f7f7f7, #f7f7f7 3px, transparent, transparent 6px, #f7f7f7 6px),
40+
linear-gradient(#f7f7f7, #f7f7f7 1.4em, #aaa 1.4em);
41+
}
3742

38-
.diff-left .line-no {
43+
table.diff .line-no:first-child {
3944
border-right: 1px solid #ddd;
4045
text-align: right;
4146
}
42-
.diff-right .line-no {
47+
table.diff .line-no:last-child {
4348
border-left: 1px solid #ddd;
4449
text-align: left;
4550
}
46-
.diff-left.diff-column {
51+
table.diff td:nth-child(2) {
4752
border-right: 1px solid #ddd;
4853
}
4954

50-
.diff-line-no, .diff-wrapper, .diff-column {
51-
display: inline-block;
52-
vertical-align: top;
53-
}
54-
55-
.diff-wrapper {
56-
overflow-x: auto;
57-
overflow-y: hidden; /* shouldn't happen, but we sometimes get a pixel. */
58-
}
59-
60-
.diff-content {
61-
display: table; /* "expand to fit" */
62-
min-width: 100%;
63-
}
64-
6555
.line-no, .code {
6656
padding: 2px;
6757
height: 1.11em;
68-
white-space: pre;
6958
font-family: monospace;
7059
}
71-
72-
.diff {
73-
white-space: nowrap;
74-
}
75-
76-
.diff-wrapper, .diff-wrapper > div {
77-
display: inline-block;
78-
vertical-align: top;
60+
.diff .skip {
61+
text-align: center;
62+
background: #f7f7f7;
7963
}
8064

8165
.diff .delete {
@@ -85,17 +69,63 @@
8569
background-color: #efe;
8670
}
8771

88-
.diff-left-content .replace {
72+
.before.replace {
8973
background-color: #fee;
9074
}
91-
.diff-right-content .replace {
75+
.after.replace {
9276
background-color: #efe;
9377
}
9478

95-
.diff-left-content .char-replace, .diff-left-content .char-delete {
79+
.before .char-replace, .before .char-delete {
9680
background-color: #fcc;
9781
}
9882

99-
.diff-right-content .char-replace, .diff-right-content .char-insert {
83+
.after .char-replace, .after .char-insert {
10084
background-color: #cfc;
10185
}
86+
87+
/* Single column selection */
88+
.selecting-left td,
89+
.selecting-left td *,
90+
.selecting-right td,
91+
.selecting-right td *
92+
{
93+
-moz-user-select: none;
94+
-webkit-user-select: none;
95+
-ms-user-select: none;
96+
user-select: none;
97+
}
98+
99+
.selecting-left td.line-no::selection,
100+
.selecting-left td.line-no *::selection,
101+
.selecting-right td.line-no::selection,
102+
.selecting-right td.line-no *::selection,
103+
.selecting-left td.after::selection,
104+
.selecting-left td.after *::selection,
105+
.selecting-right td.before::selection,
106+
.selecting-right td.before *::selection
107+
{
108+
background: transparent;
109+
}
110+
111+
.selecting-left td.line-no::-moz-selection,
112+
.selecting-left td.line-no *::-moz-selection,
113+
.selecting-right td.line-no::-moz-selection,
114+
.selecting-right td.line-no *::-moz-selection,
115+
.selecting-left td.after::-moz-selection,
116+
.selecting-left td.after *::-moz-selection,
117+
.selecting-right td.before::-moz-selection,
118+
.selecting-right td.before *::-moz-selection
119+
{
120+
background: transparent;
121+
}
122+
123+
.selecting-left td.before,
124+
.selecting-left td.before *,
125+
.selecting-right td.after,
126+
.selecting-right td.after * {
127+
-moz-user-select: text;
128+
-webkit-user-select: text;
129+
-ms-user-select: text;
130+
user-select: text;
131+
}

0 commit comments

Comments
 (0)