-
-
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
Improve a typical command class #2883
Comments
I think it was made like this because not every command was supposed to have We could even go a step further and set observable class Command {
constructor() {
// ...
if ( this._checkValue ) {
// ...
}
}
// ...
}
class MyCommand extends Command {
_checkValue() {
// ...
}
} We have something like this with I am not sure about joining those two, though. As you know, CKE4 has tri-state property for this and AFAIR it caused problems. We separated those two on purpose. |
I didn't mean merging them into one property of course. Just to merge the two methods for refreshing the command. But I'm not sure about this anyway. |
Well, I understand that value and state are set under similar circumstances (I mean after changes are made on document). But I wouldn't join them together at the moment. Having them separated makes some things easier:
|
Fixed by ckeditor/ckeditor5-core#88. |
This is a message quote command implementation:
It's very similar to the list command and heading command could be aligned to it as well (now it differs a bit, which is an issue itself).
What I don't like here is:
changesDone
. See also https://github.com/ckeditor/ckeditor5-engine/issues/698. I think that we could define something likeCommand#refreshOnChange()
method which would register such a listener itself.refreshState()
andrefreshValue()
, but a class definition is ugly. I think that we should hoist the "value" concept to the base command and createCommand#refreshValue()
there. Then, the actual logic would be enclosed in_checkValue()
and_checkEnabled()
. Or, we can go a bit further and somehow join these two._checkEnabled()
will be really similar in all 3 commands so perhaps it can be moved to some util.The text was updated successfully, but these errors were encountered: