-
-
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
Conversion: Re-converting the entire "thing" when it changes #6510
Comments
Another doubt that came to my mind: if we'd go with an API similar to what I mentioned, will features still be extensible? That worries me, but the truth is – they are not extensible currently. E.g. #2780 that's caused by the fact that implementer couldn't possibly know how to implement the media embed converter to make it extensible, or #507 which is hard to resolve because composing block features is super tricky due to the number of events and ways that would have to consider. |
Idea for sample/guide: some kind of icon with multiple attributes in the model and the view has conditional elements (depending on attribute value). The problem is that writing atomic converter for each attribute might be hard. Having one simple converter for the whole thing would ease that. Change of the attribute requires different rendering of the main element contents. For instance do not render some label/output if attribute is falsy - ie in a counter display only numeric values bigger then |
Slot conversion APITechnical Story: #7729 Context and Problem StatementConverting complex model->view structures... Decision Drivers
Considered Options
Pros and Cons of the OptionsOption 1: A
|
The base reconversion API using
|
Outdated. Current work is tracked in #10294 |
Background
How does conversion work right now? Whenever a thing changes in the model, we buffer those changes with the differ to get a minimal set of them and then convert those by saying how the view should change.
This makes converters extremely complex in cases where the model and view structures diverge (take lists, todo lists or tables). In fact, even in close to 1:1 cases like the image feature there's awful lot of complexity in them and very little flexibility.
We have an ongoing discussion whether the model and view structure should diverge in the first place. If they'd be identical, converters would be quite clear. However, then a lot of it would end up in commands and, from my experience, leak to other features too.
My experience from CKEditor 4 times is that a list feature itself adds tremendous amount of problems to other algorithms such as backspacing, the enter key, inserting new content, etc. You want to insert your image in the middle of a list so the list is split? Good luck! And I'm not joking – we've been regularly seeing issues with handling lists by backspace/enter in CKEditor 4 after 6 years since that code was written. That does not happen in CKEditor 5.
In CKEditor 5 we managed to keep nearly all the complexity in a single place which is the list converters. And when tested, we don't get back to that. It's there, it works, we can forget about it. I don't think that any other feature does anything special about lists. This is a huge win. Complexity is kept under the hood of this feature and we maintain nicely decoupled solution.
Of course, there are drawbacks too. For instance,
<ol/ul>
attributes are a problem because these elements do not exist in the model.Proposed direction
Quoting myself:
How could that look from code perspective? There are many possible APIs, but something that seems most imaginable today would look like this:
Of course, there's a lot that would have to happen under the hood and a inside createViewTable, but that'd be the gist.
That API, however, would not be sufficient to handle lists where there's no single "root". When a paragraph is inserted in the middle of a list (so, between two
listItem
s), the conversion of a model range (a fragment of the model) would have to triggered. This could be expressed like this:However, we could perhaps also change the list implementation so it would have a
<list>
wrapper, while still being flat (indentation kept as an attribute). In this case, the list converter would look like this:Of course, again, a lot of complexity would need to be handled by the conversion API, like reconverting the right things (markers?), handling re-mapping, consuming everything, etc. But that code is there today anyway and I hope it would be managable.
Doubts
I know that there are certain doubts about this direction. That's most likely the reason why it wasn't implemented this way in the first place.
The main doubts I heard are:
If you'd like to see this improvement implemented, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: