-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
src/multicommand.js
Outdated
* @param {module:core/command~Command} command | ||
*/ | ||
registerChildCommand( command ) { | ||
this._childCommands.add( { command } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you wrap it with an object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we use Collection
? Then why using Collection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I've started with collection to use some of its delegation powers but it turned out I use as an array. I'll change that.
* | ||
* @param {module:core/command~Command} command | ||
*/ | ||
registerChildCommand( command ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just addChildCommand()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, "register" reads quite well in the docs. So I don't have a strong opinion on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "register" implies something more than just adding it (like adding to a collection). So if it also reads well in the docs I'll leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. We actually start watching those commands.
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
Co-Authored-By: Piotrek Koszuliński <pkoszulinski@gmail.com>
* @inheritDoc | ||
*/ | ||
refresh() { | ||
// Override base command refresh(): the command's state is changed when one of child commands changes states. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I became unsure about this. I'll report a followup, though.
Suggested merge commit message (convention)
Feature: Introduce
MultiCommand
that allows to group many commands as one.Additional information
This is part of IndentBlock PR.
The changes in core:
Created Indent feature plugins:
Indent
- typical glue plugin.IndentEditing
- introduces the "multi"'indent'
and'outdent'
commands.IndentUI
- introduces the'indent'
and'outdent'
toolbar buttons.We talked about defining
Indent
feature (buttons) with @Reinmar but I'm divided on where to put this feature. From one side this feature might not be needed by some - thus it might be better to put it in... 🥁 ...another repository as a separateckeditor5-indent
feature. But OTOH we will probably include this in most of the builds to use'indent'
and'outdent'
buttons.The
MultiCommand
that allows to register many commands under one alias.I've created the
MultiCommand
as a way to programmatically register other indentation commands under one command so the UI buttons would attach to one command only event thought there are voices against (by @pjasiun dunno @Reinmar voice on this).The command allows other features to register a child command (if it is defined in command collection). The
MultiCommand
changes itsisEnabled
state totrue
if any of registered commands is enabled. It also executes first enabled command (if any).I've created this command as we want to expose
'indent'
and'outdent'
buttons that will enable to indent list and indent blocks. We already have'indentList'
(I'll skip theoutdent
as it is similar) command and a newly introduced'indentBlock'
command. We want to have one button for both (as in CKEditor 4). Now, I don't like the idea of overriding, ieindentBlock
command byindentList
command if the command is in list and not in a block. This isn't clean and might introduce some WTFs to others. Now theMultiCommand
might be justInputCommand
with the same interface as we have only one usage for such construct now and in forseable future. But I'm strongly against anyif
s or other hacks in one commands that would tightly couple both features. (early stage POC with buttons)The
MultiCommand
allows to have any of indent feature to be present and does not require loading of other.