Skip to content

Commit eb60395

Browse files
committed
Update filebrowser.js
1 parent 4d5d2c2 commit eb60395

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

filebrowser.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,33 @@ function createNewFileInHTML() {
24312431
// change selected file
24322432
changeSelectedFile(treeLoc.join(), tempSHA, fileName, encodeUnicode('\r\n'), getFileLang(fileName),
24332433
[0, 0], [0, 0], true);
2434-
2434+
2435+
// close file view if open
2436+
if (liveView.classList.contains('file-open')) {
2437+
2438+
liveView.classList.add('notransition');
2439+
liveView.classList.remove('file-open');
2440+
2441+
onNextFrame(() => {
2442+
2443+
liveView.classList.remove('notransition');
2444+
2445+
});
2446+
2447+
// if on mobile device
2448+
if (isMobile) {
2449+
2450+
// update bottom float
2451+
bottomFloat.classList.remove('file-open');
2452+
2453+
} else {
2454+
2455+
liveToggle.classList.remove('file-open');
2456+
2457+
}
2458+
2459+
}
2460+
24352461
// if on mobile device
24362462
if (isMobile) {
24372463

@@ -2797,17 +2823,26 @@ function toggleSidebar(open) {
27972823
}
27982824

27992825

2800-
function deleteModFileInHTML(fileEl) {
2826+
async function deleteModFileInHTML(fileEl) {
28012827

28022828
const fileSha = getAttr(fileEl, 'sha');
28032829

28042830
deleteModFile(fileSha);
28052831

2832+
28062833
fileEl.classList.remove('modified');
28072834

28082835
if (fileEl.classList.contains('selected')) {
28092836

2810-
loadFileInHTML(fileEl, fileSha);
2837+
const scrollPos = selectedFile.scrollPos;
2838+
2839+
await loadFileInHTML(fileEl, fileSha);
2840+
2841+
// prevent bottom float disappearing on mobile
2842+
if (isMobile) lastScrollTop = scrollPos[1];
2843+
2844+
// scroll to pos in code
2845+
cd.scrollTo(scrollPos[0], scrollPos[1]);
28112846

28122847
}
28132848

@@ -3155,6 +3190,7 @@ function setupEditor() {
31553190
// get selection language
31563191
let selLang = Prism.util.getLanguage(cursorEl);
31573192
if (selLang == 'javascript') selLang = 'js';
3193+
if (selLang == 'json') selLang = 'js';
31583194
if (selLang == 'markup') selLang = 'html';
31593195

31603196
// find syntax for language

0 commit comments

Comments
 (0)