Skip to content

Commit 93ec331

Browse files
committed
update editor
1 parent 7e3f682 commit 93ec331

File tree

4 files changed

+81
-79
lines changed

4 files changed

+81
-79
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/app.js

Lines changed: 59 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const cacheName = "luizbills.litecanvas-editor-v1";
2-
const version = "2.42.1";
2+
const version = "2.43.0";
33

44
const precacheResources = [
55
"/",

src/index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if (url.searchParams.get("reset") !== null) {
3131
}
3232

3333
const autoplay = !["0", "false"].includes(url.searchParams.get("autoplay"));
34+
let blank = url.searchParams.get("blank") != null;
3435

3536
let codeFromURL = url.searchParams.get("c");
3637
if (codeFromURL !== null) {
@@ -40,6 +41,7 @@ if (codeFromURL !== null) {
4041
if (codeFromURL) {
4142
config.autosave = false;
4243
$("#changing-shared-code").style.display = "";
44+
blank = false;
4345
}
4446
}
4547

@@ -96,7 +98,7 @@ function stopGame(evt) {
9698
shareButton.addEventListener("click", (evt) => {
9799
if (!navigator.clipboard) {
98100
return alert(
99-
"Your browser not support this feature. Consider installing Firefox or Chrome."
101+
"Your browser not support this feature. Consider installing Firefox or Chrome.",
100102
);
101103
}
102104
const code = window.codeEditor.state.doc.toString();
@@ -115,14 +117,14 @@ shareButton.addEventListener("click", (evt) => {
115117
(err) => {
116118
alert("Error: Unable to generate your shareable url!");
117119
console.error("Error on copying text to clipboard:", err);
118-
}
120+
},
119121
);
120122
});
121123

122124
copyButton.addEventListener("click", (evt) => {
123125
if (!navigator.clipboard) {
124126
return alert(
125-
"Your browser not support this feature. Consider installing Firefox or Chrome."
127+
"Your browser not support this feature. Consider installing Firefox or Chrome.",
126128
);
127129
}
128130
const code = window.codeEditor.state.doc.toString();
@@ -132,7 +134,7 @@ copyButton.addEventListener("click", (evt) => {
132134
(err) => {
133135
alert("Error: Unable to generate your shareable url!");
134136
console.error("Error on copying text to clipboard:", err);
135-
}
137+
},
136138
);
137139
});
138140

@@ -172,7 +174,7 @@ if (!smallScreen) {
172174
}
173175

174176
const state = EditorState.create({
175-
doc: codeFromURL || loadFromStorage() || demo(),
177+
doc: codeFromURL || (blank ? "" : loadFromStorage() || demo()),
176178
extensions: [
177179
editorSetup(),
178180
// Ctrl+S to run the code
@@ -197,7 +199,7 @@ const state = EditorState.create({
197199
sourceType: "script",
198200
},
199201
rules: {},
200-
})
202+
}),
201203
),
202204
javascriptLanguage.data.of({
203205
autocomplete: customCompletions,
@@ -251,16 +253,16 @@ function decompressString(str) {
251253
new Uint8Array(
252254
atob(str)
253255
.split("")
254-
.map((c) => c.charCodeAt(0))
256+
.map((c) => c.charCodeAt(0)),
255257
),
256-
{ to: "string" }
258+
{ to: "string" },
257259
);
258260
console.log("Playground url decoded successfully!");
259261
break;
260262
} catch (e) {
261263
console.error(
262264
`Failed decode the playground url (${attempts + 1}/2). Error:`,
263-
e
265+
e,
264266
);
265267
console.log("Trying to decode again (fixing some characters)...");
266268
code = null;
@@ -286,7 +288,7 @@ if (config.autosave) {
286288
function saveCode() {
287289
localStorage.setItem(
288290
"litecanvas_code",
289-
window.codeEditor.state.doc.toString()
291+
window.codeEditor.state.doc.toString(),
290292
);
291293
}
292294

0 commit comments

Comments
 (0)