Add ESC handling
This commit is contained in:
parent
f2bf94371f
commit
a4bc66c61d
2 changed files with 19 additions and 5 deletions
|
@ -13,16 +13,17 @@
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
width: 300px;
|
/* width: 300px;*/
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
|
padding: 10px;
|
||||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card:hover {
|
.card:hover {
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transform: scale(1.05);
|
/* transform: scale(1.05); */
|
||||||
transition: all 0.3s ease;
|
/* transition: all 0.3s ease; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.question {
|
.question {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
import CodeMirror from "svelte-codemirror-editor";
|
import CodeMirror from "svelte-codemirror-editor";
|
||||||
import { markdown } from "@codemirror/lang-markdown";
|
import { markdown } from "@codemirror/lang-markdown";
|
||||||
import QuizCard from "./QuizCard.svelte";
|
import QuizCard from "./QuizCard.svelte";
|
||||||
|
@ -9,8 +10,15 @@
|
||||||
|
|
||||||
let value: string;
|
let value: string;
|
||||||
let editingIndex: number;
|
let editingIndex: number;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
document.addEventListener("keydown", handleKeydown);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", handleKeydown);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
function editQuiz(quiz: Quiz, index: number) {
|
function editQuiz(quiz: main.Quiz, index: number) {
|
||||||
Markdown(quiz).then(
|
Markdown(quiz).then(
|
||||||
(result) => {
|
(result) => {
|
||||||
value = result;
|
value = result;
|
||||||
|
@ -27,7 +35,12 @@
|
||||||
)
|
)
|
||||||
editingIndex = -1;
|
editingIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key === "Escape" && editingIndex !== -1) {
|
||||||
|
editingIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in a new issue