diff --git a/LICENSE b/LICENSE index 7e50451a0c..6a8515000a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,3 @@ -Codeit is licensed under the GNU-GPL v3 or any later version. +Codeit is licensed under the GNU-GPL v3. For more info, see: https://gnu.org/licenses/gpl-3.0 Copyright (C) 2022 Codeit contributors diff --git a/filebrowser.js b/filebrowser.js index fbdee570d3..437bbdfcf6 100644 --- a/filebrowser.js +++ b/filebrowser.js @@ -1422,6 +1422,8 @@ async function loadFileInHTML(fileEl, fileSha) { resp = { content: fileSizeText }; + cd.textContent = ''; + // if on mobile device if (isMobile) { @@ -1438,7 +1440,6 @@ async function loadFileInHTML(fileEl, fileSha) { } else { liveToggle.classList.add('file-open'); - updateScrollbarArrow(); onNextFrame(() => { liveView.classList.remove('notransition'); @@ -1583,7 +1584,6 @@ function loadBinaryFileHTML(file, toggled) { if (!isMobile) { liveToggle.classList.add('file-open'); - updateScrollbarArrow(); } @@ -1945,6 +1945,18 @@ sidebarTitle.addEventListener('click', (e) => { sidebar.classList.add('learn'); + + // if adding a repository + + const focusedRepo = fileWrapper.querySelector('.repo.focused'); + + if (focusedRepo) { + + // remove it + focusedRepo.remove(); + + } + /* // if there are no modified files // and no pending promises @@ -3010,6 +3022,7 @@ function onEditorScroll() { } + function updateScrollbarArrow() { // if codeit is horizontally scrollable @@ -3027,6 +3040,10 @@ function updateScrollbarArrow() { } +// when codeit resizes, update +new ResizeObserver(updateScrollbarArrow).observe(cd); + + // check for meta key (Ctrl/Command) function isKeyEventMeta(event) { return event.metaKey || event.ctrlKey; @@ -3217,8 +3234,6 @@ function setupEditor() { cd.on('scroll', onEditorScroll); cd.on('caretmove', saveSelectedFileCaretPos); - if (!isMobile) cd.on('type', updateScrollbarArrow); - // update on screen resize const landscape = window.matchMedia('(orientation: landscape)'); @@ -3372,7 +3387,7 @@ function setupEditor() { if (shownMessages.beautifySelect < 2) { // show beautify select message - showMessage('Try selecting some text.', 3500); + showMessage('Try selecting some text first.', 4100); // bump counter shownMessages.beautifySelect++; @@ -3440,7 +3455,6 @@ function updateLineNumbersHTML() { if (!isMobile) { - updateScrollbarArrow(); updateLiveViewArrow(); } diff --git a/full.css b/full.css index c077cf05fc..a3471d39d7 100644 --- a/full.css +++ b/full.css @@ -467,6 +467,7 @@ body.notransition .live-view.file-open { width: 100%; height: 100%; background: #fff; + border: 0; max-width: unset; } @@ -1791,7 +1792,8 @@ body:not(.mobile) .live-view-menu { align-items: center; justify-content: center; pointer-events: none; - transform: scale(0.94); + transform: scale(1.08); + transform: scale(1.075); transform-origin: center; transition: 0s .18s; } @@ -1809,14 +1811,14 @@ body.mobile .dialog-background { .dialog { background: var(--deep-midnight-blue); color: #dcddde; - box-shadow: 0 2px 10px 0 rgb(0 0 0 / 20%); - border: 1px solid rgb(32 34 37 / 60%); + box-shadow: 0 8px 16px rgb(0 0 0 / 24%); border-radius: 11.5px; line-height: 1.5; opacity: 0; - padding: 2px; + padding: 9px; transition: 0s .18s, .18s var(--bounce-function) opacity; min-width: 170px; + overflow: hidden; } .dialog-wrapper.visible .dialog { @@ -1832,23 +1834,71 @@ body.mobile .dialog-background { } .dialog .button-wrapper { + position: relative; display: flex; margin-top: 7px; } +body.mobile .dialog .button-wrapper { + margin: -7px; + margin-top: 8px; +} + +body.mobile .dialog .button-wrapper::before { + content: ''; + position: absolute; + top: -1px; + left: 0; + right: 0; + height: 1px; + background: rgb(32 34 37 / 60%); + transition: inherit; + pointer-events: none; +} + +body.mobile .dialog-wrapper:not(.visible) .button-wrapper::before { + left: -2px; + right: -2px; +} + .dialog .button { padding: 8px 14px; border-radius: 5.75px; display: flex; justify-content: center; + position: relative; flex: 1; } +body.mobile .dialog .button { + border-radius: 0; +} + .dialog .cancel { color: hsl(228deg 16% 37%); } -.dialog-wrapper.one-button .dialog .cancel { +.dialog-wrapper.one-button .button.cancel { + display: none; +} + +body.mobile .dialog .cancel::after { + content: ''; + position: absolute; + top: 0; + bottom: 0; + right: -0.5px; + width: 1px; + background: rgb(32 34 37 / 60%); + transition: inherit; + pointer-events: none; +} + +body.mobile .dialog-wrapper:not(.visible) .button.cancel::after { + bottom: -2px; +} + +body.mobile .dialog-wrapper.one-button .button.cancel::after { display: none; } @@ -1868,7 +1918,7 @@ body:not(.mobile) .dialog .button:not(:active):hover { .dialog-background { position: fixed; inset: 0; - background: rgba(0,0,0,0.85); + background: hsl(227deg 11% 16% / 40%); width: calc(var(--sidebar-width) - 1px); opacity: 0; transition: .18s var(--bounce-function); diff --git a/lib/plugins/codeit-autocomplete.js b/lib/plugins/codeit-autocomplete.js index 3a63208e95..ffc9c540b3 100644 --- a/lib/plugins/codeit-autocomplete.js +++ b/lib/plugins/codeit-autocomplete.js @@ -231,6 +231,8 @@ acp.lang.css.init = () => { CSSProps.push('overflow'); CSSProps.push('transition'); CSSProps.push('animation'); + CSSProps.push('inset'); + CSSProps.push('border-radius'); CSSProps.push('-webkit-user-select'); acp.lang.css.props = CSSProps; @@ -592,6 +594,10 @@ acp.utils.shouldAutocomplete = () => { if (input !== document.activeElement) return false; const cursor = input.dropper.cursor(); + + // if cursor dosen't exist, return + if (!cursor) return false; + const cursorCollapsed = cursor.collapsed; // if cursor not collapsed, return diff --git a/lib/plugins/codeit-autolinker.js b/lib/plugins/codeit-autolinker.js index 4dd7b88e2f..e81cc00096 100644 --- a/lib/plugins/codeit-autolinker.js +++ b/lib/plugins/codeit-autolinker.js @@ -70,13 +70,14 @@ var isMac = navigator.platform.indexOf('Mac') > -1; env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`',''); - env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }'; + + env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }'; env.attributes.title = isMac ? '⌘ + ⇧ + click to open link' : 'Ctrl + Shift + click to open link'; - // Silently catch any error thrown by decodeURIComponent (#1186) + // silently catch any error thrown by decodeURIComponent try { env.content = decodeURIComponent(env.content); - } catch (e) { /* noop */ } + } catch (e) {} } } }); diff --git a/live-view/live-view.js b/live-view/live-view.js index 9ffb3f16db..6b576d667a 100644 --- a/live-view/live-view.js +++ b/live-view/live-view.js @@ -355,14 +355,6 @@ async function setupLiveView() { // update line numbers updateLineNumbersHTML(); - // if on desktop - if (!isMobile) { - - // update scrollbar arrow - updateScrollbarArrow(); - - } - } } @@ -1014,11 +1006,8 @@ async function handleLiveViewRequest(requestPath) { async function renderLiveViewHTML(file) { // if iOS version is lower than minimum - - const isSafariWithMac = (navigator.userAgent.toLowerCase().includes('safari') - && !navigator.userAgent.toLowerCase().includes('chrome')); - - if (isSafariWithMac) { + + if (isSafari) { const safariVersion = Number(navigator.userAgent.split('Version/')[1].split(' Safari')[0]); @@ -1028,9 +1017,8 @@ async function renderLiveViewHTML(file) { liveView.innerHTML = `
-
Upgrade iOS to run this file
- Here's how + Here's how
`; @@ -1055,7 +1043,7 @@ async function renderLiveViewHTML(file) { if (!workerClientId) await workerInstallPromise; - liveView.innerHTML = ''; + liveView.innerHTML = ``; liveFile = file; @@ -1063,12 +1051,6 @@ async function renderLiveViewHTML(file) { const liveFrame = liveView.querySelector('.live-frame'); - liveFrame.contentWindow.addEventListener('DOMContentLoaded', () => { - - liveFrame.contentWindow.history.replaceState({}, 'Live view', livePath); - - }); - liveFrame.contentWindow.addEventListener('load', () => { liveView.classList.add('loaded'); diff --git a/utils.js b/utils.js index be73e41d7a..e11fd10118 100644 --- a/utils.js +++ b/utils.js @@ -109,7 +109,7 @@ function stopLoading() { let messageTimeout; -function showMessage(message, duration) { +let showMessage = (message, duration) => { // if message includes an icon if (message.icon) { @@ -158,7 +158,7 @@ function showMessage(message, duration) { } -function hideMessage() { +let hideMessage = () => { messageEl.classList.remove('visible'); } @@ -166,7 +166,7 @@ function hideMessage() { // show dialog -function showDialog(confirmHandler, titleText, confirmText, showOneButton = false) { +let showDialog = (confirmHandler, titleText, confirmText, showOneButton = false) => { return new Promise(resolve => { @@ -227,7 +227,7 @@ function showDialog(confirmHandler, titleText, confirmText, showOneButton = fals } -function hideDialog() { +let hideDialog = () => { // hide dialog dialogWrapper.classList.remove('visible'); @@ -325,7 +325,7 @@ window.addEventListener('offline', () => { isOffline = true }); let isPersistStorage = false; -async function checkPersistStorage() { +let checkPersistStorage = async () => { if (navigator.storage && navigator.storage.persist) { @@ -345,6 +345,20 @@ async function checkPersistStorage() { checkPersistStorage(); +// escape HTML +let escapeHTML = (str) => { + + const p = document.createElement('p'); + p.appendChild(document.createTextNode(str)); + + let resp = p.innerHTML; + resp = resp.replaceAll(/"/g, """).replaceAll(/'/g, "'"); + + return resp; + +} + + // base64 encode/decode let encodeUnicode = (str) => { diff --git a/worker/client-channel.js b/worker/client-channel.js index 08be03c326..62dac5de74 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-v615'; +const WORKER_NAME = 'codeit-worker-v616'; // internal paths