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

Make removing the Image plugin from classic build less cumbersome #526

Closed
wwalc opened this issue Aug 21, 2017 · 9 comments · Fixed by ckeditor/ckeditor5-ui#292
Closed
Assignees
Labels
type:improvement This issue reports a possible enhancement of an existing feature.
Milestone

Comments

@wwalc
Copy link
Member

wwalc commented Aug 21, 2017

Adjusting CKEditor 5 Builds is currently quite cumbersome. As an end user I want to be able to download a CKEditor 5 Build and remove features from it easily, just like it was possible in CKEditor 4 via config.removePlugins.

Unfortunately it's not, especially for Images.

The setup that I tried:

ClassicEditor.create( document.querySelector( '#text-editor' ), {
	removePlugins: [ 'Blockquote', 'Image', 'List' ],
	toolbar: [
		'headings',
		'bold',
		'italic',
		'link',
		'unlink'
	]
} )
.then( editor => {
	console.log( editor );
} )
.catch( error => {
	console.error( error );
} );

unfortunately resulted in:

CKEditorError: componentfactory-item-missing: There is no such UI component in the factory. {"name":"imageTextAlternative"}

Being naive, I tried:

removePlugins: [ 'Blockquote', 'Image', 'List', 'ImageTextAlternative' ]

which of course did not work.

What finally helped was:

removePlugins: [ 'Blockquote', 'Image', 'ImageToolbar', 'List' ],

I guess this is a consequence of the default image config where the image toolbar is defined.

However, going finally to the point: if the ImageToolbar plugin requires the Image plugin and can't operate without it, shouldn't it remove itself automatically when Image plugin is removed?

Not sure if it's just about Image-related plugins or if there are other plugins with similar problems.

@Reinmar
Copy link
Member

Reinmar commented Aug 21, 2017

There are two problems here:

  1. That we don't have default toolbar configurations (automatic ones, like in CKEditor 4). Bacause of that you need to remember to change the toolbar configuration after removing a plugin.

  2. That removing the Image plugin does not remove the ImageToolbar plugin. If ImageToolbar depended on Image, then you'd at least see the following warning:

    plugincollection-required: Cannot load a plugin because one of its dependencies is listed in the removePlugins option.

    But in this case, the ImageToolbar plugin does not depend on Image at all. These are independent plugins. The only thing which glues them is the default image.toolbar config predefined in the build. That's why you've seen that error.

    However, the solution here is again – a default automatic toolbar configuration.

@Reinmar
Copy link
Member

Reinmar commented Aug 21, 2017

Related ticket: #409.

@Reinmar
Copy link
Member

Reinmar commented Aug 21, 2017

There's one more thing that we could do, though, apart from working on default toolbar configurations.

We could make the toolbar item loader check whether item exists in the component factory. If it does, then fine – add it to the item collection. If not, then log a warning (instead of throwing an error like now). The warning would come directly from the toolbar view so it could be more clear than the current error. Plus, the editor will work.

@Reinmar
Copy link
Member

Reinmar commented Aug 21, 2017

cc @oleq

@Reinmar Reinmar added candidate:1.0.0 type:improvement This issue reports a possible enhancement of an existing feature. labels Aug 21, 2017
@fredck fredck changed the title Make removing an Image plugin from classic build less cumbersome Make removing the Image plugin from classic build less cumbersome Aug 21, 2017
@oleq
Copy link
Member

oleq commented Aug 22, 2017

But in this case, the ImageToolbar plugin does not depend on Image at all. These are independent plugins. The only thing which glues them is the default image.toolbar config predefined in the build. That's why you've seen that error.

I would give decoupling these plugins a try. Didn't check internals so I'm not sure this is the only glue, though.

We could make the toolbar item loader check whether item exists in the component factory. If it does, then fine – add it to the item collection. If not, then log a warning (instead of throwing an error like now). The warning would come directly from the toolbar view so it could be more clear than the current error. Plus, the editor will work.

Sounds like a plan.

@Reinmar
Copy link
Member

Reinmar commented Aug 22, 2017

I would give decoupling these plugins a try. Didn't check internals so I'm not sure this is the only glue, though.

They are completely decoupled. What Wiktor tried to do failed because he used an editor build which has a preconfigured image toolbar. So the image toolbar feature was configured to load buttons which Wiktor removed by removing their plugins.

Sounds like a plan.

Could you handle it?

@oleq
Copy link
Member

oleq commented Aug 22, 2017

Yes. I'll handle this thing.

@oleq oleq self-assigned this Aug 22, 2017
@oleq oleq added this to the iteration 11 milestone Aug 22, 2017
@Reinmar
Copy link
Member

Reinmar commented Aug 23, 2017

BTW, this worked fine:

import { ClassicEditor } from '@ckeditor/ckeditor5-build-classic/ckeditor';

ClassicEditor
	.create( document.querySelector( '#snippet-image' ), {
		removePlugins: [ 'ImageToolbar', 'ImageCaption', 'ImageStyle' ],
		image: {}
	} )

EDIT: OK, that's a different story anyway.

@wwalc
Copy link
Member Author

wwalc commented Sep 7, 2017

We could make the toolbar item loader check whether item exists in the component factory. If it does, then fine – add it to the item collection. If not, then log a warning (instead of throwing an error like now). The warning would come directly from the toolbar view so it could be more clear than the current error. Plus, the editor will work.

+100.

Reinmar added a commit to ckeditor/ckeditor5-ui that referenced this issue Sep 12, 2017
Other: `ToolbarView#fillFromConfig()` will warn when the factory does not provide a component. Closes #291. Closes ckeditor/ckeditor5#526.
Reinmar added a commit to ckeditor/ckeditor5-core that referenced this issue Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
3 participants