-
-
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
Model, engine and document organisation #4211
Comments
This ticket can be done together with https://github.com/ckeditor/ckeditor5-engine/issues/678. |
Now, writer.insert( element, position ); A writer will have const writer = new Writer( batch );
writer.insert( element, position ); Writer constructor should create a new batch by default. const writer = new Writer();
writer.insert( element, position ); // works on the new batch It also solves the problem with methods and cases when a batch is not really needed. It was strange that you call At the same time, it means that writer, will not be able to fire The only inconvenience in the new solution is that you will have to use two writers if you want to have 2 separate undo steps. However, I think that:
|
Other: Refactor: engine/model reorganization, introducing new chnage and enqueueChange block, split batch/writer. Related: #1186.
Lets consider it closed by ckeditor/ckeditor5-engine@5be1ad6. Details will be handled in follow-up. |
In the PR which closes this issue:
We decided not to introducing |
At this point, we have a mess. The document is at the same time:
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).Also, 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).This is why I proposed to change the structure to this:
The current model writer class will be part of the batch API, the new writer will be more similar to the view writer.
The 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 bewriter#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.Note, 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.
Also, 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).
Another 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 theModel
class.The text was updated successfully, but these errors were encountered: