Skip to content

Mdfx css fixes#87

Merged
FlorianKirmaier merged 3 commits intomainfrom
mdfx-css-fixes
Mar 10, 2026
Merged

Mdfx css fixes#87
FlorianKirmaier merged 3 commits intomainfrom
mdfx-css-fixes

Conversation

@dlemmermann
Copy link
Collaborator

Fixes issue #86 and some more cleanup / simplification.

Copilot AI review requested due to automatic review settings March 10, 2026 15:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #86 by removing MarkdownCodeBlock’s dedicated user-agent stylesheet (which prevented downstream CSS overrides) and consolidating code block styling into the main mdfx.css, along with some CSS cleanup/simplification.

Changes:

  • Removed MarkdownCodeBlock’s getUserAgentStylesheet() and deleted markdown-code-block.css.
  • Refactored mdfx.css variables/styles (now scoped under .markdown-view) and added/updated block quote + code block rules.
  • Updated the example to apply padding and add the markdown-view style class.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
jpro-mdfx/src/main/resources/one/jpro/platform/mdfx/mdfx.css Consolidates styling (incl. code blocks) and refactors default looked-up variables.
jpro-mdfx/src/main/resources/one/jpro/platform/mdfx/markdown-code-block.css Removed to avoid a separate UA stylesheet for code blocks.
jpro-mdfx/src/main/java/one/jpro/platform/mdfx/MarkdownCodeBlock.java Removes the control-specific UA stylesheet hook.
jpro-mdfx/example/src/main/java/one/jpro/platform/mdfx/example/MarkdownViewSample.java Applies padding/style class to match the new CSS scoping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1 to 16
.markdown-view {
-mdfx-font-color: -fx-text-base-color;
-mdfx-link-color: -fx-accent;
-mdfx-border-color-1: -fx-box-border;

-mdfx-bg-color-1: #ccc;
-mdfx-bg-color-2: #ddd;
-mdfx-bg-color-3: #eee;
-mdfx-bg-color-1: -fx-control-inner-background;
-mdfx-bg-color-2: -fx-control-inner-background-alt;
-mdfx-bg-color-3: -fx-color;

-mdfx-bq-color-border: #4488cc;
-mdfx-bq-color-background: #0000ff0c;
-mdfx-bq-color-border: derive(-fx-accent, -50%);
-mdfx-bq-color-background: -fx-accent;
-mdfx-bq-text-fill: -fx-selection-bar-text;

-mdfx-code-block-border: -fx-box-border;
-mdfx-code-block-background: -fx-control-inner-background;
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default variable definitions from the global * selector to .markdown-view will break styling unless MarkdownView instances always have the markdown-view style class. MarkdownView currently does not add this class by default (it’s a plain VBox), so looked-up colors like -mdfx-font-color may become undefined for existing consumers. Consider restoring a global fallback selector, or (preferably) ensure MarkdownView adds markdown-view to its style class list in code so the CSS always applies without requiring app code changes.

Copilot uses AI. Check for mistakes.
-mdfx-bg-color-3: #eee;
-mdfx-bg-color-1: -fx-control-inner-background;
-mdfx-bg-color-2: -fx-control-inner-background-alt;
-mdfx-bg-color-3: -fx-color;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-mdfx-bg-color-3 is set to -fx-color, but this looked-up color is not defined anywhere in this project’s CSS and may not be available for a VBox-based control under all JavaFX themes. If it resolves to an undefined value, .markdown-table-cell-top background styling can be ignored. Consider deriving it from a reliably-defined value like -fx-control-inner-background (e.g., derive(...)) or using -fx-control-inner-background directly.

Suggested change
-mdfx-bg-color-3: -fx-color;
-mdfx-bg-color-3: -fx-control-inner-background;

Copilot uses AI. Check for mistakes.
Comment on lines +175 to +176
-fx-background: -mdfx-bq-color-background;
-fx-background-color: -fx-background;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -fx-background as an intermediate looked-up value is confusing because the -fx- prefix is generally reserved for JavaFX-defined properties, and JavaFX has no standard -fx-background property (only -fx-background-color, -fx-background-insets, etc.). Since you already have -mdfx-bq-color-background, it’s clearer and less error-prone to set -fx-background-color directly to -mdfx-bq-color-background and drop the extra looked-up value.

Suggested change
-fx-background: -mdfx-bq-color-background;
-fx-background-color: -fx-background;
-fx-background-color: -mdfx-bq-color-background;

Copilot uses AI. Check for mistakes.
import one.jpro.platform.mdfx.MarkdownView;
import one.jpro.platform.mdfx.extensions.YoutubeExtension;
import org.apache.commons.io.IOUtils;
import org.scenicview.ScenicView;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.scenicview.ScenicView is imported but not used anywhere in this file, which will fail builds that enforce no-unused-imports (e.g., via Checkstyle/Spotless) and adds unnecessary dependency coupling in the example. Please remove the unused import or add the intended ScenicView usage.

Suggested change
import org.scenicview.ScenicView;

Copilot uses AI. Check for mistakes.
@FlorianKirmaier FlorianKirmaier merged commit 7141016 into main Mar 10, 2026
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants