Skip to content

Commit 995329d

Browse files
authored
Merge pull request #261 from codeitcodes/mobile-console
Patch 3
2 parents 1533429 + ca9e704 commit 995329d

File tree

5 files changed

+87
-77
lines changed

5 files changed

+87
-77
lines changed

full.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ body.mobile .sidebar .header .title .branch-icon.active {
13391339

13401340
@keyframes lock-click {
13411341
50% {
1342-
transform: scaleX(-1) translateY(0.5px);
1342+
transform: scaleX(-1) translateY(0.35px);
13431343
}
13441344
}
13451345

full.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@
4444

4545
<link rel="preconnect" href="https://codeit.codes">
4646
<link rel="preconnect" href="https://api.github.com" crossorigin>
47+
48+
<link rel="preload" href="/fonts/Inter/Inter-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
49+
<link rel="preload" href="/fonts/Inter/Inter-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
50+
<link rel="preload" href="/fonts/Inter/Inter-Medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
51+
<link rel="preload" href="/fonts/Inter/Inter-SemiBold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
52+
<link rel="preload" href="/fonts/Inter/Inter-SemiBoldItalic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
53+
<link rel="preload" href="/fonts/Inter/Inter-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
54+
55+
<link rel="preload" href="/fonts/Mono-Sans/MonoSans-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
56+
<link rel="preload" href="/fonts/Mono-Sans/MonoSans-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
57+
<link rel="preload" href="/fonts/Mono-Sans/MonoSans-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
58+
<link rel="preload" href="/fonts/Mono-Sans/MonoSans-BoldItalic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
59+
60+
<link rel="preload" href="/fonts/Roboto-Mono/RobotoMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
61+
<link rel="preload" href="/fonts/Roboto-Mono/RobotoMono-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
62+
<link rel="preload" href="/fonts/Roboto-Mono/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
63+
<link rel="preload" href="/fonts/Roboto-Mono/RobotoMono-BoldItalic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
4764

4865
<link rel="stylesheet" href="/fonts/fonts.css">
4966

@@ -422,7 +439,7 @@
422439

423440
<div class="splash-wrapper">
424441
<div class="cube-loader"></div>
425-
<div class="loading-subtitle">Connection problems? <a href="https://twitter.com/codeitcodes" target="_blank" class="link">Let us know!</a></div>
442+
<div class="loading-subtitle">Connection problems? <a href="https://github.com/codeitcodes/codeit/issues/new?template=bug_report.md&title=Connection%20problems" target="_blank" class="link">Let us know!</a></div>
426443
</div>
427444

428445

lib/codeit.js

Lines changed: 62 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*
22
33
codeit.js
4-
v3.1.4
5-
MIT License
6-
4+
3.1.5
5+
76
https://codeit.codes
87
98
*/
@@ -733,97 +732,91 @@ class CodeitElement extends HTMLElement {
733732
function handleSelfClosingCharacters(event) {
734733

735734
const cursor = cd.dropper.cursor();
736-
const inStringOrComment = (cursor.in('string') || cursor.in('comment'));
737735

738-
// if cursor is not in string or comment
739-
if (!inStringOrComment) {
736+
// join brackets and quotation marks
737+
// to get chars to autocomplete
738+
const open = cd.options.openBrackets.join('') + cd.options.quot.join('');
739+
const close = cd.options.closeBrackets.join('') + cd.options.quot.join('');
740740

741-
// join brackets and quotation marks
742-
// to get chars to autocomplete
743-
const open = cd.options.openBrackets.join('') + cd.options.quot.join('');
744-
const close = cd.options.closeBrackets.join('') + cd.options.quot.join('');
741+
// get code before and after cursor
742+
const codeAfter = cd.afterCursor();
743+
const codeBefore = cd.beforeCursor();
745744

746-
// get code before and after cursor
747-
const codeAfter = cd.afterCursor();
748-
const codeBefore = cd.beforeCursor();
745+
const charBefore = codeBefore.slice(-1);
746+
const charAfter = codeAfter.charAt(0);
749747

750-
const charBefore = codeBefore.slice(-1);
751-
const charAfter = codeAfter.charAt(0);
748+
// check if typed an opening or closing char
749+
const typedOpeningChar = open.includes(event.key);
750+
const typedClosingChar = close.includes(event.key);
752751

753-
// check if typed an opening or closing char
754-
const typedOpeningChar = open.includes(event.key);
755-
const typedClosingChar = close.includes(event.key);
752+
// closing char is next to cursor if
753+
// the chars before and after the cursor are
754+
// matching opening and closing chars
755+
const closingCharNextToCursor = (charBefore === open[close.indexOf(event.key)]
756+
&& charAfter === event.key);
756757

757-
// closing char is next to cursor if
758-
// the chars before and after the cursor are
759-
// matching opening and closing chars
760-
const closingCharNextToCursor = (charBefore === open[close.indexOf(event.key)]
761-
&& charAfter === event.key);
758+
// if typed opening char
759+
if (typedOpeningChar) {
762760

763-
// if typed opening char
764-
if (typedOpeningChar) {
761+
// if selection exists
762+
if (!cursor.collapsed) {
765763

766-
// if selection exists
767-
if (!cursor.collapsed) {
764+
// prevent default behavior
765+
event.preventDefault();
766+
767+
// get the text to wrap
768+
const textToWrap = window.getSelection().toString();
768769

769-
// prevent default behavior
770-
event.preventDefault();
770+
// wrap the text with matching opening and closing chars
771+
const wrappedText = event.key + textToWrap + close[open.indexOf(event.key)];
771772

772-
// get the text to wrap
773-
const textToWrap = window.getSelection().toString();
773+
// delete current selection
774+
cd.deleteCurrentSelection();
774775

775-
// wrap the text with matching opening and closing chars
776-
const wrappedText = event.key + textToWrap + close[open.indexOf(event.key)];
776+
// insert wrapped text
777+
cd.insert(wrappedText, { moveToEnd: false });
778+
779+
// get caret pos in text
780+
const pos = cd.getSelection();
781+
782+
// restore pos in text
783+
cd.setSelection(pos.start, (pos.start + wrappedText.length));
777784

778-
// delete current selection
779-
cd.deleteCurrentSelection();
785+
} else {
786+
787+
// get caret pos in text
788+
const pos = cd.getSelection();
780789

781-
// insert wrapped text
782-
cd.insert(wrappedText, { moveToEnd: false });
790+
// if cursor is on last line
791+
if (pos.start === cd.textContent.length) {
783792

784-
// get caret pos in text
785-
const pos = cd.getSelection();
793+
// insert newline
794+
cd.insert((close[open.indexOf(event.key)] + '\n'), { moveToEnd: false });
786795

787-
// restore pos in text
788-
cd.setSelection(pos.start, (pos.start + wrappedText.length));
789-
790796
} else {
791-
792-
// get caret pos in text
793-
const pos = cd.getSelection();
794-
795-
// if cursor is on last line
796-
if (pos.start === cd.textContent.length) {
797-
798-
// insert newline
799-
cd.insert((close[open.indexOf(event.key)] + '\n'), { moveToEnd: false });
800-
801-
} else {
802-
803-
// insert matching closing char
804-
cd.insert(close[open.indexOf(event.key)], { moveToEnd: false });
805-
806-
}
807797

798+
// insert matching closing char
799+
cd.insert(close[open.indexOf(event.key)], { moveToEnd: false });
800+
808801
}
809802

810803
}
811804

812-
// if typed closing char but closing char
813-
// is already next to cursor
814-
if (typedClosingChar && closingCharNextToCursor) {
805+
}
815806

816-
// prevent default behavior
817-
event.preventDefault();
807+
// if typed closing char but closing char
808+
// is already next to cursor
809+
if (typedClosingChar && closingCharNextToCursor) {
818810

819-
// get caret pos in text
820-
const pos = cd.getSelection();
811+
// prevent default behavior
812+
event.preventDefault();
821813

822-
// move caret one char right
823-
pos.start++;
824-
cd.setSelection(pos.start);
814+
// get caret pos in text
815+
const pos = cd.getSelection();
825816

826-
}
817+
// move caret one char right
818+
pos.start++;
819+
cd.setSelection(pos.start);
827820

828821
}
829822

lib/plugins/codeit-autolinker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858

5959
Prism.hooks.add('wrap', function (env) {
6060

61+
// disabled for markdown because regex dosen't cover all edge cases
6162
if (env.language === 'markdown') return;
6263

63-
if (env.language === 'markdown' &&
64+
/*
65+
if (env.language === 'markdown' &&
6466
env.type === 'url-reference') {
6567
6668
let matches = env.content.match(url);
@@ -74,6 +76,7 @@
7476
}
7577
7678
}
79+
*/
7780

7881
if (/-link$/.test(env.type)) {
7982
env.tag = 'a';
@@ -95,11 +98,8 @@
9598
env.attributes.onclick = onClickEvent;
9699
env.attributes.title = linkTitle;
97100

98-
// silently catch any error thrown by decodeURIComponent
99-
try {
100-
env.content = decodeURIComponent(env.content);
101-
} catch (e) {}
102101
}
102+
103103
});
104104

105105
}());

worker/client-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
// update worker name when updating worker
7-
const WORKER_NAME = 'codeit-worker-v657';
7+
const WORKER_NAME = 'codeit-worker-v658';
88

99

1010
// internal paths

0 commit comments

Comments
 (0)