Skip to content

Commit bf3d01c

Browse files
committed
close #1
1 parent 9397f66 commit bf3d01c

File tree

7 files changed

+111
-38
lines changed

7 files changed

+111
-38
lines changed

assets/css/main.scss

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -278,57 +278,97 @@ nav.navbar {
278278
Table
279279
\* ----------------------------------------------------------------------------------------------------------------- */
280280
table {
281-
.main-row-action {
282-
cursor: pointer;
283-
}
284-
285-
th.row-action {
286-
width: 16px;
287-
}
281+
tbody {
282+
.main-row-action {
283+
cursor: pointer;
284+
}
288285

289-
td.row-action a {
290-
color: $body-color;
291-
}
286+
th.row-action {
287+
width: 16px;
288+
}
292289

293-
pre {
294-
white-space: pre-wrap;
295-
overflow-wrap: break-word;
296-
overflow: auto;
297-
max-height: 150px;
290+
td.row-action a {
291+
color: $body-color;
292+
}
298293

299-
code {
294+
pre {
300295
white-space: pre-wrap;
301296
overflow-wrap: break-word;
302-
word-break: break-all;
303-
}
304-
}
297+
overflow: auto;
298+
max-height: 100px;
299+
cursor: pointer;
300+
position: relative;
305301

306-
tr.deleted {
307-
opacity: 0.5;
308-
}
302+
code {
303+
white-space: pre-wrap;
304+
overflow-wrap: break-word;
305+
word-break: break-all;
306+
307+
&:after {
308+
content:'';
309+
width:100%;
310+
height:35px;
311+
position:absolute;
312+
left:0;
313+
bottom:0;
314+
background: linear-gradient(transparent, $gray-900);
315+
}
316+
}
317+
}
309318

310-
.table.table-sm {
311-
margin-top: calc(-#{$table-cell-padding});
312-
width: calc(100% + (#{$table-cell-padding } * 2));
313-
margin-left: -$table-cell-padding;
314-
position: relative;
315-
border-bottom: $table-border-width dashed $table-border-color;
316-
font-size: $font-size-sm;
319+
tr:hover {
320+
pre code:after {
321+
background: linear-gradient(transparent, $indigo);
322+
}
323+
}
317324

318-
td, th {
319-
border: 0;
325+
.hljs {
326+
background: none;
320327
}
321328

322-
th {
323-
border-right: $table-border-width dashed $table-border-color;
329+
tr.hightlight {
330+
&:hover {
331+
background: none;
332+
}
333+
334+
pre {
335+
overflow: hidden;
336+
max-height: none;
337+
cursor: default;
338+
339+
code:after {
340+
display: none;
341+
}
342+
}
324343
}
325344

326-
tbody tr:nth-of-type(even) {
327-
background-color: lighten($table-accent-bg, 0.1);
345+
tr.deleted {
346+
opacity: 0.5;
328347
}
329348

330-
tbody tr:nth-of-type(odd) {
331-
background-color: lighten($table-bg, 0.1);
349+
.table.table-sm {
350+
margin-top: calc(-#{$table-cell-padding});
351+
width: calc(100% + (#{$table-cell-padding } * 2));
352+
margin-left: -$table-cell-padding;
353+
position: relative;
354+
border-bottom: $table-border-width dashed $table-border-color;
355+
font-size: $font-size-sm;
356+
357+
td, th {
358+
border: 0;
359+
}
360+
361+
th {
362+
border-right: $table-border-width dashed $table-border-color;
363+
}
364+
365+
tbody tr:nth-of-type(even) {
366+
background-color: lighten($table-accent-bg, 0.1);
367+
}
368+
369+
tbody tr:nth-of-type(odd) {
370+
background-color: lighten($table-bg, 0.1);
371+
}
332372
}
333373
}
334374
}

assets/css/vendor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
@import "../../node_modules/sweetalert2/src/sweetalert2";
66
$bs-datetimepicker-btn-hover-bg: $gray-800;
77
@import "../../node_modules/tempusdominus-bootstrap-4/src/sass/tempusdominus-bootstrap-4";
8+
@import "../../node_modules/highlight.js/styles/darkula.css";
89

assets/js/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import swal from 'sweetalert2';
55
import 'moment';
66
import 'tempusdominus-bootstrap-4';
77
import urijs from 'urijs';
8+
import hljs from 'highlight.js';
89

910
turbolinks.start();
1011
turbolinks.setProgressBarDelay(0);
@@ -142,4 +143,28 @@ $(document).on('ready turbolinks:load', function () {
142143
dateTimeSubmit($(this))
143144
}
144145
});
146+
147+
// Highlight
148+
$('pre.highlight code').on('dblclick', function() {
149+
let code = $(this);
150+
151+
if (code.closest('tr').hasClass("hightlight")) {
152+
code.
153+
removeClass()
154+
.html(code.data('raw'))
155+
.closest('tr')
156+
.removeClass("hightlight")
157+
} else {
158+
code.data('raw', code.html());
159+
160+
try {
161+
let json = JSON.parse(code.html());
162+
code.html(JSON.stringify(json, null, 2));
163+
} catch (e) {}
164+
165+
hljs.highlightBlock(code[0]);
166+
167+
code.closest('tr').addClass("hightlight");
168+
}
169+
});
145170
});

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dependencies": {
77
"bootstrap": "^4.1.3",
88
"font-awesome": "^4.7.0",
9+
"highlight.js": "^9.13.1",
910
"jquery": "^3.3.1",
1011
"moment": "^2.22.2",
1112
"popper.js": "^1.14.4",

public/blocks/topic/data.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
</#list>
145145
</table>
146146
</#if>
147-
<pre class="mb-0"><code>${data.getValue()!"null"}</code></pre>
147+
<pre class="mb-0 highlight"><code>${data.getValue()!"null"}</code></pre>
148148
</td>
149149
</tr>
150150
</#list>

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = (env, argv) => {
2626
'moment',
2727
'imports-loader?jQuery=>jQuery!tempusdominus-bootstrap-4',
2828
'urijs',
29+
'highlight.js',
2930
path.join(srcDirectory, 'css/vendor.scss')
3031
],
3132
main: [

0 commit comments

Comments
 (0)