Skip to content

Commit

Permalink
improve editor scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills committed Jul 11, 2024
1 parent bbaa717 commit 4a85993
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 73 deletions.
120 changes: 60 additions & 60 deletions public/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/sw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const cacheName = "luizbills.litecanvas-editor-v1";
const version = "1.62.1";
const version = "1.62.2";

const precacheResources = [
"/",
Expand All @@ -21,7 +21,7 @@ const precacheResources = [

self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(cacheName).then((cache) => cache.addAll(precacheResources))
caches.open(cacheName).then((cache) => cache.addAll(precacheResources)),
);
});

Expand All @@ -34,7 +34,7 @@ self.addEventListener("fetch", (event) => {
return cachedResponse;
}
return fetch(event.request);
})
}),
);
});

Expand Down
21 changes: 11 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pako from "pako";
import { EditorView } from "codemirror";
import { EditorState } from "@codemirror/state";
import { keymap } from "@codemirror/view";
import { keymap, scrollPastEnd } from "@codemirror/view";
import {
javascript,
javascriptLanguage,
Expand Down Expand Up @@ -113,7 +113,7 @@ function stopGame(evt) {
shareButton.addEventListener("click", (evt) => {
if (!navigator.clipboard) {
return alert(
"Your browser not support this feature. Consider installing Firefox or Chrome."
"Your browser not support this feature. Consider installing Firefox or Chrome.",
);
}
const code = codeEditor.state.doc.toString();
Expand All @@ -131,14 +131,14 @@ shareButton.addEventListener("click", (evt) => {
(err) => {
alert("Error: Unable to generate your shareable url!");
console.error("Error on copying text to clipboard:", err);
}
},
);
});

copyButton.addEventListener("click", (evt) => {
if (!navigator.clipboard) {
return alert(
"Your browser not support this feature. Consider installing Firefox or Chrome."
"Your browser not support this feature. Consider installing Firefox or Chrome.",
);
}
const code = codeEditor.state.doc.toString();
Expand All @@ -148,14 +148,14 @@ copyButton.addEventListener("click", (evt) => {
(err) => {
alert("Error: Unable to generate your shareable url!");
console.error("Error on copying text to clipboard:", err);
}
},
);
});

function runCode() {
if (!litecanvasSourceCode) {
return alert(
"The litecanvas source code was not loaded. Try reloading this page."
"The litecanvas source code was not loaded. Try reloading this page.",
);
}
const game = codeEditor.state.doc.toString();
Expand Down Expand Up @@ -203,7 +203,7 @@ const state = EditorState.create({
sourceType: "script",
},
rules: {},
})
}),
),
javascriptLanguage.data.of({
autocomplete: customCompletions,
Expand All @@ -216,6 +216,7 @@ const state = EditorState.create({
EditorView.updateListener.of((update) => {
if (update.docChanged) config.codeChanged = true;
}),
scrollPastEnd(),
...desktopExtensions,
],
});
Expand Down Expand Up @@ -272,16 +273,16 @@ function decompressString(str) {
new Uint8Array(
atob(str)
.split("")
.map((c) => c.charCodeAt(0))
.map((c) => c.charCodeAt(0)),
),
{ to: "string" }
{ to: "string" },
);
console.log("Playground url decoded successfully!");
break;
} catch (e) {
console.error(
`Failed decode the playground url (${attempts + 1}/2). Error:`,
e
e,
);
console.log("Trying to decode again (fixing some characters)...");
code = null;
Expand Down

0 comments on commit 4a85993

Please sign in to comment.