Skip to content

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Dec 3, 2024

Improvements:

This PR adds custom classes to editor's heading and paragraph blocks to distinguish between the editor specific blocks and external blocks.

This ensures all styles only get applied to the paragraph and heading tags inside the editor and don't affect the other blocks.

Summary by CodeRabbit

  • New Features

    • Introduced new configurations for paragraph and heading extensions, enhancing styling capabilities.
    • Added specific CSS classes for paragraphs and headings to improve visual hierarchy.
  • Bug Fixes

    • Adjusted margins and padding for headings and paragraphs for consistent spacing.
  • Style

    • Enhanced specificity of CSS styles for editor components, particularly for headings and paragraphs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The changes in this pull request enhance the editor's extension configurations by adding specific HTML attributes for the paragraph and heading extensions, allowing for improved styling. The CoreEditorExtensionsWithoutProps and DocumentEditorExtensionsWithoutProps arrays have been updated to include these new configurations. Additionally, modifications to the CSS styles for headings and paragraphs ensure that the new classes are targeted correctly, improving the overall layout and visual hierarchy of the editor.

Changes

File Path Change Summary
packages/editor/src/core/extensions/core-without-props.ts Added configurations for paragraph and heading extensions with specific classes. Updated DocumentEditorExtensionsWithoutProps to include IssueWidgetWithoutProps().
packages/editor/src/core/extensions/extensions.tsx Updated CoreEditorExtensions to include new configurations for paragraph and heading extensions with specific classes.
packages/editor/src/core/extensions/read-only-extensions.tsx Modified CoreReadOnlyEditorExtensions to add new configurations for paragraph and heading extensions with specific classes.
packages/editor/src/styles/editor.css Modified CSS to enhance styles for .editor-heading-block and .editor-paragraph-block, adjusting margins and refining task list styles.

Possibly related PRs

Suggested labels

✍️editor, 🌟improvement

Suggested reviewers

  • SatishGandham

🐰 In the editor's land, where styles do play,
New classes hop in, brightening the way.
Paragraphs and headings, dressed up so fine,
With blocks of style, they truly do shine!
So let’s celebrate, with a joyful cheer,
For a fancier editor, we hold so dear! ✨


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: 0

🧹 Outside diff range and nitpick comments (3)
packages/editor/src/core/extensions/extensions.tsx (1)

76-85: LGTM! Consider reducing configuration duplication.

The custom classes are correctly implemented in the main editor configuration. However, these configurations are duplicated across three files.

Consider extracting these common configurations into a shared constant or helper function to maintain DRY principles:

// shared-config.ts
export const EDITOR_BLOCK_CONFIGS = {
  paragraph: {
    HTMLAttributes: {
      class: "editor-paragraph-block",
    },
  },
  heading: {
    HTMLAttributes: {
      class: "editor-heading-block",
    },
  },
};

// Usage in each file:
StarterKit.configure({
  ...otherConfigs,
  ...EDITOR_BLOCK_CONFIGS,
});
packages/editor/src/styles/editor.css (2)

325-331: Consider using attribute selector for better maintainability

While the current implementation works well, consider using an attribute selector for better maintainability.

-h1.editor-heading-block,
-h2.editor-heading-block,
-h3.editor-heading-block,
-h4.editor-heading-block,
-h5.editor-heading-block,
-h6.editor-heading-block,
-p.editor-paragraph-block {
+[class*="editor-heading-block"],
+.editor-paragraph-block {
  margin: 0 !important;
}

Line range hint 402-423: Consider alternative to !important for paragraph spacing

While the paragraph styling is well-implemented, the use of !important for consecutive paragraph spacing might make future maintenance challenging.

Consider increasing selector specificity instead:

-p.editor-paragraph-block + p.editor-paragraph-block {
+.prose p.editor-paragraph-block + p.editor-paragraph-block {
-  padding-top: 8px !important;
+  padding-top: 8px;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b6ab853 and b0c8989.

📒 Files selected for processing (4)
  • packages/editor/src/core/extensions/core-without-props.ts (1 hunks)
  • packages/editor/src/core/extensions/extensions.tsx (1 hunks)
  • packages/editor/src/core/extensions/read-only-extensions.tsx (1 hunks)
  • packages/editor/src/styles/editor.css (11 hunks)
🔇 Additional comments (6)
packages/editor/src/core/extensions/core-without-props.ts (1)

46-55: LGTM! Custom classes added for better styling control.

The addition of custom classes for paragraph and heading blocks is well-implemented and follows a consistent naming pattern.

Let's verify the CSS definitions for these new classes:

✅ Verification successful

CSS definitions are properly implemented for the custom classes

The CSS rules for both .editor-paragraph-block and .editor-heading-block are well-defined in packages/editor/src/styles/editor.css with comprehensive styling including:

  • Proper margin and padding rules
  • Heading-specific styles for h1-h6
  • Special handling for paragraphs within lists
  • Proper spacing between consecutive paragraphs
  • Integration with the prose styling system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for CSS definitions of the new editor block classes
# Expected: CSS rules for .editor-paragraph-block and .editor-heading-block

rg -l "editor-paragraph-block|editor-heading-block" --type css

Length of output: 102


Script:

#!/bin/bash
# Let's check the actual CSS definitions for these classes
rg "editor-(paragraph|heading)-block" packages/editor/src/styles/editor.css -A 3

Length of output: 2003

packages/editor/src/core/extensions/read-only-extensions.tsx (1)

68-77: LGTM! Consistent implementation in read-only mode.

The custom classes are correctly implemented in the read-only editor configuration, maintaining consistency with the core editor.

packages/editor/src/styles/editor.css (4)

136-136: LGTM: Task list styling changes properly scoped

The addition of .editor-paragraph-block class to task list paragraph selectors maintains existing functionality while properly scoping styles to editor-specific paragraphs.

Also applies to: 183-183, 194-194


Line range hint 336-400: LGTM: Consistent and well-structured heading styles

The heading styles are well-implemented with:

  • Consistent spacing patterns across all levels
  • Proper use of CSS variables for font sizes and line heights
  • Correct scoping using the new editor-specific classes

427-428: LGTM: List typography properly scoped

The list typography changes correctly scope the styles to editor paragraphs while maintaining the existing font sizing system.


Line range hint 325-428: Verify style isolation

Let's verify that these editor-specific styles don't affect regular paragraphs and headings outside the editor.

✅ Verification successful

Based on the search results, I can now generate the final response:

The editor-specific styles are properly isolated and won't affect regular paragraphs and headings

The styles are well-scoped through specific class combinations (.editor-heading-block and .editor-paragraph-block) and are further isolated within the .prose context. The search results show:

  • No other CSS files define conflicting .prose styles
  • No competing heading or paragraph styles outside the editor
  • The only related files are variables.css which defines the CSS variables used by the editor styles
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other CSS files that might style paragraphs or headings
# to ensure no conflicts with our new editor-specific classes

echo "Checking for other paragraph/heading styles that might conflict..."
rg -t css "(?:h[1-6]|p)\s*{" --glob '!packages/editor/src/styles/editor.css'

echo "Checking for other uses of our new editor classes..."
rg -t css "editor-(paragraph|heading)-block"

Length of output: 2501


Script:

#!/bin/bash
# Let's fix the regex and try again to find potential conflicting styles
echo "Checking for other paragraph/heading styles that might conflict..."
rg -t css "[hp][1-6]?\s*{|\.prose\s" --glob '!packages/editor/src/styles/editor.css'

# Also check for any other CSS files that might use the .prose class
echo -e "\nChecking for other .prose class usage..."
fd -e css -x grep -l "\.prose" {} \; | grep -v "editor.css"

Length of output: 510


Script:

#!/bin/bash
# Let's try a simpler approach to find potential style conflicts
echo "Checking for other heading styles..."
rg -t css "h[1-6]" --glob '!packages/editor/src/styles/editor.css'

echo -e "\nChecking for other paragraph styles..."
rg -t css "p\s*{|p\." --glob '!packages/editor/src/styles/editor.css'

echo -e "\nChecking for other .prose styles..."
rg -t css "\.prose" --glob '!packages/editor/src/styles/editor.css'

Length of output: 3247

@sriramveeraghanta sriramveeraghanta modified the milestones: v0.24.0, v0.24.1 Dec 3, 2024
@pushya22 pushya22 merged commit 64a44f4 into preview Dec 4, 2024
12 of 14 checks passed
@pushya22 pushya22 deleted the style/editor-blocks branch December 4, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants