Skip to content
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: Add auto-apply markdown features on editor: Enable WYSIWYG #1068

Merged

Conversation

NawinKumarSharma
Copy link
Contributor

Fixes #(issue)

This pr fixes #1039

Pull Request details

When a user types markdown syntax, the editor should automatically recognize and implement the respective feature.
the editor should instantly recognize markdown syntax and apply the relevant features without user intervention.
markdown feature:

Markdown shortcuts make it easy to format the text while typing.

To test that, start a new line and type # followed by a space to get a heading. 
Try #, ##, ###, ####, #####, ###### for different levels.

Those conventions are called input rules in Tiptap. Some of them are enabled by default. 
Try > for blockquotes, *, - or + for bullet lists, or `foobar` to highlight code, ~~tildes~~ to strike text, 
or ==equal signs== to highlight text.

You can overwrite existing input rules or add your own to nodes, marks and extensions.

For example, we added the Typography extension here. Try typing (c) to see how it’s converted to a proper © character. You can also try ->, >>, 1/2, !=, or --.

Any Breaking changes

None

Associated Screenshots

Screencast.from.2024-10-06.02-48-24.webm

@NawinKumarSharma NawinKumarSharma requested a review from a team as a code owner October 5, 2024 21:43
Copy link

vercel bot commented Oct 5, 2024

@NawinKumarSharma is attempting to deploy a commit to the Codú Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 5, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces several modifications across multiple components to enhance visual presentation and styling, particularly focusing on dark mode support. Key changes include updates to class names for various elements, ensuring appropriate text and background colors in different modes. Additionally, the Editor component is enhanced by integrating new features from the TipTap library, improving its functionality. The overall structure and logic of the components remain intact, with a primary focus on cosmetic and stylistic improvements.

Changes

File Path Change Summary
app/(app)/[username]/_usernameClient.tsx Updated className of two div elements for improved styling in light and dark modes.
app/(app)/articles/_client.tsx Added dark:bg-neutral-800 class to <select> element for enhanced dark mode styling.
app/(app)/create/[[...paramsArr]]/_client.tsx Changed text color from white to black in the preview section for better readability.
components/Tabs/index.tsx Modified className of <select> element to include bg-white and dark:bg-neutral-900 for light and dark modes.
components/editor/editor/index.tsx Added imports for new TipTap extensions and updated useEditor hook to enhance editor functionality.

Assessment against linked issues

Objective Addressed Explanation
Enable WYSIWYG features in the editor (#1039)

Possibly related issues

  • Meta issue : Editor #1022: The changes in the Editor component align with the goal of implementing a WYSIWYG editor, as it integrates new features that enhance editing capabilities.

Possibly related PRs

Suggested labels

hacktoberfest-accepted, hacktoberfest

Poem

🐇 In the land of code, where colors play,
A rabbit hops, brightening the day.
With dark mode magic and styles so fine,
The editor's glow, oh how it will shine!
From white to black, the text now sings,
A joyful dance, as the new feature springs!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
components/Tabs/index.tsx (1)

32-32: LGTM! Consider extracting the className to a constant.

The addition of bg-white for light mode and dark:bg-neutral-900 for dark mode improves the visual consistency of the select element across different color schemes. This change enhances the user experience without affecting the component's functionality.

To improve readability and maintainability, consider extracting the long className string into a constant:

const SELECT_CLASS_NAME = "block w-full rounded-md border-neutral-300 bg-white focus:border-neutral-500 focus:ring-neutral-500 dark:bg-neutral-900";

// Then use it in the JSX
<select
  id="tabs"
  name="tabs"
  className={SELECT_CLASS_NAME}
  // ... other props
>

This refactoring would make the JSX cleaner and easier to maintain in the future.

app/(app)/[username]/_usernameClient.tsx (2)

127-127: LGTM: Improved dark mode styling for Tabs

The addition of the dark:bg-neutral-900 class enhances the visibility of the Tabs component in dark mode by setting an appropriate background color. This change contributes to a better WYSIWYG experience and improves the overall consistency of the UI in different color schemes.

For consistency, consider adding a light mode background color as well. For example:

-<div className="mx-auto mt-4 dark:bg-neutral-900 sm:max-w-2xl lg:max-w-5xl">
+<div className="mx-auto mt-4 bg-white dark:bg-neutral-900 sm:max-w-2xl lg:max-w-5xl">

This ensures that the Tabs component has a consistent background in both light and dark modes.


Line range hint 1-238: Overall: Improved WYSIWYG experience with minimal changes

The changes made to this component successfully enhance the WYSIWYG experience by improving text and UI element visibility in different color modes. The modifications are minimal and non-breaking, focusing on visual improvements while maintaining the overall structure and functionality of the component.

To further improve the consistency of color scheme handling throughout the component, consider reviewing and updating other elements that might benefit from explicit color classes for both light and dark modes. This could include:

  1. Text colors for headings, links, and other text elements.
  2. Background colors for different sections or cards within the profile.
  3. Border colors for separators or input fields.

Example:

-<h2 className="text-sm font-bold text-neutral-500 dark:text-neutral-400">
+<h2 className="text-sm font-bold text-neutral-500 dark:text-neutral-400 bg-white dark:bg-neutral-800">

This systematic approach would ensure a consistent and visually appealing experience across the entire component in both light and dark modes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7cc3d4f and 302e1e9.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
📒 Files selected for processing (5)
  • app/(app)/[username]/_usernameClient.tsx (2 hunks)
  • app/(app)/articles/_client.tsx (1 hunks)
  • app/(app)/create/[[...paramsArr]]/_client.tsx (1 hunks)
  • components/Tabs/index.tsx (1 hunks)
  • components/editor/editor/index.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • app/(app)/articles/_client.tsx
  • app/(app)/create/[[...paramsArr]]/_client.tsx
🔇 Additional comments (6)
components/editor/editor/index.tsx (4)

3-6: LGTM: New imports align with PR objectives

The addition of Highlight, Typography, and StarterKit from the Tiptap library aligns well with the PR objectives to implement WYSIWYG features. These extensions will enable automatic recognition and application of markdown syntax as users type, enhancing the editor's functionality.


20-23: LGTM: New extensions enhance WYSIWYG functionality

The addition of StarterKit, Highlight, and Typography extensions from Tiptap is a good step towards implementing the desired WYSIWYG functionality. These extensions will likely provide a robust foundation for markdown syntax recognition and formatting.


20-23: Clarify the removal of previous extensions

The removal of TiptapExtensions and CustomCodeBlockEdit might impact existing functionality. Could you please clarify:

  1. What functionality was provided by these extensions?
  2. How is this functionality being replaced or maintained with the new set of extensions?
  3. Are there any potential breaking changes resulting from this removal?

Line range hint 1-53: Summary of changes and next steps

The changes to the Editor component focus on updating the Tiptap extensions to enhance WYSIWYG functionality. While these changes align with the PR objectives, there are a few points that require clarification:

  1. The impact of removing TiptapExtensions and CustomCodeBlockEdit.
  2. Confirmation that all required markdown features are implemented.

Once these points are addressed, the changes look promising for improving the editor's functionality as described in the PR objectives. The unchanged parts of the component appear to be compatible with the new extensions.

Next steps:

  1. Address the clarification requests in the previous comments.
  2. Verify the implementation of all required markdown features.
  3. Consider adding tests to ensure the new functionality works as expected.
components/Tabs/index.tsx (1)

Line range hint 1-68: Clarify the relevance of this change to the PR objectives.

The change in this file improves the visual consistency of the Tabs component in light and dark modes. However, it doesn't seem to be directly related to the main objectives of the PR, which are focused on adding auto-apply markdown features and enabling WYSIWYG editing.

Could you please clarify how this change in the Tabs component contributes to the PR objectives? If it's an unrelated improvement, consider separating it into a different PR to maintain focus on the main feature implementation.

To verify the usage of this component in relation to the editor, you can run the following script:

This will help us understand if and how the Tabs component is used in the context of the editor implementation.

app/(app)/[username]/_usernameClient.tsx (1)

91-91: LGTM: Improved text visibility in light mode

The addition of the text-black class ensures that the text color is explicitly set to black in light mode, complementing the existing dark:text-white class for dark mode. This change enhances the visibility and consistency of the text across different color schemes, contributing to a better WYSIWYG experience.

components/editor/editor/index.tsx Show resolved Hide resolved
@JohnAllenTech
Copy link
Contributor

Thats pretty cool! Alot of functionality for a very small change!

Copy link
Contributor

@NiallJoeMaher NiallJoeMaher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🌮 🦖

Copy link

vercel bot commented Oct 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
codu ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 6, 2024 7:18am

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.

Auto-apply markdown features: Enable WYSIWYG
3 participants