{"action":"created","issue":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/1186","repository_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine","labels_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/1186/labels{/name}","comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/1186/comments","events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/1186/events","html_url":"https://github.com/ckeditor/ckeditor5-engine/issues/1186","id":275403384,"number":1186,"title":"Model, engine and document organisation","user":{"login":"pjasiun","id":1166967,"avatar_url":"https://avatars2.githubusercontent.com/u/1166967?v=4","gravatar_id":"","url":"https://api.github.com/users/pjasiun","html_url":"https://github.com/pjasiun","followers_url":"https://api.github.com/users/pjasiun/followers","following_url":"https://api.github.com/users/pjasiun/following{/other_user}","gists_url":"https://api.github.com/users/pjasiun/gists{/gist_id}","starred_url":"https://api.github.com/users/pjasiun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjasiun/subscriptions","organizations_url":"https://api.github.com/users/pjasiun/orgs","repos_url":"https://api.github.com/users/pjasiun/repos","events_url":"https://api.github.com/users/pjasiun/events{/privacy}","received_events_url":"https://api.github.com/users/pjasiun/received_events","type":"User","site_admin":false},"labels":[{"id":449836576,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/candidate:1.0.0","name":"candidate:1.0.0","color":"ffdd33","default":false},{"id":560409809,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/module:controller","name":"module:controller","color":"fef2c0","default":false},{"id":282736704,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/module:model","name":"module:model","color":"fef2c0","default":false},{"id":297499637,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/module:view","name":"module:view","color":"fef2c0","default":false},{"id":339376062,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels/type:task","name":"type:task","color":"84b6eb","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/milestones/13","html_url":"https://github.com/ckeditor/ckeditor5-engine/milestone/13","labels_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/milestones/13/labels","id":2904067,"number":13,"title":"iteration 14","description":"","creator":{"login":"Reinmar","id":156149,"avatar_url":"https://avatars2.githubusercontent.com/u/156149?v=4","gravatar_id":"","url":"https://api.github.com/users/Reinmar","html_url":"https://github.com/Reinmar","followers_url":"https://api.github.com/users/Reinmar/followers","following_url":"https://api.github.com/users/Reinmar/following{/other_user}","gists_url":"https://api.github.com/users/Reinmar/gists{/gist_id}","starred_url":"https://api.github.com/users/Reinmar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Reinmar/subscriptions","organizations_url":"https://api.github.com/users/Reinmar/orgs","repos_url":"https://api.github.com/users/Reinmar/repos","events_url":"https://api.github.com/users/Reinmar/events{/privacy}","received_events_url":"https://api.github.com/users/Reinmar/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":16,"state":"open","created_at":"2017-11-10T16:56:08Z","updated_at":"2017-12-21T13:03:10Z","due_on":"2018-01-31T08:00:00Z","closed_at":null},"comments":3,"created_at":"2017-11-20T15:52:21Z","updated_at":"2017-12-21T14:43:28Z","closed_at":"2017-12-19T13:37:36Z","author_association":"MEMBER","body":"At this point, we have a mess. The document is at the same time:\r\n - document data structure with roots, selection, and history,\r\n - the model entry point with methods like `transformDeltas` (which has nothing to do with the document), `enqueueChanges` or even schema (which is mostly used in converters which operates on data outside the document).\r\n\r\nAlso, after changes proposed in https://github.com/ckeditor/ckeditor5-engine/issues/858#issuecomment-344947666, the document will fire `change` event also for changes which do not change the document (changes in document fragments or detached elements). This is the same change event which is overused (and should be replaced with post fixers https://github.com/ckeditor/ckeditor5-engine/issues/1101).\r\n\r\nThis is why I proposed to change the structure to this:\r\n![screen shot 2017-11-20 at 16 29 38](https://user-images.githubusercontent.com/1166967/33026119-05278ab8-ce10-11e7-996b-10b33d49f8ab.png)\r\n\r\nThe current model writer class will be part of the batch API, the new writer will be more similar to the view writer.\r\n\r\nThe key concept is split between document, which is a read-only data structure, and writer which is the way to modify the document, but it can also modify any element or document fragment. It will be the writer who fires event about applied operations (currently it is `document#change` event), it will be `writer#operation`. `document#change` will be a more semantic event, the proper event to use by plugins, most probably the result of the document diff util https://github.com/ckeditor/ckeditor5-engine/issues/1172. \r\n\r\nNote, that this way any util which listens on applied operations (markers, differ), can work on any subtree, while these focused on the document can filter only document operation or listen on document events.\r\n\r\nAlso, model and view will have a very similar architecture: read-only document and writer to modify it. It won't be identical because you will have to create a batch, to modify the model in batches, but this is because the problems are different (view does not need the concept of batches).\r\n\r\nAnother change is to split model and document. Now, the document will be... only a document. It will not be model entry point anymore. Schema, default transformations, `transformDeltas`, creating writer will be moved to the `Model` class."},"comment":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/comments/353367826","html_url":"https://github.com/ckeditor/ckeditor5-engine/issues/1186#issuecomment-353367826","issue_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/1186","id":353367826,"user":{"login":"pjasiun","id":1166967,"avatar_url":"https://avatars2.githubusercontent.com/u/1166967?v=4","gravatar_id":"","url":"https://api.github.com/users/pjasiun","html_url":"https://github.com/pjasiun","followers_url":"https://api.github.com/users/pjasiun/followers","following_url":"https://api.github.com/users/pjasiun/following{/other_user}","gists_url":"https://api.github.com/users/pjasiun/gists{/gist_id}","starred_url":"https://api.github.com/users/pjasiun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjasiun/subscriptions","organizations_url":"https://api.github.com/users/pjasiun/orgs","repos_url":"https://api.github.com/users/pjasiun/repos","events_url":"https://api.github.com/users/pjasiun/events{/privacy}","received_events_url":"https://api.github.com/users/pjasiun/received_events","type":"User","site_admin":false},"created_at":"2017-12-21T14:43:28Z","updated_at":"2017-12-21T14:43:28Z","author_association":"MEMBER","body":"In the PR which closes this issue:\r\n - model and document were split (model handles all nodes: these in the document and these detached),\r\n - batch and writer were split (batch is only the collection of deltas while writer gets all methods to modify the tree),\r\n - instead of `enqueueChanges`, 2 new syntax were introduced: `change` and `enqueueChange`, see https://github.com/ckeditor/ckeditor5-engine/blob/a8e0f3732d2ef6dbc2e604103edb393df8e6b89f/src/model/model.js#L60-L153,\r\n - `change` and `enqueueChange` blocks become now the only proper API to get the writer and modify the model.\r\n\r\nWe decided not to introducing `engine` class because of reasone described here: https://github.com/ckeditor/ckeditor5-engine/issues/678#issuecomment-352760701."}}
{"actor":{"display_login":"pjasiun"}}