-
-
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
Check whether it's optimal that selection updates its own attributes on #changesDone and #change:range #3597
Comments
Now we have two pieces of code in document: the https://github.com/ckeditor/ckeditor5-engine/blob/b13aadd0fc9b42e9fff70f7bb1b847ba14581ecc/src/treemodel/document.js#L86-L93. First: this.selection.on( 'change:range', () => {
this.selection._updateAttributes();
} ); Looks like a code which should be moved to the selection. It makes perfect sense for the selection to update attributes when we change ranges. Keeping this code in the document is... lets say "strange". Second: this.on( 'changesDone', () => {
this.selection._updateAttributes();
} ); Should be removed. If there is collapsed range in the text, without attributes ( |
Right now
|
I am afraid that event on I can't imagine that user has to manually fire some methods on However, I understand that the issue is important and urgent. Unfortunately it's hard to come up with completely different and satisfying solution. With no doubt,
This should guarantee that selection attributes correctness. We can also discuss efficiency:
However, in this issue, I'd focus on correctness and leave efficiency for other issue if we have problems with it. Anyway, it's worth noting, that |
Okay I gave it a little more thought and, hopefully, I have some kind of idea what should be changed. So I'll sum it up once again, because why not. First, rendering and enqueue changes blocks:
This all leads to the conclusion that:
|
About events.
As I wrote 2 posts above, |
What can I say... it will take me one day to read this :D. |
All you have to do is +1 me, bro. |
So how would you know when selection attribute has changed? There will be no robust way to listen to that.
Can't As for the rest, the plan sounds ok. I can't think of a better solution. |
I might forgot about it, but you would have to do it when listening on However. If there is no
It's not that important to me, so if it looks okay and works okay, it can be done this way. |
That's what we'd like to avoid :D.
I don't understand this, but I read it as "we can fire |
No, no, I just got confused and for a while thought that we might want to fire |
I am working on this issue. Core ideas are already implemented. What's left to do, are tests and refactor. Here's a quick summary of what will change and how:
What I don't like but will probably be left like this right now (and may need followup issues):
What's left to do:
I am pushing |
BTW Is there a simple way to differentiate between selection that was changed because user moved cursor and selection that changed because a text was inserted? |
Yes (there will be as a result of fixing this issue):
The event will have parameter with |
After writing manual test I discovered a bug (which may not be directly connected with the issue). When selection is collapsed and attribute is set on it, it is rendered, for example like this: Now, after a letter is typed, all ZWSes are removed aaaandd.. selection is moved to the end of paragraph... |
Quote from https://github.com/ckeditor/ckeditor5-core/pull/234
The text was updated successfully, but these errors were encountered: