mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2024-05-17 21:16:38 +02:00
Add Markdown Support to File Previewer
Sorry if this code is a bit buggy (especially the underline patch 😳)
Also this is pretty much pointless so I won't feel insulted if it isn't accepted. I'm just trying to share what I personally need just in case someone else might need it.
This commit is contained in:
parent
c1718ff4c5
commit
b2f561b851
|
@ -2041,7 +2041,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
|
|||
<td><?php echo fm_enc($owner['name'] . ':' . $group['name']) ?></td>
|
||||
<?php endif; ?>
|
||||
<td class="inline-actions">
|
||||
<a title="<?php echo lng('Preview') ?>" href="<?php echo $filelink.'&quickView=1'; ?>" data-toggle="lightbox" data-gallery="tiny-gallery" data-title="<?php echo fm_convert_win(fm_enc($f)) ?>" data-max-width="100%" data-width="100%"><i class="fa fa-eye"></i></a>
|
||||
<a title="<?php echo lng('Preview') ?>" href="<?php echo $filelink.'&quickView=1'; ?>" data-toggle="lightbox" data-ext="<?php echo pathinfo($f, PATHINFO_EXTENSION) ?>" data-gallery="tiny-gallery" data-title="<?php echo fm_convert_win(fm_enc($f)) ?>" data-max-width="100%" data-width="100%"><i class="fa fa-eye"></i></a>
|
||||
<?php if (!FM_READONLY): ?>
|
||||
<a title="<?php echo lng('Delete') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo lng('Delete').' '.lng('File').'?'; ?>\n \n ( <?php echo urlencode($f) ?> )');"> <i class="fa fa-trash-o"></i></a>
|
||||
<a title="<?php echo lng('Rename') ?>" href="#" onclick="rename('<?php echo fm_enc(addslashes(FM_PATH)) ?>', '<?php echo fm_enc(addslashes($f)) ?>');return false;"><i class="fa fa-pencil-square-o"></i></a>
|
||||
|
@ -3763,12 +3763,17 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.min.js"></script>
|
||||
<?php if (FM_USE_HIGHLIGHTJS): ?>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/highlight.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>hljs.highlightAll(); var isHighlightingEnabled = true;</script>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
|
||||
event.preventDefault();
|
||||
var reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { $('.ekko-lightbox-container pre code').each(function (i, e) { hljs.highlightBlock(e) }); }, 555); } };
|
||||
var reInitHighlight;
|
||||
if ($(this)[0].dataset.ext == 'md' || $(this)[0].dataset.ext == 'markdown') {
|
||||
reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { var md; $('.ekko-lightbox-container pre code').each(function (i, e) { md = e.innerHTML; $(e).parent().replaceWith(document.createElement("md")) }); $('.ekko-lightbox-container md').each(function (i, e) { $(e).html(marked.parse(md).replace(/<u>(.*)<\/u>/gim, '<u>$1</u>')) }); }, 555); } };
|
||||
} else {
|
||||
reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { $('.ekko-lightbox-container pre code').each(function (i, e) { hljs.highlightBlock(e) }); }, 555); } };
|
||||
}
|
||||
$(this).ekkoLightbox({
|
||||
alwaysShowClose: true, showArrows: true, onShown: function() { reInitHighlight(); }, onNavigate: function(direction, itemIndex) { reInitHighlight(); }
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue