{"action":"created","issue":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/586","repository_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine","labels_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/586/labels{/name}","comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/586/comments","events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/586/events","html_url":"https://github.com/ckeditor/ckeditor5-engine/issues/586","id":175765088,"number":586,"title":"Introduce `breakBlock` to `Composer`.","user":{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/module:model","name":"module:model","color":"fef2c0"},{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/status:confirmed","name":"status:confirmed","color":"e6e6e6"},{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/type:enhancement","name":"type:enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false},"assignees":[{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-09-08T14:14:18Z","updated_at":"2016-09-09T09:06:46Z","closed_at":null,"body":"`EnterCommand` introduced `enterBlock` method which takes `Selection` instance and, briefly speaking, removes contents in that selection and breaks the block in which selection was made. Additionally, it was possible to pass `defaultBlockName` option which changed what kind of element was created if selection was at the end of the element (i.e. `<h1>` was changed to `<p>`).\r\n\r\nThen, `EnterCommand` when executed, used that function. The callback to `enter` event was added:\r\n\r\n```javascript\r\nthis.listenTo( editingView, 'enter', ( evt, data ) => {\r\n\teditor.execute( 'enter' );\r\n\tdata.preventDefault();\r\n}, 'low' );\r\n```\r\n\r\nYou could pass `defaultBlockName` as execution parameter: `editor.execute( 'enter', 'p' );`.\r\n\r\nIt appears that there are two problems concerning this approach:\r\n1. We might need more flexibility in how `EnterCommand` behaves in some features. This would lead to putting more stuff/options into the command, which would be used only in single cases.\r\n2. It was possible to overwrite `enter` event callback, but it was not possible to overwrite how `EnterCommand` works. In other word, in different feature I could do:\r\n\r\n```javascript\r\nthis.listenTo( editingView, 'enter', ( evt, data ) => {\r\n\tif ( something ) {\r\n\t\teditor.execute( 'enter', 'heading1' );\r\n\t\tdata.preventDefault();\r\n\t\tevt.stop();\r\n\t}\r\n}, 'high' );\r\n```\r\n\r\nSo it was possible to overwrite what happens after clicking `Enter` key but if other feature wanted to call `EnterCommand`, it would have to use the default version (or know about all other features).\r\n\r\nThat's why we decided that it is a good idea to move this whole mechanism to `Composer` and make it work similar to `deleteContents`. Then, `EnterCommand` can just call `Composer#breakBlock` while other features can add their own callbacks. This is more flexible and correct approach.\r\n\r\nPS: `breakBlock` name is temporary. Maybe there is a better name. However I don't like `enter` in original `enterBlock` name because it is strictly connected with `Enter` key and doesn't really describe what the method does."},"comment":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/comments/245860272","html_url":"https://github.com/ckeditor/ckeditor5-engine/issues/586#issuecomment-245860272","issue_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/586","id":245860272,"user":{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T09:06:46Z","updated_at":"2016-09-09T09:06:46Z","body":"The question is why someone would call `EnterCommand`? We can be less semantic and more focused on developers intentions. I am afraid that people will call `EnterCommand` having in mind \"i want to simulate clicking enter key\".\r\n\r\nAs I think of it, I think that `EnterCommand` should be named `BreakCommand` :D.\r\n\r\nWith love,\r\nSzymon."}}
{"actor":{"display_login":"scofalik"}}