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

T/27 #28

Merged
merged 3 commits into from
Sep 19, 2016
Merged

T/27 #28

merged 3 commits into from
Sep 19, 2016

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented Sep 13, 2016

@scofalik
Copy link
Contributor Author

ckeditor/ckeditor5-heading#29

Related PR that should be handled simultaneously.

@@ -26,6 +26,6 @@ export default class Enter extends Feature {
this.listenTo( editingView, 'enter', ( evt, data ) => {
editor.execute( 'enter' );
data.preventDefault();
} );
}, 'low' );
Copy link
Member

Choose a reason for hiding this comment

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

This should be the standard observer. Others can use high priority.

Copy link
Contributor Author

@scofalik scofalik Sep 19, 2016

Choose a reason for hiding this comment

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

In engine, many callbacks are added with low priority, hinting that these are default callbacks that may be overwritten. In a result, most callbacks added in (external) plugins/features can be added with default priority and still overwrite default ones.

So, I felt like this is a very basic functionallity, almost like those in engine, hence I decided to go with low priority. If you really think this is wrong, I will change it. But remember that we have only 5 levels of events, so users will only get high and highest.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I can live with it. low makes some sense, cause indeed other listeners will usually want to precede it. And if anyone will want to do something after, there's still lowest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And there is low added after this listener (I am not sure now how this chain of dependencies and requirements in plugins will work, but I hope that Enter feature will be loaded as one of first ones.

Copy link
Member

Choose a reason for hiding this comment

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

And there is low added after this listener

What do you mean?

I am not sure now how this chain of dependencies and requirements in plugins will work

Works like a charm :P. No other feature requires the enter feature right now, so it can be loaded first or last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean that if you add a listener with low priority after (in code) discussed listener, the new listener will be fired as a second one. So lowest is not the only option to go.

Copy link
Member

Choose a reason for hiding this comment

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

So yes, if your feature requires the Enter feature, then it'd work.

enterBlock( doc.batch(), doc.selection, { defaultBlockName: 'paragraph' } );
enterBlock( batch, doc.selection );

this.fire( 'afterExecute', { batch } );
Copy link
Member

Choose a reason for hiding this comment

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

This must be automated. We can do this later ofc. See also my other comment about accepting batch and selection in many commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be automated but doing it now would will take us too much time and it's better to close this part of code and then rework all the commands.

*/
export function enterBlock( batch, selection, options = {} ) {
const defaultBlockName = options.defaultBlockName;
function enterBlock( batch, selection ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't it exposed any more? The command cannot be always reused (undo step integration isn't then possible), so the function can be useful from time to time.

This made me think that perhaps we should allow passing those params (batch, selection) to all commands which use them. In https://github.com/ckeditor/ckeditor5-enter/pull/28/files#r79292725 I wrote that we need to automate those kind of commands anyway, so perhaps we can go one step further and add also this flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why you cannot integrate undo steps? If the command adds the used batch to the data object passed with afterExecute event callback you can add new deltas to it.

Of course this way you cannot do beforeExecute and this could be an argument for making it more flexible.

Anyway, I don't think this need to be exposed anymore as calling this method is everything what EnterCommand does. There are no options, etc. So if you want to call this method, you can call editor.execute( 'enter' ) too. If you want to modify this, use afterExecute callback. My rule of thumb was "if Headings does not need it, it does not need to be exposed".

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.

Tests pass. Code looks good, but we need to understand what will happen with this code later on.

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.

At least one thing to fix: https://github.com/ckeditor/ckeditor5-enter/pull/28/files#r79292600

Plus couple of questions to answer and create followups.

@Reinmar Reinmar merged commit 3dc594b into master Sep 19, 2016
@Reinmar Reinmar deleted the t/27 branch September 19, 2016 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove defaulBlockName and make EnterCommand extendable
2 participants