mattcasters opened a new pull request, #7396:
URL: https://github.com/apache/hop/pull/7396
Here is a complete description of the changes that you can copy and paste
directly for the code reviewers of **Issue #7111**:
***
### Description of Changes
This PR introduces a dedicated file handler for Markdown (`.md`) files in
the Hop File Explorer perspective. It adds an interactive toolbar at the top of
the Markdown viewer containing a **Preview** button to generate and open styled
HTML versions of the Markdown files.
#### Key Features:
1. **Dedicated Handler (`MarkDownExplorerFileTypeHandler`)**:
* Registers a dedicated subclass of `BaseTextExplorerFileTypeHandler` for
`.md` files.
* Enables syntax highlighting by returning `"markdown"` from
`getLanguageId()`.
2. **Declarative Toolbar Integration**:
* Leverages Hop's declarative UI system by decorating the class with
`@GuiPlugin` and utilizing `ToolbarFacade` and `GuiToolbarWidgets`.
* Integrates the "Preview" button using the `@GuiToolbarElement`
annotation to call the preview logic.
3. **HTML Generator & Styling (Supporting Dark Mode)**:
* Parses the Markdown structure into HTML using the bundled
`org.commonmark:commonmark` library.
* Embeds customized CSS styles to match the Hop GUI look:
* **Dark Mode** (when `PropsUi.getInstance().isDarkMode()` is `true`):
Employs a premium slate-navy palette (`#0b0f19` background, `#f8fafc` headers,
`#38bdf8` cyan links, and `#1e293b` code blocks).
* **Light Mode**: Employs a clean off-white template (`#f8fafc`
background, `#0f172a` headers, `#2563eb` links, and `#f1f5f9` code blocks).
* Saves the generated HTML page to a local temporary file and opens it in
the system's default browser via `EnvironmentUtils.getInstance().openUrl(...)`.
---
### Files Modified & Created
* **`plugins/transforms/textfile/pom.xml`**: Added
`org.commonmark:commonmark` dependency (version `0.27.1`) to the build
classpath.
* **`plugins/transforms/textfile/.../types/MarkDownExplorerFileType.java`**:
Changed the generic argument type to refer to `MarkDownExplorerFileTypeHandler`
and updated factory methods accordingly.
*
**`plugins/transforms/textfile/.../types/MarkDownExplorerFileTypeHandler.java`**
*(New File)*: Implemented the new custom handler, declarative toolbar
initialization, and commonmark parsing and styling logic.
* **`plugins/transforms/textfile/.../messages/messages_en_US.properties`** &
**`messages_pt_BR.properties`**: Added
`MarkDownFileTypeHandler.Preview.Tooltip` translations for the toolbar button
tooltip.
---
### Verification and Testing
1. **Spotless & Checkstyle**:
* Passed `./mvnw spotless:check` and `./mvnw checkstyle:check` cleanly.
2. **Compilation**:
* Compiled successfully with `./mvnw clean install -pl
plugins/transforms/textfile -DskipTests`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]