mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 14:04:45 -04:00
Improves text preview. A little bit slower, but with line-wrap.
This commit is contained in:
parent
e6e5f3309b
commit
74b0ec827b
5 changed files with 89 additions and 349 deletions
|
@ -151,6 +151,21 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
|||
|
||||
if (sh) {
|
||||
sh.highlight({}, $nText[0]);
|
||||
|
||||
var $text = $('#pv-txt-text'),
|
||||
$lineNos = $text.find('td.gutter .line').addClass('cntlinenr'),
|
||||
$codeLines = $text.find('td.code .line').addClass('cntline'),
|
||||
$table = $('<table/>'),
|
||||
i, $tr;
|
||||
|
||||
for (i = 0; i < $lineNos.length; i += 1) {
|
||||
$tr = $('<tr/>');
|
||||
$('<td/>').addClass('nr').append($lineNos.eq(i)).appendTo($tr);
|
||||
$('<td/>').addClass('line').append($codeLines.eq(i)).appendTo($tr);
|
||||
$table.append($tr);
|
||||
}
|
||||
|
||||
$text.find('table').replaceWith($table);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue