From 28f920240377aae7567ff5461c483f7e3802ff2d Mon Sep 17 00:00:00 2001 From: goynov Date: Sat, 7 Feb 2026 14:18:58 +0200 Subject: [PATCH] copy/paste from Excel --- .../MazeQuizGame/MazeQuizGame.vue | 31 +++++++++++++++++-- src/plugins/lang.js | 2 ++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue index 4547c11..17845bd 100644 --- a/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue +++ b/src/components/InteractiveObjects/MazeQuizGame/MazeQuizGame.vue @@ -29,9 +29,12 @@ - - Add question - Close + + {{ l.addQuestion }} + + + + {{ l.close }} @@ -78,6 +81,28 @@ export default { }, deleteQuestion(idx){ this.modelValue.questions.splice(idx, 1); + }, + async pasteFromExcel(){ + const text = await navigator.clipboard.readText(); + if(text){ + let rows = text.split('\n'); + this.modelValue.questions.splice(0, this.modelValue.questions.length); + rows.forEach(r=>{ + let cols = r.split('\t'); + if(cols.length >= 4){ + this.modelValue.questions.push({ + q: cols[0], + a: [cols[1], cols[2], cols[3]], + h: cols[4] || '' + }) + } + }) + } + }, + copyToExcel(){ + let text = this.modelValue.questions.map(q=> `${q.q}\t${q.a[0]}\t${q.a[1]}\t${q.a[2] || ''}\t${q.h || ''}`).join('\n'); + navigator.clipboard.writeText(text); + this.toast('Copied to clipboard, you can paste it in Excel or similar spreadsheet software', 'success'); } } } diff --git a/src/plugins/lang.js b/src/plugins/lang.js index 2ed6fc2..8fb6a45 100644 --- a/src/plugins/lang.js +++ b/src/plugins/lang.js @@ -60,6 +60,7 @@ const lang = { width: 'Width', height: 'Height', question: 'Question', + addQuestion: 'Add question', manageQuestions: 'Manage questions', shuffleQuestions: 'Shuffle questions', correctAnswer: 'Correct answer', @@ -195,6 +196,7 @@ const lang = { width: 'Ширина', height: 'Височина', question: 'Въпрос', + addQuestion: 'Добавяне на въпрос', manageQuestions: 'Въвеждане на въпросите', shuffleQuestions: 'Разбъркване на въпросите', correctAnswer: 'Правилен отговор',