diff --git a/api/link.js b/api/link.js index 4e411ec19f..b78770a7c6 100644 --- a/api/link.js +++ b/api/link.js @@ -98,62 +98,82 @@ const html = ` - + + + + + + + +if (link && notLiveView) { - + link += '?live=false'; + +} + +if (link) { + + const resp = decodeLink(link); + + // redirect to decoded URL + window.location.replace(resp); + +} else { + + window.location.replace(window.location.origin); + +} + + + + `; diff --git a/filebrowser.js b/filebrowser.js index d9b466b61d..391e1c2f5b 100644 --- a/filebrowser.js +++ b/filebrowser.js @@ -509,7 +509,8 @@ async function renderSidebarHTML(pageNum = 1) { // if item is a file if (item.type == 'file') { - + + // get the file's latest version let file = getLatestVersion(item); // search for matching eclipsed files @@ -3327,8 +3328,16 @@ function setupEditor() { // show file content in codeit try { - - cd.textContent = decodeUnicode(selectedFile.content); + + const fileContent = decodeUnicode(selectedFile.content); + + // compare current code with new code + if (hashCode(cd.textContent) !== hashCode(fileContent)) { + + // if the code is different, swap it + cd.textContent = fileContent; + + } // change codeit lang cd.lang = selectedFile.lang; diff --git a/full.css b/full.css index b6a83b2785..2346acfd34 100644 --- a/full.css +++ b/full.css @@ -705,7 +705,7 @@ body.expanded .sidebar-toggle svg .left { overflow-y: overlay; overscroll-behavior-y: contain; pointer-events: none; - padding-left: env(safe-area-inset-left); + padding-left: env(safe-area-inset-left, 0px); box-sizing: border-box; z-index: 998; } @@ -1107,7 +1107,7 @@ body.mobile .sidebar .header .title .branch-icon.active { } .sidebar .header .search-screen .search-input { - width: calc(var(--sidebar-width) - 102px + 38px); + width: calc(var(--sidebar-width) - 102px + 38px - env(safe-area-inset-left, 0px)); white-space: nowrap; line-height: 20px; color: #d4d5d7; @@ -1121,7 +1121,7 @@ body.mobile .sidebar .header .title .branch-icon.active { } .sidebar .header .search-screen:has(> .clear.visible) .search-input { - width: calc(var(--sidebar-width) - 102px); + width: calc(var(--sidebar-width) - 102px - env(safe-area-inset-left, 0px)); } .sidebar .header .search-screen .search-input:empty::before { @@ -1158,7 +1158,7 @@ body.mobile .sidebar .header .title .branch-icon.active { .sidebar .header.searching .logo { padding-left: 7px; - max-width: calc(var(--sidebar-width) - 140px - 16px - 7px - 7px - 7px); + max-width: calc(var(--sidebar-width) - 139px - 16px - 7px - 7px - 7px - env(safe-area-inset-left, 0px)); } .sidebar .header.searching .title .branch { @@ -2310,7 +2310,7 @@ body:not(.mobile) .dialog .button:not(:active):hover { align-items: center; justify-content: center; pointer-events: none; - z-index: 1002; + z-index: 1003; } .message { diff --git a/lib/codeit.js b/lib/codeit.js index f6d468cc03..71df0c3178 100644 --- a/lib/codeit.js +++ b/lib/codeit.js @@ -1,7 +1,7 @@ /* codeit.js - v3.1.3 + v3.1.4 MIT License https://codeit.codes @@ -456,24 +456,33 @@ class CodeitElement extends HTMLElement { cd.on('copy', (e) => { + e.preventDefault(); + const text = window.getSelection().toString(); + + if (text === '') return false; + + e.clipboardData.setData('text/plain', text); - e.preventDefault(); }); cd.on('paste', (e) => { + + e.preventDefault(); let paste = e.clipboardData.getData('text'); + if (paste === '') return false; + + const selection = window.getSelection(); if (!selection.rangeCount) return false; if (!selection.getRangeAt(0).collapsed && hashCode(paste) === hashCode(selection.toString())) { - selection.getRangeAt(0).collapse(); - e.preventDefault(); + selection.getRangeAt(0).collapse(); return false; } @@ -488,8 +497,6 @@ class CodeitElement extends HTMLElement { cd.insert(paste); recordHistory(); - - e.preventDefault(); }); @@ -566,7 +573,7 @@ class CodeitElement extends HTMLElement { function handleDelNewLine(event) { - if (event.key === 'Backspace' || event.key === 'Delete') { + if (event.key === 'Backspace') { const before = cd.beforeCursor(); @@ -824,7 +831,7 @@ class CodeitElement extends HTMLElement { function handleDelClosingCharacters(event) { - if (event.key === 'Backspace' || event.key === 'Delete') { + if (event.key === 'Backspace') { const open = cd.options.openBrackets.join('') + cd.options.quot.join(''); const close = cd.options.closeBrackets.join('') + cd.options.quot.join(''); @@ -1197,18 +1204,45 @@ class CodeitElement extends HTMLElement { } - function overrideDeleteText(event) { + function overrideDeleteText(e) { - if (event.key === 'Backspace' || event.key === 'Delete') { + // when deleting in large files, + // the browser reparses the element tree and slows down + // override with range.deleteContents() fixes the problem - event.preventDefault(); + if (e.key === 'Backspace') { - // when deleting in large files, - // the browser reparses the element tree and slows down - // override with range.deleteContents() fixes the problem + e.preventDefault(); + cd.deleteCurrentSelection(); } + + if (e.key === 'Delete') { + + e.preventDefault(); + + + // get current selection + const s = window.getSelection(); + let r0 = s.getRangeAt(0); + + // get selection in text content + let textSel = cd.getSelection(); + + // if selection is empty, select the char after + if (r0.collapsed) { + + textSel.end += 1; + + cd.setSelection(textSel.start, textSel.end); + + } + + + cd.deleteCurrentSelection(); + + } } @@ -1217,14 +1251,16 @@ class CodeitElement extends HTMLElement { // get current selection const s = window.getSelection(); let r0 = s.getRangeAt(0); - + // get selection in text content let textSel = cd.getSelection(); // if selection is empty, select the char before if (r0.collapsed) { - cd.setSelection(textSel.start-1, textSel.end); + textSel.start -= 1; + + cd.setSelection(textSel.start, textSel.end); // get current range r0 = s.getRangeAt(0); diff --git a/lib/plugins/codeit-autocomplete.js b/lib/plugins/codeit-autocomplete.js index 963fcc1623..4a10a27d7a 100644 --- a/lib/plugins/codeit-autocomplete.js +++ b/lib/plugins/codeit-autocomplete.js @@ -104,7 +104,7 @@ acp.autocomplete = async (lang) => { // render results in HTML - const resultsExist = acp.utils.resultsExist(results, query); + const resultsExist = (results.length !== 0); if (resultsExist) { @@ -682,29 +682,6 @@ acp.utils.sort = (matches) => { } -// check if results exist -acp.utils.resultsExist = (results, query) => { - - // if there's no results - if (results.length === 0) { - - return false; - - } - - // if query matches result - if (results.length === 1 && - results[0] === query) { - - return false; - - } - - return true; - -} - - // show autocomplete menu acp.utils.showAcpMenu = () => { diff --git a/live-view/live-view.js b/live-view/live-view.js index 7a81b5bb8b..c6667a972a 100644 --- a/live-view/live-view.js +++ b/live-view/live-view.js @@ -221,6 +221,14 @@ async function setupLiveView() { (file.dir == treeLoc.join() && file.name == fileName))[0]; + // if modified file exists + if (modFile) { + + // get the file's latest version + modFile = getLatestVersion(modFile); + + } + } @@ -557,6 +565,7 @@ if (isMobile) { }); + function shareLiveViewLink() { // share live view link @@ -573,9 +582,8 @@ if (isMobile) { }); } - + /* - liveMenuShare.addEventListener('click', shareLiveViewLink); liveMenuConsole.addEventListener('click', () => { @@ -612,7 +620,6 @@ if (isMobile) { liveButtonOptions.classList.remove('active'); }); - */ } else { @@ -972,6 +979,9 @@ async function handleLiveViewRequest(requestPath) { // if matching modified file exists if (modFile) { + // get the file's latest version + modFile = getLatestVersion(modFile); + // return modified file content respContent = modFile.content; diff --git a/worker/client-channel.js b/worker/client-channel.js index 0c3babda9c..67cc6b7a33 100644 --- a/worker/client-channel.js +++ b/worker/client-channel.js @@ -4,7 +4,7 @@ // update worker name when updating worker -const WORKER_NAME = 'codeit-worker-v649'; +const WORKER_NAME = 'codeit-worker-v657'; // internal paths