fix(ui): limit Markdown rendering on RichInput#6061
Conversation
- Added a new `useMarkdown` prop to RichInput for toggling between Markdown and HTML content. - Updated the `extensions` function to conditionally configure link support based on the `useMarkdown` prop. - Modified the content update logic to handle Markdown conversion when `useMarkdown` is enabled. - Adjusted initial content loading to respect the `useMarkdown` setting for proper content type detection.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to the RichInput UI component by providing explicit control over Markdown rendering. The changes allow developers to toggle between Markdown and HTML content handling, ensuring that the input field behaves as expected based on the desired content type. This prevents unwanted Markdown interpretations when plain HTML is intended and vice-versa, improving the flexibility and reliability of the RichInput component. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
| StarterKit.configure({ | ||
| codeBlock: false | ||
| codeBlock: false, | ||
| ...(!useMarkdown && { link: false }) |
There was a problem hiding this comment.
need to disable link for non-markdown usage
- StarterKit v3.20.4 added Link extension (wasn't in v2):
- starter-kit/dist/index.js:
if (this.options.link !== false) { extensions.push(Link.configure(...)) }
- starter-kit/dist/index.js:
- Link extension defaults to autolink: true with HTML attributes that wrap URLs:
- extension-link/src/link.ts:234:
autolink: true - extension-link/src/link.ts:238-239:
target: '_blank', rel: 'noopener noreferrer nofollow'
- extension-link/src/link.ts:234:
- This transforms https://example.com into:
<a target="_blank" rel="noopener noreferrer nofollow" href="https://example.com">https://example.com</a>
- Server-side TurndownService then converts to markdown link https://example.com, which is an invalid URL.
The v2 → v3 StarterKit upgrade in PR #6021 silently introduced the Link extension with auto-linking enabled.
Without the change, url will include an a tag which will also lead to invalid url error
"url": "<p><a target=\"_blank\" rel=\"noopener noreferrer nofollow\" href=\"https://github.com/FlowiseAI/Flowise/pull\">https://github.com/FlowiseAI/Flowise/pull</a>/<span class=\"variable\" data-type=\"mention\" data-id=\"$form.pr\" data-label=\"$form.pr\" data-mention-suggestion-char=\"{{\">{{ $form.pr }}</span> </p>",
There was a problem hiding this comment.
Note on html tag in the url field:
-
url field with variable:
"url": "<p>https://github.com/FlowiseAI/Flowise/pull/<span class=\"variable\" data-type=\"mention\" data-id=\"question\" data-label=\"question\" data-mention-suggestion-char=\"{{\">{{ question }}</span> </p>", -
url field without variable:
"url": "<p>https://github.com/FlowiseAI/Flowise/pull/6053</p>",
only the <a> tag would cause problem. The server's resolveVariables handles span tag correctly:
- Detects HTML (
<p>matches) → runs TurndownService - TurndownService converts
<p>https://.../<span>{{ question }}</span></p>→https://.../{{ question }} - Variable resolution replaces
{{ question }}→https://.../123 new URL("https://.../123")→ works
The <a> tag was the issue because TurndownService converts <a href="url">text</a> to [text](url) markdown link syntax, which is not a valid URL.
There was a problem hiding this comment.
Code Review
This pull request enhances the RichInput component by introducing a useMarkdown flag, determined by inputParam?.rows. This flag conditionally enables or disables Markdown functionality within the rich text editor. When useMarkdown is true, the editor processes content as Markdown, including disabling the link extension when not in markdown mode, and attempts to retrieve Markdown content on update. Conversely, when useMarkdown is false, the editor operates in HTML mode, disabling the link extension and handling content as HTML. The initial content loading logic has also been updated to align with this new useMarkdown flag. There is no feedback to provide.





useMarkdownprop to RichInput for toggling between Markdown and HTML content.extensionsfunction to conditionally configure link support based on theuseMarkdownprop.useMarkdownis enabled.useMarkdownsetting for proper content type detection.Fix in http node
markdown-fix-http-with-variable.mov
Markdown support for input allowing multiple rows
markdown-support-when-enabled.mov