Support custom TextMate themes in consuming modules#103
Open
Dansoftowner wants to merge 6 commits intoJPro-one:mainfrom
Open
Support custom TextMate themes in consuming modules#103Dansoftowner wants to merge 6 commits intoJPro-one:mainfrom
Dansoftowner wants to merge 6 commits intoJPro-one:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR makes code theme loading customizable for
MarkdownCodeBlock.Previously, applications using jpro-mdfx as a library could not load their own TextMate code themes with CSS such as
-mdfx-code-theme: "path/to/my/own/theme", even when the resource package was opened correctly, because theme paths were resolved relative to MDFX internal classes instead of the consuming application.Changes
MarkdownCodeBlock.createCodeThemeSource(String codeTheme)as an overridable hook for custom theme loading.MarkdownView.setThemeResourceClass(Class<?>)andgetThemeResourceClass().MarkdownViewnow passes its configured theme resource class to generatedMarkdownCodeBlockinstances.MarkdownCodeBlockfirst attempts to load the requested theme relative to the configured theme resource class.MarkdownCodeBlock.class, preserving support for MDFX bundled themes.Why
This allows applications and modules using MDFX to package and load their own TextMate code themes. It also keeps the default behavior compatible with existing theme paths.
Examples
When
MarkdownViewis subclassed, the subclass is used as the default theme resource class:For advanced cases,
MarkdownCodeBlock.createCodeThemeSource(...)can still be overridden: