Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

i/5692: The main editor toolbar should respect the config.toolbar.shouldGroupWhenFull configuration #100

Merged
merged 2 commits into from
Nov 20, 2019

Conversation

oleq
Copy link
Member

@oleq oleq commented Nov 18, 2019

Suggested merge commit message (convention)

Feature: The main editor toolbar should respect the config.toolbar.shouldGroupWhenFull configuration (see ckeditor/ckeditor5#5692).


Additional information

Requires ckeditor/ckeditor5-core#201.

@coveralls
Copy link

coveralls commented Nov 18, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling b1da1ac on i/5692 into b5e4793 on master.

this.ui = new ClassicEditorUI( this, new ClassicEditorUIView( this.locale, this.editing.view ) );
const shouldGroupWhenFull = this.config.get( 'toolbar.shouldGroupWhenFull' );
const view = new ClassicEditorUIView( this.locale, this.editing.view, {
shouldToolbarGroupWhenFull: shouldGroupWhenFull === undefined ? true : shouldGroupWhenFull
Copy link
Member Author

@oleq oleq Nov 18, 2019

Choose a reason for hiding this comment

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

TBH I hate this bit. I should've used this.config.define( 'toolbar.shouldGroupWhenFull', true ) in this constructor() instead. But...

The thing is that toolbar configuration (as in the Config instance) can be either as

  • toolbar: [ 'bold', ... ]
  • or toolbar: { items: [ 'bold', ... ], otherOptions: ... }
    at this stage.

Doing this.config.define( 'toolbar.shouldGroupWhenFull', true ) overrides the former format (the later is OK) creating toolbar: { shouldGroupWhenFull: true } and nuking the items configuration passed to the create().

So to keep things working I'd have to do something like this:

// Get the second "normalized" form in the Config first.
this.config.set( 'toolbar', normalizeToolbarConfig( this.config.get( 'toolbar' ) ) );
// Then set some default.
this.config.define( 'toolbar.shouldGroupWhenFull', true )

which I hate even more because it changes the internal form (as in the Config instance, not the plain object provided by the user) of the toolbar configuration and who knows with what consequences.

So yeah... maybe I'm overreacting but I think we should discuss this bit.

Copy link
Member

Choose a reason for hiding this comment

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

I agree... that sucks. You can report a followup and comment it here with a link.

Also, I'd move the condition outside of the ClassicEditorUIView() constructor call to have the correct value directly in shouldGroupWhenFull variable.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@Reinmar Reinmar left a comment

Choose a reason for hiding this comment

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

As commented.

@Reinmar Reinmar merged commit 9a57e63 into master Nov 20, 2019
@Reinmar Reinmar deleted the i/5692 branch November 20, 2019 11:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants