Skip to content

feat: expose renderMarkdownToHtml on ExtensionManager#10700

Merged
christian-byrne merged 1 commit intoComfy-Org:mainfrom
christian-byrne:feat/expose-renderMarkdownToHtml
Mar 29, 2026
Merged

feat: expose renderMarkdownToHtml on ExtensionManager#10700
christian-byrne merged 1 commit intoComfy-Org:mainfrom
christian-byrne:feat/expose-renderMarkdownToHtml

Conversation

@christian-byrne
Copy link
Copy Markdown
Contributor

@christian-byrne christian-byrne commented Mar 29, 2026

Summary

Expose renderMarkdownToHtml() on the ExtensionManager interface so custom node extensions can render markdown to sanitized HTML without bundling their own copies of marked/DOMPurify.

Motivation

Multiple custom node packs (KJNodes, comfy_mtb, rgthree-comfy) bundle their own markdown rendering libraries to implement help popups on nodes. This causes:

  • Cloud breakage: KJNodes uses a kjweb_async pattern (custom aiohttp static route) to lazily load marked.min.js and purify.min.js. This 404s on Cloud because the custom route is not registered.
  • Redundant bundling: Both marked (^15.0.11) and dompurify (^3.2.5) are already direct dependencies of the frontend, used internally by markdownRendererUtil.ts, NodePreview.vue, WhatsNewPopup.vue, etc.
  • XSS risk: Custom nodes using raw marked without DOMPurify could introduce XSS vulnerabilities.

By exposing the existing renderMarkdownToHtml() through the official ExtensionManager API, custom nodes can:

const html = app.extensionManager.renderMarkdownToHtml(nodeData.description)

...instead of bundling and loading their own copies.

Changes

  • src/types/extensionTypes.ts: Add renderMarkdownToHtml(markdown: string, baseUrl?: string): string to the ExtensionManager interface with JSDoc.
  • src/stores/workspaceStore.ts: Import and re-export renderMarkdownToHtml from @/utils/markdownRendererUtil.

Impact

  • Zero bundle size increase — the function and its dependencies are already bundled in the vendor-markdown chunk.
  • No breaking changes — purely additive to the ExtensionManager interface.
  • Follows existing pattern — same approach as toast, dialog, command, setting on ExtensionManager.

Related: #TBD (long-term plan for custom node extension library dependencies)

┆Issue is synchronized with this Notion page by Unito

Add renderMarkdownToHtml to the ExtensionManager interface so custom
node extensions can render markdown to sanitized HTML without bundling
their own copies of marked/DOMPurify.

Both libraries are already bundled in the frontend (marked ^15.0.11,
dompurify ^3.2.5) and used internally. This exposes the existing
utility function through the official public API surface that
extensions already use (app.extensionManager).

The function uses marked with GFM support and DOMPurify sanitization,
making it safe for direct use with innerHTML.
@christian-byrne christian-byrne requested a review from a team March 29, 2026 06:42
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 29, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

The changes expose a markdown-to-HTML rendering utility function through the workspace store API and establish its contract in the ExtensionManager interface. The function accepts markdown text with an optional base URL parameter and returns sanitized HTML via marked and DOMPurify.

Changes

Cohort / File(s) Summary
Markdown Rendering Function Export
src/stores/workspaceStore.ts, src/types/extensionTypes.ts
Added renderMarkdownToHtml function to workspace store API (imported from markdownRendererUtil) and defined its method signature in the ExtensionManager interface with parameters for markdown content and optional base URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 With whiskers twitching, I type with glee,
Markdown now renders, for all to see!
From store to interface, the path is clear,
HTML rendered, pure and dear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: exposing renderMarkdownToHtml on ExtensionManager, which is the primary objective of the changeset.
End-To-End Regression Coverage For Fixes ✅ Passed PR title uses 'feat:' prefix indicating a feature addition, not a bug fix. Bug-fix language check condition is satisfied.
Adr Compliance For Entity/Litegraph Changes ✅ Passed This check does not apply because the PR only modifies files in src/stores/ and src/types/, which are outside the specified paths (src/lib/litegraph/, src/ecs/, or graph entity files).
Description check ✅ Passed The pull request description comprehensively covers all required template sections with clear detail about changes, motivation, and impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 29, 2026

🎭 Playwright: ✅ 768 passed, 0 failed · 3 flaky

📊 Browser Reports
  • chromium: View Report (✅ 754 / ❌ 0 / ⚠️ 3 / ⏭️ 1)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 11 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

@github-actions
Copy link
Copy Markdown

🎨 Storybook: loading Building...

@christian-byrne christian-byrne added needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch core/1.42 Backport PRs for core 1.42 cloud/1.42 Backport PRs for cloud 1.42 labels Mar 29, 2026
@christian-byrne christian-byrne merged commit 367f810 into Comfy-Org:main Mar 29, 2026
52 of 54 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 29, 2026
## Summary

Expose `renderMarkdownToHtml()` on the `ExtensionManager` interface so
custom node extensions can render markdown to sanitized HTML without
bundling their own copies of `marked`/`DOMPurify`.

## Motivation

Multiple custom node packs (KJNodes, comfy_mtb, rgthree-comfy) bundle
their own markdown rendering libraries to implement help popups on
nodes. This causes:

- **Cloud breakage**: KJNodes uses a `kjweb_async` pattern (custom
aiohttp static route) to lazily load `marked.min.js` and
`purify.min.js`. This 404s on Cloud because the custom route is not
registered.
- **Redundant bundling**: Both `marked` (^15.0.11) and `dompurify`
(^3.2.5) are already direct dependencies of the frontend, used
internally by `markdownRendererUtil.ts`, `NodePreview.vue`,
`WhatsNewPopup.vue`, etc.
- **XSS risk**: Custom nodes using raw `marked` without `DOMPurify`
could introduce XSS vulnerabilities.

By exposing the existing `renderMarkdownToHtml()` through the official
`ExtensionManager` API, custom nodes can:
```js
const html = app.extensionManager.renderMarkdownToHtml(nodeData.description)
```
...instead of bundling and loading their own copies.

## Changes

- **`src/types/extensionTypes.ts`**: Add `renderMarkdownToHtml(markdown:
string, baseUrl?: string): string` to the `ExtensionManager` interface
with JSDoc.
- **`src/stores/workspaceStore.ts`**: Import and re-export
`renderMarkdownToHtml` from `@/utils/markdownRendererUtil`.

## Impact

- **Zero bundle size increase** — the function and its dependencies are
already bundled in the `vendor-markdown` chunk.
- **No breaking changes** — purely additive to the `ExtensionManager`
interface.
- **Follows existing pattern** — same approach as `toast`, `dialog`,
`command`, `setting` on `ExtensionManager`.

Related: #TBD (long-term plan for custom node extension library
dependencies)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10700-feat-expose-renderMarkdownToHtml-on-ExtensionManager-3326d73d36508149bc1dc6bb45e7c077)
by [Unito](https://www.unito.io)
github-actions bot pushed a commit that referenced this pull request Mar 29, 2026
## Summary

Expose `renderMarkdownToHtml()` on the `ExtensionManager` interface so
custom node extensions can render markdown to sanitized HTML without
bundling their own copies of `marked`/`DOMPurify`.

## Motivation

Multiple custom node packs (KJNodes, comfy_mtb, rgthree-comfy) bundle
their own markdown rendering libraries to implement help popups on
nodes. This causes:

- **Cloud breakage**: KJNodes uses a `kjweb_async` pattern (custom
aiohttp static route) to lazily load `marked.min.js` and
`purify.min.js`. This 404s on Cloud because the custom route is not
registered.
- **Redundant bundling**: Both `marked` (^15.0.11) and `dompurify`
(^3.2.5) are already direct dependencies of the frontend, used
internally by `markdownRendererUtil.ts`, `NodePreview.vue`,
`WhatsNewPopup.vue`, etc.
- **XSS risk**: Custom nodes using raw `marked` without `DOMPurify`
could introduce XSS vulnerabilities.

By exposing the existing `renderMarkdownToHtml()` through the official
`ExtensionManager` API, custom nodes can:
```js
const html = app.extensionManager.renderMarkdownToHtml(nodeData.description)
```
...instead of bundling and loading their own copies.

## Changes

- **`src/types/extensionTypes.ts`**: Add `renderMarkdownToHtml(markdown:
string, baseUrl?: string): string` to the `ExtensionManager` interface
with JSDoc.
- **`src/stores/workspaceStore.ts`**: Import and re-export
`renderMarkdownToHtml` from `@/utils/markdownRendererUtil`.

## Impact

- **Zero bundle size increase** — the function and its dependencies are
already bundled in the `vendor-markdown` chunk.
- **No breaking changes** — purely additive to the `ExtensionManager`
interface.
- **Follows existing pattern** — same approach as `toast`, `dialog`,
`command`, `setting` on `ExtensionManager`.

Related: #TBD (long-term plan for custom node extension library
dependencies)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10700-feat-expose-renderMarkdownToHtml-on-ExtensionManager-3326d73d36508149bc1dc6bb45e7c077)
by [Unito](https://www.unito.io)
@comfy-pr-bot
Copy link
Copy Markdown
Member

@christian-byrne Successfully backported to #10719

@comfy-pr-bot
Copy link
Copy Markdown
Member

@christian-byrne Successfully backported to #10720

@github-actions github-actions bot removed the needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch label Mar 29, 2026
comfy-pr-bot added a commit that referenced this pull request Mar 29, 2026
…anager (#10720)

Backport of #10700 to `cloud/1.42`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10720-backport-cloud-1-42-feat-expose-renderMarkdownToHtml-on-ExtensionManager-3326d73d3650819189fde93d1fe2584b)
by [Unito](https://www.unito.io)

Co-authored-by: Christian Byrne <cbyrne@comfy.org>
comfy-pr-bot added a commit that referenced this pull request Mar 29, 2026
…nager (#10719)

Backport of #10700 to `core/1.42`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10719-backport-core-1-42-feat-expose-renderMarkdownToHtml-on-ExtensionManager-3326d73d36508124bb21d6b2a5119402)
by [Unito](https://www.unito.io)

Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cloud/1.42 Backport PRs for cloud 1.42 core/1.42 Backport PRs for core 1.42 size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants