Compare commits
3 Commits
Containerf
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
8b3c78cb84 | ||
|
049a1b0125 | ||
f5aac579ff |
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;
|
||||
|
Reference in New Issue
Block a user