-
Notifications
You must be signed in to change notification settings - Fork 40
Move selection methods to Writer, protect DocumentSelection #1237
Conversation
Changes Unknown when pulling 8bddd7d on t/1209 into ** on master**. |
ff03f2a
to
a19980b
Compare
2704d59
to
d8029cf
Compare
src/model/documentselection.js
Outdated
|
||
/** | ||
* `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 |
There was a problem hiding this comment.
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.
src/model/documentselection.js
Outdated
/** | ||
* Document which owns this selection. | ||
* TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
src/model/liveselection.js
Outdated
@@ -0,0 +1,674 @@ | |||
/** |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/model/selection.js
Outdated
* | ||
* @fires change | ||
* @private | ||
*/ |
There was a problem hiding this comment.
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.
src/model/utils/deletecontent.js
Outdated
@@ -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 ); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ) { |
There was a problem hiding this comment.
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.
src/model/documentselection.js
Outdated
this._selection.destroy(); | ||
} | ||
|
||
getAttributeKeys() { |
There was a problem hiding this comment.
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. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Samples needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Selection constructor could use |
Suggested merge commit message (convention)
other: Moved selection methods to
Writer
, introducedLiveSelection
. Closes ckeditor/ckeditor5#4221.