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

fix: toolbar style update and ts error #51

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Conversation

zzxming
Copy link
Collaborator

@zzxming zzxming commented Sep 8, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

  1. When the toolbar passes a non nested array. toolbar class .ql-active can not update style correctly.
const quill = new FluentEditor('#editor', {
  modules: {
    toolbar: ['bold', 'italic', { size: [ '12px', false, '20px' ]}]
  }
});
  1. fix toolbar type error

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced visual feedback for toolbar buttons with updated hover and active states.
    • Added a new property for line heights in the toolbar item configuration.
  • Bug Fixes

    • Improved type handling for toolbar functionalities, ensuring better type safety and clarity.
  • Refactor

    • Streamlined CSS formatting for better readability and maintainability across multiple stylesheets.
    • Simplified toolbar item type definitions to allow for greater flexibility in input structures.

Copy link

coderabbitai bot commented Sep 8, 2024

Walkthrough

The changes involve updates to several SCSS files, enhancing the formatting and structure of CSS rules without altering their functionality. Additionally, modifications were made to TypeScript interfaces and types to improve type definitions and flexibility. Import statements were adjusted for clarity, and the handling of toolbar functionalities was refined to enhance type safety and code clarity.

Changes

Files Change Summary
.../font.scss, .../lineHeight.scss, .../size.scss, .../toolbar.scss CSS formatting improvements, including removal of unnecessary indentation and restructuring for better readability. Styles remain intact.
.../toolbar-item.interface.ts, .../type.ts Modified IToolbarItem interface to refine the header property type and added a new lineheight property. Updated ToolbarOption type to allow for individual strings and items.
.../lineheight.ts, .../index.ts Adjusted import statements for Parchment and refined type handling in the BetterToolbar class, enhancing type safety and clarity in method signatures and parameter types.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Toolbar
    participant Quill
    participant Parchment

    User->>Toolbar: Interacts with toolbar
    Toolbar->>Quill: Calls Quill.import('parchment')
    Quill->>Parchment: Returns Parchment module
    Toolbar->>User: Updates UI based on interaction
Loading

🐰 "In the garden of code, changes bloom bright,
With styles refined, and types set right.
A hop and a skip, the toolbar's in play,
Enhancing our tools, come join the ballet!
With every new line, we dance with delight,
In the world of code, everything feels right!" 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

@zzxming zzxming changed the title Fix style fix: toolbar style update and ts error Sep 8, 2024
@github-actions github-actions bot added the bug Something isn't working label Sep 8, 2024
Copy link

@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, codebase verification and nitpick comments (1)
packages/fluent-editor/src/toolbar/index.ts (1)

Line range hint 100-156: Approved with suggestions: Enhancements in attach method.

The changes in the attach method improve type specificity and handling of events. However, consider adding comments to clarify the logic, especially around the conditions that determine the value variable.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b34a261 and 6b3d5d1.

Files selected for processing (8)
  • packages/fluent-editor/src/assets/font.scss (1 hunks)
  • packages/fluent-editor/src/assets/lineHeight.scss (1 hunks)
  • packages/fluent-editor/src/assets/size.scss (1 hunks)
  • packages/fluent-editor/src/assets/toolbar.scss (1 hunks)
  • packages/fluent-editor/src/config/types/toolbar-item.interface.ts (1 hunks)
  • packages/fluent-editor/src/config/types/type.ts (1 hunks)
  • packages/fluent-editor/src/lineheight.ts (1 hunks)
  • packages/fluent-editor/src/toolbar/index.ts (5 hunks)
Files skipped from review due to trivial changes (3)
  • packages/fluent-editor/src/assets/font.scss
  • packages/fluent-editor/src/assets/lineHeight.scss
  • packages/fluent-editor/src/assets/size.scss
Additional comments not posted (9)
packages/fluent-editor/src/config/types/type.ts (1)

3-3: Approved changes with a suggestion to verify broader impact.

The modification to the ToolbarOption type definition enhances flexibility in toolbar configuration. However, it's crucial to verify that this change integrates well with existing usages of ToolbarOption throughout the application to ensure no unintended side effects occur.

Run the following script to verify the usage of ToolbarOption:

Verification successful

Verified usage of ToolbarOption in the codebase.

The ToolbarOption type is used within the IEditorModules interface in editor-modules.interface.ts. The changes to the type definition appear to be compatible with its current usage, allowing for more flexible configurations. No immediate issues were found, but further manual verification is recommended to ensure no unintended side effects in other parts of the application.

  • packages/fluent-editor/src/config/types/editor-modules.interface.ts: Usage within IEditorModules interface.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `ToolbarOption` to ensure they align with the new type definition.

# Test: Search for the type usage. Expect: All occurrences should handle the new flexible types correctly.
rg --type typescript -A 5 $'ToolbarOption'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify all usages of `ToolbarOption` to ensure they align with the new type definition.

# Corrected command to search for the type usage in TypeScript files.
rg --glob '*.ts' -A 5 $'ToolbarOption'

Length of output: 1686

packages/fluent-editor/src/lineheight.ts (1)

3-3: Approved import change with a suggestion to verify functionality.

The update to the import statement for Parchment aligns with standard practices and should enhance code clarity. Ensure that this change does not impact the functionality of LineHeightStyle or other features that depend on the Parchment module.

Run the following script to verify the functionality of LineHeightStyle:

Verification successful

Import Change Verified: No Issues Found with LineHeightStyle

The import change for Parchment does not negatively impact the functionality of LineHeightStyle. The usage and integration of LineHeightStyle in the codebase are consistent and error-free. No further action is required.

  • LineHeightStyle is defined and used correctly in packages/fluent-editor/src/lineheight.ts and packages/fluent-editor/src/fluent-editor.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `LineHeightStyle` functions correctly with the new import method.

# Test: Search for any issues reported in logs or tests related to `LineHeightStyle`.
rg --type typescript -A 5 $'LineHeightStyle'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify that `LineHeightStyle` functions correctly with the new import method.

# Test: Search for any issues reported in logs or tests related to `LineHeightStyle`.
rg --glob '*.ts' -A 5 'LineHeightStyle'

Length of output: 1559

packages/fluent-editor/src/config/types/toolbar-item.interface.ts (1)

5-5: Approved interface changes with suggestions for further actions.

The modifications to the IToolbarItem interface, including the refined type for the header property and the addition of the lineheight property, enhance flexibility and functionality. It's important to ensure these changes are well integrated into the toolbar's configuration and to verify that they function as expected in different scenarios.

Run the following script to verify the integration and functionality of the new lineheight property:

Also applies to: 12-12

packages/fluent-editor/src/toolbar/index.ts (4)

5-5: Approved: Import statement for TypeToolbar.

The explicit import of TypeToolbar enhances type safety and clarity in the codebase.


11-11: Approved: Updated debuglogger function.

The modification to restrict the debuglogger function's parameter type to predefined levels improves the robustness and predictability of logging.


21-21: Approved: More strictly typed return object in namespace function.

This change ensures that the methods exposed by the namespace function conform to the expected signature, enhancing type safety.


30-30: Approved: Modified Toolbar import.

Changing the import statement to use a type assertion for TypeToolbar aligns with TypeScript's type system and improves code clarity.

packages/fluent-editor/src/assets/toolbar.scss (2)

361-377: Approved: Updated hover and active states for buttons and labels.

The changes to the fill and color properties enhance visual feedback for user interactions, making the toolbar elements more prominent. This aligns with the PR's objective to fix style issues.


379-382: Approved: Maintained disabled state styling.

The styling for the disabled state remains consistent, ensuring that the user interface remains intuitive and accessible.

packages/fluent-editor/src/toolbar/index.ts Show resolved Hide resolved
@kagol kagol merged commit 55db52d into opentiny:main Sep 9, 2024
4 checks passed
This was referenced Sep 9, 2024
@zzxming zzxming deleted the fix-style branch September 10, 2024 03:50
This was referenced Sep 20, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 15, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants