-
-
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
Delete element attributes once it has any content #4104
Comments
@scofalik: Which batch should I used for that? It's not just selection's attributes here, but element's. |
We discussed this and checked how applying attributes to empty selection work in GDocs and in CKEditor 5. GDocs:
CKEditor 5:
So, our undo implementation and selection+attributes mechanisms are really good. |
This will be simple – we should use the batch in which the changes (inserting the content) were applied. We shouldn't touch transparent batches though to not break collaborative changes (they should've had this change already). BTW, attributes are already copied to the element if they are set on the selection. This is done by |
As I've already been suggesting - any "autofixing" callbacks on |
I realised that the fact that If we're fine with that, I'd implement the additional "remove attrs from element on change" inside |
I don't want to be that guy, but I wanted to call it |
Well, at this point this is a good point. AFAICS, we have just one I'd even remove OTOH, this is not the cleanest design... If we'd move the entire code to OTTH: |
I'd leave it as it is. No point in introducing mess to the project at this moment. |
The point is that someone may mistakenly clone |
PS. There's no |
OK, I made my mind:
Better solution for the future – |
On thing that I'd like to understand is why * _getStoredAttributes() {
const selectionParent = this.getFirstPosition().parent;
if ( this.isCollapsed && selectionParent.childCount === 0 ) {
for ( const key of selectionParent.getAttributeKeys() ) {
if ( key.indexOf( storePrefix ) === 0 ) {
const realKey = key.substr( storePrefix.length );
yield [ realKey, selectionParent.getAttribute( key ) ];
}
}
}
} If selection attributes are meant to only exist on empty elements, does this check make any sense? |
There's something wrong either with maaany tests (more likely) or with the E.g. all the + some comment that |
I can see that so far the last |
Another problem with Second thing – there's |
OK, I fixed part of the tests, but I find it suspicious that many of them fire the |
We know that, for now, the change event is a mess. In fact, it should be fired per-delta, not per-operation. It's a part of the big Refactoring: https://github.com/ckeditor/ckeditor5-engine/issues/679#issuecomment-276360352. |
It's because Instead of creating dummy batch in all tests, I've added |
OK, thx. I'll fix those tests which I can fix quickly so the code is hit enough. |
I can't fix some tests because they only mock operations (e.g. in liverange and liveposition tests) but the model is empty, so the check fails on trying to query |
Internal: Attributes which selection stores in elements should be removed once they are not empty any more. Closes #1001.
See https://github.com/ckeditor/ckeditor5-enter/issues/40:
And:
The text was updated successfully, but these errors were encountered: