-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support markdown on user message #3848
Merged
Merged
Conversation
This file contains 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
urmauur
changed the title
feat: support markdown
feat: support markdown on user message
Oct 21, 2024
Works well on my end. |
louis-jan
approved these changes
Oct 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @urmauur, this looks great! |
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.
Describe Your Changes
New Rich Editor Component (
RichTextEditor.tsx
):RichTextEditor.tsx
is created, which defines a React component for a rich text editor using Slate.js.Custom Types for Slate:
slate
module declaration is updated to include custom types (CustomElement
,CustomText
) that extend the default Slate Editor interface.Initial Value:
Decorate Function:
decorate
function is implemented to identify code blocks and apply styles (bold, italic) to text ranges.highlight.js
.RenderLeaf Function:
renderLeaf
function applies the formatting and styling attributes to the text elements in the editor.Event Handling:
onKeyDown
are implemented to handle specific key events (e.g., Enter, Tab) for inserting new lines, toggling code blocks, and handling tab indentation.Styling:
RichEditor
component includes various CSS classes to style the editor and its content, including syntax highlighting for different programming languages.Integration with Existing Components:
ChatInput.tsx
file is modified to use the newRichTextEditor
component instead of the oldCodeEditor
.RichEditor
component is configured with options such asclassName
,style
,placeholder
, andspellCheck
.Code Refactoring:
TextArea
component is commented out in favor of the newRichEditor
.These changes significantly enhance the text editing capabilities of the application, allowing for more complex and formatted text input, including support for code blocks with syntax highlighting.
Fixes Issues
Note: The reason we only support syntax highlighting and text formatting (bold and italic) in the chat input is to avoid making the input box interface cluttered or unattractive. For example, rendering blockquotes inside the chat input would lead to a messy and visually unappealing interface.
Self Checklist