From a8088181d3f4c16ab103c6f549c17b0025e62cc1 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 23 Jun 2026 11:57:02 -0500 Subject: [PATCH] A better approach for dark mode for some rendering in the editor. This reworks what was done in #3008 and #3016. Rather than trying to force the PG critic and hardcopy xml into light mode, remove the `bg-white` class from the render panel and use the page colors. This means that these things are in a proper dark mode for those that use it. Problems do not need the white background since by default iframes are given a white background. Also the iframe elements do not need to have the `color-scheme` style set to `light`. That has no effect inside the iframe anyway. --- htdocs/js/PGProblemEditor/pgproblemeditor.js | 4 +--- htdocs/js/RenderProblem/renderproblem.js | 1 - templates/ContentGenerator/Instructor/PGProblemEditor.html.ep | 2 +- .../Instructor/PGProblemEditor/pg_critic.html.ep | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/js/PGProblemEditor/pgproblemeditor.js b/htdocs/js/PGProblemEditor/pgproblemeditor.js index 70c6be34f6..fe41965c22 100644 --- a/htdocs/js/PGProblemEditor/pgproblemeditor.js +++ b/htdocs/js/PGProblemEditor/pgproblemeditor.js @@ -574,7 +574,6 @@ const iframe = document.createElement('iframe'); iframe.title = 'Rendered content'; iframe.id = 'pgedit-render-iframe'; - iframe.style.colorScheme = 'light'; // Adjust editor dimensions when the window is resized and when the iframe loads. const adjustIFrameHeight = () => { @@ -667,8 +666,7 @@ if (fileType === 'hardcopy_theme') { const contents = webworkConfig?.pgCodeMirror?.source; if (contents) { - renderArea.innerHTML = - '
' + contents.replace(/&/g, '&').replace(/';
+					renderArea.innerHTML = '
' + contents.replace(/&/g, '&').replace(/';
 				} else
 					renderArea.innerHTML =
 						'
The file has no content.
'; diff --git a/htdocs/js/RenderProblem/renderproblem.js b/htdocs/js/RenderProblem/renderproblem.js index f3bb2bbebb..ec4503a64a 100644 --- a/htdocs/js/RenderProblem/renderproblem.js +++ b/htdocs/js/RenderProblem/renderproblem.js @@ -69,7 +69,6 @@ iframe = document.createElement('iframe'); iframe.id = `${renderArea.id}_iframe`; iframe.style.border = 'none'; - iframe.style.colorScheme = 'light'; while (renderArea.firstChild) renderArea.firstChild.remove(); renderArea.append(iframe); diff --git a/templates/ContentGenerator/Instructor/PGProblemEditor.html.ep b/templates/ContentGenerator/Instructor/PGProblemEditor.html.ep index 5d7f86dbe6..13f6e68660 100644 --- a/templates/ContentGenerator/Instructor/PGProblemEditor.html.ep +++ b/templates/ContentGenerator/Instructor/PGProblemEditor.html.ep @@ -175,7 +175,7 @@ > -
+
diff --git a/templates/ContentGenerator/Instructor/PGProblemEditor/pg_critic.html.ep b/templates/ContentGenerator/Instructor/PGProblemEditor/pg_critic.html.ep index b5fcf46f9d..33de2acdcf 100644 --- a/templates/ContentGenerator/Instructor/PGProblemEditor/pg_critic.html.ep +++ b/templates/ContentGenerator/Instructor/PGProblemEditor/pg_critic.html.ep @@ -1,6 +1,6 @@ % Perl::Critic::Violation::set_format('%m at line %l, column %c.'); % -
+

<%= maketext('PG Critic Violations') %>

% my @pgCriticViolations = grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ } @$violations; % my @perlCriticViolations = grep { $_->policy !~ /^Perl::Critic::Policy::PG::/ } @$violations;