-
-
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
Pasting incorrect list is not fixed. #2979
Comments
After looking into this issue I confirm that the incorrect result is produced by post fixer. The thing is that in described case, source of "change" is clipboard and inserted data was already incorrect. This complicates things a bit because it is unclear where the fix should be applied. The post fixer is written in a way that it assumes that data in editor was correct, so we manipulate only correct data. This means that if there is a move of a range of 10 items, the range contents itself are correct. In the result, we only have to check boundaries (where the range was inserted and from where it was taken out). If we don't make that assumption, we have to check all inserted contents and move contents - and I mean literally all. Whenever anything is inserted or moved, the fixer would iterate through it. OTOH, right now the fixer is fired for every change too, but it does less, that for sure. The interesting part about this issue is that, for some reason, clipboard when pasting contents, uses separate <listItem type="bulleted" indent="1">a</listItem>
<listItem type="numbered" indent="1">b</listItem>
<listItem type="bulleted" indent="1">c</listItem> What post fixer does is:
So to prevent such scenario, we would have to find first previous item with same indent and use it as reference point. This is doable but takes more CPU time. Edit: since post fixer changes only attributes there is no threat of messing up with ranges (tree structure) so maybe we could also fire fixes without putting them in enqueueChanges block so they are applied immediately. However, if So the question I guess is: where do we really want to fix it? On the other hand if something generates such |
Another point is that we have And finally, I have another idea. In its heart, the problem is caused by incorrect DOM/HTML. We already fix incorrect DOM a bit in view to model converters: for example we remove elements not allowed by So to sum up:
This leads my to a conclusion that it will be best to make a fix that fixes just this problem as we know it and to choose a fix that will be least invasive, easy to implement and test and easy to remove later. That's why I would like to introduce the fix in view to model converter - unless I stumble on a problem or discover this won't work. |
The current implementation isn't weird. It's just KISS. The This is possible to improve this by scanning elements forward to retrieve all of allowed ones, but this shouldn't be necessary. This would only complicate the |
As for what to do... We can see that our Another topic is how "low" we'd like to implement the fixing mechanisms to be sure that the content never gets incorrect. We could put the code in Another question is whether it needs to be done on Therefore, I'm now leaning towards the following mental model:
Plus, there's one more thing. I had a problem even today that the content was rendered, but the model was completely incorrect. I had a We'll be fixing those algorithms, but I'd love if the schema was used to always validate the structure. I guess we can't do that immediately on every change, but perhaps we could do that on |
@scofalik, I guess you saw https://github.com/ckeditor/ckeditor5-engine/issues/858#issuecomment-289694808, but I'm posting it here for the future reference anyway :) |
There are many possible solutions and things we could introduce to solve some problems in whole or partially. AFAIR what @pjasiun meant there is that since nodes are immediately created in some kind of tree, there would be an event sent and then some kind of fixers might start their work. It is something but I don't know if it is more helpful than other presented solutions. |
Whenever someone mentions me at the bottom of the long conversation I have a feeling that you are trolling me ;) Anyway, I agree that it's not any revolutionizing change now you can use event dispatcher or tree walker, which will do the job in a few lines of code. Anyway, it's one more advantage of this change. |
I already suggested that fixing might be done on |
That's not what I meant, but it's interesting that we got back to this idea. What I meant was that the validation tool could be a part of our dev tools. It'd help us noticing that content went bad by logging errors to the console. Currently, we don't know anything about such issues, unless they start to throw during conversion. It'd also be great if this validator could always run, but I'm afraid that then we'd need to start considering performance and that would be a lot harder. So, first I turned towards dev tools to at least help at this stage. As for doing fixes by Schema's callbacks – I still have mixed feeling about this. That would be a unified API to perform such fixes, but I can't really imagine it. With change events and |
That's not what I meant.
I never said so. All I said that some
And it's fine now (and has to be like this now). But it could be theoretically also possible on |
Internal: List postfixer now looks at the first/last item of the list when fixing list item type. Closes #54.
Originally posted by @Reinmar in #2972.
I found the following case. I copied:
And got:
It's not OT related, but I'm not sure if you want to work on all possible scenarios at once or you predict that we'll be tackling them down one by one.
The text was updated successfully, but these errors were encountered: