From 22acf6e3b1fc4950af68bcee3f9e013dd3760f41 Mon Sep 17 00:00:00 2001 From: Kevin Jilissen Date: Fri, 14 Nov 2025 00:04:48 +0100 Subject: [PATCH] Dynamically stretch the code editor height --- webapp/public/js/domjudge.js | 8 ++++++++ webapp/public/style_domjudge.css | 1 - webapp/src/Twig/TwigExtension.php | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webapp/public/js/domjudge.js b/webapp/public/js/domjudge.js index 371ae20e92..949df4752a 100644 --- a/webapp/public/js/domjudge.js +++ b/webapp/public/js/domjudge.js @@ -1290,3 +1290,11 @@ function initScoreboardSubmissions() { }); }); } + +function resizeEditors() { + // This function assumes that there is at most one tabbed editor in the screen. + const activeEditor = document.querySelector(".tab-pane.active .editor"); + const height = $(window).height() - document.body.offsetHeight + activeEditor.clientHeight - 1 + "px"; + $('.editor').height(height); +} +$(window).resize(resizeEditors); diff --git a/webapp/public/style_domjudge.css b/webapp/public/style_domjudge.css index 18eb31ef24..ab2f593aa3 100644 --- a/webapp/public/style_domjudge.css +++ b/webapp/public/style_domjudge.css @@ -754,6 +754,5 @@ blockquote { .editor { width: 100%; - height: 80vh; border: 1px solid grey; } diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 60df1de6cc..c59b0a1d7c 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -883,6 +883,7 @@ public function codeEditor( }); %s %s + resizeEditors(); }); }); @@ -1011,6 +1012,7 @@ public function showDiff(string $id, SubmissionFile $newFile, SubmissionFile $ol updateMode(e.target.value); }); updateMode(initialDiffMode); + resizeEditors(); }); });