Skip to content

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jan 28, 2025

Description

This PR includes-

  1. A new floating toolbar like the issue description's for Pages.
  2. Toggle Sticky toolbar option for Pages.

Type of Change

  • Feature (non-breaking change which adds functionality)

Screenshots and Media (if applicable)

Screen.Recording.2025-01-28.at.13.53.07.mov

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a configurable sticky toolbar option for pages.
    • Introduced bubble menu toggle for document editors.
  • Improvements

    • Enhanced page personalization configuration to include sticky toolbar settings.
    • Updated editor rendering logic to support new bubble menu functionality.
  • Changes

    • Modified page actions and dropdown menus to include sticky toolbar functionality.
    • Updated type definitions to support new configuration options related to the bubble menu and sticky toolbar.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Walkthrough

This pull request introduces a new bubbleMenuEnabled prop across multiple components in the editor system. The changes primarily focus on adding conditional rendering for the bubble menu in document editors, with modifications spanning from the collaborative editor to page renderers and configuration hooks. The implementation allows for more flexible control over the visibility of the editor's bubble menu, defaulting to enabled but providing the option to disable it in specific contexts like read-only editors.

Changes

File Change Summary
packages/editor/src/core/types/editor.ts Updated ICollaborativeDocumentEditor interface to include bubbleMenuEnabled and explicitly define editable
packages/editor/src/core/components/editors/document/collaborative-editor.tsx Added bubbleMenuEnabled prop defaulting to true
packages/editor/src/core/components/editors/document/page-renderer.tsx Updated IPageRenderer type, added conditional rendering for EditorBubbleMenu
packages/editor/src/core/components/editors/document/read-only-editor.tsx Set bubbleMenuEnabled to false for read-only editors
web/core/components/pages/dropdowns/actions.tsx Added "sticky-toolbar" to TPageActions type
web/core/hooks/use-page-filters.ts Added sticky_toolbar to personalization config and related handling logic
web/core/components/pages/editor/header/options-dropdown.tsx Enhanced PageOptionsDropdown to manage sticky toolbar state and functionality
web/core/components/pages/editor/header/root.tsx Updated rendering logic for PageToolbar based on isStickyToolbarEnabled

Sequence Diagram

sequenceDiagram
    participant Editor as CollaborativeDocumentEditor
    participant Renderer as PageRenderer
    participant Menu as EditorBubbleMenu

    Editor->>Renderer: Pass bubbleMenuEnabled prop
    alt bubbleMenuEnabled is true
        Renderer->>Menu: Render EditorBubbleMenu
    else bubbleMenuEnabled is false
        Renderer-->>Menu: Skip rendering
    end
Loading

Possibly related PRs

Suggested labels

🧹chore

Suggested reviewers

  • SatishGandham
  • rahulramesha

Poem

🐰 A rabbit's tale of menus bright,
Bubbles dancing left and right,
With a prop so neat and clean,
Toggle on, or toggle unseen,
Editor's magic takes its flight! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25ac832 and 180e95d.

📒 Files selected for processing (2)
  • packages/editor/src/core/components/editors/document/page-renderer.tsx (3 hunks)
  • web/core/components/pages/editor/header/options-dropdown.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/core/components/pages/editor/header/options-dropdown.tsx
  • packages/editor/src/core/components/editors/document/page-renderer.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (3)
web/core/hooks/use-page-filters.ts (1)

93-104: Fix JSDoc description for handleStickyToolbar.

The JSDoc comment incorrectly states it updates full_width value instead of sticky_toolbar.

-   * @description action to update full_width value
+   * @description action to update sticky_toolbar value
packages/editor/src/core/components/editors/document/collaborative-editor.tsx (1)

79-83: Consider maintaining consistent prop ordering.

For better readability and maintainability, consider grouping related props together. The bubbleMenuEnabled prop could be grouped with other display-related props like displayConfig.

  <PageRenderer
      aiHandler={aiHandler}
-      bubbleMenuEnabled={bubbleMenuEnabled}
-      displayConfig={displayConfig}
+      displayConfig={displayConfig}
+      bubbleMenuEnabled={bubbleMenuEnabled}
      editor={editor}
      editorContainerClassName={editorContainerClassNames}
packages/editor/src/core/components/editors/document/page-renderer.tsx (1)

144-150: Consider optimizing the menu wrapper structure.

The additional div wrapper around BlockMenu and AIFeaturesMenu might be unnecessary. Consider simplifying the structure:

  {editor.isEditable && (
    <>
      {bubbleMenuEnabled && <EditorBubbleMenu editor={editor} />}
-     <div>
        <BlockMenu editor={editor} />
        <AIFeaturesMenu menu={aiHandler?.menu} />
-     </div>
    </>
  )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f22cd1 and 25ac832.

📒 Files selected for processing (8)
  • packages/editor/src/core/components/editors/document/collaborative-editor.tsx (2 hunks)
  • packages/editor/src/core/components/editors/document/page-renderer.tsx (3 hunks)
  • packages/editor/src/core/components/editors/document/read-only-editor.tsx (1 hunks)
  • packages/editor/src/core/types/editor.ts (1 hunks)
  • web/core/components/pages/dropdowns/actions.tsx (1 hunks)
  • web/core/components/pages/editor/header/options-dropdown.tsx (4 hunks)
  • web/core/components/pages/editor/header/root.tsx (2 hunks)
  • web/core/hooks/use-page-filters.ts (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (8)
web/core/hooks/use-page-filters.ts (1)

32-38: LGTM! Well-implemented memoization.

The memoization is correctly implemented with proper dependency tracking and fallback handling.

web/core/components/pages/editor/header/root.tsx (1)

51-53: LGTM! Robust conditional rendering.

The PageToolbar rendering logic includes all necessary checks in the correct order, ensuring a stable and predictable behavior.

packages/editor/src/core/components/editors/document/read-only-editor.tsx (1)

72-72: LGTM! Appropriate bubble menu handling for read-only mode.

Correctly disables the bubble menu in read-only context, maintaining consistent behavior.

web/core/components/pages/editor/header/options-dropdown.tsx (3)

52-62: LGTM! Well-structured menu option implementation.

The sticky toolbar menu option follows the established pattern and properly integrates with the ToggleSwitch component.


116-116: LGTM! Logical placement in options order.

The sticky-toolbar option is appropriately placed alongside other view-related options.


35-35: Verify the implementation of usePageFilters hook.

The hook returns new properties for sticky toolbar management. Let's verify their implementation.

✅ Verification successful

Sticky toolbar functionality is properly implemented in usePageFilters hook

The hook correctly implements sticky toolbar state management with proper memoization and localStorage persistence.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the usePageFilters hook implementation
ast-grep --pattern 'export const usePageFilters = () => {
  $$$
  return {
    $$$
    isStickyToolbarEnabled,
    handleStickyToolbar,
    $$$
  }
}'

Length of output: 6296

packages/editor/src/core/types/editor.ts (1)

142-143: LGTM! Good type safety improvements.

The changes improve type safety by:

  • Making editable explicit
  • Adding bubbleMenuEnabled as an optional property for backward compatibility
web/core/components/pages/dropdowns/actions.tsx (1)

39-39: LGTM! Non-breaking type extension.

The addition of "sticky-toolbar" to TPageActions is properly implemented as a non-breaking change.


type IPageRenderer = {
aiHandler?: TAIHandler;
bubbleMenuEnabled: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider making bubbleMenuEnabled optional.

Making bubbleMenuEnabled a required property could break existing implementations. Consider making it optional with a default value to ensure backward compatibility.

-  bubbleMenuEnabled: boolean;
+  bubbleMenuEnabled?: boolean;
📝 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.

Suggested change
bubbleMenuEnabled: boolean;
bubbleMenuEnabled?: boolean;

@sriramveeraghanta sriramveeraghanta merged commit b698f44 into preview Jan 28, 2025
10 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat/pages-toolbar branch January 28, 2025 14:51
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.

4 participants