Skip to content

Conversation

@Yukaii
Copy link
Member

@Yukaii Yukaii commented Jun 5, 2025

  • Added mermaid.min.js to the build output in webpack.common.js.
  • Updated mermaid initialization in extra.js to use the new API.
  • Included mermaid.min.js script in foot.ejs, pretty.ejs, and slide.ejs for rendering diagrams.

Signed-off-by: Yukai Huang [email protected]

…ization in extra.js

- Added mermaid.min.js to the build output in webpack.common.js.
- Updated mermaid initialization in extra.js to use the new API.
- Included mermaid.min.js script in foot.ejs, pretty.ejs, and slide.ejs for rendering diagrams.

Signed-off-by: Yukai Huang <[email protected]>
@Yukaii Yukaii force-pushed the bugfix/dev-2044-mermaid-bundling-issue branch from c6e7d3b to 97b3ad8 Compare June 5, 2025 05:28
@Yukaii Yukaii linked an issue Jun 5, 2025 that may be closed by this pull request
@Yukaii Yukaii requested review from Copilot and jackycute June 5, 2025 05:31
Copy link
Contributor

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 integrates Mermaid.js into the build pipeline and updates the initialization and rendering logic in extra.js to use Mermaid’s new API.

  • Add mermaid.min.js to Webpack’s output and remove legacy loader entries
  • Inject mermaid.min.js script tags into EJS templates
  • Refactor extra.js to call mermaid.initialize and mermaid.run instead of the old API

Reviewed Changes

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

Show a summary per file
File Description
webpack.common.js Add copy step for mermaid.min.js and drop old script-loader!mermaid entries
public/views/slide.ejs Include Mermaid script tag in slide view
public/views/pretty.ejs Include Mermaid script tag in pretty print view
public/views/codimd/foot.ejs Include Mermaid script tag in CodiMD foot template
public/js/extra.js Replace startOnLoad assignment with mermaid.initialize, switch mermaid.init to mermaid.run
Comments suppressed due to low confidence (4)

public/js/extra.js:439

  • [nitpick] The callback parameters key and value are ambiguous; consider renaming them to index and element for clarity.
mermaids.each(async (key, value) => {

public/js/extra.js:257

  • New API usage in extra.js should be covered by unit or integration tests (e.g., mocking mermaid.initialize and verifying mermaid.run calls) to ensure diagrams render as expected.
window.mermaid.initialize({

public/views/pretty.ejs:108

  • Indentation is inconsistent with the surrounding <script> tags; consider adding the same leading whitespace to match the existing style.
<script src="<%- serverURL %>/build/mermaid/mermaid.min.js" defer></script>

public/views/codimd/foot.ejs:33

  • This <script> tag is not indented like the others in this block; adjust whitespace to maintain consistency.
<script src="<%- serverURL %>/build/mermaid/mermaid.min.js" defer></script>

- Refactored the mermaid rendering logic to utilize the latest API for generating diagrams.
- Improved error handling by displaying the error message directly instead of using a string property.
- Ensured that the diagram's HTML is updated correctly after rendering.

Signed-off-by: Yukai Huang <[email protected]>
@Yukaii Yukaii merged commit 470e228 into develop Jun 5, 2025
5 checks passed
@Yukaii Yukaii deleted the bugfix/dev-2044-mermaid-bundling-issue branch June 5, 2025 06:42
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.

Editor page Error in built docker image (commit 3c86c655)

3 participants