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

Move selection methods to Writer, protect DocumentSelection #1237

Merged
merged 61 commits into from
Jan 29, 2018
Merged

Conversation

ma2ciek
Copy link
Contributor

@ma2ciek ma2ciek commented Jan 15, 2018

Suggested merge commit message (convention)

other: Moved selection methods to Writer, introduced LiveSelection. Closes ckeditor/ckeditor5#4221.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.767% when pulling 2447683 on t/1209 into 47291eb on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.723% when pulling 92c91ce on t/1209 into 47291eb on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.723% when pulling a200add on t/1209 into 47291eb on master.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8bddd7d on t/1209 into ** on master**.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.752% when pulling 38bfce5 on t/1209 into e55814b on master.

@ma2ciek ma2ciek force-pushed the t/1209 branch 2 times, most recently from ff03f2a to a19980b Compare January 16, 2018 10:26
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.752% when pulling a19980b on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.752% when pulling a19980b on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.752% when pulling ea88b5f on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.767% when pulling e045b18 on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.796% when pulling 002738d on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.796% when pulling a012c2c on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.796% when pulling 25f275e on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.825% when pulling 6d4da68 on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.825% when pulling 504e221 on t/1209 into e55814b on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.839% when pulling 2bad633 on t/1209 into e55814b on master.

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 8e0feed on t/1209 into fd2f7c1 on master.

@ma2ciek ma2ciek force-pushed the t/1209 branch 2 times, most recently from 2704d59 to d8029cf Compare January 24, 2018 10:58

/**
* `DocumentSelection` is a special selection which is used as the
* {@link module:engine/model/document~Document#selection document's selection}.
* There can be only one instance of `DocumentSelection` per document.
*
* `DocumentSelection` is a proxy to {@link module:engine/model/liveselection~LiveSelection} that provides
Copy link

Choose a reason for hiding this comment

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

Live Selection should not be public and should not be mentioned in the documentation for public classes.

/**
* Document which owns this selection.
* TODO
Copy link

Choose a reason for hiding this comment

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

TODO

@@ -0,0 +1,674 @@
/**
Copy link

Choose a reason for hiding this comment

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

I would make LiveSelection private or protected. It should be used only by the DocumentSelection and could be even defined there.

Copy link

Choose a reason for hiding this comment

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

Both classed could go to the same file.

*
* @fires change
* @private
*/
Copy link

Choose a reason for hiding this comment

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

Private methods should go to the end of this file.

@@ -82,7 +83,11 @@ export default function deleteContent( model, selection, options = {} ) {
schema.removeDisallowedAttributes( startPos.parent.getChildren(), writer );
}

selection.setCollapsedAt( startPos );
if ( selection instanceof DocumentSelection ) {
selection._setTo( startPos );
Copy link

Choose a reason for hiding this comment

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

The writer should be used here.

/**
* Document which owns this selection.
* Selection used internally by that class (`DocumentSelection` is a proxy to that selection).
*
* @protected
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a very useful property in tests.

* @param {Number|'end'|'before'|'after'} [offset] Offset or one of the flags. Used only when
* first parameter is a {@link module:engine/model/item~Item model item}.
*/
_setFocus( itemOrPosition, offset ) {
Copy link

Choose a reason for hiding this comment

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

All protected method should go after all public methods.

this._selection.destroy();
}

getAttributeKeys() {
Copy link

Choose a reason for hiding this comment

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

Docs?


/**
* Sets attribute(s) on the selection. If attribute with the same key already is set, it's value is overwritten.
*
Copy link

Choose a reason for hiding this comment

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

Samples needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@ma2ciek ma2ciek changed the title Move selection methods to Writer, introduce LiveSelection Move selection methods to Writer, protect DocumentSelection Jan 26, 2018
@pjasiun
Copy link

pjasiun commented Jan 26, 2018

Selection constructor could use setTo and accepts all its parameters. Then we should be able to remove Selection.createFromSelection.

@pjasiun pjasiun merged commit 7db1fee into master Jan 29, 2018
@pjasiun pjasiun deleted the t/1209 branch January 29, 2018 11:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants