Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Fix: Prevented from losing selection attributes between operations - IME. #1730

Merged
merged 6 commits into from
Apr 23, 2019

Conversation

oskarwrobel
Copy link
Contributor

Suggested merge commit message (convention)

Fix: Prevented from losing selection attributes between operations - IME. Closes https://github.com/ckeditor/ckeditor5-typing/issues/188.


Additional information

Related ckeditor/ckeditor5-typing#189.

@coveralls
Copy link

coveralls commented Apr 21, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 01fa7f9 on t/ckeditor5-typing/188 into 8c39bdb on master.

@oskarwrobel oskarwrobel requested a review from Mgsy April 21, 2019 13:07
@Reinmar Reinmar requested a review from scofalik April 23, 2019 08:03
@Reinmar
Copy link
Member

Reinmar commented Apr 23, 2019

Let's be extremely cautious here. I assigned also @scofalik who worked the most on selection attributes.

Copy link
Member

@Mgsy Mgsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -391,6 +394,10 @@ export default class Document {

do {
for ( const callback of this._postFixers ) {
// Ensure selection attributes are up to date before each post-fixer.
// https://github.com/ckeditor/ckeditor5-engine/issues/1673.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add here additional comment on why it is done like this and not after every operation so we won't be re-thinking this problem again in a year.

/**
* Refreshes selection attributes and markers according to the current position in the model.
*/
refreshAttributes() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be named refresh().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or... different. It doesn't look good when refreshAttributes refreshes more than attributes. Or simply let's not wrap it in a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh() sounds ok. I was considering it.

@@ -313,6 +313,9 @@ export default class Document {
this.fire( 'change', writer.batch );
}

// Refresh selection attributes according to the final position in the model after the change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, the selection attributes are now not refreshed on change at all. Does it mean that the selection might have wrong attributes after last post-fixer changes it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be added as a change event callback. First because of that reason, second because I think it is better if there's less selection-related code directly in Document class. We already have a lot of listeners in DocumentSelection. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to Document class to not split the refreshes between two classes.

@@ -391,6 +394,10 @@ export default class Document {

do {
for ( const callback of this._postFixers ) {
// Ensure selection attributes are up to date before each post-fixer.
// https://github.com/ckeditor/ckeditor5-engine/issues/1673.
this.selection.refreshAttributes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like hard-coding it like this here but I can't find a better idea :(.

@@ -307,15 +307,15 @@ export default class Document {
if ( this._hasDocumentChangedFromTheLastChangeBlock() ) {
this._callPostFixers( writer );

// Refresh selection attributes according to the final position in the model after the change.
this.selection.refreshAttributes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be both before and after change event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, it should be not necessary. Changing the model on change event is not recommended, post fixers are the last who should change the model.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I missed something?

@pjasiun pjasiun merged commit 42dcb25 into master Apr 23, 2019
@pjasiun pjasiun deleted the t/ckeditor5-typing/188 branch April 23, 2019 12:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IME] Styling is lost after making composition with enabled inline style
6 participants