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

Handling attributes, ranges and their changes in (Live)Selection. #634

Merged
merged 24 commits into from
Oct 18, 2016

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented Oct 17, 2016

Fixes ckeditor/ckeditor5#3597. See the issue for the list of changes.

Followup issue: ckeditor/ckeditor5#3847

Related PR: ckeditor/ckeditor5-core#31

scofalik and others added 19 commits October 13, 2016 12:01
Change log:
moved callbacks updating LiveSelection attributes to LiveSelection,
fixed events to fire only when range or attribute changed,
removed enqueueChanges blocks,
fixed attribute overwriting by _updateAttributes,
other minor fixes.
* Returns a default range for this selection. The default range is a collapsed range that starts and ends
* at the beginning of this selection's document's {@link engine.model.Document#_getDefaultRoot default root}.
*
* @protected
Copy link
Member

Choose a reason for hiding this comment

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

Is it protected or not?

Copy link
Member

Choose a reason for hiding this comment

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

According to @scofalik it is.

@@ -313,7 +306,7 @@ export default class Document {
* @protected
* @returns {engine.model.RootElement} The default root for this document.
*/
_getDefaultRoot() {
getDefaultRoot() {
Copy link
Member

Choose a reason for hiding this comment

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

Is it protected or not?

* Keeps mapping of attribute name to priority with which the attribute got modified (added/changed/removed)
* last time. Possible values of priority are: `'low'` and `'normal'`.
*
* Priorities are used by internal `LiveSelection` mechanisms. All attributes set using `LiveSelection`
Copy link
Member

Choose a reason for hiding this comment

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

You meant "The 'low' priority is used by..."?

Copy link
Member

Choose a reason for hiding this comment

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

In fact, what I meant by this comment was to ask for an explanation when low is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

low is being used when attributes are changed indirectly, that is through _updateAttributes.

Really, if you think is is overengineered I'll try to close this "logic" (that _updateAttributes clears only attributes set by itself) in _updateAttributes. IMHO it is over-engineered, but we may resolve this issue in ... spearate issue.

this.on( 'change:range', ( evt, data ) => {
if ( data.directChange ) {
// Reset attributes on selection (clear attributes and priorities).
//this._resetAttributes();
Copy link
Member

Choose a reason for hiding this comment

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

Missing space after //.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it seems to be a commented method call. Didn't you want to introduce this method?

Copy link
Member

Choose a reason for hiding this comment

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

In a separate comment, which I removed after a while, I wrote that _updateAttributes( true/false ) sounds like two separate methods, cause it isn't clear what it does with that param. It's okayish now, cause it's a priv stuff, but worth giving a short thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Te commented code is a mistake. Sorry for that.

As far as _updateAttributes is concerned, this issue may be resolved by simplifying LiveSelection internal logic and getting rid of priorities. I thought priorities, as a general solution, will be nice, but they got too clunky and even though I have those priorities, I still have to write some special code (like in _updateAttributes).

@@ -178,6 +178,11 @@ export class SchemaItem {

// Now we have to check every item name from the path to check.
for ( let checkName of checkPath ) {
// Don't check items that are not registered in schema.
if ( !this._schema.hasItem( checkName ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Missing test for this change.

@Reinmar
Copy link
Member

Reinmar commented Oct 17, 2016

I found one regression: https://github.com/ckeditor/ckeditor5-engine/issues/637.

@Reinmar
Copy link
Member

Reinmar commented Oct 17, 2016

The rest is fine – 100% CC, manual tests pass, etc. #637 needs to be changed in other piece of code, so it's independent.

@Reinmar
Copy link
Member

Reinmar commented Oct 17, 2016

@Reinmar
Copy link
Member

Reinmar commented Oct 17, 2016

I pushed manual test for #603 and checked that it's fully fixed by this PR. Cool!

@scofalik
Copy link
Contributor Author

I've pushed test for Schema and removed commented line of code.
As I understand #603 is fine white #589 and #462 are to-be-closed.
#637 is a different case and will be handled separately.

Does this mean that this PR is ready to be closed?

@Reinmar
Copy link
Member

Reinmar commented Oct 18, 2016

Another ticket which seemed to be fixed: https://github.com/ckeditor/ckeditor5-engine/issues/590.

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.

Check whether it's optimal that selection updates its own attributes on #changesDone and #change:range
2 participants