3 Commits

Author SHA1 Message Date
Maurice
8b3c78cb84 Fixed language picker bug in viewer 2024-02-05 16:34:29 +01:00
Maurice
049a1b0125 Fix 2024-02-01 20:42:32 +01:00
f5aac579ff Merge pull request 'build: update containerfile' () from Containerfile into dev
Reviewed-on: 
2024-02-01 19:08:54 +00:00
2 changed files with 15 additions and 9 deletions
pastabble-frontend/src/lib

@@ -6,23 +6,22 @@
export let language: string | undefined;
let displayCode: string | undefined;
let displayLanguage: string | undefined;
let showAlert = false;
let initial = true;
$: if(code) {
highlight();
initial = false;
}
$: if(language) {
if(initial || !code) {
highlight();
}
$: if(language !== displayLanguage) {
highlight();
}
function highlight() {
if(language) {
const res = hljs.highlight(language!, code!);
const res = hljs.highlight(code!, {
language
});
if(!res.errorRaised) {
displayCode = res.value;
}
@@ -33,6 +32,7 @@
language = res.language;
}
}
displayLanguage = language;
}
async function copy() {

@@ -45,7 +45,10 @@
});
if(res.ok) {
const id = await res.text();
let id = await res.text();
if(id.includes('/')) {
id = id.substring(id.lastIndexOf('/') + 1);
}
push(`/${id}`);
}
}
@@ -75,7 +78,10 @@
});
if(res.status === 200) {
const id = await res.text();
let id = await res.text();
if(id.includes('/')) {
id = id.substring(id.lastIndexOf('/') + 1);
}
createdUrl = `${location.origin}/to/${id}`;
enteredUrl = '';
showAlert = true;