8
0
Просмотр исходного кода

Usage of Selection and DocumentSelection in MutationObserver and SelectionObserver.

Szymon Kupś 7 лет назад
Родитель
Сommit
b9f1505736

+ 3 - 3
packages/ckeditor5-engine/src/view/observer/mutationobserver.js

@@ -10,7 +10,7 @@
 /* globals window */
 
 import Observer from './observer';
-import DocumentViewSelection from '../documentselection';
+import ViewSelection from '../selection';
 import { startsWithFiller, getDataWithoutFiller } from '../filler';
 import isEqualWith from '@ckeditor/ckeditor5-utils/src/lib/lodash/isEqualWith';
 
@@ -239,8 +239,8 @@ export default class MutationObserver extends Observer {
 
 			// Anchor and focus has to be properly mapped to view.
 			if ( viewSelectionAnchor && viewSelectionFocus ) {
-				viewSelection = new DocumentViewSelection( viewSelectionAnchor );
-				viewSelection._setFocus( viewSelectionFocus );
+				viewSelection = new ViewSelection( viewSelectionAnchor );
+				viewSelection.setFocus( viewSelectionFocus );
 			}
 		}
 

+ 2 - 2
packages/ckeditor5-engine/src/view/observer/selectionobserver.js

@@ -209,7 +209,7 @@ export default class SelectionObserver extends Observer {
  * @param {Object} data
  * @param {module:engine/view/documentselection~DocumentSelection} data.oldSelection Old View selection which is
  * {@link module:engine/view/document~Document#selection}.
- * @param {module:engine/view/documentselection~DocumentSelection} data.newSelection New View selection which is converted DOM selection.
+ * @param {module:engine/view/selection~Selection} data.newSelection New View selection which is converted DOM selection.
  * @param {Selection} data.domSelection Native DOM selection.
  */
 
@@ -226,6 +226,6 @@ export default class SelectionObserver extends Observer {
  * @param {Object} data
  * @param {module:engine/view/documentselection~DocumentSelection} data.oldSelection Old View selection which is
  * {@link module:engine/view/document~Document#selection}.
- * @param {module:engine/view/documentselection~DocumentSelection} data.newSelection New View selection which is converted DOM selection.
+ * @param {module:engine/view/selection~Selection} data.newSelection New View selection which is converted DOM selection.
  * @param {Selection} data.domSelection Native DOM selection.
  */

+ 4 - 3
packages/ckeditor5-engine/tests/view/observer/selectionobserver.js

@@ -7,7 +7,8 @@
 
 import ViewRange from '../../../src/view/range';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
-import ViewSelection from '../../../src/view/documentselection';
+import DocumentSelection from '../../../src/view/documentselection';
+import ViewSelection from '../../../src/view/selection';
 import View from '../../../src/view/view';
 import SelectionObserver from '../../../src/view/observer/selectionobserver';
 import FocusObserver from '../../../src/view/observer/focusobserver';
@@ -64,7 +65,7 @@ describe( 'SelectionObserver', () => {
 		viewDocument.on( 'selectionChange', ( evt, data ) => {
 			expect( data ).to.have.property( 'domSelection' ).that.equals( domDocument.getSelection() );
 
-			expect( data ).to.have.property( 'oldSelection' ).that.is.instanceof( ViewSelection );
+			expect( data ).to.have.property( 'oldSelection' ).that.is.instanceof( DocumentSelection );
 			expect( data.oldSelection.rangeCount ).to.equal( 0 );
 
 			expect( data ).to.have.property( 'newSelection' ).that.is.instanceof( ViewSelection );
@@ -265,7 +266,7 @@ describe( 'SelectionObserver', () => {
 				expect( spy.calledOnce ).to.true;
 				expect( data ).to.have.property( 'domSelection' ).to.equal( domDocument.getSelection() );
 
-				expect( data ).to.have.property( 'oldSelection' ).to.instanceof( ViewSelection );
+				expect( data ).to.have.property( 'oldSelection' ).to.instanceof( DocumentSelection );
 				expect( data.oldSelection.rangeCount ).to.equal( 0 );
 
 				expect( data ).to.have.property( 'newSelection' ).to.instanceof( ViewSelection );