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

Add prototype submenu for image insert. #16334

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mremiszewski
Copy link
Contributor

@mremiszewski mremiszewski commented May 10, 2024

Suggested merge commit message (convention)

Feature (image): Add menu bar integration for inserting an image via URL.

Minor Breaking Change (image): Inserting an image via URL is done in a modal instead of being directly in the image upload dropdown.
Minor Breaking Change (image): The image upload dropdown no longer supports focus cycling between child controls.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates across multiple CKEditor5 packages focus on enhancing UI components, particularly through the addition of menuBarButtonViewCreator methods in various UI classes. These methods facilitate the creation of menu bar buttons with specific functionalities. There's also a notable simplification and restructuring in the ImageInsertUI components, alongside updates to menu item identifiers and configuration options to improve user interaction and interface consistency.

Changes

File Path Change Summary
.../ckeditor5-ckbox/src/ckboxui.ts
.../ckeditor5-ckfinder/src/ckfinderui.ts
.../ckeditor5-image/src/imageupload/imageuploadui.ts
Added menuBarButtonViewCreator method in CKBoxUI, CKFinderUI, and ImageUploadUI classes for creating menu bar buttons with specific icon and label bindings.
.../ckeditor5-image/src/imageinsert/... Added multiple new UI components and methods for menu bar integration, and restructured existing components for simplicity.
.../ckeditor5-image/src/imageinsert/imageinsertviaurlui.ts Enhanced button creation methods, introduced modal display functionality for URL insertion, and updated import statements.
.../ckeditor5-image/src/imageinsert/ui/imageinserturlview.ts Simplified view structure by removing unused components and methods, and refocused on essential functionalities.
.../ckeditor5-image/tests/manual/imageinsert.js Added new configuration option for menu bar visibility.
.../ckeditor5-ui/src/menubar/utils.ts Updated menu item identifiers to reflect new functionalities.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2e9b16d and d9f4712.
Files selected for processing (8)
  • packages/ckeditor5-ckbox/src/ckboxui.ts (1 hunks)
  • packages/ckeditor5-ckfinder/src/ckfinderui.ts (1 hunks)
  • packages/ckeditor5-image/src/imageinsert/imageinsertui.ts (6 hunks)
  • packages/ckeditor5-image/src/imageinsert/imageinsertviaurlui.ts (5 hunks)
  • packages/ckeditor5-image/src/imageinsert/ui/imageinserturlview.ts (8 hunks)
  • packages/ckeditor5-image/src/imageupload/imageuploadui.ts (1 hunks)
  • packages/ckeditor5-image/tests/manual/imageinsert.js (1 hunks)
  • packages/ckeditor5-ui/src/menubar/utils.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/ckeditor5-image/src/imageinsert/ui/imageinserturlview.ts
  • packages/ckeditor5-ui/src/menubar/utils.ts
Additional comments not posted (6)
packages/ckeditor5-image/tests/manual/imageinsert.js (1)

34-34: Configuration option to control menu bar visibility added correctly.

packages/ckeditor5-ckbox/src/ckboxui.ts (1)

70-80: Method menuBarButtonViewCreator correctly creates and configures a menu bar button for CKBox integration.

packages/ckeditor5-ckfinder/src/ckfinderui.ts (1)

75-85: Method menuBarButtonViewCreator correctly implemented for CKFinder integration, following CKEditor5 UI standards.

packages/ckeditor5-image/src/imageupload/imageuploadui.ts (1)

82-84: Method menuBarButtonViewCreator correctly implemented for creating a menu bar button in ImageUploadUI.

packages/ckeditor5-image/src/imageinsert/imageinsertviaurlui.ts (1)

Line range hint 43-64: Methods related to image insertion via URL (_createInsertUrlButton, _createInsertUrlView, _showModal) are correctly implemented and integrated.

packages/ckeditor5-image/src/imageinsert/imageinsertui.ts (1)

Line range hint 104-241: Methods for creating toolbar and menu bar components (_createToolbarComponent, _createMenuBarComponent) and registering integrations (registerIntegration) are correctly implemented.


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.

@scofalik
Copy link
Contributor

scofalik commented May 16, 2024

Quick functional review (images below):

  1. Image insert options inside an "Image" submenu is okay.
  2. Add a proper icon to the menu bar "Image" item. It can be the one from the toolbar.
  3. We need to do something with "Image or file" item as it doesn't make sense / looks bad when there's also "Image" just above.
    1. In toolbar, it's up to integrator which icon / dropdown option they will use. Nothing is set by default, so there's no obvious duplication.
    2. In menu bar however, we propose default setup and we want it to be as complete as possible.
    3. My proposal: change "Image or file" label to "File".
      1. It should work fine with any file manager.
      2. I think it will not be weird if you choose an image afterwards.
      3. It will duplicate the functionality from "Image => Insert with file manager" but I am fine with this.
      4. cc @Witoso @dagdzi
  4. "Insert image via URL" (in menu bar) should not have a tooltip. No other menu item has a tooltip. I also think that the dropdown component should not have tooltips either, as the tooltips just duplicate the label information.
  5. "Insert image via URL" should look the same in the dropdown as in the menu bar. Convert the mini-form to the button that will open the modal dialog.
  6. Modal dialog size is incorrect (too narrow, with no paddings, I propose twice much size than now + some reasonable paddings).
  7. Labels in the menu bar dropdown should be: "Upload from computer", "Insert with file manager", "Insert via URL".
  8. I have doubts about the label changing from "Image" to "Replace image" but I'd like to get a second opinion @dagdzi @Witoso.

Ad 3:

Ad 4:

 

image

Ad 8:

@Witoso
Copy link
Member

Witoso commented May 16, 2024

"Insert image via URL" should look the same in the dropdown as in the menu bar. Convert the mini-form to the button that will open the modal dialog.

Yep, good catch! I want this form gone :)  

"Image or file" label to "File".

Which ui component is it? Shouldn't this be named File manager?

I have doubts about the label changing from "Image" to "Replace image" but I'd like to get a second opinion @dagdzi @Witoso.

I agree, I think in main level in the menu bar we should keep nouns, and ideally don't change it to not confuse users.

@scofalik
Copy link
Contributor

scofalik commented May 16, 2024

This is file manager component, but it wouldn't follow a convention if we name it "File manager" in the menu. The menu is called "Insert" and each label in the menu is an entity that you insert, e.g. "Insert -> table", "Insert -> image", etc. "Insert -> file manager" does not follow that. Hence I proposed "File".

It could be "Insert -> From/Using/With file manager" 🤷 But I though "File" will be just cleaner.

@Witoso
Copy link
Member

Witoso commented May 16, 2024

So maybe it doesn't make sense to keep it in Insert? File manager is also used for other things (CKBox), managing files, editing, upload is just one of the capabilities.

@scofalik
Copy link
Contributor

scofalik commented May 16, 2024

I think you should have a menu bar button that allows you to insert a file and is easily discoverable. Not hidden under "Insert -> Image -> Image with file manager".

We could also add "File manager" in "Tools -> File manager". But that would be a 3rd place where the same component is added 😄. Also, I don't know if we can even open the file manager in a different mode than "insert something". I mean, you always have "Insert" button in the dialog. You don't open editor, and file manager from the editor, to organize your files, right? (Unless I miss something.)

@Witoso
Copy link
Member

Witoso commented May 17, 2024

Then let's go with the file.

Copy link
Contributor

@scofalik scofalik left a comment

Choose a reason for hiding this comment

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

Additionally go through all the files in the image package related to UI / inserting images and check if all docs are up-to-date.

E.g. ImageInsertUI has this description:

Adds the `'insertImage'` dropdown to the {@link module:ui/componentfactory~ComponentFactory UI component factory}
and also the `imageInsert` dropdown as an alias for backward compatibility.

Which doesn't even mention anything about menu bar.

buttonViewCreator: isOnlyOne => this._createInsertUrlButton( isOnlyOne ),
formViewCreator: isOnlyOne => this._createInsertUrlView( isOnlyOne )
buttonViewCreator: () => this._createInsertUrlButton( ButtonView ),
formViewCreator: () => this._createInsertUrlView(),
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 look and behave similar to this._createInsertUrlButton( MenuBarMenuListItemButtonView ). It should be a dropdown item (button) like other integration methods.

@mremiszewski mremiszewski marked this pull request as ready for review May 24, 2024 13:15
@@ -36,6 +42,8 @@ import ImageUtils from '../imageutils.js';
*
* Adds the `'insertImage'` dropdown to the {@link module:ui/componentfactory~ComponentFactory UI component factory}
* and also the `imageInsert` dropdown as an alias for backward compatibility.
*
* Adds the `'menuBar:insertImage'` sub-menu to the {@link module:ui/componentfactory~ComponentFactory UI component factory}.
Copy link
Contributor

Choose a reason for hiding this comment

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

We also added new components in ckbox and ckfinder and AFAICS their API docs are not updated as well.

I also wanted you to go through existing guides but since core team is now reworking them AND we need to do other tasks related to docs (update demos, update all other guides not only images), then let's skip it for now.

@scofalik
Copy link
Contributor

scofalik commented May 24, 2024

Please remove tooltips from the items in the toolbar dropdown as they are simply repeating the button label and are annoying.

Regarding labels and tooltips, as it seems that it got confusing:

  1. Menu bar:
    1. Upload from computer
    2. Insert with file manager
    3. Insert via URL
  2. Toolbar dropdown (formview integration):
    1. Upload/Replace from computer
    2. Insert/Replace with file manager
    3. Insert via URL / Update image URL
  3. Toolbar button (button integration):
    1. Upload/Replace image from computer
    2. Insert/Replace image with file manager
    3. Insert image via URL / Update image URL

Make sure that only toolbar buttons (and all of them!) have tooltips.

buttonViewCreator: isOnlyOne => this._createInsertUrlButton( isOnlyOne ),
formViewCreator: isOnlyOne => this._createInsertUrlView( isOnlyOne )
requiresForm: false,
buttonViewCreator,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably incorrect 🤔. If insert via URL is the only available option, then it will be displayed in the toolbar with text, right? Which is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIU, buttonViewCreator should use the uploadUrl component.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I just realized that uploadUrl is rather a bad name. First question: upload what? Second: we don't upload anything really.

The other components we have are called:

  • insertImage
  • uploadImage

urlImage sounds quite bad so I propose insertImageUrl (and ofc menuBar:insertImageUrl).

Copy link
Contributor

@scofalik scofalik May 24, 2024

Choose a reason for hiding this comment

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

Also please add info about this component to metadata file. After the selected part:

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

3 participants