-
Notifications
You must be signed in to change notification settings - Fork 2.8k
rich text editor : errors fixed #3127
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
Conversation
|
@dipto-metaforktech is attempting to deploy a commit to the Dub Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR deletes Vercel cron configuration, updates type handling in the rich-text editor's extension system with a type assertion, and modifies toolbar action handlers to focus the editor while commenting out formatting commands (bold, italic, heading, link modifications). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/ui/src/rich-text-area/rich-text-toolbar.tsx (1)
153-169: Critical: Link insertion and removal is completely disabled.Both
setLink()andunsetLink()commands are commented out. Users cannot add or remove links from selected text. The link button is rendered and can be clicked, but the prompt appears without any effect on the editor.Restore the functionality:
const url = window.prompt("Link URL", previousUrl); if (!url?.trim()) { - editor.commands.focus(); - editor.commands.extendMarkRange("link"); - // editor.commands.unsetLink(); + editor.chain().focus().extendMarkRange("link").unsetLink().run(); return; } - editor.commands.focus(); - editor.commands.extendMarkRange("link"); - // editor.commands.setLink({ href: url }); + editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();packages/ui/src/rich-text-area/rich-text-provider.tsx (1)
125-200: I need to inspect the actual file to verify the review comment's accuracy and the recommended fix.I need to examine the actual file to verify the review comment's accuracy and the recommended fix.
Based on my verification using web searches and documentation, I can now provide a definitive assessment of the review comment.
Critical:
as anysuppresses type safety instead of fixing the underlying issue.The use of
as anytype assertion for TipTap extensions is acknowledged as "not a great solution" but is used as a workaround. The extensions array with conditional spreading creates type inference challenges that TipTap reports as type assignment errors.The recommended solution aligns with TipTap best practices. The issue stems from the
extensionsproperty expected byuseEditorbeing a straightforward array of extensions, not a complex conditional array. Removing theas anyassertion and properly typing the array is the correct approach.Recommended solution:
Remove the
as anyassertion and the wrapping parentheses. The extensions array should be:- extensions: ([ + extensions: [ ...(markdown ? [Markdown] : []), StarterKit.configure({ heading: features.includes("headings") ? { levels: [1, 2], } : false, bold: features.includes("bold") ? undefined : false, italic: features.includes("italic") ? undefined : false, link: features.includes("links") ? undefined : false, }), Placeholder.configure({ placeholder, emptyEditorClass: "before:content-[attr(data-placeholder)] before:float-left before:text-content-muted before:h-0 before:pointer-events-none", }), // Images ...(features.includes("images") && handleImageUpload ? [ Image.configure({ inline: false, HTMLAttributes: { class: "rounded-lg max-w-full h-auto", }, }), FileHandler.configure({ allowedMimeTypes: [ "image/png", "image/jpeg", "image/gif", "image/webp", ], onDrop: (currentEditor, files, pos) => { files.forEach((file) => handleImageUpload(file, currentEditor, pos), ); }, onPaste: (currentEditor, files, htmlContent) => { if (htmlContent) return false; files.forEach((file) => handleImageUpload( file, currentEditor, currentEditor.state.selection.anchor, ), ); }, }), ] : []), ...(features.includes("variables") && variables ? [ Mention.extend({ renderHTML({ node }: { node: any }) { return [ "span", { class: "px-1 py-0.5 bg-blue-100 text-blue-700 rounded font-semibold", "data-type": "mention", "data-id": node.attrs.id, }, `{{${node.attrs.id}}}`, ]; }, renderText({ node }: { node: any }) { return `{{${node.attrs.id}}}`; }, }).configure({ suggestion: suggestions(variables), }), ] : []), - ] as any), + ],If TypeScript errors persist after this change, the actual type mismatch needs investigation. Check that TipTap package versions are compatible and consider adding an explicit type annotation if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/web/vercel.json(0 hunks)packages/ui/src/rich-text-area/rich-text-provider.tsx(2 hunks)packages/ui/src/rich-text-area/rich-text-toolbar.tsx(3 hunks)
💤 Files with no reviewable changes (1)
- apps/web/vercel.json
| onClick={() => { | ||
| editor?.commands.focus(); | ||
| // editor?.commands.toggleBold(); | ||
| }} | ||
| /> | ||
| )} | ||
| {features?.includes("italic") && ( | ||
| <RichTextToolbarButton | ||
| icon={TextItalic} | ||
| label="Italic" | ||
| isActive={editorState?.isItalic} | ||
| onClick={() => editor?.chain().focus().toggleItalic().run()} | ||
| onClick={() => { | ||
| editor?.commands.focus(); | ||
| // editor?.commands.toggleItalic(); | ||
| }} |
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.
🧩 Analysis chain
Critical: Bold and Italic formatting is completely disabled.
The toggleBold() and toggleItalic() commands are commented out. Users can click these buttons, but no formatting will be applied. The buttons only focus the editor without performing any text formatting.
This breaks core rich text editor functionality and should not be merged.
Root cause analysis needed:
If these commands were commented out due to errors, the underlying issue must be diagnosed and fixed properly:
- Verify the StarterKit configuration in
rich-text-provider.tsxcorrectly enables bold/italic - Check if the commands exist on the editor instance
- Ensure TipTap extensions are properly initialized
Restore the functionality:
{features?.includes("bold") && (
<RichTextToolbarButton
icon={TextBold}
label="Bold"
isActive={editorState?.isBold}
onClick={() => {
- editor?.commands.focus();
- // editor?.commands.toggleBold();
+ editor?.chain().focus().toggleBold().run();
}}
/>
)}
{features?.includes("italic") && (
<RichTextToolbarButton
icon={TextItalic}
label="Italic"
isActive={editorState?.isItalic}
onClick={() => {
- editor?.commands.focus();
- // editor?.commands.toggleItalic();
+ editor?.chain().focus().toggleItalic().run();
}}
/>
)}Please share the error messages that led to commenting out these commands so the actual issue can be addressed.
🏁 Script executed:
#!/bin/bash
# Locate and inspect the rich-text-toolbar.tsx file
fd -t f "rich-text-toolbar.tsx" --exec cat {} \;Length of output: 5512
🏁 Script executed:
#!/bin/bash
# Locate and inspect the rich-text-provider.tsx file for configuration
fd -t f "rich-text-provider.tsx" --exec cat {} \;Length of output: 7058
🏁 Script executed:
#!/bin/bash
# Search for any error messages or context around disabled commands
rg -n "toggleBold|toggleItalic|toggleHeading|setLink|unsetLink" -B2 -A2 --type=tsx --type=tsLength of output: 27
🏁 Script executed:
#!/bin/bash
# Check for TipTap configuration and extension imports
rg -n "StarterKit|extensions|@tiptap" -C2 --type=tsx --type=tsLength of output: 27
Critical: Formatting commands are disabled across all toolbar buttons.
The toggleBold(), toggleItalic(), toggleHeading(), unsetLink(), and setLink() commands are commented out throughout the file. The editor will focus but apply no formatting—buttons will appear functional with active/inactive states while users see no text changes.
The StarterKit configuration in rich-text-provider.tsx is correct, so the issue is purely in the disabled command calls:
- Bold (line 57)
- Italic (line 67)
- Heading 1 (line 77)
- Heading 2 (line 85)
- Link unset (line 136)
- Link set (line 141)
Restore all formatting commands using the standard TipTap command chain pattern:
- editor?.commands.focus();
- // editor?.commands.toggleBold();
+ editor?.chain().focus().toggleBold().run();Apply the same pattern to all disabled commands (toggleItalic, toggleHeading, setLink, unsetLink).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onClick={() => { | |
| editor?.commands.focus(); | |
| // editor?.commands.toggleBold(); | |
| }} | |
| /> | |
| )} | |
| {features?.includes("italic") && ( | |
| <RichTextToolbarButton | |
| icon={TextItalic} | |
| label="Italic" | |
| isActive={editorState?.isItalic} | |
| onClick={() => editor?.chain().focus().toggleItalic().run()} | |
| onClick={() => { | |
| editor?.commands.focus(); | |
| // editor?.commands.toggleItalic(); | |
| }} | |
| onClick={() => { | |
| editor?.chain().focus().toggleBold().run(); | |
| }} | |
| /> | |
| )} | |
| {features?.includes("italic") && ( | |
| <RichTextToolbarButton | |
| icon={TextItalic} | |
| label="Italic" | |
| isActive={editorState?.isItalic} | |
| onClick={() => { | |
| editor?.commands.focus(); | |
| // editor?.commands.toggleItalic(); | |
| }} |
🤖 Prompt for AI Agents
In packages/ui/src/rich-text-area/rich-text-toolbar.tsx around lines 56–70 (and
the other specified lines: bold 57, italic 67, heading1 77, heading2 85, unset
link 136, set link 141), the formatting commands are commented out so buttons
only focus the editor; restore the TipTap command chain calls. Replace the
commented calls with the standard pattern using editor?.chain().focus()...
.run(): e.g. use editor?.chain().focus().toggleBold().run(),
editor?.chain().focus().toggleItalic().run(),
editor?.chain().focus().toggleHeading({ level: 1 }).run(),
editor?.chain().focus().toggleHeading({ level: 2 }).run(),
editor?.chain().focus().unsetLink().run(), and for setting links use
editor?.chain().focus().extendMarkRange().setLink({ href: url }).run() (getting
url from the existing input/prompt logic).
| onClick={() => { | ||
| editor?.commands.focus(); | ||
| // editor?.commands.toggleHeading({ level: 1 }); | ||
| }} | ||
| /> | ||
| <RichTextToolbarButton | ||
| icon={Heading2} | ||
| label="Heading 2" | ||
| isActive={editorState?.isHeading2} | ||
| onClick={() => | ||
| editor?.chain().focus().toggleHeading({ level: 2 }).run() | ||
| } | ||
| onClick={() => { | ||
| editor?.commands.focus(); | ||
| // editor?.commands.toggleHeading({ level: 2 }); | ||
| }} |
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.
Critical: Heading formatting is completely disabled.
The toggleHeading() commands for both heading levels are commented out. Users cannot create headings, making the heading buttons non-functional.
Restore the functionality:
<RichTextToolbarButton
icon={Heading1}
label="Heading 1"
isActive={editorState?.isHeading1}
onClick={() => {
- editor?.commands.focus();
- // editor?.commands.toggleHeading({ level: 1 });
+ editor?.chain().focus().toggleHeading({ level: 1 }).run();
}}
/>
<RichTextToolbarButton
icon={Heading2}
label="Heading 2"
isActive={editorState?.isHeading2}
onClick={() => {
- editor?.commands.focus();
- // editor?.commands.toggleHeading({ level: 2 });
+ editor?.chain().focus().toggleHeading({ level: 2 }).run();
}}
/>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onClick={() => { | |
| editor?.commands.focus(); | |
| // editor?.commands.toggleHeading({ level: 1 }); | |
| }} | |
| /> | |
| <RichTextToolbarButton | |
| icon={Heading2} | |
| label="Heading 2" | |
| isActive={editorState?.isHeading2} | |
| onClick={() => | |
| editor?.chain().focus().toggleHeading({ level: 2 }).run() | |
| } | |
| onClick={() => { | |
| editor?.commands.focus(); | |
| // editor?.commands.toggleHeading({ level: 2 }); | |
| }} | |
| <RichTextToolbarButton | |
| icon={Heading1} | |
| label="Heading 1" | |
| isActive={editorState?.isHeading1} | |
| onClick={() => { | |
| editor?.chain().focus().toggleHeading({ level: 1 }).run(); | |
| }} | |
| /> | |
| <RichTextToolbarButton | |
| icon={Heading2} | |
| label="Heading 2" | |
| isActive={editorState?.isHeading2} | |
| onClick={() => { | |
| editor?.chain().focus().toggleHeading({ level: 2 }).run(); | |
| }} | |
| /> |
🤖 Prompt for AI Agents
packages/ui/src/rich-text-area/rich-text-toolbar.tsx around lines 79 to 91: the
heading buttons have their toggleHeading calls commented out so they do nothing;
restore functionality by uncommenting and invoking
editor?.commands.toggleHeading({ level: 1 }) for the Heading 1 button and
editor?.commands.toggleHeading({ level: 2 }) for the Heading 2 button, keeping
the existing editor?.commands.focus() calls and null-safe checks to avoid
runtime errors if editor is undefined.
|
It was a mistake wanted to changed in my forked of dub repo. Instead clicked here in the main repo |
|
|
Summary by CodeRabbit
Chores
Refactor