-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Implement a balloon toolbar factory #5486
Comments
Toolbars currently diff in only a few places:
Note that for some widget we can need two toolbars - e.g. for table cell and the table widget. |
Extracting @pjasiun comment from
|
An abstract class and simple inheritance like the above should be pretty easy to implement. The downcast of this approach is the Plugin->WidgetToolbar->ImageToolbar inheritance. I'd only change the There's also a common part that could be actually moved to the
IMO the And I'm not sure how the second table toolbar config should be named (for the table widget). As the |
Do we have to introduce this by a plugin and inheritance? It's ok to me that there is some The Additionally, unless you see that concretising this feature to widgets only makes it simpler, then I'd consider keeping generic to e.g. all kinds of elements. |
PS. This is the kind of API that greatly improves the DX and this, in fact, I think it was already requested by the community, so I assigned it to "next". |
After a F2F call, I had another idea, which should be pretty easy to implement and works similarly to how the We could make the Then, the export default class ImageToolbar extends Plugin {
static get requires() {
return [ WidgetToolbar ];
}
afterInit() {
const editor = this.editor;
const widgetToolbar = editor.plugins.get( 'WidgetToolbar' );
widgetToolbar.add( 'image', {
items: editor.config.get( 'image.toolbar' ) || [],
isSelected: isImageWidgetSelected,
} );
}
// Optionally. `WidgetToolbar#destroy()` would remove all listeners.
destroy() {
const widgetToolbar = editor.plugins.get( 'WidgetToolbar' );
widgetToolbar.remove( 'image' );
}
} The WDYT? |
I like this idea. It is simple to describe, does not force you to create own plugin to add a widget toolbar (all you need to do is to load one) and consistent with other parts of the API (we have a few plugins which are this kind of utils, for instance, |
I'm not sure if the And I can't go with My first thought was Maybe:
WDYT? |
|
Balloon toolbar has decorative |
widgetToolbar.add( 'image', {
items: editor.config.get( 'image.toolbar' ) || [],
isSelected: isImageWidgetSelected,
} );
The first problematic thing is the plugin name. Its instance We can keep the short name too, but then we need to rename |
Hehe :) Even the documentation has a problem with the toolbar vs collection thing: |
Lets move this discussion to the PR: https://github.com/ckeditor/ckeditor5-widget/pull/54/files |
Feature: Introduced the widget toolbar repository. Closes ckeditor/ckeditor5-ui#442.
ATM the following features share the same concept of a toolbar attached to a widget:
but they don't share the code, which is almost the same. We need a utility to create this kind of component easily to DRY and centralize the maintenance. Otherwise it's a waste of time and LOC.
cc @ma2ciek, @Reinmar
The text was updated successfully, but these errors were encountered: