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

Various merge tags related improvements and adjustments. #16096

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Dumluregn
Copy link
Contributor

@Dumluregn Dumluregn commented Mar 25, 2024

Suggested merge commit message (convention)

Feature (ui): Add the LabelWithHighlightView and ButtonLabelWithHighlightView components to the common UI library.
Feature (ui): Add the filterGroupAndItemNames() helper to the common UI library.
Feature (ui): The SearchTextView#reset() method will also reset the scroll of its filteredView to the top.

Internal (merge-tags): Added a mergeTag element to the inlineObjectElements array in the DomConverter class.


Additional information

This is a PR with improvements necessary for the upcoming merge tags feature.

Dumluregn and others added 11 commits March 8, 2024 11:54
Internal (merge-tags): Added a mergeTag element to the `inlineObjectElements` array in the `DomConverter` class.
Feature (ui): Add the `LabelWithHighlightView` and `ButtonLabelWithHighlightView` components to the common UI library.
Feature (ui): Add the `filterGroupAndItemNames()` helper to the common UI library. 
Feature (ui): The `SearchTextView#reset()` method will also reset the scroll of its `filteredView` to the top.
@Dumluregn Dumluregn marked this pull request as draft March 25, 2024 15:02
Copy link
Contributor

coderabbitai bot commented May 9, 2024

Walkthrough

The recent updates across the CKEditor 5 package focus on enhancing UI components and integration with new elements like mergeTag. New classes for highlighted text views are introduced, along with updates in menu bar utilities and search functionalities. The changes include additions to handle new inline elements and improvements in UI responsiveness, particularly in search views.

Changes

Files Changes Summary
.../domconverter.ts, .../whitespace-handling-integration.js Added 'mergeTag' to inlineObjectElements and singletons for improved inline element handling.
.../buttonlabelwithhighlightview.ts, .../labelwithhighlightview.ts, .../index.ts Introduced new classes for highlighted text views and updated exports.
.../utils.ts, .../menubar/utils.ts Enhanced menu bar utilities to include new mergeTag functionalities.
.../search/filtergroupanditemnames.ts, .../search/text/searchtextview.ts, .../tests/search/... Improved search functionalities and added tests for new filter and search view features.
.../tests/highlightedtext/... Implemented tests for new highlighted text view classes.

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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

Out of diff range and nitpick comments (2)
packages/ckeditor5-ui/src/highlightedtext/labelwithhighlightview.ts (1)

21-26: Ensure proper documentation for public properties id and for.

It's good practice to include a brief description in the documentation comments for public properties to explain their purpose or usage, which can be beneficial for other developers.

packages/ckeditor5-ui/src/highlightedtext/buttonlabelwithhighlightview.ts (1)

20-30: Ensure proper documentation for public properties style, text, and id.

Similar to the previous file, it would be beneficial to include brief descriptions in the documentation comments for these public properties to aid other developers in understanding their usage.

@@ -182,7 +182,7 @@ export default class DomConverter {
'td', 'tfoot', 'th', 'thead', 'tr', 'ul'
];
this.inlineObjectElements = [
'object', 'iframe', 'input', 'button', 'textarea', 'select', 'option', 'video', 'embed', 'audio', 'img', 'canvas'
'object', 'iframe', 'input', 'button', 'textarea', 'select', 'option', 'video', 'embed', 'audio', 'img', 'canvas', 'mergeTag'
Copy link
Contributor

@coderabbitai coderabbitai bot May 9, 2024

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Several files in the codebase still use the old function signature.

  • The search results indicate that 'mergeTag' is referenced in UI-related code but does not appear to be handled in a way that supports its behavior as an inline object element in domconverter.ts.
  • This could potentially lead to issues since the handling necessary to support its inclusion in the inlineObjectElements array does not seem to be implemented.
Analysis chain

Addition of 'mergeTag' to inlineObjectElements approved.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that 'mergeTag' is handled appropriately in other parts of the codebase.

# Test: Search for 'mergeTag' handling. Expect: Relevant handling logic in other parts of the code.
rg --type typescript 'mergeTag'

Length of output: 66



Script:

#!/bin/bash
# Description: Re-verify that 'mergeTag' is handled appropriately in other parts of the codebase by correcting the file type error in the previous script.

# Corrected Test: Search for 'mergeTag' handling in TypeScript files. Expect: Relevant handling logic in other parts of the code.
rg --type ts 'mergeTag'

Length of output: 511

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be injected from the feature code. It's public property. The property itself is read-only but the content is not.

See how we handle other similar props:

const unsafeElements = editor.editing.view.domConverter.unsafeElements;

// Make sure that this element will not render in the editing view.
if ( !unsafeElements.includes( viewElement.name ) ) {
unsafeElements.push( viewElement.name );
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@niegowski, thank you for your input. The handling of 'mergeTag' as an inline object element in the DomConverter class is indeed crucial for ensuring it integrates smoothly with the rest of the system, especially given its role in the UI components.

From the examples you provided, it seems like the approach used in other parts of CKEditor 5 involves defining properties in a way that they are publicly accessible but their modification is controlled. This is typically achieved using getter/setter methods or similar patterns to encapsulate the property's value, ensuring it remains read-only externally while allowing its content to be modified internally.

Currently, 'mergeTag' is added directly to the inlineObjectElements array in the DomConverter class, which makes it part of the internal configuration for handling inline objects. This approach is straightforward but does not allow external manipulation or extension in the same way that a getter/setter pattern would.

If aligning the handling of 'mergeTag' with the approach you highlighted is desired, we could consider introducing a method to get and potentially set the contents of the inlineObjectElements array in a controlled manner. This would provide flexibility and maintain consistency with other parts of the codebase.

Would you like me to draft a potential implementation for this adjustment, or is there a specific aspect of the integration you would like to discuss further?

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

Out of diff range and nitpick comments (2)
packages/ckeditor5-ui/src/panel/balloon/balloonpanelview.ts (2)

401-421: Add JSDoc for the options parameter.

To improve code readability and maintainability, consider adding JSDoc comments for the options parameter in the generatePositions method.

/**
 * @param {Object} options - Options to generate positions.
 * @param {number} [options.sideOffset] - A custom side offset (in pixels) of each position.
 * @param {number} [options.heightOffset] - A custom height offset (in pixels) of each position.
 * @param {number} [options.stickyVerticalOffset] - A custom offset (in pixels) of the `viewportStickyNorth` positioning function.
 * @param {Object} [options.config] - Additional configuration of the balloon panel view.
 */

437-441: Ensure consistent use of configuration spread.

For consistency, ensure that the spread operator is used uniformly across all positioning functions when adding the config object.

...( config && { config } )

Comment on lines 677 to 698
viewportStickyNorth: ( targetRect, balloonRect, viewportRect, limiterRect ) => {
const boundaryRect = limiterRect || viewportRect;

if ( !targetRect.getIntersection( boundaryRect ) ) {
return null;
}

// Engage when the target top and bottom edges are close or off the boundary.
// By close, it means there's not enough space for the balloon arrow (offset).
if ( boundaryRect.height - targetRect.height > stickyVerticalOffset ) {
return null;
}

return {
top: boundaryRect.top + stickyVerticalOffset,
left: targetRect.left + targetRect.width / 2 - balloonRect.width / 2,
name: 'arrowless',
config: {
withArrow: false,
...config
}
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a fallback for stickyVerticalOffset.

To enhance robustness, consider adding a fallback value for stickyVerticalOffset in the viewportStickyNorth positioning function.

const stickyOffset = stickyVerticalOffset || BalloonPanelView.stickyVerticalOffset;

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.

None yet

2 participants